use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class JaretTablePrintDialog method createParameterArea.
protected void createParameterArea(Composite parent) {
GridLayout gl = new GridLayout();
gl.numColumns = 2;
parent.setLayout(gl);
_repeatHeader = new Button(parent, SWT.CHECK);
_repeatHeader.setSelection(_configuration.getRepeatHeader());
_repeatHeader.setText("Repeat header");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
_repeatHeader.setLayoutData(gd);
final Label scaleText = new Label(parent, SWT.RIGHT);
scaleText.setText(getScaleText());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scaleText.setLayoutData(gd);
final Scale scale = new Scale(parent, SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scale.setLayoutData(gd);
scale.setMaximum(1000);
scale.setMinimum(10);
scale.setSelection((int) (_configuration.getScale() * 100));
scale.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent ev) {
int val = scale.getSelection();
double s = (double) val / 100.0;
_configuration.setScale(s);
scaleText.setText(getScaleText());
updateConf();
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
_pagesLabel = new Label(parent, SWT.RIGHT);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
_pagesLabel.setLayoutData(gd);
_printerData = _pdatas[_printerCombo.getSelectionIndex()];
Printer printer = new Printer(_printerData);
_tablePrinter.setPrinter(printer);
Point pages = _tablePrinter.calculatePageCount(_configuration);
printer.dispose();
_pagesLabel.setText(getPagesText(pages));
}
use of org.eclipse.swt.layout.GridLayout 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.layout.GridLayout 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.layout.GridLayout 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;
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class ProjectSettingTBPage method createContents.
/**
* Create contents of the preference page.
* @param parent
*/
@Override
public Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer.setContentProvider(new ArrayContentProvider());
createColumn(tableViewer);
tableViewer.setInput(curDbList);
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
DatabaseModelBean dbModel = (DatabaseModelBean) selection.getFirstElement();
if (null == dbModel) {
return;
}
if (Constants.DBTYPE_SQLITE.equals(dbModel.getDbType())) {
String path = dbModel.getItlDBLocation() + File.separator + dbModel.getDbName();
File file = new File(path);
if (!file.exists()) {
setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.FileNotFoundMsg"));
return;
} else {
setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.title"));
}
}
if (dbModel != null && !dbModel.isHasMatch()) {
setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.msg1"));
}
}
});
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
composite.setLayout(new GridLayout(5, false));
new Label(composite, SWT.NONE);
HSDropDownButton addBtn = new HSDropDownButton(composite, SWT.NONE);
addBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.addBtn"));
Menu addMenu = addBtn.getMenu();
MenuItem item = new MenuItem(addMenu, SWT.PUSH);
item.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddFileTb"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialg = new FileDialog(getShell());
fileDialg.setFilterExtensions(new String[] { "*.hstb", "*.*" });
String result = fileDialg.open();
if (result == null) {
return;
}
File f = new File(result);
if (!f.exists()) {
return;
}
Map<DatabaseModelBean, String> r = null;
try {
r = Utils.convertFile2TbModel(f, false);
} catch (Exception e1) {
MessageDialog.openError(getShell(), Messages.getString("tb.dialog.addFileTb.errorTitle"), e1.getMessage());
}
if (r == null) {
return;
}
Iterator<DatabaseModelBean> it = r.keySet().iterator();
if (it.hasNext()) {
DatabaseModelBean selectedVal = it.next();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
dbList.add(selectedVal);
addToCurrDbList(dbList);
}
}
});
MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
serverItem.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddServerTb"));
serverItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TermDbManagerDialog dialog = new TermDbManagerDialog(getShell());
dialog.setDialogUseFor(TermDbManagerDialog.TYPE_DBSELECTED);
if (dialog.open() == Window.OK) {
Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
while (it.hasNext()) {
dbList.add(it.next());
}
addToCurrDbList(dbList);
}
}
});
Button createBtn = new Button(composite, SWT.NONE);
createBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.createBtn"));
createBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
NewTermDbWizard wizard = new NewTermDbWizard();
TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
DatabaseModelBean dbModel = wizard.getCreateDb();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
dbList.add(dbModel);
addToCurrDbList(dbList);
}
}
});
Button removeBtn = new Button(composite, SWT.NONE);
removeBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.removeBtn"));
removeBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
removeForCurrDbList((IStructuredSelection) tableViewer.getSelection());
}
});
Button importTmxBtn = new Button(composite, SWT.NONE);
importTmxBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.importTmxBtn"));
importTmxBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
Iterator<?> it = selection.iterator();
if (it.hasNext()) {
DatabaseModelBean dbModel = (DatabaseModelBean) it.next();
TbxImportWizard wizard = new TbxImportWizard(dbModel);
TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
checkDbHashMatch(dbModel);
tableViewer.refresh();
}
// 刷新项目
ResourceUtils.refreshCurentSelectProject();
} else {
MessageDialog.openInformation(getShell(), Messages.getString("projectsetting.ProjectSettingTBPage.msgTitle"), Messages.getString("projectsetting.ProjectSettingTBPage.msg2"));
}
}
});
addBtn.setFocus();
Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point createPoint = createBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point remPoint = removeBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point importPoint = importTmxBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(addPoint.x, createPoint.x)));
GridData btnData = new GridData();
btnData.widthHint = width + 10;
addBtn.setLayoutData(btnData);
createBtn.setLayoutData(btnData);
removeBtn.setLayoutData(btnData);
importTmxBtn.setLayoutData(btnData);
return container;
}
Aggregations