use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AddOrUpdateLanguageDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
tparent.setLayoutData(data);
GridLayout layout = new GridLayout(3, false);
tparent.setLayout(layout);
GridData txtData = new GridData(GridData.FILL_HORIZONTAL);
txtData.horizontalSpan = 2;
Label lbl = new Label(tparent, SWT.NONE);
lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.lblLangImage"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
imageLabel = new Label(tparent, SWT.NONE);
GridData imGd = new GridData();
imGd.widthHint = 16;
imGd.heightHint = 12;
imageLabel.setLayoutData(imGd);
imageLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
try {
String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
if (this.imagePath != null && !this.imagePath.equals("")) {
String imagePath = bundlePath + this.imagePath;
if (image != null && !image.isDisposed()) {
image.dispose();
}
image = new Image(getShell().getDisplay(), imagePath);
}
if (image != null) {
ImageData imgData = image.getImageData().scaledTo(16, 12);
if (image != null && !image.isDisposed()) {
image.dispose();
}
image = new Image(getShell().getDisplay(), imgData);
imageLabel.setData(this.imagePath);
} else {
if (image != null && !image.isDisposed()) {
image.dispose();
}
image = new Image(getShell().getDisplay(), bundlePath + ImageConstant.LANG_EMPTYPIC);
}
imageLabel.setImage(image);
} catch (IOException e) {
e.printStackTrace();
}
imageLabel.setToolTipText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.imageLabel"));
imageLabel.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
FileDialog dlg = new FileDialog(getShell());
dlg.setFilterExtensions(new String[] { "*.png" });
String path = dlg.open();
if (path != null) {
ImageData data = new ImageData(path).scaledTo(16, 12);
if (image != null && !image.isDisposed()) {
image.dispose();
}
image = new Image(getShell().getDisplay(), data);
imageLabel.setImage(image);
imageLabel.setData(path);
}
}
});
new Label(tparent, SWT.NONE).setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.lblImage"));
lbl = new Label(tparent, SWT.NONE);
lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.txtCode"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
txtCode = new Text(tparent, SWT.BORDER);
txtCode.setLayoutData(txtData);
txtCode.setText(strCode == null ? "" : strCode);
lbl = new Label(tparent, SWT.NONE);
lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.txtName"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
txtName = new Text(tparent, SWT.BORDER);
txtName.setLayoutData(txtData);
txtName.setText(strName == null ? "" : strName);
lbl = new Label(tparent, SWT.NONE);
lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.isBidi"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
btnIsBidi = new Button(tparent, SWT.RADIO);
btnIsBidi.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.btnIsBidi"));
btnIsNotBidi = new Button(tparent, SWT.RADIO);
btnIsNotBidi.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.btnIsNotBidi"));
if (blnIsBidi) {
btnIsBidi.setSelection(true);
} else {
btnIsNotBidi.setSelection(true);
}
tparent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
txtCode.forceFocus();
txtCode.selectAll();
return tparent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class LanguageCodesPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite page = initContents(parent);
fill();
// setProperty();
addListener();
return page;
}
use of org.eclipse.swt.widgets.Composite 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.widgets.Composite 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.widgets.Composite 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();
}
Aggregations