Il giorno lun, 05/03/2007 alle 18.57 +0100, Mario Torre ha scritto:
> Let me know what do you think about it!
OOps...
For some reason I've removed a class from the patch... This is the
correct one.
Mario
2007-03-05 Mario Torre <[EMAIL PROTECTED]>
* tools/gccontrolcenter.in: new tool to setup runtime preferences.
* tools/Makefile.am: enable build of gccontrolcenter.in
* tools/gnu/classpath/tools/setup: new package.
* tools/gnu/classpath/tools/setup/Main.java: new file.
* tools/gnu/classpath/tools/setup/ClasspathPreferencesHandler.java:
likewise.
* tools/gnu/classpath/tools/setup/PreferenceNode.java: likewise.
* tools/gnu/classpath/tools/setup/PreferenceOption.java: likewise.
* tools/gnu/classpath/tools/setup/PreferencesController.java: likewise.
* tools/gnu/classpath/tools/setup/PreferencesTab.java: likewise.
* tools/gnu/classpath/tools/setup/resources/classpathPreferences.xml:
likewise.
--
Lima Software - http://www.limasoftware.net/
GNU Classpath Developer - http://www.classpath.org/
Jabber: [EMAIL PROTECTED] - Profile:
http://www.gtalkprofile.com/profile/9661.html
pgp key: http://subkeys.pgp.net/
PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P classpath
Index: tools/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/tools/Makefile.am,v
retrieving revision 1.38
diff -u -r1.38 Makefile.am
--- tools/Makefile.am 1 Mar 2007 00:26:08 -0000 1.38
+++ tools/Makefile.am 5 Mar 2007 21:01:50 -0000
@@ -28,7 +28,7 @@
bin_SCRIPTS =
bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
gjar gnative2ascii gserialver gjavah grmiregistry \
- gtnameserv gorbd grmid grmic
+ gtnameserv gorbd grmid grmic gccontrolcenter
AM_CPPFLAGS = -Wall \
@@ -98,15 +98,21 @@
-DTOOLPACKAGE="\"rmic\"" \
-DTOOLNAME="\"grmic\""
+gccontrolcenter_SOURCES = toolwrapper.c
+gccontrolcenter_CFLAGS = \
+ -DTOOLPACKAGE="\"setup\"" \
+ -DTOOLNAME="\"setup\""
+
+
else
bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
gjar gnative2ascii gserialver gjavah grmiregistry \
- gtnameserv gorbd grmid grmic
+ gtnameserv gorbd grmid grmic gccontrolcenter
bin_PROGRAMS =
endif
EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
gjar.in gnative2ascii.in gserialver.in gjavah.in grmiregistry.in \
- gtnameserv.in gorbd.in grmid.in grmic.in
+ gtnameserv.in gorbd.in grmid.in grmic.in gccontrolcenter.in
# All our example java source files
TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java \
@@ -134,8 +140,10 @@
# RMIC templates that must be included in the generated zip file.
RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmic/templates/*.jav
+CCENTER_CONFIG_FILE = $(srcdir)/gnu/classpath/tools/setup/resources/classpathPreferences.xml
+
# All the files we find "interesting"
-ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES)
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES) $(CCENTER_CONFIG_FILE)
# Some architecture independent data to be installed.
TOOLS_DATA = $(TOOLS_ZIP)
Index: tools/gnu/classpath/tools/setup/ClasspathPreferencesHandler.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/ClasspathPreferencesHandler.java
diff -N tools/gnu/classpath/tools/setup/ClasspathPreferencesHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/ClasspathPreferencesHandler.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,140 @@
+/* ClasspathPreferencesHandler.java -- Handle the parsing of the preference
+ config file.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.setup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class ClasspathPreferencesHandler
+ extends DefaultHandler
+{
+ private List<PreferenceNode> nodes = new ArrayList<PreferenceNode>();
+ private PreferenceNode currentElement = null;
+
+ private boolean parsingDescription = false;
+
+ private boolean done = false;
+
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes attributes)
+ throws SAXException
+ {
+ super.startElement(namespaceURI, localName, qName, attributes);
+
+ if (qName.compareTo("node") == 0)
+ {
+ currentElement = new PreferenceNode();
+
+ currentElement.setName(attributes.getValue("name"));
+ currentElement.setType(attributes.getValue("type"));
+ currentElement.setClassName(attributes.getValue("class"));
+ }
+
+ if (currentElement == null) return;
+
+ if (qName.compareTo("property") == 0)
+ {
+ PreferenceOption option = new PreferenceOption();
+
+ option.setName(attributes.getValue("name"));
+ option.setNode(attributes.getValue("node"));
+ option.setKey(attributes.getValue("key"));
+ option.setTooltip(attributes.getValue("tooltip"));
+ option.setDefaultValue(attributes.getValue("defaultValue"));
+ option.setType(currentElement.getType());
+
+ currentElement.addOption(option);
+ }
+
+ if (qName.compareTo("description") == 0)
+ parsingDescription = true;
+
+ }
+
+ public void characters(char[] ch, int start, int length)
+ throws SAXException
+ {
+ if (currentElement == null) return;
+
+ if (parsingDescription)
+ {
+ String description = currentElement.getDescription();
+ if (description == null) description = "";
+
+ String newData = new String(ch, start, length);
+ currentElement.setDescription(description + newData);
+ }
+ }
+
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException
+ {
+ if (qName.compareTo("node") == 0)
+ {
+ nodes.add(currentElement);
+ currentElement = null;
+ }
+
+ if (qName.compareTo("description") == 0)
+ parsingDescription = false;
+ }
+
+ public void endDocument()
+ throws SAXException
+ {
+ done = true;
+ }
+
+ public boolean parsingDone()
+ {
+ return done;
+ }
+
+ public List<PreferenceNode> getNodes()
+ {
+ return nodes;
+ }
+}
Index: tools/gnu/classpath/tools/setup/PreferencesTab.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/PreferencesTab.java
diff -N tools/gnu/classpath/tools/setup/PreferencesTab.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/PreferencesTab.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,230 @@
+/* PreferencesTab.java -- Graphic Form
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+package gnu.classpath.tools.setup;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import javax.swing.border.Border;
+import javax.swing.border.TitledBorder;
+
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class PreferencesTab
+ extends JPanel implements ActionListener
+{
+ Hashtable<PreferenceOption, JTextField> fields =
+ new Hashtable<PreferenceOption, JTextField>();
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5610326790779277981L;
+
+ public PreferencesTab(List<PreferenceNode> nodes)
+ {
+ super(new BorderLayout());
+
+ JTabbedPane tabbedPane = new JTabbedPane();
+
+ //tabbedPane.add("General", buildImportExportPreferenceTab());
+
+ for (PreferenceNode node : nodes)
+ {
+ JComponent panel = makePreferencePanel(node);
+ tabbedPane.addTab(node.getName(), panel);
+ }
+
+ // Add the tabbed pane to this panel.
+ add(tabbedPane);
+
+ // The following line enables to use scrolling tabs.
+ tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ }
+
+ protected JComponent makePreferencePanel(PreferenceNode node)
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ JPanel descriptionPanel = new JPanel(new GridLayout(0, 1));
+ JTextArea description = new JTextArea(node.getDescription());
+ description.setEditable(false);
+ descriptionPanel.add(description);
+
+ panel.add(descriptionPanel);
+
+ for (PreferenceOption option : node.getOptions())
+ {
+ String type = "Preference";
+ if (!option.getType().equalsIgnoreCase("preference"))
+ type = "Property";
+
+ String nodeName = type + ": " + option.getName();
+
+ JPanel preferencePanel = new JPanel();
+ preferencePanel.setLayout(new GridLayout(0, 2));
+
+ TitledBorder titleBorder = BorderFactory.createTitledBorder(nodeName);
+ titleBorder.setTitleJustification(TitledBorder.RIGHT);
+
+ Border border = BorderFactory.createCompoundBorder(titleBorder,
+ BorderFactory.createEmptyBorder(5,5,5,5));
+
+ preferencePanel.setBorder(border);
+ JLabel preferenceNode = new JLabel(option.getNode() + "." +
+ option.getKey() + ": ");
+
+ JTextField command = new JTextField();
+
+ command.setText(getDefaultPreference(option));
+
+ fields.put(option, command);
+
+ preferencePanel.add(preferenceNode);
+ preferencePanel.add(command);
+
+ panel.add(preferencePanel);
+ }
+
+ JPanel controlPane = new JPanel();
+ TitledBorder controlPaneTitleBorder =
+ BorderFactory.createTitledBorder("Controls");
+
+ controlPaneTitleBorder.setTitleJustification(TitledBorder.LEFT);
+
+ Border tileBorder =
+ BorderFactory.createCompoundBorder(controlPaneTitleBorder,
+ BorderFactory.createEmptyBorder
+ (5,5,5,5));
+
+ JButton saveButton = new JButton("Save");
+ JButton cancelButton = new JButton("Reset");
+
+ saveButton.setToolTipText("Saves the changes");
+ cancelButton.setToolTipText("Resets teh preferences to the latest " +
+ "saved defaults");
+
+ cancelButton.setActionCommand("exit");
+ cancelButton.addActionListener(this);
+ saveButton.addActionListener(this);
+
+ controlPane.setLayout(new BoxLayout(controlPane, BoxLayout.LINE_AXIS));
+ controlPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
+ controlPane.add(Box.createHorizontalGlue());
+ controlPane.add(cancelButton);
+ controlPane.add(Box.createRigidArea(new Dimension(10, 0)));
+ controlPane.add(saveButton);
+
+ controlPane.setBorder(tileBorder);
+
+ panel.add(controlPane);
+
+ return panel;
+ }
+
+ private JComponent buildImportExportPreferenceTab()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ JButton importPreferences = new JButton("Import");
+ JButton exportPreferences = new JButton("Export");
+
+ panel.add(importPreferences);
+ panel.add(exportPreferences);
+
+ return panel;
+ }
+
+ /**
+ * @param option
+ * @return
+ */
+ private String getDefaultPreference(PreferenceOption option)
+ {
+ return PreferencesController.load(option);
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ String _event = event.getActionCommand();
+ if (_event.equalsIgnoreCase("save"))
+ {
+ for (Enumeration<PreferenceOption> options = fields.keys();
+ options.hasMoreElements(); )
+ {
+ PreferenceOption option = options.nextElement();
+ String value = fields.get(option).getText();
+
+ option.setValue(value);
+
+ PreferencesController.save(option);
+ }
+ }
+ else
+ {
+ for (Enumeration<PreferenceOption> options = fields.keys();
+ options.hasMoreElements(); )
+ {
+ PreferenceOption option = options.nextElement();
+ fields.get(option).setText(getDefaultPreference(option));
+ }
+ }
+ }
+
+}
Index: tools/gccontrolcenter.in
===================================================================
RCS file: tools/gccontrolcenter.in
diff -N tools/gccontrolcenter.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gccontrolcenter.in 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+## Copyright (C) 2007 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath 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.
+##
+## GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+## A simple shell script to launch the GNU Classpath Control Center tool.
+##
+
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.setup.Main
Index: tools/gnu/classpath/tools/setup/Main.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/Main.java
diff -N tools/gnu/classpath/tools/setup/Main.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/Main.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,141 @@
+/* Main.java -- Main file for ClasspathControlCenter
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.setup;
+
+import java.awt.BorderLayout;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class Main
+{
+ /** Configuration file. */
+ private static final String XML_CONFIG_FILE =
+ "/gnu/classpath/tools/setup/resources/classpathPreferences.xml";
+
+ public Main()
+ {
+ /* do nothing */
+ }
+
+ public void run()
+ {
+ ClasspathPreferencesHandler handler = new ClasspathPreferencesHandler();
+ parseConfigFile(XML_CONFIG_FILE, handler);
+ }
+
+ /**
+ * @param configFile
+ */
+ private void parseConfigFile(String configFile,
+ ClasspathPreferencesHandler handler)
+ {
+ try
+ {
+ // Create a builder factory
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+
+ InputStream is = getClass().getResourceAsStream(XML_CONFIG_FILE);
+
+ // Create the builder and parse the file
+ factory.newSAXParser().parse(is, handler);
+
+ // FIXME: not sure, is parse blocking until it finish or not?
+ while (!handler.parsingDone())
+ ;
+
+ // create the GUI
+ buildGui(handler.getNodes());
+
+ }
+ catch (SAXException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ParserConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void buildGui(final List<PreferenceNode> nodes)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ JFrame frame = new JFrame("Classpath Control Center");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ // Create and set up the content pane.
+ JComponent contentPane = new PreferencesTab(nodes);
+ contentPane.setOpaque(true);
+
+ frame.getContentPane().add(contentPane, BorderLayout.CENTER);
+
+ // Display the window.
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ new Main().run();
+ }
+}
Index: tools/gnu/classpath/tools/setup/resources/classpathPreferences.xml
===================================================================
RCS file: tools/gnu/classpath/tools/setup/resources/classpathPreferences.xml
diff -N tools/gnu/classpath/tools/setup/resources/classpathPreferences.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/resources/classpathPreferences.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+
+ Document : classpathPreferences.xml
+ Created on : 3 marzo 2007, 15.27
+ Author : Mario Torre <[EMAIL PROTECTED]>
+ Description:
+ Preferences file for ClasspathControlPanel
+-->
+
+<classpathPreferences >
+ <node name='Desktop' class='java.awt.Desktop' type='preference'>
+ <description>
+ Defines a set of preferences to configure the runtime behaviour
+ of java.awt.Desktop. Each field represents the default command
+ to be executed for each action (the field name).
+ </description>
+ <property name='Html' node='gnu.java.awt.peer.Desktop.html' key='command' default='' tooltip='' />
+ <property name='Mail' node='gnu.java.awt.peer.Desktop.mail' key='command' default='' tooltip='' />
+ <property name='Edit' node='gnu.java.awt.peer.Desktop.edit' key='command' default='' tooltip='' />
+ <property name='Print' node='gnu.java.awt.peer.Desktop.print' key='command' default='' tooltip='' />
+ <property name='Open' node='gnu.java.awt.peer.Desktop.open' key='command' default='' tooltip='' />
+ </node>
+</classpathPreferences>
Index: tools/gnu/classpath/tools/setup/PreferencesController.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/PreferencesController.java
diff -N tools/gnu/classpath/tools/setup/PreferencesController.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/PreferencesController.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,111 @@
+/* PreferencesController.java -- Load and saves preferences.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.setup;
+
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class PreferencesController
+{
+ /**
+ * @param option
+ * @return
+ */
+ public static String load(PreferenceOption option)
+ {
+ String result = "";
+
+ if (option.getType().equalsIgnoreCase("preference"))
+ {
+ String _node = option.getNode().replace(".", "/");
+ Preferences node = Preferences.userRoot().node(_node);
+
+ String defaultValue = ((option.getDefaultValue() == null) ? "" :
+ option.getDefaultValue());
+
+ result = node.get(option.getKey(), defaultValue);
+ }
+
+ return result;
+ }
+
+ /**
+ * @param option
+ */
+ public static void save(PreferenceOption option)
+ {
+ if (option.getType().equalsIgnoreCase("preference"))
+ {
+ String _node = "/" + option.getNode().replace(".", "/");
+ Preferences node = Preferences.userRoot().node(_node);
+
+ String defaultValue = ((option.getValue() == null) ? "" :
+ option.getValue());
+
+ if (defaultValue.equals(""))
+ {
+ try
+ {
+ node.remove(option.getKey());
+ }
+ catch (Exception e)
+ {
+ // nothing
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ node.put(option.getKey(), defaultValue);
+ }
+
+ try
+ {
+ node.sync();
+ }
+ catch (BackingStoreException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
Index: tools/gnu/classpath/tools/setup/PreferenceOption.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/PreferenceOption.java
diff -N tools/gnu/classpath/tools/setup/PreferenceOption.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/PreferenceOption.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,163 @@
+/* PreferenceOption.java -- Represent a preference option.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+package gnu.classpath.tools.setup;
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class PreferenceOption
+{
+ private String name = "";
+ private String node = "";
+ private String key = "";
+ private String defaultValue = "";
+ private String tooltip = "";
+ private String type = "";
+ private String value = "";
+
+ /**
+ * @return the defaultValue
+ */
+ public String getDefaultValue()
+ {
+ return defaultValue;
+ }
+ /**
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue)
+ {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @return the key
+ */
+ public String getKey()
+ {
+ return key;
+ }
+
+ /**
+ * @param key the key to set
+ */
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ /**
+ * @return the node
+ */
+ public String getNode()
+ {
+ return node;
+ }
+ /**
+ * @param node the node to set
+ */
+ public void setNode(String node)
+ {
+ this.node = node;
+ }
+ /**
+ * @return the tooltip
+ */
+ public String getTooltip()
+ {
+ return tooltip;
+ }
+ /**
+ * @param tooltip the tooltip to set
+ */
+ public void setTooltip(String tooltip)
+ {
+ this.tooltip = tooltip;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return name + ", " + node + ", " + key + ", " + ", " + type +
+ defaultValue + ", " + defaultValue + ", " + value;
+ }
+}
Index: tools/gnu/classpath/tools/setup/PreferenceNode.java
===================================================================
RCS file: tools/gnu/classpath/tools/setup/PreferenceNode.java
diff -N tools/gnu/classpath/tools/setup/PreferenceNode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/setup/PreferenceNode.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,132 @@
+/* PreferenceNode.java --
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.tools.setup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Mario Torre <[EMAIL PROTECTED]>
+ */
+public class PreferenceNode
+{
+ private List<PreferenceOption> options = new ArrayList<PreferenceOption>();
+ private String name = "";
+ private String className = "";
+ private String description = "";
+ private String type = "";
+
+ /**
+ * @return the className
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * @param className the className to set
+ */
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+ /**
+ * @return the type
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * @return the nodes
+ */
+ public List<PreferenceOption> getOptions()
+ {
+ return options;
+ }
+
+ /**
+ * @param nodes the nodes to set
+ */
+ public void addOption(PreferenceOption node)
+ {
+ this.options.add(node);
+ }
+}