summaryrefslogtreecommitdiff
path: root/sources/prefs/editors
diff options
context:
space:
mode:
Diffstat (limited to 'sources/prefs/editors')
-rw-r--r--sources/prefs/editors/VSAbstractBetterEditor.java126
-rw-r--r--sources/prefs/editors/VSAbstractEditor.java1061
-rw-r--r--sources/prefs/editors/VSColorChooser.java78
-rw-r--r--sources/prefs/editors/VSEditorFrame.java117
-rw-r--r--sources/prefs/editors/VSEditorTable.java314
-rw-r--r--sources/prefs/editors/VSProcessEditor.java131
-rw-r--r--sources/prefs/editors/VSSimulatorEditor.java143
7 files changed, 0 insertions, 1970 deletions
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);
- }
- }
-}