|
From: <jum...@li...> - 2015-04-01 13:52:34
|
Revision: 4368
http://sourceforge.net/p/jump-pilot/code/4368
Author: ma15569
Date: 2015-04-01 13:52:26 +0000 (Wed, 01 Apr 2015)
Log Message:
-----------
Fix tooltip
Modified Paths:
--------------
core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
core/trunk/src/language/jump.properties
Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java 2015-04-01 06:37:19 UTC (rev 4367)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java 2015-04-01 13:52:26 UTC (rev 4368)
@@ -33,20 +33,29 @@
package com.vividsolutions.jump.workbench.ui;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JDesktopPane;
import javax.swing.JPanel;
+import javax.swing.border.TitledBorder;
+import org.saig.core.gui.swing.sldeditor.util.FormUtils;
+import org.saig.jump.widgets.config.ConfigTooltipPanel;
+
import com.vividsolutions.jts.util.Assert;
import com.vividsolutions.jump.I18N;
import com.vividsolutions.jump.util.Blackboard;
+import com.vividsolutions.jump.workbench.ui.plugin.PersistentBlackboardPlugIn;
/**
- * Implements an {@link OptionsPanel} for Edit.
+ * Implements an {@link OptionsPanel} for Edit.
+ *
+ * [2015-1-4] added option for advanced layer tooltip
*/
public class EditOptionsPanel extends JPanel implements OptionsPanel {
@@ -56,54 +65,108 @@
private JCheckBox preventEditsCheckBox = new JCheckBox();
private JPanel jPanel2 = new JPanel();
private Blackboard blackboard;
- private JDesktopPane desktopPane;
-
+ private JPanel tooltipPanel;
+ private JCheckBox tooltipCheck;
+
+ /** Opciones de tooltip */
+ public static final String LAYER_TOOLTIPS_ON = ConfigTooltipPanel.class
+ .getName() + " - LAYER_TOOLTIPS"; //$NON-NLS-1$
+
public EditOptionsPanel(final Blackboard blackboard,
JDesktopPane desktopPane) {
this.blackboard = blackboard;
- this.desktopPane = desktopPane;
try {
jbInit();
} catch (Exception e) {
Assert.shouldNeverReachHere(e.toString());
- }
+ }
+
+ this.blackboard = blackboard;
+ this.setLayout(new GridBagLayout());
+
+ // Anyadimos los paneles
+ FormUtils.addRowInGBL(this, 1, 0, getEditPanel());
+ FormUtils.addRowInGBL(this, 2, 0, getTooltipPanel());
+ FormUtils.addFiller(this, 3, 0);
}
+ /**
+ *
+ * @return
+ */
+ private JPanel getTooltipPanel() {
+ if (tooltipPanel == null) {
+ tooltipPanel = new JPanel(new GridBagLayout());
+ TitledBorder titledBorder1 = new TitledBorder(
+ BorderFactory.createEtchedBorder(Color.white, new Color(
+ 148, 145, 140)),
+ I18N.get("ui.EditOptionsPanel.configure-layer-tree-tooltip"));
+ tooltipPanel.setBorder(titledBorder1); //$NON-NLS-1$
+ tooltipCheck = new JCheckBox(
+ I18N.get("ui.EditOptionsPanel.enable-JUMP-basic-tooltips")); //$NON-NLS-1$
+
+ FormUtils.addRowInGBL(tooltipPanel, 0, 0, tooltipCheck);
+ }
+ return tooltipPanel;
+ }
+
public String validateInput() {
return null;
}
public void okPressed() {
- blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, preventEditsCheckBox.isSelected());
- }
+ blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
+ preventEditsCheckBox.isSelected());
+ PersistentBlackboardPlugIn.get(blackboard).put(LAYER_TOOLTIPS_ON,
+ tooltipCheck.isSelected());
+ }
+
public void init() {
preventEditsCheckBox.setSelected(blackboard.get(
EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, false));
+ boolean layerTooltipsOn = PersistentBlackboardPlugIn.get(blackboard)
+ .get(LAYER_TOOLTIPS_ON, false);
+ if (layerTooltipsOn) {
+ tooltipCheck.setSelected(true);
+ }
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
jPanel1.setLayout(gridBagLayout1);
- preventEditsCheckBox.setText(I18N.get("ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries"));
- this.add(jPanel1, BorderLayout.CENTER);
- jPanel1.add(
- preventEditsCheckBox,
- new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 4, 0), 0, 0));
- jPanel1.add(
- jPanel2,
- new GridBagConstraints(
- 100,
- 100,
- 1,
- 1,
- 1.0,
- 1.0,
- GridBagConstraints.CENTER,
- GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0),
- 0,
- 0));
+ preventEditsCheckBox
+ .setText(I18N
+ .get("ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries"));
+ this.add(jPanel1, BorderLayout.EAST);
+ TitledBorder titledBorder2 = new TitledBorder(
+ BorderFactory.createEtchedBorder(Color.white, new Color(148,
+ 145, 140)), I18N.get("Edit"));
+ jPanel1.setBorder(titledBorder2); //$NON-NLS-1$
+ jPanel1.add(preventEditsCheckBox, new GridBagConstraints(0, 0, 1, 1,
+ 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
+ new Insets(10, 10, 4, 0), 0, 0));
+ jPanel1.add(jPanel2, new GridBagConstraints(100, 100, 1, 1, 1.0, 1.0,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
+ 0, 0, 0, 0), 0, 0));
+ // FormUtils.addRowInGBL( jPanel1, 0, 0, preventEditsCheckBox);
}
+
+ private JPanel getEditPanel() {
+ if (jPanel1 == null) {
+ jPanel1 = new JPanel(new GridBagLayout());
+ TitledBorder titledBorder2 = new TitledBorder(
+ BorderFactory.createEtchedBorder(Color.white, new Color(
+ 148, 145, 140)), I18N.get("Edit"));
+ jPanel1.setBorder(titledBorder2); //$NON-NLS-1$
+ preventEditsCheckBox = new JCheckBox(
+ "ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries");
+ jPanel1.add(preventEditsCheckBox, new GridBagConstraints(0, 0, 1,
+ 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(10, 10, 4, 0), 0, 0));
+
+ // FormUtils.addRowInGBL(tooltipPanel, 0, 0, tooltipCheck);
+ }
+ return jPanel1;
+ }
}
Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java 2015-04-01 06:37:19 UTC (rev 4367)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java 2015-04-01 13:52:26 UTC (rev 4368)
@@ -53,13 +53,13 @@
import org.apache.log4j.Logger;
import org.openjump.core.rasterimage.RasterImageLayer;
-import org.saig.jump.widgets.config.ConfigTooltipPanel;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jump.I18N;
import com.vividsolutions.jump.feature.Feature;
import com.vividsolutions.jump.feature.FeatureCollection;
import com.vividsolutions.jump.io.datasource.DataSourceQuery;
+import com.vividsolutions.jump.util.StringUtil;
import com.vividsolutions.jump.workbench.JUMPWorkbench;
import com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset;
import com.vividsolutions.jump.workbench.imagery.ReferencedImageStyle;
@@ -123,20 +123,13 @@
private final static String LAYER_NAME = I18N
.get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Layer-Name");
private final static String FILE_NAME = I18N.get("ui.MenuNames.FILE");
- private final static String XMIN = I18N
- .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.xmin");
- private final static String YMIN = I18N
- .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.ymin");
- private final static String XMAX = I18N
- .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.xmax");
- private final static String YMAX = I18N
- .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.ymax");
+ private final static String MODIFIED = I18N
+ .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.modified");
private final static String SRS = I18N
.get("ui.plugin.wms.EditWMSQueryPanel.coordinate-reference-system");
private final static String URL = "Url";
- private final static String MODIFIED = I18N
- .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.modified");
- private final static String NOTSAVED = "This layer has no datasource";
+ private final static String NODATASOURCELAYER = I18N
+ .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.nodatasourcelayer.message");
// I18N
// .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Not-Saved");
private final static String SOURCE_PATH = I18N
@@ -316,12 +309,12 @@
*/
/**
- * Giuseppe Aruta [2015-01-04] Generated tooltip text
- * [2015-03-29] Made tooltip optional (original/enhanced)
+ * Giuseppe Aruta [2015-01-04] Generated tooltip text [2015-03-29] Made
+ * tooltip optional (original/enhanced)
*/
boolean layerTooltipsOn = PersistentBlackboardPlugIn.get(
JUMPWorkbench.getInstance().getBlackboard()).get(
- ConfigTooltipPanel.LAYER_TOOLTIPS_ON, false);
+ EditOptionsPanel.LAYER_TOOLTIPS_ON, false);
if (layerTooltipsOn) {
setToolTipText(generateMinimalToolTipText(layerable));
@@ -329,7 +322,6 @@
setToolTipText(generateToolTipText(layerable));
}
// setToolTipText(generateToolTipText(layerable));
-
if (isSelected) {
Color sbg = list.getSelectionBackground();
Color sfg = list.getSelectionForeground();
@@ -573,6 +565,38 @@
}
/*
+ * This method takes a String of text and simulates word wrapping by
+ * applying HTML code <BR> after n characters per line. It will check to
+ * make sure that we are not in the middle of a word before breaking the
+ * line.
+ */
+ public static String SplitString(String string, int n) {
+
+ StringBuffer buf = new StringBuffer();
+ String tempString = string;
+
+ if (string != null) {
+
+ while (tempString.length() > n) {
+ String block = tempString.substring(0, n);
+ int index = block.lastIndexOf(File.separator);
+ if (index < 0) {
+ index = tempString.indexOf(File.separator);
+ }
+ if (index >= 0) {
+ buf.append(tempString.substring(0, index) + "<BR>");
+ }
+ tempString = tempString.substring(index + 1);
+ }
+ } else {
+ tempString = File.separator;
+ }
+ buf.append(tempString);
+ return buf.toString();
+
+ }
+
+ /*
* Associate Byte, Megabytes, etc to file
*/
private static final String[] Q = new String[] { "", "KB", "MB", "GB",
@@ -594,7 +618,7 @@
* Enumeration of File extension used in Sextante Raster Layer
*/
public enum TypeFile {
- ASC, CSV, DXF, FLT, TIF, TIFF, JPG, JPEG, PNG, GIF, GRD, JP2, BMP
+ ASC, CSV, DXF, FLT, TIF, TIFF, JPG, JPEG, PNG, GIF, GRD, JP2, BMP, ECW, MrSID
}
private String filetype;
@@ -657,16 +681,18 @@
filetype = "BMP - Windows Bitmap";
break;
}
+ case ECW: {
+ filetype = "ECW - Enhanced Compression Wavelet";
+ break;
}
+ case MrSID: {
+ filetype = "MrSID - Multiresolution seamless image database";
+ break;
+ }
+ }
return filetype;
}
-
-
- /**
- * Giuseppe Aruta [2015-01-04] Create a tooltip
- * Original JUMP version
- */
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
@@ -676,16 +702,40 @@
}
return ext;
}
-
+
+ /**
+ * Giuseppe Aruta [2015-01-04] Create a tooltip Original JUMP version
+ */
+ private String generateMinimalToolTipText(Layerable layerable) {
+
+ String tooltip = "";
+ if (layerable instanceof Layer) {
+ if (((Layer) layerable).getDescription() == null
+ || ((Layer) layerable).getDescription().trim().length() == 0
+ || ((Layer) layerable).getDescription().equals(
+ layerable.getName())) {
+ tooltip = FEATURE_COUNT
+ + " = "
+ + ((Layer) layerable).getFeatureCollectionWrapper()
+ .size();
+ } else {
+ tooltip = layerable.getName() + ": "
+ + ((Layer) layerable).getDescription();
+ }
+ } else
+ tooltip = layerable.getName();
+ return tooltip;
+ }
+
private String generateToolTipText(Layerable layerable) {
// String tooltip = layerable.getName();
String tooltip = "";
String sourceClass = "";
- JEditorPane pane = new JEditorPane();
+ new JEditorPane();
- String sourcePath = NOTSAVED.toUpperCase();
+ String sourcePath = NODATASOURCELAYER.toUpperCase();
/*
* WMSLayer.class
@@ -699,7 +749,8 @@
tooltip += "<DIV style=\"width: 400px; text-justification: justify;\">";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layer.getName() + "<br>";
tooltip += "<b>" + DATASOURCE_CLASS + ": </b>" + "WMS" + "<br>";
- tooltip += "<b>" + URL + ": </b>" + SplitString(url) + "<br>";
+ tooltip += "<b>" + URL + ": </b>" + StringUtil.split(url, 350)
+ + "<br>";
tooltip += "<b>" + SRS + ": </b>" + srs + "<br>";
tooltip += "<b>" + EXTENT + ": </b>" + env.toString() + "<br>";
tooltip += "</DIV></BODY></HTML>";
@@ -723,7 +774,8 @@
tooltip += "<DIV style=\"width: 400px; text-justification: justify;\">";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layer.getName() + "<br>";
tooltip += "<b>" + DATASOURCE_CLASS + ": </b>" + "WFS" + "<br>";
- tooltip += "<b>" + URL + ": </b>" + SplitString(url) + "<br>";
+ tooltip += "<b>" + URL + ": </b>" + StringUtil.split(url, 350)
+ + "<br>";
tooltip += "<b>" + SRS + ": </b>" + srs + "<br>";
tooltip += "<b>" + EXTENT + ": </b>" + env.toString() + "<br>";
tooltip += "<b>" + FEATURE_COUNT + ": </b>" + size + "<br>";
@@ -737,17 +789,17 @@
// If RasterImageLayer.class has a datasource
if (layer.getImageFileName() != null) {
File image = new File(layer.getImageFileName());
- String folder = image.getParent();
- String nameFile = image.getName();
+ image.getParent();
+ image.getName();
String type = filetype(image);
- String path = SplitString(image.toString());
+ String path = StringUtil.split(image.toString(), 350);
tooltip = "<HTML><BODY>";
tooltip += "<DIV style=\"width: 400px; text-justification: justify;\">";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layer.getName()
+ "<br>";
- tooltip += "<b>" + DATASOURCE_CLASS + ": </b>" + SEXTANTE
- + ": " + type + "<br>";
+ tooltip += "<b>" + DATASOURCE_CLASS + ": </b>" + ": " + type
+ + " (" + SEXTANTE + ")<br>";
// tooltip += "<b>" + FILE_NAME + ": </b>" + nameFile + "<br>";
tooltip += "<b>" + SOURCE_PATH + ": </b>" + path + "<br>";
tooltip += "<b>" + FEATURE_COUNT + ": </b>" + "1" + "<br>";
@@ -755,7 +807,7 @@
}
// If RasterImageLayer.class has no datasource
else {
- sourcePath = NOTSAVED;
+ sourcePath = NODATASOURCELAYER;
tooltip = "<HTML><BODY>";
tooltip += "<DIV style=\"width: 400px; text-justification: justify;\">";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layer.getName()
@@ -816,8 +868,8 @@
if (dotPos > 0)
sourceClass = sourceClass.substring(dotPos + 1);
File f = new File(sourcePath);
- String fileName = f.getName();
- String path = SplitString(sourcePath);
+ f.getName();
+ String path = StringUtil.split(sourcePath, 350);
// Layer.class with datasource that has been modified
if (layer.isFeatureCollectionModified()) {
@@ -843,13 +895,13 @@
tooltip += "<b>" + DATASOURCE_CLASS + ": </b>"
+ sourceClass + "<br>";
tooltip += "<b>" + SOURCE_PATH + ": </b>"
- + SplitString(sourcePath) + "<br>";
+ + StringUtil.split(sourcePath, 350) + "<br>";
tooltip += "<b>" + FEATURE_COUNT + ": </b>" + size + "<br>";
tooltip += "</DIV></BODY></HTML>";
} else {
- sourcePath = NOTSAVED;
+ sourcePath = NODATASOURCELAYER;
tooltip = "<HTML><BODY>"; //$NON-NLS-1$
// tooltip +=
// "<DIV style=\"width: 300px; text-justification: justify;\">";
@@ -886,8 +938,7 @@
sourcePathImage = sourcePathImage.substring(5);
sourceClassImage = (String) feature
.getString(ImageryLayerDataset.ATTR_TYPE);
- String sourceClassImage1 = sourceClassImage.replace("%20",
- " ");
+ sourceClassImage.replace("%20", " ");
/*
* Check if the Image Layer.class has only one file loaded
*/
@@ -896,18 +947,17 @@
String filePath = f.getAbsolutePath();
String filePath1 = filePath.replace("%20", " ");
String type = filetype(f);
- String fileName = f.getName();
+ f.getName();
tooltip = "<HTML><BODY>"; //$NON-NLS-1$
tooltip += "<DIV style=\"width: 400px; text-justification: justify;\">";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layerName
+ "<br>";
- tooltip += "<b>" + DATASOURCE_CLASS + ": </b>"
- + "Image (Referenced Image readers)" + ": "
- + type + "<br>";
+ tooltip += "<b>" + DATASOURCE_CLASS + ": </b>" + type
+ + "<br>";
tooltip += "<b>" + SOURCE_PATH + ": </b>"
- + SplitString(filePath1) + "<br>";
+ + StringUtil.split(filePath1, 350) + "<br>";
tooltip += "<b>" + FEATURE_COUNT + ": </b>" + size
+ "<br>";
tooltip += "</DIV></BODY></HTML>";
@@ -937,7 +987,8 @@
else {
tooltip = "<HTML><BODY>";
tooltip += "<b>" + LAYER_NAME + ": </b>" + layerName + "<br>";
- tooltip += "<b>" + FILE_NAME + ": </b>" + NOTSAVED + "<br>";
+ tooltip += "<b>" + FILE_NAME + ": </b>" + NODATASOURCELAYER
+ + "<br>";
tooltip += "<b>" + FEATURE_COUNT + ": </b>" + size + "<br>";
tooltip += "</BODY></HTML>";
}
@@ -947,59 +998,6 @@
}
- private String generateMinimalToolTipText(Layerable layerable) {
-
- String tooltip = "";
- if (layerable instanceof Layer) {
- if (((Layer) layerable).getDescription() == null
- || ((Layer) layerable).getDescription().trim().length() == 0
- || ((Layer) layerable).getDescription().equals(
- layerable.getName())) {
- tooltip = FEATURE_COUNT
- + " = "
- + ((Layer) layerable).getFeatureCollectionWrapper()
- .size();
- } else {
- tooltip = layerable.getName() + ": "
- + ((Layer) layerable).getDescription();
- }
- } else
- tooltip = layerable.getName();
- return tooltip;
- }
-
- /*
- * This method takes a String of text and simulates word wrapping
- * by applying HTML code <BR> after a defined line length. It
- * will check to make sure that we are not in the middle of a word
- * before breaking the line.
- */
- public static String SplitString(String string) {
-
- StringBuffer buf = new StringBuffer();
- String tempString = string;
-
- if (string != null) {
-
- while (tempString.length() > 190) {
- String block = tempString.substring(0, 400);
- int index = block.lastIndexOf(' ');
- if (index < 0) {
- index = tempString.indexOf(' ');
- }
- if (index >= 0) {
- buf.append(tempString.substring(0, index) + "<BR>");
- }
- tempString = tempString.substring(index + 1);
- }
- } else {
- tempString = " ";
- }
- buf.append(tempString);
- return buf.toString();
-
- }
-
@Override
// [ede 11.2012] this is necessary for comboboxes with transparent bg, like
// in
Modified: core/trunk/src/language/jump.properties
===================================================================
--- core/trunk/src/language/jump.properties 2015-04-01 06:37:19 UTC (rev 4367)
+++ core/trunk/src/language/jump.properties 2015-04-01 13:52:26 UTC (rev 4368)
@@ -776,6 +776,7 @@
org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.xmin = xMin
org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.ymax = yMax
org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.ymin = yMin
+org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.nodatasourcelayer.message=This layer has no datasource
org.openjump.core.ui.plugin.layer.SortCategoryAbstractPlugIn.Sort-Selected-Categories = Sort Selected Categories
org.openjump.core.ui.plugin.layer.SortCategoryByFeaturesPlugIn.By-Featues = By Features
org.openjump.core.ui.plugin.layer.SortCategoryByFeaturesPlugIn.By-Least-Number-of-Features = By Least Number of Features
@@ -1728,6 +1729,8 @@
ui.DatasetOptionsPanel.ShowCharsetSelection = Show charset selection
ui.DatasetOptionsPanel.datasetOptions = Dataset
ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries = Prevent edits resulting in invalid geometries.
+ui.EditOptionsPanel.configure-layer-tree-tooltip=Configure layer tree tooltip
+ui.EditOptionsPanel.enable-JUMP-basic-tooltips=Enable JUMP basic tooltips
ui.EditTransaction.the-geometry-is-invalid-cancelled = The new geometry is invalid. Cancelled.
ui.EditTransaction.the-new-geometry-is-invalid = The new geometry is invalid.
ui.ErrorFialog.hide-details = Hide Details
|