From: <aki...@us...> - 2008-10-01 20:57:58
|
Revision: 5352 http://gridarta.svn.sourceforge.net/gridarta/?rev=5352&view=rev Author: akirschbaum Date: 2008-10-01 20:57:39 +0000 (Wed, 01 Oct 2008) Log Message: ----------- Make ScriptModel.name final. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/script/ScriptManager.java trunk/crossfire/src/cfeditor/script/ScriptController.java trunk/src/app/net/sf/gridarta/script/ScriptModel.java trunk/src/app/net/sf/gridarta/script/ScriptModelParser.java Modified: trunk/crossfire/src/cfeditor/gui/script/ScriptManager.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/ScriptManager.java 2008-10-01 20:52:24 UTC (rev 5351) +++ trunk/crossfire/src/cfeditor/gui/script/ScriptManager.java 2008-10-01 20:57:39 UTC (rev 5352) @@ -143,8 +143,7 @@ public void actionPerformed(final ActionEvent e) { final String name = JOptionPane.showInputDialog(scripts, "Name of the new Beanshell plugin?"); if (name != null) { - final ScriptModel m = new ScriptModel(); - m.setName(name); + final ScriptModel m = new ScriptModel(name); m.setCode("//input your beanshell Code"); if (!ScriptManager.this.scriptController.getScriptModel2().addScript(m)) { JOptionPane.showMessageDialog(scripts, "The script " + name + " already exists.", "Error", JOptionPane.WARNING_MESSAGE); Modified: trunk/crossfire/src/cfeditor/script/ScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-10-01 20:52:24 UTC (rev 5351) +++ trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-10-01 20:57:39 UTC (rev 5352) @@ -160,8 +160,7 @@ return; } - final ScriptModel cScript = new ScriptModel(); - ScriptModelParser.fromXML(cScript, elt); + final ScriptModel cScript = ScriptModelParser.fromXML(elt); cScript.setFile(file); log.debug("script: " + cScript.getName()); if (override || scriptModel2.getScript(cScript.getName()) == null) { Modified: trunk/src/app/net/sf/gridarta/script/ScriptModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/ScriptModel.java 2008-10-01 20:52:24 UTC (rev 5351) +++ trunk/src/app/net/sf/gridarta/script/ScriptModel.java 2008-10-01 20:57:39 UTC (rev 5352) @@ -49,7 +49,11 @@ private final List<PluginParameter<?, ?>> parameters = new ArrayList<PluginParameter<?, ?>>(); - private String name = ""; + /** + * The script name. + */ + @NotNull + private final String name; private boolean autoboot = false; @@ -71,8 +75,10 @@ /** * Creates a new instance. + * @param name the script name */ - public ScriptModel() { + public ScriptModel(@NotNull final String name) { + this.name = name; } /** @@ -84,22 +90,6 @@ } /** - * Sets the name of this ScriptModel. - * @param name The name of this ScriptModel. - * @todo Maybe this should be moved to the constructor and the underlying - * field made final. - */ - public void setName(final String name) { - if (this.name.equals(name)) { - return; - } - - this.name = name; - modified = true; - notifyListeners(); - } - - /** * Returns the code of this ScriptModel. * @return The code of this ScriptModel. * @todo Improve name - what code is it? Source code? A special coded @@ -195,9 +185,8 @@ */ @Override public Object clone() throws CloneNotSupportedException { - final ScriptModel model = new ScriptModel(); + final ScriptModel model = new ScriptModel(name); model.code = code; - model.name = name; model.autoboot = autoboot; model.filter = filter; model.script = script; Modified: trunk/src/app/net/sf/gridarta/script/ScriptModelParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/ScriptModelParser.java 2008-10-01 20:52:24 UTC (rev 5351) +++ trunk/src/app/net/sf/gridarta/script/ScriptModelParser.java 2008-10-01 20:57:39 UTC (rev 5352) @@ -44,8 +44,8 @@ private ScriptModelParser() { } - public static void fromXML(@NotNull final ScriptModel scriptModel, @NotNull final Element node) { - scriptModel.setName(node.getChildTextTrim("name")); + public static @NotNull final ScriptModel fromXML(@NotNull final Element node) { + final ScriptModel scriptModel = new ScriptModel(node.getChildTextTrim("name")); scriptModel.setCode(node.getChildTextTrim("code")); boolean isAutoboot = false; boolean isFilter = false; @@ -84,6 +84,7 @@ } } scriptModel.resetModified(); + return scriptModel; } public static Element toXML(@NotNull final ScriptModel scriptModel) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |