OpenASIP  2.0
SaveOptionsCmd.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 SaveOptionsCmd.cc
26  *
27  * Definition of SaveOptionsCmd class.
28  *
29  * @author Tommi Rantanen 2004 (tommi.rantanen-no.spam-tut.fi)
30  */
31 
32 #include "SaveOptionsCmd.hh"
33 #include "OptionsDialog.hh"
34 #include "ProDeConstants.hh"
35 #include "ProDeOptions.hh"
36 #include "ProDe.hh"
38 #include "ObjectState.hh"
39 #include "WxConversion.hh"
40 #include "CommandRegistry.hh"
41 #include "ErrorDialog.hh"
42 #include "Environment.hh"
43 
44 using std::string;
45 
46 /**
47  * The Constructor.
48  */
50  EditorCommand(ProDeConstants::CMD_NAME_SAVE_OPTIONS) {
51 }
52 
53 
54 /**
55  * The Destructor.
56  */
58 
59 
60 /**
61  * Executes the command.
62  *
63  * @return True, if the command was succesfully executed, false otherwise.
64  */
65 bool
67 
68  ProDeOptions* options = wxGetApp().options();
70  writer.setDestinationFile(Environment::userConfPath("ProDe.conf"));
71 
72  try {
73  writer.writeOptions(*options);
74  options->clearModified();
75  } catch (Exception e) {
76  ErrorDialog errorDialog(parentWindow(),
78  errorDialog.ShowModal();
79  return false;
80  }
81  return true;
82 }
83 
84 
85 /**
86  * Returns id of this command.
87  */
88 int
91 }
92 
93 
94 /**
95  * Creates and returns a new instance of this command.
96  */
99  return new SaveOptionsCmd();
100 }
101 
102 
103 
104 /**
105  * Returns short version of the command name.
106  */
107 string
110 }
111 
112 
113 /**
114  * Returns path to the command's icon file.
115  */
116 string
119 }
120 
121 
122 /**
123  * This command is enabled when the options have been modified.
124  *
125  * @return True if the options have been modified, otherwise false.
126  */
127 bool
129  return wxGetApp().options()->isModified();
130 }
SaveOptionsCmd.hh
ProDeConstants::CMD_SNAME_SAVE_OPTIONS
static const std::string CMD_SNAME_SAVE_OPTIONS
Command name for the "Save Options" command.
Definition: ProDeConstants.hh:260
ProDe.hh
ProDeOptions
Definition: ProDeOptions.hh:44
ProDeConstants::COMMAND_SAVE_OPTIONS
@ COMMAND_SAVE_OPTIONS
Definition: ProDeConstants.hh:464
WxConversion::toWxString
static wxString toWxString(const std::string &source)
CommandRegistry.hh
OptionsDialog.hh
SaveOptionsCmd::shortName
virtual std::string shortName() const
Definition: SaveOptionsCmd.cc:108
ProDeOptionsSerializer.hh
Environment::userConfPath
static TCEString userConfPath(const std::string &fileName)
Definition: Environment.cc:303
SaveOptionsCmd
Definition: SaveOptionsCmd.hh:42
SaveOptionsCmd::~SaveOptionsCmd
virtual ~SaveOptionsCmd()
Definition: SaveOptionsCmd.cc:57
ErrorDialog
Definition: ErrorDialog.hh:42
SaveOptionsCmd::SaveOptionsCmd
SaveOptionsCmd()
Definition: SaveOptionsCmd.cc:49
ErrorDialog.hh
XMLSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: XMLSerializer.cc:142
ObjectState.hh
SaveOptionsCmd::isEnabled
virtual bool isEnabled()
Definition: SaveOptionsCmd.cc:128
Environment.hh
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
ProDeConstants.hh
SaveOptionsCmd::Do
virtual bool Do()
Definition: SaveOptionsCmd.cc:66
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
ProDeOptions.hh
SaveOptionsCmd::icon
virtual std::string icon() const
Definition: SaveOptionsCmd.cc:117
SaveOptionsCmd::create
virtual SaveOptionsCmd * create() const
Definition: SaveOptionsCmd.cc:98
EditorCommand
Definition: EditorCommand.hh:46
WxConversion.hh
GUIOptionsSerializer::writeOptions
void writeOptions(const GUIOptions &options)
Definition: GUIOptionsSerializer.cc:163
ProDeConstants
Definition: ProDeConstants.hh:43
SaveOptionsCmd::id
virtual int id() const
Definition: SaveOptionsCmd.cc:89
ProDeConstants::CMD_ICON_SAVE_OPTIONS
static const std::string CMD_ICON_SAVE_OPTIONS
Icon location for the "Save Options" command.
Definition: ProDeConstants.hh:324
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
ProDeOptionsSerializer
Definition: ProDeOptionsSerializer.hh:43