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

#include <OSEdPropertiesCmd.hh>

Inheritance diagram for OSEdPropertiesCmd:
Inheritance graph
Collaboration diagram for OSEdPropertiesCmd:
Collaboration graph

Public Member Functions

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

 OSEdPropertiesCmd (const OSEdPropertiesCmd &)
 Copying not allowed.
 
OSEdPropertiesCmdoperator= (const OSEdPropertiesCmd &)
 Assignment not allowed.
 

Detailed Description

Executes the command when operation is modified.

Definition at line 43 of file OSEdPropertiesCmd.hh.

Constructor & Destructor Documentation

◆ OSEdPropertiesCmd() [1/2]

OSEdPropertiesCmd::OSEdPropertiesCmd ( )

Constructor.

Definition at line 62 of file OSEdPropertiesCmd.cc.

62 :
64}
static const std::string CMD_NAME_PROPERTIES
Operation properties command name.

Referenced by create().

◆ ~OSEdPropertiesCmd()

OSEdPropertiesCmd::~OSEdPropertiesCmd ( )
virtual

Destructor.

Definition at line 69 of file OSEdPropertiesCmd.cc.

69 {
70}

◆ OSEdPropertiesCmd() [2/2]

OSEdPropertiesCmd::OSEdPropertiesCmd ( const OSEdPropertiesCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdPropertiesCmd::create ( ) const
virtual

Creates a new command.

Returns
The created command.

Implements GUICommand.

Definition at line 88 of file OSEdPropertiesCmd.cc.

88 {
89 return new OSEdPropertiesCmd();
90}

References OSEdPropertiesCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdPropertiesCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful, false otherwise.

Implements GUICommand.

Definition at line 98 of file OSEdPropertiesCmd.cc.

98 {
99
101 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
102 OSEdTreeView* treeView = mainFrame->treeView();
103 Operation* op = treeView->selectedOperation();
104 string opName = op->name();
105 wxTreeItemId opId = treeView->selectedOperationId();
106 string modName = treeView->moduleOfOperation(opId);
107 wxTreeItemId modId = treeView->moduleIdOfOperation(opId);
108 string pathName = treeView->pathOfModule(modId);
109 OperationModule& module = OperationContainer::module(pathName, modName);
110
112
113 if (!FileSystem::fileIsWritable(module.propertiesModule())) {
116 error.ShowModal();
117 delete op;
118 return false;
119 } else {
120 OperationPropertyDialog dialog(parentWindow(), op, module, pathName);
121 ObjectState* orig = op->saveState();
122 if (dialog.ShowModal() == wxID_OK) {
123
124 ObjectState* mod = op->saveState();
125 if (*mod != *orig) {
126 // write operation properties to file
127 OperationSerializer& serializer =
129 serializer.setSourceFile(module.propertiesModule());
130 ObjectState* root = NULL;
131 try {
132 root = serializer.readState();
133 for (int i = 0; i < root->childCount(); i++) {
134 ObjectState* child = root->child(i);
135 if (child->stringAttribute("name") == opName) {
136 root->replaceChild(child, op->saveState());
137 break;
138 }
139 }
140 serializer.setDestinationFile(module.propertiesModule());
141 serializer.writeState(root);
142 } catch (const Exception& s) {
143 format fmt =
145 ErrorDialog eDialog(
147 eDialog.ShowModal();
148 }
149 delete root;
150
151 // update the tree.
152 if (opName != op->name()) {
154 index.refreshModule(pathName, modName);
155 treeView->changeText(opId, op->name());
156 }
157
158 treeView->update();
159 }
160 delete mod;
161 }
162 delete orig;
163 delete op;
164 return true;
165 }
166
167 assert(false);
168 return false;
169}
#define assert(condition)
static bool fileIsWritable(const std::string fileName)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static NullOperationModule & instance()
OSEdTreeView * treeView() const
static OSEdTextGenerator & instance()
@ TXT_ERROR_CAN_NOT_MODIFY
Error when can not modify.
std::string pathOfModule(wxTreeItemId id)
void changeText(wxTreeItemId id, const std::string &text)
wxTreeItemId selectedOperationId()
Operation * selectedOperation()
wxTreeItemId moduleIdOfOperation(wxTreeItemId id)
std::string moduleOfOperation(wxTreeItemId id)
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
void replaceChild(ObjectState *old, ObjectState *newChild)
int childCount() const
static OperationSerializer & operationSerializer()
static OperationIndex & operationIndex()
void refreshModule(const std::string &path, const std::string &modName)
void setSourceFile(const std::string &filename)
virtual void writeState(const ObjectState *state)
void setDestinationFile(const std::string &filename)
virtual ObjectState * readState()
virtual TCEString name() const
Definition Operation.cc:93
virtual ObjectState * saveState() const
Definition Operation.cc:490
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References assert, OSEdTreeView::changeText(), ObjectState::child(), ObjectState::childCount(), FileSystem::fileIsWritable(), NullOperationModule::instance(), OSEdTextGenerator::instance(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::moduleOfOperation(), Operation::name(), OperationContainer::operationIndex(), OperationContainer::operationSerializer(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationSerializer::readState(), OperationIndex::refreshModule(), ObjectState::replaceChild(), Operation::saveState(), OSEdTreeView::selectedOperation(), OSEdTreeView::selectedOperationId(), OperationSerializer::setDestinationFile(), OperationSerializer::setSourceFile(), ObjectState::stringAttribute(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdMainFrame::treeView(), OSEdTextGenerator::TXT_ERROR_CAN_NOT_MODIFY, OSEdTreeView::update(), and OperationSerializer::writeState().

Here is the call graph for this function:

◆ icon()

string OSEdPropertiesCmd::icon ( ) const
virtual

Returns the icon path.

Returns
Empty string (icons not used).

Implements GUICommand.

Definition at line 194 of file OSEdPropertiesCmd.cc.

194 {
195 return "";
196}

◆ id()

int OSEdPropertiesCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 78 of file OSEdPropertiesCmd.cc.

78 {
80}
@ CMD_PROPERTIES
Operation properties command id.

References OSEdConstants::CMD_PROPERTIES.

◆ isEnabled()

bool OSEdPropertiesCmd::isEnabled ( )
virtual

Returns true, if command is enabled.

Returns
True, if command is enabled.

Implements GUICommand.

Definition at line 177 of file OSEdPropertiesCmd.cc.

177 {
178 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
179 Operation* op = treeView->selectedOperation();
180 if (op != NULL) {
181 delete op;
182 return true;
183 } else {
184 return false;
185 }
186}

References OSEdTreeView::selectedOperation().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


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