Java Code Examples for org.eclipse.swt.widgets.Combo#indexOf()

The following examples show how to use org.eclipse.swt.widgets.Combo#indexOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WizardNewXtextProjectCreationPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void fillBreeCombo(Combo comboToFill) {
	Set<String> brees = Sets.newLinkedHashSet();
	Set<String> availableBrees = Sets.newHashSet();
	for (IExecutionEnvironment ee : JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()) {
		availableBrees.add(ee.getId());
	}
	for (JavaVersion supportedVersion : JavaVersion.values()) {
		if (supportedVersion.isAtLeast(JavaVersion.JAVA6)) {
			String bree = supportedVersion.getBree();
			if (availableBrees.contains(bree))
				brees.add(bree);
		}
	}
	String[] array = brees.toArray(new String[] {});
	String selectionMemento = comboToFill.getText();
	comboToFill.setItems(array);
	int index = comboToFill.indexOf(selectionMemento);
	String defaultBree = JREContainerProvider.getDefaultBREE();
	if (index < 0) {
		if (brees.contains(defaultBree)) {
			comboToFill.select(comboToFill.indexOf(defaultBree));
		} else {
			comboToFill.select(array.length - 1);
		}
	}
	comboToFill.select(index);
}
 
Example 2
Source File: FindReplaceDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void updateCombHistory(Combo combo) {
	if (combo == null || combo.isDisposed()) {
		return;
	}
	String value = combo.getText();
	if (value == null || value.length() == 0) {
		return;
	}

	int index = combo.indexOf(value);
	if (index == 0) {
		return;
	}
	if (index != -1) {
		combo.remove(index);
	}

	int itemCount = combo.getItemCount();
	if (itemCount == 0) {
		combo.add(value, 0);
		combo.setText(value);
		return;
	}
	combo.add(value, 0);
	combo.setText(value);
	if (itemCount > 10) {
		combo.remove(11);
	}
}