[Schmitzm-commits] r566 - in branches/1.0-gt2-2.6/src/schmitzm: geotools/gui lang swing swing/resource/locales

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 24 16:43:10 CET 2009


Author: mojays
Date: 2009-11-24 16:43:08 +0100 (Tue, 24 Nov 2009)
New Revision: 566

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/lang/LangUtil.java
   branches/1.0-gt2-2.6/src/schmitzm/swing/ExceptionDialog.java
   branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
   branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
Log:
BugFix:
- JEditorPane constuctor
Enhancement:
- ExceptionDialog provides clipboard and console funtionality
- LangUtil.copyToClipboard(..)

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java	2009-11-24 15:43:08 UTC (rev 566)
@@ -76,7 +76,7 @@
 
 
 /**
- * The {@code GeoEditorPane} extends the {@link SelectableXMapPane} with functionalities
+ * The {@code JEditorPane} extends the {@link SelectableXMapPane} with functionalities
  * to create new vector layers by successively click points via mouse.
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
  * @version 1.0
@@ -176,13 +176,14 @@
   protected Stack<SimpleFeature> globalRedoFeatures = new Stack<SimpleFeature>();
 
   /**
-   * Creates a new {@code GeoEditorPane}.
+   * Creates a new {@code JEditorPane}.
    */
   public JEditorPane() {
+    this(null);
   }
 
   /**
-   * Creates a new {@code GeoEditorPane}. This constructor provides the possibility
+   * Creates a new {@code JEditorPane}. This constructor provides the possibility
    * to use alternative implementations of the internal components.
    * <b>The specified parameter all can be {@code null}! In this case
    * the respective default component is used.</b>

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java	2009-11-24 15:43:08 UTC (rev 566)
@@ -119,17 +119,16 @@
    */
   public LayeredMapPane(GeoMapPane geoMapPane) {
     super();
-    if (geoMapPane == null) {
+    if (geoMapPane == null)
       geoMapPane = new GeoMapPane();
-      // Kartenbereich ueber Border "versenken"
-      geoMapPane.getMapPanePanel()
-                .setBorder(BorderFactory.createLoweredBevelBorder());
-      // Aufgrund der Border werden die Koordinaten-Leisten
-      // nicht mehr benoetigt
-      geoMapPane.setGridBarVisible(false);
-    }
     this.setLayout(new BorderLayout());
 
+    // Kartenbereich ueber Border "versenken"
+    geoMapPane.getMapPanePanel().setBorder(BorderFactory.createLoweredBevelBorder());
+    // Aufgrund der Border werden die Koordinaten-Leisten
+    // nicht mehr benoetigt
+    geoMapPane.setGridBarVisible(false);
+   
     // rechter Bereich: Map, Grids und Scale
     this.geoMapPane = geoMapPane;
     this.mapPane = geoMapPane.getMapPane();

Modified: branches/1.0-gt2-2.6/src/schmitzm/lang/LangUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/lang/LangUtil.java	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/lang/LangUtil.java	2009-11-24 15:43:08 UTC (rev 566)
@@ -29,6 +29,8 @@
  ******************************************************************************/
 package schmitzm.lang;
 
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
 import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -896,6 +898,17 @@
       throw new IllegalArgumentException("Can not handle collection: "+getSimpleClassName(values),err);
     }
   }
+  
+  /**
+   * Puts a text to system clipboard.
+   * @param str a text
+   */
+  public static void copyToClipboard(String str) {
+    if ( str == null )
+      return;
+    StringSelection sel = new StringSelection( str );
+    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel,sel);
+  }
 
   /**
    * Erzeugt einen Log4j-Logger fuer ein Objekt. Als Identifier fuer den Logger
@@ -965,3 +978,4 @@
   }
 
 }
+

Modified: branches/1.0-gt2-2.6/src/schmitzm/swing/ExceptionDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/swing/ExceptionDialog.java	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/swing/ExceptionDialog.java	2009-11-24 15:43:08 UTC (rev 566)
@@ -32,6 +32,8 @@
 import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
@@ -43,6 +45,8 @@
 import javax.swing.JTextArea;
 import javax.swing.JToggleButton;
 
+import schmitzm.lang.LangUtil;
+
 /**
  * Diese Klasse stellt eine modale Fehler-Meldung dar. Diese besteht neben
  * einer Meldung aus einem Text-Feld, in dem der StackTrace des Fehlers
@@ -59,6 +63,10 @@
   protected JButton okButton = null;
   /** Button um Details anzuzeigen. */
   protected JToggleButton detailsButton = null;
+  /** Button um die Exception in die Zwischenablage zu kopieren. */
+  protected JButton copyToClipboardButton = null;
+  /** Button um die Exception auf die Console zu kopieren. */
+  protected JButton copyToConsoleButton = null;
   /** Bereich, in dem die Details angezeigt werden. */
   protected JTextArea detailsTextArea = null;
   /** ScrollPane, in dem sich die TextArea fuer die Details befinden. */
@@ -117,14 +125,16 @@
       errMessage = err.getMessage();
 
     // Vorlagen-Dialog erzeugen
-    this.err               = err;
-    this.messageLabel      = new JLabel(errMessage);
-    this.okButton          = new JButton( SwingUtil.RESOURCE.getString("Ok") );
-    this.detailsButton     = new JToggleButton( SwingUtil.RESOURCE.getString("Details"), showDetails );
-    this.detailsTextArea   = new JTextArea(10,60);
+    this.err                   = err;
+    this.messageLabel          = new JLabel(errMessage);
+    this.okButton              = new JButton( SwingUtil.RESOURCE.getString("Ok") );
+    this.copyToConsoleButton   = new JButton( SwingUtil.RESOURCE.getString("ExceptionDialog.CopyToConsole") );
+    this.copyToClipboardButton = new JButton( SwingUtil.RESOURCE.getString("ExceptionDialog.CopyToClipboard") );
+    this.detailsButton         = new JToggleButton( SwingUtil.RESOURCE.getString("Details"), showDetails );
+    this.detailsTextArea       = new JTextArea(10,60);
     this.detailsTextArea.setEditable(false);
-    this.detailsPrintStream = new TextAreaPrintStream(detailsTextArea);
-    this.detailsScrollPane  = new JScrollPane(detailsTextArea);
+    this.detailsPrintStream    = new TextAreaPrintStream(detailsTextArea);
+    this.detailsScrollPane     = new JScrollPane(detailsTextArea);
     this.detailsScrollPane.setVisible(showDetails);
     this.setError(err);
     JOptionPane  pane = new JOptionPane(
@@ -132,7 +142,7 @@
       JOptionPane.ERROR_MESSAGE,
       JOptionPane.DEFAULT_OPTION,
       null,
-      new Object[] {okButton, detailsButton}
+      new Object[] {okButton, detailsButton, copyToConsoleButton, copyToClipboardButton}
     );
     JDialog dialog = pane.createDialog(parent,title);
 
@@ -155,6 +165,17 @@
         pack();
       }
     } );
+    this.copyToClipboardButton.addActionListener( new ActionListener() {
+      public void actionPerformed(ActionEvent e) {
+        LangUtil.copyToClipboard( detailsTextArea.getText() );
+      }
+    } );
+    this.copyToConsoleButton.addActionListener( new ActionListener() {
+      public void actionPerformed(ActionEvent e) {
+        if ( getError() != null )
+          getError().printStackTrace();
+      }
+    } );
 
     pack();
     SwingUtil.setRelativeFramePosition(this,SwingUtil.getParentWindow(parent),0.5,0.5);

Modified: branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-11-24 15:43:08 UTC (rev 566)
@@ -89,6 +89,9 @@
 Start=Start
 Calculate=Calculate
 
+ExceptionDialog.CopyToClipboard=Copy to clipboard
+ExceptionDialog.CopyToConsole=Copy to console
+
 OperationTreePanel.OpDesc.and=AND
 OperationTreePanel.OpDesc.or=OR
 OperationTreePanel.OpDesc.not=NOT

Modified: branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2009-11-24 15:29:41 UTC (rev 565)
+++ branches/1.0-gt2-2.6/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2009-11-24 15:43:08 UTC (rev 566)
@@ -86,6 +86,9 @@
 Start=Start
 Calculate=Rechnen
 
+ExceptionDialog.CopyToClipboard=In die Zwischenablage
+ExceptionDialog.CopyToConsole=Auf Console ausgeben
+
 OperationTreePanel.OpDesc.and=UND
 OperationTreePanel.OpDesc.or=ODER
 OperationTreePanel.OpDesc.not=NICHT



More information about the Schmitzm-commits mailing list