OpenASIP  2.0
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. More...
 
OSEdRemoveModuleCmdoperator= (const OSEdRemoveModuleCmd &)
 Assignment not allowed. More...
 

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.

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 =
111  assert(removed == true);
112 
113  if (module.hasBehaviorSource()) {
114  fmt = texts.text(
116 
118 
119  wxString confText = WxConversion::toWxString(fmt.str());
120  ConfirmDialog confirm(parentWindow(), confText);
121 
122  if (confirm.ShowModal() == wxID_YES) {
124  }
125  }
126 
127  if (module.definesBehavior()) {
129  }
130 
132  index.removeModule(path, modName);
133  treeView->removeItem(modId);
134  treeView->infoView()->moduleView(path);
135  }
136  return true;
137 }

References assert, OperationModule::behaviorModule(), OperationModule::behaviorSourceModule(), OperationModule::definesBehavior(), FileSystem::fileOfPath(), OperationModule::hasBehaviorSource(), OSEdTreeView::infoView(), OSEdTextGenerator::instance(), OperationContainer::module(), OSEdInfoView::moduleView(), OperationContainer::operationIndex(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationModule::propertiesModule(), 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 }

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 }

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:
OSEdTreeView::selectedModule
std::string selectedModule()
Definition: OSEdTreeView.cc:513
OperationModule::definesBehavior
virtual bool definesBehavior() const
Definition: OperationModule.cc:93
OSEdTreeView::selectedModuleId
wxTreeItemId selectedModuleId()
Definition: OSEdTreeView.cc:537
WxConversion::toWxString
static wxString toWxString(const std::string &source)
FileSystem::removeFileOrDirectory
static bool removeFileOrDirectory(const std::string &path)
Definition: FileSystem.cc:493
OSEdTreeView::removeItem
void removeItem(wxTreeItemId id)
Definition: OSEdTreeView.cc:622
OSEdTreeView::pathOfModule
std::string pathOfModule(wxTreeItemId id)
Definition: OSEdTreeView.cc:431
OperationContainer::module
static OperationModule & module(const std::string &path, const std::string &mod)
Definition: OperationContainer.cc:148
OperationModule::behaviorModule
virtual std::string behaviorModule() const
Definition: OperationModule.cc:105
OSEdTreeView::infoView
OSEdInfoView * infoView() const
Definition: OSEdTreeView.cc:662
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
FileSystem::fileOfPath
static std::string fileOfPath(const std::string pathName)
Definition: FileSystem.cc:101
OSEdInfoView::moduleView
void moduleView(const std::string &name)
Definition: OSEdInfoView.cc:129
assert
#define assert(condition)
Definition: Application.hh:86
OperationModule::propertiesModule
virtual std::string propertiesModule() const
Definition: OperationModule.cc:121
FileSystem::fileIsWritable
static bool fileIsWritable(const std::string fileName)
OSEdConstants::CMD_REMOVE_MODULE
@ CMD_REMOVE_MODULE
Remove module command id.
Definition: OSEdConstants.hh:95
OSEdTreeView
Definition: OSEdTreeView.hh:54
OperationModule::behaviorSourceModule
virtual std::string behaviorSourceModule() const
Definition: OperationModule.cc:144
OSEdTreeView::isModuleSelected
bool isModuleSelected() const
Definition: OSEdTreeView.cc:731
ConfirmDialog
Definition: ConfirmDialog.hh:41
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
OperationModule
Definition: OperationModule.hh:46
OperationModule::hasBehaviorSource
virtual bool hasBehaviorSource() const
Definition: OperationModule.cc:131
OperationIndex
Definition: OperationIndex.hh:58
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OperationIndex::removeModule
void removeModule(const std::string &path, const std::string &modName)
Definition: OperationIndex.cc:212
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OSEdRemoveModuleCmd::OSEdRemoveModuleCmd
OSEdRemoveModuleCmd()
Definition: OSEdRemoveModuleCmd.cc:58
OperationContainer::operationIndex
static OperationIndex & operationIndex()
Definition: OperationContainer.cc:94
OSEdTextGenerator::TXT_QUESTION_REMOVE_MODULE
@ TXT_QUESTION_REMOVE_MODULE
Remove module question.
Definition: OSEdTextGenerator.hh:208
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
OSEdTextGenerator::TXT_QUESTION_REMOVE_BEHAVIOR_FILE
@ TXT_QUESTION_REMOVE_BEHAVIOR_FILE
Remove behavior question.
Definition: OSEdTextGenerator.hh:209
OSEdConstants::CMD_NAME_REMOVE_MODULE
static const std::string CMD_NAME_REMOVE_MODULE
Remove module command name.
Definition: OSEdConstants.hh:69