Search in sources :

Example 71 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class KeysPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IWorkbenchHelpContextIds.KEYS_PREFERENCE_PAGE);
    final Composite page = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    page.setLayout(layout);
    Group groupParent = new Group(page, SWT.None);
    groupParent.setLayout(new GridLayout());
    groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
    groupParent.setText(Messages.getString("preferencepage.KeysPreferencePage.groupParent"));
    HsImageLabel imageLabel = new HsImageLabel(Messages.getString("preferencepage.KeysPreferencePage.imageLabel"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_KEY));
    Composite cmp = imageLabel.createControl(groupParent);
    cmp.setLayout(new GridLayout());
    Composite cmpTemp = (Composite) imageLabel.getControl();
    cmpTemp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite cmpContent = new Composite(cmpTemp, SWT.None);
    cmpContent.setLayout(new GridLayout());
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    cmpContent.setLayoutData(data);
    // 不显示过滤文本框
    PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.SHOW_FILTERED_TEXTS, false);
    IDialogSettings settings = getDialogSettings();
    fPatternFilter = new CategoryPatternFilter(true, commandService.getCategory(null));
    if (settings.get(TAG_FILTER_UNCAT) != null) {
        fPatternFilter.filterCategories(settings.getBoolean(TAG_FILTER_UNCAT));
    }
    createTree(cmpContent);
    fill();
    applyDialogFont(cmpContent);
    imageLabel.computeSize();
    return page;
}
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) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData)

Example 72 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class ProjectSettingBaseInfoPage method createContents.

/**
	 * Create contents of the preference page.
	 * @param parent
	 */
@Override
public Control createContents(Composite parent) {
    // GridData fieldData = new GridData();
    // fieldData.heightHint = 10;
    // Composite container = new Composite(parent, SWT.NULL);
    // container.setLayout(new GridLayout());
    // container.setLayoutData(fieldData);
    //
    // ScrolledComposite cmpScrolled = new ScrolledComposite(container, SWT.V_SCROLL);
    // cmpScrolled.setAlwaysShowScrollBars(true);
    // cmpScrolled.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // cmpScrolled.setExpandHorizontal(true);
    // cmpScrolled.setExpandVertical(true);
    Composite cmpField = new Composite(parent, SWT.None);
    cmpField.setLayout(new GridLayout(2, false));
    // cmpScrolled.setContent(cmpField);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    Label label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.projectNameLabel"));
    Point namePoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    projectNameLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.sourceLangLabel"));
    Point srcPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    sourceLangLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    label = new Label(cmpField, SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.targetlangLabel"));
    Point tgtPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    targetlangLabel = new Label(cmpField, SWT.NONE);
    // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    initData();
    int width = Math.max(namePoint.x, Math.max(srcPoint.x, tgtPoint.x)) + 10;
    Map<String, String> mapField = projCfgBean.getMapField();
    if (mapField != null && mapField.size() > 0) {
        lstText = new ArrayList<Text>();
        Iterator<Entry<String, String>> it = mapField.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, String> entry = (Entry<String, String>) it.next();
            Label lbl = new Label(cmpField, SWT.WRAP);
            String strLbl = TextUtil.xmlToString(entry.getKey()).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 > width) {
                gd.widthHint = width;
            }
            Text txt = new Text(cmpField, SWT.BORDER);
            txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            txt.setText(TextUtil.xmlToString(entry.getValue()));
            txt.setData(TextUtil.xmlToString(entry.getKey()));
            txt.addModifyListener(new ModifyListener() {

                public void modifyText(ModifyEvent e) {
                    if (lstText != null && lstText.size() > 0) {
                        boolean isValid = true;
                        for (Text txt : lstText) {
                            String value = txt.getText();
                            if (value != null && !value.equals("")) {
                                if (value.trim().equals("")) {
                                    setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg3"));
                                    isValid = false;
                                    setValid(false);
                                    break;
                                } else if (value.trim().length() > 50) {
                                    setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg4"));
                                    setValid(false);
                                    isValid = false;
                                    break;
                                }
                            }
                        }
                        if (isValid) {
                            setErrorMessage(null);
                            setValid(true);
                        }
                    }
                }
            });
            lstText.add(txt);
        // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    }
    Map<String, Object[]> mapAttr = projCfgBean.getMapAttr();
    if (mapAttr != null && mapAttr.size() > 0) {
        lstCombo = new ArrayList<Combo>();
        Iterator<Entry<String, Object[]>> it = mapAttr.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, Object[]> entry = (Entry<String, Object[]>) it.next();
            String attrName = TextUtil.xmlToString(entry.getKey());
            String attrSelVal = TextUtil.xmlToString((String) entry.getValue()[0]);
            @SuppressWarnings("unchecked") List<String> lstAttrVal = (List<String>) entry.getValue()[1];
            String[] arrAttrVal = new String[lstAttrVal.size()];
            int selIndex = 0;
            for (int i = 0; i < lstAttrVal.size(); i++) {
                arrAttrVal[i] = TextUtil.xmlToString(lstAttrVal.get(i));
                if (attrSelVal.equals(arrAttrVal[i])) {
                    selIndex = i;
                }
            }
            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 > width) {
                gd.widthHint = width;
            }
            Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
            cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            cmb.setItems(arrAttrVal);
            cmb.select(selIndex);
            cmb.setData(attrName);
            lstCombo.add(cmb);
        // cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    }
    return cmpField;
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData)

Example 73 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class ImportProjectWizardPage2 method createResourceTree.

/**
	 * 创建两颗显示资源树
	 */
private void createResourceTree(Composite tparent) {
    Composite resourceTreeCmp = new Composite(tparent, SWT.NONE);
    resourceTreeCmp.setLayoutData(new GridData(GridData.FILL_BOTH));
    resourceTreeCmp.setLayout(new GridLayout(2, true));
    Label leftLbl = new Label(resourceTreeCmp, SWT.NONE);
    leftLbl.setText(Messages.getString("importProjectWizardPage.projectOfImport"));
    Label rightLbl = new Label(resourceTreeCmp, SWT.NONE);
    rightLbl.setText(Messages.getString("importProjectWizardPage.repeatedContent"));
    // 定义两颗树
    selectContentProvider = new SelectProjectContentProvider();
    repeateContentProvider = new RepeatProjectContentProvider();
    selectElementTree = new ResourceTree(resourceTreeCmp, selectContentProvider, new ProjectLabelProvider());
    repeatElementTree = new ResourceTree(resourceTreeCmp, repeateContentProvider, new ProjectLabelProvider());
    // 左边的按钮
    Composite leftBtnCmp = new Composite(resourceTreeCmp, SWT.NONE);
    leftBtnCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(3).applyTo(leftBtnCmp);
    leftSelectAllBtn = new Button(leftBtnCmp, SWT.PUSH);
    leftSelectAllBtn.setText(Messages.getString("importProjectWizardPage.leftSelectAllBtn"));
    leftSelectAllBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(leftSelectAllBtn);
    leftDisSelectAllBtn = new Button(leftBtnCmp, SWT.PUSH);
    leftDisSelectAllBtn.setText(Messages.getString("importProjectWizardPage.leftDisSelectAllBtn"));
    leftDisSelectAllBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(leftDisSelectAllBtn);
    leftAllExpandBtn = new Button(leftBtnCmp, SWT.PUSH);
    leftAllExpandBtn.setText(Messages.getString("importProjectWizardPage.leftExpandAllBtn"));
    leftAllExpandBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(leftAllExpandBtn);
    // 右边的按钮
    Composite rightBtnCmp = new Composite(resourceTreeCmp, SWT.NONE);
    rightBtnCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(3).applyTo(rightBtnCmp);
    rightSelectAllBtn = new Button(rightBtnCmp, SWT.PUSH);
    rightSelectAllBtn.setText(Messages.getString("importProjectWizardPage.rightSelectAllBtn"));
    rightSelectAllBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(rightSelectAllBtn);
    rightDisSelectAllBtn = new Button(rightBtnCmp, SWT.PUSH);
    rightDisSelectAllBtn.setText(Messages.getString("importProjectWizardPage.rightDisSelectAllBtn"));
    rightDisSelectAllBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(rightDisSelectAllBtn);
    rightAllExpandBtn = new Button(rightBtnCmp, SWT.PUSH);
    rightAllExpandBtn.setText(Messages.getString("importProjectWizardPage.rightExpandAllBtn"));
    rightAllExpandBtn.addListener(SWT.Selection, this);
    setButtonLayoutData(rightAllExpandBtn);
    // 初始化两颗树的事件
    initTreeListener();
    selectElementTree.setInput(this);
    repeatElementTree.setInput(this);
}
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) Label(org.eclipse.swt.widgets.Label) ResourceTree(net.heartsome.cat.ts.importproject.widgiet.ResourceTree)

Example 74 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class ImportProjectWizardPage2 method createBrowseBtn.

/**
	 * 创建 浏览 文件按钮
	 * @param tparent
	 */
private void createBrowseBtn(Composite tparent) {
    Composite btnCmp = new Composite(tparent, SWT.NONE);
    btnCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnCmp.setLayout(new GridLayout(3, false));
    Label lbl = new Label(btnCmp, SWT.NONE);
    lbl.setText(Messages.getString("importProjectWizardPage.selectFileLbl"));
    filePathTxt = new Text(btnCmp, SWT.BORDER);
    filePathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    browseBtn = new Button(btnCmp, SWT.NONE);
    browseBtn.setText(Messages.getString("importProjectWizardPage.broswer"));
    browseBtn.addListener(SWT.Selection, this);
}
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) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 75 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class MachineTranslationPreferencePage method createBingTranslateArea.

private Composite createBingTranslateArea(Composite tparent) {
    Group apiKeySettingGroup = new Group(tparent, SWT.NONE);
    apiKeySettingGroup.setText(Messages.getString("preference.BingPreferencePage.apiKeySettingGroup"));
    apiKeySettingGroup.setLayout(new GridLayout(1, false));
    apiKeySettingGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    HsImageLabel lbKeySetting = new HsImageLabel(Messages.getString("preference.BingPreferencePage.lbKeySetting"), Activator.getImageDescriptor("images/trans_bing_key_32.png"));
    Composite com = lbKeySetting.createControl(apiKeySettingGroup);
    com.setLayout(new GridLayout(3, false));
    Label lblId = new Label(com, SWT.NONE);
    lblId.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblId.setText(Messages.getString("preference.BingPreferencePage.lblId"));
    idText = new Text(com, SWT.BORDER);
    idText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new Label(com, SWT.NONE);
    Label lblApiKey = new Label(com, SWT.NONE);
    lblApiKey.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblApiKey.setText(Messages.getString("preference.BingPreferencePage.lblApiKey"));
    bingKeyText = new Text(com, SWT.BORDER);
    bingKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    bingStateLable = new Label(com, SWT.NONE);
    bingStateLable.setImage(errorImage);
    new Label(com, SWT.NONE);
    Button validateKey = new Button(com, SWT.NONE);
    validateKey.setText(Messages.getString("preference.BingPreferencePage.validateKey"));
    validateKey.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String id = idText.getText();
            String bingKey = bingKeyText.getText();
            if (id == null || id.equals("")) {
                MessageDialog.openInformation(getShell(), Messages.getString("preference.BingPreferencePage.msgTitle"), Messages.getString("preference.BingPreferencePage.msg1"));
                return;
            }
            if (bingKey == null || bingKey.equals("")) {
                MessageDialog.openInformation(getShell(), Messages.getString("preference.BingPreferencePage.msgTitle"), Messages.getString("preference.BingPreferencePage.msg2"));
                return;
            }
            bingValidator();
            setComponentsState();
            if (!bingState) {
                MessageDialog.openInformation(getShell(), Messages.getString("preference.BingPreferencePage.msgTitle"), Messages.getString("preference.BingPreferencePage.msg3"));
                return;
            }
        }
    });
    new Label(com, SWT.NONE);
    new Label(com, SWT.NONE);
    Link link = new Link(com, SWT.NONE);
    link.setText("<a>" + Messages.getString("preference.BingPreferencePage.link") + "</a>");
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Program.launch("http://msdn.microsoft.com/en-us/library/hh454950.aspx");
        }
    });
    link.setToolTipText("http://msdn.microsoft.com/en-us/library/hh454950.aspx");
    new Label(com, SWT.NONE);
    lbKeySetting.computeSize();
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)1868 GridData (org.eclipse.swt.layout.GridData)1646 Composite (org.eclipse.swt.widgets.Composite)1417 Label (org.eclipse.swt.widgets.Label)839 Button (org.eclipse.swt.widgets.Button)672 SelectionEvent (org.eclipse.swt.events.SelectionEvent)597 Text (org.eclipse.swt.widgets.Text)510 Group (org.eclipse.swt.widgets.Group)491 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)481 Combo (org.eclipse.swt.widgets.Combo)215 ModifyListener (org.eclipse.swt.events.ModifyListener)199 SelectionListener (org.eclipse.swt.events.SelectionListener)197 ModifyEvent (org.eclipse.swt.events.ModifyEvent)190 Table (org.eclipse.swt.widgets.Table)138 Point (org.eclipse.swt.graphics.Point)131 TableViewer (org.eclipse.jface.viewers.TableViewer)112 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)109 Shell (org.eclipse.swt.widgets.Shell)107 FillLayout (org.eclipse.swt.layout.FillLayout)96 ArrayList (java.util.ArrayList)89