diff options
Diffstat (limited to 'sources/prefs')
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 301 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefsDE.java | 275 | ||||
| -rw-r--r-- | sources/prefs/VSPrefs.java | 1210 | ||||
| -rw-r--r-- | sources/prefs/VSPrefsRestriction.java | 157 | ||||
| -rw-r--r-- | sources/prefs/VSSerializablePrefs.java | 60 | ||||
| -rw-r--r-- | sources/prefs/editors/VSAbstractBetterEditor.java | 126 | ||||
| -rw-r--r-- | sources/prefs/editors/VSAbstractEditor.java | 1061 | ||||
| -rw-r--r-- | sources/prefs/editors/VSColorChooser.java | 78 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorFrame.java | 117 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorTable.java | 314 | ||||
| -rw-r--r-- | sources/prefs/editors/VSProcessEditor.java | 131 | ||||
| -rw-r--r-- | sources/prefs/editors/VSSimulatorEditor.java | 143 |
12 files changed, 0 insertions, 3973 deletions
diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java deleted file mode 100644 index 63a2127..0000000 --- a/sources/prefs/VSDefaultPrefs.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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; - -import java.awt.Color; -import java.awt.event.KeyEvent; - -/** - * The class VSDefaultPrefs, makes sure that the simulator has its default - * configuration values. - * - * @author Paul C. Buetow - */ -public class VSDefaultPrefs extends VSSerializablePrefs { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * Inits a prefs object with default values. - * - * @return the lang.process.removeprefs - */ - public static VSPrefs init() { - VSDefaultPrefs prefs = new VSDefaultPrefs(); - prefs.fillWithDefaults(); - return prefs; - } - - /** - * Fill everything with ts defaults. - */ - public void fillWithDefaults() { - super.clear(); - addWithDefaults(); - } - - /** - * Adds default values if not existent. - */ - public void addWithDefaults() { - fillDefaultBooleans(); - fillDefaultColors(); - fillDefaultFloats(); - fillDefaultIntegers(); - fillDefaultLongs(); - fillDefaultStrings(); - } - - /** - * Fill with default strings. - */ - public void fillDefaultStrings() { - initString("lang.en.about", "About"); - initString("lang.en.about.info", "This program used to be the diploma thesis of Paul C. Buetow. Please contact vs@dev.buetow.org, if you find any errors!"); - initString("lang.en.activate", "activate"); - initString("lang.en.activated", "activated"); - initString("lang.en.actualize", "Activation"); - initString("lang.en.all", "All"); - initString("lang.en.antialiasing", "Anti-Aliasing"); - initString("lang.en.cancel", "Abort"); - initString("lang.en.client", "Client"); - initString("lang.en.clientrequest.start", "Start client request"); - initString("lang.en.close", "Close"); - initString("lang.en.colorchooser", "Color chooser"); - initString("lang.en.colorchooser2", "Please select color"); - initString("lang.en.copy", "Copy"); - initString("lang.en.crashed", "Crashed"); - initString("lang.en.dat", "Simulation (.dat)"); - initString("lang.en.deactivate", "deactivate"); - initString("lang.en.deactivated", "deactivated"); - initString("lang.en.default", "Defaults"); - initString("lang.en.edit", "Edit"); - initString("lang.en.editor", "Editor"); - initString("lang.en.event", "Event"); - initString("lang.en.event.add.global", "Insert global event"); - initString("lang.en.event.add.local", "Insert local event"); - initString("lang.en.event.add.time", "at"); - initString("lang.en.events", "Events"); - initString("lang.en.events.process", "Process events"); - initString("lang.en.file", "File"); - initString("lang.en.filter", "Filter"); - initString("lang.en.loging.active", "Logging"); - initString("lang.en.loging.clear", "Delete logs"); - initString("lang.en.message", "Message"); - initString("lang.en.message.recv", "Message received"); - initString("lang.en.message.sent", "Message sent"); - initString("lang.en.mode.expert", "Expert mode"); - initString("lang.en.name", "VS-Simulator 1.1"); - initString("lang.en.ok", "OK"); - initString("lang.en.open", "Open"); - initString("lang.en.pause", "Paus"); - initString("lang.en.prefs", "Preferences"); - initString("lang.en.prefs.color", "Color preferences"); - initString("lang.en.prefs.diverse", "Diverse preferences"); - initString("lang.en.prefs.ext", "Extended preferences"); - initString("lang.en.prefs.message", "Message preferences"); - initString("lang.en.prefs.message.defaults", "Message prefs. for new processes"); - initString("lang.en.prefs.more", "More preferences"); - initString("lang.en.prefs.process", "Process preferences"); - initString("lang.en.prefs.process", "Standard process preferences"); - initString("lang.en.prefs.process.defaults", "Preferences for new processes"); - initString("lang.en.prefs.process.ext", "Extended process preferences"); - initString("lang.en.prefs.protocols", "Protocol preferences"); - initString("lang.en.prefs.simulator", "Simulator preferences"); - initString("lang.en.process", "Process"); - initString("lang.en.process.add.new", "Insert new process"); - initString("lang.en.process.crash", "Crash process"); - initString("lang.en.process.edit", "Edit process"); - initString("lang.en.process.id", "PID"); - initString("lang.en.process.new", "New process"); - initString("lang.en.process.not.selected", "No process selected"); - initString("lang.en.process.recover", "Recover process"); - initString("lang.en.process.remove", "Remove process"); - initString("lang.en.process.selected", "Selected process"); - initString("lang.en.process.time.local", "Local time"); - initString("lang.en.processes.all", "All processes"); - initString("lang.en.protocol", "Protocol"); - initString("lang.en.protocol.client", "Client side"); - initString("lang.en.protocol.editor", "Protocol editor"); - initString("lang.en.protocol.server", "Server side"); - initString("lang.en.protocol.tasks.activation", "Client-/Server protocol activation"); - initString("lang.en.protocol.tasks.client", "Client Task-Manager (Client request)"); - initString("lang.en.protocols", "Protocols"); - initString("lang.en.quit", "Quit"); - initString("lang.en.recovered", "Recovered"); - initString("lang.en.remove", "Remove"); - initString("lang.en.replay", "Repeat"); - initString("lang.en.reset", "Reset"); - initString("lang.en.save", "Save"); - initString("lang.en.saveas", "Save as"); - initString("lang.en.server", "Server"); - initString("lang.en.serverrequest.start", "Start server request"); - initString("lang.en.simulator", "Simulator"); - initString("lang.en.simulator.close", "Close simulation"); - initString("lang.en.simulator.finished", "Simulation closed"); - initString("lang.en.simulator.new", "New simulation"); - initString("lang.en.simulator.paused", "Simulation paused"); - initString("lang.en.simulator.resetted", "Simulation resetted"); - initString("lang.en.simulator.started", "Simulation started"); - initString("lang.en.start", "Start"); - initString("lang.en.stop", "Stop"); - initString("lang.en.takeover", "Take over"); - initString("lang.en.task", "Task"); - initString("lang.en.task.manager", "Event editor"); - initString("lang.en.tasks.fullfilled", "Fullfilled tasks"); - initString("lang.en.tasks.global", "GLobal tasks"); - initString("lang.en.tasks.local", "Local tasks"); - initString("lang.en.time", "Time"); - initString("lang.en.time.lamport", "Lamport time"); - initString("lang.en.time.vector", "Vector time"); - initString("lang.en.timed.global", "Global events"); - initString("lang.en.timed.local", "Local events"); - initString("lang.en.type", "Type"); - initString("lang.en.value", "Value"); - initString("lang.en.variable", "Variable"); - initString("lang.en.variables", "Variables"); - initString("lang.en.variables.global", "Global variables"); - initString("lang.en.window.close", "Close window"); - initString("lang.en.window.new", "New window"); - - /* Protocol names */ - initString("lang.en.events.implementations.VSProcessCrashEvent", "Process Crash Event"); - initString("lang.en.events.implementations.VSProcessCrashEvent.short", "Process Crash"); - initString("lang.en.events.implementations.VSProcessRecoverEvent", "Process Recover Event"); - initString("lang.en.events.implementations.VSProcessRecoverEvent.short", "Process Recover"); - initString("lang.en.protocols.implementations.VSBasicMulticastProtocol", "Basic Multicast Protocol"); - initString("lang.en.protocols.implementations.VSBasicMulticastProtocol.short", "Basic Multicast"); - initString("lang.en.protocols.implementations.VSBerkelyTimeProtocol", "Berkley algorithm for internal sync."); - initString("lang.en.protocols.implementations.VSBerkelyTimeProtocol.short", "Berkley Protocol"); - initString("lang.en.protocols.implementations.VSBroadcastProtocol", "Broadcast Protocol"); - initString("lang.en.protocols.implementations.VSBroadcastProtocol.short", "Broadcast"); - initString("lang.en.protocols.implementations.VSDummyProtocol", "Example/Dummy Protocol"); - initString("lang.en.protocols.implementations.VSDummyProtocol.short", "Example/Dummy"); - initString("lang.en.protocols.implementations.VSExternalTimeSyncProtocol", "Christians method for external sync."); - initString("lang.en.protocols.implementations.VSExternalTimeSyncProtocol.short", "Christians"); - initString("lang.en.protocols.implementations.VSInternalTimeSyncProtocol", "Internal Synchronization Protocol"); - initString("lang.en.protocols.implementations.VSInternalTimeSyncProtocol.short", "Internal sync."); - initString("lang.en.protocols.implementations.VSOnePhaseCommitProtocol", "One-Phase Commit Protocol"); - initString("lang.en.protocols.implementations.VSOnePhaseCommitProtocol.short", "1-Phase Commit"); - initString("lang.en.protocols.implementations.VSPingPongProtocol", "Ping-Pong Protocol"); - initString("lang.en.protocols.implementations.VSPingPongProtocol.short", "Ping-Pong"); - initString("lang.en.protocols.implementations.VSReliableMulticastProtocol", "Reliable Multicast Protocol"); - initString("lang.en.protocols.implementations.VSReliableMulticastProtocol.short", "Reliable Multicast"); - initString("lang.en.protocols.implementations.VSTwoPhaseCommitProtocol", "Two-Phase Commit"); - initString("lang.en.protocols.implementations.VSTwoPhaseCommitProtocol.short", "2-Phase Commit"); - } - - /** - * Fill with default integers. - */ - public void fillDefaultIntegers() { - /* Simulator prefs */ - initInteger("sim.process.num", 3, "Number of processes", 1, 6); - initInteger("message.prob.outage", 0, "Message lost prob.", 0, 100, "%"); - initInteger("process.prob.crash", 0, "Process crash prob.", 0, 100, "%"); - initInteger("sim.seconds", 15, "Simulation duration", 5, 120, "s"); - - /* Internal prefs */ - initInteger("keyevent.about", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.cancel", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.close", KeyEvent.VK_C, null, 0, 100); - initInteger("keyevent.default", KeyEvent.VK_F, null, 0, 100); - initInteger("keyevent.edit", KeyEvent.VK_E, null, 0, 100); - initInteger("keyevent.file", KeyEvent.VK_D, null, 0, 100); - initInteger("keyevent.new", KeyEvent.VK_N, null, 0, 100); - initInteger("keyevent.actualize", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.takeover", KeyEvent.VK_B, null, 0, 100); - initInteger("keyevent.ok", KeyEvent.VK_O, null, 0, 100); - initInteger("keyevent.open", KeyEvent.VK_O, null, 0, 100); - initInteger("keyevent.pause", KeyEvent.VK_P, null, 0, 100); - initInteger("keyevent.prefs", KeyEvent.VK_P, null, 0, 100); - initInteger("keyevent.prefs.ext", KeyEvent.VK_E, null, 0, 100); - initInteger("keyevent.quit", KeyEvent.VK_B, null, 0, 100); - initInteger("keyevent.replay", KeyEvent.VK_W, null, 0, 100); - initInteger("keyevent.reset", KeyEvent.VK_R, null, 0, 100); - initInteger("keyevent.save", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.saveas", KeyEvent.VK_V, null, 0, 100); - initInteger("keyevent.simulator", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100); - - initInteger("div.window.prefs.xsize", 400, "Configuration window X-Axis", 550, 3200, "px"); - initInteger("div.window.prefs.ysize", 400, "Configuration window Y-Axis", 640, 2400, "px"); - initInteger("div.window.logsize", 300, "Log window Y-Axis", 100, 1000, "px"); - initInteger("div.window.splitsize", 320, "Toolbar X-Axis", 100, 1000, "px"); - initInteger("div.window.xsize", 1024, "Main window X-Axis", 750, 3200, "px"); - initInteger("div.window.ysize", 768, "Main window Y-Axis", 600, 2400, "px"); - } - - /** - * Fill with default floats. - */ - public void fillDefaultFloats() { - /* Simulator prefs */ - initFloat("process.clock.variance", 0, "Clock variance"); - initFloat("sim.clock.speed", 0.5f, "Simulation play speed"); - } - - /** - * Fill default longs. - */ - public void fillDefaultLongs() { - /* Simulator prefs */ - initLong("message.sendingtime.min", 500, "Max transmission time", "ms"); - initLong("message.sendingtime.max", 2000, "Min transmission time", "ms"); - } - - /** - * Fill with default colors. - */ - public void fillDefaultColors() { - /* Internal prefs */ - initColor("col.background", new Color(0xFF, 0xFF, 0xFF)); - initColor("col.process.default", new Color(0x00, 0x00, 0x00)); - initColor("col.process.running", new Color(0x0D, 0xD8, 0x09)); - initColor("col.process.crashed", new Color(0xff, 0x00, 0x00)); - initColor("col.process.highlight", new Color(0xff, 0xA5, 0x00)); - initColor("col.process.line", new Color(0x00, 0x00, 0x00)); - initColor("col.process.secondline", new Color(0xAA, 0xAA, 0xAA)); - initColor("col.process.sepline", new Color(0xff, 0x00, 0x00)); - initColor("col.process.stopped", new Color(0x00, 0x00, 0x00)); - initColor("col.message.arrived", new Color(0x00, 0x85, 0xD2)); - initColor("col.message.sending", new Color(0x0D, 0xD8, 0x09)); - initColor("col.message.lost", new Color(0xFF, 0x00, 0x00)); - } - - /** - * Fill with default booleans. - */ - public void fillDefaultBooleans() { - initBoolean("sim.mode.expert", false, "Expert mode"); - initBoolean("sim.message.own.recv", false, "Processes receive own messages"); - initBoolean("sim.message.prob.mean", true, "Use mean value of message lost prob."); - initBoolean("sim.message.sendingtime.mean", true, "Use mean value of transmission times"); - initBoolean("sim.messages.relevant", true, "Only show relevant messages"); - initBoolean("sim.periodic", false, "Repeat simulation periodically"); - initBoolean("sim.update.lamporttime.all", false, "Lamport timestamps affect all events"); - initBoolean("sim.update.vectortime.all", false, "Vector timestamps affect all events"); - } -} diff --git a/sources/prefs/VSDefaultPrefsDE.java b/sources/prefs/VSDefaultPrefsDE.java deleted file mode 100644 index 9f65153..0000000 --- a/sources/prefs/VSDefaultPrefsDE.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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; - -import java.awt.Color; -import java.awt.event.KeyEvent; - -/** - * The class VSDefaultPrefsDE, makes sure that the simulator has its default - * configuration values. - * - * @author Paul C. Buetow - */ -public class VSDefaultPrefsDE extends VSSerializablePrefs { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * Inits a prefs object with default values. - * - * @return the lang.process.removeprefs - */ - public static VSPrefs init() { - VSDefaultPrefsDE prefs = new VSDefaultPrefsDE(); - prefs.fillWithDefaults(); - return prefs; - } - - /** - * Fill everything with ts defaults. - */ - public void fillWithDefaults() { - super.clear(); - addWithDefaults(); - } - - /** - * Adds default values if not existent. - */ - public void addWithDefaults() { - fillDefaultBooleans(); - fillDefaultColors(); - fillDefaultFloats(); - fillDefaultIntegers(); - fillDefaultLongs(); - fillDefaultStrings(); - } - - /** - * Fill with default strings. - */ - public void fillDefaultStrings() { - initString("lang.de.about", "About"); - initString("lang.de.about.info", "Dieses Programm wurde von Paul Bütow im Rahmen der Diplomarbeit \"Objektorientierte Entwicklung eines GUI-basierten Tools für die ereignisbasierte Simulator verteilter Systeme\" bei Prof. Dr.-Ing. Oßmann als 1. Prüfer sowie Betreuer und Prof. Dr. rer. nat. Fassbender als 2. Prüfer erstellt. Bei Fehlern bitte eine kurze Mail mit Fehlerbeschreibung an vs@paul.buetow.org schicken!"); - initString("lang.de.activate", "aktivieren"); - initString("lang.de.activated", "aktiviert"); - initString("lang.de.actualize", "Aktualisieren"); - initString("lang.de.all", "Alle"); - initString("lang.de.antialiasing", "Anti-Aliasing"); - initString("lang.de.cancel", "Abbrechen"); - initString("lang.de.client", "Client"); - initString("lang.de.clientrequest.start", "Clientanfrage starten"); - initString("lang.de.close", "Schliessen"); - initString("lang.de.colorchooser", "Farbauswahl"); - initString("lang.de.colorchooser2", "Bitte Farbe auswählen"); - initString("lang.de.copy", "Kopieren"); - initString("lang.de.crashed", "Abgestürzt"); - initString("lang.de.dat", "Simulation (.dat)"); - initString("lang.de.deactivate", "deaktivieren"); - initString("lang.de.deactivated", "deaktiviert"); - initString("lang.de.default", "Defaults"); - initString("lang.de.edit", "Editieren"); - initString("lang.de.editor", "Editor"); - initString("lang.de.event", "Ereignis"); - initString("lang.de.event.add.global", "Globales Ereignis einfügen"); - initString("lang.de.event.add.local", "Lokales Ereignis einfügen"); - initString("lang.de.event.add.time", "bei"); - initString("lang.de.events", "Ereignisse"); - initString("lang.de.events.process", "Prozessereignisse"); - initString("lang.de.file", "Datei"); - initString("lang.de.filter", "Filter"); - initString("lang.de.loging.active", "Logging"); - initString("lang.de.loging.clear", "Loggs löschen"); - initString("lang.de.message", "Nachricht"); - initString("lang.de.message.recv", "Nachricht erhalten"); - initString("lang.de.message.sent", "Nachricht versendet"); - initString("lang.de.mode.expert", "Expertenmodus"); - initString("lang.de.name", "VS-Simulator 1.0"); - initString("lang.de.ok", "OK"); - initString("lang.de.open", "Öffnen"); - initString("lang.de.pause", "Pausieren"); - initString("lang.de.prefs", "Einstellungen"); - initString("lang.de.prefs.color", "Farbeinstellungen"); - initString("lang.de.prefs.diverse", "Diverse Einstellungen"); - initString("lang.de.prefs.ext", "Erweiterte Einstellungen"); - initString("lang.de.prefs.message", "Nachrichteneinstellungen"); - initString("lang.de.prefs.message.defaults", "Nachrichteneinstellungen für neue Prozesse"); - initString("lang.de.prefs.more", "Mehr Einstellungen"); - initString("lang.de.prefs.process", "Prozesseinstellungen"); - initString("lang.de.prefs.process", "Prozessstandardeinstellungen"); - initString("lang.de.prefs.process.defaults", "Einstellungen für neue Prozesse"); - initString("lang.de.prefs.process.ext", "Erweiterte Prozesseinstellungen"); - initString("lang.de.prefs.protocols", "Protokolleinstellungen"); - initString("lang.de.prefs.simulator", "Simulationseinstellungen"); - initString("lang.de.process", "Prozess"); - initString("lang.de.process.add.new", "Neuen Prozess hinzufügen"); - initString("lang.de.process.crash", "Prozess abstürzen"); - initString("lang.de.process.edit", "Prozess editieren"); - initString("lang.de.process.id", "PID"); - initString("lang.de.process.new", "Neuer Prozess"); - initString("lang.de.process.not.selected", "Kein Prozess ausgewählt"); - initString("lang.de.process.recover", "Prozess wiederbeleben"); - initString("lang.de.process.remove", "Prozess entfernen"); - initString("lang.de.process.selected", "Aktuell ausgewählter Prozess"); - initString("lang.de.process.time.local", "Lokale Zeit"); - initString("lang.de.processes.all", "Alle Prozesse"); - initString("lang.de.protocol", "Protokoll"); - initString("lang.de.protocol.client", "Clientseite"); - initString("lang.de.protocol.editor", "Protokolleditor"); - initString("lang.de.protocol.server", "Serverseite"); - initString("lang.de.protocol.tasks.activation", "Client-/Serverprotokoll Aktivierung"); - initString("lang.de.protocol.tasks.client", "Client Task-Manager (Clientanfragen)"); - initString("lang.de.protocols", "Protokolle"); - initString("lang.de.quit", "Beenden"); - initString("lang.de.recovered", "Wiederbelebt"); - initString("lang.de.remove", "Entfernen"); - initString("lang.de.replay", "Wiederholen"); - initString("lang.de.reset", "Reset"); - initString("lang.de.save", "Speichern"); - initString("lang.de.saveas", "Speichern unter"); - initString("lang.de.server", "Server"); - initString("lang.de.serverrequest.start", "Serveranfrage starten"); - initString("lang.de.simulator", "Simulator"); - initString("lang.de.simulator.close", "Simulation schliessen"); - initString("lang.de.simulator.finished", "Simulation beendet"); - initString("lang.de.simulator.new", "Neue Simulation"); - initString("lang.de.simulator.paused", "Simulation pausiert"); - initString("lang.de.simulator.resetted", "Simulation zurückgesetzt"); - initString("lang.de.simulator.started", "Simulation gestartet"); - initString("lang.de.start", "Starten"); - initString("lang.de.stop", "Stoppen"); - initString("lang.de.takeover", "Übernehmen"); - initString("lang.de.task", "Aufgabe"); - initString("lang.de.task.manager", "Ereigniseditor"); - initString("lang.de.tasks.fullfilled", "Abgelaufene Aufgaben"); - initString("lang.de.tasks.global", "Globale Aufgaben"); - initString("lang.de.tasks.local", "Lokale Aufgaben"); - initString("lang.de.time", "Zeit"); - initString("lang.de.time.lamport", "Lamportzeit"); - initString("lang.de.time.vector", "Vektorzeit"); - initString("lang.de.timed.global", "Globale Ereignisse"); - initString("lang.de.timed.local", "Lokale Ereignisse"); - initString("lang.de.type", "Typ"); - initString("lang.de.value", "Wert"); - initString("lang.de.variable", "Variable"); - initString("lang.de.variables", "Variablen"); - initString("lang.de.variables.global", "Globale Variablen"); - initString("lang.de.window.close", "Fenster schliessen"); - initString("lang.de.window.new", "Neues Fenster"); - } - - /** - * Fill with default integers. - */ - public void fillDefaultIntegers() { - /* Simulator prefs */ - initInteger("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); - initInteger("message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); - initInteger("process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); - initInteger("sim.seconds", 15, "Dauer der Simulation", 5, 120, "s"); - - /* Internal prefs */ - initInteger("keyevent.about", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.cancel", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.close", KeyEvent.VK_C, null, 0, 100); - initInteger("keyevent.default", KeyEvent.VK_F, null, 0, 100); - initInteger("keyevent.edit", KeyEvent.VK_E, null, 0, 100); - initInteger("keyevent.file", KeyEvent.VK_D, null, 0, 100); - initInteger("keyevent.new", KeyEvent.VK_N, null, 0, 100); - initInteger("keyevent.actualize", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.takeover", KeyEvent.VK_B, null, 0, 100); - initInteger("keyevent.ok", KeyEvent.VK_O, null, 0, 100); - initInteger("keyevent.open", KeyEvent.VK_O, null, 0, 100); - initInteger("keyevent.pause", KeyEvent.VK_P, null, 0, 100); - initInteger("keyevent.prefs", KeyEvent.VK_P, null, 0, 100); - initInteger("keyevent.prefs.ext", KeyEvent.VK_E, null, 0, 100); - initInteger("keyevent.quit", KeyEvent.VK_B, null, 0, 100); - initInteger("keyevent.replay", KeyEvent.VK_W, null, 0, 100); - initInteger("keyevent.reset", KeyEvent.VK_R, null, 0, 100); - initInteger("keyevent.save", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.saveas", KeyEvent.VK_V, null, 0, 100); - initInteger("keyevent.simulator", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100); - - initInteger("div.window.prefs.xsize", 400, "Einstellungsfenster X-Achse", 550, 3200, "px"); - initInteger("div.window.prefs.ysize", 400, "Einstellungsfenster Y-Achse", 640, 2400, "px"); - initInteger("div.window.logsize", 300, "Loggfenster Y-Achse", 100, 1000, "px"); - initInteger("div.window.splitsize", 320, "Toolbar X-Achse", 100, 1000, "px"); - initInteger("div.window.xsize", 1024, "Hauptfenster X-Achse", 750, 3200, "px"); - initInteger("div.window.ysize", 768, "Hauptfenster Y-Achse", 600, 2400, "px"); - } - - /** - * Fill with default floats. - */ - public void fillDefaultFloats() { - /* Simulator prefs */ - initFloat("process.clock.variance", 0, "Uhrabweichung"); - initFloat("sim.clock.speed", 0.5f, "Abspielgeschwindigkeit der Simulation"); - } - - /** - * Fill default longs. - */ - public void fillDefaultLongs() { - /* Simulator prefs */ - initLong("message.sendingtime.min", 500, "Minimale Übertragungszeit", "ms"); - initLong("message.sendingtime.max", 2000, "Maximale Übertragungszeit", "ms"); - } - - /** - * Fill with default colors. - */ - public void fillDefaultColors() { - /* Internal prefs */ - initColor("col.background", new Color(0xFF, 0xFF, 0xFF)); - initColor("col.process.default", new Color(0x00, 0x00, 0x00)); - initColor("col.process.running", new Color(0x0D, 0xD8, 0x09)); - initColor("col.process.crashed", new Color(0xff, 0x00, 0x00)); - initColor("col.process.highlight", new Color(0xff, 0xA5, 0x00)); - initColor("col.process.line", new Color(0x00, 0x00, 0x00)); - initColor("col.process.secondline", new Color(0xAA, 0xAA, 0xAA)); - initColor("col.process.sepline", new Color(0xff, 0x00, 0x00)); - initColor("col.process.stopped", new Color(0x00, 0x00, 0x00)); - initColor("col.message.arrived", new Color(0x00, 0x85, 0xD2)); - initColor("col.message.sending", new Color(0x0D, 0xD8, 0x09)); - initColor("col.message.lost", new Color(0xFF, 0x00, 0x00)); - } - - /** - * Fill with default booleans. - */ - public void fillDefaultBooleans() { - initBoolean("sim.mode.expert", false, "Expertenmodus aktivieren"); - initBoolean("sim.message.own.recv", false, "Prozesse empfangen eigene Nachrichten"); - initBoolean("sim.message.prob.mean", true, "Mittelwerte der Nachrichtverlustw'k. bilden"); - initBoolean("sim.message.sendingtime.mean", true, "Mittelwerte der Übertragungszeiten bilden"); - initBoolean("sim.messages.relevant", true, "Nur relevante Nachrichten anzeigen"); - initBoolean("sim.periodic", false, "Simulation periodisch wiederholen"); - initBoolean("sim.update.lamporttime.all", false, "Lamportzeiten betreffen alle Ereignisse"); - initBoolean("sim.update.vectortime.all", false, "Vektorzeiten betreffen alle Ereignisse"); - } -} diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java deleted file mode 100644 index 31e1f22..0000000 --- a/sources/prefs/VSPrefs.java +++ /dev/null @@ -1,1210 +0,0 @@ -/* - * 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; - -import java.awt.Color; -import java.io.*; -import java.util.*; - -import serialize.*; - -/** - * The class VSPrefs, this class is for dynamic data storage. It can hold - * various different types such as Boolean, Floats, Integers, Strings, Colors. - * - * @author Paul C. Buetow - */ -public class VSPrefs { - /** Check if we want to overwrite description strings */ - //private boolean useDefaultStrings = false; - - /** The Constant BOOLEAN_PREFIX. */ - public static final String BOOLEAN_PREFIX = "Boolean: "; - - /** The Constant COLOR_PREFIX. */ - public static final String COLOR_PREFIX = "Color: "; - - /** The Constant FLOAT_PREFIX. */ - public static final String FLOAT_PREFIX = "Float: "; - - /** The Constant INTEGER_PREFIX. */ - public static final String INTEGER_PREFIX = "Integer: "; - - /** The Constant VECTOR_PREFIX. */ - public static final String VECTOR_PREFIX = "Vector: "; - - /** The Constant LONG_PREFIX. */ - public static final String LONG_PREFIX = "Long: "; - - /** The Constant STRING_PREFIX. */ - public static final String STRING_PREFIX = "String: "; - - /** The color prefs. */ - private HashMap<String,Color> colorPrefs; - - /** The float prefs. */ - private HashMap<String,Float> floatPrefs; - - /** The integer prefs. */ - private HashMap<String,Integer> integerPrefs; - - /** The integer vector prefs. */ - private HashMap<String,Vector<Integer>> vectorPrefs; - - /** The long prefs. */ - private HashMap<String,Long> longPrefs; - - /** The setting restriction prefs. */ - private HashMap<String,VSPrefsRestriction> restrictions; - - /** The description prefs. */ - private HashMap<String,String> descriptionPrefs; - - /** The string prefs. */ - private HashMap<String,String> stringPrefs; - - /** The boolean prefs. */ - private HashMap<String,Boolean> booleanPrefs; - - /** The object prefs. */ - private HashMap<String,Object> objectPrefs; - - /** The units. */ - private HashMap<String,String> units; - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 4L; - - /** The id counter. */ - private static int idCounter; - - /** The id. */ - protected int id; - - /** - * Instantiates a new lang.process.removeprefs. - */ - public VSPrefs() { - colorPrefs = new HashMap<String,Color>(); - descriptionPrefs = new HashMap<String,String>(); - floatPrefs = new HashMap<String,Float>(); - integerPrefs = new HashMap<String,Integer>(); - vectorPrefs = new HashMap<String,Vector<Integer>>(); - longPrefs = new HashMap<String,Long>(); - restrictions = new HashMap<String,VSPrefsRestriction>(); - stringPrefs = new HashMap<String,String>(); - booleanPrefs = new HashMap<String,Boolean>(); - objectPrefs = new HashMap<String,Object>(); - units = new HashMap<String,String>(); - id = ++idCounter; - } - - /** - * Clear. - */ - protected synchronized void clear() { - colorPrefs.clear(); - floatPrefs.clear(); - integerPrefs.clear(); - vectorPrefs.clear(); - longPrefs.clear(); - stringPrefs.clear(); - booleanPrefs.clear(); - objectPrefs.clear(); - descriptionPrefs.clear(); - restrictions.clear(); - } - - /* Unit methods */ - - /** - * Gets the unit. - * - * @param fullKey the full key - * - * @return the unit - */ - public synchronized String getUnit(String fullKey) { - return units.get(fullKey); - } - - /** - * Sets the unit. - * - * @param key the key - * @param unit the unit - */ - public synchronized void initUnit(String key, String unit) { - if (unit == null /*|| units.containsKey(key)*/) - return; - units.put(key, unit); - } - - /* Description methods */ - /** - * Sets the description if unset. - * - * @param key the key - * @param descr the descr - */ - public synchronized void initDescription(String key, String descr) { - if (descr == null /*|| descriptionPrefs.containsKey(key)*/) - return; - descriptionPrefs.put(key, descr); - } - - /** - * Gets the description. - * - * @param fullKey the full key - * - * @return the description - */ - public synchronized String getDescription(String fullKey) { - return descriptionPrefs.get(fullKey); - } - - /* Restriction methods */ - - /** - * Gets the restriction. - * - * @param fullKey the full key - * - * @return the restriction - */ - public synchronized VSPrefsRestriction getRestriction(String fullKey) { - return restrictions.get(fullKey); - } - - /** - * Sets the restriction. - * - * @param key the key - * @param settingRestriction the setting restriction - */ - public synchronized void initRestriction(String key, - VSPrefsRestriction settingRestriction) { - restrictions.put(key, settingRestriction); - } - - /* Object methods */ - - /** - * Object exists. - * - * @param key the key - * - * @return true, if successful - */ - public synchronized boolean objectExists(String key) { - return null != objectPrefs.get(key); - } - - /** - * Gets the object. - * - * @param key the key - * - * @return the object - */ - public synchronized Object getObject(String key) { - Object val = objectPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such object config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Removes the object. - * - * @param key the key - */ - public synchronized void removeObject(String key) { - objectPrefs.remove(key); - } - - /** - * Sets the object. - * - * @param key the key - * @param val the val - */ - public synchronized void setObject(String key, Object val) { - objectPrefs.put(key, val); - } - - /* Boolean methods */ - - /** - * Gets the boolean. - * - * @param key the key - * - * @return the boolean - */ - public boolean getBoolean(String key) { - return getBooleanObj(key).booleanValue(); - } - - /** - * Gets the boolean key set. - * - * @return the boolean key set - */ - public synchronized Set<String> getBooleanKeySet() { - return booleanPrefs.keySet(); - } - - /** - * Gets the boolean obj. - * - * @param key the key - * - * @return the boolean obj - */ - public synchronized Boolean getBooleanObj(String key) { - Boolean val = booleanPrefs.get(key); - - if (val == null) - return new Boolean(false); - - return val; - } - - /** - * Inits the boolean. - * - * @param key the key - * @param val the val - */ - public synchronized void initBoolean(String key, Boolean val) { - if (!booleanPrefs.containsKey(key)) - booleanPrefs.put(key, val); - } - - /** - * Inits the boolean. - * - * @param key the key - * @param val the val - */ - public void initBoolean(String key, boolean val) { - initBoolean(key, new Boolean(val)); - } - - /** - * Inits the boolean. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initBoolean(String key, boolean val, String descr) { - initBoolean(key, val); - initDescription(BOOLEAN_PREFIX + key, descr); - } - - /** - * Sets the boolean. - * - * @param key the key - * @param val the val - */ - public synchronized void setBoolean(String key, Boolean val) { - booleanPrefs.put(key, val); - } - - /** - * Sets the boolean. - * - * @param key the key - * @param val the val - */ - public void setBoolean(String key, boolean val) { - setBoolean(key, new Boolean(val)); - } - - /* Color methods */ - - /** - * Gets the color. - * - * @param key the key - * - * @return the color - */ - public synchronized Color getColor(String key) { - Color color = colorPrefs.get(key); - - if (color == null) { - System.err.println("Fatal: No such color config value \"" - + key + "\""); - System.exit(1); - } - - return color; - } - - /** - * Gets the color key set. - * - * @return the color key set - */ - public synchronized Set<String> getColorKeySet() { - return colorPrefs.keySet(); - } - - /** - * Inits the color. - * - * @param key the key - * @param color the color - */ - public synchronized void initColor(String key, Color color) { - if (!colorPrefs.containsKey(key)) - colorPrefs.put(key, color); - } - - /** - * Inits the color. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initColor(String key, Color val, String descr) { - initColor(key, val); - initDescription(COLOR_PREFIX + key, descr); - } - - /** - * Sets the color. - * - * @param key the key - * @param color the color - */ - public synchronized void setColor(String key, Color color) { - colorPrefs.put(key, color); - } - - /* Float methods */ - - /** - * Gets the float. - * - * @param key the key - * - * @return the float - */ - public float getFloat(String key) { - return getFloatObj(key).floatValue(); - } - - /** - * Gets the float key set. - * - * @return the float key set - */ - public synchronized Set<String> getFloatKeySet() { - return floatPrefs.keySet(); - } - - /** - * Gets the float obj. - * - * @param key the key - * - * @return the float obj - */ - public synchronized Float getFloatObj(String key) { - Float val = floatPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such float config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Inits the float. - * - * @param key the key - * @param val the val - */ - public synchronized void initFloat(String key, Float val) { - if (!floatPrefs.containsKey(key)) - floatPrefs.put(key, val); - } - - /** - * Inits the float. - * - * @param key the key - * @param val the val - */ - public void initFloat(String key, float val) { - initFloat(key, new Float(val)); - } - - /** - * Inits the float. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initFloat(String key, float val, String descr) { - initFloat(key, val); - initDescription(FLOAT_PREFIX + key, descr); - } - - /** - * Inits the float plus unit. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param unit the unit - */ - public void initFloat(String key, float val, String descr, String unit) { - initFloat(key, val, descr); - initUnit(FLOAT_PREFIX + key, unit); - } - - /** - * Sets the float. - * - * @param key the key - * @param val the val - */ - public synchronized void setFloat(String key, Float val) { - floatPrefs.put(key, val); - } - - /** - * Sets the float. - * - * @param key the key - * @param val the val - */ - public void setFloat(String key, float val) { - setFloat(key, new Float(val)); - } - - /* Integer methods */ - - /** - * Gets the integer. - * - * @param key the key - * - * @return the integer - */ - public int getInteger(String key) { - return getIntegerObj(key).intValue(); - } - - /** - * Gets the integer key set. - * - * @return the integer key set - */ - public synchronized Set<String> getIntegerKeySet() { - return integerPrefs.keySet(); - } - - /** - * Gets the integer obj. - * - * @param key the key - * - * @return the integer obj - */ - public synchronized Integer getIntegerObj(String key) { - Integer val = integerPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such integer config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - */ - public void initInteger(String key, int val) { - if (!integerPrefs.containsKey(key)) - setInteger(key, new Integer(val)); - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initInteger(String key, int val, String descr) { - initInteger(key, val); - initDescription(INTEGER_PREFIX + key, descr); - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param r the restriction - */ - public void initInteger(String key, int val, String descr, - VSPrefsRestriction.VSIntegerPrefsRestriction r) { - initInteger(key, val, descr); - initRestriction(INTEGER_PREFIX + key, r); - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param r the restriction - */ - public void initInteger(String key, int val, String descr, - VSPrefsRestriction.VSIntegerPrefsRestriction r, - String unit) { - initInteger(key, val, descr, r); - initUnit(INTEGER_PREFIX + key, unit); - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param minValue the min value - * @param maxValue the max value - */ - public void initInteger(String key, int val, String descr, int minValue, - int maxValue) { - initInteger(key, val, descr, - new VSPrefsRestriction.VSIntegerPrefsRestriction( - minValue, maxValue)); - } - - /** - * Inits the integer plus unit. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param minValue the min value - * @param maxValue the max value - * @param unit the unit - */ - public void initInteger(String key, int val, String descr, int minValue, - int maxValue, String unit) { - initInteger(key, val, descr, minValue, maxValue); - initUnit(INTEGER_PREFIX + key, unit); - } - - /** - * Sets the integer. - * - * @param key the key - * @param val the val - */ - public synchronized void setInteger(String key, Integer val) { - integerPrefs.put(key, val); - } - - /** - * Sets the integer. - * - * @param key the key - * @param val the val - */ - public void setInteger(String key, int val) { - setInteger(key, new Integer(val)); - } - - /* Integer vector methods */ - - /** - * Gets the integer key set. - * - * @return the integer key set - */ - public synchronized Set<String> getVectorKeySet() { - return vectorPrefs.keySet(); - } - - /** - * Gets the integer obj. - * - * @param key the key - * - * @return the integer obj - */ - public synchronized Vector<Integer> getVector(String key) { - Vector<Integer> val = vectorPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such integer config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Inits the integer. - * - * @param key the key - * @param val the val - */ - public synchronized void initVector(String key, Vector<Integer> val) { - if (!vectorPrefs.containsKey(key)) - setVector(key, val); - } - - /** - * Inits the integer vector. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initVector(String key, Vector<Integer> val, String descr) { - initVector(key, val); - initDescription(VECTOR_PREFIX + key, descr); - } - - /** - * Inits the integer vector plus unit. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initVector(String key, Vector<Integer> val, String descr, - String unit) { - initVector(key, val, descr); - initUnit(VECTOR_PREFIX + key, unit); - } - - /** - * Sets the integer vector. - * - * @param key the key - * @param val the val - */ - public synchronized void setVector(String key, Vector<Integer> val) { - vectorPrefs.put(key, val); - } - - /* Long methods */ - - /** - * Gets the long. - * - * @param key the key - * - * @return the long - */ - public long getLong(String key) { - return getLongObj(key).longValue(); - } - - /** - * Gets the long key set. - * - * @return the long key set - */ - public synchronized Set<String> getLongKeySet() { - return longPrefs.keySet(); - } - - /** - * Gets the long obj. - * - * @param key the key - * - * @return the long obj - */ - public synchronized Long getLongObj(String key) { - Long val = longPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such long config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Inits the long. - * - * @param key the key - * @param val the val - */ - public synchronized void initLong(String key, Long val) { - if (!longPrefs.containsKey(key)) - longPrefs.put(key, val); - } - - /** - * Sets the long if unset. - * - * @param key the key - * @param val the val - */ - public void initLong(String key, long val) { - initLong(key, new Long(val)); - } - - /** - * Inits the long. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initLong(String key, long val, String descr) { - initLong(key, val); - initDescription(LONG_PREFIX + key, descr); - } - - /** - * Inits the long unit. - * - * @param key the key - * @param val the val - * @param descr the descr - * @param unit the unit - */ - public void initLong(String key, long val, String descr, String unit) { - initLong(key, val, descr); - initUnit(LONG_PREFIX + key, unit); - } - - /** - * Deletes the long. - * - * @param key the key - */ - public synchronized void deleteLong(String key) { - longPrefs.remove(key); - } - - /** - * Sets the long. - * - * @param key the key - * @param val the val - */ - public synchronized void setLong(String key, Long val) { - longPrefs.put(key, val); - } - - /** - * Sets the long. - * - * @param key the key - * @param val the val - */ - public void setLong(String key, long val) { - setLong(key, new Long(val)); - } - - /* String methods */ - - /** - * Gets the string. - * - * @param key the key - * - * @return the string - */ - public synchronized String getString(String key) { - String val = stringPrefs.get(key); - - if (val == null) { - System.err.println("Fatal: No such string config value \"" - + key + "\""); - System.exit(1); - } - - return val; - } - - /** - * Gets the string key set. - * - * @return the string key set - */ - public synchronized Set<String> getStringKeySet() { - return stringPrefs.keySet(); - } - - /** - * Inits the string. - * - * @param key the key - * @param val the val - */ - public synchronized void initString(String key, String val) { - //if (!stringPrefs.containsKey(key)) - stringPrefs.put(key, val); - } - - /** - * Inits the string. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void initString(String key, String val, String descr) { - initString(key, val); - initDescription(STRING_PREFIX + key, descr); - } - - /** - * Sets the string. - * - * @param key the key - * @param val the val - */ - public synchronized void setString(String key, String val) { - stringPrefs.put(key, val); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - protected synchronized void serialize_( - VSSerialize serialize, ObjectOutputStream objectOutputStream) - throws IOException { - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - - objectOutputStream.writeObject(booleanPrefs); - objectOutputStream.writeObject(colorPrefs); - objectOutputStream.writeObject(descriptionPrefs); - objectOutputStream.writeObject(floatPrefs); - objectOutputStream.writeObject(integerPrefs); - objectOutputStream.writeObject(longPrefs); - objectOutputStream.writeObject(stringPrefs); - objectOutputStream.writeObject(units); - objectOutputStream.writeObject(vectorPrefs); - objectOutputStream.writeObject(restrictions); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - protected synchronized void deserialize_(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - objectPrefs.clear(); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - - booleanPrefs = (HashMap<String,Boolean>) - objectInputStream.readObject(); - colorPrefs = (HashMap<String,Color>) - objectInputStream.readObject(); - descriptionPrefs = (HashMap<String,String>) - objectInputStream.readObject(); - floatPrefs = (HashMap<String,Float>) - objectInputStream.readObject(); - integerPrefs = (HashMap<String,Integer>) - objectInputStream.readObject(); - longPrefs = (HashMap<String,Long>) - objectInputStream.readObject(); - stringPrefs = (HashMap<String,String>) - objectInputStream.readObject(); - units = (HashMap<String,String>) - objectInputStream.readObject(); - vectorPrefs = (HashMap<String,Vector<Integer>>) - objectInputStream.readObject(); - restrictions = (HashMap<String,VSPrefsRestriction>) - objectInputStream.readObject(); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - } - - /** - * Copies integers into another VSPrefs object. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyIntegers(VSPrefs copyInto, String[] keys) { - for (String key : keys) - copyInto.initInteger(key, - getInteger(key), - getDescription(INTEGER_PREFIX + key), - (VSPrefsRestriction.VSIntegerPrefsRestriction) - getRestriction(INTEGER_PREFIX + key), - getUnit(INTEGER_PREFIX + key)); - } - - /** - * Copies longs into another VSPrefs object. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyLongs(VSPrefs copyInto, String[] keys) { - for (String key : keys) - copyInto.initLong(key, getLong(key), - getDescription(LONG_PREFIX + key), - getUnit(LONG_PREFIX + key)); - } - - /** - * Copies floats into another VSPrefs object. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyFloats(VSPrefs copyInto, String[] keys) { - for (String key : keys) - copyInto.initFloat(key, getFloat(key), - getDescription(FLOAT_PREFIX + key), - getUnit(FLOAT_PREFIX + key)); - } - - /** - * Copies strings into another VSPrefs object. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyStrings(VSPrefs copyInto, String[] keys) { - for (String key : keys) - copyInto.initString(key, getString(key), - getDescription(STRING_PREFIX + key)); - } - - /** - * Copies color references into another VSPrefs object. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyColors(VSPrefs copyInto, String[] keys) { - for (String key : keys) { - Color color = getColor(key); - float comp[] = color.getComponents(null); - copyInto.initColor(key, new Color(comp[0], comp[1], comp[2]), - getDescription(COLOR_PREFIX + key)); - } - } - - /** - * Copies colors. - * - * @param copyInto the copy into - * @param keys the keys - */ - public void copyBooleans(VSPrefs copyInto, String[] keys) { - for (String key : keys) - copyInto.initBoolean(key, getBoolean(key), - getDescription(BOOLEAN_PREFIX + key)); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - String descr = ""; - - Set<String> set = null; - - set = getIntegerKeySet(); - if (set.size() > 0) { - descr += INTEGER_PREFIX; - for (String key : set) - descr += key + "=" + getInteger(key) + "; "; - } - - set = getVectorKeySet(); - if (set.size() > 0) { - descr += VECTOR_PREFIX; - for (String key : set) - descr += key + "=" + getVector(key) + "; "; - } - - set = getLongKeySet(); - if (set.size() > 0) { - descr += LONG_PREFIX; - for (String key : set) - descr += key + "=" + getLong(key) + "; "; - } - - set = getFloatKeySet(); - if (set.size() > 0) { - descr += FLOAT_PREFIX; - for (String key : set) - descr += key + "=" + getFloat(key) + "; "; - } - - set = getBooleanKeySet(); - if (set.size() > 0) { - descr += BOOLEAN_PREFIX; - for (String key : set) - descr += key + "=" + getBoolean(key) + "; "; - } - - set = getStringKeySet(); - if (set.size() > 0) { - descr += STRING_PREFIX; - for (String key : set) - descr += key + "=" + getString(key) + "; "; - } - - if (descr.endsWith("; ")) - return descr.substring(0, descr.length() - 2); - - return descr; - } - - /** - * Gets the iD. - * - * @return the iD - */ - public int getID() { - return id; - } - - /** - * Checks if the prefs are empty. - * - * @return true, if empty - */ - public boolean isEmpty() { - if (!colorPrefs.isEmpty()) - return false; - - if (!floatPrefs.isEmpty()) - return false; - - if (!integerPrefs.isEmpty()) - return false; - - if (!vectorPrefs.isEmpty()) - return false; - - if (!longPrefs.isEmpty()) - return false; - - if (!stringPrefs.isEmpty()) - return false; - - if (!booleanPrefs.isEmpty()) - return false; - - return true; - } - - /** - * Returns all full keys. - * - * @return All full keys - */ - public ArrayList<String> getAllFullKeys() { - ArrayList<String> allKeys = new ArrayList<String>(); - - Set<String> set = null; - - set = getIntegerKeySet(); - for (String key : set) - allKeys.add(INTEGER_PREFIX + key); - - set = getVectorKeySet(); - for (String key : set) - allKeys.add(VECTOR_PREFIX + key); - - set = getLongKeySet(); - for (String key : set) - allKeys.add(LONG_PREFIX + key); - - set = getFloatKeySet(); - for (String key : set) - allKeys.add(FLOAT_PREFIX + key); - - set = getBooleanKeySet(); - for (String key : set) - allKeys.add(BOOLEAN_PREFIX + key); - - set = getStringKeySet(); - for (String key : set) - allKeys.add(STRING_PREFIX + key); - - Collections.sort(allKeys); - - return allKeys; - } - - /** - * Not overwrite description string defaults - */ - /* - public void useDefaultStrings(boolean value) { - useDefaultStrings = value; - } - */ -} diff --git a/sources/prefs/VSPrefsRestriction.java b/sources/prefs/VSPrefsRestriction.java deleted file mode 100644 index 0709713..0000000 --- a/sources/prefs/VSPrefsRestriction.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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; - -import java.io.*; -import java.util.Vector; - -/** - * The class VSPrefsRestriction. - */ -abstract public class VSPrefsRestriction implements Serializable { - private static final long serialVersionUID = 2L; - - /** - * The class VSIntegerPrefsRestriction. - */ - public static class VSIntegerPrefsRestriction extends VSPrefsRestriction { - private static final long serialVersionUID = 2L; - /** The min value. */ - private int minValue; - - /** The max value. */ - private int maxValue; - - /** - * Instantiates a new integer setting restriction. - * - * @param minValue the min value - * @param maxValue the max value - */ - public VSIntegerPrefsRestriction(int minValue, int maxValue) { - this.minValue = minValue; - this.maxValue = maxValue; - } - - /** - * Gets the min value. - * - * @return the min value - */ - public int getMinValue() { - return minValue; - } - - /** - * Gets the max value. - * - * @return the max value - */ - public int getMaxValue() { - return maxValue; - } - - /* (non-Javadoc) - * @see prefs.VSPrefsRestriction#writeObject(java.io.ObjectOutputStream) - */ - public void writeObject(ObjectOutputStream out) - throws IOException { - out.writeObject(new Integer(minValue)); - out.writeObject(new Integer(maxValue)); - } - - /* (non-Javadoc) - * @see prefs.VSPrefsRestriction#readObject(java.io.ObjectInputStream) - */ - public void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException { - minValue = ((Integer) in.readObject()).intValue(); - maxValue = ((Integer) in.readObject()).intValue(); - } - } - - /** - * The class VSStringPrefsRestriction. - */ - public static class VSStringPrefsRestriction extends VSPrefsRestriction { - private static final long serialVersionUID = 2L; - - /** The possible selections. */ - Vector<String> possibleSelections; - - /** - * Instantiates a new string setting restriction. - * - * @param possibleSelections the possible selections - */ - public VSStringPrefsRestriction(String [] possibleSelections) { - this.possibleSelections = new Vector<String>(); - - for (String elem : possibleSelections) - this.possibleSelections.add(elem); - } - - /** - * Gets the possible selections. - * - * @return the possible selections - */ - public Vector<String> getPossibleSelections() { - return possibleSelections; - } - - /* (non-Javadoc) - * @see prefs.VSPrefsRestriction#writeObject(java.io.ObjectOutputStream) - */ - public void writeObject(ObjectOutputStream out) - throws IOException { - out.writeObject(possibleSelections); - } - - /* (non-Javadoc) - * @see prefs.VSPrefsRestriction#readObject(java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException { - possibleSelections = (Vector<String>) in.readObject(); - } - } - - /** - * Serializes the object. - * - * @param out The output stream - */ - abstract public void writeObject(ObjectOutputStream out) - throws IOException; - - /** - * Deserializes the object. - * - * @param in The input stream - */ - abstract public void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException; -} diff --git a/sources/prefs/VSSerializablePrefs.java b/sources/prefs/VSSerializablePrefs.java deleted file mode 100644 index 66a2c83..0000000 --- a/sources/prefs/VSSerializablePrefs.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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; - -import java.io.*; -//import java.util.*; - -import serialize.*; - -/** - * The class VSSerializablePrefs, this class is used if the VSPrefs should - * be serializable. - * - * @author Paul C. Buetow - */ -public class VSSerializablePrefs extends VSPrefs implements VSSerializable { - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 4L; - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - public synchronized void serialize(VSSerialize serialize, - ObjectOutputStream objectOutputStream) - throws IOException { - super.serialize_(serialize, objectOutputStream); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public synchronized void deserialize(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - super.deserialize_(serialize, objectInputStream); - } -} diff --git a/sources/prefs/editors/VSAbstractBetterEditor.java b/sources/prefs/editors/VSAbstractBetterEditor.java deleted file mode 100644 index 556b14a..0000000 --- a/sources/prefs/editors/VSAbstractBetterEditor.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.*; -import java.awt.event.*; -import javax.swing.*; - -import prefs.*; - -/** - * The class VSAbstractBetterEditor, is an improved VSAbstractEditor. - * - * @author Paul C. Buetow - */ -public abstract class VSAbstractBetterEditor extends VSAbstractEditor { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The content pane. */ - private Container contentPane; - - /** The info area. */ - - /** The title. */ - private String title; - - /** - * An simple constructor. - * - * @param prefs the prefs - * @param prefsToEdit the prefs to edit - * @param title the title - */ - public VSAbstractBetterEditor(VSPrefs prefs, VSPrefs prefsToEdit, - String title) { - super(prefs, prefsToEdit); - this.title = title; - this.contentPane = createContentPane(); - } - - /** - * Gets the title. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the content pane. - * - * @return the content pane - */ - public Container getContentPane() { - contentPane.setBackground(Color.WHITE); - return contentPane; - } - - /** - * Creates the content pane. - * - * @return the j panel - */ - private JPanel createContentPane() { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - - JPanel editPanel = getEditPanel(); - JPanel buttonPanel = getButtonPanel(); - - panel.add(editPanel); - panel.add(buttonPanel); - - return panel; - } - - /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#addToButtonPanelFront( - * javax.swing.JPanel) - */ - protected void addToButtonPanelFront(JPanel buttonPanel) { } - - /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#addToButtonPanelLast( - * javax.swing.JPanel) - */ - protected void addToButtonPanelLast(JPanel buttonPanel) { } - - /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#addToEditTableLast() - */ - protected void addToEditTableLast() { } - - /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#actionPerformed( - * java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - //String actionCommand = e.getActionCommand(); - /* More action in the super class!!! */ - super.actionPerformed(e); - } -} diff --git a/sources/prefs/editors/VSAbstractEditor.java b/sources/prefs/editors/VSAbstractEditor.java deleted file mode 100644 index 6118c7e..0000000 --- a/sources/prefs/editors/VSAbstractEditor.java +++ /dev/null @@ -1,1061 +0,0 @@ -/* - * 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.*; -import java.awt.event.*; -import javax.swing.*; -import java.util.*; - -import utils.*; -import prefs.*; - -/** - * The class VSAbstractEditor, an object of this class is used in order to - * edit a VSPrefs object. - * - * @author Paul C. Buetow - */ -public abstract class VSAbstractEditor implements ActionListener { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The boolean keys. */ - private ArrayList<String> booleanKeys; - - /** The color keys. */ - private ArrayList<String> colorKeys; - - /** The float keys. */ - private ArrayList<String> floatKeys; - - /** The integer keys. */ - private ArrayList<String> integerKeys; - - /** The vector keys. */ - private ArrayList<String> vectorKeys; - - /** The long keys. */ - private ArrayList<String> longKeys; - - /** The string keys. */ - private ArrayList<String> stringKeys; - - /** The boolean fields. */ - private HashMap<String,JCheckBox> booleanFields; - - /** The integer fields. */ - private HashMap<String,JComboBox> integerFields; - - /** The vector fields. */ - private HashMap<String,JTextField> vectorFields; - - /** The color fields. */ - private HashMap<String,JTextField> colorFields; - - /** The float fields. */ - private HashMap<String,JTextField> floatFields; - - /** The long fields. */ - private HashMap<String,JTextField> longFields; - - /** The string fields. */ - private HashMap<String,JTextField> stringFields; - - /** The prefs to edit map. */ - private HashMap<String,VSPrefs> prefsToEditMap; - - /** The button panel. */ - private JPanel buttonPanel; - - /** The edit panel. */ - private JPanel editPanel; - - /** The edit table. */ - private VSEditorTable editTable; - - /** The frame. */ - private VSFrame frame; - - /** The expert mode changed. */ - private boolean expertModeChanged; - - /** The prefs. */ - protected VSPrefs prefs; - - /** The prefs to edit. */ - protected VSPrefs prefsToEdit; - - /** The Constant MIN_UNIT_LENGTH. */ - protected static final int MIN_UNIT_LENGTH = 5; - - /** The Constant VALUE_FIELD_COLS. */ - protected static final int VALUE_FIELD_COLS = 9; - - /** The Constant ALL_PREFERENCES. */ - public static final int ALL_PREFERENCES = 0; - - /** The Constant SIMULATION_PREFERENCES. */ - public static final int SIMULATION_PREFERENCES = 1; - - /** - * The standard constructor. - * - * @param prefs the prefs - * @param prefsToEdit the prefs to edit - */ - public VSAbstractEditor(VSPrefs prefs, VSPrefs prefsToEdit) { - init(prefs, prefsToEdit); - } - - /** - * Adds components to the front of the button panel . - * - * @param buttonPanel the button panel - */ - abstract protected void addToButtonPanelFront(JPanel buttonPanel); - - /** - * Adds components to last of the button panel. - * - * @param buttonPanel the button panel - */ - abstract protected void addToButtonPanelLast(JPanel buttonPanel); - - /** - * Adds the to edit table last. - */ - abstract protected void addToEditTableLast(); - - /** - * Sets the default prefs. - * - * @param prefs the new prefs - */ - public void setPrefs(VSPrefs prefs) { - this.prefs = prefs; - } - - /** - * Sets the prefs to edit. - * - * @param prefsToEdit the new prefs to edit - */ - public void setPrefsToEdit(VSPrefs prefsToEdit) { - this.prefsToEdit = prefsToEdit; - } - - /** - * Sets the frame being used by the editor, if any. - * - * @param frame the new frame - */ - public void setFrame(VSFrame frame) { - this.frame = frame; - } - - /** - * Gets the frame. - * - * @return the frame - */ - public VSFrame getFrame() { - return frame; - } - - /** - * The given editors frame will get disposed if the "OK" button has been - * pressed. This can only happen if the editor has its own frame. - */ - protected void disposeFrameIfExists() { - if (frame != null) - frame.dispose(); - } - - /** - * The given editors frame will get disposed if its parent component - * disposes. This can only happen if the editor has its own frame. - */ - protected void disposeFrameWithParentIfExists() { - if (frame != null) - frame.disposeWithParent(); - } - - /** - * Inits the editor. - * - * @param prefs the prefs - * @param prefsToEdit the prefs to edit - */ - private void init(VSPrefs prefs, VSPrefs prefsToEdit) { - this.prefs = prefs; - this.prefsToEdit = prefsToEdit; - - editPanel = createEditPanel(); - buttonPanel = createButtonPanel(); - - prefsToEditMap = new HashMap<String,VSPrefs>(); - - colorFields = new HashMap<String,JTextField>(); - floatFields = new HashMap<String,JTextField>(); - integerFields = new HashMap<String,JComboBox>(); - vectorFields = new HashMap<String,JTextField>(); - longFields = new HashMap<String,JTextField>(); - booleanFields = new HashMap<String,JCheckBox>(); - stringFields = new HashMap<String,JTextField>(); - - colorKeys = filterKeys(prefsToEdit.getColorKeySet()); - floatKeys = filterKeys(prefsToEdit.getFloatKeySet()); - integerKeys = filterKeys(prefsToEdit.getIntegerKeySet()); - vectorKeys = filterKeys(prefsToEdit.getVectorKeySet()); - longKeys = filterKeys(prefsToEdit.getLongKeySet()); - booleanKeys = filterKeys(prefsToEdit.getBooleanKeySet()); - stringKeys = filterKeys(prefsToEdit.getStringKeySet()); - - fillEditPanelFront(prefsToEdit); - fillEditPanel(prefsToEdit); - } - - /** - * Filters out all keys to edit. - * - * @param set the set which contains all keys of a given hash - * - * @return the filtered keys - */ - private ArrayList<String> filterKeys(Set<String> set) { - ArrayList<String> filtered = new ArrayList<String>(); - boolean expertMode = prefs.getBoolean("sim.mode.expert"); - - for (String elem : set) { - if (!elem.startsWith("lang.en.") && !elem.startsWith("keyevent.")) { - if (expertMode) - filtered.add(elem); - else if (!elem.startsWith("col.") && (!elem.startsWith("div."))) - filtered.add(elem); - } - } - - return filtered; - } - - /** - * Creates the button panel. - * - * @return the panel - */ - private JPanel createButtonPanel() { - JPanel buttonPanel = new JPanel(); - buttonPanel.setBackground(Color.WHITE); - addToButtonPanelFront(buttonPanel); - - JButton resetButton = new JButton( - prefs.getString("lang.en.reset")); - resetButton.setMnemonic(prefs.getInteger("keyevent.reset")); - resetButton.addActionListener(this); - buttonPanel.add(resetButton); - - addToButtonPanelLast(buttonPanel); - - return buttonPanel; - } - - /** - * Creates the unit panel. - * - * @param comp the comp - * @param key the key - * - * @return the panel - */ - private JPanel createUnitPanel(VSPrefs prefsToEdit, Component comp, - String fullKey) { - JPanel unitPanel = new JPanel(new GridBagLayout()); - unitPanel.setBackground(Color.WHITE); - unitPanel.setBorder(null); - - String unitText = prefsToEdit.getUnit(fullKey); - if (unitText == null) - unitText = ""; - - unitText = " " + unitText; - while (unitText.length() < MIN_UNIT_LENGTH) - unitText = unitText + " "; - JLabel unitLabel = new JLabel(unitText); - - unitPanel.setLayout(new BoxLayout(unitPanel, BoxLayout.X_AXIS)); - unitPanel.add(comp); - unitPanel.add(unitLabel); - - return unitPanel; - } - - /** - * Creates the edit panel. - * - * @return the panel - */ - private JPanel createEditPanel() { - JPanel editPanel = new JPanel(); - editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.Y_AXIS)); - editPanel.setBackground(Color.WHITE); - - editTable = new VSEditorTable(prefs); - JScrollPane scrollPane = new JScrollPane(editTable); - editPanel.add(scrollPane); - - return editPanel; - } - - /** - * Creates the integer component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JComboBox> createIntegerComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - Integer integer = prefsToEdit.getInteger(key); - Integer initialSelection[] = { integer }; - JComboBox valComboBox = new JComboBox(initialSelection); - VSPrefsRestriction settingRestriction = - prefsToEdit.getRestriction(fullKey); - - int minValue, maxValue; - if (settingRestriction != null) { - VSPrefsRestriction.VSIntegerPrefsRestriction - integerVSPrefsRestriction = - (VSPrefsRestriction.VSIntegerPrefsRestriction) - settingRestriction; - minValue = integerVSPrefsRestriction.getMinValue(); - maxValue = integerVSPrefsRestriction.getMaxValue(); - - } else { - minValue = 0; - maxValue = 100; - } - - for (int i = minValue; i <= maxValue; ++i) - valComboBox.addItem(new Integer(i)); - valComboBox.setBorder(null); - - return new VS3Tupel<String,Component,JComboBox>(label, - createUnitPanel(prefsToEdit, valComboBox, fullKey), - valComboBox); - } - - /** - * Creates the vector component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JTextField> createVectorComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - - Vector<Integer> vec = prefsToEdit.getVector(key); - JTextField valField = new JTextField(); - valField.setBorder(null); - valField.setText(vec.toString()); - - return new VS3Tupel<String,Component,JTextField>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Creates the boolean component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - */ - protected VS3Tupel<String,Component,JCheckBox> createBooleanComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - final String activated = prefs.getString("lang.en.activated"); - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - JCheckBox valField = new JCheckBox(activated, - prefsToEdit.getBoolean(key)); - valField.setBackground(Color.WHITE); - valField.setBorder(null); - return new VS3Tupel<String,Component,JCheckBox>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Creates the long component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JTextField> createLongComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - JTextField valField = new JTextField(VALUE_FIELD_COLS); - valField.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent e) { - JTextField valField = (JTextField)e.getSource(); - if (valField.getText().length() >= valField.getColumns() + 10) - e.consume(); - } - }); - valField.setText(""+prefsToEdit.getLong(key)); - valField.setBorder(null); - return new VS3Tupel<String,Component,JTextField>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Creates the float component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JTextField> createFloatComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - JTextField valField = new JTextField(VALUE_FIELD_COLS); - valField.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent e) { - JTextField valField = (JTextField)e.getSource(); - if (valField.getText().length() >= valField.getColumns() + 10) - e.consume(); - } - }); - valField.setText(""+prefsToEdit.getFloat(key)); - valField.setBorder(null); - return new VS3Tupel<String,Component,JTextField>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Creates the color component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JTextField> createColorComponent( - String fullKey, String key, final VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - final JTextField valField = new JTextField(VALUE_FIELD_COLS); - Color color = prefsToEdit.getColor(key); - valField.setBackground(color); - valField.setEditable(false); - valField.addMouseListener(new MouseListener() { - public void mouseExited(MouseEvent e) { } - public void mouseReleased(MouseEvent e) { } - public void mouseEntered(MouseEvent e) { } - public void mousePressed(MouseEvent e) { } - public void mouseClicked(MouseEvent e) { - JFrame parentFrame = getFrame(); - JFrame frame = new VSFrame( - prefs.getString("lang.en.name") + " - " + - prefs.getString( - "lang.en.colorchooser"),parentFrame); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - JComponent colorChooserPane = new VSColorChooser(prefs, - valField); - colorChooserPane.setOpaque(true); - - frame.setContentPane(colorChooserPane); - frame.pack(); - frame.setVisible(true); - } - }); - valField.setBorder(null); - return new VS3Tupel<String,Component,JTextField>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Creates the string component. - * - * @param fullKey the full key - * @param key the key - * @param prefsToEdit the prefs to edit - * - * @return the tupel representing the component - */ - protected VS3Tupel<String,Component,JTextField> createStringComponent( - String fullKey, String key, VSPrefs prefsToEdit) { - String descr = prefs.getDescription(fullKey); - if (descr == null) - descr = prefsToEdit.getDescription(fullKey); - String label = descr == null ? fullKey : descr; - JTextField valField = new JTextField(VALUE_FIELD_COLS); - valField.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent e) { - JTextField valField = (JTextField)e.getSource(); - if (valField.getText().length() >= valField.getColumns() + 10) - e.consume(); - } - }); - valField.setText(prefsToEdit.getString(key)); - valField.setBorder(null); - return new VS3Tupel<String,Component,JTextField>(label, - createUnitPanel(prefsToEdit, valField, fullKey), valField); - } - - /** - * Fills the edit panel at the front. May be overloaded by another class. - * - * @param prefsToEdit the prefs to edit - */ - protected void fillEditPanelFront(VSPrefs prefsToEdit) { - } - - /** - * Fills the edit panel. - * - * @param prefsToEdit the prefs to edit - */ - private void fillEditPanel(VSPrefs prefsToEdit) { - HashMap<String,Component> components = new HashMap<String,Component>(); - HashMap<String,String> labels = new HashMap<String,String>(); - - for (String key : integerKeys) { - String fullKey = VSPrefs.INTEGER_PREFIX + key; - VS3Tupel<String,Component,JComboBox> tupel = - createIntegerComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - integerFields.put(key, tupel.getC()); - } - - for (String key : vectorKeys) { - String fullKey = VSPrefs.VECTOR_PREFIX + key; - VS3Tupel<String,Component,JTextField> tupel = - createVectorComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - vectorFields.put(key, tupel.getC()); - } - - for (String key : booleanKeys) { - String fullKey = VSPrefs.BOOLEAN_PREFIX + key; - VS3Tupel<String,Component,JCheckBox> tupel = - createBooleanComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - booleanFields.put(key, tupel.getC()); - } - - for (String key : longKeys) { - String fullKey = VSPrefs.LONG_PREFIX + key; - VS3Tupel<String,Component,JTextField> tupel = - createLongComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - longFields.put(key, tupel.getC()); - } - - - for (String key : floatKeys) { - String fullKey = VSPrefs.FLOAT_PREFIX + key; - VS3Tupel<String,Component,JTextField> tupel = - createFloatComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - floatFields.put(key, tupel.getC()); - } - - - for (String key : colorKeys) { - String fullKey = VSPrefs.COLOR_PREFIX + key; - VS3Tupel<String,Component,JTextField> tupel = - createColorComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - colorFields.put(key, tupel.getC()); - } - - for (String key : stringKeys) { - String fullKey = VSPrefs.STRING_PREFIX + key; - VS3Tupel<String,Component,JTextField> tupel = - createStringComponent(fullKey, key, prefsToEdit); - labels.put(fullKey, tupel.getA()); - components.put(fullKey, tupel.getB()); - stringFields.put(key, tupel.getC()); - } - - ArrayList<String> fullKeys = new ArrayList<String>(); - fullKeys.addAll(components.keySet()); - Collections.sort(fullKeys); - - boolean flag = false; - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(' ')+1); - if (key.startsWith("sim.")) { - if (!flag) { - flag = true; - addSeparator(prefs.getString("lang.en.prefs.simulator")); - } - addVariable(labels.get(fullKey), components.get(fullKey), - prefsToEdit); - } - } - - flag = false; - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(' ')+1); - if (key.startsWith("process.")) { - if (!flag) { - flag = true; - if (this instanceof VSProcessEditor) - addSeparator(prefs.getString("lang.en.prefs.process")); - else - addSeparator(prefs.getString( - "lang.en.prefs.process.defaults")); - } - addVariable(labels.get(fullKey), components.get(fullKey), - prefsToEdit); - } - } - - flag = false; - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(' ')+1); - if (key.startsWith("message.")) { - if (!flag) { - flag = true; - if (this instanceof VSProcessEditor) - addSeparator(prefs.getString( - "lang.en.prefs.message")); - else - addSeparator(prefs.getString( - "lang.en.prefs.message.defaults")); - } - addVariable(labels.get(fullKey), components.get(fullKey), - prefsToEdit); - } - } - - flag = false; - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(' ')+1); - if (key.startsWith("col.")) { - if (!flag) { - flag = true; - addSeparator(prefs.getString("lang.en.prefs.color")); - } - addVariable(labels.get(fullKey), components.get(fullKey), - prefsToEdit); - } - } - - flag = false; - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(' ')+1); - if (key.startsWith("div.")) { - if (!flag) { - flag = true; - addSeparator(prefs.getString("lang.en.prefs.diverse")); - } - addVariable(labels.get(fullKey), components.get(fullKey), - prefsToEdit); - } - } - - addToEditTableLast(); - editTable.fireTableDataChanged(); - } - - /** - * Filters out stuff. - * - * @param set The set to filter stuff out from - * @param filter Only return elemens of the filter which are in the set - * @param prefix The prefix to use - * - * @return The filtered keys - */ - private ArrayList<String> filterOut(Set<String> set, - ArrayList<String> filter, - String prefix) { - ArrayList<String> ret = new ArrayList<String>(); - - for (String key : set) { - String fullKey = prefix + key; - if (filter.contains(fullKey)) - ret.add(fullKey); - } - - return ret; - } - - /** - * Adds the to editor more variables. - * - * @param label the label - * @param prefsKey the prefs key - * @param prefsToAdd the prefs to add - * @param addOnlyThisVariables only add variables which are in this list - */ - protected void addToEditor(String label, String prefsKey, - VSPrefs prefsToAdd, - ArrayList<String> addOnlyThisVariables) { - addSeparator(label); - prefsKey = "(" + prefsKey + ")"; - - ArrayList<String> fullKeys = new ArrayList<String>(); - - fullKeys.addAll(filterOut(prefsToAdd.getIntegerKeySet(), - addOnlyThisVariables, - VSPrefs.INTEGER_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getVectorKeySet(), - addOnlyThisVariables, - VSPrefs.VECTOR_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getFloatKeySet(), - addOnlyThisVariables, - VSPrefs.FLOAT_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getLongKeySet(), - addOnlyThisVariables, - VSPrefs.LONG_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getBooleanKeySet(), - addOnlyThisVariables, - VSPrefs.BOOLEAN_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getStringKeySet(), - addOnlyThisVariables, - VSPrefs.STRING_PREFIX)); - - Collections.sort(fullKeys); - - for (String fullKey : fullKeys) { - String key = fullKey.substring(fullKey.indexOf(": ") + 2); - if (fullKey.startsWith(VSPrefs.INTEGER_PREFIX)) { - VS3Tupel<String,Component,JComboBox> tupel = - createIntegerComponent(fullKey, key, prefsToAdd); - this.integerKeys.add(prefsKey+key); - this.integerFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - - } else if (fullKey.startsWith(VSPrefs.VECTOR_PREFIX)) { - VS3Tupel<String,Component,JTextField> tupel = - createVectorComponent(fullKey, key, prefsToAdd); - this.vectorKeys.add(prefsKey+key); - this.vectorFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - - } else if (fullKey.startsWith(VSPrefs.BOOLEAN_PREFIX)) { - VS3Tupel<String,Component,JCheckBox> tupel = - createBooleanComponent(fullKey, key, prefsToAdd); - this.booleanKeys.add(prefsKey + key); - this.booleanFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - - } else if (fullKey.startsWith(VSPrefs.LONG_PREFIX)) { - VS3Tupel<String,Component,JTextField> tupel = - createLongComponent(fullKey, key, prefsToAdd); - this.longKeys.add(prefsKey+key); - this.longFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - - } else if (fullKey.startsWith(VSPrefs.FLOAT_PREFIX)) { - VS3Tupel<String,Component,JTextField> tupel = - createFloatComponent(fullKey, key, prefsToAdd); - this.floatKeys.add(prefsKey + key); - this.floatFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - - } else if (fullKey.startsWith(VSPrefs.STRING_PREFIX)) { - VS3Tupel<String,Component,JTextField> tupel = - createStringComponent(fullKey, key, prefsToAdd); - this.stringKeys.add(prefsKey + key); - this.stringFields.put(prefsKey+key, tupel.getC()); - addVariable(prefsKey, tupel.getA(), tupel.getB(), prefsToAdd); - } - } - } - - /** - * Adds a separator. - * - * @param label the label - */ - protected void addSeparator(String label) { - editTable.addSeparator(label); - } - - /** - * Adds a variable. - * - * @param label the label - * @param component the component - * @param prefs the prefs - */ - private void addVariable(String label, Component component, VSPrefs prefs) { - addVariable("", label, component, prefs); - } - - /** - * Adds a variable. - * - * @param prefsKey the prefs key - * @param label the label - * @param component the component - * @param prefs the prefs - */ - private void addVariable(String prefsKey, String label, - Component component, VSPrefs prefs) { - prefsToEditMap.put(prefsKey, prefs); - editTable.addVariable(label, component); - } - - /** - * Reset edit panel. - */ - protected void resetPrefs() { - for (String key : integerKeys) { - JComboBox valComboBox = integerFields.get(key); - valComboBox.setSelectedIndex(0); - } - - for (String key : booleanKeys) { - String keys[] = getKeys(key); - JCheckBox valField = booleanFields.get(key); - valField.setSelected(prefsToEditMap.get( - keys[1]).getBoolean(keys[0])); - } - - for (String key : vectorKeys) { - String keys[] = getKeys(key); - JTextField valField = vectorFields.get(key); - valField.setText(""+prefsToEditMap.get(keys[1]).getVector(keys[0])); - } - - for (String key : floatKeys) { - String keys[] = getKeys(key); - JTextField valField = floatFields.get(key); - valField.setText(""+prefsToEditMap.get(keys[1]).getFloat(keys[0])); - } - - for (String key : longKeys) { - String keys[] = getKeys(key); - JTextField valField = longFields.get(key); - valField.setText(""+prefsToEditMap.get(keys[1]).getLong(keys[0])); - } - - for (String key : colorKeys) { - String keys[] = getKeys(key); - JTextField valField = colorFields.get(key); - valField.setBackground(prefsToEditMap.get( - keys[1]).getColor(keys[0])); - } - - for (String key : stringKeys) { - String keys[] = getKeys(key); - JTextField valField = stringFields.get(keys); - valField.setText(prefsToEditMap.get(keys[1]).getString(keys[0])); - } - } - - /** - * Gets the keys. - * - * @param key the key - * - * @return [0] := key, [1] := prefsKey - */ - private String[] getKeys(String key) { - String keys[] = { key, "" }; - - if (key.startsWith("(")) { - keys[1] = key.substring(0, key.indexOf(")") + 1); - keys[0] = key.substring(key.indexOf(")")+1); - } - - return keys; - } - - /** - * Saves the prefs. - */ - protected void savePrefs() { - boolean expertMode = prefs.getBoolean("sim.mode.expert"); - - for (String key : integerKeys) { - String keys[] = getKeys(key); - JComboBox valComboBox = integerFields.get(key); - prefsToEditMap.get( - keys[1]).setInteger(keys[0], - (Integer) valComboBox.getSelectedItem()); - } - - for (String key : vectorKeys) { - String keys[] = getKeys(key); - JTextField valField = vectorFields.get(key); - - try { - String val = valField.getText(); - Vector<Integer> vec = utils.VSTools.parseIntegerVector(val); - prefsToEditMap.get(keys[1]).setVector(keys[0], vec); - } catch (exceptions.VSParseIntegerVectorException e) { - } - - valField.setText(""+ - prefsToEditMap.get(keys[1]).getVector(keys[0])); - } - - for (String key : booleanKeys) { - String keys[] = getKeys(key); - JCheckBox valField = booleanFields.get(key); - prefsToEditMap.get(keys[1]).setBoolean( - keys[0], valField.isSelected()); - } - - for (String key : floatKeys) { - String keys[] = getKeys(key); - JTextField valField = floatFields.get(key); - - try { - Float val = Float.valueOf(valField.getText()); - prefsToEditMap.get(keys[1]).setFloat(keys[0], val); - - } catch (NumberFormatException e) { - valField.setText(""+ - prefsToEditMap.get(keys[1]).getFloat(keys[0])); - } - } - - for (String key : longKeys) { - String keys[] = getKeys(key); - JTextField valField = longFields.get(key); - - try { - Long val = Long.valueOf(valField.getText()); - prefsToEditMap.get(keys[1]).setLong(keys[0], val); - - } catch (NumberFormatException e) { - valField.setText(""+ - prefsToEditMap.get(keys[1]).getLong(keys[0])); - } - } - - for (String key : colorKeys) { - String keys[] = getKeys(key); - JTextField valField = colorFields.get(key); - prefsToEditMap.get(keys[1]).setColor( - keys[0], valField.getBackground()); - } - - for (String key : stringKeys) { - String keys[] = getKeys(key); - JTextField valField = stringFields.get(key); - prefsToEditMap.get(keys[1]).setString(keys[0], valField.getText()); - } - - expertModeChanged = expertMode != prefs.getBoolean("sim.mode.expert"); - } - - /** - * Check if the expert mode has changed. - * - * @return true, if it has changed. false, if it has not changed. - */ - public boolean expertModeChanged() { - boolean ret = expertModeChanged; - - if (expertModeChanged) - expertModeChanged = false; - - return ret; - } - - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed( - * java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - String actionCommand = e.getActionCommand(); - - if (actionCommand.equals(prefs.getString("lang.en.takeover"))) { - savePrefs(); - - } else if (actionCommand.equals(prefs.getString("lang.en.reset"))) { - resetPrefs(); - } - } - - /** - * Gets the edit panel - * - * @return the edit panel - */ - public JPanel getEditPanel() { - return editPanel; - } - - /** - * Gets the edit table - * - * @return the edit table - */ - public VSEditorTable getEditTable() { - return editTable; - } - - /** - * Gets the button panel. - * - * @return the button panel - */ - public JPanel getButtonPanel() { - return buttonPanel; - } -} diff --git a/sources/prefs/editors/VSColorChooser.java b/sources/prefs/editors/VSColorChooser.java deleted file mode 100644 index 619bc17..0000000 --- a/sources/prefs/editors/VSColorChooser.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.*; -import javax.swing.*; -import javax.swing.event.*; - -import prefs.VSPrefs; - -/** - * The class VSColorChooser, is for selecting a color within an editor. - * - * @author Paul C. Buetow - */ -public class VSColorChooser extends JPanel implements ChangeListener { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The color chooser. */ - protected JColorChooser colorChooser; - - /** The color. */ - private Color color; - - /** The val field. */ - private JTextField valField; - - /** - * Instantiates a new VSColorChooser object. - * - * @param prefs the prefs - * @param valField the val field - */ - public VSColorChooser(VSPrefs prefs, JTextField valField) { - super(new BorderLayout()); - this.color = valField.getBackground(); - this.valField = valField; - - colorChooser = new JColorChooser(Color.yellow); - colorChooser.setColor(color); - colorChooser.getSelectionModel().addChangeListener(this); - colorChooser.setBorder(BorderFactory.createTitledBorder( - prefs.getString("lang.en.colorchooser2"))); - add(colorChooser, BorderLayout.CENTER); - } - - /* (non-Javadoc) - * @see javax.swing.event.ChangeListener#stateChanged( - * javax.swing.event.ChangeEvent) - */ - public void stateChanged(ChangeEvent e) { - Color newColor = colorChooser.getColor(); - valField.setBackground(newColor); - valField.repaint(); - } -} diff --git a/sources/prefs/editors/VSEditorFrame.java b/sources/prefs/editors/VSEditorFrame.java deleted file mode 100644 index 855bf0a..0000000 --- a/sources/prefs/editors/VSEditorFrame.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.*; -import java.awt.event.*; -import javax.swing.*; - -import prefs.*; -import utils.*; - -/** - * The class VSEditorFrame, this is a wrapper around an VSAbstractEditor - * object, which should be displayed in its own frame. - * - * @author Paul C. Buetow - */ -public class VSEditorFrame extends VSFrame implements ActionListener { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The editor. */ - private VSAbstractBetterEditor editor; - - /** The prefs. */ - private VSPrefs prefs; - - /** - * Instantiates a new VSEditorFrame object. - * - * @param prefs the prefs - * @param relativeTo the relative to - * @param editor the editor - */ - public VSEditorFrame(VSPrefs prefs, Component relativeTo, - VSAbstractBetterEditor editor) { - super(editor.getTitle(), relativeTo); - this.prefs = prefs; - this.editor = editor; - init(); - } - - /** - * Inits the VSEditorFrame object. - */ - private void init() { - editor.setFrame(this); - fillButtonPanel(editor.getButtonPanel()); - setContentPane(editor.getContentPane()); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setSize(prefs.getInteger("div.window.prefs.xsize"), - prefs.getInteger("div.window.prefs.ysize")); - setResizable(false); - setVisible(true); - } - - /** - * Fills the button panel. - * - * @param buttonPanel the button panel - */ - private void fillButtonPanel(JPanel buttonPanel) { - JButton okButton = new JButton( - prefs.getString("lang.en.ok")); - okButton.setMnemonic(prefs.getInteger("keyevent.ok")); - okButton.addActionListener(this); - buttonPanel.add(okButton, 0); - - JButton cancelButton = new JButton( - prefs.getString("lang.en.cancel")); - cancelButton.setMnemonic(prefs.getInteger("keyevent.cancel")); - cancelButton.addActionListener(this); - buttonPanel.add(cancelButton, 1); - buttonPanel.repaint(); - } - - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed( - * java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - String actionCommand = e.getActionCommand(); - - if (actionCommand.equals(prefs.getString("lang.en.ok"))) { - editor.actionPerformed(e); - dispose(); - - } else if (actionCommand.equals(prefs.getString("lang.en.cancel"))) { - editor.actionPerformed(e); - dispose(); - - } else { - editor.actionPerformed(e); - } - } -} diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java deleted file mode 100644 index 246bd8e..0000000 --- a/sources/prefs/editors/VSEditorTable.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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.util.*; - -import java.awt.*; -//import java.io.*; -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.text.*; - -import prefs.*; - -/** - * The class VSEditorTable, each VSAbstractEditor uses an object of this class - * for displaying all editable items! - * - * @author Paul C. Buetow - */ -public class VSEditorTable extends JTable { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The Constant MIN_ROWS. */ - //private static final int MIN_ROWS = 20; - - /** The prefs. */ - //private VSPrefs prefs; - - /** The nodes. */ - private ArrayList<VSNode> nodes; - - /** The model. */ - private VSEditorTableModel model; - - /** - * The class VSNode. - */ - private class VSNode { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The key. */ - private String key; - - /** The comp. */ - private Component comp; - - /** - * Instantiates a new VSNode object. - * - * @param key the key - */ - public VSNode(String key) { - this.key = key; - } - - /** - * Instantiates a new VSNode object. - * - * @param key the key - * @param comp the comp - */ - public VSNode(String key, Component comp) { - this.key = key; - this.comp = comp; - } - - /** - * Gets the key. - * - * @return the key - */ - public String getKey() { - return key; - } - - /** - * Gets the component. - * - * @return the component - */ - public Component getComponent() { - return comp; - } - - /** - * Gets the renderer component. - * - * @return the renderer component - */ - public Component getRendererComponent() { - return comp; - } - - /** - * Checks if it is a separator. - * - * @return true, if is separator - */ - public boolean isSeparator() { - return comp == null; - } - } - - /** - * The class VSEditorTableModel, it is the model of a VSEditorTable. - */ - private class VSEditorTableModel extends AbstractTableModel - implements TableCellRenderer { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new lang.process.removeeditor table model. - */ - public VSEditorTableModel() { - } - - /* (non-Javadoc) - * @see javax.swing.table.AbstractTableModel#getColumnName(int) - */ - public String getColumnName(int col) { - return ""; - } - - /* (non-Javadoc) - * @see javax.swing.table.TableModel#getRowCount() - */ - public int getRowCount() { - return nodes.size(); - } - - /* (non-Javadoc) - * @see javax.swing.table.TableModel#getColumnCount() - */ - public int getColumnCount() { - return 2; - } - - /* (non-Javadoc) - * @see javax.swing.table.TableModel#getValueAt(int, int) - */ - public Object getValueAt(int row, int col) { - VSNode node = nodes.get(row); - - if (node.isSeparator()) { - if (col == 1) - return ""; - - return node.getKey(); - } - - if (col == 0) - return node.getKey(); - - return node.getComponent(); - } - - /* (non-Javadoc) - * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int) - */ - public boolean isCellEditable(int row, int col) { - if (col == 0) - return false; - - if (nodes.get(row).isSeparator()) - return false; - - return true; - } - - /* (non-Javadoc) - * @see javax.swing.table.AbstractTableModel#setValueAt( - * java.lang.Object, int, int) - */ - public void setValueAt(Object value, int row, int col) { - } - - /* (non-Javadoc) - * @see - * javax.swing.table.TableCellRenderer#getTableCellRendererComponent( - * javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) - */ - public Component getTableCellRendererComponent(JTable table, - Object object, boolean isSelected, boolean hasFocus, int - row, int col) { - - VSNode node = nodes.get(row); - - if (node.isSeparator()) { - JTextPane pane = new JTextPane(); - if (col == 0) { - pane.setText(node.getKey()); - Style style = pane.addStyle("Bold", null); - StyleConstants.setBold(style, true); - } - pane.setBackground(new Color(0xCF, 0xCF, 0XCF)); - return pane; - } - - if (col == 0) { - JTextField field = new JTextField(" "+node.getKey()+":"); - field.setBorder(null); - field.setEditable(false); - field.setBackground(Color.WHITE); - return field; - } - - return node.getRendererComponent(); - } - } - - /** - * The class VSTableCellEditor, is the editor of the VSEditorTable - */ - private class VSTableCellEditor extends AbstractCellEditor - implements TableCellEditor { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /* (non-Javadoc) - * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent( - * javax.swing.JTable, java.lang.Object, boolean, int, int) - */ - public Component getTableCellEditorComponent(JTable table, - Object object, - boolean isSelected, - int row, - int col) { - return nodes.get(row).getComponent(); - } - - /* (non-Javadoc) - * @see javax.swing.CellEditor#getCellEditorValue() - */ - public Object getCellEditorValue() { - return new String(""); - } - } - - /** - * Instantiates a new VSEditorTable object. - * - * @param prefs the prefs - */ - public VSEditorTable(VSPrefs prefs) { - //this.prefs = prefs; - this.nodes = new ArrayList<VSNode>(); - this.model = new VSEditorTableModel(); - setModel(model); - setDefaultRenderer(Object.class, model); - setDefaultEditor(Object.class, new VSTableCellEditor()); - setIntercellSpacing(new Dimension(5, 5)); - setRowHeight(25); - setBackground(Color.WHITE); - getTableHeader().setVisible(false); - TableColumn col = getColumnModel().getColumn(1); - col.setMinWidth(100); - col.setMaxWidth(100); - col.setResizable(false); - - col = getColumnModel().getColumn(0); - col.sizeWidthToFit(); - } - - /** - * Adds the variable. - * - * @param key the key - * @param comp the comp - */ - public void addVariable(String key, Component comp) { - nodes.add(new VSNode(key, comp)); - } - - /** - * Adds the separator. - * - * @param text the text - */ - public void addSeparator(String text) { - nodes.add(new VSNode(text)); - } - - /** - * Fires that the table data has changed. - */ - public void fireTableDataChanged() { - model.fireTableDataChanged(); - } -} diff --git a/sources/prefs/editors/VSProcessEditor.java b/sources/prefs/editors/VSProcessEditor.java deleted file mode 100644 index eaacc7b..0000000 --- a/sources/prefs/editors/VSProcessEditor.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 java.util.*; - -import core.*; -import protocols.*; -import events.*; -import prefs.VSPrefs; - -/** - * The class VSProcessEditor, is for editing a VSInternalProcess object. - * - * @author Paul C. Buetow - */ -public class VSProcessEditor extends VSAbstractBetterEditor { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The process. */ - private VSInternalProcess process; - - /** The TAKEOVE r_ button. */ - public static boolean TAKEOVER_BUTTON; - - /** - * Instantiates a new VSProcessEditor object. - * - * @param prefs the prefs - * @param process the process - */ - public VSProcessEditor(VSPrefs prefs, VSInternalProcess process) { - super(prefs, process, prefs.getString("lang.en.name") + " - " + - prefs.getString("lang.en.prefs.process"));; - this.process = process; - disposeFrameWithParentIfExists(); - makeProtocolVariablesEditable(); - } - - /* (non-Javadoc) - * @see prefs.editors.VSAbstractBetterEditor#addToButtonPanelFront( - * javax.swing.JPanel) - */ - protected void addToButtonPanelFront(JPanel buttonPanel) { - JButton takeoverButton = new JButton( - prefs.getString("lang.en.takeover")); - takeoverButton.setMnemonic(prefs.getInteger("keyevent.takeover")); - takeoverButton.addActionListener(this); - buttonPanel.add(takeoverButton); - } - - /** - * Make protocol variables editable. - */ - protected void makeProtocolVariablesEditable() { - ArrayList<String> editableProtocolsClassnames = - VSRegisteredEvents.getEditableProtocolsClassnames(); - - //String protocolString = " " + prefs.getString("lang.en.protocol"); - String clientString = " " + prefs.getString("lang.en.client"); - String serverString = " " + prefs.getString("lang.en.server"); - - for (String protocolClassname : editableProtocolsClassnames) { - String protocolShortname = - VSRegisteredEvents.getShortnameByClassname( - protocolClassname); - VSAbstractProtocol protocol = - process.getProtocolObject(protocolClassname); - protocol.onClientInit(); - protocol.onServerInit(); - - ArrayList<String> clientVariables = - VSRegisteredEvents.getProtocolClientVariables( - protocolClassname); - if (clientVariables != null) - addToEditor(protocolShortname + clientString, - protocolShortname, protocol, clientVariables); - - ArrayList<String> serverVariables = - VSRegisteredEvents.getProtocolServerVariables( - protocolClassname); - if (serverVariables != null) - addToEditor(protocolShortname + serverString, - protocolShortname, protocol, serverVariables); - } - } - - /* (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.en.ok"))) { - savePrefs(); - process.updateFromPrefs(); - - } else if (actionCommand.equals(prefs.getString("lang.en.takeover"))) { - savePrefs(); - process.updateFromPrefs(); - - } else { - super.actionPerformed(e); - } - } -} diff --git a/sources/prefs/editors/VSSimulatorEditor.java b/sources/prefs/editors/VSSimulatorEditor.java deleted file mode 100644 index edd9cd5..0000000 --- a/sources/prefs/editors/VSSimulatorEditor.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.en.name") - + " - " + prefs.getString("lang.en.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.en.name") - + " - " + prefs.getString("lang.en.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.en.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.en.takeover"))) { - savePrefs(); - - if (simulator != null) { - if (expertModeChanged()) - simulator.fireExpertModeChanged(); - simulator.updateFromPrefs(); - } - - } else if (actionCommand.equals(prefs.getString("lang.en.cancel"))) { - if (!dontStartNewSimulator && openedNewWindow) - simulatorFrame.dispose(); - - } else if (actionCommand.equals(prefs.getString("lang.en.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); - } - } -} |
