Issue #429 fix proxied handler error, added toolbar for drawing tool

Former-commit-id: 89b9d575ff [formerly 057ffedb23] [formerly 89d401550a] [formerly 89b9d575ff [formerly 057ffedb23] [formerly 89d401550a] [formerly 9beef61917 [formerly 89d401550a [formerly 5728e687e79a54da8313b444a48db18c6671e79e]]]]
Former-commit-id: 9beef61917
Former-commit-id: 910a9447a4 [formerly fdde739063] [formerly c1a428c83f39039d8711dd56a44b9155703dfd85 [formerly 18291c4101]]
Former-commit-id: 00e43c76e035b2e3325ca04d238f0e0942201dcf [formerly b07f565ab9]
Former-commit-id: 9f25ebc259
This commit is contained in:
Matt Nash 2012-03-29 12:24:27 -05:00
parent 0fa5ab5052
commit d895713084
16 changed files with 389 additions and 214 deletions

View file

@ -15,8 +15,10 @@ Require-Bundle: com.raytheon.viz.ui,
org.eclipse.ecf;bundle-version="3.1.0",
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4",
com.google.guava;bundle-version="1.0.0"
com.google.guava;bundle-version="1.0.0",
com.raytheon.viz.core;bundle-version="1.12.1174"
Import-Package: com.raytheon.uf.common.status,
com.raytheon.uf.viz.core.maps.display,
com.raytheon.uf.viz.core.maps.rsc
com.raytheon.uf.viz.core.maps.rsc,
com.raytheon.uf.viz.drawing
Bundle-ActivationPolicy: lazy

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 687 B

View file

@ -130,14 +130,6 @@
style="push">
</command>
</menuContribution>
<menuContribution
locationURI="toolbar:d2d-2?after=tools.toolbar">
<command
commandId="com.raytheon.uf.viz.drawing.pathdrawingtool"
style="push"
label="Draw">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.editors">

View file

@ -25,6 +25,10 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
@ -85,6 +89,8 @@ import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.drawing.PathToolbar;
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
/**
@ -167,6 +173,7 @@ public class CollaborationGroupView extends ViewPart {
createActions();
createToolbar();
createMenubar();
createUsersTree(parent);
addDoubleClickListeners();
createContextMenu();
@ -175,6 +182,22 @@ public class CollaborationGroupView extends ViewPart {
} else {
usersTreeViewer.getTree().setEnabled(false);
}
Job job = new Job("Opening draw toolbar") {
@Override
protected IStatus run(IProgressMonitor monitor) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
final PathToolbar toolbar = PathToolbar.getToolbar();
toolbar.open();
}
});
return Status.OK_STATUS;
}
};
job.schedule();
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

View file

Before

Width:  |  Height:  |  Size: 88 B

After

Width:  |  Height:  |  Size: 88 B

View file

@ -22,10 +22,6 @@
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
id="com.raytheon.uf.viz.drawing.pathdrawingtool"
name="Draw Path...">
</command>
<command
id="com.raytheon.uf.viz.drawing.undoadd"
name="Undo Add">
@ -37,10 +33,6 @@
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.raytheon.uf.viz.drawing.tools.PathDrawingTool"
commandId="com.raytheon.uf.viz.drawing.pathdrawingtool">
</handler>
<handler
class="com.raytheon.uf.viz.drawing.actions.UndoAddAction"
commandId="com.raytheon.uf.viz.drawing.undoadd">
@ -50,7 +42,7 @@
commandId="com.raytheon.uf.viz.drawing.redoadd">
</handler>
</extension>
<extension
<!--extension
point="org.eclipse.ui.bindings">
<scheme
id="com.raytheon.uf.viz.drawing.scheme"
@ -68,5 +60,5 @@
schemeId="com.raytheon.uf.viz.drawing.scheme"
sequence="M1+Y">
</key>
</extension>
</extension-->
</plugin>

View file

@ -23,6 +23,7 @@ package com.raytheon.uf.viz.drawing;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -72,10 +73,9 @@ public abstract class AbstractDrawingTool extends AbstractModalTool {
}
if (theDrawingLayer == null) {
PathDrawingResourceData resourceData = new PathDrawingResourceData();
try {
theDrawingLayer = resourceData.construct(new LoadProperties(),
desc);
theDrawingLayer = (DrawingLayer) constructData().construct(
new LoadProperties(), desc);
} catch (VizException e1) {
e1.printStackTrace();
}
@ -110,4 +110,5 @@ public abstract class AbstractDrawingTool extends AbstractModalTool {
*/
public abstract IInputHandler getMouseHandler();
protected abstract AbstractResourceData constructData();
}

View file

@ -26,6 +26,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.graphics.RGB;
@ -42,7 +43,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.drawing.actions.ClearDrawingAction;
import com.raytheon.uf.viz.drawing.actions.EraseObjectsAction;
import com.raytheon.uf.viz.drawing.actions.RedoAddAction;
import com.raytheon.uf.viz.drawing.actions.UndoAddAction;
import com.raytheon.uf.viz.drawing.tools.ToolsUtils;
@ -50,6 +50,7 @@ import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.geom.Point;
/**
@ -70,14 +71,14 @@ public class DrawingLayer extends
protected IWireframeShape tempWireframeShape;
protected IWireframeShape eraseWireframeShape;
protected IGraphicsTarget target;
protected boolean needsRefresh = true;
protected boolean erase = false;
private EraseObjectsAction eAction = null;
public DrawingLayer(PathDrawingResourceData data, LoadProperties props) {
super(data, props);
}
@ -123,6 +124,10 @@ public class DrawingLayer extends
getDescriptor());
needsRefresh = false;
}
if (eraseWireframeShape == null) {
eraseWireframeShape = target.createWireframeShape(true,
getDescriptor());
}
RGB rgb = getCapability(ColorableCapability.class).getColor();
@ -186,12 +191,39 @@ public class DrawingLayer extends
Point point = factory
.createPoint(line.getCoordinates()[line
.getNumPoints() - 1]);
if (point.buffer(8).intersects(geom)) {
Geometry intersection = point.intersection(geom);
Geometry finalGeom = geom.difference(intersection);
deletedShapes.put(geom, wireframeShapes.remove(geom));
this.tempGeometries.add(finalGeom);
System.out.println("removing things");
Geometry intersection = point.buffer(8).intersection(geom);
Geometry finalGeom = geom.difference(intersection);
deletedShapes.put(geom, wireframeShapes.remove(geom));
if (finalGeom instanceof MultiLineString) {
MultiLineString mLineString = (MultiLineString) finalGeom;
for (int j = 0; j < mLineString.getNumGeometries(); j++) {
LineString lineString = (LineString) mLineString
.getGeometryN(j);
int pts = lineString.getNumPoints();
for (int i = 1; i < pts; i++) {
double[] p1 = this.descriptor
.worldToPixel(new double[] {
lineString.getPointN(i - 1)
.getX(),
lineString.getPointN(i - 1)
.getY() });
double[] p2 = this.descriptor
.worldToPixel(new double[] {
lineString.getPointN(i).getX(),
lineString.getPointN(i).getY() });
double[][] coords = new double[2][2];
coords[0][0] = p1[0];
coords[0][1] = p1[1];
coords[1][0] = p2[0];
coords[1][1] = p2[1];
System.out.println(i);
eraseWireframeShape.addLineSegment(coords);
}
this.wireframeShapes.put(lineString,
eraseWireframeShape);
issueRefresh();
}
}
}
}
@ -201,6 +233,7 @@ public class DrawingLayer extends
public void reset() {
resetTemp();
disposeInternal();
issueRefresh();
}
public void resetTemp() {
@ -264,25 +297,24 @@ public class DrawingLayer extends
public void addContextMenuItems(IMenuManager menuManager, int x, int y) {
ResourcePair pair = new ResourcePair();
pair.setResource(this);
if (eAction == null) {
eAction = new EraseObjectsAction();
eAction.setSelectedRsc(pair);
} else {
eAction.setSelectedRsc(pair);
}
ClearDrawingAction cAction = new ClearDrawingAction();
cAction.setSelectedRsc(pair);
cAction.setImageDescriptor(ToolsUtils.getImageDescriptor("remove.gif"));
UndoAddAction uAction = new UndoAddAction();
uAction.setSelectedRsc(pair);
uAction.setImageDescriptor(ToolsUtils.getImageDescriptor("undo.gif"));
RedoAddAction rAction = new RedoAddAction();
rAction.setSelectedRsc(pair);
rAction.setImageDescriptor(ToolsUtils.getImageDescriptor("redo.gif"));
menuManager.add(eAction);
menuManager.add(cAction);
menuManager.add(uAction);
menuManager.add(rAction);
Action action = new Action("Draw Toolbar") {
public void run() {
PathToolbar.getToolbar().open();
};
};
// ClearDrawingAction cAction = new ClearDrawingAction();
// cAction.setSelectedRsc(pair);
// cAction.setImageDescriptor(ToolsUtils.getImageDescriptor("remove.gif"));
// UndoAddAction uAction = new UndoAddAction();
// uAction.setSelectedRsc(pair);
// uAction.setImageDescriptor(ToolsUtils.getImageDescriptor("undo.gif"));
// RedoAddAction rAction = new RedoAddAction();
// rAction.setSelectedRsc(pair);
// rAction.setImageDescriptor(ToolsUtils.getImageDescriptor("redo.gif"));
// menuManager.add(cAction);
// menuManager.add(uAction);
// menuManager.add(rAction);
menuManager.add(action);
}
/**

View file

@ -19,9 +19,36 @@
**/
package com.raytheon.uf.viz.drawing;
import org.eclipse.swt.widgets.Shell;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.drawing.actions.ClearDrawingAction;
import com.raytheon.uf.viz.drawing.actions.EraseObjectsAction;
import com.raytheon.uf.viz.drawing.actions.RedoAddAction;
import com.raytheon.uf.viz.drawing.actions.UndoAddAction;
import com.raytheon.uf.viz.drawing.tools.PathDrawingTool;
import com.raytheon.uf.viz.drawing.tools.ToolsUtils;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.editor.ISelectedPanesChangedListener;
import com.raytheon.viz.ui.editor.VizMultiPaneEditor;
/**
* TODO Add Description
@ -40,23 +67,40 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
* @version 1.0
*/
public class PathToolbar extends CaveSWTDialogBase {
public class PathToolbar extends CaveSWTDialog implements
ISelectedPanesChangedListener {
private static PathToolbar toolbar;
private Map<AbstractEditor, ResourcePair> layers;
private ToolItem drawItem;
private ToolItem eraserItem;
public static PathToolbar getToolbar() {
if (toolbar == null) {
toolbar = new PathToolbar(Display.getCurrent().getActiveShell());
}
return toolbar;
}
/**
* @param parentShell
* @param swtStyle
*/
protected PathToolbar(Shell parentShell, int swtStyle) {
super(parentShell, swtStyle);
// TODO Auto-generated constructor stub
protected PathToolbar(Shell parentShell) {
super(parentShell, SWT.DIALOG_TRIM | CAVE.DO_NOT_BLOCK);
layers = new HashMap<AbstractEditor, ResourcePair>();
setText("Drawing");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
PathToolbar bar = new PathToolbar(new Shell());
bar.open();
}
/*
@ -68,6 +112,158 @@ public class PathToolbar extends CaveSWTDialogBase {
*/
@Override
protected void initializeComponents(Shell shell) {
Composite comp = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout();
comp.setLayout(layout);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
comp.setLayoutData(data);
layout.marginHeight = 0;
layout.marginWidth = 0;
ToolBar toolbar = new ToolBar(comp, SWT.FLAT);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
data = new GridData(SWT.FILL, SWT.FILL, true, true);
toolbar.setLayout(layout);
toolbar.setLayoutData(data);
drawItem = new ToolItem(toolbar, SWT.NONE);
drawItem.setText("Draw");
drawItem.setImage(ToolsUtils.getImageDescriptor("draw.gif")
.createImage());
drawItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
IDescriptor desc = editor.getActiveDisplayPane()
.getDescriptor();
if (layers.containsKey(editor)) {
if (((DrawingLayer) layers.get(editor).getResource()).erase) {
((DrawingLayer) layers.get(editor).getResource())
.setErase(false);
eraserItem.setSelection(false);
}
}
PathDrawingTool tool = new PathDrawingTool();
tool.activate();
// ((VizMultiPaneEditor) editor)
// .addSelectedPaneChangedListener(PathToolbar
// .getToolbar());
for (ResourcePair pair : desc.getResourceList()) {
if (pair.getResource() instanceof DrawingLayer) {
layers.put(editor, pair);
// drawItem.setEnabled(false);
}
}
}
});
ToolItem undoItem = new ToolItem(toolbar, SWT.FLAT);
undoItem.setText("Undo");
undoItem.setImage(ToolsUtils.getImageDescriptor("undo.gif")
.createImage());
undoItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UndoAddAction action = new UndoAddAction();
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
if (layers.get(editor) != null) {
executeAction(action);
}
}
});
ToolItem redoItem = new ToolItem(toolbar, SWT.FLAT);
redoItem.setText("Redo");
redoItem.setImage(ToolsUtils.getImageDescriptor("redo.gif")
.createImage());
redoItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RedoAddAction action = new RedoAddAction();
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
if (layers.get(editor) != null) {
executeAction(action);
}
}
});
ToolItem clearItem = new ToolItem(toolbar, SWT.FLAT);
clearItem.setText("Clear");
clearItem.setImage(ToolsUtils.getImageDescriptor("remove.gif")
.createImage());
clearItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ClearDrawingAction action = new ClearDrawingAction();
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
if (layers.get(editor) != null) {
executeAction(action);
}
}
});
eraserItem = new ToolItem(toolbar, SWT.CHECK);
eraserItem.setText("Eraser");
eraserItem.setImage(ToolsUtils.getImageDescriptor("eraser.png")
.createImage());
eraserItem.setEnabled(false);
eraserItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EraseObjectsAction action = new EraseObjectsAction();
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
if (layers.get(editor) != null) {
executeAction(action);
}
}
});
}
private void executeAction(AbstractHandler action) {
try {
action.execute(null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
/**
*
*/
private void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.editor.ISelectedPanesChangedListener#selectedPanesChanged
* (java.lang.String, com.raytheon.uf.viz.core.IDisplayPane[])
*/
@Override
public void selectedPanesChanged(String id, IDisplayPane[] pane) {
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
IDescriptor desc = editor.getActiveDisplayPane().getDescriptor();
((VizMultiPaneEditor) editor)
.addSelectedPaneChangedListener(PathToolbar.getToolbar());
boolean hasLayer = false;
for (ResourcePair pair : desc.getResourceList()) {
if (pair.getResource() instanceof DrawingLayer) {
hasLayer = true;
break;
}
}
// drawItem.setEnabled(hasLayer);
}
}

View file

@ -19,8 +19,15 @@
**/
package com.raytheon.uf.viz.drawing.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* TODO Add Description
@ -39,36 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0
*/
public class ClearDrawingAction extends AbstractRightClickAction {
public class ClearDrawingAction extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
if (getSelectedRsc() != null) {
((DrawingLayer) getSelectedRsc()).reset();
public Object execute(ExecutionEvent event) throws ExecutionException {
ResourceList list = ((AbstractEditor) EditorUtil
.getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource()).reset();
break;
}
}
return null;
}
@Override
public String getText() {
return "Clear Drawing";
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.cmenu.AbstractRightClickAction#isHidden()
*/
@Override
public boolean isHidden() {
if (getSelectedRsc() instanceof DrawingLayer) {
return false;
} else {
return true;
}
}
}
}

View file

@ -19,10 +19,15 @@
**/
package com.raytheon.uf.viz.drawing.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* TODO Add Description
@ -41,35 +46,20 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0
*/
public class EraseObjectsAction extends AbstractRightClickAction {
/**
*
*/
public EraseObjectsAction() {
super("Eraser", IAction.AS_CHECK_BOX);
}
public class EraseObjectsAction extends AbstractHandler {
@Override
public void run() {
((DrawingLayer) getSelectedRsc())
.setErase(!((DrawingLayer) getSelectedRsc()).isErase());
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.cmenu.AbstractRightClickAction#isHidden()
*/
@Override
public boolean isHidden() {
if (true) {
return true;
}
if (getSelectedRsc() instanceof DrawingLayer) {
return false;
} else {
return true;
public Object execute(ExecutionEvent event) throws ExecutionException {
ResourceList list = ((AbstractEditor) EditorUtil
.getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource())
.setErase(((DrawingLayer) pair.getResource()).isErase());
break;
}
}
return null;
}
}
}

View file

@ -19,8 +19,15 @@
**/
package com.raytheon.uf.viz.drawing.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* TODO Add Description
@ -39,43 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0
*/
public class RedoAddAction extends AbstractRightClickAction {
public class RedoAddAction extends AbstractHandler {
@Override
public void run() {
((DrawingLayer) getSelectedRsc()).redoAdd();
}
@Override
public boolean isHidden() {
if (getSelectedRsc() instanceof DrawingLayer) {
return false;
} else {
return true;
public Object execute(ExecutionEvent event) throws ExecutionException {
ResourceList list = ((AbstractEditor) EditorUtil
.getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource()).redoAdd();
break;
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#isEnabled()
*/
@Override
public boolean isEnabled() {
if (!((DrawingLayer) getSelectedRsc()).getDeletedShapes().isEmpty()) {
return true;
} else {
return false;
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#getText()
*/
@Override
public String getText() {
return "Redo Draw";
return null;
}
}

View file

@ -19,8 +19,15 @@
**/
package com.raytheon.uf.viz.drawing.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* TODO Add Description
@ -39,43 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0
*/
public class UndoAddAction extends AbstractRightClickAction {
public class UndoAddAction extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
((DrawingLayer) getSelectedRsc()).undoAdd();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#isEnabled()
*/
@Override
public boolean isEnabled() {
if (!((DrawingLayer) getSelectedRsc()).getWireframeShapes().isEmpty()) {
return true;
} else {
return false;
}
}
@Override
public String getText() {
return "Undo Draw";
}
@Override
public boolean isHidden() {
if (getSelectedRsc() instanceof DrawingLayer) {
return false;
} else {
return true;
public Object execute(ExecutionEvent event) throws ExecutionException {
ResourceList list = ((AbstractEditor) EditorUtil
.getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource()).undoAdd();
break;
}
}
return null;
}
}

View file

@ -25,11 +25,15 @@ import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.drawing.AbstractDrawingTool;
import com.raytheon.uf.viz.drawing.PathDrawingResourceData;
import com.raytheon.viz.ui.input.InputAdapter;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
@ -46,6 +50,10 @@ public class PathDrawingTool extends AbstractDrawingTool {
/** The mouse handler */
protected IInputHandler theHandler;
public AbstractResourceData constructData() {
return new PathDrawingResourceData();
}
/*
* (non-Javadoc)
*
@ -80,12 +88,16 @@ public class PathDrawingTool extends AbstractDrawingTool {
Cursor cursor = null;
if (theDrawingLayer.isErase()) {
ImageData data = ToolsUtils.getImageDescriptor("eraser.gif")
.getImageData();
ImageData data = ToolsUtils
.getImageDescriptor("eraser_box.gif").getImageData();
data.alpha = 255;
cursor = new Cursor(Display.getCurrent(), data, 8, 8);
} else {
cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
Image image = new Image(cursor.getDevice(), 16, 16);
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };
loader.save("/home/mnash/Desktop/hand.png", SWT.IMAGE_PNG);
}
Display.getCurrent().getActiveShell().setCursor(cursor);
@ -158,27 +170,6 @@ public class PathDrawingTool extends AbstractDrawingTool {
if (!theDrawingLayer.isErase()) {
theDrawingLayer.addLine(ls, null);
}
// TODO take this and send the coordinates
// TransferLine object = new TransferLine();
// object.setCoordinates(ls.getCoordinates());
// object.setShape(theDrawingLayer.getTempWireframeShape());
// object.setColor(theDrawingLayer.getCapability(
// ColorableCapability.class).getColorAsString());
// try {
// // test writing out to a file for object size
// UUID temp = UUID.randomUUID();
// JAXBContext context = SerializationUtil.getJaxbContext();
// Marshaller marshaller = context.createMarshaller();
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
// false);
// marshaller.marshal(object, new File(
// "/home/mnash/Desktop/temp/jaxb" + temp));
// // SerializationUtil.jaxbMarshalToXmlFile(object,
// // "/home/mnash/Desktop/temp/jaxb" + temp);
// } catch (JAXBException e) {
// e.printStackTrace();
// }
}
return true;
}