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