Revision: 5066
http://sourceforge.net/p/jump-pilot/code/5066
Author: michaudm
Date: 2016-10-09 17:11:42 +0000 (Sun, 09 Oct 2016)
Log Message:
-----------
Refactoring of EditOptionsPanel + add "single editable layer" option
Modified Paths:
--------------
core/trunk/ChangeLog
core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/editing/FeatureDrawingUtil.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/AddNewLayerPlugIn.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/OptionsPlugIn.java
Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog 2016-10-09 16:47:12 UTC (rev 5065)
+++ core/trunk/ChangeLog 2016-10-09 17:11:42 UTC (rev 5066)
@@ -3,6 +3,9 @@
# 2. make sure that lines break at 80 chars for constricted display situations
#<-------------------------------- 80 chars
---------------------------------->#
+2016-10-09 mmichaud <[email protected]>
+ * Refactoring of EditOptionsPanel + add single editable layer option
+
2016-10-08
* Fix bug #433 throwing exception when applying scale limits in bad order
* Optimization : changeStyle was applying the new style two times
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
2016-10-09 16:47:12 UTC (rev 5065)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -55,69 +55,93 @@
/**
* Implements an {@link OptionsPanel} for Edit.
*
- * [2015-1-4] added option for advanced layer tooltip [2016-4-10] Giuseppe
Aruta
- * [2016-4-10] Giuseppe Aruta - added option to select the geometry after it
has
+ * [2015-04-01] Giuseppe Aruta - add option for advanced layer tooltip
+ * [2016-10-04] Giuseppe Aruta - add option to select the geometry after it has
* been drawn
+ * [2016-10-09] Micha\xEBl Michaud - add option to limit the number of editable
+ * layers to one
*/
public class EditOptionsPanel extends JPanel implements OptionsPanel {
- private BorderLayout borderLayout1 = new BorderLayout();
- private JPanel jPanel1 = new JPanel();
- private GridBagLayout gridBagLayout1 = new GridBagLayout();
- private JCheckBox preventEditsCheckBox = new JCheckBox();
- private JPanel jPanel2 = new JPanel();
+
+ private JPanel editPanel;
+ private JCheckBox preventEditsCheckBox;
+ private JCheckBox selectNewGeometryCheckBox;
+ private JCheckBox singleEditableLayerCheckBox;
+
+ private JPanel layerToolTipPanel;
private Blackboard blackboard;
- private JPanel tooltipPanel;
- private JCheckBox tooltipCheck;
- public static JCheckBox geometryCheck;
+ private JCheckBox tooltipCheckBox;
- /** Opciones de tooltip */
- public static final String LAYER_TOOLTIPS_ON = ConfigTooltipPanel.class
- .getName() + " - LAYER_TOOLTIPS"; //$NON-NLS-1$
+ /** Option de editable layer number */
+ public static final String SELECT_NEW_GEOMETRY_KEY =
ConfigTooltipPanel.class
+ .getName() + " - SELECT_NEW_GEOMETRY";
+
+ /** Option de editable layer number */
+ public static final String SINGLE_EDITABLE_LAYER_KEY =
ConfigTooltipPanel.class
+ .getName() + " - SINGLE_EDITABLE_LAYER";
+
+ /** Option de tooltip */
+ public static final String LAYER_TOOLTIPS_KEY = ConfigTooltipPanel.class
+ .getName() + " - LAYER_TOOLTIPS";
+
+ public static final String EDIT_PANEL =
+ I18N.get("ui.EditOptionsPanel.edit-panel");
+ public static final String PREVENT_INVALID_EDIT =
+
I18N.get("ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries");
+ public static final String SELECT_NEW_GEOMETRY =
+ I18N.get("ui.EditOptionsPanel.select-new-geometry"); // Select the
geometry after it has been drawn
+ public static final String SINGLE_EDITABLE_LAYER =
+ I18N.get("ui.EditOptionsPanel.single-editable-layer");
+
+ public static final String CONFIGURE_LAYERTREE_PANEL =
+ I18N.get("ui.EditOptionsPanel.configure-layer-tree-tooltip");
+ public static final String LAYER_TOOLTIP =
+ I18N.get("ui.EditOptionsPanel.enable-JUMP-basic-tooltips");
+
/** Option selected geometry */
/*
* public static final String SELECTED_GEOMETRY = ConfigTooltipPanel.class
* .getName() + " - SELECTED_GEOMETRY"; //$NON-NLS-1$
*/
- public EditOptionsPanel(final Blackboard blackboard,
- JDesktopPane desktopPane) {
+ public EditOptionsPanel(final Blackboard blackboard) {
this.blackboard = blackboard;
- try {
- jbInit();
- } catch (Exception e) {
- Assert.shouldNeverReachHere(e.toString());
- }
-
- this.blackboard = blackboard;
this.setLayout(new GridBagLayout());
- // Anyadimos los paneles
+ // Add titled panels
FormUtils.addRowInGBL(this, 1, 0, getEditPanel());
FormUtils.addRowInGBL(this, 3, 0, getTooltipPanel());
FormUtils.addFiller(this, 4, 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);
+ try {
+ init();
+ } catch (Exception e) {
+ Assert.shouldNeverReachHere(e.toString());
}
- return tooltipPanel;
}
+ public void init() {
+ System.out.println("persistence " +
PersistentBlackboardPlugIn.get(blackboard).get(
+ SINGLE_EDITABLE_LAYER_KEY, true));
+ System.out.println("blackboard " + blackboard.get(
+ SINGLE_EDITABLE_LAYER_KEY, true));
+
preventEditsCheckBox.setSelected(PersistentBlackboardPlugIn.get(blackboard).get(
+ EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, false));
+
selectNewGeometryCheckBox.setSelected(PersistentBlackboardPlugIn.get(blackboard).get(
+ SELECT_NEW_GEOMETRY_KEY, false));
+
singleEditableLayerCheckBox.setSelected(PersistentBlackboardPlugIn.get(blackboard).get(
+ SINGLE_EDITABLE_LAYER_KEY, true));
+
tooltipCheckBox.setSelected(PersistentBlackboardPlugIn.get(blackboard).get(
+ LAYER_TOOLTIPS_KEY, false));
+
+ blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
preventEditsCheckBox.isSelected());
+ blackboard.put(SELECT_NEW_GEOMETRY_KEY,
selectNewGeometryCheckBox.isSelected());
+ blackboard.put(SINGLE_EDITABLE_LAYER_KEY,
singleEditableLayerCheckBox.isSelected());
+ blackboard.put(LAYER_TOOLTIPS_KEY, tooltipCheckBox.isSelected());
+ }
+
public String validateInput() {
return null;
}
@@ -125,78 +149,92 @@
public void okPressed() {
blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
preventEditsCheckBox.isSelected());
- PersistentBlackboardPlugIn.get(blackboard).put(LAYER_TOOLTIPS_ON,
- tooltipCheck.isSelected());
- /*
- * PersistentBlackboardPlugIn.get(blackboard).put(SELECTED_GEOMETRY,
- * geometryCheck.isSelected());
- */
+ blackboard.put(SELECT_NEW_GEOMETRY_KEY,
+ selectNewGeometryCheckBox.isSelected());
+ blackboard.put(SINGLE_EDITABLE_LAYER_KEY,
+ singleEditableLayerCheckBox.isSelected());
+ blackboard.put(LAYER_TOOLTIPS_KEY,
+ tooltipCheckBox.isSelected());
+ PersistentBlackboardPlugIn.get(blackboard).
+ put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
preventEditsCheckBox.isSelected());
+ PersistentBlackboardPlugIn.get(blackboard).
+ put(SELECT_NEW_GEOMETRY_KEY,
selectNewGeometryCheckBox.isSelected());
+ PersistentBlackboardPlugIn.get(blackboard).
+ put(SINGLE_EDITABLE_LAYER_KEY,
singleEditableLayerCheckBox.isSelected());
+ PersistentBlackboardPlugIn.get(blackboard).
+ put(LAYER_TOOLTIPS_KEY, tooltipCheckBox.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);
- }
- /*
- * boolean geometryOn = PersistentBlackboardPlugIn.get(blackboard).get(
- * SELECTED_GEOMETRY, false); if (geometryOn) {
- * geometryCheck.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"));
- geometryCheck = new JCheckBox(
- I18N.get("ui.EditOptionsPanel.select-geometry")); //$NON-NLS-1$
- geometryCheck
- .setToolTipText("ui.EditOptionsPanel.select-geometry-warning");
+ preventEditsCheckBox.setText(I18N
+
.get("ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries"));
+ geometryCheck = new JCheckBox(I18N
+ .get("ui.EditOptionsPanel.select-geometry"));
+ geometryCheck.setToolTipText(I18N
+ .get("ui.EditOptionsPanel.select-geometry-warning"));
this.add(jPanel1, BorderLayout.EAST);
+
TitledBorder titledBorder2 = new TitledBorder(
BorderFactory.createEtchedBorder(Color.white, new Color(148,
145, 140)), I18N.get("ui.EditOptionsPanel.edit"));
- jPanel1.setBorder(titledBorder2); //$NON-NLS-1$
+ jPanel1.setBorder(titledBorder2);
FormUtils.addRowInGBL(jPanel1, 0, 0, preventEditsCheckBox);
FormUtils.addRowInGBL(jPanel1, 1, 0, geometryCheck);
+ FormUtils.addRowInGBL(jPanel1, 1, 0, geometryCheck);
jPanel1.add(jPanel2, new GridBagConstraints(200, 200, 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());
+ if (editPanel == null) {
+ editPanel = new JPanel(new GridBagLayout());
TitledBorder titledBorder2 = new TitledBorder(
- BorderFactory.createEtchedBorder(Color.white, new Color(
- 148, 145, 140)),
- I18N.get("ui.EditOptionsPanel.edit"));
- jPanel1.setBorder(titledBorder2); //$NON-NLS-1$
- preventEditsCheckBox = new JCheckBox(
-
"ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries");
- geometryCheck = new JCheckBox(
- "Select the geometry after it has been drawn");
//$NON-NLS-1$
- FormUtils.addRowInGBL(jPanel1, 0, 0, preventEditsCheckBox);
- FormUtils.addRowInGBL(jPanel1, 1, 0, geometryCheck);
- /*
- * 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(geometryCheck, new
- * GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST,
- * GridBagConstraints.NONE, new Insets(10, 10, 4, 0), 0, 0));
- */
+ BorderFactory.createEtchedBorder(
+ Color.white, new Color(148, 145, 140)
+ ),
+ EDIT_PANEL);
+ editPanel.setBorder(titledBorder2);
- // FormUtils.addRowInGBL(tooltipPanel, 0, 0, tooltipCheck);
+ preventEditsCheckBox = new JCheckBox(PREVENT_INVALID_EDIT);
+ selectNewGeometryCheckBox = new JCheckBox(SELECT_NEW_GEOMETRY);
+ singleEditableLayerCheckBox = new JCheckBox(SINGLE_EDITABLE_LAYER);
+
+ FormUtils.addRowInGBL(editPanel, 0, 0, preventEditsCheckBox);
+ FormUtils.addRowInGBL(editPanel, 1, 0, selectNewGeometryCheckBox);
+ FormUtils.addRowInGBL(editPanel, 2, 0,
singleEditableLayerCheckBox);
}
- return jPanel1;
+ return editPanel;
}
+
+ /**
+ *
+ * @return
+ */
+ private JPanel getTooltipPanel() {
+ if (layerToolTipPanel == null) {
+
+ layerToolTipPanel = new JPanel(new GridBagLayout());
+ TitledBorder titledBorder1 = new TitledBorder(
+ BorderFactory.createEtchedBorder(
+ Color.white, new Color(148, 145, 140)
+ ),
+ CONFIGURE_LAYERTREE_PANEL);
+ layerToolTipPanel.setBorder(titledBorder1);
+
+ tooltipCheckBox = new JCheckBox(LAYER_TOOLTIP);
+
+ FormUtils.addRowInGBL(layerToolTipPanel, 0, 0, tooltipCheckBox);
+ }
+ return layerToolTipPanel;
+ }
}
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
2016-10-09 16:47:12 UTC (rev 5065)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -310,9 +310,8 @@
* Giuseppe Aruta [2015-01-04] Generated tooltip text [2015-03-29] Made
* tooltip optional (original/enhanced)
*/
- boolean layerTooltipsOn = PersistentBlackboardPlugIn.get(
- JUMPWorkbench.getInstance().getBlackboard()).get(
- EditOptionsPanel.LAYER_TOOLTIPS_ON, false);
+ boolean layerTooltipsOn = JUMPWorkbench.getInstance().getBlackboard()
+ .get(EditOptionsPanel.LAYER_TOOLTIPS_KEY, false);
if (layerTooltipsOn) {
setToolTipText(generateMinimalToolTipText(layerable));
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/editing/FeatureDrawingUtil.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/editing/FeatureDrawingUtil.java
2016-10-09 16:47:12 UTC (rev 5065)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/editing/FeatureDrawingUtil.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -180,7 +180,9 @@
public void execute() {
getLayer().getFeatureCollectionWrapper().add(feature);
- if (EditOptionsPanel.geometryCheck.isSelected()) {
+ if
(layerViewPanel.getWorkBenchFrame().getContext().getWorkbench()
+
.getBlackboard().get(EditOptionsPanel.SELECT_NEW_GEOMETRY_KEY, false)) {
+ //if (EditOptionsPanel.geometryCheck.isSelected()) {
featsToAdd = new ArrayList<Feature>();
featsToAdd.add(feature);
SelectionManager selectionManager = layerViewPanel
@@ -380,7 +382,12 @@
public void selectGeometry(LayerViewPanel panel, Geometry geom) {
SelectionManager selectionManager = panel.getSelectionManager();
- if (EditOptionsPanel.geometryCheck.isSelected()) {
+ if (panel.getWorkBenchFrame()
+ .getContext()
+ .getWorkbench()
+ .getBlackboard()
+ .get(EditOptionsPanel.SELECT_NEW_GEOMETRY_KEY, false)) {
+ //if (EditOptionsPanel.geometryCheck.isSelected()) {
this.featsToAdd = new ArrayList();
this.featsToAdd.add(FeatureUtil.toFeature(geom, layer(panel)
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/AddNewLayerPlugIn.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/AddNewLayerPlugIn.java
2016-10-09 16:47:12 UTC (rev 5065)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/AddNewLayerPlugIn.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -41,11 +41,14 @@
import com.vividsolutions.jump.feature.FeatureCollection;
import com.vividsolutions.jump.feature.FeatureDataset;
import com.vividsolutions.jump.feature.FeatureSchema;
+import com.vividsolutions.jump.workbench.model.Layer;
+import com.vividsolutions.jump.workbench.model.Layerable;
import com.vividsolutions.jump.workbench.model.StandardCategoryNames;
import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
import com.vividsolutions.jump.workbench.plugin.EnableCheck;
import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.ui.EditOptionsPanel;
import com.vividsolutions.jump.workbench.ui.cursortool.editing.EditingPlugIn;
import com.vividsolutions.jump.workbench.ui.images.IconLoader;
@@ -67,13 +70,16 @@
reportNothingToUndoYet(context);
Collection selectedCategories = context.getLayerNamePanel()
.getSelectedCategories();
- context
- .addLayer(
+ Layer layer = context.addLayer(
selectedCategories.isEmpty() ? StandardCategoryNames.WORKING
: selectedCategories.iterator().next().toString(),
I18N.get("ui.plugin.AddNewLayerPlugIn.new"),
- createBlankFeatureCollection()).setFeatureCollectionModified(false)
- .setEditable(true);
+ createBlankFeatureCollection());
+ layer.setFeatureCollectionModified(false);
+ if
(context.getWorkbenchContext().getBlackboard().get(EditOptionsPanel.SINGLE_EDITABLE_LAYER_KEY,
false)) {
+ setAllLayersToUneditable(context);
+ }
+ layer.setEditable(true);
((EditingPlugIn) context.getWorkbenchContext().getBlackboard()
.get(EditingPlugIn.KEY)).getToolbox(context.getWorkbenchContext())
.setVisible(true);
@@ -81,6 +87,12 @@
return true;
}
+ private void setAllLayersToUneditable(PlugInContext context) {
+ for (Object object :
context.getLayerNamePanel().getLayerManager().getLayerables(Layerable.class)) {
+ ((Layerable)object).setEditable(false);
+ }
+ }
+
@Override
public EnableCheck getEnableCheck() {
return EnableCheckFactory.getInstance()
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java
2016-10-09 16:47:12 UTC (rev 5065)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -65,12 +65,12 @@
public static final ImageIcon ICON = IconLoader.icon("edit.gif");
public EditablePlugIn(EditingPlugIn editingPlugIn) {
+ super();
this.editingPlugIn = editingPlugIn;
}
public EditablePlugIn() {
- super();
- this.editingPlugIn = EditingPlugIn.getInstance();
+ this(EditingPlugIn.getInstance());
}
public boolean execute(PlugInContext context) throws Exception {
@@ -83,6 +83,7 @@
for (Layerable layerable : layers) {
if (isWritable(layerable)) {
+ if (makeEditable) setAllLayersToUneditable(context);
layerable.setEditable(makeEditable);
} else {
String message = "<html><br>" + I18N.getMessage(CONFIRMATION_1,
"<i>'"+layerable.getName()+"'</i>");
@@ -103,6 +104,7 @@
});
okCancelPanel.setVisible(true);
if (okCancelPanel.wasOKPressed()) {
+ if (makeEditable) setAllLayersToUneditable(context);
layerable.setEditable(makeEditable);
if (layerable instanceof Layer) {
((Layer)layerable).setDataSourceQuery(null);
@@ -166,6 +168,12 @@
return mec;
}
+ private void setAllLayersToUneditable(PlugInContext context) {
+ for (Object object :
context.getLayerNamePanel().getLayerManager().getLayerables(Layerable.class)) {
+ ((Layerable)object).setEditable(false);
+ }
+ }
+
private static Layerable[] getSelectedLayerables(WorkbenchContext wbc) {
Layerable[] layers = new Layerable[] {};
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/OptionsPlugIn.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/OptionsPlugIn.java
2016-10-09 16:47:12 UTC (rev 5065)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/OptionsPlugIn.java
2016-10-09 17:11:42 UTC (rev 5066)
@@ -81,8 +81,7 @@
dialog(context).addTab(
I18N.get("ui.plugin.OptionsPlugIn.view-edit"),
new EditOptionsPanel(context.getWorkbenchContext().getWorkbench()
- .getBlackboard(), context.getWorkbenchContext().getWorkbench()
- .getFrame().getDesktopPane()));
+ .getBlackboard()));
dialog(context).addTab(
I18N.get("ui.plugin.OptionsPlugIn.snap-vertices-tools"),
GUIUtil.resize(IconLoader.icon("QuickSnap.gif"), 16),
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel