use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class ExportExternalDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
final Group groupFile = new Group(tparent, SWT.NONE);
groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
groupFile.setLayout(new GridLayout(1, false));
groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = tbv.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
tableLayout.addColumnData(new ColumnWeightData(1));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
tableLayout.addColumnData(new ColumnWeightData(10));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
tbv.setLabelProvider(new TableViewLabelProvider());
tbv.setContentProvider(new ArrayContentProvider());
tbv.setInput(xlfBeans);
final Group groupExportType = new Group(tparent, SWT.NONE);
groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
groupExportType.setLayout(new GridLayout(3, false));
groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
final Label lblExportType = new Label(groupExportType, SWT.NONE);
lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
for (String type : ExportExternal.getExportTypes()) {
cmb.add(type);
}
cmb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
btnNotrans.setSelection(false);
}
}
});
final Label lblR8State = new Label(groupExportType, SWT.NONE);
lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
btnHsproofState = new Button(groupExportType, SWT.CHECK);
btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
btnHsproofNote = new Button(groupExportType, SWT.CHECK);
btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
final Group groupFilter = new Group(tparent, SWT.NONE);
groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
groupFilter.setLayout(new GridLayout(3, false));
groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
// 过滤大类
btnAllTrans = new Button(groupFilter, SWT.RADIO);
btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
btnAllTrans.setSelection(true);
btnAllTrans.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnAllTrans.getSelection()) {
setFilterDefaultValue();
}
}
});
btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
btnOnlySpecial.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnOnlySpecial.getSelection()) {
setFilterDefaultValue();
}
}
;
});
btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
btnFilterWhenState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnFilterWhenState.getSelection()) {
setFilterDefaultValue();
}
}
;
});
// 大类细节
cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
cmpFilterAllTrans.setLayout(new GridLayout(1, false));
cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
btnExceptLocked.setEnabled(true);
btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
btnExceptContextMatch.setEnabled(true);
btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterWhenState.setLayout(new GridLayout(1, false));
btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
Composite cmpSaveas = new Composite(tparent, SWT.NONE);
cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtSaveas.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
}
});
Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
btnSaveas.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setFilterPath(dialogSetting.get("defaultPath"));
String path = dialog.open();
if (path != null) {
txtSaveas.setText(path);
dialogSetting.put("defaultPath", path);
}
}
});
setDefaultValue();
return parent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class CSVSettingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(5, 5, 5, 5).applyTo(tparent);
int height = 160;
if (isTBXConverter) {
height = 230;
}
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(320, height).grab(true, true).applyTo(tparent);
Composite cmpSelFile = new Composite(tparent, SWT.None);
GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).extendedMargins(0, 0, 0, 0).applyTo(cmpSelFile);
GridDataFactory.fillDefaults().applyTo(cmpSelFile);
new Label(cmpSelFile, SWT.None).setText(Messages.getString("dialog.CSVSettingDialog.lblFile"));
txtCSV = new Text(cmpSelFile, SWT.BORDER);
txtCSV.setEditable(false);
txtCSV.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnBrowse = new Button(cmpSelFile, SWT.None);
btnBrowse.setText(Messages.getString("dialog.CSVSettingDialog.btnBrowse"));
btnBrowse.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(Messages.getString("dialog.CSVSettingDialog.dialogTitle"));
String[] extensions = { "*.csv", "*.txt", "*" };
String[] filters = { Messages.getString("dialog.CSVSettingDialog.filters1"), Messages.getString("dialog.CSVSettingDialog.filters2"), Messages.getString("dialog.CSVSettingDialog.filters3") };
dialog.setFilterExtensions(extensions);
dialog.setFilterNames(filters);
String fileSep = System.getProperty("file.separator");
if (txtCSV.getText() != null && !txtCSV.getText().trim().equals("")) {
dialog.setFilterPath(txtCSV.getText().substring(0, txtCSV.getText().lastIndexOf(fileSep)));
dialog.setFileName(txtCSV.getText().substring(txtCSV.getText().lastIndexOf(fileSep) + 1));
} else {
dialog.setFilterPath(System.getProperty("user.home"));
}
String name = dialog.open();
if (name != null) {
txtCSV.setText(name);
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Composite cmpContent = new Composite(tparent, SWT.NONE);
cmpContent.setLayout(new GridLayout(2, false));
cmpContent.setLayoutData(new GridData(GridData.FILL_BOTH));
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbColSeparator"));
cmbColSeparator = new Combo(cmpContent, SWT.NONE);
cmbColSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbColSeparator.setItems(arrColSeparator);
cmbColSeparator.select(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbTextDelimiter"));
cmbTextDelimiter = new Combo(cmpContent, SWT.NONE);
cmbTextDelimiter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbTextDelimiter.setItems(arrTextDelimiter);
cmbTextDelimiter.setText("\"");
cmbTextDelimiter.setTextLimit(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbEncoding"));
cmbEncoding = new Combo(cmpContent, SWT.READ_ONLY);
cmbEncoding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
String[] arrEncoding = LocaleService.getPageCodes();
cmbEncoding.setItems(arrEncoding);
cmbEncoding.select(indexOf(arrEncoding, "UTF-8"));
if (isTBXConverter) {
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbLang"));
cmbLang = new TableComboViewer(cmpContent, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = cmbLang.getTableCombo();
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
cmbLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
ArrayList<Language> languages = new ArrayList<Language>(LocaleService.getDefaultLanguage().values());
Collections.sort(languages, new Comparator<Language>() {
public int compare(Language o1, Language o2) {
return o1.toString().compareTo(o2.toString());
}
});
cmbLang.setContentProvider(new ArrayContentProvider());
cmbLang.setLabelProvider(new LanguageLabelProvider());
cmbLang.setInput(languages);
cmbLang.getTableCombo().select(0);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbXCSTemplate"));
cmbXCSTemplate = new Combo(cmpContent, SWT.READ_ONLY);
cmbXCSTemplate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (xcsTemplates.length > 0) {
cmbXCSTemplate.setItems(xcsTemplates);
cmbXCSTemplate.select(0);
}
}
return tparent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class ColumnTypeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(750, 400).grab(true, true).applyTo(tparent);
ScrolledComposite cmpScrolled = new ScrolledComposite(tparent, SWT.V_SCROLL);
cmpScrolled.setAlwaysShowScrollBars(false);
cmpScrolled.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
cmpScrolled.setExpandHorizontal(true);
cmpScrolled.setShowFocusedControl(true);
Composite cmpContent = new Composite(cmpScrolled, SWT.None);
cmpScrolled.setContent(cmpContent);
cmpContent.setLayout(new GridLayout(5, false));
arrCmbLangs = new Combo[size];
arrCmbPropsName = new Combo[size];
arrCmbPropsType = new Combo[size];
arrCmbPropsLevel = new Combo[size];
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column1"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column2"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column3"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column4"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column5"));
for (int i = 0; i < size; i++) {
ColProperties type = colTypes.get(i);
new Label(cmpContent, SWT.None).setText(type.getColName() + " : ");
arrCmbPropsLevel[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbPropsLevel[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsName[i] = new Combo(cmpContent, SWT.READ_ONLY);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 120;
arrCmbPropsName[i].setLayoutData(data);
arrCmbPropsType[i] = new Combo(cmpContent, SWT.READ_ONLY);
data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 150;
arrCmbPropsType[i].setLayoutData(data);
arrCmbLangs[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbLangs[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsLevel[i].setItems(levelValues);
arrCmbPropsLevel[i].select(0);
String propLevel = type.getLevel();
if (!propLevel.equals("")) {
//$NON-NLS-1$
arrCmbPropsLevel[i].setText(propLevel);
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbLangs[i].setEnabled(false);
arrCmbPropsName[i].setItems(conceptPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbLangs[i].setEnabled(true);
arrCmbPropsName[i].setItems(TranslationPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
arrCmbPropsType[i].select(0);
}
}
// fixed a bug 2339 by John.
String propName = type.getPropName();
if (!propName.equals("")) {
//$NON-NLS-1$
arrCmbPropsName[i].setText(propName);
}
// Update content for Prop Type combo
String propType = type.getPropType();
if (!propType.equals("")) {
//$NON-NLS-1$
arrCmbPropsType[i].setText(propType);
}
if (!propLevel.equals("")) {
//$NON-NLS-1$
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[i].setEnabled(propName.equals(ColProperties.descripName));
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbPropsType[i].setEnabled(!propName.equals(ColProperties.termName));
if (propName.equals(ColProperties.descripName)) {
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[i].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[i].select(0);
}
}
// Update content for Language Combo
arrCmbLangs[i].setItems(LocaleService.getLanguages());
arrCmbLangs[i].select(0);
String lang = type.getLanguage();
if (!lang.equals("")) {
//$NON-NLS-1$
arrCmbLangs[i].setText(LocaleService.getLanguage(lang));
}
final int idx = i;
arrCmbPropsName[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (name.equals(ColProperties.termName)) {
arrCmbPropsType[idx].setEnabled(false);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.termNoteName)) {
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.noteName)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsType[idx].setEnabled(false);
return;
}
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setEnabled(true);
if (level.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
}
arrCmbPropsType[idx].select(0);
return;
}
arrCmbPropsType[idx].setEnabled(false);
}
});
arrCmbPropsLevel[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (level.equals(ColProperties.conceptLevel)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsName[idx].setItems(conceptPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
}
if (level.equals(ColProperties.langLevel)) {
arrCmbLangs[idx].setEnabled(true);
arrCmbPropsName[idx].setItems(TranslationPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(false);
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[idx].select(0);
}
}
});
}
cmpContent.setSize(cmpContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
return tparent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class CustomFilterDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
gray = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);
black = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
tParent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().extendedMargins(5, 5, 10, 0).numColumns(2).equalWidth(false).applyTo(tParent);
tParent.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite cmpLeft = new Composite(tParent, SWT.BORDER);
cmpLeft.setLayout(new GridLayout(2, false));
GridDataFactory.swtDefaults().applyTo(cmpLeft);
Composite cmpList = new Composite(cmpLeft, SWT.NONE);
cmpList.setLayout(new GridLayout(1, true));
cmpList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(cmpList, SWT.NONE).setText(Messages.getString("dialog.CustomFilterDialog.c1Lbl"));
initCustomFilterList(cmpList);
Composite cmpBtn = new Composite(cmpLeft, SWT.None);
cmpBtn.setLayout(new GridLayout());
cmpBtn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
Button addCustom = new Button(cmpBtn, SWT.PUSH);
addCustom.setText(Messages.getString("dialog.CustomFilterDialog.addCustom"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addCustom);
addCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (isChange()) {
if (!MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg1"))) {
return;
}
}
refresh();
}
});
Button delCustom = new Button(cmpBtn, SWT.PUSH);
delCustom.setText(Messages.getString("dialog.CustomFilterDialog.delCustom"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).applyTo(delCustom);
delCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String[] filters = customFilterList.getSelection();
if (filters != null && filters.length > 0) {
if (MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg2"))) {
for (int i = 0; i < filters.length; i++) {
customFilters.remove(filters[i]);
customFiltersAddition.remove(filters[i]);
customFiltersIndex.remove(filters[i]);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IEditorReference[] editors = page.getEditorReferences();
for (IEditorReference ef : editors) {
IEditorPart editor = ef.getEditor(false);
if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
Combo cb = ((XLIFFEditorImplWithNatTable) editor).getFilterCombo();
if (cb != null && !cb.isDisposed()) {
cb.remove(filters[i]);
}
}
}
}
}
// cmbFilter.remove(filters[i]);
customFilterList.remove(filters[i]);
XLFHandler.getFilterMap().remove(filters[i]);
}
PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION, customFilters);
PreferenceStore.saveCustomCondition(IPreferenceConstants.FILTER_CONDITION_INDEX, customFiltersIndex);
}
} else {
MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg3"));
}
}
});
Button editCustom = new Button(cmpBtn, SWT.PUSH);
editCustom.setText(Messages.getString("dialog.CustomFilterDialog.editCustom"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).applyTo(editCustom);
editCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
edit();
}
});
Composite cmpRight = new Composite(tParent, SWT.NONE);
cmpRight.setLayout(new GridLayout(1, true));
cmpRight.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite top = new Composite(cmpRight, SWT.NONE);
top.setLayout(new GridLayout(2, false));
top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(top, SWT.NONE).setText(Messages.getString("dialog.CustomFilterDialog.topLbl"));
filterNameTxt = new Text(top, SWT.BORDER);
filterNameTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filterNameTxt.forceFocus();
top = new Composite(cmpRight, SWT.NONE);
top.setLayout(new GridLayout(2, false));
top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
andBtn = new Button(top, SWT.RADIO);
andBtn.setText(Messages.getString("dialog.CustomFilterDialog.andBtn"));
andBtn.setSelection(true);
orBtn = new Button(top, SWT.RADIO);
orBtn.setText(Messages.getString("dialog.CustomFilterDialog.orBtn"));
scroll = new ScrolledComposite(cmpRight, SWT.V_SCROLL | SWT.BORDER);
scroll.setAlwaysShowScrollBars(true);
scroll.setLayoutData(new GridData(GridData.FILL_BOTH));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
// scroll.setSize(500, 200);
dynaComp = new Composite(scroll, SWT.None);
scroll.setContent(dynaComp);
dynaComp.setLayout(new GridLayout(1, true));
new DynaComposite(dynaComp, SWT.NONE);
return parent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class CustomFilterDialog method okPressed.
@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();
}
}
Aggregations