[Schmitzm-commits] r81 - in trunk/src/schmitzm/geotools/gui: . resource/locales

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 22 15:51:22 CEST 2009


Author: alfonx
Date: 2009-04-22 15:51:21 +0200 (Wed, 22 Apr 2009)
New Revision: 81

Modified:
   trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
   trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
   trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
Log:
* Added a SelectionStatusLabel to SelectableFeatureTablePane.java in the style of "4 of 15 points are selected"


Modified: trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-22 13:47:55 UTC (rev 80)
+++ trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-22 13:51:21 UTC (rev 81)
@@ -15,10 +15,8 @@
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 
 import javax.swing.AbstractAction;
 import javax.swing.Action;
@@ -28,13 +26,15 @@
 import javax.swing.JScrollBar;
 import javax.swing.JScrollPane;
 import javax.swing.JToolBar;
-import javax.swing.JViewport;
 import javax.swing.SortOrder;
+import javax.swing.SwingUtilities;
 import javax.swing.RowSorter.SortKey;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
 
 import org.geotools.feature.FeatureCollection;
 
-import com.vividsolutions.jts.geom.Envelope;
+import schmitzm.geotools.GTUtil;
 
 /**
  * Extends the {@link FeatureTablePane} with buttons and functionality to select
@@ -60,6 +60,8 @@
 			SelectableFeatureTablePane.class
 					.getResource("resource/icons/mActionZoomToSelected.png"));
 	private final JMapPane externalMapPane;
+	
+	private JLabel statusLabel;
 
 	/**
 	 * @param model
@@ -99,10 +101,53 @@
 		mapPane.setPreferredSize(new Dimension(200, 300));
 		featuresTable.getParent().setPreferredSize(new Dimension(400, 300));
 
-		newPanelArroundTable.add(getToolBar(), BorderLayout.NORTH);
+		// In the NORTH, the ToolBar and a JLabel presenting the total and selected number of features is displayed
+		JPanel north = new JPanel(new BorderLayout());
+		north.add(getToolBar(), BorderLayout.WEST);
+		north.add(getStatusLabel(), BorderLayout.EAST);
+		newPanelArroundTable.add(north, BorderLayout.NORTH);
 		newPanelArroundTable.add(getSearchBar(), BorderLayout.SOUTH);
+		
+		getTable().getSelectionModel().addListSelectionListener( new ListSelectionListener(){
+
+			@Override
+			public void valueChanged(ListSelectionEvent e) {
+				if (!e.getValueIsAdjusting()){
+					if (!SwingUtilities.isEventDispatchThread()) throw new RuntimeException("Not on EDT!");
+					getStatusLabel();
+				}
+			}
+			
+		});
 	}
 
+	/**
+	 * This Label present something like "40 of 56 Polygons selected". It is lazily constructed. Later calls will only update the existing label.  
+	 */
+	private JLabel getStatusLabel() {
+		if (statusLabel == null){
+			statusLabel = new JLabel();
+		}
+		
+		// TODO Cache totalAnz and localizedGeometryTypeName. Do not recalc all the time!  
+		
+		int selectedAnz = getSelectedFeatures().size();
+		int totalAnz = getFeatureCollection().size();
+		String localizedGeometryTypeName = "rows";
+		
+		if ( GTUtil.isPolygon(getFeatureCollection())){
+			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons");
+		} else if ( GTUtil.isPoint(getFeatureCollection())){
+			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points");
+		}else if ( GTUtil.isLineString(getFeatureCollection())){
+			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines");
+		}
+	
+		statusLabel.setText( GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus", selectedAnz, totalAnz,localizedGeometryTypeName));
+		
+		return statusLabel;
+	}
+
 	private Component getSearchBar() {
 		return new JLabel(""); // TODO Add ability to search here!
 	}
@@ -112,6 +157,8 @@
 	 */
 	protected JToolBar getToolBar() {
 		JToolBar toolBar = new JToolBar();
+		
+		toolBar.setFloatable(false); // Sorry Martin ;-) 
 
 		/**
 		 * Add an Action to clear the selection

Modified: trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-04-22 13:47:55 UTC (rev 80)
+++ trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-04-22 13:51:21 UTC (rev 81)
@@ -101,4 +101,8 @@
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.clearSelection.tt=Clear selection
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.selectionToTop.tt=Move selected to the top of the table
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.invertSelection.tt=Invert selection
-schmitzm.geotools.gui.SelectableFeatureTablePane.button.zoomToSelection.tt=Zoom to selected features
\ No newline at end of file
+schmitzm.geotools.gui.SelectableFeatureTablePane.button.zoomToSelection.tt=Zoom to selected features
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus=${0} of ${1} ${2} selected.
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons=polygons
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points=points
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines=lines
\ No newline at end of file

Modified: trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-04-22 13:47:55 UTC (rev 80)
+++ trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-04-22 13:51:21 UTC (rev 81)
@@ -98,3 +98,7 @@
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.selectionToTop.tt=Ausgewählte Zeilen in der Tabelle nach oben verschieben 
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.invertSelection.tt=Auswahl umkehren
 schmitzm.geotools.gui.SelectableFeatureTablePane.button.zoomToSelection.tt=Zoomt zu den ausgewählten Geoobjekten 
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus=${0} von ${1} ${2} selektiert.
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons=Polygone
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points=Punkte
+schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines=Linien
\ No newline at end of file



More information about the Schmitzm-commits mailing list