Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 215891 Details for
Bug 346172
Support zoom, print and save as image actions in the diagram editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v5
Patch (text/plain), 29.15 KB, created by
Greg Amerson
on 2012-05-18 21:49:53 EDT
(
hide
)
Description:
Patch v5
Filename:
MIME Type:
Creator:
Greg Amerson
Created:
2012-05-18 21:49:53 EDT
Size:
29.15 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.sapphire.ui >Index: META-INF/sapphire-extension.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/META-INF/sapphire-extension.xml,v >retrieving revision 1.43 >diff -u -r1.43 sapphire-extension.xml >--- META-INF/sapphire-extension.xml 9 May 2012 16:00:45 -0000 1.43 >+++ META-INF/sapphire-extension.xml 19 May 2012 01:47:55 -0000 >@@ -12,6 +12,7 @@ > * Konstantin Komissarchik - initial implementation and ongoing maintenance > * Gregory Amerson - [358295] Need access to selection in list property editor > * Gregory Amerson - [377136] Add Sapphire.Diagram.Node to possible contexts for Sapphire.Add >+ * Gregory Amerson - [346172] Support zoom, print, and save as image actions in the diagram editor > ****************************************************************************** > --> > >@@ -216,6 +217,36 @@ > <group>Sapphire.Diagram.Appearance</group> > </action> > <action> >+ <id>Sapphire.Diagram.Zoom.In</id> >+ <label>zoom In</label> >+ <image>org/eclipse/sapphire/ui/actions/ZoomIn.gif</image> >+ <description>Zoom in the diagram.</description> >+ <location>after:Sapphire.Diagram.Layout</location> >+ <group>Sapphire.Diagram.Zoom</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> >+ <action> >+ <id>Sapphire.Diagram.Zoom.Out</id> >+ <label>zoom out</label> >+ <image>org/eclipse/sapphire/ui/actions/ZoomOut.gif</image> >+ <description>Zoom out the diagram.</description> >+ <location>after:Sapphire.Diagram.Zoom.In</location> >+ <group>Sapphire.Diagram.Zoom</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> >+ <action> >+ <id>Sapphire.Diagram.Zoom.Actual</id> >+ <label>zoom actual</label> >+ <image>org/eclipse/sapphire/ui/actions/ZoomActual.gif</image> >+ <description>Zoom the diagram to actual size.</description> >+ <location>after:Sapphire.Diagram.Zoom.Out</location> >+ <group>Sapphire.Diagram.Zoom</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> >+ <action> > <id>Sapphire.Diagram.Node.Default</id> > <context>Sapphire.Diagram.Node</context> > <label>default action</label> >@@ -247,6 +278,26 @@ > <location>after:Sapphire.Diagram.SelectAll</location> > <group>Sapphire.Diagram.SelectAll</group> > </action> >+ <action> >+ <id>Sapphire.Diagram.Save.As.Image</id> >+ <label>save as image</label> >+ <image>org/eclipse/sapphire/ui/actions/SaveAsImage.gif</image> >+ <description>Save the diagram as an image.</description> >+ <location>after:Sapphire.Diagram.SelectAllNodes</location> >+ <group>Sapphire.Diagram.Export</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> >+ <action> >+ <id>Sapphire.Diagram.Print</id> >+ <label>Print</label> >+ <image>org/eclipse/sapphire/ui/actions/Print.gif</image> >+ <description>Print the diagram.</description> >+ <location>after:Sapphire.Diagram.Save.As.Image</location> >+ <group>Sapphire.Diagram.Export</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> > > <action-handler> > <action>Sapphire.Browse</action> >@@ -396,7 +447,25 @@ > <action>Sapphire.Diagram.SelectAllNodes</action> > <impl>org.eclipse.sapphire.ui.diagram.actions.DiagramSelectAllNodesActionHandler</impl> > <context>Sapphire.Diagram.Editor</context> >- </action-handler> >+ </action-handler> >+ <action-handler> >+ <action>Sapphire.Diagram.Zoom.In</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.diagram.actions.ZoomInDiagramActionHandler</impl> >+ </action-handler> >+ <action-handler> >+ <action>Sapphire.Diagram.Zoom.Out</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.diagram.actions.ZoomOutDiagramActionHandler</impl> >+ </action-handler> >+ <action-handler> >+ <action>Sapphire.Diagram.Zoom.Actual</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.diagram.actions.ZoomActualDiagramActionHandler</impl> >+ </action-handler> > <action-handler-factory> > <action>Sapphire.Add</action> > <impl>org.eclipse.sapphire.ui.form.editors.masterdetails.internal.OutlineNodeAddActionHandlerFactory</impl> >Index: src/org/eclipse/sapphire/ui/def/ActionContextRef.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/def/ActionContextRef.java,v >retrieving revision 1.2 >diff -u -r1.2 ActionContextRef.java >--- src/org/eclipse/sapphire/ui/def/ActionContextRef.java 6 Apr 2012 20:36:42 -0000 1.2 >+++ src/org/eclipse/sapphire/ui/def/ActionContextRef.java 19 May 2012 01:47:55 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2012 Oracle >+ * Copyright (c) 2012 Oracle and Liferay > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * Konstantin Komissarchik - initial implementation and ongoing maintenance >+ * Gregory Amerson - [346172] Support zoom, print, and save as image actions in the diagram editor > ******************************************************************************/ > > package org.eclipse.sapphire.ui.def; >@@ -55,6 +56,7 @@ > SapphireActionSystem.CONTEXT_SECTION, > SapphireActionSystem.CONTEXT_VALUE_PROPERTY_EDITOR, > SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR, >+ SapphireActionSystem.CONTEXT_DIAGRAM_HEADER, > SapphireActionSystem.CONTEXT_DIAGRAM, > SapphireActionSystem.CONTEXT_DIAGRAM_NODE, > SapphireActionSystem.CONTEXT_DIAGRAM_NODE_HIDDEN, >Index: src/org/eclipse/sapphire/ui/diagram/actions/ZoomActualDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/actions/ZoomActualDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/diagram/actions/ZoomActualDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/actions/ZoomActualDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/****************************************************************************** >+ * Copyright (c) 2012 Liferay >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Gregory Amerson - initial implementation >+ ******************************************************************************/ >+ >+package org.eclipse.sapphire.ui.diagram.actions; >+ >+import org.eclipse.sapphire.Event; >+import org.eclipse.sapphire.Listener; >+import org.eclipse.sapphire.ui.SapphireAction; >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.def.ActionHandlerDef; >+import org.eclipse.sapphire.ui.diagram.SapphireDiagramActionHandler; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart.ZoomLevelChangedEvent; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class ZoomActualDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ public void init( SapphireAction action, ActionHandlerDef def ) >+ { >+ super.init( action, def ); >+ >+ this.getPart().nearest( SapphireDiagramEditorPagePart.class ).attach >+ ( >+ new Listener() >+ { >+ @Override >+ public void handle( Event event ) >+ { >+ if( event instanceof ZoomLevelChangedEvent ) >+ { >+ broadcast( new EnablementChangedEvent() ); >+ } >+ } >+ } >+ ); >+ } >+ >+ @Override >+ public boolean isEnabled() >+ { >+ int zoomLevel = >+ ZoomActualDiagramActionHandler.this.getPart().nearest( SapphireDiagramEditorPagePart.class ).getZoomLevel(); >+ >+ return zoomLevel != 100; >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ final SapphireDiagramEditorPagePart diagramEditorPart = >+ this.getPart().nearest( SapphireDiagramEditorPagePart.class ); >+ >+ diagramEditorPart.setZoomLevel( 100 ); >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/actions/ZoomInDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/actions/ZoomInDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/diagram/actions/ZoomInDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/actions/ZoomInDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/****************************************************************************** >+ * Copyright (c) 2012 Liferay >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Gregory Amerson - initial implementation >+ ******************************************************************************/ >+ >+package org.eclipse.sapphire.ui.diagram.actions; >+ >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.SapphireDiagramActionHandler; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class ZoomInDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ final SapphireDiagramEditorPagePart diagramEditorPart = >+ this.getPart().nearest( SapphireDiagramEditorPagePart.class ); >+ >+ diagramEditorPart.setZoomLevel( diagramEditorPart.getZoomLevel() + 25 ); >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/actions/ZoomOutDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/actions/ZoomOutDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/diagram/actions/ZoomOutDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/actions/ZoomOutDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/****************************************************************************** >+ * Copyright (c) 2012 Liferay >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Gregory Amerson - initial implementation >+ ******************************************************************************/ >+ >+package org.eclipse.sapphire.ui.diagram.actions; >+ >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.SapphireDiagramActionHandler; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class ZoomOutDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ final SapphireDiagramEditorPagePart diagramEditorPart = >+ this.getPart().nearest( SapphireDiagramEditorPagePart.class ); >+ >+ diagramEditorPart.setZoomLevel( diagramEditorPart.getZoomLevel() - 25 ); >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPagePart.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPagePart.java,v >retrieving revision 1.38 >diff -u -r1.38 SapphireDiagramEditorPagePart.java >--- src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPagePart.java 9 May 2012 16:00:45 -0000 1.38 >+++ src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPagePart.java 19 May 2012 01:47:58 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2012 Oracle >+ * Copyright (c) 2012 Oracle and Liferay > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,7 +9,8 @@ > * Shenxue Zhou - initial implementation and ongoing maintenance > * Konstantin Komissarchik - [342897] Integrate with properties view > * Ling Hao - [344319] Image specification for diagram parts inconsistent with the rest of sdef >- * Konstantin Komissarchik - [375770] Support context menu actions when multiple diagram parts are selected >+ * Konstantin Komissarchik - [375770] Support context menu actions when multiple diagram parts are selected >+ * Gregory Amerson - [346172] Support zoom, print, and save as image actions in the diagram editor > ******************************************************************************/ > > package org.eclipse.sapphire.ui.diagram.editor; >@@ -73,6 +74,7 @@ > private int verticalGridUnit; > private List<FunctionResult> connectionImageDataFunctionResults; > private Point mouseLocation; >+ private int zoomLevel = 100; // zoomLevel cooresponds to 100%, 25 would be 25%, 200 would be 200% > > @Override > protected void init() >@@ -245,6 +247,20 @@ > } > } > >+ public int getZoomLevel() >+ { >+ return this.zoomLevel; >+ } >+ >+ public void setZoomLevel(int level) >+ { >+ if( this.zoomLevel != level ) >+ { >+ this.zoomLevel = level; >+ broadcast( new ZoomLevelChangedEvent() ); >+ } >+ } >+ > public int getGridUnit() > { > return this.gridUnit; >@@ -1031,4 +1047,6 @@ > } > > } >+ >+ public static final class ZoomLevelChangedEvent extends Event {} > } >#P org.eclipse.sapphire.ui.swt.gef >Index: META-INF/sapphire-extension.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui.swt.gef/META-INF/sapphire-extension.xml,v >retrieving revision 1.7 >diff -u -r1.7 sapphire-extension.xml >--- META-INF/sapphire-extension.xml 9 May 2012 16:00:47 -0000 1.7 >+++ META-INF/sapphire-extension.xml 19 May 2012 01:48:01 -0000 >@@ -2,7 +2,7 @@ > > <!-- > ****************************************************************************** >- * Copyright (c) 2012 Oracle >+ * Copyright (c) 2012 Oracle and Liferay > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,7 @@ > * > * Contributors: > * Ling Hao - initial implementation and ongoing maintenance >+ * Gregory Amerson - [346172] Support zoom, print, and save as image actions in the diagram editor > ****************************************************************************** > --> > >@@ -40,4 +41,16 @@ > <context>Sapphire.Diagram.Node.Hidden</context> > <context>Sapphire.Diagram.Connection.Hidden</context> > </action-handler> >+ <action-handler> >+ <action>Sapphire.Diagram.Print</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.swt.gef.actions.PrintDiagramActionHandler</impl> >+ </action-handler> >+ <action-handler> >+ <action>Sapphire.Diagram.Save.As.Image</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.swt.gef.actions.SaveAsImageDiagramActionHandler</impl> >+ </action-handler> > </extension> >\ No newline at end of file >Index: src/org/eclipse/sapphire/ui/swt/gef/SapphireDiagramEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui.swt.gef/src/org/eclipse/sapphire/ui/swt/gef/SapphireDiagramEditor.java,v >retrieving revision 1.18 >diff -u -r1.18 SapphireDiagramEditor.java >--- src/org/eclipse/sapphire/ui/swt/gef/SapphireDiagramEditor.java 17 May 2012 19:47:39 -0000 1.18 >+++ src/org/eclipse/sapphire/ui/swt/gef/SapphireDiagramEditor.java 19 May 2012 01:48:02 -0000 >@@ -11,6 +11,7 @@ > * Shenxue Zhou - [365019] SapphireDiagramEditor does not work on non-workspace files > * Gregory Amerson - [374022] SapphireGraphicalEditor init with SapphireEditor > * Konstantin Komissarchik - [376245] Revert action in StructuredTextEditor does not revert diagram nodes and connections in SapphireDiagramEditor >+ * Gregory Amerson - [346172] Support zoom, print, and save as image actions in the diagram editor > ******************************************************************************/ > > package org.eclipse.sapphire.ui.swt.gef; >@@ -78,6 +79,7 @@ > import org.eclipse.sapphire.ui.diagram.editor.DiagramPageEvent; > import org.eclipse.sapphire.ui.diagram.editor.DiagramPartEvent; > import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart.ZoomLevelChangedEvent; > import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramPartListener; > import org.eclipse.sapphire.ui.diagram.layout.DiagramLayoutPersistenceService; > import org.eclipse.sapphire.ui.internal.SapphireUiFrameworkPlugin; >@@ -153,7 +155,7 @@ > private SizeCache bodyCache = new SizeCache(); > private SizeCache headCache = new SizeCache(); > private FormColors formColors; >- private Listener diagramHeaderImageListener; >+ private Listener diagramEditorPagePartListener; > > private SapphireActionHandlerDelegate selectAllAction; > private SapphireActionHandlerDelegate deleteAction; >@@ -339,7 +341,7 @@ > > this.layoutPersistenceService.attach(this.layoutPersistenceServiceListener); > >- this.diagramHeaderImageListener = new Listener() >+ this.diagramEditorPagePartListener = new Listener() > { > @Override > public void handle( final Event event ) >@@ -348,11 +350,14 @@ > { > refreshFormHeaderImage(); > } >+ else if( event instanceof ZoomLevelChangedEvent ) >+ { >+ refreshZoomLevel(); >+ } > } > }; > >- this.diagramPart.attach( this.diagramHeaderImageListener ); >- >+ this.diagramPart.attach( this.diagramEditorPagePartListener ); > } > > public IDiagramEditorPageDef getDiagramEditorPageDef() >@@ -1022,7 +1027,7 @@ > layoutPersistenceService.dispose(); > } > >- this.diagramPart.detach( this.diagramHeaderImageListener ); >+ this.diagramPart.detach( this.diagramEditorPagePartListener ); > final Image image = this.header.getImage(); > if( image != null ) > { >@@ -1114,6 +1119,22 @@ > } > > } >+ >+ private void refreshZoomLevel() >+ { >+ int zoomLevel = this.diagramPart.getZoomLevel(); >+ >+ double zoom = (double) zoomLevel / 100; >+ >+ getZoomManager().setZoom( zoom ); >+ } >+ >+ private ZoomManager getZoomManager() >+ { >+ GraphicalViewer graphicalViewer = (GraphicalViewer) getAdapter( GraphicalViewer.class ); >+ >+ return (ZoomManager) graphicalViewer.getProperty( ZoomManager.class.toString() ); >+ } > > private SapphireDiagramOutline getDiagramOutline() > { >Index: src/org/eclipse/sapphire/ui/swt/gef/actions/PrintDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/swt/gef/actions/PrintDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/swt/gef/actions/PrintDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/swt/gef/actions/PrintDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/****************************************************************************** >+ * Copyright (c) 2012 Liferay >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Gregory Amerson - initial implementation >+ ******************************************************************************/ >+ >+package org.eclipse.sapphire.ui.swt.gef.actions; >+ >+import org.eclipse.gef.ui.actions.PrintAction; >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.SapphireDiagramActionHandler; >+import org.eclipse.sapphire.ui.swt.gef.DiagramRenderingContext; >+import org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class PrintDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ DiagramRenderingContext diagramContext = (DiagramRenderingContext) context; >+ SapphireDiagramEditor diagramEditor = diagramContext.getDiagramEditor(); >+ >+ if( diagramEditor != null ) >+ { >+ new PrintAction( diagramEditor ).run(); >+ } >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/****************************************************************************** >+ * Copyright (c) 2012 Liferay >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Gregory Amerson - initial implementation >+ ******************************************************************************/ >+ >+package org.eclipse.sapphire.ui.swt.gef.actions; >+ >+import java.io.FileOutputStream; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.SWTGraphics; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.gef.GraphicalViewer; >+import org.eclipse.gef.LayerConstants; >+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; >+import org.eclipse.sapphire.modeling.util.NLS; >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.SapphireDiagramActionHandler; >+import org.eclipse.sapphire.ui.swt.gef.DiagramRenderingContext; >+import org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.GC; >+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 org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IFileEditorInput; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class SaveAsImageDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ DiagramRenderingContext diagramContext = (DiagramRenderingContext) context; >+ SapphireDiagramEditor diagramEditor = diagramContext.getDiagramEditor(); >+ >+ if( diagramEditor != null ) >+ { >+ FileDialog dialog = new FileDialog( context.getShell(), SWT.SAVE ); >+ >+ IEditorInput editorInput = diagramEditor.getPart().adapt( IEditorInput.class ); >+ >+ if( editorInput instanceof IFileEditorInput ) >+ { >+ dialog.setFilterPath( ( (IFileEditorInput) editorInput ).getFile().getParent().getRawLocation().toOSString() ); >+ } >+ >+ dialog.setFileName( editorInput.getName().replaceAll( ".xml", ".png" ) ); >+ >+ dialog.setFilterExtensions( new String[] { "*.png" } ); >+ >+ dialog.setText( Resources.saveAsImageMessage ); >+ >+ dialog.setOverwrite( true ); >+ >+ String filePath = dialog.open(); >+ >+ if( filePath == null ) >+ { >+ return null; >+ } >+ >+ GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor.getAdapter( GraphicalViewer.class ); >+ >+ ScalableFreeformRootEditPart rootEditPart = >+ (ScalableFreeformRootEditPart) graphicalViewer.getRootEditPart(); >+ >+ IFigure figure = rootEditPart.getLayer( LayerConstants.PRINTABLE_LAYERS ); >+ >+ Rectangle rectangle = figure.getBounds(); >+ >+ Image image = new Image( Display.getDefault(), rectangle.width, rectangle.height ); >+ >+ GC gc = new GC( image ); >+ SWTGraphics graphics = new SWTGraphics( gc ); >+ figure.paint( graphics ); >+ >+ ImageLoader loader = new ImageLoader(); >+ loader.data = new ImageData[] { image.getImageData() }; >+ >+ try >+ { >+ final FileOutputStream output = new FileOutputStream( filePath ); >+ >+ loader.save( output, SWT.IMAGE_PNG ); >+ output.flush(); >+ output.close(); >+ >+ image.dispose(); >+ gc.dispose(); >+ graphics.dispose(); >+ } >+ catch( Exception e ) >+ { >+ } >+ >+ } >+ >+ return null; >+ } >+ >+ private static final class Resources extends NLS >+ { >+ public static String saveAsImageMessage; >+ >+ static >+ { >+ initializeMessages( SaveAsImageDiagramActionHandler.class.getName(), Resources.class ); >+ } >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.properties >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.properties >diff -N src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/swt/gef/actions/SaveAsImageDiagramActionHandler.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+saveAsImageMessage = Save as image >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
konstantin
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 346172
:
215832
|
215833
|
215834
|
215835
|
215836
|
215838
|
215874
|
215877
|
215880
| 215891 |
215927
|
215928
|
215934