OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BlockImplementationFileDialog Class Reference

#include <BlockImplementationFileDialog.hh>

Inheritance diagram for BlockImplementationFileDialog:
Inheritance graph
Collaboration diagram for BlockImplementationFileDialog:
Collaboration graph

Public Member Functions

 BlockImplementationFileDialog (wxWindow *parent, wxWindowID id, HDB::BlockImplementationFile &file)
 
virtual ~BlockImplementationFileDialog ()
 

Private Types

enum  {
  ID_LABEL_PATH = 10000 , ID_PATH , ID_LABEL_FORMAT , ID_FORMAT ,
  ID_BROWSE , ID_LINE
}
 Enumerated IDs for dialog widgets. More...
 

Private Member Functions

void onBrowse (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 Creates the dialog contents.
 

Private Attributes

HDB::BlockImplementationFilefile_
 BlockImplementationFile object to modify.
 
wxString path_
 Block implementation file path.
 
int format_
 Selected implementation file type.
 

Detailed Description

Dialog for editing BlockImplementationFile objects.

Definition at line 44 of file BlockImplementationFileDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ BlockImplementationFileDialog()

BlockImplementationFileDialog::BlockImplementationFileDialog ( wxWindow *  parent,
wxWindowID  id,
HDB::BlockImplementationFile file 
)

The Constructor.

Parameters
parentParent window of the dialog.
idWindow identifier for the dialog window.
fileBlockImplementationFile object to modify.

Definition at line 64 of file BlockImplementationFileDialog.cc.

65 :
66 wxDialog(parent, id, _T("Parameter")),
67 file_(file) {
68
69 createContents(this, true, true);
70
73
74 FindWindow(ID_PATH)->SetValidator(wxTextValidator(wxFILTER_ASCII, &path_));
75 FindWindow(ID_FORMAT)->SetValidator(wxGenericValidator(&format_));
76
77 TransferDataToWindow();
78}
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Creates the dialog contents.
wxString path_
Block implementation file path.
int format_
Selected implementation file type.
HDB::BlockImplementationFile & file_
BlockImplementationFile object to modify.
static wxString toWxString(const std::string &source)

References WxConversion::toWxString().

Here is the call graph for this function:

◆ ~BlockImplementationFileDialog()

BlockImplementationFileDialog::~BlockImplementationFileDialog ( )
virtual

The Destructor.

Definition at line 84 of file BlockImplementationFileDialog.cc.

84 {
85}

Member Function Documentation

◆ createContents()

wxSizer * BlockImplementationFileDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog contents.

Creates the dialog contents.

Definition at line 185 of file BlockImplementationFileDialog.cc.

186 {
187
188 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
189
190 wxFlexGridSizer *item1 = new wxFlexGridSizer( 3, 0, 0 );
191
192 wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_PATH, wxT("Path:"), wxDefaultPosition, wxDefaultSize, 0 );
193 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
194
195 wxTextCtrl *item3 = new wxTextCtrl( parent, ID_PATH, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
196 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
197
198 wxButton *item4 = new wxButton( parent, ID_BROWSE, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
199 item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
200
201 wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_FORMAT, wxT("Format:"), wxDefaultPosition, wxDefaultSize, 0 );
202 item1->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
203
204 wxString strs6[] =
205 {
206 wxT("VHDL"),
207 wxT("Verilog")
208 };
209 wxChoice *item6 = new wxChoice( parent, ID_FORMAT, wxDefaultPosition, wxSize(100,-1), 2, strs6, 0 );
210 item1->Add( item6, 0, wxGROW|wxALL, 5 );
211
212 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
213
214 wxStaticLine *item7 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
215 item0->Add( item7, 0, wxGROW|wxALL, 5 );
216
217 wxBoxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
218
219 wxButton *item9 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
220 item8->Add( item9, 0, wxALL, 5 );
221
222 wxButton *item10 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
223 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
224
225 item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
226
227 if (set_sizer)
228 {
229 parent->SetSizer( item0 );
230 if (call_fit)
231 item0->SetSizeHints( parent );
232 }
233
234 return item0;
235}

References ID_BROWSE, ID_FORMAT, ID_LABEL_FORMAT, ID_LABEL_PATH, ID_LINE, and ID_PATH.

◆ onBrowse()

void BlockImplementationFileDialog::onBrowse ( wxCommandEvent &  event)
private

Event handler for the Browse-button.

Displays a wxFileDialog for selecting the implementation file.

Definition at line 93 of file BlockImplementationFileDialog.cc.

93 {
94
95 const HDBManager& manager = *wxGetApp().mainFrame().hdbManager();
96 std::string hdbPath = manager.fileName();
97 wxString defaultDir = WxConversion::toWxString(
98 FileSystem::directoryOfPath(manager.fileName()).c_str());
99
100 wxFileDialog dialog(
101 this, _T("Choose a file"), defaultDir, _T(""),
102 _T("VHDL files (*.vhd;*.vhdl)|*.vhd;*.vhdl|Verilog files (*.v)|*.v| All files (*.*)|*.*"),
103 (wxOPEN | wxFILE_MUST_EXIST));
104
105 wxChoice *hdl_type = (wxChoice *)FindWindow(ID_FORMAT);
106 dialog.SetFilterIndex(hdl_type->GetCurrentSelection());
107
108 if (dialog.ShowModal() == wxID_OK) {
109
110 std::string filename = WxConversion::toString(dialog.GetPath());
111 std::string vhdlPath = FileSystem::directoryOfPath(filename);
112 std::vector<std::string> vhdlPaths = Environment::vhdlPaths(hdbPath);
113
114 for (std::vector<std::string>::iterator it = vhdlPaths.begin();
115 it != vhdlPaths.end(); ++it) {
116 // check if VHDL path is relative to one of the search paths.
117 if (vhdlPath.substr(0, (*it).length()) == *it) {
118
119 filename = filename.substr((*it).length() + 1);
120 break;
121 }
122 }
123
125 TransferDataToWindow();
126 }
127}
static std::vector< std::string > vhdlPaths(const std::string &hdbPath)
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
std::string fileName() const
static std::string toString(const wxString &source)

References FileSystem::directoryOfPath(), HDB::HDBManager::fileName(), ID_FORMAT, path_, WxConversion::toString(), WxConversion::toWxString(), and Environment::vhdlPaths().

Here is the call graph for this function:

◆ onOK()

void BlockImplementationFileDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the dialog OK-button.

Definition at line 134 of file BlockImplementationFileDialog.cc.

134 {
135
136 TransferDataFromWindow();
137
138 path_ = path_.Trim(true).Trim(false);
139
140 if (path_.IsEmpty()) {
141 wxString message = _T("Path field must not be empty.");
142 ErrorDialog dialog(this, message);
143 dialog.ShowModal();
144 return;
145 }
146
147 // Attempt to find the file in search paths
148 const HDBManager& manager = *wxGetApp().mainFrame().hdbManager();
149
150 std::string hdbPath = manager.fileName();
151 std::vector<std::string> vhdlPaths =
152 Environment::vhdlPaths(hdbPath);
153 try {
154 std::string filename =
156 vhdlPaths, WxConversion::toString(path_));
157
158 for (std::vector<std::string>::iterator it = vhdlPaths.begin();
159 it != vhdlPaths.end(); ++it) {
160 if (filename.substr(0, (*it).length()) == *it) {
162 << filename << " in search path " << *it << std::endl;
163 filename = filename.substr((*it).length() + 1);
165 break;
166 }
167 }
168 } catch (FileNotFound const& f) {
169 wxString message = _T("File not found from the VHDL search paths.");
170 ErrorDialog dialog(this, message);
171 dialog.ShowModal();
172 return;
173 }
174
177
178 EndModal(wxID_OK);
179}
static std::ostream & logStream()
static std::string findFileInSearchPaths(const std::vector< std::string > &searchPaths, const std::string &file)
void setPathToFile(const std::string &pathToFile)

References file_, HDB::HDBManager::fileName(), FileSystem::findFileInSearchPaths(), format_, Application::logStream(), path_, HDB::BlockImplementationFile::setFormat(), HDB::BlockImplementationFile::setPathToFile(), WxConversion::toString(), WxConversion::toWxString(), and Environment::vhdlPaths().

Here is the call graph for this function:

Member Data Documentation

◆ file_

HDB::BlockImplementationFile& BlockImplementationFileDialog::file_
private

BlockImplementationFile object to modify.

Definition at line 69 of file BlockImplementationFileDialog.hh.

Referenced by onOK().

◆ format_

int BlockImplementationFileDialog::format_
private

Selected implementation file type.

Definition at line 74 of file BlockImplementationFileDialog.hh.

Referenced by onOK().

◆ path_

wxString BlockImplementationFileDialog::path_
private

Block implementation file path.

Definition at line 72 of file BlockImplementationFileDialog.hh.

Referenced by onBrowse(), and onOK().


The documentation for this class was generated from the following files: