org.eclipse.swt.widgets.Combo#indexOf ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Combo#indexOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
}
 
源代码2 项目: tmxeditor8   文件: FindReplaceDialog.java
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);
	}
}