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 57701 Details for
Bug 15734
[PropertiesView] PropertySheet displays wrong values with multiple selection
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]
Blanking not equal property values
multipleSelectEclipsePatch.txt (text/plain), 7.17 KB, created by
Krzysztof Daniel
on 2007-01-29 09:46:36 EST
(
hide
)
Description:
Blanking not equal property values
Filename:
MIME Type:
Creator:
Krzysztof Daniel
Created:
2007-01-29 09:46:36 EST
Size:
7.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.views >Index: src/org/eclipse/ui/views/properties/PropertySheetEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java,v >retrieving revision 1.25 >diff -u -r1.25 PropertySheetEntry.java >--- src/org/eclipse/ui/views/properties/PropertySheetEntry.java 12 Sep 2006 18:58:38 -0000 1.25 >+++ src/org/eclipse/ui/views/properties/PropertySheetEntry.java 29 Jan 2007 14:41:53 -0000 >@@ -49,6 +49,12 @@ > IPropertySheetEntry { > > /** >+ * The value displayed when property values from different objects >+ * of one kind have different values >+ */ >+ private static final String VALUE_INCONSISTENT = ""; //$NON-NLS-1$ >+ >+ /** > * The values we are displaying/editing. These objects repesent the value of > * one of the properties of the values of our parent entry. Except for the > * root entry where they represent the input (selected) objects. >@@ -61,11 +67,10 @@ > private Map sources = new HashMap(0); > > /** >- * The value of this entry is defined as the the first object in its value >- * array or, if that object is an <code>IPropertySource</code>, the value >- * it returns when sent <code>getEditableValue</code> >+ * An array of values or, if they are <code>IPropertySource</code>, >+ * the values it returns when sent <code>getEditableValue</code>. > */ >- private Object editValue; >+ private Object[] editValues; > > private PropertySheetEntry parent; > >@@ -78,8 +83,39 @@ > private String errorText; > > private PropertySheetEntry[] childEntries = null; >+ >+ /** >+ * The parameter is >+ * <ul> >+ * <li><code>true</code> if inconsistent properties should be blanked,</li> >+ * <li><code>false</code> otherwise.</li> >+ * </ul> >+ */ >+ protected boolean blankNotEqualPropertyValues = false; > > /** >+ * Constructs an <code>PropertySheetEntry</code> that may blank inconsistent >+ * properties depending on the <code>blankInconsistency</code> parameter. >+ * >+ * @param blankNotEqualPropertyValues a parameter indicating, that property >+ * values should be blanked, if many selected objects have the same >+ * properties with different values. >+ * <ul> >+ * <li><code>true</code> enabled </li> >+ * <li><code>false</code> disabled </li> >+ * </ul> >+ */ >+ public PropertySheetEntry(boolean blankNotEqualPropertyValues){ >+ this.blankNotEqualPropertyValues = blankNotEqualPropertyValues; >+ } >+ >+ /** >+ * Default constructor. <code>PropertySheetEntry</code> will not care about >+ * property value of different objects. Always the first one will be displayed. >+ */ >+ public PropertySheetEntry(){ } >+ >+ /** > * Create the CellEditorListener for this entry. It listens for value > * changes in the CellEditor, and cancel and finish requests. > */ >@@ -119,6 +155,11 @@ > if (editor == null) { > return; > } >+ if (!editor.isDirty() >+ /*we care only if blank can be set*/ >+ && blankNotEqualPropertyValues){ >+ return; >+ } > > // Check if editor has a valid value > if (!editor.isValueValid()) { >@@ -133,11 +174,11 @@ > boolean changed = false; > if (values.length > 1) { > changed = true; >- } else if (editValue == null) { >+ } else if (editValues[0] == null) { > if (newValue != null) { > changed = true; > } >- } else if (!editValue.equals(newValue)) { >+ } else if (!editValues[0].equals(newValue)) { > changed = true; > } > >@@ -256,15 +297,17 @@ > * Factory method to create a new child <code>PropertySheetEntry</code> > * instance. > * <p> >- * Subclasses may overwrite to create new instances of their own class. >+ * Subclasses may overwrite to create new instances of their own class, >+ * but should pass <code>blankingInconsistency</code> to child entries. > * </p> > * > * @return a new <code>PropertySheetEntry</code> instance for the > * descriptor passed in >+ * @see #blankNotEqualPropertyValues > * @since 3.1 > */ > protected PropertySheetEntry createChildEntry() { >- return new PropertySheetEntry(); >+ return new PropertySheetEntry(blankNotEqualPropertyValues); > } > > /* >@@ -381,8 +424,23 @@ > } > } > if (editor != null) { >- editor.setValue(editValue); >- setErrorText(editor.getErrorMessage()); >+ boolean consistent = true; >+ Object editValue = editValues[0]; >+ for(int i = 1; i < editValues.length; i++){ >+ if (!editValue.equals(editValues[i])){ >+ consistent = false; >+ } >+ } >+ >+ if (consistent == true || >+ /*or consistency checking is disabled*/ >+ !blankNotEqualPropertyValues){ >+ editor.setValue(editValues[0]); >+ setErrorText(editor.getErrorMessage()); >+ } else { >+ editor.setValue(VALUE_INCONSISTENT); >+ setErrorText(null); >+ } > } > return editor; > } >@@ -432,7 +490,7 @@ > if (provider == null) { > return null; > } >- return provider.getImage(editValue); >+ return provider.getImage(editValues[0]); > } > > /** >@@ -480,18 +538,34 @@ > * (non-Javadoc) Method declared on IPropertySheetEntry. > */ > public String getValueAsString() { >- if (editValue == null) { >- return "";//$NON-NLS-1$ >- } >- ILabelProvider provider = descriptor.getLabelProvider(); >- if (provider == null) { >- return editValue.toString(); >+ String[] textEditValues = new String[editValues.length]; >+ // compute all edit values >+ for(int i = 0; i < editValues.length; i++){ >+ if (editValues[i] != null) { >+ ILabelProvider provider = descriptor.getLabelProvider(); >+ if (provider != null) { >+ String text = provider.getText(editValues[i]); >+ if (text != null) { >+ textEditValues[i] = text; >+ } else { >+ textEditValues[i] = "";//$NON-NLS-1$ >+ } >+ } else { >+ textEditValues[i] = editValues[i].toString(); >+ } >+ } else { >+ textEditValues[i] = "";//$NON-NLS-1$ >+ } > } >- String text = provider.getText(editValue); >- if (text == null) { >- return "";//$NON-NLS-1$ >+ // check consistency if required >+ if(blankNotEqualPropertyValues){ >+ for(int i = 1; i < textEditValues.length; i++){ >+ if (!textEditValues[0].equals(textEditValues[i])){ >+ return VALUE_INCONSISTENT; >+ } >+ } > } >- return text; >+ return textEditValues[0]; > } > > /** >@@ -743,17 +817,21 @@ > sources = new HashMap(values.length * 2 + 1); > > if (values.length == 0) { >- editValue = null; >+ editValues = new Object[1]; > } else { >- // set the first value object as the entry's value >- Object newValue = values[0]; >- >- // see if we should convert the value to an editable value >- IPropertySource source = getPropertySource(newValue); >- if (source != null) { >- newValue = source.getEditableValue(); >+ >+ editValues = new Object[values.length]; >+ >+ for(int i = 0; i < editValues.length; i++){ >+ // see if we should convert the value to an editable value >+ IPropertySource source = getPropertySource(values[i]); >+ if (source != null) { >+ editValues[i] = source.getEditableValue(); >+ } else { >+ editValues[i] = values[i]; >+ } > } >- editValue = newValue; >+ > } > > // update our child entries
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 15734
:
25082
| 57701