View | Details | Raw Unified | Return to bug 21756 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/views/properties/IPropertySheetEntry.java (-125 / +148 lines)
Lines 13-147 Link Here
13
import org.eclipse.jface.viewers.CellEditor;
13
import org.eclipse.jface.viewers.CellEditor;
14
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Composite;
16
16
/**
17
/**
17
 * <code>IPropertySheetEntry</code> describes the model interface for the
18
 * <code>IPropertySheetEntry</code> describes the model interface for the
18
 * property sheet.
19
 * property sheet.
19
 * <p>
20
 * <p>
20
 * May be implemented when supplying a custom root entry
21
 * May be implemented when supplying a custom root entry to a property page.
21
 * to a property page.
22
 * </p>
22
 * </p>
23
 */
23
 */
24
public interface IPropertySheetEntry {
24
public interface IPropertySheetEntry {
25
	/**
25
26
	 * The filter id for expert properties
26
    /**
27
	 */
27
     * The filter id for expert properties
28
	public String FILTER_ID_EXPERT = "org.eclipse.ui.views.properties.expert"; //$NON-NLS-1$
28
     */
29
/**
29
    public String FILTER_ID_EXPERT = "org.eclipse.ui.views.properties.expert"; //$NON-NLS-1$
30
 * Adds the given listener to this entry's collection
30
31
 * of listeners.
31
    /**
32
 *
32
     * Adds the given listener to this entry's collection of listeners.
33
 * @param listener the listener to add
33
     * 
34
 */
34
     * @param listener
35
public void addPropertySheetEntryListener(IPropertySheetEntryListener listener);
35
     *            the listener to add
36
/**
36
     */
37
 * Apply the current cell editor value.
37
    public void addPropertySheetEntryListener(
38
 */
38
            IPropertySheetEntryListener listener);
39
public void applyEditorValue();
39
40
/**
40
    /**
41
 * Called when the entry is no longer needed
41
     * Apply the current cell editor value.
42
 */
42
     */
43
public void dispose();
43
    public void applyEditorValue();
44
/**
44
45
 * Returns the entry's category.
45
    /**
46
 *
46
     * Called when the entry is no longer needed
47
 * @return the entry's category
47
     */
48
 */
48
    public void dispose();
49
public String getCategory();
49
50
/**
50
    /**
51
 * Returns the child entries for this entry.
51
     * Returns the entry's category.
52
 *
52
     * 
53
 * @return the child entries for this entry
53
     * @return the entry's category
54
 */
54
     */
55
public IPropertySheetEntry[] getChildEntries();
55
    public String getCategory();
56
/**
56
57
 * Return a short description of the property sheet entry.
57
    /**
58
 * Typically this description is shown in a status line
58
     * Returns the child entries for this entry.
59
 * when the entry is selected.
59
     * 
60
 *
60
     * @return the child entries for this entry
61
 * @return the entry's description
61
     */
62
 */
62
    public IPropertySheetEntry[] getChildEntries();
63
public String getDescription();
63
64
/**
64
    /**
65
 * Returns the name used to display the property.
65
     * Return a short description of the property sheet entry. Typically this
66
 *
66
     * description is shown in a status line when the entry is selected.
67
 * @return the name used to display the property
67
     * 
68
 */
68
     * @return the entry's description
69
public String getDisplayName();
69
     */
70
/**
70
    public String getDescription();
71
 * Return the <code>CellEditor</code> used to edit the property.
71
72
 *
72
    /**
73
 * @param parent the parent widget for the editor
73
     * Returns the name used to display the property.
74
 * @return the <code>CellEditor</code> used to edit the property
74
     * 
75
 */
75
     * @return the name used to display the property
76
CellEditor getEditor(Composite parent);
76
     */
77
/**
77
    public String getDisplayName();
78
 * Returns the error text to display if the value is invalid. 
78
79
 *
79
    /**
80
 * @return the error text to display when the value is invalid
80
     * Return the <code>CellEditor</code> used to edit the property.
81
 * or <code>null</code>
81
     * 
82
 */
82
     * @param parent
83
public String getErrorText();
83
     *            the parent widget for the editor
84
/**
84
     * @return the <code>CellEditor</code> used to edit the property
85
 * Return the filter ids used to group entries into levels such as Expert.
85
     */
86
 * Valid values are defined as constants on this interface.
86
    CellEditor getEditor(Composite parent);
87
 *
87
88
 * @return the filter ids used to group entries into levels such as Expert.
88
    /**
89
 */
89
     * Returns the error text to display if the value is invalid.
90
public String[] getFilters();
90
     * 
91
/**
91
     * @return the error text to display when the value is invalid or
92
 * Returns the help context id for this entry,
92
     *         <code>null</code>
93
 * or <code>null</code> if this entry has no help context id.
93
     */
94
 * <p>
94
    public String getErrorText();
95
 * NOTE: Help support system API's changed since 2.0 and arrays
95
96
 * of contexts are no longer supported.
96
    /**
97
 * </p>
97
     * Return the filter ids used to group entries into levels such as Expert.
98
 * <p>
98
     * Valid values are defined as constants on this interface.
99
 * Thus the only valid non-<code>null</code> return type for this method
99
     * 
100
 * is a <code>String</code> representing a context id. The previously
100
     * @return the filter ids used to group entries into levels such as Expert.
101
 * valid return types are deprecated. The plural name for this method
101
     */
102
 * is unfortunate.
102
    public String[] getFilters();
103
 * </p>
103
104
 * 
104
    /**
105
 * @return the help context id for this entry
105
     * Returns the help context id for this entry, or <code>null</code> if
106
 */
106
     * this entry has no help context id.
107
public Object getHelpContextIds();
107
     * <p>
108
/**
108
     * NOTE: Help support system API's changed since 2.0 and arrays of contexts
109
 * Returns the image for the property value, if there is one.
109
     * are no longer supported.
110
 * This image is managed by the entry it came from.  Callers
110
     * </p>
111
 * of this method must never dispose the returned image.
111
     * <p>
112
 *
112
     * Thus the only valid non- <code>null</code> return type for this method
113
 * @return the image for this property value or <code>null</code>
113
     * is a <code>String</code> representing a context id. The previously
114
 */
114
     * valid return types are deprecated. The plural name for this method is
115
public Image getImage();
115
     * unfortunate.
116
/**
116
     * </p>
117
 * Returns the value of the objects expressed as a String.
117
     * 
118
 *
118
     * @return the help context id for this entry
119
 * @return the value of the objects expressed as a String
119
     */
120
 */
120
    public Object getHelpContextIds();
121
public String getValueAsString();
121
122
/**
122
    /**
123
 * Returns <code>true</code> if the entry has children.
123
     * Returns the image for the property value, if there is one. This image is
124
 *
124
     * managed by the entry it came from. Callers of this method must never
125
 * @return <code>true</code> if the entry has children
125
     * dispose the returned image.
126
 */
126
     * 
127
public boolean hasChildEntries();
127
     * @return the image for this property value or <code>null</code>
128
/**
128
     */
129
 * Removes the given listener from this entry's collection
129
    public Image getImage();
130
 * of listeners.
130
131
 *
131
    /**
132
 * @param listener the listener to remove
132
     * Returns the value of the objects expressed as a String.
133
 */
133
     * 
134
public void removePropertySheetEntryListener(IPropertySheetEntryListener listener);
134
     * @return the value of the objects expressed as a String
135
/**
135
     */
136
 * Resets the property value to its default value if it has been changed.
136
    public String getValueAsString();
137
 */
137
138
void resetPropertyValue();
138
    /**
139
/*
139
     * Returns <code>true</code> if the entry has children.
140
 * Sets the objects which represent the property values for
140
     * 
141
 * this entry. In the case of the root entry these objects
141
     * @return <code>true</code> if the entry has children
142
 * are the input to the viewer.
142
     */
143
 *
143
    public boolean hasChildEntries();
144
 * @param values the values for this entry
144
145
 */
145
    /**
146
public void setValues(Object[] values);
146
     * Removes the given listener from this entry's collection of listeners.
147
}
147
     * 
148
     * @param listener
149
     *            the listener to remove
150
     */
151
    public void removePropertySheetEntryListener(
152
            IPropertySheetEntryListener listener);
153
154
    /**
155
     * Resets the property value to its default value if it has been changed.
156
     * <p>
157
     * Does nothing if the notion of a default value is not meaningful for 
158
     * the property.
159
     * </p>
160
     */
161
    void resetPropertyValue();
162
163
    /**
164
     * Sets the objects which represent the property values for this entry. In
165
     * the case of the root entry these objects are the input to the viewer.
166
     * 
167
     * @param values the values for this entry
168
     */
169
    public void setValues(Object[] values);
170
}
(-)src/org/eclipse/ui/views/properties/IPropertySource.java (-5 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Gunnar Wagenknecht - fix for bug 21756 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=21756)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.views.properties;
12
package org.eclipse.ui.views.properties;
12
13
Lines 29-34 Link Here
29
 * @see org.eclipse.core.runtime.IAdaptable
30
 * @see org.eclipse.core.runtime.IAdaptable
30
 * @see org.eclipse.core.runtime.Platform#getAdapterManager()
31
 * @see org.eclipse.core.runtime.Platform#getAdapterManager()
31
 * @see org.eclipse.ui.views.properties.PropertySheetPage
32
 * @see org.eclipse.ui.views.properties.PropertySheetPage
33
 * @see org.eclipse.ui.views.properties.IPropertySource2
32
 */
34
 */
33
public interface IPropertySource {
35
public interface IPropertySource {
34
36
Lines 99-120 Link Here
99
public Object getPropertyValue(Object id);
101
public Object getPropertyValue(Object id);
100
/**
102
/**
101
 * Returns whether the value of the property with the given id has changed from
103
 * Returns whether the value of the property with the given id has changed from
102
 * its default value. Returns <code>false</code> if the notion of default value
104
 * its default value. Returns <code>false</code> if this source does not have
103
 * is not meaningful for the specified property, or if this source does not have
104
 * the specified property.
105
 * the specified property.
106
 * <p>
107
 * If the notion of default value is not meaningful for the specified property
108
 * than <code>true</code> is returned.
109
 * </p>
105
 * 
110
 * 
106
 * @param id the id of the property 
111
 * @param id the id of the property 
107
 * @return <code>true</code> if the value of the specified property has changed
112
 * @return <code>true</code> if the value of the specified property has changed
108
 *   from its original default value, and <code>false</code> otherwise
113
 *   from its original default value or if the specified property does not have 
114
 *   a meaningfull default value, and <code>false</code> otherwise
115
 * @see IPropertySource2#isPropertyResettable(Object)
116
 * @see #resetPropertyValue(Object)
109
 */
117
 */
110
public boolean isPropertySet(Object id);
118
public boolean isPropertySet(Object id);
111
/**
119
/**
112
 * Resets the property with the given id to its default value if possible.
120
 * Resets the property with the given id to its default value if possible.
113
 * Does nothing if the notion of default value is not meaningful for 
121
 * <p>
122
 * Does nothing if the notion of a default value is not meaningful for 
114
 * the specified property, or if the property's value cannot be changed,
123
 * the specified property, or if the property's value cannot be changed,
115
 * or if this source does not have the specified property.
124
 * or if this source does not have the specified property.
125
 * </p>
126
 * <p>
127
 * Callers will check if this <code>IPropertySource</code> 
128
 * implements <code>IPropertySource2</code> and this method will
129
 * only be called if <code>IPropertySource2#isPropertyResettable(Object)</code>
130
 * returns <code>true</code> for the property with the given id.
131
 * </p>
116
 * 
132
 * 
117
 * @param id the id of the property being reset
133
 * @param id the id of the property being reset
134
 * @see #isPropertySet(Object)
135
 * @see IPropertySource2#isPropertyResettable(Object)
118
 */
136
 */
119
public void resetPropertyValue(Object id);
137
public void resetPropertyValue(Object id);
120
/**
138
/**
(-)src/org/eclipse/ui/views/properties/PropertySheetEntry.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Gunnar Wagenknecht - fix for bug 21756 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=21756)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.ui.views.properties;
13
package org.eclipse.ui.views.properties;
Lines 512-517 Link Here
512
	for (int i = 0; i < objects.length; i++){
513
	for (int i = 0; i < objects.length; i++){
513
		IPropertySource source = getPropertySource(objects[i]);
514
		IPropertySource source = getPropertySource(objects[i]);
514
		if (source.isPropertySet(descriptor.getId())) {
515
		if (source.isPropertySet(descriptor.getId())) {
516
            // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=21756
517
            if(source instanceof IPropertySource2) {
518
                IPropertySource2 extendedSource = (IPropertySource2) source;
519
                // continue with next if property is not resettable
520
                if (!extendedSource.isPropertyResettable(descriptor.getId()))
521
                    continue;
522
            }
515
			source.resetPropertyValue(descriptor.getId());
523
			source.resetPropertyValue(descriptor.getId());
516
			change = true;
524
			change = true;
517
		}
525
		}
(-)src/org/eclipse/ui/views/properties/IPropertySource2.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     Gunnar Wagenknecht - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.views.properties;
12
13
/**
14
 * Extension to the standard <code>IPropertySource</code> interface.
15
 * <p>
16
 * This interface provides extended API to <code>IPropertySource</code> to
17
 * allow an easier indication of properties that have a default value and can be
18
 * resetted.
19
 * </p>
20
 * 
21
 * @since 3.0
22
 * @see org.eclipse.ui.views.properties.IPropertySource
23
 */
24
public interface IPropertySource2 extends IPropertySource {
25
26
    /**
27
     * Returns whether the value of the property with the specified id is
28
     * resettable to a default value.
29
     * 
30
     * @param id
31
     *            the id of the property
32
     * @return <code>true</code> if the property with the specified id has a
33
     *         meaningfull default value to which it can be resetted to, and
34
     *         <code>false</code> otherwise
35
     * @see IPropertySource#resetPropertyValue(Object)
36
     * @see IPropertySource#isPropertySet(Object)
37
     */
38
    boolean isPropertyResettable(Object id);
39
}

Return to bug 21756