OpenASIP  2.0
EditImmediateSlotsCmd.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 EditImmediateSlotsCmd.cc
26  *
27  * Definition of EditImmediateSlotsCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/docview.h>
34 
35 #include "EditImmediateSlotsCmd.hh"
36 #include "ProDeConstants.hh"
37 #include "ImmediateSlotDialog.hh"
38 #include "ProDe.hh"
39 #include "Model.hh"
40 #include "MDFDocument.hh"
41 
42 using std::string;
43 
44 
45 /**
46  * The Constructor.
47  */
49  EditorCommand(ProDeConstants::CMD_NAME_EDIT_IMMEDIATE_SLOTS) {
50 }
51 
52 
53 /**
54  * The Destructor.
55  */
57 
58 
59 /**
60  * Executes the command.
61  *
62  * @return True, if the command was succesfully executed, false otherwise.
63  */
64 bool
66 
67  assert(parentWindow() != NULL);
68  assert(view() != NULL);
69 
70  Model* model = dynamic_cast<MDFDocument*>(
71  view()->GetDocument())->getModel();
72 
73  model->pushToStack();
74 
75  ImmediateSlotDialog dialog(parentWindow(), model->getMachine());
76 
77  if (dialog.ShowModal() == wxID_OK) {
78  model->notifyObservers();
79  return true;
80  } else {
81  // Cancel button was pressed, immediate slot modifications are
82  // cancelled.
83  model->popFromStack();
84  return false;
85  }
86 }
87 
88 
89 /**
90  * Returns id of this command.
91  */
92 int
95 }
96 
97 
98 /**
99  * Creates and returns a new instance of this command.
100  */
103  return new EditImmediateSlotsCmd();
104 }
105 
106 
107 
108 /**
109  * Returns path to the command's icon file.
110  */
111 string
114 }
115 
116 
117 /**
118  * Returns short version of the command name.
119  */
120 string
123 }
124 
125 
126 /**
127  * Returns true when the command is executable, false when not.
128  *
129  * This command is executable when a document is open.
130  *
131  * @return True, if a document is open.
132  */
133 bool
135  wxDocManager* manager = wxGetApp().docManager();
136  if (manager->GetCurrentView() != NULL) {
137  return true;
138  }
139  return false;
140 }
EditImmediateSlotsCmd
Definition: EditImmediateSlotsCmd.hh:41
ProDe.hh
EditImmediateSlotsCmd::~EditImmediateSlotsCmd
virtual ~EditImmediateSlotsCmd()
Definition: EditImmediateSlotsCmd.cc:56
MDFDocument.hh
EditImmediateSlotsCmd::shortName
virtual std::string shortName() const
Definition: EditImmediateSlotsCmd.cc:121
EditImmediateSlotsCmd::isEnabled
virtual bool isEnabled()
Definition: EditImmediateSlotsCmd.cc:134
EditImmediateSlotsCmd::EditImmediateSlotsCmd
EditImmediateSlotsCmd()
Definition: EditImmediateSlotsCmd.cc:48
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditImmediateSlotsCmd.hh
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
EditImmediateSlotsCmd::create
virtual EditImmediateSlotsCmd * create() const
Definition: EditImmediateSlotsCmd.cc:102
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
EditImmediateSlotsCmd::icon
virtual std::string icon() const
Definition: EditImmediateSlotsCmd.cc:112
Model.hh
ImmediateSlotDialog.hh
EditImmediateSlotsCmd::id
virtual int id() const
Definition: EditImmediateSlotsCmd.cc:93
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
ProDeConstants::COMMAND_EDIT_IMMEDIATE_SLOTS
@ COMMAND_EDIT_IMMEDIATE_SLOTS
Definition: ProDeConstants.hh:443
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants.hh
ProDeConstants::CMD_ICON_DEFAULT
static const std::string CMD_ICON_DEFAULT
Icon path for default icon of commands.
Definition: ProDeConstants.hh:286
EditImmediateSlotsCmd::Do
virtual bool Do()
Definition: EditImmediateSlotsCmd.cc:65
Model
Definition: Model.hh:50
ImmediateSlotDialog
Definition: ImmediateSlotDialog.hh:47
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
ProDeConstants::CMD_SNAME_EDIT_IMMEDIATE_SLOTS
static const std::string CMD_SNAME_EDIT_IMMEDIATE_SLOTS
Command name for the "Edit Immediate slots" command.
Definition: ProDeConstants.hh:237
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88