From 8e1619437041409b6c49aabb57b3bef4ad515b9d Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Tue, 3 Apr 2012 12:23:11 -0500 Subject: [PATCH] #429 fix issue where dialog prevents collaboration view from opening, add collaboration drawing layer, use event bus for message handling, prep work for Former-commit-id: be35f7e75bbeb89fe160e24d9ff691f62753c96b --- .../META-INF/MANIFEST.MF | 3 +- .../icons/multiple_draw.gif | Bin 0 -> 346 bytes .../data/CollaborationDataManager.java | 23 ++- .../ui/CollaborationGroupView.java | 22 --- .../ui/role/ParticipantEventController.java | 32 ++++ .../ui/role/SessionLeaderEventController.java | 85 ++++++++++ .../CollaborationDrawingLayer.java | 151 ++++++++++++++++++ .../CollaborationPathDrawingResourceData.java | 86 ++++++++++ .../CollaborationPathDrawingTool.java | 53 ++++++ .../telestrator/CollaborationPathToolbar.java | 109 +++++++++++++ .../ui/telestrator/TelestratorLine.java} | 27 +++- .../ui/telestrator/TelestratorObject.java} | 16 +- .../META-INF/MANIFEST.MF | 6 +- .../raytheon/uf/viz/drawing/DrawingLayer.java | 141 ++++++++-------- .../raytheon/uf/viz/drawing/PathToolbar.java | 67 ++++---- .../uf/viz/drawing/actions/RedoAddAction.java | 3 + .../uf/viz/drawing/actions/UndoAddAction.java | 4 +- .../uf/viz/drawing/events/DrawingEvent.java | 66 ++++++++ .../viz/drawing/events/DrawingEventBus.java | 74 +++++++++ .../viz/drawing/events/DrawingListener.java | 46 ++++++ .../uf/viz/drawing/tools/PathDrawingTool.java | 21 ++- 21 files changed, 880 insertions(+), 155 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/icons/multiple_draw.gif create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/SessionLeaderEventController.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingResourceData.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingTool.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java rename cave/{com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java => com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorLine.java} (72%) rename cave/{com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java => com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorObject.java} (82%) create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEvent.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEventBus.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingListener.java 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 22abbe53ed..55ba0bb78e 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 @@ -21,5 +21,6 @@ Require-Bundle: com.raytheon.viz.ui, 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.drawing + com.raytheon.uf.viz.drawing, + com.raytheon.viz.awipstools.ui.display Bundle-ActivationPolicy: lazy diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/icons/multiple_draw.gif b/cave/com.raytheon.uf.viz.collaboration.ui/icons/multiple_draw.gif new file mode 100644 index 0000000000000000000000000000000000000000..471ef2a09b72cc12ced3164220cb513255b581dc GIT binary patch literal 346 zcmZ?wbhEHb6krfwSgOfjGxxpY!Z(f!-#RS$;IQPQ)6x&l%Rf4;_~N?az4OX1c5D8* zum9?_;lKNaul`%#dF=Qby#2lJp8tXS{s!&;7kT(q)RA}L$Nt8jc^iHDU(D&h31{9W zpZbt~>O)`8iVC kU04&lTsV2yJlS~IT^PBY85o>-nNqm8I-HnUd>t9A0Wej sessionsMap; - private Map roleEventControllersMap; + private Multimap roleEventControllersMap; Map editorsMap; @@ -132,7 +136,7 @@ public class CollaborationDataManager { linkCollaboration = false; usersMap = new HashMap(); sessionsMap = new HashMap(); - roleEventControllersMap = new HashMap(); + roleEventControllersMap = HashMultimap.create(); editorsMap = new HashMap(); } @@ -302,10 +306,12 @@ public class CollaborationDataManager { } } - AbstractRoleEventController controller = roleEventControllersMap - .remove(sessionId); + Collection controller = roleEventControllersMap + .removeAll(sessionId); if (controller != null) { - controller.shutdown(); + for (AbstractRoleEventController cont : controller) { + cont.shutdown(); + } } } @@ -381,7 +387,11 @@ public class CollaborationDataManager { DataProviderEventController dpec = new DataProviderEventController( displaySession); dpec.startup(); + SessionLeaderEventController slec = new SessionLeaderEventController( + displaySession); + slec.startup(); roleEventControllersMap.put(sessionId, dpec); + roleEventControllersMap.put(sessionId, slec); // TODO set displaySession's data provider and session leader. } } catch (CollaborationException e) { @@ -411,6 +421,9 @@ public class CollaborationDataManager { public void run() { IQualifiedID inviter = invitation.getInviter(); IQualifiedID room = invitation.getRoomId(); + if (shell.isDisposed()) { + shell = new Shell(Display.getCurrent()); + } MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); box.setText("Invitation"); 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 f4cf6f9902..22a9da2fd1 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 @@ -27,10 +27,6 @@ import java.util.List; 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; @@ -98,9 +94,7 @@ 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.core.icon.IconUtil; -import com.raytheon.uf.viz.drawing.PathToolbar; import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; /** @@ -193,22 +187,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { if (CollaborationDataManager.getInstance().isConnected() == 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(); } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/ParticipantEventController.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/ParticipantEventController.java index a657968ff1..e486a74eb9 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/ParticipantEventController.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/ParticipantEventController.java @@ -31,6 +31,7 @@ import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup; import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditor; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority; +import com.raytheon.uf.viz.drawing.PathToolbar; /** * Handles the events of a session that are specific to the Participant role. @@ -79,4 +80,35 @@ public class ParticipantEventController extends AbstractRoleEventController { } } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController + * #startup() + */ + @Override + public void startup() { + super.startup(); + VizApp.runAsync(new Runnable() { + @Override + public void run() { + PathToolbar toolbar = PathToolbar.getToolbar(); + toolbar.open(); + } + }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController + * #shutdown() + */ + @Override + public void shutdown() { + super.shutdown(); + PathToolbar.getToolbar().close(); + } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/SessionLeaderEventController.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/SessionLeaderEventController.java new file mode 100644 index 0000000000..117d57404b --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/SessionLeaderEventController.java @@ -0,0 +1,85 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.ui.role; + +import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; +import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathToolbar; +import com.raytheon.uf.viz.core.VizApp; +import com.raytheon.uf.viz.drawing.PathToolbar; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 2, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class SessionLeaderEventController extends AbstractRoleEventController { + + /** + * @param session + */ + public SessionLeaderEventController(ISharedDisplaySession session) { + super(session); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController + * #startup() + */ + @Override + public void startup() { + super.startup(); + VizApp.runAsync(new Runnable() { + @Override + public void run() { + PathToolbar toolbar = CollaborationPathToolbar.getToolbar(); + toolbar.open(); + } + }); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController + * #shutdown() + */ + @Override + public void shutdown() { + super.shutdown(); + PathToolbar.getToolbar().close(); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java new file mode 100644 index 0000000000..e5f65461e4 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java @@ -0,0 +1,151 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.ui.telestrator; + +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.swt.graphics.Color; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.drawables.IWireframeShape; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.uf.viz.drawing.PathDrawingResourceData; +import com.vividsolutions.jts.geom.LineString; + +/** + * A layer that extends Drawing Layer but allows other users to have things + * drawn as well + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 3, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationDrawingLayer extends DrawingLayer { + + private Multimap collaboratorShapes; + + /** + * @param data + * @param props + */ + public CollaborationDrawingLayer(PathDrawingResourceData data, + LoadProperties props) { + super(data, props); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.DrawingLayer#initInternal(com.raytheon.uf + * .viz.core.IGraphicsTarget) + */ + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + super.initInternal(target); + this.collaboratorShapes = HashMultimap.create(); + getCapabilities().removeCapability(ColorableCapability.class); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.DrawingLayer#paintInternal(com.raytheon.uf + * .viz.core.IGraphicsTarget, + * com.raytheon.uf.viz.core.drawables.PaintProperties) + */ + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + super.paintInternal(target, paintProps); + + OutlineCapability outline = getCapability(OutlineCapability.class); + // paint the shapes that come over from others + for (Color color : collaboratorShapes.keySet()) { + for (IWireframeShape sh : collaboratorShapes.get(color)) { + target.drawWireframeShape(sh, color.getRGB(), + outline.getOutlineWidth(), outline.getLineStyle()); + } + } + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.drawing.DrawingLayer#disposeInternal() + */ + @Override + protected void disposeInternal() { + super.disposeInternal(); + for (IWireframeShape shape : collaboratorShapes.values()) { + shape.dispose(); + } + collaboratorShapes.clear(); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.DrawingLayer#finalizeLine(com.vividsolutions + * .jts.geom.LineString, java.lang.String) + */ + @Override + public void finalizeLine(LineString line, String uuid) { + super.finalizeLine(line, uuid); + + Map sessions = CollaborationDataManager + .getInstance().getSessions(); + + TelestratorLine tObject = new TelestratorLine(); + // set the coordinates of the TransferLine + tObject.setCoordinates(Arrays.asList(line.getCoordinates())); + // get the color of the user here, before sending it off + tObject.setColor(null); + // for (String str : sessions.keySet()) { + // try { + // ((ISharedDisplaySession) sessions.get(str)).sendEvent(tObject); + // } catch (CollaborationException e) { + // e.printStackTrace(); + // } + // } + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingResourceData.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingResourceData.java new file mode 100644 index 0000000000..05a03ff1f9 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingResourceData.java @@ -0,0 +1,86 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.ui.telestrator; + +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.uf.viz.drawing.PathDrawingResourceData; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 3, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationPathDrawingResourceData extends + PathDrawingResourceData { + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.PathDrawingResourceData#construct(com.raytheon + * .uf.viz.core.rsc.LoadProperties, + * com.raytheon.uf.viz.core.drawables.IDescriptor) + */ + @Override + public DrawingLayer construct(LoadProperties loadProperties, + IDescriptor descriptor) throws VizException { + CollaborationDrawingLayer layer = new CollaborationDrawingLayer(this, + loadProperties); + return layer; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#setClassT + * (java.lang.String) + */ + @Override + public String getClassT() { + return this.getClass().getCanonicalName(); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#setClassT + * (java.lang.String) + */ + @Override + public void setClassT(String classT) { + + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingTool.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingTool.java new file mode 100644 index 0000000000..4e4c351bb0 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathDrawingTool.java @@ -0,0 +1,53 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.ui.telestrator; + +import com.raytheon.uf.viz.core.rsc.AbstractResourceData; +import com.raytheon.uf.viz.drawing.tools.PathDrawingTool; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 3, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationPathDrawingTool extends PathDrawingTool { + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.drawing.tools.PathDrawingTool#constructData() + */ + @Override + public AbstractResourceData constructData() { + CollaborationPathDrawingResourceData data = new CollaborationPathDrawingResourceData(); + return data; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java new file mode 100644 index 0000000000..179fcdda92 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java @@ -0,0 +1,109 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.ui.telestrator; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import com.raytheon.uf.viz.drawing.PathToolbar; +import com.raytheon.uf.viz.drawing.events.DrawingEventBus; +import com.raytheon.uf.viz.drawing.tools.PathDrawingTool; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 3, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationPathToolbar extends PathToolbar { + + /** + * @param parentShell + */ + protected CollaborationPathToolbar(Shell parentShell) { + super(parentShell); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.drawing.PathToolbar#startTool() + */ + @Override + protected void startTool() { + PathDrawingTool tool = new CollaborationPathDrawingTool(); + tool.activate(); + } + + public static PathToolbar getToolbar() { + if (pathToolbar == null) { + pathToolbar = new CollaborationPathToolbar(new Shell( + Display.getCurrent())); + DrawingEventBus.register(PathToolbar.getToolbar()); + } + return pathToolbar; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.PathToolbar#initializeComponents(org.eclipse + * .swt.widgets.Shell) + */ + @Override + protected void initializeComponents(Shell shell) { + // allows for subclasses to add more items to the toolbar, in this case + // allowing the user to turn off other collaborator drawings + super.initializeComponents(shell); + // ToolItem allowOthersItem = new ToolItem(toolbar, SWT.CHECK); + // allowOthersItem.setText("Leader Only"); + // allowOthersItem.setImage(IconUtil.getImageDescriptor( + // Activator.getDefault().getBundle(), "multiple_draw.gif") + // .createImage()); + // allowOthersItem.setSelection(true); + // allowOthersItem.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // AbstractEditor editor = EditorUtil + // .getActiveEditorAs(AbstractEditor.class); + // IDescriptor desc = editor.getActiveDisplayPane() + // .getDescriptor(); + // for (ResourcePair pair : desc.getResourceList()) { + // if (pair.getResource() instanceof CollaborationDrawingLayer) { + // System.out.println("collaborating"); + // } + // } + // } + // }); + } + +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorLine.java similarity index 72% rename from cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java rename to cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorLine.java index 480a91c053..e57114701e 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorLine.java @@ -17,14 +17,16 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.drawing.objects; +package com.raytheon.uf.viz.collaboration.ui.telestrator; import java.util.List; +import org.eclipse.swt.graphics.Color; + import com.vividsolutions.jts.geom.Coordinate; /** - * TODO Add Description + * A line for the telestrator * *
  * 
@@ -40,9 +42,28 @@ import com.vividsolutions.jts.geom.Coordinate;
  * @version 1.0
  */
 
-public class TransferLine {
+public class TelestratorLine extends TelestratorObject {
+    // the color of the shape to be drawn
+    private Color color;
+
+    // the coordinates to be converted into a wireframe shape
     private List coordinates;
 
+    /**
+     * @param color
+     *            the color to set
+     */
+    public void setColor(Color color) {
+        this.color = color;
+    }
+
+    /**
+     * @return the color
+     */
+    public Color getColor() {
+        return color;
+    }
+
     /**
      * @param coordinates
      *            the coordinates to set
diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorObject.java
similarity index 82%
rename from cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java
rename to cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorObject.java
index 96d8fb5013..e52b9e352b 100644
--- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/TelestratorObject.java
@@ -17,25 +17,27 @@
  * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
  * further licensing information.
  **/
-package com.raytheon.uf.viz.drawing.objects;
+package com.raytheon.uf.viz.collaboration.ui.telestrator;
+
+import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
 
 /**
  * TODO Add Description
  * 
  * 
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 26, 2012            mnash     Initial creation
- *
+ * 
  * 
- * + * * @author mnash - * @version 1.0 + * @version 1.0 */ -public class TransferObject { +public class TelestratorObject implements IDisplayEvent { } diff --git a/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF index 45742dc817..0d483df5ec 100644 --- a/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF @@ -11,11 +11,13 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0", com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", com.raytheon.viz.awipstools;bundle-version="1.12.1174", - com.raytheon.viz.ui;bundle-version="1.12.1174" + com.raytheon.viz.ui;bundle-version="1.12.1174", + com.google.guava;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: com.raytheon.uf.common.time, com.raytheon.viz.ui.cmenu, com.vividsolutions.jts.geom Export-Package: com.raytheon.uf.viz.drawing, - com.raytheon.uf.viz.drawing.objects + com.raytheon.uf.viz.drawing.events, + com.raytheon.uf.viz.drawing.tools 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 e2125a17d2..6f56bb0412 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,13 +26,12 @@ 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; +import com.google.common.eventbus.EventBus; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; @@ -41,14 +40,16 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; 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.viz.ui.cmenu.IContextMenuContributor; +import com.raytheon.uf.viz.drawing.events.DrawingEvent; +import com.raytheon.uf.viz.drawing.events.DrawingEventBus; +import com.raytheon.uf.viz.drawing.events.DrawingListener; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.MultiLineString; import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.TopologyException; /** * Implements a basic drawing layer @@ -57,8 +58,7 @@ import com.vividsolutions.jts.geom.Point; * */ public class DrawingLayer extends - AbstractVizResource implements - IContextMenuContributor { + AbstractVizResource { protected List tempGeometries; @@ -70,9 +70,6 @@ public class DrawingLayer extends protected IWireframeShape eraseWireframeShape; - // TODO take this out - private List erasedShapes; - protected IGraphicsTarget target; protected boolean erase = false; @@ -81,8 +78,21 @@ public class DrawingLayer extends private boolean needsRefresh = false; + protected RGB color; + + protected OutlineCapability outline; + + // allowing for others to get events from the drawing tool, just having to + // subscribe + private EventBus eventBus; + + private DrawingListener eventListener = null; + public DrawingLayer(PathDrawingResourceData data, LoadProperties props) { super(data, props); + eventBus = DrawingEventBus.getEventBus(); + eventListener = DrawingEventBus.getDrawingListener(); + eventBus.register(eventListener); } /* @@ -107,11 +117,9 @@ public class DrawingLayer extends this.wireframeShapes = new LinkedHashMap(); this.deletedShapes = new LinkedHashMap(); - this.erasedShapes = new ArrayList(); this.target = target; - - getCapability(OutlineCapability.class); - getCapability(ColorableCapability.class); + outline = getCapability(OutlineCapability.class); + color = getCapability(ColorableCapability.class).getColor(); getCapability(EditableCapability.class); } @@ -134,46 +142,27 @@ public class DrawingLayer extends getDescriptor()); } - OutlineCapability outline = getCapability(OutlineCapability.class); - ColorableCapability colorable = getCapability(ColorableCapability.class); + outline = getCapability(OutlineCapability.class); + color = getCapability(ColorableCapability.class).getColor(); - // remove after debugging - // MagnificationCapability magnification = - // getCapability(MagnificationCapability.class); - // for (Geometry ls : wireframeShapes.keySet()) { - // if (ls instanceof LineString) { - // LineString string = (LineString) ls; - // for (int i = 0; i < string.getNumPoints(); i++) { - // target.drawPoint(string.getPointN(i).getX(), string - // .getPointN(i).getY(), 0, colorable.getColor(), - // PointStyle.BOX, magnification.getMagnification() - // .floatValue()); - // DrawableString dString = new DrawableString(string - // .getPointN(i).getCoordinate().toString(), - // colorable.getColor()); - // dString.basics.x = string.getPointN(i).getX(); - // dString.basics.y = string.getPointN(i).getY(); - // target.drawStrings(dString); - // } - // } - // } for (IWireframeShape sh : wireframeShapes.values()) { - target.drawWireframeShape(sh, colorable.getColor(), + target.drawWireframeShape(sh, color, (float) outline.getOutlineWidth(), outline.getLineStyle()); } for (Geometry g : this.tempGeometries) { drawTempLinePrimitive(g, tempWireframeShape); } - // if (erase) { - // target.drawWireframeShape(tempWireframeShape, new RGB(255, 0, 0), - // 1.0f); - // } else { - target.drawWireframeShape(tempWireframeShape, colorable.getColor(), + target.drawWireframeShape(tempWireframeShape, color, outline.getOutlineWidth(), outline.getLineStyle()); - // } } + /** + * Add the geometry to the wireframe shape that is passed in + * + * @param shape + * @param wShape + */ private void drawTempLinePrimitive(Geometry shape, IWireframeShape wShape) { LineString line = (LineString) shape; @@ -225,6 +214,8 @@ public class DrawingLayer extends public void finalizeLine(LineString line, String uuid) { tempWireframeShape.compile(); wireframeShapes.put(line, tempWireframeShape); + DrawingEvent event = new DrawingEvent(line, null); + eventBus.post(event); } public void addTempDrawLine(LineString line) { @@ -232,7 +223,7 @@ public class DrawingLayer extends } public void addTempEraseLine(LineString line) { - this.tempGeometries.add(line); + // this.tempGeometries.add(line); Map shapes = new HashMap(); shapes.putAll(wireframeShapes); for (Geometry geom : shapes.keySet()) { @@ -244,7 +235,12 @@ public class DrawingLayer extends if (line.buffer(size / 2).intersects(geom)) { Geometry intersection = line.buffer(size / 2) .intersection(geom); - Geometry finalGeom = geom.difference(intersection); + Geometry finalGeom = null; + try { + finalGeom = geom.difference(intersection); + } catch (TopologyException e) { + continue; + } deletedShapes.put(geom, wireframeShapes.remove(geom)); Geometry lString = null; @@ -259,7 +255,6 @@ public class DrawingLayer extends drawTempLinePrimitive(lineString, eraseWireframeShape); this.wireframeShapes.put(lineString, eraseWireframeShape); - erasedShapes.add(eraseWireframeShape); } } if (finalGeom instanceof LineString) { @@ -273,14 +268,8 @@ public class DrawingLayer extends descriptor); drawTempLinePrimitive(lString, eraseWireframeShape); this.wireframeShapes.put(lString, eraseWireframeShape); - erasedShapes.add(eraseWireframeShape); } else { - lString = (GeometryCollection) finalGeom; - // for (int j = 0; j < lString.getNumGeometries(); j++) { - // System.out.println(lString.getGeometryN(j).getClass()); - // } - // System.out.println(finalGeom.getClass() + " has " - // + lString.getNumGeometries() + " geometries"); + // do nothing } } tempGeometries.clear(); @@ -293,8 +282,10 @@ public class DrawingLayer extends issueRefresh(); } + /** + * reset the temporary geometries so that we can start a new line + */ public void resetTemp() { - // this.tempWireframeShape.dispose(); this.tempGeometries.clear(); needsRefresh = true; } @@ -344,23 +335,7 @@ public class DrawingLayer extends } /** - * Add items to the right click menu, in this case just a button to launch - * the Drawing toolbar - */ - @Override - public void addContextMenuItems(IMenuManager menuManager, int x, int y) { - ResourcePair pair = new ResourcePair(); - pair.setResource(this); - Action action = new Action("Draw Toolbar...") { - public void run() { - PathToolbar.getToolbar().open(); - }; - }; - menuManager.add(action); - } - - /** - * @return the erase + * @return are you currently erasing */ public boolean isErase() { return erase; @@ -368,23 +343,39 @@ public class DrawingLayer extends /** * @param erase - * the erase to set + * to erase or not to erase */ public void setErase(boolean erase) { this.erase = erase; } /** - * @return the deletedShapes + * @return the deletedShapes, these shapes will get disposed when the clear + * button is selected */ public Map getDeletedShapes() { return deletedShapes; } /** - * @return the wireframeShapes + * @return the wireframeShapes, these shapes will get disposed when the + * clear button is selected */ public Map getWireframeShapes() { return wireframeShapes; } -} + + /** + * @return the eventBus + */ + public EventBus getEventBus() { + return eventBus; + } + + /** + * @return the eventListener + */ + public DrawingListener getEventListener() { + return eventListener; + } +} \ No newline at end of file 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 9e1510fa02..b9b274728d 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 @@ -37,7 +37,8 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextService; -import com.raytheon.uf.viz.core.IDisplayPane; +import com.google.common.eventbus.AllowConcurrentEvents; +import com.google.common.eventbus.Subscribe; import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.icon.IconUtil; @@ -46,12 +47,12 @@ 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.events.DrawingEvent; +import com.raytheon.uf.viz.drawing.events.DrawingEventBus; import com.raytheon.uf.viz.drawing.tools.PathDrawingTool; 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 @@ -70,13 +71,14 @@ import com.raytheon.viz.ui.editor.VizMultiPaneEditor; * @version 1.0 */ -public class PathToolbar extends CaveSWTDialog implements - ISelectedPanesChangedListener { +public class PathToolbar extends CaveSWTDialog { - private static PathToolbar toolbar; + protected static PathToolbar pathToolbar; // private Map layers; + protected ToolBar toolbar; + private ToolItem drawItem; private ToolItem eraserItem; @@ -90,10 +92,11 @@ public class PathToolbar extends CaveSWTDialog implements private IContextActivation drawingContext; public static PathToolbar getToolbar() { - if (toolbar == null) { - toolbar = new PathToolbar(new Shell(Display.getCurrent())); + if (pathToolbar == null) { + pathToolbar = new PathToolbar(new Shell(Display.getCurrent())); + DrawingEventBus.register(PathToolbar.getToolbar()); } - return toolbar; + return pathToolbar; } /** @@ -142,7 +145,7 @@ public class PathToolbar extends CaveSWTDialog implements layout.marginHeight = 0; layout.marginWidth = 0; - ToolBar toolbar = new ToolBar(comp, SWT.FLAT); + toolbar = new ToolBar(comp, SWT.FLAT); layout = new GridLayout(); layout.marginHeight = 0; @@ -169,8 +172,8 @@ public class PathToolbar extends CaveSWTDialog implements eraserItem.setSelection(false); } } - PathDrawingTool tool = new PathDrawingTool(); - tool.activate(); + + startTool(); // ((VizMultiPaneEditor) editor) // .addSelectedPaneChangedListener(PathToolbar // .getToolbar()); @@ -234,7 +237,6 @@ public class PathToolbar extends CaveSWTDialog implements executeAction(action); } }); - updateToolbar(); } @Override @@ -243,6 +245,7 @@ public class PathToolbar extends CaveSWTDialog implements .getWorkbench().getService(IContextService.class); drawingContext = contextService .activateContext("com.raytheon.uf.viz.drawing.context"); + updateToolbar(); super.opened(); } @@ -254,29 +257,14 @@ public class PathToolbar extends CaveSWTDialog implements } } - /* - * (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()); - for (ResourcePair pair : desc.getResourceList()) { - if (pair.getResource() instanceof DrawingLayer) { - break; - } - } + @AllowConcurrentEvents + @Subscribe + public void handleMessage(DrawingEvent event) { + updateToolbar(); } - private void updateToolbar() { - if (true) { + public void updateToolbar() { + if (this.isDisposed()) { return; } AbstractEditor editor = EditorUtil @@ -294,17 +282,13 @@ public class PathToolbar extends CaveSWTDialog implements } else { clearItem.setEnabled(true); if (layer.getDeletedShapes().isEmpty()) { - undoItem.setEnabled(true); redoItem.setEnabled(false); } else { - undoItem.setEnabled(false); redoItem.setEnabled(true); } if (layer.getWireframeShapes().isEmpty()) { - redoItem.setEnabled(true); undoItem.setEnabled(false); } else { - redoItem.setEnabled(false); undoItem.setEnabled(true); } } @@ -312,4 +296,11 @@ public class PathToolbar extends CaveSWTDialog implements } } + /** + * + */ + protected void startTool() { + PathDrawingTool tool = new PathDrawingTool(); + tool.activate(); + } } 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 3d1c3f1aa8..c5376f10b2 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 @@ -26,6 +26,7 @@ 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.events.DrawingEvent; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.editor.AbstractEditor; @@ -56,6 +57,8 @@ public class RedoAddAction extends AbstractHandler { for (ResourcePair pair : list) { if (pair.getResource() instanceof DrawingLayer) { ((DrawingLayer) pair.getResource()).redoAdd(); + ((DrawingLayer) pair.getResource()).getEventBus().post( + new DrawingEvent(null, null)); break; } } 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 554824ccd0..8ada3a8fb1 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 @@ -26,6 +26,7 @@ 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.events.DrawingEvent; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.editor.AbstractEditor; @@ -42,7 +43,6 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * *
* - * @author mnash * @version 1.0 */ @@ -56,6 +56,8 @@ public class UndoAddAction extends AbstractHandler { for (ResourcePair pair : list) { if (pair.getResource() instanceof DrawingLayer) { ((DrawingLayer) pair.getResource()).undoAdd(); + ((DrawingLayer) pair.getResource()).getEventBus().post( + new DrawingEvent(null, null)); break; } } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEvent.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEvent.java new file mode 100644 index 0000000000..e6e63b5c43 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEvent.java @@ -0,0 +1,66 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.drawing.events; + +import com.raytheon.viz.ui.editor.AbstractEditor; +import com.vividsolutions.jts.geom.Geometry; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 2, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class DrawingEvent { + + private AbstractEditor editor; + + private Geometry geom; + + public DrawingEvent(Geometry geom, AbstractEditor editor) { + this.geom = geom; + this.editor = editor; + } + + /** + * @return the geom + */ + public Geometry getGeom() { + return geom; + } + + /** + * @return the editor + */ + public AbstractEditor getEditor() { + return editor; + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEventBus.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEventBus.java new file mode 100644 index 0000000000..63c27b0b5e --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingEventBus.java @@ -0,0 +1,74 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.drawing.events; + +import com.google.common.eventbus.EventBus; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 2, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class DrawingEventBus { + private static EventBus eventBus; + + private static DrawingListener drawingListener; + + /** + * @return the eventBus + */ + public static EventBus getEventBus() { + if (eventBus == null) { + eventBus = new EventBus("DrawingEventBus"); + } + return eventBus; + } + + /** + * @return the drawingListener + */ + public static DrawingListener getDrawingListener() { + if (drawingListener == null) { + drawingListener = new DrawingListener(); + } + return drawingListener; + } + + /** + * Send in class to register in the event bus + * + * @param ob + */ + public static void register(Object ob) { + getEventBus().register(ob); + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingListener.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingListener.java new file mode 100644 index 0000000000..a0ad2a5780 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/events/DrawingListener.java @@ -0,0 +1,46 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.drawing.events; + +import com.google.common.eventbus.Subscribe; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 2, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class DrawingListener { + + @Subscribe + public void handleMessage(DrawingEvent event) { + } +} 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 ac85bfdf89..c406535854 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 @@ -52,7 +52,8 @@ public class PathDrawingTool extends AbstractDrawingTool { protected IInputHandler theHandler; public AbstractResourceData constructData() { - return new PathDrawingResourceData(); + PathDrawingResourceData data = new PathDrawingResourceData(); + return data; } /* @@ -179,8 +180,26 @@ public class PathDrawingTool extends AbstractDrawingTool { theDrawingLayer.finalizeLine(ls, null); } } + + // this probably should be put elsewhere or genericized in some + // manner + // PathToolbar.getToolbar().updateToolbar(); + editor.refresh(); return true; } } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.tools.AbstractModalTool#activate() + */ + @Override + public void activate() { + super.activate(); + theDrawingLayer.getCapability(EditableCapability.class).setEditable( + true); + theDrawingLayer.issueRefresh(); + } }