OpenASIP 2.2
Loading...
Searching...
No Matches
ProximQuitCmd.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 ProximQuitCmd.cc
26 *
27 * Implementation of ProximQuitCmd class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include "ProximQuitCmd.hh"
34#include "ProximConstants.hh"
35#include "Proxim.hh"
38#include "ConfirmDialog.hh"
39#include "GUIOptions.hh"
41#include "ErrorDialog.hh"
42#include "WxConversion.hh"
43#include "Exception.hh"
44#include "ProximToolbox.hh"
45#include "Environment.hh"
46
47/**
48 * The Constructor.
49 */
55
56/**
57 * The Destructor.
58 */
61
62
63/**
64 * Executes the command.
65 *
66 * @return True, if the command was succesfully executed.
67 */
68bool
70
71 assert(parentWindow() != NULL);
72
74 wxString message = _T("Simulation is still running.\n");
75 message.Append(_T("Are you sure you want to stop the simulation "));
76 message.Append(_T("and quit?"));
77 ConfirmDialog dialog(parentWindow(), message);
78
79 if (dialog.ShowModal() != wxID_YES) {
80 return false;
81 }
82
83 wxGetApp().simulation()->finishSimulation();
84 }
85
86 GUIOptions& options = wxGetApp().options();
87 if (options.isModified()) {
88 wxString message = _T("Options are modified.\n");
89 message.Append(_T("Do you want to save changes?"));
90 ConfirmDialog dialog(parentWindow(), message);
91
92 int returnValue = dialog.ShowModal();
93 if (returnValue == wxID_YES) {
94
96 try {
97 writer.setDestinationFile(
98 Environment::userConfPath("Proxim.conf"));
99 writer.writeOptions(options);
100 options.clearModified();
101 } catch (Exception& e) {
102 wxString message = _T("Error saving options:\n\n");
103 message.Append(WxConversion::toWxString(e.errorMessage()));
104 ErrorDialog errorDialog(parentWindow(), message);
105 errorDialog.ShowModal();
106 return false;
107 }
108 } else if (returnValue == wxID_CANCEL) {
109 return false;
110 }
111 }
112
114
115 return true;
116}
117
118
119/**
120 * Returns full path to the command icon file.
121 *
122 * @return Full path to the command icon file.
123 */
124std::string
126 return "quit.png";
127}
128
129
130/**
131 * Returns ID of this command.
132 */
133int
137
138
139/**
140 * Creates and returns a new isntance of this command.
141 *
142 * @return Newly created instance of this command.
143 */
146 return new ProximQuitCmd();
147}
148
149
150/**
151 * Returns true if the command is enabled, false otherwise.
152 *
153 * @return Always true.
154 */
155bool
157 return true;
158}
#define assert(condition)
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static TCEString userConfPath(const std::string &fileName)
std::string errorMessage() const
Definition Exception.cc:123
wxWindow * parentWindow() const
Definition GUICommand.cc:75
void writeOptions(const GUIOptions &options)
static const std::string SCL_QUIT
Command for quiting the simulation.
static const std::string CONFIGURATION_NAME
Configuration file top-level element name.
void input(std::string command)
virtual ProximQuitCmd * create() const
virtual ~ProximQuitCmd()
virtual bool isEnabled()
virtual int id() const
virtual bool Do()
SimulatorFrontend * simulator_
virtual std::string icon() const
static ProximLineReader & lineReader()
static TracedSimulatorFrontend * frontend()
bool isSimulationStopped() const
bool isSimulationRunning() const
static wxString toWxString(const std::string &source)
void setDestinationFile(const std::string &fileName)