[Schmitzm-commits] r2169 - in trunk/schmitzm-core/src/main: java/de/schmitzm/lang java/de/schmitzm/swing java/de/schmitzm/swing/input java/de/schmitzm/swing/tree resources/de/schmitzm/swing/resource/locales
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sun Dec 16 13:41:55 CET 2012
Author: mojays
Date: 2012-12-16 13:41:55 +0100 (Sun, 16 Dec 2012)
New Revision: 2169
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/DirectoryChooser.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JToggleButtonLabel.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DirectoryInputOption.java
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JPanel.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkCancelDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/tree/DirectoryTree.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
Log:
SwingUtil: new recursive method setEnabled(.)
OkCancelDialog: new protected constructions which do not call init() immediately
JPanel: setEnabled(.) linked to new recursive method SwingUtil.setEnabled(.)
ApplicationProps: new method getStringList(.)
DirectoryTree: BugFix
new GUI components: DirectoryChooser, DirectoryInputOption, JToggleButtonLabel
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -38,6 +38,9 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -250,8 +253,8 @@
}
/**
- * Parses a map from string.
- * @param mapStr semicolon-separated list of "key:value" pairs
+ * Parses a map from string.
+ * @param key key to semicolon-separated list of "key:value" pairs
*/
public Map<String,String> getStringMap(KEYS key, String... defaultValue) {
Map<String,String> map = new SequentialOrderedMap<String, String>();
@@ -270,6 +273,19 @@
}
/**
+ * Parses a list from string.
+ * @param key key to semicolon-separated list
+ */
+ public List<String> getStringList(KEYS key, String... defaultValue) {
+ String listStr = getString(key, defaultValue);
+ if ( StringUtils.isBlank(listStr) )
+ return new ArrayList<String>();
+ String[] pairs = listStr.split(";");
+ List<String> list = Arrays.asList(pairs);
+ return list;
+ }
+
+ /**
* Returns a property value which was stored encrypted in the map.
* @param key properties key
* @param defaultValueDecrypted default value (already decrypted!)
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/DirectoryChooser.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/DirectoryChooser.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/DirectoryChooser.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -0,0 +1,221 @@
+/**
+ * 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
+ */
+package de.schmitzm.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.io.File;
+
+import javax.swing.JScrollPane;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+
+import de.schmitzm.swing.tree.DirectoryTree;
+
+/**
+ * Dialog to select a directory from local file system.
+ * @author Martin O.J. Schmitz
+ */
+public class DirectoryChooser extends OkCancelDialog {
+
+ /** Holds the component to choose directory(s). */
+ protected DirectoryTree dirTree;
+
+ /** Holds the root directory shown in {@link DirectoryTree}. */
+ protected File rootDir;
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ */
+ public DirectoryChooser(Frame owner) {
+ this(owner, (String)null);
+ }
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ */
+ public DirectoryChooser(Dialog owner) {
+ this(owner, (String)null);
+ }
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ * @param dir initial directory
+ */
+ public DirectoryChooser(Frame owner, File dir) {
+ super(owner, null, true, false);
+ setRootDirectory(dir);
+ init();
+ }
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ * @param dir initial directory
+ */
+ public DirectoryChooser(Frame owner, String dir) {
+ super(owner, null, true, false);
+ setRootDirectory( dir );
+ init();
+ }
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ * @param dir initial directory
+ */
+ public DirectoryChooser(Dialog owner, String dir) {
+ super(owner, null, true, false);
+ setRootDirectory( dir );
+ init();
+ }
+
+ /**
+ * Sets the root directory for the {@link DirectoryChooser}.
+ * Should only be called by constructor!
+ */
+ protected void setRootDirectory(String rootDir) {
+ setRootDirectory( rootDir != null ? new File(rootDir) : null );
+ }
+
+ /**
+ * Sets the root directory for the {@link DirectoryChooser}.
+ * Should only be called by constructor!
+ */
+ protected void setRootDirectory(File rootDir) {
+ if ( rootDir != null && !rootDir.isDirectory() )
+ throw new IllegalArgumentException("Root directory must be a directory: "+rootDir.getAbsolutePath());
+ if ( rootDir != null && !rootDir.exists() )
+ throw new IllegalArgumentException("Root must be an existing directory: "+rootDir.getAbsolutePath());
+ this.rootDir = rootDir;
+ }
+
+ /**
+ * Returns the root directory of the {@link DirectoryChooser}.
+ */
+ public File getRootDirectory() {
+ return this.rootDir;
+ }
+
+ /**
+ * Called immediately by the constructor to initialize the
+ * dialog.
+ */
+ @Override
+ protected void init() {
+ super.init();
+ setTitle( SwingUtil.R("DirectoryChooser.title") );
+ setPreferredSize( new Dimension(300,400) );
+
+ this.dirTree = new DirectoryTree( getRootDirectory() );
+ dirTree.setEmptyRootDescription( SwingUtil.R("DirectoryChooser.DirectoryRoot") );
+ dirTree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() {
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ updateActions();
+ }
+ });
+
+ getContentPane().add(new JScrollPane(dirTree), BorderLayout.CENTER);
+ updateActions();
+ pack();
+ SwingUtil.setRelativeFramePosition(this, getOwner(), 0.5, 0.5);
+ }
+
+ /**
+ * Returns the directory tree component.
+ */
+ public DirectoryTree getDirectoryTree() {
+ return dirTree;
+ }
+
+
+ /**
+ * Updates the activation of the dialog actions.
+ */
+ protected void updateActions() {
+ okAction.setEnabled( dirTree.getSelectionCount() > 0 );
+ }
+
+
+ /**
+ * Returns the selected directory.
+ * @return {@code null} if dialog was not closed by OK
+ */
+ public File[] getSelectedDirectories() {
+ if ( isDialogApproved() )
+ return dirTree.getSelectedDirectories();
+ return null;
+ }
+
+ /**
+ * Sets the selected directory.
+ */
+ public void setSelectedDirectory(File dir) {
+ dirTree.setSelectedDirectory(dir);
+ }
+
+ /**
+ * Returns the selected directory.
+ * @return {@code null} if dialog was not closed by OK
+ */
+ public File getSelectedDirectory() {
+ if ( isDialogApproved() )
+ return dirTree.getSelectedDirectory();
+ return null;
+ }
+
+ /**
+ * Shows the chooser.
+ * @param parent parent component
+ * @param selectedDir preset selection (if {@code null} the previous selection remains
+ * unchanged)
+ */
+ public File[] show(Component parent, File selectedDir) {
+ if ( selectedDir != null )
+ setSelectedDirectory(selectedDir);
+ if ( parent != null )
+ SwingUtil.setRelativeFramePosition(this,parent, 0.5, 0.5);
+ setVisible(true);
+ return getSelectedDirectories();
+ }
+
+}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JPanel.java 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JPanel.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -139,8 +139,9 @@
super.setEnabled(enabled);
// Passing it down to all sub-components
- for (Component c : getComponents())
- c.setEnabled(enabled);
+// for (Component c : getComponents())
+// c.setEnabled(enabled);
+ SwingUtil.setEnabled(this, enabled);
}
/**
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JToggleButtonLabel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JToggleButtonLabel.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/JToggleButtonLabel.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -0,0 +1,134 @@
+/**
+ * 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
+ */
+package de.schmitzm.swing;
+
+import java.awt.Insets;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JRadioButton;
+import javax.swing.JToggleButton;
+
+import net.miginfocom.swing.MigLayout;
+
+/**
+ * Individual label for a {@link JRadioButton} or {@link JCheckBox}, which reacts on mouse click
+ * with activation of connected button.
+ * The advantage of this label (in contrast the integrated label of {@link JRadioButton}) is, that
+ * can be arranged individually with other components e.g. in a {@link MigLayout}.
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class JToggleButtonLabel extends JLabel implements MouseListener {
+
+ /** Holds the {@link JCheckBox} or {@link JRadioButton} the label is connected to. */
+ protected JToggleButton button;
+
+
+ /**
+ * Creates a new label.
+ * @param button {@link JCheckBox} to connect the label to
+ */
+ public JToggleButtonLabel(JCheckBox button) {
+ this(button,null);
+ }
+
+ /**
+ * Creates a new label.
+ * @param button {@link JCheckBox} to connect the label to
+ * @param text label text
+ */
+ public JToggleButtonLabel(JCheckBox button, String text) {
+ this((JToggleButton)button,text);
+ }
+
+ /**
+ * Creates a new label.
+ * @param button {@link JRadioButton} to connect the label to
+ */
+ public JToggleButtonLabel(JRadioButton button) {
+ this(button,null);
+ }
+
+ /**
+ * Creates a new label.
+ * @param button {@link JRadioButton} to connect the label to
+ * @param text label text
+ */
+ public JToggleButtonLabel(JRadioButton button, String text) {
+ this((JToggleButton)button,text);
+ }
+
+
+ /**
+ * Creates a new label.
+ * @param button {@link JCheckBox} or {@link JRadioButton} to connect the
+ * label to
+ * @param text label text
+ */
+ protected JToggleButtonLabel(JToggleButton button, String text) {
+ super(text);
+ this.button = button;
+ Insets bi = button.getBorder().getBorderInsets(button);
+ setBorder( BorderFactory.createEmptyBorder(bi.top,0,bi.bottom,bi.right) );
+ addMouseListener(this);
+ }
+
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ button.doClick();
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkCancelDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkCancelDialog.java 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkCancelDialog.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -88,8 +88,7 @@
* @param modal indicates whether the dialog is modal
*/
public OkCancelDialog(Frame owner, String title, boolean modal) {
- super(owner, title, modal);
- init();
+ this(owner, title, modal, true);
}
/**
@@ -99,11 +98,34 @@
* @param modal indicates whether the dialog is modal
*/
public OkCancelDialog(Dialog owner, String title, boolean modal) {
+ this(owner, title, modal, true);
+ }
+
+ /**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ * @param modal indicates whether the dialog is modal
+ */
+ protected OkCancelDialog(Frame owner, String title, boolean modal, boolean init) {
super(owner, title, modal);
- init();
+ if ( init )
+ init();
}
/**
+ * Creates a new dialog
+ * @param owner parent component
+ * @param title dialog title
+ * @param modal indicates whether the dialog is modal
+ */
+ protected OkCancelDialog(Dialog owner, String title, boolean modal, boolean init) {
+ super(owner, title, modal);
+ if ( init )
+ init();
+ }
+
+ /**
* Called immediately by the constructor to initialize the
* dialog.
*/
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -1074,6 +1074,26 @@
}
/**
+ * Enables or disables all input components ({@link JTextComponent}, {@link JComboBox},
+ * ...) of a panel recursively..
+ */
+ public static void setEnabled(Component component, boolean enabled) {
+ // avoid recursion for de.schmitzm.swing.JPanel
+ if ( component.isEnabled() != enabled )
+ component.setEnabled(enabled);
+
+ // recursive components
+ if ( component instanceof javax.swing.JPanel )
+ for (Component comp : ((javax.swing.JPanel)component).getComponents())
+ setEnabled(comp, enabled);
+ if ( component instanceof JScrollPane )
+ for (Component comp : ((JScrollPane)component).getComponents())
+ setEnabled(comp, enabled);
+ if ( component instanceof JViewport )
+ setEnabled(((JViewport)component).getView(), enabled);
+ }
+
+ /**
* Similar to {@link JOptionPane#showOptionDialog(Component, Object, String, int, int, Icon, Object[], Object),
* except that the dialog is resizable!
*/
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DirectoryInputOption.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DirectoryInputOption.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DirectoryInputOption.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package de.schmitzm.swing.input;
+
+import java.awt.Frame;
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.apache.commons.lang.StringUtils;
+
+import de.schmitzm.swing.DirectoryChooser;
+
+/**
+ * Diese Eingabe-Option dient dazu eine Verzeichnis-Angabe zu vorzunehmen. Dies
+ * kann ueber manuelle Eingabe erfolgen, oder durch Browsen mittels einem
+ * {@link DirectoryChooser}. Der Wert, den die Eingabe-Option repraesentiert stellt
+ * ein {@link File}-Objekt dar.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * @version 1.0
+ */
+public class DirectoryInputOption extends BrowseInputOption {
+ protected DirectoryChooser directoryChooser;
+
+ /**
+ * Erzeugt eine neue Eingabe-Option.
+ * @param label Beschreibung der Eingabe-Option
+ * @param inputNeeded bestimmt, ob eine Eingabe erforderlich ist
+ * @param defValue Standard-Wert der vorgeblendet wird
+ */
+ public DirectoryInputOption(String label, boolean inputNeeded, File defValue) {
+ super(label,inputNeeded,defValue);
+ setDirectoryChooser( new DirectoryChooser((Frame)null) );
+ }
+
+ /**
+ * Erzeugt eine neue Eingabe-Option.
+ * @param label Beschreibung der Eingabe-Option
+ * @param inputNeeded bestimmt, ob eine Eingabe erforderlich ist
+ */
+ public DirectoryInputOption(String label, boolean inputNeeded) {
+ this(label,inputNeeded,null);
+ }
+
+ /**
+ * Liefert den Wert, der in der Option eingegeben wurde. Prueft zuerst
+ * auf Gueltigkeit und ruft dann {@link #performGetValue()} auf.
+ * @return <code>null</code> wenn die aktuelle Eingabe nicht zulaessig ist
+ * (siehe {@link #isInputValid()})
+ */
+ public File getValue() {
+ return (File)super.getValue();
+ }
+
+ /**
+ * Liefert den Verzeichnisauswahl-Dialog fuer die Browse-Aktion.
+ */
+ public DirectoryChooser getDirectoryChooser() {
+ return directoryChooser;
+ }
+
+ /**
+ * Setzt den Verzeichnisauswahl-Dialog fuer die Browse-Aktion.
+ */
+ public void setDirectoryChooser(DirectoryChooser dirChooser) {
+ this.directoryChooser = dirChooser;
+ directoryChooser.getDirectoryTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ }
+
+ /**
+ * Liefert das ein {@link File}-Objekt zu der Text-Eingabe (Dateipfad)
+ * der Option.
+ * @param objectStr Objekt-String
+ */
+ public File convertFromString(String objectStr) {
+ if ( StringUtils.isBlank(objectStr) )
+ return null;
+
+ File dir = new File(objectStr);
+ if ( dir.exists() && !dir.isDirectory() )
+ dir = dir.getParentFile();
+ return dir;
+ }
+
+ /**
+ * Liefert den kompletten Datei-Pfad fuer die durch die Eingabe-Option
+ * repraesentierten {@link File}.
+ * @param object {@link File}-Instanz
+ * @return {@code null}, fall kein {@link File}-Objekt uebergeben wird
+ */
+ public String convertToString(Object object) {
+ return ((File)object).getAbsolutePath();
+ }
+
+ /**
+ * Implementiert die Browse-Aktion die ausgefuehrt wird, wenn der Button der
+ * Eingabe-Option gedrueckt wird. Oeffnet einen {@link JFileChooser}.
+ * @param actValue aktueller Wert der Eingabe-Option
+ * @return <code>null</code> falls die Browse-Aktion abgebrochen wird
+ */
+ public File performBrowse(Object actValue) {
+ File[] files = directoryChooser.show(this, (File)actValue );
+ if ( files == null || files.length < 1 )
+ return null;
+ return files[0];
+ }
+}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/tree/DirectoryTree.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/tree/DirectoryTree.java 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/tree/DirectoryTree.java 2012-12-16 12:41:55 UTC (rev 2169)
@@ -266,7 +266,11 @@
// Navigate to node
DirectoryTreeNode node = (DirectoryTreeNode)getRoot();
for (File subDir : dirPath) {
- node = node.findChild(subDir);
+ DirectoryTreeNode child = node.findChild(subDir);
+ // if sub-directory can not be found, cancel traversing
+ if ( child == null )
+ break;
+ node = child;
}
return new TreePath( node.getPath() );
}
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties 2012-12-13 10:22:08 UTC (rev 2168)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties 2012-12-16 12:41:55 UTC (rev 2169)
@@ -312,3 +312,6 @@
SMTPSettings.auth.user=User name
SMTPSettings.auth.pw=Password
SMTPSettings.sender.addr=Sender mail address
+
+DirectoryChooser.title=Choose directory
+DirectoryChooser.DirectoryRoot=Computer
\ No newline at end of file
More information about the Schmitzm-commits
mailing list