diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF index 0889269792..f82a2ad24e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF @@ -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 diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/icons/session_leader.png b/cave/com.raytheon.uf.viz.collaboration.ui/icons/session_leader.png index 81ea967d68..92f4662811 100644 Binary files a/cave/com.raytheon.uf.viz.collaboration.ui/icons/session_leader.png and b/cave/com.raytheon.uf.viz.collaboration.ui/icons/session_leader.png differ diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index f1c2fef047..062544067e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -130,14 +130,6 @@ style="push"> - - - - diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index f5ff14d278..19d4b413b1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -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(); } /** diff --git a/cave/com.raytheon.uf.viz.drawing/icons/draw.gif b/cave/com.raytheon.uf.viz.drawing/icons/draw.gif new file mode 100644 index 0000000000..0bfecd50ee Binary files /dev/null and b/cave/com.raytheon.uf.viz.drawing/icons/draw.gif differ diff --git a/cave/com.raytheon.uf.viz.drawing/icons/eraser.png b/cave/com.raytheon.uf.viz.drawing/icons/eraser.png new file mode 100644 index 0000000000..bc6a3fa43a Binary files /dev/null and b/cave/com.raytheon.uf.viz.drawing/icons/eraser.png differ diff --git a/cave/com.raytheon.uf.viz.drawing/icons/eraser.gif b/cave/com.raytheon.uf.viz.drawing/icons/eraser_box.gif similarity index 100% rename from cave/com.raytheon.uf.viz.drawing/icons/eraser.gif rename to cave/com.raytheon.uf.viz.drawing/icons/eraser_box.gif diff --git a/cave/com.raytheon.uf.viz.drawing/plugin.xml b/cave/com.raytheon.uf.viz.drawing/plugin.xml index dfc18c8dc5..da4862783f 100644 --- a/cave/com.raytheon.uf.viz.drawing/plugin.xml +++ b/cave/com.raytheon.uf.viz.drawing/plugin.xml @@ -22,10 +22,6 @@ - - @@ -37,10 +33,6 @@ - - @@ -50,7 +42,7 @@ commandId="com.raytheon.uf.viz.drawing.redoadd"> - - + diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java index 7e170cbcd8..6a74450348 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java @@ -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(); } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java index ad335d131b..24ed2ecb5b 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java @@ -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); } /** diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java index fe2fab5943..4e2c291e26 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java @@ -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 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(); + 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); } } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java index 3748235e58..db129f67a0 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java @@ -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; - } - } -} +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java index ac8226df48..9a7914cc73 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java @@ -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; } -} +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java index ee087cda34..3d1c3f1aa8 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java @@ -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; } } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java index 1f2493677d..554824ccd0 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java @@ -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; } } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java index f645bdaec7..670bdd12af 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java @@ -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; }