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

#include <DeleteComponentCmd.hh>

Inheritance diagram for DeleteComponentCmd:
Inheritance graph
Collaboration diagram for DeleteComponentCmd:
Collaboration graph

Public Member Functions

 DeleteComponentCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual DeleteComponentCmdcreate () const
 
virtual std::string shortName () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

wxCommand for deleting components from the Machine.

Definition at line 43 of file DeleteComponentCmd.hh.

Constructor & Destructor Documentation

◆ DeleteComponentCmd()

DeleteComponentCmd::DeleteComponentCmd ( )

The Constructor.

Definition at line 48 of file DeleteComponentCmd.cc.

48 :
50
51}
static const std::string CMD_NAME_DELETE_COMP
Command name for the "Delete Component" command.

Referenced by create().

Member Function Documentation

◆ create()

DeleteComponentCmd * DeleteComponentCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 116 of file DeleteComponentCmd.cc.

116 {
117 return new DeleteComponentCmd();
118}

References DeleteComponentCmd().

Here is the call graph for this function:

◆ Do()

bool DeleteComponentCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 61 of file DeleteComponentCmd.cc.

61 {
62
63 assert(parentWindow() != NULL);
64 assert(view() != NULL);
65
66 // send delete request to the selected EditPart
67 Request* deleteRequest = new Request(Request::DELETE_REQUEST);
68 EditPart* selected = dynamic_cast<MDFView*>(view())->selection();
69 if (selected == NULL) {
70 return false;
71 }
72
73 ComponentCommand* command = selected->performRequest(deleteRequest);
74
75 // execute the returned command
76 if (command == NULL) {
77 return false;
78 } else {
79 Model* model = dynamic_cast<MDFDocument*>(
80 wxGetApp().docManager()->GetCurrentDocument())->getModel();
81
82 model->pushToStack();
83
84 dynamic_cast<MDFView*>(view())->clearSelection();
85 bool result = command->Do();
86
87 if (result) {
88 // Model was modified.
89 model->notifyObservers();
90 } else {
91 // Command was cancelled.
92 model->popFromStack();
93 }
94 return result;
95 }
96}
#define assert(condition)
virtual bool Do()=0
ComponentCommand * performRequest(Request *request) const
Definition EditPart.cc:297
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
Definition Model.hh:50
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
void popFromStack(bool modified=false)
Definition Model.cc:195
@ DELETE_REQUEST
Delete request.
Definition Request.hh:49

References assert, Request::DELETE_REQUEST, ComponentCommand::Do(), Model::notifyObservers(), GUICommand::parentWindow(), EditPart::performRequest(), Model::popFromStack(), Model::pushToStack(), and EditorCommand::view().

Here is the call graph for this function:

◆ icon()

string DeleteComponentCmd::icon ( ) const
virtual

Returns path to the command's icon file.

Returns
Full path to the command's icon file.

Reimplemented from EditorCommand.

Definition at line 137 of file DeleteComponentCmd.cc.

137 {
139}
static const std::string CMD_ICON_DELETE_COMP
Icon location for the "Delete Component" command.

References ProDeConstants::CMD_ICON_DELETE_COMP.

◆ id()

int DeleteComponentCmd::id ( ) const
virtual

Returns command identifier of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 105 of file DeleteComponentCmd.cc.

References ProDeConstants::COMMAND_DELETE_COMP.

◆ isEnabled()

bool DeleteComponentCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a block is selected, and the block can handle a delete request.

Returns
True, if a deletable block is selected.

Reimplemented from EditorCommand.

Definition at line 152 of file DeleteComponentCmd.cc.

152 {
153 wxDocManager* manager = wxGetApp().docManager();
154
155 MDFView* mdfView = dynamic_cast<MDFView*>(manager->GetCurrentView());
156 if (mdfView == NULL) {
157 return false;
158 }
159 Request* deleteRequest = new Request(Request::DELETE_REQUEST);
160 if (mdfView->selection() == NULL ||
161 !mdfView->selection()->canHandle(deleteRequest)) {
162
163 return false;
164 }
165 delete deleteRequest;
166 return true;
167}
bool canHandle(Request *request) const
Definition EditPart.cc:316
EditPart * selection()
Definition MDFView.cc:169

References EditPart::canHandle(), Request::DELETE_REQUEST, and MDFView::selection().

Here is the call graph for this function:

◆ shortName()

string DeleteComponentCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 127 of file DeleteComponentCmd.cc.

127 {
129}
static const std::string CMD_SNAME_DELETE_COMP
Command name for the "Modify Component" command.

References ProDeConstants::CMD_SNAME_DELETE_COMP.


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