Search in sources :

Example 61 with Composite

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;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ImageData(org.eclipse.swt.graphics.ImageData) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 62 with Composite

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite)

Example 63 with Composite

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));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData)

Example 64 with Composite

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;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 65 with Composite

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();
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Language(net.heartsome.cat.common.locale.Language) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableCombo(org.eclipse.nebula.widgets.tablecombo.TableCombo)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)2054 GridData (org.eclipse.swt.layout.GridData)1441 GridLayout (org.eclipse.swt.layout.GridLayout)1419 Label (org.eclipse.swt.widgets.Label)853 Button (org.eclipse.swt.widgets.Button)694 SelectionEvent (org.eclipse.swt.events.SelectionEvent)577 Text (org.eclipse.swt.widgets.Text)519 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)463 Group (org.eclipse.swt.widgets.Group)305 Combo (org.eclipse.swt.widgets.Combo)210 Point (org.eclipse.swt.graphics.Point)198 FillLayout (org.eclipse.swt.layout.FillLayout)188 ModifyListener (org.eclipse.swt.events.ModifyListener)186 SelectionListener (org.eclipse.swt.events.SelectionListener)183 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)182 ModifyEvent (org.eclipse.swt.events.ModifyEvent)168 Table (org.eclipse.swt.widgets.Table)159 TableViewer (org.eclipse.jface.viewers.TableViewer)153 Control (org.eclipse.swt.widgets.Control)149 ArrayList (java.util.ArrayList)107