summaryrefslogtreecommitdiff
path: root/VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java
diff options
context:
space:
mode:
Diffstat (limited to 'VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java')
-rw-r--r--VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java143
1 files changed, 143 insertions, 0 deletions
diff --git a/VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java b/VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java
new file mode 100644
index 0000000..d900692
--- /dev/null
+++ b/VS-Sim-Sources/sources/prefs/editors/VSSimulatorEditor.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * All icons of the icons/ folder are under a Creative Commons
+ * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa.
+ *
+ * The icon's homepage is http://code.google.com/p/ultimate-gnome/
+ */
+
+package prefs.editors;
+
+import java.awt.event.*;
+import javax.swing.*;
+
+import simulator.*;
+import prefs.*;
+
+/**
+ * The class VSSimulatorEditor, is for editing a VSSimulator object.
+ *
+ * @author Paul C. Buetow
+ */
+public class VSSimulatorEditor extends VSAbstractBetterEditor {
+ /** The serial version uid */
+ private static final long serialVersionUID = 1L;
+
+ /** The constant OPENED_NEW_WINDOW */
+ public static final boolean OPENED_NEW_WINDOW = true;
+
+ /** The constant OPENED_NEW_TAB */
+ public static final boolean OPENED_NEW_TAB = false;
+
+ /** The simulator frame. */
+ private VSSimulatorFrame simulatorFrame;
+
+ /** The simulator. */
+ private VSSimulator simulator;
+
+ /** The TAKEOVE r_ button. */
+ public static boolean TAKEOVER_BUTTON;
+
+ /** The dont start new simulator. */
+ private boolean dontStartNewSimulator;
+
+ /** Open a new simulator window. */
+ private boolean openedNewWindow;
+
+ /**
+ * Instantiates a new VSSimulatorEditor object.
+ *
+ * @param prefs the prefs
+ * @param simulatorFrame the simulator frame
+ * @param simulator the simulator
+ */
+ public VSSimulatorEditor(VSPrefs prefs, VSSimulatorFrame simulatorFrame,
+ VSSimulator simulator) {
+ super(prefs, prefs, prefs.getString("lang.name")
+ + " - " + prefs.getString("lang.prefs"));
+ this.dontStartNewSimulator = true;//simulator != null;
+ this.simulatorFrame = simulatorFrame;
+ this.simulator = simulator;
+ }
+
+ /**
+ * Instantiates a new VSSimulatorEditor object.
+ *
+ * @param prefs the prefs
+ * @param simulatorFrame the simulator frame
+ */
+ public VSSimulatorEditor(VSPrefs prefs, VSSimulatorFrame simulatorFrame,
+ boolean openedNewWindow) {
+ super(prefs, prefs, prefs.getString("lang.name")
+ + " - " + prefs.getString("lang.prefs"));
+ this.simulatorFrame = simulatorFrame;
+ this.openedNewWindow = openedNewWindow;
+ }
+
+ /* (non-Javadoc)
+ * @see prefs.editors.VSAbstractBetterEditor#addToButtonPanelFront(
+ * javax.swing.JPanel)
+ */
+ protected void addToButtonPanelFront(JPanel buttonPanel) {
+ if (TAKEOVER_BUTTON) {
+ TAKEOVER_BUTTON = false;
+ JButton takeoverButton = new JButton(
+ prefs.getString("lang.takeover"));
+ takeoverButton.setMnemonic(prefs.getInteger("keyevent.takeover"));
+ takeoverButton.addActionListener(this);
+ buttonPanel.add(takeoverButton);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see prefs.editors.VSAbstractBetterEditor#actionPerformed(
+ * java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ String actionCommand = e.getActionCommand();
+
+ if (actionCommand.equals(prefs.getString("lang.takeover"))) {
+ savePrefs();
+
+ if (simulator != null) {
+ if (expertModeChanged())
+ simulator.fireExpertModeChanged();
+ simulator.updateFromPrefs();
+ }
+
+ } else if (actionCommand.equals(prefs.getString("lang.cancel"))) {
+ if (!dontStartNewSimulator && openedNewWindow)
+ simulatorFrame.dispose();
+
+ } else if (actionCommand.equals(prefs.getString("lang.ok"))) {
+ savePrefs();
+ if (expertModeChanged()) {
+ if (simulator != null)
+ simulator.fireExpertModeChanged();
+ }
+ if (!dontStartNewSimulator)
+ simulatorFrame.addSimulator(new VSSimulator(prefsToEdit,
+ simulatorFrame));
+ else if (simulator != null)
+ simulator.updateFromPrefs();
+
+ } else {
+ super.actionPerformed(e);
+ }
+ }
+}