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 343972 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/sapphire/samples/gallery/GalleryEditor.sdef (+2 lines)
Lines 11-16 Link Here
11
 * Contributors:
11
 * Contributors:
12
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
12
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
13
 *    Greg Amerson - [342771] Support "image+label" hint for when actions are presented in a toolbar
13
 *    Greg Amerson - [342771] Support "image+label" hint for when actions are presented in a toolbar
14
 *    Greg Amerson - [bugzilla 343972] - Add support for setting the masterDetails formPage header image
14
 ******************************************************************************
15
 ******************************************************************************
15
-->
16
-->
16
17
Lines 39-44 Link Here
39
    <editor-page>
40
    <editor-page>
40
        <id>main</id>
41
        <id>main</id>
41
        <page-header-text>sapphire gallery</page-header-text>
42
        <page-header-text>sapphire gallery</page-header-text>
43
        <page-header-image>Prefix.png</page-header-image>
42
        <initial-selection>simple values</initial-selection>
44
        <initial-selection>simple values</initial-selection>
43
        <documentation>
45
        <documentation>
44
            <title>Sapphire Gallery</title>
46
            <title>Sapphire Gallery</title>
(-)src/org/eclipse/sapphire/sdk/DefinitionEditor.sdef (+2 lines)
Lines 8-13 Link Here
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
11
 *    Greg Amerson - [bugzilla 343972] - Add support for setting the masterDetails formPage header image
11
 ******************************************************************************
12
 ******************************************************************************
12
-->
13
-->
13
14
Lines 991-996 Link Here
991
                    <include>PartId</include>
992
                    <include>PartId</include>
992
                    <property-editor>PageName</property-editor>
993
                    <property-editor>PageName</property-editor>
993
                    <property-editor>PageHeaderText</property-editor>
994
                    <property-editor>PageHeaderText</property-editor>
995
                    <property-editor>PageHeaderImage</property-editor>
994
                    <property-editor>OutlineHeaderText</property-editor>
996
                    <property-editor>OutlineHeaderText</property-editor>
995
                    <property-editor>InitialSelectionPath</property-editor>
997
                    <property-editor>InitialSelectionPath</property-editor>
996
                </content>
998
                </content>
(-)src/org/eclipse/sapphire/ui/SapphireEditorFormPage.java (+43 lines)
Lines 8-18 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 *    Ling Hao - [bugzilla 329114] rewrite context help binding feature
10
 *    Ling Hao - [bugzilla 329114] rewrite context help binding feature
11
 *    Greg Amerson - [bugzilla 343972] - Add support for setting the masterDetails formPage header image
11
 ******************************************************************************/
12
 ******************************************************************************/
12
13
13
package org.eclipse.sapphire.ui;
14
package org.eclipse.sapphire.ui;
14
15
16
import static org.eclipse.sapphire.ui.renderers.swt.SwtRendererUtil.toImageDescriptor;
17
15
import org.eclipse.sapphire.modeling.IModelElement;
18
import org.eclipse.sapphire.modeling.IModelElement;
19
import org.eclipse.sapphire.ui.SapphirePart.ImageChangedEvent;
20
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.ui.forms.editor.FormPage;
21
import org.eclipse.ui.forms.editor.FormPage;
17
22
18
/**
23
/**
Lines 26-31 Link Here
26
{
31
{
27
    private final SapphireEditor editor;
32
    private final SapphireEditor editor;
28
    private final SapphireEditorPagePart part;
33
    private final SapphireEditorPagePart part;
34
    private final SapphirePartListener listener;
29
    
35
    
30
    public SapphireEditorFormPage( final SapphireEditor editor,
36
    public SapphireEditorFormPage( final SapphireEditor editor,
31
                                   final SapphireEditorPagePart editorPagePart ) 
37
                                   final SapphireEditorPagePart editorPagePart ) 
Lines 34-39 Link Here
34
40
35
        this.editor = editor;
41
        this.editor = editor;
36
        this.part = editorPagePart;
42
        this.part = editorPagePart;
43
        
44
        this.listener = new SapphirePartListener()
45
        {
46
            @Override
47
            public void handleEvent( final SapphirePartEvent event )
48
            {
49
                if( event instanceof ImageChangedEvent )
50
                {
51
                    refreshImage();
52
                }
53
            }
54
        };
55
        
56
        this.part.addListener( this.listener );
37
    }
57
    }
38
    
58
    
39
    public final SapphireEditor getEditor()
59
    public final SapphireEditor getEditor()
Lines 51-56 Link Here
51
        return this.part.getModelElement();
71
        return this.part.getModelElement();
52
    }
72
    }
53
    
73
    
74
   @Override
75
    public void createPartControl(Composite parent) {
76
	   super.createPartControl(parent);
77
	   
78
	   refreshImage();
79
    } 
80
    
81
    private final void refreshImage()
82
    {
83
    	if (this.getManagedForm() != null)
84
    	{
85
    		this.getManagedForm().getForm().setImage( toImageDescriptor( this.part.getPageHeaderImage() ).createImage() );
86
    	}
87
    }
88
89
    @Override
90
    public void dispose()
91
    {
92
        super.dispose();
93
        
94
        this.part.removeListener( this.listener );
95
    }
96
    
54
    public abstract String getId();
97
    public abstract String getId();
55
    
98
    
56
}
99
}
(-)src/org/eclipse/sapphire/ui/SapphireEditorPagePart.java (+44 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 *    Greg Amerson - [bugzilla 343972] - Add support for setting the masterDetails formPage header image
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.sapphire.ui;
13
package org.eclipse.sapphire.ui;
Lines 15-20 Link Here
15
import java.util.Set;
16
import java.util.Set;
16
17
17
import org.eclipse.help.IContext;
18
import org.eclipse.help.IContext;
19
import org.eclipse.sapphire.modeling.IModelElement;
20
import org.eclipse.sapphire.modeling.ImageData;
21
import org.eclipse.sapphire.modeling.el.FunctionResult;
18
import org.eclipse.sapphire.ui.def.IEditorPageDef;
22
import org.eclipse.sapphire.ui.def.IEditorPageDef;
19
import org.eclipse.sapphire.ui.def.ISapphireDocumentation;
23
import org.eclipse.sapphire.ui.def.ISapphireDocumentation;
20
import org.eclipse.sapphire.ui.def.ISapphireDocumentationDef;
24
import org.eclipse.sapphire.ui.def.ISapphireDocumentationDef;
Lines 32-37 Link Here
32
    
36
    
33
{
37
{
34
    private PropertiesViewContributionPart propertiesViewContributionPart;
38
    private PropertiesViewContributionPart propertiesViewContributionPart;
39
    private FunctionResult imageFunctionResult;
40
    
41
    @Override
42
    protected void init() {
43
    	super.init();
44
    	
45
    	final IModelElement element = getModelElement();
46
    	final IEditorPageDef def = getDefinition();
47
    	
48
        this.imageFunctionResult = initExpression
49
        (
50
            element,
51
            def.getPageHeaderImage().getContent(),
52
            ImageData.class,
53
            null,
54
            new Runnable()
55
            {
56
                public void run()
57
                {
58
                    notifyListeners( new ImageChangedEvent( SapphireEditorPagePart.this ) );
59
                }
60
            }
61
        );
62
    }
35
    
63
    
36
    @Override
64
    @Override
37
    public IEditorPageDef getDefinition()
65
    public IEditorPageDef getDefinition()
Lines 86-91 Link Here
86
        }
114
        }
87
    }
115
    }
88
    
116
    
117
    public ImageData getPageHeaderImage()
118
    {
119
        return (ImageData) this.imageFunctionResult.value();
120
    }
121
122
    @Override
123
    public void dispose()
124
    {
125
        super.dispose();
126
        
127
        if( this.imageFunctionResult != null )
128
        {
129
            this.imageFunctionResult.dispose();
130
        }
131
    }
132
    
89
    public static abstract class Event extends SapphirePartEvent
133
    public static abstract class Event extends SapphirePartEvent
90
    {
134
    {
91
        public Event( final SapphireEditorPagePart part )
135
        public Event( final SapphireEditorPagePart part )
(-)src/org/eclipse/sapphire/ui/def/IEditorPageDef.java (-1 / +16 lines)
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 *    Ling Hao - [bugzilla 329114] rewrite context help binding feature
10
 *    Ling Hao - [bugzilla 329114] rewrite context help binding feature
11
 ******************************************************************************/
11
 *    Greg Amerson - [bugzilla 343972] - Add support for setting the masterDetails formPage header image
12
 *******************************************************************************/
12
13
13
package org.eclipse.sapphire.ui.def;
14
package org.eclipse.sapphire.ui.def;
14
15
Lines 17-22 Link Here
17
import org.eclipse.sapphire.modeling.ValueProperty;
18
import org.eclipse.sapphire.modeling.ValueProperty;
18
import org.eclipse.sapphire.modeling.annotations.DefaultValue;
19
import org.eclipse.sapphire.modeling.annotations.DefaultValue;
19
import org.eclipse.sapphire.modeling.annotations.Label;
20
import org.eclipse.sapphire.modeling.annotations.Label;
21
import org.eclipse.sapphire.modeling.annotations.Type;
22
import org.eclipse.sapphire.modeling.el.Function;
20
import org.eclipse.sapphire.modeling.localization.Localizable;
23
import org.eclipse.sapphire.modeling.localization.Localizable;
21
import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding;
24
import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding;
22
25
Lines 57-60 Link Here
57
    Value<String> getPageHeaderText();
60
    Value<String> getPageHeaderText();
58
    void setPageHeaderText( String pageHeaderText );
61
    void setPageHeaderText( String pageHeaderText );
59
    
62
    
63
    // *** PageHeaderImage ***
64
    
65
    @Type( base = Function.class )
66
    @Label( standard = "page header image" )
67
    @XmlBinding( path = "page-header-image" )
68
    
69
    ValueProperty PROP_PAGE_HEADER_IMAGE = new ValueProperty( TYPE, "PageHeaderImage" );
70
    
71
    Value<Function> getPageHeaderImage();
72
    void setPageHeaderImage( String value );
73
    void setPageHeaderImage( Function value );
74
    
60
}
75
}

Return to bug 343972