Issue #663 Fixed key binding issue, added cursor icon change when tool is selected
Change-Id: I9040da01355e64208ef54ccc6d8452ab57c9d3c5 Former-commit-id:8c9c33ef9f
[formerly8c9c33ef9f
[formerly 5c240b5224ee93a36c5e05ddb15b373645222081]] Former-commit-id:2058b7f0ea
Former-commit-id:11cb7bafb0
This commit is contained in:
parent
079a247ee5
commit
0222587b96
2 changed files with 109 additions and 23 deletions
|
@ -27,9 +27,13 @@ import java.util.Set;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.ToolBar;
|
import org.eclipse.swt.widgets.ToolBar;
|
||||||
import org.eclipse.swt.widgets.ToolItem;
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
import com.raytheon.uf.viz.core.ContextManager;
|
import com.raytheon.uf.viz.core.ContextManager;
|
||||||
|
@ -116,6 +120,36 @@ public class CollaborationDrawingToolbar extends DrawingToolbar implements
|
||||||
ContextManager.getInstance(window).activateContexts(this);
|
ContextManager.getInstance(window).activateContexts(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.drawing.DrawingToolbar#initializeComponents(org.eclipse
|
||||||
|
* .swt.widgets.Shell)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initializeComponents(Shell shell) {
|
||||||
|
super.initializeComponents(shell);
|
||||||
|
Listener activateDeactivate = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SWT.Activate:
|
||||||
|
ContextManager.getInstance(PlatformUI.getWorkbench())
|
||||||
|
.activateContexts(CollaborationDrawingToolbar.this);
|
||||||
|
break;
|
||||||
|
case SWT.Deactivate:
|
||||||
|
ContextManager.getInstance(PlatformUI.getWorkbench())
|
||||||
|
.deactivateContexts(
|
||||||
|
CollaborationDrawingToolbar.this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
shell.addListener(SWT.Activate, activateDeactivate);
|
||||||
|
shell.addListener(SWT.Deactivate, activateDeactivate);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,10 +22,13 @@ package com.raytheon.uf.viz.drawing;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Cursor;
|
import org.eclipse.swt.graphics.Cursor;
|
||||||
import org.eclipse.swt.graphics.ImageData;
|
import org.eclipse.swt.graphics.ImageData;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||||
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
|
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
|
||||||
import com.raytheon.viz.ui.input.InputAdapter;
|
import com.raytheon.viz.ui.input.InputAdapter;
|
||||||
|
@ -58,6 +61,8 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
|
|
||||||
private Cursor normal;
|
private Cursor normal;
|
||||||
|
|
||||||
|
private boolean handlingInput = false;
|
||||||
|
|
||||||
protected IDisplayPaneContainer container;
|
protected IDisplayPaneContainer container;
|
||||||
|
|
||||||
private Shell currentShell = null;
|
private Shell currentShell = null;
|
||||||
|
@ -65,19 +70,30 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
public DrawingToolUIManager(DrawingToolLayer drawingLayer,
|
public DrawingToolUIManager(DrawingToolLayer drawingLayer,
|
||||||
IDisplayPaneContainer container) {
|
IDisplayPaneContainer container) {
|
||||||
this.drawingLayer = drawingLayer;
|
this.drawingLayer = drawingLayer;
|
||||||
|
|
||||||
// Create erasor cursor
|
|
||||||
ImageData data = IconUtil.getImageDescriptor(
|
|
||||||
Activator.getDefault().getBundle(), "eraser_box.gif")
|
|
||||||
.getImageData();
|
|
||||||
data.alpha = 255;
|
|
||||||
erasor = new Cursor(Display.getCurrent(), data, 8, 8);
|
|
||||||
|
|
||||||
// Create pencil cursor
|
|
||||||
pencil = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
|
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
container.registerMouseHandler(this);
|
|
||||||
|
VizApp.runAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Create erasor cursor
|
||||||
|
ImageData data = IconUtil.getImageDescriptor(
|
||||||
|
Activator.getDefault().getBundle(), "eraser_box.gif")
|
||||||
|
.getImageData();
|
||||||
|
data.alpha = 255;
|
||||||
|
erasor = new Cursor(Display.getCurrent(), data, 8, 8);
|
||||||
|
|
||||||
|
// Create pencil cursor
|
||||||
|
data = IconUtil.getImageDescriptor(
|
||||||
|
Activator.getDefault().getBundle(), "draw.gif")
|
||||||
|
.getImageData();
|
||||||
|
pencil = new Cursor(Display.getCurrent(), data, 1, 15);
|
||||||
|
|
||||||
|
normal = Display.getCurrent().getSystemCursor(SWT.CURSOR_ARROW);
|
||||||
|
|
||||||
|
DrawingToolUIManager.this.container
|
||||||
|
.registerMouseHandler(DrawingToolUIManager.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -87,6 +103,48 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
container.unregisterMouseHandler(this);
|
container.unregisterMouseHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.input.InputAdapter#handleMouseExit(org.eclipse.swt
|
||||||
|
* .widgets.Event)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean handleMouseExit(Event event) {
|
||||||
|
if (!handlingInput) {
|
||||||
|
if (currentShell != null) {
|
||||||
|
currentShell.setCursor(normal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.input.InputAdapter#handleMouseEnter(org.eclipse.swt
|
||||||
|
* .widgets.Event)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean handleMouseEnter(Event event) {
|
||||||
|
if (handlingInput == false) {
|
||||||
|
currentShell = ((Control) event.widget).getShell();
|
||||||
|
switch (drawingLayer.getDrawMode()) {
|
||||||
|
case DRAW:
|
||||||
|
currentShell.setCursor(pencil);
|
||||||
|
break;
|
||||||
|
case ERASE:
|
||||||
|
currentShell.setCursor(erasor);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
currentShell.setCursor(normal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -96,15 +154,10 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
||||||
if (mouseButton != 1 || drawingLayer.getDrawMode() == DrawMode.NONE
|
if (mouseButton != 1 || drawingLayer.getDrawMode() == DrawMode.NONE
|
||||||
|| currentShell != null) {
|
|| handlingInput) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentShell = Display.getCurrent().getActiveShell();
|
handlingInput = true;
|
||||||
if (drawingLayer.getDrawMode() == DrawMode.DRAW) {
|
|
||||||
currentShell.setCursor(pencil);
|
|
||||||
} else {
|
|
||||||
currentShell.setCursor(erasor);
|
|
||||||
}
|
|
||||||
return handleMouseDownMove(x, y, mouseButton);
|
return handleMouseDownMove(x, y, mouseButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +169,7 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||||
if (currentShell == null) {
|
if (handlingInput == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,18 +188,17 @@ public class DrawingToolUIManager extends InputAdapter {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseUp(int x, int y, int mouseButton) {
|
public boolean handleMouseUp(int x, int y, int mouseButton) {
|
||||||
if (currentShell == null) {
|
if (handlingInput == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentShell.setCursor(normal);
|
|
||||||
if (drawingLayer.getDrawMode() == DrawMode.DRAW) {
|
if (drawingLayer.getDrawMode() == DrawMode.DRAW) {
|
||||||
drawingLayer.doneDrawing();
|
drawingLayer.doneDrawing();
|
||||||
} else {
|
} else {
|
||||||
drawingLayer.doneErasing();
|
drawingLayer.doneErasing();
|
||||||
}
|
}
|
||||||
container.refresh();
|
container.refresh();
|
||||||
currentShell = null;
|
handlingInput = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue