Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 346172 | Differences between
and this patch

Collapse All | Expand All

(-)html/releases/0.5/enhancements.html (+17 lines)
Lines 10-15 Link Here
10
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
11
 *    Gregory Amerson - [372359] Provide means to extend the behavior of adapt methods
11
 *    Gregory Amerson - [372359] Provide means to extend the behavior of adapt methods
12
 *    Gregory Amerson - [358295] Need access to selection in list property editor
12
 *    Gregory Amerson - [358295] Need access to selection in list property editor
13
 *    Gregory Amerson - [346172] Support zoom, print and save as image actions
13
 ******************************************************************************
14
 ******************************************************************************
14
-->
15
-->
15
16
Lines 244-249 Link Here
244
<p>Select all diagram parts or just the nodes using a pair of new actions. Alternatively, use
245
<p>Select all diagram parts or just the nodes using a pair of new actions. Alternatively, use
245
Ctrl + A key binding to select everything.</p>
246
Ctrl + A key binding to select everything.</p>
246
247
248
<p>Zoom actions have been added to both diagram header and diagram context menu.  Actions for
249
zoom in, zoom out, and zoom actual have been added.  Also, the state of the zoom will be persisted per resource
250
so that the zoom level of the diagram will be restored between editing sessions.
251
</p>
252
253
<p>Print action has been added to both diagram header and the diagram context menu.  This just invokes the standard
254
GEF print action for the current diagram.
255
</p>
256
257
<p>A &quot;Save as Image&quot; action has been added to both diagram header and the diagram context menu.  This 
258
action will open a dialog to prompt the user for a location to export the current diagram as a PNG image.
259
</p>
260
261
<p>
262
<img src="images/DiagramHeaderActions.png" />
263
</p>
247
264
248
<h2><a name="MutipleDiagramPartsActions">Actions for Multiple Diagram Parts</a></h2>
265
<h2><a name="MutipleDiagramPartsActions">Actions for Multiple Diagram Parts</a></h2>
249
266
(-)META-INF/MANIFEST.MF (-3 / +4 lines)
Lines 15-20 Link Here
15
 org.eclipse.sapphire.ui.diagram.def,
15
 org.eclipse.sapphire.ui.diagram.def,
16
 org.eclipse.sapphire.ui.diagram.editor,
16
 org.eclipse.sapphire.ui.diagram.editor,
17
 org.eclipse.sapphire.ui.diagram.layout,
17
 org.eclipse.sapphire.ui.diagram.layout,
18
 org.eclipse.sapphire.ui.diagram.layout.standard;x-friends:="org.eclipse.sapphire.ui.swt.gef,org.eclipse.sapphire.workspace.ui",
19
 org.eclipse.sapphire.ui.diagram.state,
20
 org.eclipse.sapphire.ui.diagram.state.internal,
18
 org.eclipse.sapphire.ui.form.editors.masterdetails,
21
 org.eclipse.sapphire.ui.form.editors.masterdetails,
19
 org.eclipse.sapphire.ui.form.editors.masterdetails.def,
22
 org.eclipse.sapphire.ui.form.editors.masterdetails.def,
20
 org.eclipse.sapphire.ui.internal,
23
 org.eclipse.sapphire.ui.internal,
Lines 24-32 Link Here
24
 org.eclipse.sapphire.ui.swt,
27
 org.eclipse.sapphire.ui.swt,
25
 org.eclipse.sapphire.ui.swt.renderer,
28
 org.eclipse.sapphire.ui.swt.renderer,
26
 org.eclipse.sapphire.ui.swt.renderer.actions,
29
 org.eclipse.sapphire.ui.swt.renderer.actions,
27
 org.eclipse.sapphire.ui.util,
30
 org.eclipse.sapphire.ui.util
28
 org.eclipse.sapphire.ui.diagram.layout,
29
 org.eclipse.sapphire.ui.diagram.layout.standard;x-friends:="org.eclipse.sapphire.ui.swt.gef,org.eclipse.sapphire.workspace.ui"
30
Require-Bundle: org.eclipse.sapphire.modeling,
31
Require-Bundle: org.eclipse.sapphire.modeling,
31
 org.eclipse.sapphire.modeling.xml,
32
 org.eclipse.sapphire.modeling.xml,
32
 org.eclipse.sapphire.java,
33
 org.eclipse.sapphire.java,
(-)src/org/eclipse/sapphire/ui/SapphirePart.java (-1 / +2 lines)
Lines 10-15 Link Here
10
 *    Ling Hao - [329114] rewrite context help binding feature
10
 *    Ling Hao - [329114] rewrite context help binding feature
11
 *    Gregory Amerson - [372816] Provide adapt mechanism for SapphirePart
11
 *    Gregory Amerson - [372816] Provide adapt mechanism for SapphirePart
12
 *    Gregory Amerson - [373614] Suppport AdapterService in SapphirePart
12
 *    Gregory Amerson - [373614] Suppport AdapterService in SapphirePart
13
 *    Gregory Amerson - [346172] Support zoom, print and save as image actions
13
 ******************************************************************************/
14
 ******************************************************************************/
14
15
15
package org.eclipse.sapphire.ui;
16
package org.eclipse.sapphire.ui;
Lines 537-543 Link Here
537
            }
538
            }
538
        }
539
        }
539
540
540
        if( result == null )
541
        if( result == null && getLocalModelElement() != null)
541
        {
542
        {
542
            result = getLocalModelElement().adapt( adapterType );
543
            result = getLocalModelElement().adapt( adapterType );
543
        }
544
        }
(-)src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPagePart.java (-7 / +42 lines)
Lines 16-21 Link Here
16
16
17
package org.eclipse.sapphire.ui.diagram.editor;
17
package org.eclipse.sapphire.ui.diagram.editor;
18
18
19
import java.io.File;
19
import java.util.ArrayList;
20
import java.util.ArrayList;
20
import java.util.Collections;
21
import java.util.Collections;
21
import java.util.HashMap;
22
import java.util.HashMap;
Lines 31-43 Link Here
31
import org.eclipse.sapphire.modeling.ImpliedElementProperty;
32
import org.eclipse.sapphire.modeling.ImpliedElementProperty;
32
import org.eclipse.sapphire.modeling.ModelElementList;
33
import org.eclipse.sapphire.modeling.ModelElementList;
33
import org.eclipse.sapphire.modeling.ModelProperty;
34
import org.eclipse.sapphire.modeling.ModelProperty;
35
import org.eclipse.sapphire.modeling.ResourceStoreException;
34
import org.eclipse.sapphire.modeling.el.FunctionResult;
36
import org.eclipse.sapphire.modeling.el.FunctionResult;
37
import org.eclipse.sapphire.modeling.xml.RootXmlResource;
38
import org.eclipse.sapphire.modeling.xml.XmlResourceStore;
35
import org.eclipse.sapphire.ui.IPropertiesViewContributorPart;
39
import org.eclipse.sapphire.ui.IPropertiesViewContributorPart;
36
import org.eclipse.sapphire.ui.ISapphirePart;
40
import org.eclipse.sapphire.ui.ISapphirePart;
37
import org.eclipse.sapphire.ui.Point;
41
import org.eclipse.sapphire.ui.Point;
38
import org.eclipse.sapphire.ui.PropertiesViewContributionManager;
42
import org.eclipse.sapphire.ui.PropertiesViewContributionManager;
39
import org.eclipse.sapphire.ui.PropertiesViewContributionPart;
43
import org.eclipse.sapphire.ui.PropertiesViewContributionPart;
40
import org.eclipse.sapphire.ui.SapphireActionSystem;
44
import org.eclipse.sapphire.ui.SapphireActionSystem;
45
import org.eclipse.sapphire.ui.SapphireEditor;
41
import org.eclipse.sapphire.ui.SapphireEditorPagePart;
46
import org.eclipse.sapphire.ui.SapphireEditorPagePart;
42
import org.eclipse.sapphire.ui.SapphirePart;
47
import org.eclipse.sapphire.ui.SapphirePart;
43
import org.eclipse.sapphire.ui.SapphirePartListener;
48
import org.eclipse.sapphire.ui.SapphirePartListener;
Lines 47-52 Link Here
47
import org.eclipse.sapphire.ui.diagram.def.IDiagramExplicitConnectionBindingDef;
52
import org.eclipse.sapphire.ui.diagram.def.IDiagramExplicitConnectionBindingDef;
48
import org.eclipse.sapphire.ui.diagram.def.IDiagramImplicitConnectionBindingDef;
53
import org.eclipse.sapphire.ui.diagram.def.IDiagramImplicitConnectionBindingDef;
49
import org.eclipse.sapphire.ui.diagram.def.IDiagramNodeDef;
54
import org.eclipse.sapphire.ui.diagram.def.IDiagramNodeDef;
55
import org.eclipse.sapphire.ui.diagram.state.SapphireDiagramEditorPageState;
56
import org.eclipse.sapphire.ui.form.editors.masterdetails.state.IMasterDetailsEditorPageState;
57
import org.eclipse.sapphire.ui.internal.SapphireUiFrameworkPlugin;
50
import org.eclipse.sapphire.util.ReadOnlyListFactory;
58
import org.eclipse.sapphire.util.ReadOnlyListFactory;
51
59
52
/**
60
/**
Lines 76-87 Link Here
76
    private int verticalGridUnit;
84
    private int verticalGridUnit;
77
	private List<FunctionResult> connectionImageDataFunctionResults;
85
	private List<FunctionResult> connectionImageDataFunctionResults;
78
	private Point mouseLocation;
86
	private Point mouseLocation;
79
    private int zoomLevel = 100; // zoomLevel corresponds to 100%, 25 would be 25%, 200 would be 200%
87
    private SapphireDiagramEditorPageState state;
80
88
81
    @Override
89
    @Override
82
    protected void init()
90
    protected void init()
83
    {
91
    {
84
        super.init();
92
        super.init();
93
        
94
        try
95
        {
96
            final File stateFile = adapt( SapphireEditor.class ).getDefaultStateStorageFile( this );
97
            this.state = SapphireDiagramEditorPageState.TYPE.instantiate( new RootXmlResource( new XmlResourceStore( stateFile ) ) );
98
        }
99
        catch( ResourceStoreException e )
100
        {
101
            this.state = SapphireDiagramEditorPageState.TYPE.instantiate();
102
        }
85
            
103
            
86
        this.diagramPageDef = (IDiagramEditorPageDef)super.definition;
104
        this.diagramPageDef = (IDiagramEditorPageDef)super.definition;
87
        ImpliedElementProperty modelElementProperty = (ImpliedElementProperty)resolve(this.diagramPageDef.getProperty().getContent());
105
        ImpliedElementProperty modelElementProperty = (ImpliedElementProperty)resolve(this.diagramPageDef.getProperty().getContent());
Lines 256-272 Link Here
256
    
274
    
257
    public int getMaxZoomLevel()
275
    public int getMaxZoomLevel()
258
    {
276
    {
259
        return 200;
277
        return 400;
260
    }
278
    }
261
    
279
    
262
    public int getZoomLevel()
280
    public int getZoomLevel()
263
    {
281
    {
264
        return this.zoomLevel;
282
        return getState().getZoomLevel().getContent( true );
265
    }
283
    }
266
    
284
    
267
    public void setZoomLevel( final int level )
285
    public void setZoomLevel( final int level )
268
    {
286
    {
269
        if( this.zoomLevel != level )
287
        final Integer currentZoomLevel = getState().getZoomLevel().getContent( true );
288
        
289
        if( currentZoomLevel != level )
270
        {
290
        {
271
            int newZoomLevel = level;
291
            int newZoomLevel = level;
272
            
292
            
Lines 286-300 Link Here
286
                }
306
                }
287
            }
307
            }
288
            
308
            
289
            if( this.zoomLevel != newZoomLevel )
309
            if( currentZoomLevel != newZoomLevel )
290
            {
310
            {
291
                final int oldZoomLevel = this.zoomLevel;
311
                final int oldZoomLevel = currentZoomLevel;
292
                this.zoomLevel = level;
312
                getState().setZoomLevel( level );
313
                
314
                try
315
                {
316
                    getState().resource().save();
317
                }
318
                catch( ResourceStoreException e )
319
                {
320
                    SapphireUiFrameworkPlugin.log( e );
321
                }
322
                
293
                broadcast( new ZoomLevelEvent( this, oldZoomLevel, newZoomLevel ) );
323
                broadcast( new ZoomLevelEvent( this, oldZoomLevel, newZoomLevel ) );
294
            }
324
            }
295
        }
325
        }
296
    }
326
    }
297
    
327
    
328
    public final SapphireDiagramEditorPageState getState()
329
    {
330
        return this.state;
331
    }
332
    
298
    public int getGridUnit()
333
    public int getGridUnit()
299
    {
334
    {
300
    	return this.gridUnit;
335
    	return this.gridUnit;
(-)src/org/eclipse/sapphire/ui/diagram/state/SapphireDiagramEditorPageState.java (+43 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2012 Liferay
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Gregory Amerson - initial implementation   
10
 ******************************************************************************/
11
12
package org.eclipse.sapphire.ui.diagram.state;
13
14
import org.eclipse.sapphire.modeling.IModelElement;
15
import org.eclipse.sapphire.modeling.ModelElementType;
16
import org.eclipse.sapphire.modeling.Value;
17
import org.eclipse.sapphire.modeling.ValueProperty;
18
import org.eclipse.sapphire.modeling.annotations.DefaultValue;
19
import org.eclipse.sapphire.modeling.annotations.GenerateImpl;
20
import org.eclipse.sapphire.modeling.annotations.Type;
21
import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding;
22
23
/**
24
 * @author <a href="mailto:gregory.amerson@liferay.com">Gregory Amerson</a>
25
 */
26
@XmlBinding( path = "sapphire-diagram-editor-page-state" )
27
@GenerateImpl
28
public interface SapphireDiagramEditorPageState extends IModelElement
29
{
30
    ModelElementType TYPE = new ModelElementType( SapphireDiagramEditorPageState.class );    
31
    
32
    // *** ZoomLevel ***
33
    
34
    @Type( base = Integer.class )
35
    @DefaultValue( text = "100" )
36
    @XmlBinding( path = "zoom-level" )
37
38
    ValueProperty PROP_ZOOM_LEVEL = new ValueProperty( TYPE, "ZoomLevel" );
39
    
40
    Value<Integer> getZoomLevel();
41
    void setZoomLevel( String value );
42
    void setZoomLevel( Integer value );
43
}
(-)src/org/eclipse/sapphire/ui/swt/gef/SapphireDiagramEditor.java (-3 / +12 lines)
Lines 834-839 Link Here
834
		// context button manager
834
		// context button manager
835
		contextButtonManager = new ContextButtonManager(this);
835
		contextButtonManager = new ContextButtonManager(this);
836
		
836
		
837
		Integer zoomLevel = this.getPart().getState().getZoomLevel().getContent( true );
838
        
839
		double zoom = (double) zoomLevel / 100;
840
        
841
        getZoomManager().setZoom( zoom );
837
	}
842
	}
838
			
843
			
839
	@Override
844
	@Override
Lines 1005-1018 Link Here
1005
		ret.x += viewLocation.x;
1010
		ret.x += viewLocation.x;
1006
		ret.y += viewLocation.y;
1011
		ret.y += viewLocation.y;
1007
1012
1008
		ZoomManager zoomManager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
1013
		if ( getZoomManager() != null)
1009
		if (zoomManager != null)
1010
		{
1014
		{
1011
			ret = ret.getScaled(1 / zoomManager.getZoom());
1015
			ret = ret.getScaled(1 / getZoomManager().getZoom());
1012
		}
1016
		}
1013
1017
1014
		return ret;
1018
		return ret;
1015
	}
1019
	}
1020
    
1021
	private ZoomManager getZoomManager()
1022
	{
1023
	    return (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
1024
	}
1016
	
1025
	
1017
1026
1018
	@Override
1027
	@Override

Return to bug 346172