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

The following examples show how to use org.eclipse.swt.widgets.Combo#isDisposed() . 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: NewProjectWizardProjInfoPage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取项目属性字段集合
 * @return key 为属性名称,value 中第一个值为选中的属性值,第二个值为该属性对应的所有属性值集合
 */
public LinkedHashMap<String, Object[]> getAttributeMap() {
	LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
	if (lstCombo != null) {
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
	}
	return mapAttr;
}
 
Example 2
Source File: NewProjectWizardProjInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取项目属性字段集合
 * @return key 为属性名称,value 中第一个值为选中的属性值,第二个值为该属性对应的所有属性值集合
 */
public LinkedHashMap<String, Object[]> getAttributeMap() {
	LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
	if (lstCombo != null) {
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
	}
	return mapAttr;
}
 
Example 3
Source File: ProjectSettingBaseInfoPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performOk() {
	if (lstText != null) {
		LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
		projCfgBean.setMapField(mapField);
	}

	if (lstCombo != null) {
		LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
		projCfgBean.setMapAttr(mapAttr);
	}
	return super.performOk();
}
 
Example 4
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static int getComboIndex(final Combo combo, final int defVal) {
    if ((combo == null) || (combo.isDisposed())) {
        return defVal;
    }

    return (combo.getSelectionIndex());
}
 
Example 5
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static String getComboText(final Combo combo, final String defVal) {
    if ((combo == null) || (combo.isDisposed())) {
        return defVal;
    }

    return (combo.getText());
}
 
Example 6
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);
	}
}
 
Example 7
Source File: ProjectSettingBaseInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performOk() {
	if (lstText != null) {
		LinkedHashMap<String, String> mapField = new LinkedHashMap<String, String>();
		for (Text txt : lstText) {
			if (!txt.isDisposed()) {
				mapField.put(TextUtil.stringToXML((String) txt.getData()), TextUtil.stringToXML(txt.getText()).trim());
			}
		}
		projCfgBean.setMapField(mapField);
	}

	if (lstCombo != null) {
		LinkedHashMap<String, Object[]> mapAttr = new LinkedHashMap<String, Object[]>();
		for (Combo cmb : lstCombo) {
			if (!cmb.isDisposed()) {
				ArrayList<String> lstAttrValue = new ArrayList<String>();
				for (String attrVal : cmb.getItems()) {
					lstAttrValue.add(TextUtil.stringToXML(attrVal));
				}
				mapAttr.put(TextUtil.stringToXML((String) cmb.getData()),
						new Object[] { TextUtil.stringToXML(cmb.getText()), lstAttrValue });
			}
		}
		projCfgBean.setMapAttr(mapAttr);
	}
	return super.performOk();
}
 
Example 8
Source File: CustomFilterDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
	protected void okPressed() {
		String filterNameStr = filterNameTxt.getText();
		if (filterNameStr == null || "".equals(filterNameStr)) {
			MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg6"));
			return;
		}
		StringBuilder xpath = new StringBuilder();
		String link = andBtn.getSelection() ? " and " : " or ";
		ArrayList<String[]> tempValue = new ArrayList<String[]>();
		for (DynaComposite comp : conditionList) { // 得到所有自定义条件组合的xpath
			String tempXpath = comp.getXpath(true);
			if (RESULT_FAILED.equals(tempXpath)) {
				return;
			}
			xpath.append(tempXpath).append(link);
			tempValue.add(comp.getTempIndex());
		}
		if (xpath.length() > 0) {
			if (isAdd()) {
				IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
				if (window != null) {
					IWorkbenchPage page = window.getActivePage();
					if (page != null) {
						IEditorReference[] editors = page.getEditorReferences();
						for(IEditorReference e : editors){
							IEditorPart editor  = e.getEditor(false);
							if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
								Combo cb = ((XLIFFEditorImplWithNatTable) editor).getFilterCombo();
								if(cb != null && !cb.isDisposed()){
									cb.add(filterNameTxt.getText());
								}
							}
						}
					}
				}
//				cmbFilter.add(filterNameTxt.getText());
			} else {
				XLFHandler.getFilterMap().put(filterNameTxt.getText(), xpath.substring(0, xpath.lastIndexOf(link)));
			}
			customFilters.put(filterNameStr, xpath.substring(0, xpath.lastIndexOf(link)));
			customFiltersAddition.put(filterNameStr, link.trim());
			customFiltersIndex.put(filterNameStr, tempValue);
			PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION, new TreeMap<String, String>(customFilters));
			PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION_ADDITION, customFiltersAddition);
			PreferenceStore.saveCustomCondition(IPreferenceConstants.FILTER_CONDITION_INDEX, customFiltersIndex);
			reload();
		}
	}
 
Example 9
Source File: CustomFilterDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
	protected void okPressed() {
		String filterNameStr = filterNameTxt.getText();
		if (filterNameStr == null || "".equals(filterNameStr)) {
			MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg6"));
			return;
		}
		StringBuilder xpath = new StringBuilder();
		String link = andBtn.getSelection() ? " and " : " or ";
		ArrayList<String[]> tempValue = new ArrayList<String[]>();
		for (DynaComposite comp : conditionList) { // 得到所有自定义条件组合的xpath
			String tempXpath = comp.getXpath(true);
			if (RESULT_FAILED.equals(tempXpath)) {
				return;
			}
			xpath.append(tempXpath).append(link);
			tempValue.add(comp.getTempIndex());
		}
		if (xpath.length() > 0) {
			if (isAdd()) {
				IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
				if (window != null) {
					IWorkbenchPage page = window.getActivePage();
					if (page != null) {
						IEditorReference[] editors = page.getEditorReferences();
						for(IEditorReference e : editors){
							IEditorPart editor  = e.getEditor(false);
							if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
								Combo cb = ((XLIFFEditorImplWithNatTable) editor).getFilterCombo();
								if(cb != null && !cb.isDisposed()){
									cb.add(filterNameTxt.getText());
								}
							}
						}
					}
				}
//				cmbFilter.add(filterNameTxt.getText());
			} else {
				XLFHandler.getFilterMap().put(filterNameTxt.getText(), xpath.substring(0, xpath.lastIndexOf(link)));
			}
			customFilters.put(filterNameStr, xpath.substring(0, xpath.lastIndexOf(link)));
			customFiltersAddition.put(filterNameStr, link.trim());
			customFiltersIndex.put(filterNameStr, tempValue);
			PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION, new TreeMap<String, String>(customFilters));
			PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION_ADDITION, customFiltersAddition);
			PreferenceStore.saveCustomCondition(IPreferenceConstants.FILTER_CONDITION_INDEX, customFiltersIndex);
			reload();
		}
	}