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

#include <OSEdAddModuleCmd.hh>

Inheritance diagram for OSEdAddModuleCmd:
Inheritance graph
Collaboration diagram for OSEdAddModuleCmd:
Collaboration graph

Public Member Functions

 OSEdAddModuleCmd ()
 
virtual ~OSEdAddModuleCmd ()
 
virtual int id () const
 
virtual GUICommandcreate () const
 
virtual bool Do ()
 
virtual bool isEnabled ()
 
virtual std::string icon () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Private Member Functions

 OSEdAddModuleCmd (const OSEdAddModuleCmd &)
 Copying not allowed.
 
OSEdAddModuleCmdoperator= (const OSEdAddModuleCmd &)
 Assignment not allowed.
 

Detailed Description

Command for adding new module to operation set.

Definition at line 43 of file OSEdAddModuleCmd.hh.

Constructor & Destructor Documentation

◆ OSEdAddModuleCmd() [1/2]

OSEdAddModuleCmd::OSEdAddModuleCmd ( )

Constructor.

Definition at line 57 of file OSEdAddModuleCmd.cc.

57 :
59}
static const std::string CMD_NAME_ADD_MODULE
Add module command name.

Referenced by create().

◆ ~OSEdAddModuleCmd()

OSEdAddModuleCmd::~OSEdAddModuleCmd ( )
virtual

Destructor.

Definition at line 64 of file OSEdAddModuleCmd.cc.

64 {
65}

◆ OSEdAddModuleCmd() [2/2]

OSEdAddModuleCmd::OSEdAddModuleCmd ( const OSEdAddModuleCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdAddModuleCmd::create ( ) const
virtual

Creates a new command.

Returns
New command.

Implements GUICommand.

Definition at line 83 of file OSEdAddModuleCmd.cc.

83 {
84 return new OSEdAddModuleCmd();
85}

References OSEdAddModuleCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdAddModuleCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful.

Implements GUICommand.

Definition at line 93 of file OSEdAddModuleCmd.cc.

93 {
94
95 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
96 OSEdTreeView* treeView = mainFrame->treeView();
97 string path = treeView->selectedPath();
99 wxTreeItemId pathId = treeView->selectedPathId();
101
102 if (!FileSystem::fileExists(path)) {
103 if (!FileSystem::createDirectory(path)) {
104 format fmt =
106 ErrorDialog error(
108 error.ShowModal();
109 return false;
110 }
111 index.addPath(path);
112 treeView->SetItemBold(pathId);
113 }
114
115 AddModuleDialog dialog(parentWindow(), path);
116 if (dialog.ShowModal() == wxID_OK) {
117
118 OperationModule* module = new OperationModule(dialog.name(), path);
119 OperationSerializer& serializer =
121 serializer.setDestinationFile(module->propertiesModule());
122 ObjectState* root = new ObjectState("osal");
123 try {
124 serializer.writeState(root);
125 } catch (const Exception& e) {
126 format fmt = texts.text(
128
129 ErrorDialog error(parentWindow(),
130 WxConversion::toWxString(fmt.str()));
131 error.ShowModal();
132 delete root;
133 return false;
134 }
135 delete root;
136 index.addModule(module, path);
137 treeView->addItem(pathId, module->name());
138 treeView->update();
139 }
140
141 return true;
142}
static bool createDirectory(const std::string &path)
static bool fileExists(const std::string fileName)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
OSEdTreeView * treeView() const
static OSEdTextGenerator & instance()
@ TXT_ERROR_CAN_NOT_CREATE_MOD
Error when can not create module.
void addItem(wxTreeItemId parent, std::string item)
std::string selectedPath()
wxTreeItemId selectedPathId()
static OperationSerializer & operationSerializer()
static OperationIndex & operationIndex()
void addModule(OperationModule *module, const std::string &path)
void addPath(const std::string &path)
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References OSEdTreeView::addItem(), OperationIndex::addModule(), OperationIndex::addPath(), FileSystem::createDirectory(), FileSystem::fileExists(), OSEdTextGenerator::instance(), OperationContainer::operationIndex(), OperationContainer::operationSerializer(), GUICommand::parentWindow(), OSEdTreeView::selectedPath(), OSEdTreeView::selectedPathId(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdMainFrame::treeView(), OSEdTextGenerator::TXT_ERROR_CAN_NOT_CREATE_MOD, and OSEdTreeView::update().

Here is the call graph for this function:

◆ icon()

string OSEdAddModuleCmd::icon ( ) const
virtual

Return icon path.

Returns
Empty string (no icons used).

Implements GUICommand.

Definition at line 181 of file OSEdAddModuleCmd.cc.

181 {
182 return "";
183}

◆ id()

int OSEdAddModuleCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 73 of file OSEdAddModuleCmd.cc.

73 {
75}
@ CMD_ADD_MODULE
Add module command id.

References OSEdConstants::CMD_ADD_MODULE.

◆ isEnabled()

bool OSEdAddModuleCmd::isEnabled ( )
virtual

Returns true if command is enabled.

Returns
True if command is enabled.

Implements GUICommand.

Definition at line 150 of file OSEdAddModuleCmd.cc.

150 {
151 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
152 string path = treeView->selectedPath();
153 if (path != "") {
154 if (FileSystem::fileExists(path)) {
155 string dumbFile = path + FileSystem::DIRECTORY_SEPARATOR +
156 "dumb12234";
157 if (FileSystem::createFile(dumbFile)) {
159 return true;
160 } else {
161 return false;
162 }
163 } else {
164 if (FileSystem::createDirectory(path)) {
166 return true;
167 } else {
168 return false;
169 }
170 }
171 }
172 return false;
173}
static bool createFile(const std::string &file)
static bool removeFileOrDirectory(const std::string &path)
static const std::string DIRECTORY_SEPARATOR

References FileSystem::createDirectory(), FileSystem::createFile(), FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), FileSystem::removeFileOrDirectory(), and OSEdTreeView::selectedPath().

Here is the call graph for this function:

◆ operator=()

OSEdAddModuleCmd & OSEdAddModuleCmd::operator= ( const OSEdAddModuleCmd )
private

Assignment not allowed.


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