use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method run.
/**
* {@inheritDoc}
*/
public void run() {
save();
Dialog confColsDialog = new Dialog(Display.getCurrent().getActiveShell()) {
@Override
protected Control createDialogArea(Composite parent) {
return createColumnControlPanel(parent);
}
};
int result = confColsDialog.open();
if (result == Dialog.CANCEL) {
restore();
}
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method createColumnControlPanel.
/**
* Create the dialog area. TODO can be done much nicer ... but works for the first draft
*
* @param parent parent composite
* @return initialized control
*/
private Control createColumnControlPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NULL);
panel.setLayout(new RowLayout());
Label l = new Label(panel, SWT.NULL);
l.setText("Configure the columns");
Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
_chkBoxViewer = new CheckboxTableViewer(table);
_chkBoxViewer.setContentProvider(new ColTableContentProvider());
_chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
column.setText("Column");
column.setWidth(100);
_chkBoxViewer.getTable().setHeaderVisible(true);
_chkBoxViewer.setInput("x");
final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
IColumn col = _table.getTableModel().getColumn(i);
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
table.getColumn(0).pack();
table.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
TableItem item = (TableItem) event.item;
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
_tvs.setColumnVisible(col, item.getChecked());
} else {
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
}
}
});
Button upButton = new Button(panel, SWT.PUSH);
upButton.setText("up");
upButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx > firstColIdx) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx - 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Button downButton = new Button(panel, SWT.PUSH);
downButton.setText("down");
downButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx < _tvs.getSortedColumns().size() - 1) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx + 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
return panel;
}
use of org.eclipse.swt.widgets.Composite 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.Composite in project translationstudio8 by heartsome.
the class TermDbManagerDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite composite = (Composite) super.createDialogArea(parent);
GridLayout parentLayout = ((GridLayout) composite.getLayout());
parentLayout.numColumns = 4;
parentLayout.marginHeight = 0;
parentLayout.marginWidth = 0;
parentLayout.marginTop = 0;
parentLayout.verticalSpacing = 0;
parentLayout.horizontalSpacing = 0;
Control treeControl = createTreeAreaContents(composite);
createSash(composite, treeControl);
Label versep = new Label(composite, SWT.SEPARATOR | SWT.VERTICAL);
GridData verGd = new GridData(GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL);
versep.setLayoutData(verGd);
versep.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
Composite pageAreaComposite = new Composite(composite, SWT.NONE);
pageAreaComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(1, true);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
pageAreaComposite.setLayout(layout);
// Build the Page container
Composite pageContainer = createPageContainer(pageAreaComposite);
GridData pageContainerData = new GridData(GridData.FILL_BOTH);
pageContainerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
pageContainer.setLayoutData(pageContainerData);
// Build the separator line
Label bottomSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
bottomSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
return composite;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class TBDatabasePage method createContents.
@Override
protected Control createContents(Composite parent) {
// TODO Auto-generated method stub
Composite tparent = new Composite(parent, SWT.NONE);
tparent.setLayout(new GridLayout());
tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
// 添加术语匹配是否忽略大小写
{
Group commonGroup1 = new Group(tparent, SWT.NONE);
commonGroup1.setLayout(new GridLayout());
commonGroup1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
commonGroup1.setText(Messages.getString("preference.TBDatabasePage.commontitle"));
HsImageLabel imageLbale1 = new HsImageLabel(Messages.getString("preference.TBDatabasePage.commonsearchterm"), Activator.getImageDescriptor("images/preference/tb/tb_update_32.png"));
Composite comp1 = imageLbale1.createControl(commonGroup1);
btnCaseSensitive = new Button(comp1, SWT.CHECK);
btnCaseSensitive.setText(Messages.getString("preference.TBDatabasePage.commonCasesensitive"));
btnCaseSensitive.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
imageLbale1.computeSize();
}
Group commonGroup = new Group(tparent, SWT.NONE);
commonGroup.setLayout(new GridLayout());
commonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
commonGroup.setText(Messages.getString("preference.TBDatabasePage.commonGroup"));
HsImageLabel imageLbale = new HsImageLabel(Messages.getString("preference.TBDatabasePage.imageLbale"), Activator.getImageDescriptor("images/preference/tb/tb_update_32.png"));
Composite comp = imageLbale.createControl(commonGroup);
btnAlwaysAdd = new Button(comp, SWT.RADIO);
btnAlwaysAdd.setText(Messages.getString("preference.TBDatabasePage.btnAlwaysAdd"));
btnAlwaysAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnRepeatOverwrite = new Button(comp, SWT.RADIO);
btnRepeatOverwrite.setText(Messages.getString("preference.TBDatabasePage.btnRepeatOverwrite"));
btnRepeatOverwrite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnRepeatMerge = new Button(comp, SWT.RADIO);
btnRepeatMerge.setText(Messages.getString("preference.TBDatabasePage.btnRepeatMerge"));
btnRepeatMerge.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnRepeatIgnore = new Button(comp, SWT.RADIO);
btnRepeatIgnore.setText(Messages.getString("preference.TBDatabasePage.btnRepeatIgnore"));
btnRepeatIgnore.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
parent.pack();
imageLbale.computeSize();
int intUpdateTB = preferenceStore.getInt(TBPreferenceConstants.TB_UPDATE);
setInitValues(intUpdateTB);
return parent;
}
Aggregations