
org.eclipse.ui.views.properties.ComboBoxLabelProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.eclipse.ui.views Show documentation
Show all versions of org.eclipse.ui.views Show documentation
This is org.eclipse.ui.views jar used by Scout SDK
The newest version!
/*******************************************************************************
* Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.views.properties;
import org.eclipse.jface.viewers.LabelProvider;
/**
* An ILabelProvider
that assists in rendering labels for
* ComboBoxPropertyDescriptors
. The label for a given
* Integer
value is the String
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
* ILabelProvider
may return.
*/
public ComboBoxLabelProvider(String[] values) {
this.values = values;
}
/**
* @return the possible label values that this
* ILabelProvider
may return.
*/
public String[] getValues() {
return values;
}
/**
* @param values the possible label values that this
* ILabelProvider
may return.
*/
public void setValues(String[] values) {
this.values = values;
}
/**
* Returns the String
that maps to the given
* Integer
offset in the values array.
*
* @param element an Integer
object whose value is a valid
* location within the values array of the receiver
* @return a String
from the provided values array, or the
* empty String
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@Override
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];
}
return ""; //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy