use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class TermBaseSearchDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout());
GridData parentData = new GridData(GridData.FILL_BOTH);
parentData.heightHint = 600;
parentData.widthHint = 775;
tparent.setLayoutData(parentData);
Group groupSearch = new Group(tparent, SWT.None);
groupSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.groupSearch"));
GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
Label lblSearch = new Label(groupSearch, SWT.NONE);
lblSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.lblSearch"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
cmbSearch = new Combo(groupSearch, SWT.DROP_DOWN | SWT.BORDER);
cmbSearch.setText(strSearchText == null ? "" : strSearchText);
GridData txtData = new GridData();
// 解决在 Windows 下文本框高度太小的问题
// txtData.heightHint = 20;
txtData.widthHint = 590;
cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnSearch = new Button(groupSearch, SWT.PUSH);
btnSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSearch"));
new Label(groupSearch, SWT.NONE);
Composite compCondition = new Composite(groupSearch, SWT.NONE);
GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(4).equalWidth(false).applyTo(compCondition);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compCondition);
btnIsCaseSensitive = new Button(compCondition, SWT.CHECK);
btnIsCaseSensitive.setText(Messages.getString("dialog.TermBaseSearchDialog.btnIsCaseSensitive"));
GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
btnIsIgnoreMark.setText(Messages.getString("dialog.TermBaseSearchDialog.btnIsIgnoreMark"));
btnIsIgnoreMark.setSelection(true);
GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
btnApplyRegularExpression.setText(Messages.getString("dialog.TermBaseSearchDialog.btnApplyRegularExpression"));
GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
Composite compMatchQuality = new Composite(compCondition, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).margins(0, 0).spacing(0, 0).numColumns(3).equalWidth(false).applyTo(compMatchQuality);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(compMatchQuality);
new Label(compMatchQuality, SWT.NONE).setText(Messages.getString("dialog.TermBaseSearchDialog.lblQuality"));
spiMatchQuality = new Spinner(compMatchQuality, SWT.BORDER);
spiMatchQuality.setMaximum(100);
spiMatchQuality.setMinimum(30);
spiMatchQuality.setIncrement(5);
spiMatchQuality.setSelection(100);
GridData spinnaData = new GridData();
spinnaData.widthHint = 23;
spiMatchQuality.setLayoutData(spinnaData);
new Label(compMatchQuality, SWT.NONE).setText("%");
Label lblTB = new Label(groupSearch, SWT.NONE);
lblTB.setText(Messages.getString("dialog.TermBaseSearchDialog.lblTB"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTB);
Composite cmpTB = new Composite(groupSearch, SWT.NONE);
GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(2).equalWidth(false).applyTo(cmpTB);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(cmpTB);
cmbDatabase = new Combo(cmpTB, SWT.READ_ONLY);
GridDataFactory.swtDefaults().hint(120, SWT.DEFAULT).applyTo(cmbDatabase);
initDatabaseCombo();
btnSelectLang = new Button(cmpTB, SWT.RIGHT);
// GridData data = new GridData();
// data.widthHint = 150;
// data.heightHint = 27;
// btnSelectLang.setLayoutData(data);
// btnSelectLang.setImage(Activator.getImageDescriptor(ImageConstants.CONCORDANCE_SELECT_LANG).createImage());
// btnSelectLang.addPaintListener(new PaintListener() {
// public void paintControl(PaintEvent e) {
// e.gc.drawText(Messages.getString("dialog.TermBaseSearchDialog.btnSelectLang"), 5, 5,
// SWT.DRAW_TRANSPARENT);
// }
// });
btnSelectLang.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSelectLang"));
initLanguageMenu();
Group groupTable = new Group(tparent, SWT.NONE);
GridLayoutFactory.swtDefaults().margins(10, 10).applyTo(groupTable);
groupTable.setLayoutData(new GridData(GridData.FILL_BOTH));
// GridDataFactory.fillDefaults().hint(700, 440).applyTo(groupTable);
groupTable.setText(Messages.getString("dialog.TermBaseSearchDialog.groupTable"));
grid = new Grid(groupTable, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
grid.setHeaderVisible(true);
grid.setLinesVisible(true);
grid.setLayoutData(new GridData(GridData.FILL_BOTH));
grid.setAutoHeight(true);
grid.setRowsResizeable(true);
grid.setWordWrapHeader(true);
if (strSrcLang != null) {
columnSrcLang = new GridColumn(grid, SWT.NONE);
srcCellRenderer.setVerticalAlignment(SWT.CENTER);
srcCellRenderer.setStyleColumn(0);
columnSrcLang.setCellRenderer(srcCellRenderer);
columnSrcLang.setText(strSrcLang);
columnSrcLang.setWidth(365);
columnSrcLang.setWordWrap(true);
}
if (strTgtLang != null) {
GridColumn columnTgtLang = new GridColumn(grid, SWT.NONE);
TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
cellRenderer.setVerticalAlignment(SWT.CENTER);
columnTgtLang.setCellRenderer(cellRenderer);
columnTgtLang.setText(strTgtLang);
columnTgtLang.setWidth(365);
columnTgtLang.setWordWrap(true);
}
for (String strLang : lstLangs) {
final GridColumn column = new GridColumn(grid, SWT.NONE);
TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
cellRenderer.setVerticalAlignment(SWT.CENTER);
column.setCellRenderer(cellRenderer);
column.setText(strLang);
column.setWidth(0);
column.setWordWrap(true);
}
readDialogSettings();
setEnabled();
updateCombo(cmbSearch, lstSearchHistory);
if (!strSearchText.equals("")) {
cmbSearch.setText(strSearchText);
} else if (lstSearchHistory != null && lstSearchHistory.size() > 0) {
cmbSearch.setText(lstSearchHistory.get(0));
}
cmbSearch.setSelection(new Point(0, cmbSearch.getText().length()));
initListener();
return parent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class TableControlPanel method createControls.
/**
* @param panel
*/
private void createControls() {
RowLayout rl = new RowLayout();
rl.type = SWT.HORIZONTAL;
this.setLayout(rl);
Composite col1 = new Composite(this, SWT.NULL);
rl = new RowLayout();
rl.type = SWT.VERTICAL;
col1.setLayout(rl);
Composite col2 = new Composite(this, SWT.NULL);
rl = new RowLayout();
rl.type = SWT.VERTICAL;
col2.setLayout(rl);
Composite col3 = new Composite(this, SWT.NULL);
rl = new RowLayout();
rl.type = SWT.VERTICAL;
col3.setLayout(rl);
final Button autoFilterCheck = new Button(col1, SWT.CHECK);
autoFilterCheck.setText("AutoFilter");
autoFilterCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setAutoFilterEnable(autoFilterCheck.getSelection());
}
});
final Button drawHeaderCheck = new Button(col1, SWT.CHECK);
drawHeaderCheck.setSelection(_table.getDrawHeader());
drawHeaderCheck.setText("Draw header");
drawHeaderCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setDrawHeader(drawHeaderCheck.getSelection());
}
});
final Button fillDragCheck = new Button(col1, SWT.CHECK);
fillDragCheck.setSelection(_table.isSupportFillDragging());
fillDragCheck.setText("Support fill dragging");
fillDragCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setSupportFillDragging(fillDragCheck.getSelection());
}
});
Button b = new Button(col2, SWT.PUSH);
b.setText("Print");
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
print();
}
});
final Scale headerRotationScale = new Scale(col2, SWT.HORIZONTAL);
headerRotationScale.setMaximum(90);
headerRotationScale.setMinimum(0);
headerRotationScale.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
int val = headerRotationScale.getSelection();
((DefaultTableHeaderRenderer) _table.getHeaderRenderer()).setRotation(val);
if (val > 0) {
_table.setHeaderHeight(50);
} else {
_table.setHeaderHeight(18);
}
_table.redraw();
}
});
final Button allowHeaderResizeCheck = new Button(col1, SWT.CHECK);
allowHeaderResizeCheck.setSelection(_table.getDrawHeader());
allowHeaderResizeCheck.setText("Allow header resize");
allowHeaderResizeCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setHeaderResizeAllowed(allowHeaderResizeCheck.getSelection());
}
});
final Button allowRowResizeCheck = new Button(col1, SWT.CHECK);
allowRowResizeCheck.setSelection(_table.getDrawHeader());
allowRowResizeCheck.setText("Allow row resize");
allowRowResizeCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setRowResizeAllowed(allowRowResizeCheck.getSelection());
}
});
final Button allowColResizeCheck = new Button(col1, SWT.CHECK);
allowColResizeCheck.setSelection(_table.getDrawHeader());
allowColResizeCheck.setText("Allow column resize");
allowColResizeCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setColumnResizeAllowed(allowColResizeCheck.getSelection());
}
});
Label l = new Label(col2, SWT.NULL);
l.setText("Fixed columns");
final Combo fixedColCombo = new Combo(col2, SWT.BORDER | SWT.READ_ONLY);
fixedColCombo.setItems(new String[] { "0", "1", "2", "3", "4" });
fixedColCombo.select(0);
fixedColCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setFixedColumns(fixedColCombo.getSelectionIndex());
}
});
l = new Label(col2, SWT.NULL);
l.setText("Fixed rows");
final Combo fixedRowCombo = new Combo(col2, SWT.BORDER | SWT.READ_ONLY);
fixedRowCombo.setItems(new String[] { "0", "1", "2", "3", "4" });
fixedRowCombo.select(0);
fixedRowCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setFixedRows(fixedRowCombo.getSelectionIndex());
}
});
final Button resizeRestrictionCheck = new Button(col1, SWT.CHECK);
resizeRestrictionCheck.setSelection(_table.getResizeRestriction());
resizeRestrictionCheck.setText("Restrict resizing to headers/row headers");
resizeRestrictionCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setResizeRestriction(resizeRestrictionCheck.getSelection());
}
});
final Button excludeFixedRowsCheck = new Button(col1, SWT.CHECK);
excludeFixedRowsCheck.setSelection(_table.getExcludeFixedRowsFromSorting());
excludeFixedRowsCheck.setText("Exclude fixed rows from sorting");
excludeFixedRowsCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.setExcludeFixedRowsFromSorting(excludeFixedRowsCheck.getSelection());
}
});
final Button rowFilterCheck = new Button(col1, SWT.CHECK);
rowFilterCheck.setSelection(false);
rowFilterCheck.setText("Set rowfilter (even char count on col2)");
rowFilterCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = rowFilterCheck.getSelection();
if (sel) {
_table.setRowFilter(new AbstractRowFilter() {
public boolean isInResult(IRow row) {
return ((DummyRow) row).getT2() != null && ((DummyRow) row).getT2().length() % 2 == 0;
}
});
} else {
_table.setRowFilter(null);
}
}
});
final Button rowSorterCheck = new Button(col1, SWT.CHECK);
rowSorterCheck.setSelection(false);
rowSorterCheck.setText("Set rowsorter (char count on col3)");
rowSorterCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = rowSorterCheck.getSelection();
if (sel) {
_table.setRowSorter(new AbstractRowSorter() {
public int compare(IRow o1, IRow o2) {
int c1 = ((DummyRow) o1).getT3() != null ? ((DummyRow) o1).getT3().length() : 0;
int c2 = ((DummyRow) o2).getT3() != null ? ((DummyRow) o2).getT3().length() : 0;
return c1 - c2;
}
});
} else {
_table.setRowSorter(null);
}
}
});
final Button onlyRowSelectionCheck = new Button(col1, SWT.CHECK);
onlyRowSelectionCheck.setSelection(false);
onlyRowSelectionCheck.setText("Only row selection allowed");
onlyRowSelectionCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = onlyRowSelectionCheck.getSelection();
_table.getSelectionModel().setOnlyRowSelectionAllowed(sel);
_table.getSelectionModel().clearSelection();
}
});
final Button optimizeScrollingCheck = new Button(col1, SWT.CHECK);
optimizeScrollingCheck.setSelection(_table.getOptimizeScrolling());
optimizeScrollingCheck.setText("Optimize scrolling");
optimizeScrollingCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = optimizeScrollingCheck.getSelection();
_table.setOptimizeScrolling(sel);
}
});
/**
* Style strategy coloring the background of odd row indizes. The implementation is brute force creating
* tons of objects underway ... so be careful.
*/
final IStyleStrategy _styleStrategy = new IStyleStrategy() {
public ICellStyle getCellStyle(IRow row, IColumn column, ICellStyle incomingStyle, ICellStyle defaultCellStyle) {
if (_table.getInternalRowIndex(row) % 2 == 0) {
return incomingStyle;
} else {
ICellStyle s = incomingStyle.copy();
s.setBackgroundColor(new RGB(230, 230, 230));
return s;
}
}
};
final Button bgColoringCheck = new Button(col1, SWT.CHECK);
bgColoringCheck.setSelection(_table.getTableViewState().getCellStyleProvider().getStyleStrategy() != null);
bgColoringCheck.setText("BG coloring (IStyleStrategy)");
bgColoringCheck.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = bgColoringCheck.getSelection();
if (!sel) {
_table.getTableViewState().getCellStyleProvider().setStyleStrategy(null);
_table.redraw();
} else {
_table.getTableViewState().getCellStyleProvider().setStyleStrategy(_styleStrategy);
_table.redraw();
}
}
});
Button b2 = new Button(col2, SWT.PUSH);
b2.setText("Spawn new window");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
// hack
if (_table.getHierarchicalModel() == null) {
if (_table.getTableModel() instanceof SimpleJaretTableModel) {
new SimpleModelExample(_table.getTableModel());
} else {
new TableExample(_table.getTableModel());
}
} else {
new TableHierarchicalExample(_table.getHierarchicalModel());
}
}
});
b2 = new Button(col2, SWT.PUSH);
b2.setText("Start changing bars");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
for (int i = 0; i < _table.getTableModel().getRowCount(); i++) {
Runnable r = new Changer(_table.getTableModel(), i);
Thread t = new Thread(r);
t.start();
}
}
});
b2 = new Button(col3, SWT.PUSH);
b2.setText("Set heightmode OPTIMAL");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.OPTIMAL);
}
});
b2 = new Button(col3, SWT.PUSH);
b2.setText("Set heightmode OPTANDVAR");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.OPTANDVAR);
}
});
b2 = new Button(col3, SWT.PUSH);
b2.setText("Set heightmode VARIABLE");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
}
});
b2 = new Button(col3, SWT.PUSH);
b2.setText("Set heightmode FIXED");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
_table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.FIXED);
}
});
l = new Label(col3, SWT.NULL);
l.setText("Column resize mode");
final Combo colModeCombo = new Combo(col3, SWT.BORDER | SWT.READ_ONLY);
colModeCombo.setItems(new String[] { "NONE", "SUBSEQUENT", "ALLSUBSEQUENT", "ALL" });
colModeCombo.select(0);
colModeCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
String sel = colModeCombo.getText();
_table.getTableViewState().setColumnResizeMode(ITableViewState.ColumnResizeMode.valueOf(sel));
}
});
b2 = new Button(col3, SWT.PUSH);
b2.setText("Clipboard info");
b2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
Clipboard cb = new Clipboard(Display.getCurrent());
System.out.println("Clipboard info");
TextTransfer textTransfer = TextTransfer.getInstance();
Object content = cb.getContents(textTransfer);
if (content != null) {
System.out.println("TEXT: " + content.getClass() + ":" + content.toString());
}
RTFTransfer rtfTransfer = RTFTransfer.getInstance();
content = cb.getContents(rtfTransfer);
if (content != null) {
System.out.println("RTF: " + content.getClass() + ":" + content.toString());
}
HTMLTransfer htmlTransfer = HTMLTransfer.getInstance();
content = cb.getContents(htmlTransfer);
if (content != null) {
System.out.println("HTML: " + content.getClass() + ":" + content.toString());
}
}
});
final Button includeColHeadingsWhenCopying = new Button(col3, SWT.CHECK);
includeColHeadingsWhenCopying.setText("Include col header when copying");
if (_table.getCcpStrategy() instanceof DefaultCCPStrategy) {
DefaultCCPStrategy stategy = (DefaultCCPStrategy) _table.getCcpStrategy();
includeColHeadingsWhenCopying.setSelection(stategy.getIncludeHeadersInCopy());
includeColHeadingsWhenCopying.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean sel = includeColHeadingsWhenCopying.getSelection();
DefaultCCPStrategy stategy = (DefaultCCPStrategy) _table.getCcpStrategy();
stategy.setIncludeHeadersInCopy(sel);
}
});
} else {
includeColHeadingsWhenCopying.setEnabled(false);
}
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class ExportFilterComposite method createContent.
/** 创建控件 */
private void createContent() {
setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
GridLayout gridLayout = new GridLayout(5, false);
gridLayout.horizontalSpacing = 2;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
setLayout(gridLayout);
conditionComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
Combo conditionCombo = conditionComboViewer.getCombo();
GridData gdConditionCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdConditionCombo.widthHint = 200;
conditionCombo.setLayoutData(gdConditionCombo);
conditionComboViewer.setContentProvider(new ArrayContentProvider());
conditionComboViewer.setInput(filterNames);
conditionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
baseDataBean.setOptionName((String) sel.getFirstElement());
handlerFilterChangedEvent();
opratorComboViewer.setInput(baseDataBean.getCurrentFilterExpressions());
// 默认选中第一个
opratorComboViewer.getCombo().select(0);
baseDataBean.setCurrentExpression(opratorComboViewer.getCombo().getText());
}
});
opratorComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
Combo opratorCombo = opratorComboViewer.getCombo();
GridData gd_opratorCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd_opratorCombo.widthHint = 100;
opratorCombo.setLayoutData(gd_opratorCombo);
opratorComboViewer.setContentProvider(new ArrayContentProvider());
opratorComboViewer.setInput(this.baseDataBean.getCurrentFilterExpressions());
opratorComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
baseDataBean.setCurrentExpression((String) sel.getFirstElement());
}
});
dynaComposite = new Composite(this, SWT.NONE);
dynaComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
GridLayout gldynaComposite = new GridLayout(1, false);
gldynaComposite.marginWidth = 0;
gldynaComposite.marginHeight = 0;
dynaComposite.setLayout(gldynaComposite);
valueText = new Text(dynaComposite, SWT.BORDER);
valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
addButton = new Button(this, SWT.NONE);
GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdAddButton.widthHint = 25;
addButton.setLayoutData(gdAddButton);
addButton.setText("+");
addButton.addListener(SWT.Selection, this);
deleteButton = new Button(this, SWT.NONE);
GridData gdDeletebutton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdDeletebutton.widthHint = 25;
deleteButton.setLayoutData(gdDeletebutton);
deleteButton.setText("-");
deleteButton.addListener(SWT.Selection, this);
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class AddOrEditMapRuleOfSrxDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
Composite langCmp = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(450, 100).applyTo(langCmp);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(langCmp);
Label modelLbl = new Label(langCmp, SWT.NONE);
modelLbl.setText(Messages.getString("srx.AddOrEditMapRuleOfSrxDialog.modelLbl"));
GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
langModelTxt = new Text(langCmp, SWT.BORDER);
langModelTxt.setLayoutData(textData);
Label langRuleNameLbl = new Label(langCmp, SWT.NONE);
langRuleNameLbl.setText(Messages.getString("srx.AddOrEditMapRuleOfSrxDialog.langRuleNameLbl"));
langRuleNameCmb = new Combo(langCmp, SWT.BORDER | SWT.READ_ONLY);
langRuleNameCmb.setLayoutData(textData);
// 给语言规则名称下拉框赋值
langRuleNameCmb.setItems(handler.getLanguageRuleNamesOfSrx_2(srxLocation).toArray(new String[] {}));
return tparent;
}
use of org.eclipse.swt.widgets.Combo in project translationstudio8 by heartsome.
the class AddOrEditElementOfXmlConvertDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
Composite composite = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);
// 元素类型下拉框的值, 备注:不能本地化
String[] typeValues = { "segment", "inline", "ignore" };
// 内联类型下拉框的值, 备注:不能本地化
String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link", "x-underlined", "x-other" };
// 保留空格下拉框的值, 备注:不能本地化
String[] remainSpaceVlaues = { "", "yes", "no" };
GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
textData.widthHint = 100;
// 元素名称
Label nameLbl = new Label(composite, SWT.NONE);
nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
nameLbl.setAlignment(SWT.RIGHT);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);
nameTxt = new Text(composite, SWT.BORDER);
nameTxt.setLayoutData(textData);
// 元素类型
Label typeLbl = new Label(composite, SWT.NONE);
typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);
typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
typeCmb.setLayoutData(textData);
typeCmb.setItems(typeValues);
typeCmb.select(0);
// 内联类型
Label inlineLbl = new Label(composite, SWT.NONE);
inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);
inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
inlineCmb.setLayoutData(textData);
inlineCmb.setItems(internalValues);
inlineCmb.setEnabled(false);
// 可翻译属性
Label transAttriLbl = new Label(composite, SWT.NONE);
transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);
transAtrriTxt = new Text(composite, SWT.BORDER);
transAtrriTxt.setLayoutData(textData);
// 保留空格
Label remainSpaceLbl = new Label(composite, SWT.NONE);
remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);
remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
remainSpaceCmb.setLayoutData(textData);
remainSpaceCmb.setItems(remainSpaceVlaues);
// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
typeCmb.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String type = typeCmb.getText();
if ("segment".equals(type)) {
inlineCmb.setText("");
inlineCmb.setEnabled(false);
transAtrriTxt.setEnabled(true);
} else if ("inline".equals(type)) {
inlineCmb.setEnabled(true);
transAtrriTxt.setText("");
transAtrriTxt.setEnabled(false);
} else if ("ignore".equals(type)) {
inlineCmb.setText("");
inlineCmb.setEnabled(false);
transAtrriTxt.setText("");
transAtrriTxt.setEnabled(false);
}
}
});
return tparent;
}
Aggregations