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

Former-commit-id: 9beef61917 [formerly 89d401550a [formerly 5728e687e79a54da8313b444a48db18c6671e79e]]
Former-commit-id: 89d401550a
Former-commit-id: 057ffedb23
This commit is contained in:
Matt Nash 2012-03-29 12:24:27 -05:00
parent a4965d6bf9
commit 89b9d575ff
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", org.eclipse.ecf;bundle-version="3.1.0",
com.raytheon.uf.viz.core;bundle-version="1.12.1174", com.raytheon.uf.viz.core;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4", 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, Import-Package: com.raytheon.uf.common.status,
com.raytheon.uf.viz.core.maps.display, 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 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"> style="push">
</command> </command>
</menuContribution> </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>
<extension <extension
point="org.eclipse.ui.editors"> point="org.eclipse.ui.editors">

View file

@ -25,6 +25,10 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.Action;
import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator; 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.CollaborationSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
import com.raytheon.uf.viz.collaboration.ui.session.SessionView; 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; import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
/** /**
@ -167,6 +173,7 @@ public class CollaborationGroupView extends ViewPart {
createActions(); createActions();
createToolbar(); createToolbar();
createMenubar(); createMenubar();
createUsersTree(parent); createUsersTree(parent);
addDoubleClickListeners(); addDoubleClickListeners();
createContextMenu(); createContextMenu();
@ -175,6 +182,22 @@ public class CollaborationGroupView extends ViewPart {
} else { } else {
usersTreeViewer.getTree().setEnabled(false); 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> <plugin>
<extension <extension
point="org.eclipse.ui.commands"> point="org.eclipse.ui.commands">
<command
id="com.raytheon.uf.viz.drawing.pathdrawingtool"
name="Draw Path...">
</command>
<command <command
id="com.raytheon.uf.viz.drawing.undoadd" id="com.raytheon.uf.viz.drawing.undoadd"
name="Undo Add"> name="Undo Add">
@ -37,10 +33,6 @@
</extension> </extension>
<extension <extension
point="org.eclipse.ui.handlers"> point="org.eclipse.ui.handlers">
<handler
class="com.raytheon.uf.viz.drawing.tools.PathDrawingTool"
commandId="com.raytheon.uf.viz.drawing.pathdrawingtool">
</handler>
<handler <handler
class="com.raytheon.uf.viz.drawing.actions.UndoAddAction" class="com.raytheon.uf.viz.drawing.actions.UndoAddAction"
commandId="com.raytheon.uf.viz.drawing.undoadd"> commandId="com.raytheon.uf.viz.drawing.undoadd">
@ -50,7 +42,7 @@
commandId="com.raytheon.uf.viz.drawing.redoadd"> commandId="com.raytheon.uf.viz.drawing.redoadd">
</handler> </handler>
</extension> </extension>
<extension <!--extension
point="org.eclipse.ui.bindings"> point="org.eclipse.ui.bindings">
<scheme <scheme
id="com.raytheon.uf.viz.drawing.scheme" id="com.raytheon.uf.viz.drawing.scheme"
@ -68,5 +60,5 @@
schemeId="com.raytheon.uf.viz.drawing.scheme" schemeId="com.raytheon.uf.viz.drawing.scheme"
sequence="M1+Y"> sequence="M1+Y">
</key> </key>
</extension> </extension-->
</plugin> </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.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; 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.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IInputHandler; import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -72,10 +73,9 @@ public abstract class AbstractDrawingTool extends AbstractModalTool {
} }
if (theDrawingLayer == null) { if (theDrawingLayer == null) {
PathDrawingResourceData resourceData = new PathDrawingResourceData();
try { try {
theDrawingLayer = resourceData.construct(new LoadProperties(), theDrawingLayer = (DrawingLayer) constructData().construct(
desc); new LoadProperties(), desc);
} catch (VizException e1) { } catch (VizException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
@ -110,4 +110,5 @@ public abstract class AbstractDrawingTool extends AbstractModalTool {
*/ */
public abstract IInputHandler getMouseHandler(); 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.List;
import java.util.Map; import java.util.Map;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.graphics.RGB; 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.EditableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.drawing.actions.ClearDrawingAction; 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.RedoAddAction;
import com.raytheon.uf.viz.drawing.actions.UndoAddAction; import com.raytheon.uf.viz.drawing.actions.UndoAddAction;
import com.raytheon.uf.viz.drawing.tools.ToolsUtils; 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.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Point;
/** /**
@ -70,14 +71,14 @@ public class DrawingLayer extends
protected IWireframeShape tempWireframeShape; protected IWireframeShape tempWireframeShape;
protected IWireframeShape eraseWireframeShape;
protected IGraphicsTarget target; protected IGraphicsTarget target;
protected boolean needsRefresh = true; protected boolean needsRefresh = true;
protected boolean erase = false; protected boolean erase = false;
private EraseObjectsAction eAction = null;
public DrawingLayer(PathDrawingResourceData data, LoadProperties props) { public DrawingLayer(PathDrawingResourceData data, LoadProperties props) {
super(data, props); super(data, props);
} }
@ -123,6 +124,10 @@ public class DrawingLayer extends
getDescriptor()); getDescriptor());
needsRefresh = false; needsRefresh = false;
} }
if (eraseWireframeShape == null) {
eraseWireframeShape = target.createWireframeShape(true,
getDescriptor());
}
RGB rgb = getCapability(ColorableCapability.class).getColor(); RGB rgb = getCapability(ColorableCapability.class).getColor();
@ -186,12 +191,39 @@ public class DrawingLayer extends
Point point = factory Point point = factory
.createPoint(line.getCoordinates()[line .createPoint(line.getCoordinates()[line
.getNumPoints() - 1]); .getNumPoints() - 1]);
if (point.buffer(8).intersects(geom)) { Geometry intersection = point.buffer(8).intersection(geom);
Geometry intersection = point.intersection(geom); Geometry finalGeom = geom.difference(intersection);
Geometry finalGeom = geom.difference(intersection); deletedShapes.put(geom, wireframeShapes.remove(geom));
deletedShapes.put(geom, wireframeShapes.remove(geom));
this.tempGeometries.add(finalGeom); if (finalGeom instanceof MultiLineString) {
System.out.println("removing things"); 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() { public void reset() {
resetTemp(); resetTemp();
disposeInternal(); disposeInternal();
issueRefresh();
} }
public void resetTemp() { public void resetTemp() {
@ -264,25 +297,24 @@ public class DrawingLayer extends
public void addContextMenuItems(IMenuManager menuManager, int x, int y) { public void addContextMenuItems(IMenuManager menuManager, int x, int y) {
ResourcePair pair = new ResourcePair(); ResourcePair pair = new ResourcePair();
pair.setResource(this); pair.setResource(this);
if (eAction == null) { Action action = new Action("Draw Toolbar") {
eAction = new EraseObjectsAction(); public void run() {
eAction.setSelectedRsc(pair); PathToolbar.getToolbar().open();
} else { };
eAction.setSelectedRsc(pair); };
} // ClearDrawingAction cAction = new ClearDrawingAction();
ClearDrawingAction cAction = new ClearDrawingAction(); // cAction.setSelectedRsc(pair);
cAction.setSelectedRsc(pair); // cAction.setImageDescriptor(ToolsUtils.getImageDescriptor("remove.gif"));
cAction.setImageDescriptor(ToolsUtils.getImageDescriptor("remove.gif")); // UndoAddAction uAction = new UndoAddAction();
UndoAddAction uAction = new UndoAddAction(); // uAction.setSelectedRsc(pair);
uAction.setSelectedRsc(pair); // uAction.setImageDescriptor(ToolsUtils.getImageDescriptor("undo.gif"));
uAction.setImageDescriptor(ToolsUtils.getImageDescriptor("undo.gif")); // RedoAddAction rAction = new RedoAddAction();
RedoAddAction rAction = new RedoAddAction(); // rAction.setSelectedRsc(pair);
rAction.setSelectedRsc(pair); // rAction.setImageDescriptor(ToolsUtils.getImageDescriptor("redo.gif"));
rAction.setImageDescriptor(ToolsUtils.getImageDescriptor("redo.gif")); // menuManager.add(cAction);
menuManager.add(eAction); // menuManager.add(uAction);
menuManager.add(cAction); // menuManager.add(rAction);
menuManager.add(uAction); menuManager.add(action);
menuManager.add(rAction);
} }
/** /**

View file

@ -19,9 +19,36 @@
**/ **/
package com.raytheon.uf.viz.drawing; 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 * TODO Add Description
@ -40,23 +67,40 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
* @version 1.0 * @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 parentShell
* @param swtStyle * @param swtStyle
*/ */
protected PathToolbar(Shell parentShell, int swtStyle) { protected PathToolbar(Shell parentShell) {
super(parentShell, swtStyle); super(parentShell, SWT.DIALOG_TRIM | CAVE.DO_NOT_BLOCK);
// TODO Auto-generated constructor stub layers = new HashMap<AbstractEditor, ResourcePair>();
setText("Drawing");
} }
/** /**
* @param args * @param args
*/ */
public static void main(String[] 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 @Override
protected void initializeComponents(Shell shell) { 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; 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.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 * TODO Add Description
@ -39,36 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0 * @version 1.0
*/ */
public class ClearDrawingAction extends AbstractRightClickAction { public class ClearDrawingAction extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override @Override
public void run() { public Object execute(ExecutionEvent event) throws ExecutionException {
if (getSelectedRsc() != null) { ResourceList list = ((AbstractEditor) EditorUtil
((DrawingLayer) getSelectedRsc()).reset(); .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; 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.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 * TODO Add Description
@ -41,35 +46,20 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0 * @version 1.0
*/ */
public class EraseObjectsAction extends AbstractRightClickAction { public class EraseObjectsAction extends AbstractHandler {
/**
*
*/
public EraseObjectsAction() {
super("Eraser", IAction.AS_CHECK_BOX);
}
@Override @Override
public void run() { public Object execute(ExecutionEvent event) throws ExecutionException {
((DrawingLayer) getSelectedRsc()) ResourceList list = ((AbstractEditor) EditorUtil
.setErase(!((DrawingLayer) getSelectedRsc()).isErase()); .getActiveEditorAs(AbstractEditor.class))
} .getActiveDisplayPane().getDescriptor().getResourceList();
for (ResourcePair pair : list) {
/* if (pair.getResource() instanceof DrawingLayer) {
* (non-Javadoc) ((DrawingLayer) pair.getResource())
* .setErase(((DrawingLayer) pair.getResource()).isErase());
* @see com.raytheon.viz.ui.cmenu.AbstractRightClickAction#isHidden() break;
*/ }
@Override
public boolean isHidden() {
if (true) {
return true;
}
if (getSelectedRsc() instanceof DrawingLayer) {
return false;
} else {
return true;
} }
return null;
} }
} }

View file

@ -19,8 +19,15 @@
**/ **/
package com.raytheon.uf.viz.drawing.actions; 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.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 * TODO Add Description
@ -39,43 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0 * @version 1.0
*/ */
public class RedoAddAction extends AbstractRightClickAction { public class RedoAddAction extends AbstractHandler {
@Override @Override
public void run() { public Object execute(ExecutionEvent event) throws ExecutionException {
((DrawingLayer) getSelectedRsc()).redoAdd(); ResourceList list = ((AbstractEditor) EditorUtil
} .getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
@Override for (ResourcePair pair : list) {
public boolean isHidden() { if (pair.getResource() instanceof DrawingLayer) {
if (getSelectedRsc() instanceof DrawingLayer) { ((DrawingLayer) pair.getResource()).redoAdd();
return false; break;
} else { }
return true;
} }
} return null;
/*
* (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";
} }
} }

View file

@ -19,8 +19,15 @@
**/ **/
package com.raytheon.uf.viz.drawing.actions; 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.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 * TODO Add Description
@ -39,43 +46,19 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1.0 * @version 1.0
*/ */
public class UndoAddAction extends AbstractRightClickAction { public class UndoAddAction extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override @Override
public void run() { public Object execute(ExecutionEvent event) throws ExecutionException {
((DrawingLayer) getSelectedRsc()).undoAdd(); ResourceList list = ((AbstractEditor) EditorUtil
} .getActiveEditorAs(AbstractEditor.class))
.getActiveDisplayPane().getDescriptor().getResourceList();
/* for (ResourcePair pair : list) {
* (non-Javadoc) if (pair.getResource() instanceof DrawingLayer) {
* ((DrawingLayer) pair.getResource()).undoAdd();
* @see org.eclipse.jface.action.Action#isEnabled() break;
*/ }
@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;
} }
return null;
} }
} }

View file

@ -25,11 +25,15 @@ import java.util.List;
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.Image;
import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Display; 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.core.rsc.IInputHandler;
import com.raytheon.uf.viz.drawing.AbstractDrawingTool; import com.raytheon.uf.viz.drawing.AbstractDrawingTool;
import com.raytheon.uf.viz.drawing.PathDrawingResourceData;
import com.raytheon.viz.ui.input.InputAdapter; import com.raytheon.viz.ui.input.InputAdapter;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.GeometryFactory;
@ -46,6 +50,10 @@ public class PathDrawingTool extends AbstractDrawingTool {
/** The mouse handler */ /** The mouse handler */
protected IInputHandler theHandler; protected IInputHandler theHandler;
public AbstractResourceData constructData() {
return new PathDrawingResourceData();
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -80,12 +88,16 @@ public class PathDrawingTool extends AbstractDrawingTool {
Cursor cursor = null; Cursor cursor = null;
if (theDrawingLayer.isErase()) { if (theDrawingLayer.isErase()) {
ImageData data = ToolsUtils.getImageDescriptor("eraser.gif") ImageData data = ToolsUtils
.getImageData(); .getImageDescriptor("eraser_box.gif").getImageData();
data.alpha = 255; data.alpha = 255;
cursor = new Cursor(Display.getCurrent(), data, 8, 8); cursor = new Cursor(Display.getCurrent(), data, 8, 8);
} else { } else {
cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); 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); Display.getCurrent().getActiveShell().setCursor(cursor);
@ -158,27 +170,6 @@ public class PathDrawingTool extends AbstractDrawingTool {
if (!theDrawingLayer.isErase()) { if (!theDrawingLayer.isErase()) {
theDrawingLayer.addLine(ls, null); 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; return true;
} }