package es.iiia.sgi.controls;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.PlatformUI;
import es.iiia.sgi.editors.RenderingEditor;
public class RandomizationCombo extends ControlContribution {
Combo combo;
int selection;
public RandomizationCombo(String id) {
super(id);
}
@Override
protected Control createControl(Composite parent) {
combo = new Combo(parent, SWT.NONE | SWT.DROP_DOWN | SWT.READ_ONLY);
combo.add("None");
combo.add("Low");
combo.add("Medium");
combo.add("High");
combo.add("Extreme");
combo.setTextLimit(10);
combo.select(selection);
//combo.setBackground(ColorConstants.white);
combo.setToolTipText("Randomization value");
combo.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
RenderingEditor editor = ((RenderingEditor) PlatformUI
.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor());
editor.setRandomization(combo.getSelectionIndex() + 1);
selection = combo.getSelectionIndex();
}
});
return combo;
}
}