Revision: 6352
          http://sourceforge.net/p/jump-pilot/code/6352
Author:   ma15569
Date:     2020-07-16 10:55:56 +0000 (Thu, 16 Jul 2020)
Log Message:
-----------
Added option to open a feature InfoFrame when a new feature is created
workaround to Feature request #245 "Create form to edit attribute values"

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java   
2020-07-16 10:51:16 UTC (rev 6351)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/EditOptionsPanel.java   
2020-07-16 10:55:56 UTC (rev 6352)
@@ -34,6 +34,8 @@
 
 import java.awt.Color;
 import java.awt.GridBagLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 
 import javax.swing.BorderFactory;
 import javax.swing.JCheckBox;
@@ -53,140 +55,180 @@
  * [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
+ * [2016-10-09] Micha�l Michaud - add option to limit the number of editable
  * layers to one
- */
+ * [2020-06-16] Giuseppe Aruta - Feature request #245 Create form to edit 
attribute values 
+ * Added option to open Infoframe after digitalized a new feature
+ */ 
 
 public class EditOptionsPanel extends JPanel implements OptionsPanel {
 
-    private JPanel editPanel;
-    private JCheckBox preventEditsCheckBox;
-    private JCheckBox selectNewGeometryCheckBox;
-    private JCheckBox singleEditableLayerCheckBox;
+       private JPanel editPanel;
+       private JCheckBox preventEditsCheckBox;
+       private JCheckBox selectNewGeometryCheckBox;
+       private JCheckBox selectInfoNewGeometryCheckBox;
+       private JCheckBox singleEditableLayerCheckBox;
 
-    private JPanel layerToolTipPanel;
-    private Blackboard blackboard;
-    private JCheckBox tooltipCheckBox;
+       private JPanel layerToolTipPanel;
+       private Blackboard blackboard;
+       private JCheckBox tooltipCheckBox;
 
 
-    /** 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 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 editable layer number */
+       public static final String SELECT_INFO_GEOMETRY_KEY = 
ConfigTooltipPanel.class
+                       .getName() + " - SELECT_INFO_GEOMETRY";
 
-    /** Option de tooltip */
-    public static final String LAYER_TOOLTIPS_KEY = ConfigTooltipPanel.class
-            .getName() + " - LAYER_TOOLTIPS";
+       /** Option de editable layer number */
+       public static final String SINGLE_EDITABLE_LAYER_KEY = 
ConfigTooltipPanel.class
+                       .getName() + " - SINGLE_EDITABLE_LAYER";
 
-    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 SELECT_NEW_GEOMETRY_WARNING =
-            
I18N.get("ui.EditOptionsPanel.select-new-geometry-deselect-previous-selection");
 // Select the geometry after it has been drawn
-    public static final String SINGLE_EDITABLE_LAYER =
-            I18N.get("ui.EditOptionsPanel.single-editable-layer");
+       /** Option de tooltip */
+       public static final String LAYER_TOOLTIPS_KEY = ConfigTooltipPanel.class
+                       .getName() + " - LAYER_TOOLTIPS";
 
-    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");
+       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 SELECT_INFO_GEOMETRY 
="..."+I18N.get("ui.EditOptionsPanel.open.info.frame");
 
-    public EditOptionsPanel(final Blackboard blackboard) {
-        this.blackboard = blackboard;
-        this.setLayout(new GridBagLayout());
+       public static final String SELECT_NEW_GEOMETRY_WARNING =
+                       
I18N.get("ui.EditOptionsPanel.select-new-geometry-deselect-previous-selection");
 // Select the geometry after it has been drawn
+       public static final String SINGLE_EDITABLE_LAYER =
+                       I18N.get("ui.EditOptionsPanel.single-editable-layer");
 
-        // Add titled panels
-        FormUtils.addRowInGBL(this, 1, 0, getEditPanel());
-        FormUtils.addRowInGBL(this, 3, 0, getTooltipPanel());
-        FormUtils.addFiller(this, 4, 0);
+       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");
 
-        try {
-            init();
-        } catch (Exception e) {
-            Assert.shouldNeverReachHere(e.toString());
-        }
-    }
 
-    public void init() {
-        preventEditsCheckBox.setSelected(blackboard.get(
-                EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, false));
-        selectNewGeometryCheckBox.setSelected(blackboard.get(
-                SELECT_NEW_GEOMETRY_KEY, false));
-        singleEditableLayerCheckBox.setSelected(blackboard.get(
-                SINGLE_EDITABLE_LAYER_KEY, true));
-        tooltipCheckBox.setSelected(blackboard.get(
-                LAYER_TOOLTIPS_KEY, false));
+       public EditOptionsPanel(final Blackboard blackboard) {
+               this.blackboard = blackboard;
+               this.setLayout(new GridBagLayout());
 
-        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());
-    }
+               // Add titled panels
+               FormUtils.addRowInGBL(this, 1, 0, getEditPanel());
+               FormUtils.addRowInGBL(this, 3, 0, getTooltipPanel());
+               FormUtils.addFiller(this, 4, 0);
 
-    public String validateInput() {
-        return null;
-    }
+               try {
+                       init();
+               } catch (Exception e) {
+                       Assert.shouldNeverReachHere(e.toString());
+               }
 
-    public void okPressed() {
-        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());
-    }
+               selectNewGeometryCheckBox.addItemListener(new ItemListener() {
+                       @Override
+                       public void itemStateChanged(ItemEvent e) {
+                               if(e.getStateChange() == ItemEvent.SELECTED) 
{//checkbox has been selected
+                                       
selectInfoNewGeometryCheckBox.setEnabled(true);
+                               } else {//checkbox has been deselected
+                                       
selectInfoNewGeometryCheckBox.setSelected(false);
+                                       
selectInfoNewGeometryCheckBox.setEnabled(false);
+                               };
+                       }
+               });
+       }
 
+       @Override
+       public void init() {
+               preventEditsCheckBox.setSelected(blackboard.get(
+                               EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, 
false));
+               selectNewGeometryCheckBox.setSelected(blackboard.get(
+                               SELECT_NEW_GEOMETRY_KEY, false));
+               selectInfoNewGeometryCheckBox.setSelected(blackboard.get(
+                               SELECT_INFO_GEOMETRY_KEY, false));
+               selectInfoNewGeometryCheckBox.setEnabled(blackboard.get(
+                               SELECT_NEW_GEOMETRY_KEY, true));
 
-    private JPanel getEditPanel() {
-        if (editPanel == null) {
-            editPanel = new JPanel(new GridBagLayout());
-            TitledBorder titledBorder2 = new TitledBorder(
-                    BorderFactory.createEtchedBorder(
-                            Color.white, new Color(148, 145, 140)
-                    ),
-                    EDIT_PANEL);
-            editPanel.setBorder(titledBorder2);
 
-            preventEditsCheckBox = new JCheckBox(PREVENT_INVALID_EDIT);
-            selectNewGeometryCheckBox = new JCheckBox(SELECT_NEW_GEOMETRY);
-            
selectNewGeometryCheckBox.setToolTipText(SELECT_NEW_GEOMETRY_WARNING);
-            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 editPanel;
-    }
+               singleEditableLayerCheckBox.setSelected(blackboard.get(
+                               SINGLE_EDITABLE_LAYER_KEY, true));
+               tooltipCheckBox.setSelected(blackboard.get(
+                               LAYER_TOOLTIPS_KEY, false));
 
-    /**
-     *
-     * @return
-     */
-    private JPanel getTooltipPanel() {
-        if (layerToolTipPanel == null) {
+               blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, 
preventEditsCheckBox.isSelected());
+               blackboard.put(SELECT_NEW_GEOMETRY_KEY, 
selectNewGeometryCheckBox.isSelected());
+               blackboard.put(SELECT_INFO_GEOMETRY_KEY, 
selectInfoNewGeometryCheckBox.isSelected());
+               blackboard.put(SINGLE_EDITABLE_LAYER_KEY, 
singleEditableLayerCheckBox.isSelected());
+               blackboard.put(LAYER_TOOLTIPS_KEY, 
tooltipCheckBox.isSelected());
+       }
 
-            layerToolTipPanel = new JPanel(new GridBagLayout());
-            TitledBorder titledBorder1 = new TitledBorder(
-                    BorderFactory.createEtchedBorder(
-                            Color.white, new Color(148, 145, 140)
-                    ),
-                    CONFIGURE_LAYERTREE_PANEL);
-            layerToolTipPanel.setBorder(titledBorder1);
+       @Override
+       public String validateInput() {
+               return null;
+       }
 
-            tooltipCheckBox = new JCheckBox(LAYER_TOOLTIP);
+       @Override
+       public void okPressed() {
+               blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
+                               preventEditsCheckBox.isSelected());
+               blackboard.put(SELECT_NEW_GEOMETRY_KEY,
+                               selectNewGeometryCheckBox.isSelected());
 
-            FormUtils.addRowInGBL(layerToolTipPanel, 0, 0, tooltipCheckBox);
-        }
-        return layerToolTipPanel;
-    }
+               blackboard.put(SELECT_INFO_GEOMETRY_KEY,
+                               selectInfoNewGeometryCheckBox.isSelected());
+               blackboard.put(SINGLE_EDITABLE_LAYER_KEY,
+                               singleEditableLayerCheckBox.isSelected());
+               blackboard.put(LAYER_TOOLTIPS_KEY,
+                               tooltipCheckBox.isSelected());
+       }
+
+
+       private JPanel getEditPanel() {
+               if (editPanel == null) {
+                       editPanel = new JPanel(new GridBagLayout());
+                       TitledBorder titledBorder2 = new TitledBorder(
+                                       BorderFactory.createEtchedBorder(
+                                                       Color.white, new 
Color(148, 145, 140)
+                                                       ),
+                                       EDIT_PANEL);
+                       editPanel.setBorder(titledBorder2);
+
+                       preventEditsCheckBox = new 
JCheckBox(PREVENT_INVALID_EDIT);
+                       selectNewGeometryCheckBox = new 
JCheckBox(SELECT_NEW_GEOMETRY);
+                       selectInfoNewGeometryCheckBox= new 
JCheckBox(SELECT_INFO_GEOMETRY);
+                       
selectInfoNewGeometryCheckBox.setEnabled(selectNewGeometryCheckBox.isSelected());
+
+                       
selectNewGeometryCheckBox.setToolTipText(SELECT_NEW_GEOMETRY_WARNING);
+                       singleEditableLayerCheckBox = new 
JCheckBox(SINGLE_EDITABLE_LAYER);
+
+                       FormUtils.addRowInGBL(editPanel, 0, 0, 
preventEditsCheckBox);
+                       FormUtils.addRowInGBL(editPanel, 1, 0, 
selectNewGeometryCheckBox);
+                       FormUtils.addRowInGBL(editPanel, 2, 0, 
selectInfoNewGeometryCheckBox);
+                       FormUtils.addRowInGBL(editPanel, 3, 0, 
singleEditableLayerCheckBox);
+               }
+               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;
+       }
 }



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to