[Schmitzm-commits] r1172 - in trunk: src/schmitzm/geotools/feature/resource/locales src/schmitzm/swing src_junit/schmitzm/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 26 11:55:38 CEST 2010
Author: mojays
Date: 2010-10-26 11:55:37 +0200 (Tue, 26 Oct 2010)
New Revision: 1172
Modified:
trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties
trunk/src/schmitzm/swing/BooleanInputOption.java
trunk/src/schmitzm/swing/InputOption.java
trunk/src/schmitzm/swing/SwingUtil.java
trunk/src_junit/schmitzm/swing/SwingUtilTest.java
Log:
BooleanInputOption: "Param" constructors removed because I do not want a geotools dependency in schmitzm.swing
InputOption: automatic indication of mandatory field with red "*"
SwingUtil: quick and dirty method to determine the default component background color
Modified: trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties 2010-10-26 01:41:51 UTC (rev 1171)
+++ trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties 2010-10-26 09:55:37 UTC (rev 1172)
@@ -1,71 +1,71 @@
-##########
-#Copyright (c) 2009 Martin O. J. Schmitz.
-#
-#This file is part of the SCHMITZM library - a collection of utility
-#classes based on Java 1.6, focusing (not only) on Java Swing
-#and the Geotools library.
-#
-#The SCHMITZM project is hosted at:
-#http://wald.intevation.org/projects/schmitzm/
-#
-#This program is free software; you can redistribute it and/or
-#modify it under the terms of the GNU Lesser General Public License
-#as published by the Free Software Foundation; either version 3
-#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 Lesser General Public License (license.txt)
-#along with this program; if not, write to the Free Software
-#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#or try this link: http://www.gnu.org/licenses/lgpl.html
-#
-#Contributors:
-# Martin O. J. Schmitz - initial API and implementation
-# Stefan A. Tzeggai - additional utility classes
-##########
-#This file is part of the SCHMITZM library - a collection of utility
-#classes based on Java 1.6, focussing (not only) on Java Swing
-#and the Geotools library.
-#
-#The SCHMITZM project is hosted at:
-#http://wald.intevation.org/projects/schmitzm/
-#
-#This program is free software; you can redistribute it and/or
-#modify it under the terms of the GNU Lesser General Public License
-#as published by the Free Software Foundation; either version 3
-#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 Lesser General Public License (license.txt)
-#along with this program; if not, write to the Free Software
-#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#or try this link: http://www.gnu.org/licenses/lgpl.html
-#
-#Contributors:
-# Martin O. J. Schmitz - initial API and implementation
-# Stefan A. Tzeggai - additional utility classes
-##########
-# -----------------------------------------------------------
-# ------ Default Translations (english) for components ------
-# ------ in Package schmitzm.geotools.feature ------
-# -----------------------------------------------------------
-
-# --- Restrictions for attribute names ---
-org.geotools.err.attr.name=Attribute name not allowed
-org.geotools.err.attr.name.null=Attribute name must not be NULL\!
-org.geotools.err.attr.name.length=At most 10 characters allowed for attribute name\!
-org.geotools.err.attr.name.start=Attribute name must start with a character (A-Z,a-z)!
-org.geotools.err.attr.name.chars=Only digits (0-9), characters (A-Z,a-z) and '_' allowed for attribute name!
-
-
-# --- Translations for FeatureOperationTree / FeatureOperationTreeParser
-FeatureOperationTree.err.NullAttr=FeatureOperationTree can not evaluate null-Attributes: ${0}
-FeatureOperationTree.err.UnknownAttr=Unknown feature attribute: ${0}
+##########
+#Copyright (c) 2009 Martin O. J. Schmitz.
+#
+#This file is part of the SCHMITZM library - a collection of utility
+#classes based on Java 1.6, focusing (not only) on Java Swing
+#and the Geotools library.
+#
+#The SCHMITZM project is hosted at:
+#http://wald.intevation.org/projects/schmitzm/
+#
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU Lesser General Public License
+#as published by the Free Software Foundation; either version 3
+#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 Lesser General Public License (license.txt)
+#along with this program; if not, write to the Free Software
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#or try this link: http://www.gnu.org/licenses/lgpl.html
+#
+#Contributors:
+# Martin O. J. Schmitz - initial API and implementation
+# Stefan A. Tzeggai - additional utility classes
+##########
+#This file is part of the SCHMITZM library - a collection of utility
+#classes based on Java 1.6, focussing (not only) on Java Swing
+#and the Geotools library.
+#
+#The SCHMITZM project is hosted at:
+#http://wald.intevation.org/projects/schmitzm/
+#
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU Lesser General Public License
+#as published by the Free Software Foundation; either version 3
+#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 Lesser General Public License (license.txt)
+#along with this program; if not, write to the Free Software
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#or try this link: http://www.gnu.org/licenses/lgpl.html
+#
+#Contributors:
+# Martin O. J. Schmitz - initial API and implementation
+# Stefan A. Tzeggai - additional utility classes
+##########
+# -----------------------------------------------------------
+# ------ Default Translations (english) for components ------
+# ------ in Package schmitzm.geotools.feature ------
+# -----------------------------------------------------------
+
+# --- Restrictions for attribute names ---
+org.geotools.err.attr.name=Attribute name not allowed
+org.geotools.err.attr.name.null=Attribute name must not be NULL\!
+org.geotools.err.attr.name.length=At most 10 characters allowed for attribute name\!
+org.geotools.err.attr.name.start=Attribute name must start with a character (A-Z,a-z)!
+org.geotools.err.attr.name.chars=Only digits (0-9), characters (A-Z,a-z) and '_' allowed for attribute name!
+
+
+# --- Translations for FeatureOperationTree / FeatureOperationTreeParser
+FeatureOperationTree.err.NullAttr=FeatureOperationTree can not evaluate null-Attributes: ${0}
+FeatureOperationTree.err.UnknownAttr=Unknown feature attribute: ${0}
Modified: trunk/src/schmitzm/swing/BooleanInputOption.java
===================================================================
--- trunk/src/schmitzm/swing/BooleanInputOption.java 2010-10-26 01:41:51 UTC (rev 1171)
+++ trunk/src/schmitzm/swing/BooleanInputOption.java 2010-10-26 09:55:37 UTC (rev 1172)
@@ -31,7 +31,7 @@
import javax.swing.JCheckBox;
-import org.geotools.data.DataAccessFactory.Param;
+//import org.geotools.data.DataAccessFactory.Param;
/**
* Diese Klasse stellt eine boolsche Eingabe-Option fuer das
@@ -74,23 +74,23 @@
this(label, false);
}
- /**
- * Erzeugt eine neue Eingabe-Option.
- */
- public BooleanInputOption(Param param, Boolean defValue) {
- this(param.title.toString(), defValue);
- setToolTipText(param.description.toString());
- }
+// /**
+// * Erzeugt eine neue Eingabe-Option.
+// */
+// public BooleanInputOption(Param param, Boolean defValue) {
+// this(param.title.toString(), defValue);
+// setToolTipText(param.description.toString());
+// }
+//
+// /**
+// * Erzeugt eine neue Eingabe-Option.
+// */
+// public BooleanInputOption(Param param) {
+// this(param.title.toString(), (Boolean) param.sample);
+// setToolTipText(param.description.toString());
+// }
/**
- * Erzeugt eine neue Eingabe-Option.
- */
- public BooleanInputOption(Param param) {
- this(param.title.toString(), (Boolean) param.sample);
- setToolTipText(param.description.toString());
- }
-
- /**
* Erzeugt eine neue Instanz von {@link JCheckBox}.
*/
protected JCheckBox createInputComponent() {
Modified: trunk/src/schmitzm/swing/InputOption.java
===================================================================
--- trunk/src/schmitzm/swing/InputOption.java 2010-10-26 01:41:51 UTC (rev 1171)
+++ trunk/src/schmitzm/swing/InputOption.java 2010-10-26 09:55:37 UTC (rev 1172)
@@ -30,7 +30,10 @@
package schmitzm.swing;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.Component;
+import java.awt.Container;
+import java.awt.FlowLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.Vector;
@@ -53,8 +56,12 @@
/** Speichert eine Referenz auf die Eingabe-Option (<code>this</code>), damit
* in inneren Klassen darauf referenziert werden kann. */
protected final Component OPTION_COMPONENT = this;
+ /** Enhaelt das Label mit der Beschreibung der Option, sowie ggf. das Obligatorisch-Kennzeichen. */
+ protected Container descLabelContainer = null;
/** Speichert die Beschreibung der Option */
protected JLabel descLabel = null;
+ /** Kennzeichnet die Option als obligatorisch. */
+ protected JLabel inputNeededLabel = null;
/** Speichert die Eingabe-Komponente der Option. */
protected JComponent inpComp = null;
/** Kann eine Fehlermeldung enthalten, wenn die Eingabe nicht
@@ -66,7 +73,53 @@
private boolean inpNeeded = false;
private Vector listeners = new Vector();
private E oldValue = null;
+
+ /** Label (hinter der Bezeichnung), mit dem obligatorische Felder markiert werden. */
+ private static String defaultInputNeededSign = "*";
+ /** Farbe, in der die Markierung für obligatorische Felder dargestellt wird. */
+ private static Color defaultInputNeededSignColor = Color.RED;//new Color(240,100,100);
+
+ /**
+ * Liefert das Label (dargestellt hinter der Bezeichnung), mit dem
+ * obligatorische Felder markiert werden (Default: "*").
+ */
+ public static String getInputNeededSign() {
+ return defaultInputNeededSign;
+ }
+
+ /**
+ * Setzt das Label (dargestellt hinter der Bezeichnung), mit dem
+ * obligatorische Felder markiert werden (Default: "*").<br>
+ * Diese Einstellung wirkt sich erst auf neu erzeugte {@link InputOption}
+ * aus. Die Darstellung bestehender {@link InputOption}-Objekte aendert sich
+ * erst, wenn die inputNeeded-Eigenschaft neu gesetzt wird!
+ * @see #setInputNeeded(boolean)
+ */
+ public static void setInputNeededSign(String sign) {
+ defaultInputNeededSign = sign;
+ }
+
+ /**
+ * Liefert die Farbe, mit der obligatorische Felder markiert werden
+ * (Default: {@link Color#RED}).
+ */
+ public static Color getInputNeededSignColor() {
+ return defaultInputNeededSignColor;
+ }
+
+ /**
+ * Setzt die Farbe, mit der obligatorische Felder markiert werden
+ * (Default: {@link Color#RED}).<br>
+ * Diese Einstellung wirkt sich erst auf neu erzeugte {@link InputOption}
+ * aus. Die Darstellung bestehender {@link InputOption}-Objekte aendert sich
+ * erst, wenn die inputNeeded-Eigenschaft neu gesetzt wird!
+ * @see #setInputNeeded(boolean)
+ */
+ public static void setInputNeededSignColor(Color signColor) {
+ defaultInputNeededSignColor = signColor;
+ }
+
/**
* Erzeugt eine neue Eingabe-Option.
* @param label Beschreibung (wird im Label angezeigt)
@@ -89,6 +142,8 @@
// Darstellung des Containers erzeugen
setLayout(new BorderLayout());
descLabel = new JLabel(label);
+ inputNeededLabel = new JLabel();
+ inputNeededLabel.setForeground(defaultInputNeededSignColor);
inpComp = createInputComponent();
inpComp.addFocusListener( new FocusListener() {
public void focusGained(FocusEvent e) {
@@ -102,10 +157,15 @@
fireOptionChanged(oldValue,getValue());
}
});
+ setInputNeeded(inputNeeded);
// Elemente dem Container hinzufuegen
if ( label != null ) {
- add( descLabel, BorderLayout.NORTH );
+ descLabelContainer = new Container();
+ descLabelContainer.setLayout( new FlowLayout(FlowLayout.LEFT,0,0) );
+ descLabelContainer.add( descLabel );
+ descLabelContainer.add( inputNeededLabel );
+ add( descLabelContainer, BorderLayout.NORTH );
add( inpComp, centerInputComp ? BorderLayout.CENTER : BorderLayout.SOUTH );
} else {
add( inpComp, centerInputComp ? BorderLayout.CENTER : BorderLayout.NORTH );
@@ -192,6 +252,19 @@
*/
public void setInputNeeded(boolean inpNeeded) {
this.inpNeeded = inpNeeded;
+// if ( inpComp != null ) {
+// if ( inpNeeded )
+// inpComp.setBackground( defaultInputNeededBackground );
+// else
+// inpComp.setBackground( SwingUtil.getDefaultBackground() );
+// }
+ if ( inputNeededLabel != null ) {
+ if ( inpNeeded )
+ inputNeededLabel.setText( defaultInputNeededSign );
+ else
+ inputNeededLabel.setText( "" );
+ }
+
}
/**
Modified: trunk/src/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/src/schmitzm/swing/SwingUtil.java 2010-10-26 01:41:51 UTC (rev 1171)
+++ trunk/src/schmitzm/swing/SwingUtil.java 2010-10-26 09:55:37 UTC (rev 1172)
@@ -92,7 +92,9 @@
public class SwingUtil {
private static final Logger LOGGER = Logger.getLogger(SwingUtil.class
.getClass().getName());
+ private static final JLabel DUMMY_LABEL = new JLabel("dummy");
+
/**
* {@link ResourceProvider}, der die Lokalisation fuer GUI-Komponenten des
* Package {@code schmitzm.swing} zur Verfuegung stellt. Diese sind in
@@ -1452,5 +1454,12 @@
throw new RuntimeException("Not on EDT!");
}
}
-
+
+ /**
+ * Returns the default background color for the current L&F.
+ */
+ public static Color getDefaultBackground() {
+ // Quick and dirty:
+ return DUMMY_LABEL.getBackground();
+ }
}
Modified: trunk/src_junit/schmitzm/swing/SwingUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/swing/SwingUtilTest.java 2010-10-26 01:41:51 UTC (rev 1171)
+++ trunk/src_junit/schmitzm/swing/SwingUtilTest.java 2010-10-26 09:55:37 UTC (rev 1172)
@@ -41,7 +41,9 @@
"Test Passwort",
pwInputOption,
new ManualInputOption.Text("blablabla"),
- new FileInputOption("Eine Datei eingeben:",false)
+ new FileInputOption("Eine Datei eingeben:",false),
+ new SelectionInputOption.Combo<String>("Eine Auswahl:",true,new String[] {"A","B","C"},null),
+ new SelectionInputOption.Radio<String>("Noch eine Auswahl:",true,new String[] {"A","B","C"},null)
);
if ( values == null )
System.out.println("Dialog aborted without passwort.");
More information about the Schmitzm-commits
mailing list