Search in sources :

Example 96 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class CustomMessageDialog method createMessageArea.

@Override
protected Control createMessageArea(Composite composite) {
    Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        addAccessibleListeners(imageLabel, image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }
    // create message
    if (message != null) {
        text = new StyledText(composite, getMessageLabelStyle());
        text.setBackground(composite.getBackground());
        text.setText(message);
        text.setEditable(false);
        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT).applyTo(text);
        setStyle();
    }
    return composite;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Label(org.eclipse.swt.widgets.Label) Image(org.eclipse.swt.graphics.Image)

Example 97 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class GetActiveKeyDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginTop = 10;
    tparent.setLayout(layout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
    Composite compNav = new Composite(tparent, SWT.NONE);
    GridLayout navLayout = new GridLayout();
    compNav.setLayout(navLayout);
    createNavigation(compNav);
    Group groupActivekey = new Group(tparent, SWT.NONE);
    groupActivekey.setText(Messages.getString("license.GetActiveKeyDialog.activekey"));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(groupActivekey);
    GridLayout layoutGroup = new GridLayout(2, false);
    layoutGroup.marginWidth = 5;
    layoutGroup.marginHeight = 20;
    groupActivekey.setLayout(layoutGroup);
    StyledText text = new StyledText(groupActivekey, SWT.WRAP | SWT.READ_ONLY);
    text.setBackground(text.getParent().getBackground());
    text.setText(Messages.getString("license.GetActiveKeyDialog.activemessage"));
    GridData dataText = new GridData();
    dataText.horizontalSpan = 2;
    dataText.widthHint = 470;
    text.setLayoutData(dataText);
    int start = Messages.getString("license.GetActiveKeyDialog.activemessage").indexOf(Messages.getString("license.GetActiveKeyDialog.ts"));
    int length = Messages.getString("license.GetActiveKeyDialog.ts").length();
    StyleRange styleRange = new StyleRange();
    styleRange.start = start;
    styleRange.length = length;
    styleRange.fontStyle = SWT.BOLD;
    styleRange.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
    text.setStyleRange(styleRange);
    Label label = new Label(groupActivekey, SWT.WRAP | SWT.NONE);
    label.setText(Messages.getString("license.GetActiveKeyDialog.activemessage1"));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(label);
    textActivekey = new Text(groupActivekey, SWT.MULTI | SWT.WRAP);
    textActivekey.setEditable(false);
    textActivekey.setText(activekey);
    textActivekey.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 150).applyTo(textActivekey);
    Button btnCopy = new Button(groupActivekey, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.END).applyTo(btnCopy);
    btnCopy.setImage(Activator.getImageDescriptor("images/help/copy.png").createImage());
    btnCopy.setToolTipText(Messages.getString("license.GetActiveKeyDialog.copytoclipboard"));
    btnCopy.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            Clipboard cb = new Clipboard(Display.getCurrent());
            String textData = textActivekey.getText();
            TextTransfer textTransfer = TextTransfer.getInstance();
            cb.setContents(new Object[] { textData }, new Transfer[] { textTransfer });
        }
    });
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) StyleRange(org.eclipse.swt.custom.StyleRange) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 98 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class OfflineActiveDialog method createIdInputComp.

private void createIdInputComp(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(11, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    comp.setLayout(layout);
    GridData compData = new GridData();
    comp.setLayoutData(compData);
    GridData textData = new GridData();
    textData.widthHint = 40;
    GridData labelData = new GridData();
    labelData.widthHint = 5;
    text1 = new Text(comp, SWT.BORDER);
    text1.setLayoutData(textData);
    text1.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text1.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text1.setText(s.substring(0, 4));
                            text2.setFocus();
                            text2.setText(s.substring(4));
                        } else if (length == 4) {
                            text2.setFocus();
                        }
                    }
                } else {
                    text1.setText(s.substring(0, i));
                    break;
                }
            }
        }
    });
    Label label = new Label(comp, SWT.NONE);
    label.setLayoutData(labelData);
    text2 = new Text(comp, SWT.BORDER);
    text2.setLayoutData(textData);
    text2.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text2.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text2.setText(s.substring(0, 4));
                            text3.setFocus();
                            text3.setText(s.substring(4));
                        } else if (length == 4) {
                            text3.setFocus();
                        }
                    }
                } else {
                    text2.setText(s.substring(0, i));
                }
            }
        }
    });
    label = new Label(comp, SWT.NONE);
    label.setLayoutData(labelData);
    text3 = new Text(comp, SWT.BORDER);
    text3.setLayoutData(textData);
    text3.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text3.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text3.setText(s.substring(0, 4));
                            text4.setFocus();
                            text4.setText(s.substring(4));
                        } else if (length == 4) {
                            text4.setFocus();
                        }
                    }
                } else {
                    text3.setText(s.substring(0, i));
                }
            }
        }
    });
    label = new Label(comp, SWT.NONE);
    label.setLayoutData(labelData);
    text4 = new Text(comp, SWT.BORDER);
    text4.setLayoutData(textData);
    text4.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text4.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text4.setText(s.substring(0, 4));
                            text5.setFocus();
                            text5.setText(s.substring(4));
                        } else if (length == 4) {
                            text5.setFocus();
                        }
                    }
                } else {
                    text4.setText(s.substring(0, i));
                }
            }
        }
    });
    label = new Label(comp, SWT.NONE);
    label.setLayoutData(labelData);
    text5 = new Text(comp, SWT.BORDER);
    text5.setLayoutData(textData);
    text5.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text5.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text5.setText(s.substring(0, 4));
                            text6.setFocus();
                            text6.setText(s.substring(4));
                        } else if (length == 4) {
                            text6.setFocus();
                        }
                    }
                } else {
                    text5.setText(s.substring(0, i));
                }
            }
        }
    });
    label = new Label(comp, SWT.NONE);
    label.setLayoutData(labelData);
    text6 = new Text(comp, SWT.BORDER);
    text6.setLayoutData(textData);
    text6.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String s = text6.getText();
            s = s.replaceAll("-", "");
            int length = s.length();
            for (int i = 0; i < 4; i++) {
                if (i >= length) {
                    break;
                }
                char c = s.charAt(i);
                if (Character.isDigit(c) || Character.isLetter(c)) {
                    if (i == 3) {
                        if (length > 4) {
                            text6.setText(s.substring(0, 4));
                        }
                    }
                } else {
                    text6.setText(s.substring(0, i));
                }
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 99 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class TermDbManagerImportWizardTbxPage 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(3, false));
    Label lblTmx = new Label(container, SWT.NONE);
    lblTmx.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTmx.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblTmx"));
    tbxFileText = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    tbxFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tbxFileText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validator();
        }
    });
    Button tmxFileBorwserBtn = new Button(container, SWT.NONE);
    tmxFileBorwserBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.tmxFileBorwserBtn"));
    tmxFileBorwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell());
            String[] filterExt = { "*.tbx", "*.xlsx", "*.txt" };
            dlg.setFilterExtensions(filterExt);
            String path = dlg.open();
            // Messages.getString("wizard.TermDbManagerImportWizardTbxPage.openFile"), SWT.OPEN);
            if (path != null) {
                tbxFileText.setText(path);
            }
        }
    });
    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblNewLabel"));
    text = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validator();
        }
    });
    HSDropDownButton addBtn = new HSDropDownButton(container, SWT.NONE);
    addBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.button"));
    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()) {
                dbModel = it.next();
                text.setText(f.getAbsolutePath());
            }
        }
    });
    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> list = new ArrayList<DatabaseModelBean>();
                while (it.hasNext()) {
                    list.add(it.next());
                }
                if (list.size() > 0) {
                    // 只取第一个.
                    dbModel = list.get(0);
                    text.setText(dbModel.getDbName());
                }
            }
        }
    });
    setControl(container);
}
Also used : HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) ImportException(net.heartsome.cat.common.core.exception.ImportException) TermDbManagerDialog(net.heartsome.cat.database.ui.tb.dialog.TermDbManagerDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Map(java.util.Map)

Example 100 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class ConcordanceSearchDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    tparent = (Composite) super.createDialogArea(parent);
    GridLayoutFactory.swtDefaults().spacing(0, 0).extendedMargins(SWT.DEFAULT, SWT.DEFAULT, 0, 0).applyTo(tparent);
    // tparent.setLayout(new GridLayout());
    GridData parentData = new GridData(GridData.FILL_BOTH);
    parentData.widthHint = 1058;
    tparent.setLayoutData(parentData);
    Group groupSearch = new Group(tparent, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
    groupSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupSearch"));
    Label lblSearch = new Label(groupSearch, SWT.NONE);
    lblSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblSearch"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
    cmbSearch = new Combo(groupSearch, SWT.BORDER | SWT.DROP_DOWN);
    cmbSearch.setText(strSearchText == null ? "" : InnerTagUtil.resolveTag(strSearchText));
    GridData txtData = new GridData();
    // 解决在 Windows 下文本框高度太小的问题
    // txtData.heightHint = 20;
    txtData.widthHint = 610;
    cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnSearch = new Button(groupSearch, SWT.PUSH);
    btnSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSearch"));
    new Label(groupSearch, SWT.NONE);
    Composite compCondition = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).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.ConcordanceSearchDialog.btnIsCaseSensitive"));
    GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
    btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
    btnIsIgnoreMark.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnIsIgnoreMark"));
    btnIsIgnoreMark.setSelection(true);
    GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
    btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
    btnApplyRegularExpression.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnApplyRegularExpression"));
    GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
    Label lblTM = new Label(groupSearch, SWT.NONE);
    lblTM.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblDB"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTM);
    Composite compDB = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(compDB);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compDB);
    cmbDatabase = new Combo(compDB, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).applyTo(cmbDatabase);
    initDatabaseCombo();
    btnSelectLang = new Button(compDB, 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.ConcordanceSearchDialog.btnSelectLang"), 5, 5,
    // SWT.DRAW_TRANSPARENT);
    // }
    // });
    btnSelectLang.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSelectLang"));
    initLanguageMenu();
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Group groupFilter = new Group(tparent, SWT.None);
    GridLayoutFactory.swtDefaults().margins(5, 5).applyTo(groupFilter);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupFilter);
    groupFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupFilter"));
    cmpExpandableFilter = toolkit.createExpandableComposite(groupFilter, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
    cmpExpandableFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.cmpExpandableFilter"));
    Composite cmpFilter = toolkit.createComposite(cmpExpandableFilter);
    cmpFilter.setLayout(new GridLayout(3, false));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(cmpFilter);
    cmpExpandableFilter.setBackground(tparent.getBackground());
    cmpExpandableFilter.setClient(cmpFilter);
    cmpFilter.setBackground(tparent.getBackground());
    cmbSrcOrTgt = new Combo(cmpFilter, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbSrcOrTgt);
    cmbSrcOrTgt.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2") });
    cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), strSrcLang);
    cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2"), strTgtLang);
    cmbContain = new Combo(cmpFilter, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbContain);
    cmbContain.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2") });
    cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), "LIKE");
    cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2"), "NOT LIKE");
    cmbFilter = new Combo(cmpFilter, SWT.BORDER | SWT.DROP_DOWN);
    GridDataFactory.swtDefaults().hint(410, SWT.DEFAULT).applyTo(cmbFilter);
    cmpExpandableFilter.setExpanded(false);
    groupTable = new Group(tparent, SWT.None);
    GridLayoutFactory.swtDefaults().margins(5, 5).spacing(0, 2).numColumns(1).equalWidth(false).applyTo(groupTable);
    GridDataFactory.fillDefaults().hint(740, 450).applyTo(groupTable);
    groupTable.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupTable"));
    groupTable.setBackground(groupTable.getParent().getBackground());
    groupTable.setBackgroundMode(SWT.INHERIT_FORCE);
    cmpExpandableFilter.addExpansionListener(new IExpansionListener() {

        public void expansionStateChanging(ExpansionEvent e) {
            layoutExpandable();
        }

        public void expansionStateChanged(ExpansionEvent e) {
            layoutExpandable();
        }
    });
    jTable = new JaretTable(groupTable, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) {

        public void rowSelectionAdded(IRow row) {
            super.rowSelectionAdded(row);
        // XPropRow propRow = (XPropRow) row;
        // HashMap<String, String> map = (HashMap<String, String>) propRow.getDataMap();
        // String strChangeDate = map.get("changeDate");
        // // strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" :
        // CommonFunctions
        // // .retGMTdate(strChangeDate));
        // strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" : strChangeDate);
        // String strChangeId = checkString(map.get("changeId"));
        // String strDbInfo = checkString(map.get("dbType")) + "/" + checkString(map.get("severName")) + "/"
        // + checkString(map.get("dbName"));
        // String strProjectInfo = checkString(map.get("projectRef"));
        // String strJobInfo = checkString(map.get("jobRef"));
        // MessageFormat mf = new MessageFormat(strMsg);
        // lblInfo.setText(mf.format(new String[] { strChangeDate, strChangeId, strDbInfo, strProjectInfo,
        // strJobInfo }));
        }
    };
    jTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    ((DefaultTableHeaderRenderer) jTable.getHeaderRenderer()).setAlignment(DefaultTableHeaderRenderer.Alignment.LEFT);
    jTable.setHeaderResizeAllowed(false);
    jTable.setAllowSorting(false);
    jTable.registerCellEditor(String.class, new ReadOnlyTextCellEditor(true));
    PropListeningTableModel model = new PropListeningTableModel();
    ListPropCol colTag = new ListPropCol("Flag", Messages.getString("dialog.ConcordanceSearchDialog.colTag"), "Flag", -1);
    model.addColumn(colTag);
    jTable.getTableViewState().setColumnWidth(colTag, 55);
    if (strSrcLang != null) {
        PropCol ct1 = new PropCol("Source", strSrcLang, "Source");
        ct1.setEditable(false);
        model.addColumn(ct1);
        jTable.getTableViewState().setColumnWidth(ct1, 325);
    }
    if (strTgtLang != null) {
        PropCol col = new PropCol("Target", strTgtLang, "Target");
        model.addColumn(col);
        jTable.getTableViewState().setColumnWidth(col, 325);
    }
    for (int i = 0; i < lstLangs.size(); i++) {
        String strLang = lstLangs.get(i);
        ListPropCol col = new ListPropCol("Target", strLang, "LstTarget", i);
        col.setEditable(true);
        model.addColumn(col);
        jTable.getTableViewState().setColumnWidth(col, 0);
    }
    PropCol attrCol = new PropCol("Attribute", "Attribute", "Attribute");
    attrCol.setEditable(false);
    model.addColumn(attrCol);
    jTable.getTableViewState().setColumnWidth(attrCol, 325);
    tableModel = model;
    jTable.setHeaderHeight(20);
    jTable.setTableModel(tableModel);
    jTable.setDrawHeader(true);
    // jTable.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
    jTable.registerCellRenderer(tableModel.getColumn(2), new TextCellRenderer());
    colCount = jTable.getColumnCount();
    for (int colNum = colCount - 2; colNum >= 3; colNum--) {
        IColumn column = jTable.getColumn(colNum);
        jTable.registerCellRenderer(tableModel.getColumn(colNum), new TextCellRenderer());
        jTable.getTableViewState().setColumnVisible(column, false);
    }
    ImageCellRender imgRender = new ImageCellRender();
    // 表示需要删除标记(记录有标记时要显示的图片)
    imgRender.addImageDescriptorMapping(Boolean.FALSE, "1", Activator.getImageDescriptor(ImageConstants.TAG_DELETE));
    // 表示需要添加标记(记录有标记时要显示的图片)
    imgRender.addImageDescriptorMapping(Boolean.TRUE, "2", Activator.getImageDescriptor(ImageConstants.TAG_ADD));
    jTable.registerCellRenderer(tableModel.getColumn(0), imgRender);
    jTable.getSelectionModel().setOnlyRowSelectionAllowed(true);
    jTable.getSelectionModel().setMultipleSelectionAllowed(false);
    Composite cmpPage = new Composite(groupTable, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(3, 0).extendedMargins(0, 5, 0, 0).numColumns(3).equalWidth(false).applyTo(cmpPage);
    cmpPage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    cmpPage.setBackground(cmpPage.getParent().getBackground());
    cmpPage.setBackgroundMode(SWT.INHERIT_FORCE);
    new Label(cmpPage, SWT.None).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar toolBar = new ToolBar(cmpPage, SWT.NO_FOCUS | SWT.FLAT);
    btnFirst = new ToolItem(toolBar, SWT.PUSH);
    btnFirst.setImage(firstImage);
    btnPre = new ToolItem(toolBar, SWT.NONE);
    btnPre.setImage(preImage);
    btnNext = new ToolItem(toolBar, SWT.NONE);
    btnNext.setImage(nextImage);
    btnLast = new ToolItem(toolBar, SWT.NONE);
    btnLast.setImage(lastImage);
    txtPage = new Text(cmpPage, SWT.BORDER);
    GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).applyTo(txtPage);
    readDialogSettings();
    updateCombo(cmbSearch, lstSearchHistory);
    updateCombo(cmbFilter, lstFilterHistory);
    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()));
    if (lstFilterHistory != null && lstFilterHistory.size() > 0) {
        cmbFilter.setText(lstFilterHistory.get(0));
        cmbFilter.setSelection(new Point(0, cmbFilter.getText().length()));
    }
    initListener();
    return parent;
}
Also used : StyleTextCellRenderer(net.heartsome.cat.ts.ui.jaret.renderer.StyleTextCellRenderer) TextCellRenderer(de.jaret.util.ui.table.renderer.TextCellRenderer) Group(org.eclipse.swt.widgets.Group) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) JaretTable(de.jaret.util.ui.table.JaretTable) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) PropListeningTableModel(de.jaret.util.ui.table.model.PropListeningTableModel) ImageCellRender(net.heartsome.cat.ts.ui.jaret.renderer.ImageCellRender) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ToolItem(org.eclipse.swt.widgets.ToolItem) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) DefaultTableHeaderRenderer(de.jaret.util.ui.table.renderer.DefaultTableHeaderRenderer) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

Label (org.eclipse.swt.widgets.Label)849 GridData (org.eclipse.swt.layout.GridData)709 GridLayout (org.eclipse.swt.layout.GridLayout)617 Composite (org.eclipse.swt.widgets.Composite)594 Text (org.eclipse.swt.widgets.Text)394 Button (org.eclipse.swt.widgets.Button)338 SelectionEvent (org.eclipse.swt.events.SelectionEvent)324 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)266 Group (org.eclipse.swt.widgets.Group)241 Combo (org.eclipse.swt.widgets.Combo)164 ModifyEvent (org.eclipse.swt.events.ModifyEvent)140 ModifyListener (org.eclipse.swt.events.ModifyListener)140 SelectionListener (org.eclipse.swt.events.SelectionListener)77 Table (org.eclipse.swt.widgets.Table)63 TableViewer (org.eclipse.jface.viewers.TableViewer)60 Point (org.eclipse.swt.graphics.Point)59 FormAttachment (org.eclipse.swt.layout.FormAttachment)47 FormData (org.eclipse.swt.layout.FormData)47 ArrayList (java.util.ArrayList)45 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)44