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

#include <OSEdRemoveModuleCmd.hh>

Inheritance diagram for OSEdRemoveModuleCmd:
Inheritance graph
Collaboration diagram for OSEdRemoveModuleCmd:
Collaboration graph

Public Member Functions

 OSEdRemoveModuleCmd ()
 
virtual ~OSEdRemoveModuleCmd ()
 
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

 OSEdRemoveModuleCmd (const OSEdRemoveModuleCmd &)
 Copying not allowed.
 
OSEdRemoveModuleCmdoperator= (const OSEdRemoveModuleCmd &)
 Assignment not allowed.
 

Detailed Description

Command for removing a module.

Definition at line 43 of file OSEdRemoveModuleCmd.hh.

Constructor & Destructor Documentation

◆ OSEdRemoveModuleCmd() [1/2]

OSEdRemoveModuleCmd::OSEdRemoveModuleCmd ( )

Constructor.

Definition at line 58 of file OSEdRemoveModuleCmd.cc.

58 :
60}
static const std::string CMD_NAME_REMOVE_MODULE
Remove module command name.

Referenced by create().

◆ ~OSEdRemoveModuleCmd()

OSEdRemoveModuleCmd::~OSEdRemoveModuleCmd ( )
virtual

Destructor.

Definition at line 65 of file OSEdRemoveModuleCmd.cc.

65 {
66}

◆ OSEdRemoveModuleCmd() [2/2]

OSEdRemoveModuleCmd::OSEdRemoveModuleCmd ( const OSEdRemoveModuleCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdRemoveModuleCmd::create ( ) const
virtual

Returns a new command.

Returns
A new command.

Implements GUICommand.

Definition at line 84 of file OSEdRemoveModuleCmd.cc.

84 {
85 return new OSEdRemoveModuleCmd();
86}

References OSEdRemoveModuleCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdRemoveModuleCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful.

Implements GUICommand.

Definition at line 94 of file OSEdRemoveModuleCmd.cc.

94 {
95
97 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
98 string modName = treeView->selectedModule();
99 wxTreeItemId modId = treeView->selectedModuleId();
100 string path = treeView->pathOfModule(modId);
101
102 OperationModule& module = OperationContainer::module(path, modName);
103
105 fmt % modName;
107
108 if (dialog.ShowModal() == wxID_YES) {
109 bool removed =
110 FileSystem::removeFileOrDirectory(module.propertiesModule());
111 assert(removed == true);
112
113 if (module.hasBehaviorSource()) {
114 fmt = texts.text(
116
117 fmt % FileSystem::fileOfPath(module.behaviorSourceModule());
118
119 wxString confText = WxConversion::toWxString(fmt.str());
120 ConfirmDialog confirm(parentWindow(), confText);
121
122 if (confirm.ShowModal() == wxID_YES) {
123 FileSystem::removeFileOrDirectory(module.behaviorSourceModule());
124 }
125 }
126
127 if (module.definesBehavior()) {
128 FileSystem::removeFileOrDirectory(module.behaviorModule());
129 }
130
132 index.removeModule(path, modName);
133 treeView->removeItem(modId);
134 treeView->infoView()->moduleView(path);
135 }
136 return true;
137}
#define assert(condition)
static bool removeFileOrDirectory(const std::string &path)
static std::string fileOfPath(const std::string pathName)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
void moduleView(const std::string &name)
static OSEdTextGenerator & instance()
@ TXT_QUESTION_REMOVE_MODULE
Remove module question.
@ TXT_QUESTION_REMOVE_BEHAVIOR_FILE
Remove behavior question.
wxTreeItemId selectedModuleId()
std::string pathOfModule(wxTreeItemId id)
OSEdInfoView * infoView() const
void removeItem(wxTreeItemId id)
std::string selectedModule()
static OperationIndex & operationIndex()
void removeModule(const std::string &path, const std::string &modName)
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References assert, FileSystem::fileOfPath(), OSEdTreeView::infoView(), OSEdTextGenerator::instance(), OSEdInfoView::moduleView(), OperationContainer::operationIndex(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), FileSystem::removeFileOrDirectory(), OSEdTreeView::removeItem(), OperationIndex::removeModule(), OSEdTreeView::selectedModule(), OSEdTreeView::selectedModuleId(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_QUESTION_REMOVE_BEHAVIOR_FILE, and OSEdTextGenerator::TXT_QUESTION_REMOVE_MODULE.

Here is the call graph for this function:

◆ icon()

string OSEdRemoveModuleCmd::icon ( ) const
virtual

Returns icon path.

Returns
Empty string (no icons used).

Implements GUICommand.

Definition at line 169 of file OSEdRemoveModuleCmd.cc.

169 {
170 return "";
171}

◆ id()

int OSEdRemoveModuleCmd::id ( ) const
virtual

Returns the id of the command.

Returns
Id of the command.

Implements GUICommand.

Definition at line 74 of file OSEdRemoveModuleCmd.cc.

74 {
76}
@ CMD_REMOVE_MODULE
Remove module command id.

References OSEdConstants::CMD_REMOVE_MODULE.

◆ isEnabled()

bool OSEdRemoveModuleCmd::isEnabled ( )
virtual

Returns true if command is enabled.

Returns
True if command is enabled.

Implements GUICommand.

Definition at line 145 of file OSEdRemoveModuleCmd.cc.

145 {
146 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
147 if (treeView->isModuleSelected()) {
148 wxTreeItemId modId = treeView->selectedModuleId();
149 string path = treeView->pathOfModule(modId);
150 if (path != "") {
151 return FileSystem::fileIsWritable(path);
152 } else {
153 return false;
154 }
155 } else {
156 return false;
157 }
158
159 assert(false);
160 return false;
161}
static bool fileIsWritable(const std::string fileName)
bool isModuleSelected() const

References assert, FileSystem::fileIsWritable(), OSEdTreeView::isModuleSelected(), OSEdTreeView::pathOfModule(), and OSEdTreeView::selectedModuleId().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


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