OpenASIP  2.0
EditBusOrderCmd.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file EditBusOrderCmd.cc
26  *
27  * Definition of EditBusOrderCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 
34 #include <wx/docview.h>
35 
36 #include "EditBusOrderCmd.hh"
37 #include "ProDeConstants.hh"
38 #include "ProDeBusOrderDialog.hh"
39 #include "ProDe.hh"
40 #include "Model.hh"
41 #include "MDFDocument.hh"
42 #include "Machine.hh"
43 
44 using std::string;
45 
46 
47 /**
48  * The Constructor.
49  */
51  EditorCommand(ProDeConstants::CMD_NAME_EDIT_BUS_ORDER) {
52 }
53 
54 
55 /**
56  * The Destructor.
57  */
59 
60 
61 /**
62  * Executes the command.
63  *
64  * @return True, if the command was succesfully executed, false otherwise.
65  */
66 bool
68 
69  assert(parentWindow() != NULL);
70  assert(view() != NULL);
71 
72  Model* model = dynamic_cast<MDFDocument*>(
73  view()->GetDocument())->getModel();
74 
75  model->pushToStack();
76 
77  ProDeBusOrderDialog dialog(parentWindow(), *model->getMachine());
78 
79  if (dialog.ShowModal() == wxID_OK) {
80  model->notifyObservers();
81  return true;
82  } else {
83  // Cancel button was pressed, address spaces are not modified.
84  model->popFromStack();
85  return false;
86  }
87 }
88 
89 
90 /**
91  * Returns id of this command.
92  */
93 int
96 }
97 
98 
99 /**
100  * Creates and returns a new instance of this command.
101  */
104  return new EditBusOrderCmd();
105 }
106 
107 
108 /**
109  * Returns short version of the command name.
110  */
111 string
114 }
115 
116 
117 /**
118  * Returns true when the command is executable, false when not.
119  *
120  * This command is executable when a document is open.
121  *
122  * @return True, if a document is open.
123  */
124 bool
126  wxDocManager* manager = wxGetApp().docManager();
127  if (manager->GetCurrentView() != NULL) {
128  return true;
129  }
130  return false;
131 }
ProDe.hh
MDFDocument.hh
EditBusOrderCmd::shortName
virtual std::string shortName() const
Definition: EditBusOrderCmd.cc:112
ProDeConstants::CMD_SNAME_EDIT_ADDRESS_SPACES
static const std::string CMD_SNAME_EDIT_ADDRESS_SPACES
Command name for the "Edit Address Space" command.
Definition: ProDeConstants.hh:229
EditBusOrderCmd.hh
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditBusOrderCmd::id
virtual int id() const
Definition: EditBusOrderCmd.cc:94
EditBusOrderCmd::Do
virtual bool Do()
Definition: EditBusOrderCmd.cc:67
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ProDeBusOrderDialog.hh
EditBusOrderCmd::create
virtual EditBusOrderCmd * create() const
Definition: EditBusOrderCmd.cc:103
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
EditBusOrderCmd::~EditBusOrderCmd
virtual ~EditBusOrderCmd()
Definition: EditBusOrderCmd.cc:58
Model.hh
Machine.hh
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
EditBusOrderCmd
Definition: EditBusOrderCmd.hh:41
ProDeConstants::COMMAND_EDIT_BUS_ORDER
@ COMMAND_EDIT_BUS_ORDER
Definition: ProDeConstants.hh:444
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants.hh
ProDeBusOrderDialog
Definition: ProDeBusOrderDialog.hh:48
Model
Definition: Model.hh:50
EditBusOrderCmd::EditBusOrderCmd
EditBusOrderCmd()
Definition: EditBusOrderCmd.cc:50
EditBusOrderCmd::isEnabled
virtual bool isEnabled()
Definition: EditBusOrderCmd.cc:125
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88