[Schmitzm-commits] r1772 - in trunk/schmitzm-core/src/main: java/de/schmitzm/io java/de/schmitzm/swing resources/de/schmitzm/swing/resource/icons/small
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Nov 8 18:20:55 CET 2011
Author: mojays
Date: 2011-11-08 18:20:52 +0100 (Tue, 08 Nov 2011)
New Revision: 1772
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSource.java
trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSourceList.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/bullet_go.png
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/cross.png
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/folder_database.png
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/resultset_next.png
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/stop.png
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
Log:
new FileSource and FileSourceList
ExceptionDialog: If error message contains RETURNs, a JTextPane is used instead of JLabel
SwingUtil: JSpinner handled in setEditable(.)
new Icons
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSource.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSource.java 2011-11-04 09:28:09 UTC (rev 1771)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSource.java 2011-11-08 17:20:52 UTC (rev 1772)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the LESLIE library.
+ *
+ * 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
+ ******************************************************************************/
+
+package de.schmitzm.io;
+
+import java.io.File;
+
+/**
+ * Interface indicating that an object has a {@link File} as
+ * origin.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ */
+public interface FileSource {
+ /**
+ * Returns the origin of the data.
+ */
+ public Object getSource();
+
+ /**
+ * Returns the origin file of the data.
+ */
+ public File getSourceFile();
+
+}
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSourceList.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSourceList.java 2011-11-04 09:28:09 UTC (rev 1771)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/FileSourceList.java 2011-11-08 17:20:52 UTC (rev 1772)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the LESLIE library.
+ *
+ * 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
+ ******************************************************************************/
+
+package de.schmitzm.io;
+
+import java.io.File;
+import java.util.Vector;
+
+/**
+ * A {@link Vector} which is bases on a source file.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ */
+public class FileSourceList<E> extends Vector<E> implements FileSource {
+
+ /** Holds the source file. */
+ protected File source = null;
+
+ /**
+ * Creates a new list without source.
+ */
+ public FileSourceList() {
+ this(null);
+ }
+
+ /**
+ * Creates a new list.
+ */
+ public FileSourceList(File source) {
+ super();
+ this.source = source;
+ }
+
+ /**
+ * Returns the source file path.
+ */
+ @Override
+ public Object getSource() {
+ // TODO Auto-generated method stub
+ return source;
+ }
+
+ /**
+ * Returns the source file.
+ */
+ @Override
+ public File getSourceFile() {
+ return source;
+ }
+
+}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java 2011-11-04 09:28:09 UTC (rev 1771)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java 2011-11-08 17:20:52 UTC (rev 1772)
@@ -31,6 +31,7 @@
import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
@@ -40,14 +41,18 @@
import java.util.Set;
import java.util.TreeSet;
+import javax.swing.BorderFactory;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import javax.swing.JTextPane;
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;
+import javax.swing.text.JTextComponent;
import org.apache.commons.lang.SystemUtils;
@@ -89,7 +94,7 @@
/** Speichert den angezeigten Fehler. */
protected Throwable err = null;
/** Label in dem die Meldung angezeigt wird. */
- protected JLabel messageLabel = null;
+ protected JComponent messageLabel = null;
/** Button um den Dialog zu schliessen. */
protected JButton okButton = null;
/** Button um Details anzuzeigen. */
@@ -211,7 +216,15 @@
// Vorlagen-Dialog erzeugen
this.err = err;
- this.messageLabel = new JLabel(errMessage);
+ if (errMessage == null || !errMessage.contains("\n"))
+ this.messageLabel = new JLabel(errMessage);
+ else {
+ this.messageLabel = new JTextPane();
+ ((JTextPane)this.messageLabel).setEditable(false);
+ ((JTextPane)this.messageLabel).setBackground(SwingUtil.getDefaultBackground());
+ ((JTextPane)this.messageLabel).setText(errMessage);
+ ((JTextPane)this.messageLabel).setPreferredSize(new Dimension(100,100));
+ }
this.okButton = new JButton(SwingUtil.R("Ok"));
this.copyToConsoleButton = new JButton(
SwingUtil.R("ExceptionDialog.CopyToConsole"));
@@ -230,7 +243,11 @@
this.detailsScrollPane = new JScrollPane(detailsTextArea);
this.detailsScrollPane.setVisible(showDetails);
this.setError(err);
- JOptionPane pane = new JOptionPane(messageLabel,
+
+ JComponent messageComp = messageLabel;
+ if ( messageComp instanceof JTextComponent )
+ messageComp = new JScrollPane(messageComp);
+ JOptionPane pane = new JOptionPane(messageComp,
JOptionPane.ERROR_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
new Object[] { okButton, detailsButton, copyToConsoleButton,
copyToClipboardButton, mailButton });
@@ -308,7 +325,11 @@
* Liefert die angezeigte Fehlermeldung.
*/
public String getMessage() {
- return messageLabel.getText();
+ if ( messageLabel instanceof JLabel )
+ return ((JLabel)messageLabel).getText();
+ if ( messageLabel instanceof JTextComponent )
+ return ((JTextComponent)messageLabel).getText();
+ throw new UnsupportedOperationException("Text component unsupported: "+LangUtil.getSimpleClassName(messageLabel));
}
/**
@@ -318,7 +339,14 @@
if (mess == null || mess.trim().equals(""))
mess = getError() != null ? getError().getMessage() : SwingUtil
.R("Error");
- messageLabel.setText(mess);
+
+ if ( messageLabel instanceof JLabel )
+ ((JLabel)messageLabel).setText(mess);
+ else if ( messageLabel instanceof JTextComponent )
+ ((JTextComponent)messageLabel).setText(mess);
+ else
+ throw new UnsupportedOperationException("Text component unsupported: "+LangUtil.getSimpleClassName(messageLabel));
+
}
/**
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2011-11-04 09:28:09 UTC (rev 1771)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2011-11-08 17:20:52 UTC (rev 1772)
@@ -88,6 +88,7 @@
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
+import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
@@ -840,6 +841,8 @@
((JList)component).setEnabled(editable);
if ( component instanceof JDateChooser )
((JDateChooser)component).setEnabled(editable);
+ if ( component instanceof JSpinner )
+ ((JSpinner)component).setEnabled(editable);
if ( component instanceof InputOption ) {
((InputOption)component).setEnabled(editable);
return; // JPanel nicht nochmal rekursiv durchlaufen!
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/bullet_go.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/bullet_go.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/cross.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/cross.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/folder_database.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/folder_database.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/resultset_next.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/resultset_next.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/stop.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/icons/small/stop.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the Schmitzm-commits
mailing list