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

#include <CopyComponentCmd.hh>

Inheritance diagram for CopyComponentCmd:
Inheritance graph
Collaboration diagram for CopyComponentCmd:
Collaboration graph

Public Member Functions

 CopyComponentCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual CopyComponentCmdcreate () 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
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

Command for copying machine components to the clipboard.

Definition at line 43 of file CopyComponentCmd.hh.

Constructor & Destructor Documentation

◆ CopyComponentCmd()

CopyComponentCmd::CopyComponentCmd ( )

The Constructor.

Definition at line 50 of file CopyComponentCmd.cc.

50 :
52}
static const std::string CMD_NAME_COPY
Command name for the "Copy" command.

Referenced by create().

Member Function Documentation

◆ create()

CopyComponentCmd * CopyComponentCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 108 of file CopyComponentCmd.cc.

108 {
109 return new CopyComponentCmd();
110}

References CopyComponentCmd().

Here is the call graph for this function:

◆ Do()

bool CopyComponentCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 62 of file CopyComponentCmd.cc.

62 {
63
64 assert(view() != NULL);
65
66 // send copy request to the selected EditPart
67 Request* copyRequest = new Request(Request::COPY_REQUEST);
68 EditPart* selected = dynamic_cast<MDFView*>(view())->selection();
69 if (selected == NULL) {
70 return false;
71 }
72 ComponentCommand* command = selected->performRequest(copyRequest);
73
74 // execute the returned command
75 if (command == NULL) {
76 return false;
77 } else {
78 dynamic_cast<MDFView*>(view())->clearSelection();
79 command->setParentWindow(parentWindow());
80
81 // Copying component to clipboard doesn't modify model.
82 // The model is not pushed into the undo stack.
83 bool result = command->Do();
84
85 return result;
86 }
87
88}
#define assert(condition)
virtual bool Do()=0
void setParentWindow(wxWindow *window)
ComponentCommand * performRequest(Request *request) const
Definition EditPart.cc:297
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
@ COPY_REQUEST
Copy request.
Definition Request.hh:51

References assert, Request::COPY_REQUEST, ComponentCommand::Do(), GUICommand::parentWindow(), EditPart::performRequest(), ComponentCommand::setParentWindow(), and EditorCommand::view().

Here is the call graph for this function:

◆ icon()

string CopyComponentCmd::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 120 of file CopyComponentCmd.cc.

120 {
122}
static const std::string CMD_ICON_COPY
Icon location for the "Copy" command.

References ProDeConstants::CMD_ICON_COPY.

◆ id()

int CopyComponentCmd::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 97 of file CopyComponentCmd.cc.

References ProDeConstants::COMMAND_COPY.

◆ isEnabled()

bool CopyComponentCmd::isEnabled ( )
virtual

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

This command is executable when a component is selected, and the selected component can be copied.

Returns
True, if a component is selected.

Reimplemented from EditorCommand.

Definition at line 135 of file CopyComponentCmd.cc.

135 {
136 wxDocManager* manager = wxGetApp().docManager();
137
138 MDFView* mdfView = dynamic_cast<MDFView*>(manager->GetCurrentView());
139 if (mdfView == NULL) {
140 return false;
141 }
142
143 EditPart* selected = mdfView->selection();
144 Request* copyRequest = new Request(Request::COPY_REQUEST);
145 if (selected == NULL || !(selected->canHandle(copyRequest))) {
146 delete copyRequest;
147 return false;
148 }
149 delete copyRequest;
150 return true;
151}
bool canHandle(Request *request) const
Definition EditPart.cc:316
EditPart * selection()
Definition MDFView.cc:169

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

Here is the call graph for this function:

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