Revision: 4589
http://sourceforge.net/p/jump-pilot/code/4589
Author: edso
Date: 2015-12-08 16:43:40 +0000 (Tue, 08 Dec 2015)
Log Message:
-----------
try to bugfix
"renaming layers or editing attributes in attribtab executes
plugin/cursortool erronously via shortcut"
and
"shortcuts Strg+X/C/V etc. not working when editing layer names in
TreeLayerNamePanel"
Modified Paths:
--------------
core/trunk/ChangeLog
core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerViewPanel.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/AbstractCursorTool.java
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/MultiClickTool.java
Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog 2015-12-08 16:26:31 UTC (rev 4588)
+++ core/trunk/ChangeLog 2015-12-08 16:43:40 UTC (rev 4589)
@@ -1,5 +1,10 @@
# for display continuity sake please use 2 spaces instead of tabs
+2015-12-08 ede
+ * bugfix "renaming layers or editing attributes in attribtab executes
+ plugin/cursortool erronously via shortcut" and "shortcuts Strg+X/C/V etc.
+ not working when editing layer names in TreeLayerNamePanel"
+
2015-12-06 mmichaud <[email protected]>
* Improved CutFeatureTool
* add MakeValidPlugIn in Tools>Analysis to repair invalid geometries
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerViewPanel.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerViewPanel.java
2015-12-08 16:26:31 UTC (rev 4588)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerViewPanel.java
2015-12-08 16:43:40 UTC (rev 4589)
@@ -190,26 +190,30 @@
});
this.setLayout(borderLayout1);
+ final LayerViewPanel lvp = this;
addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
- // Re-activate WorkbenchFrame. Otherwise, user may try
- // entering
- // a quasi-mode by pressing a modifier key -- nothing will
- // happen because the
- // WorkbenchFrame does not have focus. [Jon Aquino]
- // JavaDoc for #toFront says some platforms will not
- // activate the window.
- // So use #requestFocus instead. [Jon Aquino 12/9/2003]
- WorkbenchFrame workbenchFrame = getWorkBenchFrame();
- // [mmichaud 2012-02-24] get rid of the focus problem between
- // OpenJUMP and BeanshellEditor (bug #3487686)
- Window focusedWindow = KeyboardFocusManager
- .getCurrentKeyboardFocusManager().getFocusedWindow();
- if (focusedWindow != workbenchFrame)
- return;
- if (workbenchFrame != null && !workbenchFrame.isActive()) {
- workbenchFrame.requestFocus();
- }
+ // cursor tools and other shortcutables depend
+ // on properly focussed ui components
+ lvp.requestFocusInWindow();
+// // Re-activate WorkbenchFrame. Otherwise, user may try
+// // entering
+// // a quasi-mode by pressing a modifier key -- nothing will
+// // happen because the
+// // WorkbenchFrame does not have focus. [Jon Aquino]
+// // JavaDoc for #toFront says some platforms will not
+// // activate the window.
+// // So use #requestFocus instead. [Jon Aquino 12/9/2003]
+// WorkbenchFrame workbenchFrame = getWorkBenchFrame();
+// // [mmichaud 2012-02-24] get rid of the focus problem between
+// // OpenJUMP and BeanshellEditor (bug #3487686)
+// Window focusedWindow = KeyboardFocusManager
+// .getCurrentKeyboardFocusManager().getFocusedWindow();
+// if (focusedWindow != workbenchFrame)
+// return;
+// if (workbenchFrame != null && !workbenchFrame.isActive()) {
+// workbenchFrame.requestFocus();
+// }
}
});
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java
2015-12-08 16:26:31 UTC (rev 4588)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java
2015-12-08 16:43:40 UTC (rev 4589)
@@ -485,40 +485,49 @@
Component c = KeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusOwner();
// traverse through parents, see if we are in a valid one
- boolean filter = false;
+ boolean valid = false;
while (c != null) {
- // System.out.println(c);
+ //System.out.println(c.getClass());
- // ignore statuspanel, copy/paste is available via
textfield
- // there
+ // ignore statuspanel,
+ // copy/paste is available via textfield's own keyboard
actions
if (c.equals(statusPanel)) {
break;
}
+ // ignore LayerTree, we have currently no plugin w/
shortcuts doing
+ // anything w/ it, preserving layer name editing shortcuts
this way
+ if (c instanceof TreeLayerNamePanel) {
+ break;
+ }
+
if (c instanceof TaskFrame
|| (c instanceof ToolboxDialog && c
.equals(EditingPlugIn.getInstance()
.getToolbox()))
|| c instanceof WorkbenchFrame) {
- filter = true;
+ valid = true;
break;
}
// we treat windows and jinternalframes as our ultimate
- // parent
- // else pretty much everything would end up with
- // WorkbenchFrame
+ // parent, as pretty much everything would end up with
+ // WorkbenchFrame as parent in the end
if (c instanceof Window || c instanceof JInternalFrame)
break;
c = c.getParent();
}
- // if we are not in one of the containers above we do not use
- // global shortcuts
- if (!filter)
- return false; // nothing dispatched
+ // if we are not in one of the containers above
+ // we do not use global shortcuts
+ if (!valid) {
+ return false; // nothing dispatched
+ }
+ // TODO: eventually the whole filtering above should be
+ // moved into ShortcutPluginExecuteKeyListener where plugins
+ // define focussed ui components they feel responsible for
switch (e.getID()) {
case KeyEvent.KEY_PRESSED:
shortcutListener.keyPressed(e);
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/AbstractCursorTool.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/AbstractCursorTool.java
2015-12-08 16:26:31 UTC (rev 4588)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/AbstractCursorTool.java
2015-12-08 16:43:40 UTC (rev 4589)
@@ -33,10 +33,12 @@
import java.awt.BasicStroke;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
+import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Shape;
@@ -71,12 +73,14 @@
import com.vividsolutions.jump.workbench.ui.LayerViewPanelListener;
import com.vividsolutions.jump.workbench.ui.TaskFrame;
import com.vividsolutions.jump.workbench.ui.WorkbenchFrame;
+import com.vividsolutions.jump.workbench.ui.cursortool.editing.EditingPlugIn;
import com.vividsolutions.jump.workbench.ui.plugin.PersistentBlackboardPlugIn;
import com.vividsolutions.jump.workbench.ui.snap.SnapManager;
import com.vividsolutions.jump.workbench.ui.snap.SnapPolicy;
import com.vividsolutions.jump.workbench.ui.snap.SnapToFeaturesPolicy;
import com.vividsolutions.jump.workbench.ui.snap.SnapToGridPolicy;
import com.vividsolutions.jump.workbench.ui.snap.SnapToVerticesPolicy;
+import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxDialog;
/**
* A tool that draws an XOR visual indicator. Subclasses need not keep track of
@@ -97,11 +101,9 @@
private boolean snappingInitialized = false;
private boolean snappingAllowed = false;
+ private boolean controlPressed = false;
+ private boolean shiftPressed = false;
- private boolean controlPressed;
-
- private boolean shiftPressed;
-
private Color color = Color.red;
private boolean filling = false;
@@ -181,15 +183,25 @@
return snappingAllowed;
}
+ protected void setShiftPressed(boolean onoff){
+ shiftPressed = onoff;
+ }
+
protected boolean wasShiftPressed() {
- //System.out.println("act shift pressed");
- return shiftPressed;
- }
+ // System.out.println("act shift pressed");
+ return shiftPressed;
+ }
- protected boolean wasControlPressed() {
- return controlPressed;
- }
+ protected void setControlPressed(boolean onoff) {
+ // System.out.println("set ctrl "+onoff+" -> "+this);
+ controlPressed = onoff;
+ }
+ protected boolean wasControlPressed() {
+ // System.out.println("get ctrl "+controlPressed+" -> "+this);
+ return controlPressed;
+ }
+
/**
* The cursor will look best if the image is a 32 x 32 transparent GIF.
*/
@@ -698,6 +710,9 @@
}
public void keyPressed(KeyEvent e) {
+ if(!componentWithFocusIsHandledByCursorTools())
+ return;
+
//System.out.println(e);
if (snappingInitialized && isSpace(e) && !off) {
off = true;
@@ -709,6 +724,9 @@
}
public void keyReleased(KeyEvent e) {
+ if(!componentWithFocusIsHandledByCursorTools())
+ return;
+
//System.out.println(e);
if (snappingInitialized && isSpace(e) && off) {
off = false;
@@ -718,11 +736,11 @@
}
saveModifiers(e);
}
-
+
private void saveModifiers(KeyEvent e){
- shiftPressed = e.isShiftDown();
- controlPressed = e.isControlDown();
- //System.out.println("act "+shiftPressed+"/"+controlPressed);
+ setShiftPressed( e.isShiftDown() );
+ setControlPressed( e.isControlDown() );
+// System.out.println("act "+wasShiftPressed()+"/"+wasControlPressed());
}
private void showMsg(String msg) {
@@ -732,6 +750,32 @@
private boolean isSpace(KeyEvent e) {
return (e.getKeyCode() == KeyEvent.VK_SPACE);
}
+ };
- };
+ /**
+ * utility method to be used by cursor tools to determine if the
+ * ui component with focus falls into it's purview
+ *
+ * @return boolean
+ */
+ public static boolean componentWithFocusIsHandledByCursorTools(){
+ // only react if LayerView, one of it's subcomponents
+ // or the EditToolBox has got the focus
+ Component c = KeyboardFocusManager
+ .getCurrentKeyboardFocusManager().getFocusOwner();
+ // traverse through parents, see if we are in a valid one
+ boolean valid = false;
+ while (c != null) {
+ if (c instanceof LayerViewPanel
+ || (c instanceof ToolboxDialog && c.equals(EditingPlugIn
+ .getInstance().getToolbox()))) {
+ valid = true;
+ break;
+ }
+
+ c = c.getParent();
+ }
+
+ return valid;
+ }
}
\ No newline at end of file
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/MultiClickTool.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/MultiClickTool.java
2015-12-08 16:26:31 UTC (rev 4588)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/cursortool/MultiClickTool.java
2015-12-08 16:43:40 UTC (rev 4589)
@@ -47,7 +47,6 @@
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.util.Assert;
import com.vividsolutions.jump.workbench.ui.LayerViewPanel;
-import com.vividsolutions.jump.workbench.ui.WorkbenchFrame;
/**
* A VisualIndicatorTool that allows the user to draw shapes with multiple
@@ -277,6 +276,10 @@
}
public void keyReleased(KeyEvent e) {
+ // ignore events on invalid components
+ if(!componentWithFocusIsHandledByCursorTools())
+ return;
+
// erase segment by segment via BACKSPACE, eventually cancel drawing
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
if (coordinates.size() > 1){
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel