Issue #663 Fixed key binding issue, added cursor icon change when tool is selected
Change-Id: I9040da01355e64208ef54ccc6d8452ab57c9d3c5 Former-commit-id:04c9f3a1c8
[formerly8c9c33ef9f
] [formerly2058b7f0ea
[formerly 5c240b5224ee93a36c5e05ddb15b373645222081]] Former-commit-id:2058b7f0ea
Former-commit-id:11cb7bafb0
This commit is contained in:
parent
e4350ca0ae
commit
ea408d8f42
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.events.SelectionAdapter;
|
||||
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.ToolItem;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.core.ContextManager;
|
||||
|
@ -116,6 +120,36 @@ public class CollaborationDrawingToolbar extends DrawingToolbar implements
|
|||
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)
|
||||
*
|
||||
|
|
|
@ -22,10 +22,13 @@ package com.raytheon.uf.viz.drawing;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
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.drawing.DrawingToolLayer.DrawMode;
|
||||
import com.raytheon.viz.ui.input.InputAdapter;
|
||||
|
@ -58,6 +61,8 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
|
||||
private Cursor normal;
|
||||
|
||||
private boolean handlingInput = false;
|
||||
|
||||
protected IDisplayPaneContainer container;
|
||||
|
||||
private Shell currentShell = null;
|
||||
|
@ -65,7 +70,11 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
public DrawingToolUIManager(DrawingToolLayer drawingLayer,
|
||||
IDisplayPaneContainer container) {
|
||||
this.drawingLayer = drawingLayer;
|
||||
this.container = container;
|
||||
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Create erasor cursor
|
||||
ImageData data = IconUtil.getImageDescriptor(
|
||||
Activator.getDefault().getBundle(), "eraser_box.gif")
|
||||
|
@ -74,10 +83,17 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
erasor = new Cursor(Display.getCurrent(), data, 8, 8);
|
||||
|
||||
// Create pencil cursor
|
||||
pencil = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
|
||||
data = IconUtil.getImageDescriptor(
|
||||
Activator.getDefault().getBundle(), "draw.gif")
|
||||
.getImageData();
|
||||
pencil = new Cursor(Display.getCurrent(), data, 1, 15);
|
||||
|
||||
this.container = container;
|
||||
container.registerMouseHandler(this);
|
||||
normal = Display.getCurrent().getSystemCursor(SWT.CURSOR_ARROW);
|
||||
|
||||
DrawingToolUIManager.this.container
|
||||
.registerMouseHandler(DrawingToolUIManager.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
@ -87,6 +103,48 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
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)
|
||||
*
|
||||
|
@ -96,15 +154,10 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
||||
if (mouseButton != 1 || drawingLayer.getDrawMode() == DrawMode.NONE
|
||||
|| currentShell != null) {
|
||||
|| handlingInput) {
|
||||
return false;
|
||||
}
|
||||
currentShell = Display.getCurrent().getActiveShell();
|
||||
if (drawingLayer.getDrawMode() == DrawMode.DRAW) {
|
||||
currentShell.setCursor(pencil);
|
||||
} else {
|
||||
currentShell.setCursor(erasor);
|
||||
}
|
||||
handlingInput = true;
|
||||
return handleMouseDownMove(x, y, mouseButton);
|
||||
}
|
||||
|
||||
|
@ -116,7 +169,7 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
*/
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||
if (currentShell == null) {
|
||||
if (handlingInput == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -135,18 +188,17 @@ public class DrawingToolUIManager extends InputAdapter {
|
|||
*/
|
||||
@Override
|
||||
public boolean handleMouseUp(int x, int y, int mouseButton) {
|
||||
if (currentShell == null) {
|
||||
if (handlingInput == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentShell.setCursor(normal);
|
||||
if (drawingLayer.getDrawMode() == DrawMode.DRAW) {
|
||||
drawingLayer.doneDrawing();
|
||||
} else {
|
||||
drawingLayer.doneErasing();
|
||||
}
|
||||
container.refresh();
|
||||
currentShell = null;
|
||||
handlingInput = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue