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 215832 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 v1
Patch (text/plain), 16.09 KB, created by
Greg Amerson
on 2012-05-18 03:58:16 EDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
Greg Amerson
Created:
2012-05-18 03:58:16 EDT
Size:
16.09 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 18 May 2012 07:54:38 -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] [diagram] Add print, zoom, save as image actions > ****************************************************************************** > --> > >@@ -216,6 +217,26 @@ > <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.Appearance</group> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> >+ <action> >+ <id>Sapphire.Diagram.Zoom.Out</id> >+ <label>zoom in</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.Appearance</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 +268,23 @@ > <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> >+ <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> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ </action> > > <action-handler> > <action>Sapphire.Browse</action> >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 18 May 2012 07:54:38 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * Konstantin Komissarchik - initial implementation and ongoing maintenance >+ * Gregory Amerson - [346172] [diagram] Add print, zoom, save as image actions > ******************************************************************************/ > > 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, >#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 18 May 2012 07:54:40 -0000 >@@ -10,6 +10,7 @@ > * > * Contributors: > * Ling Hao - initial implementation and ongoing maintenance >+ * Gregory Amerson - [346172] [diagram] Add print, zoom, save as image actions > ****************************************************************************** > --> > >@@ -40,4 +41,36 @@ > <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> >+ <action-handler> >+ <action>Sapphire.Diagram.Zoom.In</action> >+ <context>Sapphire.Diagram.Editor</context> >+ <context>Sapphire.Diagram.Header</context> >+ <impl>org.eclipse.sapphire.ui.swt.gef.actions.ZoomDiagramActionHandler</impl> >+ <param> >+ <name>zoom</name> >+ <value>in</value> >+ </param> >+ </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.swt.gef.actions.ZoomDiagramActionHandler</impl> >+ <param> >+ <name>zoom</name> >+ <value>out</value> >+ </param> >+ </action-handler> > </extension> >\ No newline at end of file >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,112 @@ >+/****************************************************************************** >+ * 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.FileNotFoundException; >+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.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( "Save as image" ); >+ >+ 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 ); >+ graphics.translate( rectangle.x * -1, rectangle.y * -1 ); >+ figure.paint( graphics ); >+ >+ ImageLoader loader = new ImageLoader(); >+ loader.data = new ImageData[] { image.getImageData() }; >+ >+ try >+ { >+ loader.save( new FileOutputStream( filePath ), SWT.IMAGE_PNG ); >+ } >+ catch( FileNotFoundException e ) >+ { >+ } >+ } >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/swt/gef/actions/ZoomDiagramActionHandler.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/swt/gef/actions/ZoomDiagramActionHandler.java >diff -N src/org/eclipse/sapphire/ui/swt/gef/actions/ZoomDiagramActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/swt/gef/actions/ZoomDiagramActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/****************************************************************************** >+ * 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.GraphicalViewer; >+import org.eclipse.gef.editparts.ZoomManager; >+import org.eclipse.gef.ui.actions.ZoomInAction; >+import org.eclipse.gef.ui.actions.ZoomOutAction; >+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.swt.gef.DiagramRenderingContext; >+import org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor; >+ >+/** >+ * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a> >+ */ >+public class ZoomDiagramActionHandler extends SapphireDiagramActionHandler >+{ >+ >+ private boolean zoomOut = true; >+ >+ @Override >+ public boolean canExecute( Object obj ) >+ { >+ return true; >+ } >+ >+ @Override >+ public void init( SapphireAction action, ActionHandlerDef def ) >+ { >+ super.init( action, def ); >+ >+ String zoom = def.getParam( "zoom" ); >+ >+ if( "in".equals( zoom ) ) >+ { >+ this.zoomOut = false; >+ } >+ } >+ >+ @Override >+ protected Object run( SapphireRenderingContext context ) >+ { >+ DiagramRenderingContext diagramContext = (DiagramRenderingContext) context; >+ SapphireDiagramEditor diagramEditor = diagramContext.getDiagramEditor(); >+ >+ if( diagramEditor != null ) >+ { >+ GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor.getAdapter( GraphicalViewer.class ); >+ >+ ZoomManager zoomManager = (ZoomManager) graphicalViewer.getProperty( ZoomManager.class.toString() ); >+ >+ if( this.zoomOut ) >+ { >+ new ZoomOutAction( zoomManager ).run(); >+ } >+ else >+ { >+ new ZoomInAction( zoomManager ).run(); >+ } >+ } >+ >+ return null; >+ } >+ >+}
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
Actions:
View
|
Diff
Attachments on
bug 346172
:
215832
|
215833
|
215834
|
215835
|
215836
|
215838
|
215874
|
215877
|
215880
|
215891
|
215927
|
215928
|
215934