use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class LanguageCodesPreferencePage method createLanguageControls.
/**
* ========================暂注释掉 <br>
* 创建与当前语言区域相关的数字、货币、时间、短日期、长日期的格式显示控件
* @param parent
* ;
*/
// private void createLocaleFormatControls(Composite parent) {
// Composite formatControls = new Composite(parent, SWT.NONE);
// formatControls.setLayout(new GridLayout(3, false));
// formatControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
// GridData gridData;
//
// // 标题
// Label title = new Label(formatControls, SWT.NONE);
// gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
// gridData.horizontalSpan = 3;
// title.setLayoutData(gridData);
// title.setText("使用此格式显示数据的示例:");
// title.setToolTipText("使用此格式显示数据的示例");
//
// // 数字
// Label digitalLabel = new Label(formatControls, SWT.NONE);
// gridData = new GridData(SWT.BEGINNING);
// digitalLabel.setLayoutData(gridData);
// digitalLabel.setText("数字:");
// digitalLabel.setToolTipText("数字");
//
// digitalValue = new Label(formatControls, SWT.CENTER);
// gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 2;
// digitalValue.setLayoutData(gridData);
//
// // 货币
// Label currencyLabel = new Label(formatControls, SWT.NONE);
// gridData = new GridData(SWT.BEGINNING);
// currencyLabel.setLayoutData(gridData);
// currencyLabel.setText("货币:");
// currencyLabel.setToolTipText("货币");
//
// currencyValue = new Label(formatControls, SWT.CENTER);
// gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 2;
// currencyValue.setLayoutData(gridData);
//
// // 时间
// Label timeLabel = new Label(formatControls, SWT.NONE);
// gridData = new GridData(SWT.BEGINNING);
// timeLabel.setLayoutData(gridData);
// timeLabel.setText("时间:");
// timeLabel.setToolTipText("时间");
//
// timeValue = new Label(formatControls, SWT.CENTER);
// gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 2;
// timeValue.setLayoutData(gridData);
//
// // 短日期
// Label shortDateLabel = new Label(formatControls, SWT.NONE);
// gridData = new GridData(SWT.BEGINNING);
// shortDateLabel.setLayoutData(gridData);
// shortDateLabel.setText("短日期:");
// shortDateLabel.setToolTipText("短日期");
//
// shortDateValue = new Label(formatControls, SWT.CENTER);
// gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 2;
// shortDateValue.setLayoutData(gridData);
//
// // 长日期
// Label longDateLabel = new Label(formatControls, SWT.NONE);
// gridData = new GridData(SWT.BEGINNING);
// longDateLabel.setLayoutData(gridData);
// longDateLabel.setText("长日期:");
// longDateLabel.setToolTipText("长日期");
//
// longDateValue = new Label(formatControls, SWT.CENTER);
// gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 2;
// longDateValue.setLayoutData(gridData);
//
// Button customize = new Button(formatControls, SWT.BORDER);
// gridData = new GridData(SWT.RIGHT, SWT.BEGINNING, true, false);
// gridData.horizontalSpan = 3;
// customize.setLayoutData(gridData);
// customize.setText("自定义此格式……");
// customize.setToolTipText("自定义此格式……");
//
// }
/**
* 创建添加、删除按钮
* @param parent
* 项层容器 ;
*/
private void createLanguageControls(Composite parent) {
Composite btnsComposite = new Composite(parent, SWT.NONE);
btnsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
btnsComposite.setLayout(new GridLayout(3, true));
addBtn = new Button(btnsComposite, SWT.NONE);
GridData gd_addBtn = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
addBtn.setLayoutData(gd_addBtn);
addBtn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.addBtn"));
// addBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editBtn = new Button(btnsComposite, SWT.NONE);
GridData gd_editBtn = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
editBtn.setLayoutData(gd_editBtn);
editBtn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.editBtn"));
// editBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeBtn = new Button(btnsComposite, SWT.NONE);
removeBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
removeBtn.setText(Messages.getString("languagecode.LanguageCodesPreferencePage.removeBtn"));
// removeBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class TranslationPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite tparent = new Composite(parent, SWT.NONE);
tparent.setLayout(new GridLayout());
tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
Group group = new Group(tparent, SWT.NONE);
group.setLayout(new GridLayout());
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setText(Messages.getString("translation.TranslationPreferencePage.group"));
HsImageLabel imageLabel = new HsImageLabel(Messages.getString("translation.TranslationPreferencePage.imageLabel"), Activator.getImageDescriptor("images/preference/translate/trans_32.png"));
Composite comp = imageLabel.createControl(group);
btnAutoAdaptSpacePosition = new Button(comp, SWT.CHECK);
btnAutoAdaptSpacePosition.setText(Messages.getString("translation.TranslationPreferencePage.btnAutoAdaptSpacePosition"));
btnAutoAdaptSpacePosition.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnAutoApplyTmMatch = new Button(comp, SWT.CHECK);
btnAutoApplyTmMatch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnAutoApplyTmMatch.setText(Messages.getString("translation.TranslationPreferencePage.btnAutoApplyTmMatch"));
btnCopyToTarget = new Button(comp, SWT.CHECK);
btnCopyToTarget.setText(Messages.getString("translation.TranslationPreferencePage.btnCopyToTarget"));
btnCopyToTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// btnSkipNotTranslateText = new Button(comp, SWT.CHECK);
// btnSkipNotTranslateText.setText("翻译时跳过锁定文本段");
// btnSkipNotTranslateText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnAutoQuickTranslation = new Button(comp, SWT.CHECK);
btnAutoQuickTranslation.setText(Messages.getString("translation.TranslationPreferencePage.btnAutoQuickTranslation"));
btnAutoQuickTranslation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
imageLabel.computeSize();
Group openOfficeGroup = new Group(tparent, SWT.NONE);
openOfficeGroup.setLayout(new GridLayout());
openOfficeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
openOfficeGroup.setText(Messages.getString("translation.TranslationPreferencePage.openOfficeGroup"));
HsImageLabel imageLabel2 = new HsImageLabel(Messages.getString("translation.TranslationPreferencePage.imageLabel2"), Activator.getImageDescriptor("images/preference/translate/trans_office_32.png"));
Composite composite = imageLabel2.createControl(openOfficeGroup);
GridLayout gd = new GridLayout(3, false);
gd.marginLeft = 0;
gd.marginTop = 0;
composite.setLayout(gd);
new Label(composite, SWT.NONE).setText(Messages.getString("translation.TranslationPreferencePage.lblOO"));
txtPath = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
txtPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnBrowse = new Button(composite, SWT.NONE);
btnBrowse.setText(Messages.getString("translation.TranslationPreferencePage.btnBrowse"));
imageLabel2.computeSize();
setValues(false);
initListener();
return tparent;
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class NewProjectWizardLanguagePage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
// source language control
Group sourceLanguageGrp = new Group(container, SWT.NONE);
sourceLanguageGrp.setLayout(new GridLayout(1, false));
sourceLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
sourceLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.sourceLanguageGrp"));
srcLangComboViewer = new TableComboViewer(sourceLanguageGrp, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = srcLangComboViewer.getTableCombo();
// set options.
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
srcLangComboViewer.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
srcLangComboViewer.setLabelProvider(new LanguageLabelProvider());
srcLangComboViewer.setContentProvider(new ArrayContentProvider());
srcLangComboViewer.setInput(languages);
srcLangComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
srcLanguage = (Language) selection.getFirstElement();
validator.update();
}
});
// initialization remember value
String rmSrcLangCode = ps.getString(IPreferenceConstants.NEW_PROJECT_SRC_LANG);
if (rmSrcLangCode != null && !rmSrcLangCode.equals("")) {
for (Language srcLang : languages) {
if (srcLang.getCode().equals(rmSrcLangCode)) {
srcLangComboViewer.setSelection(new StructuredSelection(srcLang));
break;
}
}
}
// end source language
// target language control
Group targetLanguageGrp = new Group(container, SWT.NONE);
targetLanguageGrp.setLayout(new GridLayout(3, false));
targetLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
targetLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.targetLanguageGrp"));
targetLangControl.createControl(targetLanguageGrp);
// end Target language
setControl(container);
validator.update();
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class NewProjectWizardProjInfoPage method reload.
public void reload() {
if (lstText != null) {
lstText.clear();
}
if (lstCombo != null) {
lstCombo.clear();
}
ArrayList<String> lstField = PreferenceUtil.getProjectFieldList();
LinkedHashMap<String, ArrayList<String>> mapAttr = PreferenceUtil.getProjectAttributeMap();
if ((lstField != null && lstField.size() > 0) || (mapAttr != null && mapAttr.size() > 0)) {
if (groupField == null || groupField.isDisposed()) {
groupField = new Group((Composite) getControl(), SWT.None);
groupField.setLayout(new GridLayout());
GridData fieldData = new GridData(GridData.FILL_BOTH);
groupField.setLayoutData(fieldData);
groupField.setText(Messages.getString("wizards.NewProjectWizardProjInfoPage.groupField"));
cmpScrolled = new ScrolledComposite(groupField, SWT.V_SCROLL);
cmpScrolled.setAlwaysShowScrollBars(false);
cmpScrolled.setLayoutData(new GridData(GridData.FILL_BOTH));
cmpScrolled.setExpandHorizontal(true);
cmpScrolled.setExpandVertical(true);
cmpField = new Composite(cmpScrolled, SWT.None);
cmpField.setLayout(new GridLayout(2, false));
cmpScrolled.setContent(cmpField);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
if (cmpField != null && !cmpField.isDisposed()) {
for (Control control : cmpField.getChildren()) {
control.dispose();
}
cmpField.layout();
cmpScrolled.layout();
groupField.layout();
groupField.getParent().layout();
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
if (lstField != null && lstField.size() > 0) {
if (lstText == null) {
lstText = new ArrayList<Text>();
}
for (String strField : lstField) {
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = strField.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x >= 100) {
gd.widthHint = 100;
}
Text txt = new Text(cmpField, SWT.BORDER);
txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txt.setData(strField);
txt.addListener(SWT.Modify, this);
lstText.add(txt);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
if (mapAttr != null && mapAttr.size() > 0) {
Iterator<Entry<String, ArrayList<String>>> it = mapAttr.entrySet().iterator();
if (lstCombo == null) {
lstCombo = new ArrayList<Combo>();
}
while (it.hasNext()) {
Entry<String, ArrayList<String>> entry = (Entry<String, ArrayList<String>>) it.next();
String attrName = entry.getKey();
ArrayList<String> lstAttrVal = entry.getValue();
lstAttrVal.add(0, "");
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = attrName.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x >= 100) {
gd.widthHint = 100;
}
Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmb.setItems(lstAttrVal.toArray(new String[lstAttrVal.size()]));
cmb.select(0);
cmb.setData(attrName);
lstCombo.add(cmb);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
cmpField.layout();
cmpScrolled.layout();
groupField.layout();
groupField.getParent().layout();
}
} else if (groupField != null && !groupField.isDisposed()) {
Composite cmpParent = groupField.getParent();
groupField.dispose();
cmpParent.layout();
}
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class NewProjectWizardSourceFilePage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
setControl(container);
fileListViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
fileListViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
fileListViewer.setContentProvider(new ArrayContentProvider());
fileListViewer.setInput(srcFileList);
if (this.converterCaller != null) {
final Button btnConvert = new Button(container, SWT.CHECK);
btnConvert.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.btnConvert"));
btnConvert.setSelection(true);
isOpenConverter = true;
btnConvert.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isOpenConverter = btnConvert.getSelection();
}
});
}
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
Button addBtn = new Button(composite, SWT.NONE);
addBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.addBtn"));
addBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell(), SWT.MULTI);
// CONVERTEREXTENTION
String[] supExtentions = new String[] { "*.mif;*.idml;*.inx;*.xlf;*.rtf;*.po;*.properties;*.js;*.mqxlz;*.doc;*.xls;*.ppt;" + "*.docx;*.xlsx;*.pptx;*.odt;*.ods;*.odp;*.odg;*.rtf;*.sdlxliff;*.ttx;*.htm;*.html;*.txt;*.resx;*.rc;*.xml;*.txml", "*.*" };
dlg.setFilterExtensions(supExtentions);
if (dlg.open() != null) {
String[] files = dlg.getFileNames();
for (int i = 0; i < files.length; i++) {
StringBuffer buf = new StringBuffer(dlg.getFilterPath());
buf.append(File.separator);
buf.append(files[i]);
String file = buf.toString();
if (!srcFileList.contains(file)) {
srcFileList.add(file);
}
}
fileListViewer.refresh();
}
}
});
Button deleteBtn = new Button(composite, SWT.NONE);
deleteBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.deleteBtn"));
deleteBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selections = (IStructuredSelection) fileListViewer.getSelection();
Iterator<?> it = selections.iterator();
while (it.hasNext()) {
String file = (String) it.next();
srcFileList.remove(file);
}
fileListViewer.refresh();
}
});
}
Aggregations