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 6419 Details for
Bug 21013
[PropertiesView] ComboBoxPropertyDescriptor should provide a defualt label provider
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for org.eclipse.ui.views
Views-21013.patch (text/plain), 8.15 KB, created by
Kim Horne
on 2003-10-14 14:40:54 EDT
(
hide
)
Description:
Patch for org.eclipse.ui.views
Filename:
MIME Type:
Creator:
Kim Horne
Created:
2003-10-14 14:40:54 EDT
Size:
8.15 KB
patch
obsolete
>Index: src/org/eclipse/ui/views/properties/ComboBoxPropertyDescriptor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/ComboBoxPropertyDescriptor.java,v >retrieving revision 1.5 >diff -u -r1.5 ComboBoxPropertyDescriptor.java >--- src/org/eclipse/ui/views/properties/ComboBoxPropertyDescriptor.java 10 Mar 2003 22:09:05 -0000 1.5 >+++ src/org/eclipse/ui/views/properties/ComboBoxPropertyDescriptor.java 14 Oct 2003 18:34:46 -0000 >@@ -12,12 +12,17 @@ > > import org.eclipse.jface.viewers.CellEditor; > import org.eclipse.jface.viewers.ComboBoxCellEditor; >+import org.eclipse.jface.viewers.ILabelProvider; >+ > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; > > /** > * Descriptor for a property that has a value which should be edited >- * with a combo box cell editor. >+ * with a combo box cell editor. This class provides a default >+ * <code>ILabelProvider</code> that will render the label of the given >+ * descriptor as the <code>String</code> found in the value array at the >+ * currently selected index. > * <p> > * This class may be instantiated; it is not intended to be subclassed. > * </p> >@@ -35,30 +40,48 @@ > * The list of possible values to display in the combo box > */ > private String[] values; >-/** >- * Creates an property descriptor with the given id, display name, and list >- * of value labels to display in the combo box cell editor. >- * >- * @param id the id of the property >- * @param displayName the name to display for the property >- * @param valuesArray the list of possible values to display in the combo box >- */ >-public ComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray) { >- super(id, displayName); >- values = valuesArray; >-} >-/** >- * The <code>ComboBoxPropertyDescriptor</code> implementation of this >- * <code>IPropertyDescriptor</code> method creates and returns a new >- * <code>ComboBoxCellEditor</code>. >- * <p> >- * The editor is configured with the current validator if there is one. >- * </p> >- */ >-public CellEditor createPropertyEditor(Composite parent) { >- CellEditor editor = new ComboBoxCellEditor(parent, values, SWT.READ_ONLY); >- if (getValidator() != null) >- editor.setValidator(getValidator()); >- return editor; >-} >+ >+ /** >+ * Creates an property descriptor with the given id, display name, and list >+ * of value labels to display in the combo box cell editor. >+ * >+ * @param id the id of the property >+ * @param displayName the name to display for the property >+ * @param valuesArray the list of possible values to display in the combo box >+ */ >+ public ComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray) { >+ super(id, displayName); >+ values = valuesArray; >+ } >+ >+ /** >+ * The <code>ComboBoxPropertyDescriptor</code> implementation of this >+ * <code>IPropertyDescriptor</code> method creates and returns a new >+ * <code>ComboBoxCellEditor</code>. >+ * <p> >+ * The editor is configured with the current validator if there is one. >+ * </p> >+ */ >+ public CellEditor createPropertyEditor(Composite parent) { >+ CellEditor editor = new ComboBoxCellEditor(parent, values, SWT.READ_ONLY); >+ if (getValidator() != null) >+ editor.setValidator(getValidator()); >+ return editor; >+ } >+ >+ /** >+ * The <code>ComboBoxPropertyDescriptor</code> implementation of this >+ * <code>IPropertyDescriptor</code> method returns the value set by >+ * the <code>setProvider</code> method or, if no value has been set >+ * it returns a <code>ComboBoxLabelProvider</code> created from the >+ * valuesArray of this <code>ComboBoxPropertyDescriptor</code>. >+ * >+ * @see #setLabelProvider >+ */ >+ public ILabelProvider getLabelProvider() { >+ if (isLabelProviderSet()) >+ return super.getLabelProvider(); >+ else >+ return new ComboBoxLabelProvider(values); >+ } > } >Index: src/org/eclipse/ui/views/properties/PropertyDescriptor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertyDescriptor.java,v >retrieving revision 1.4 >diff -u -r1.4 PropertyDescriptor.java >--- src/org/eclipse/ui/views/properties/PropertyDescriptor.java 10 Mar 2003 22:09:05 -0000 1.4 >+++ src/org/eclipse/ui/views/properties/PropertyDescriptor.java 14 Oct 2003 18:34:46 -0000 >@@ -205,6 +205,17 @@ > protected ICellEditorValidator getValidator() { > return validator; > } >+ >+/** >+ * Returns whether a label provider has been set on the receiver. >+ * @return whether a label provider has been set on the receiver. >+ * @see #setLabelProvider >+ * @since 3.0 >+ */ >+public boolean isLabelProviderSet() { >+ return labelProvider != null; >+} >+ > /** > * The <code>SimplePropertyDescriptor</code> implementation of this > * <code>IPropertyDescriptor</code> method returns true if the other >Index: src/org/eclipse/ui/views/properties/ComboBoxLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/views/properties/ComboBoxLabelProvider.java >diff -N src/org/eclipse/ui/views/properties/ComboBoxLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/views/properties/ComboBoxLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.views.properties; >+ >+import org.eclipse.jface.viewers.LabelProvider; >+ >+/** >+ * An <code>ILabelProvider</code> that assists in rendering labels for >+ * <code>ComboBoxPropertyDescriptors</code>. The label for a given >+ * <code>Integer</code> value is the <code>String</code> at the value in >+ * the provided values array. >+ * >+ * @since 3.0 >+ */ >+public class ComboBoxLabelProvider extends LabelProvider { >+ >+ /** >+ * The array of String labels. >+ */ >+ private String [] values; >+ >+ /** >+ * @param values the possible label values that this >+ * <code>ILabelProvider</code> may return. >+ */ >+ public ComboBoxLabelProvider(String[] values) { >+ this.values = values; >+ } >+ >+ /** >+ * @return the possible label values that this >+ * <code>ILabelProvider</code> may return. >+ */ >+ public String[] getValues() { >+ return values; >+ } >+ >+ /** >+ * @param values the possible label values that this >+ * <code>ILabelProvider</code> may return. >+ */ >+ public void setValues(String[] values) { >+ this.values = values; >+ } >+ >+ /** >+ * Returns the <code>String</code> that maps to the given >+ * <code>Integer</code> offset in the values array. >+ * >+ * @param element an <code>Integer</code> object whose value is a valid >+ * location within the values array of the receiver >+ * @return a <code>String</code> from the provided values array, or the >+ * empty <code>String</code> >+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ if (element == null) { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ if (element instanceof Integer) { >+ int index = ((Integer)element).intValue(); >+ if (index >= 0 && index < values.length) { >+ return values[index]; >+ } >+ else { >+ return ""; //$NON-NLS-1$ >+ } >+ } >+ >+ return ""; //$NON-NLS-1$ >+ } >+}
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 21013
: 6419 |
6420