Search in sources :

Example 6 with HsImageLabel

use of net.heartsome.cat.common.ui.HsImageLabel in project translationstudio8 by heartsome.

the class NonTranslationQAPage method createContents.

@Override
protected Control createContents(Composite parent) {
    isInit = true;
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).hint(550, 400).applyTo(tparent);
    Group instalGroup = new Group(tparent, SWT.NONE);
    instalGroup.setLayout(new GridLayout());
    instalGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    instalGroup.setText(Messages.getString("qa.preference.NonTranslationQAPage.nonTransElementInstal"));
    String tip = Messages.getString("preference.NonTranslationQAPage.instalLbl");
    HsImageLabel instalLbl = new HsImageLabel(tip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_QA_nontrans_nontransInstal));
    Composite instalCmp = instalLbl.createControl(instalGroup);
    instalCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // 一排按钮
    Composite buttonCmp = new Composite(instalGroup, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(4).applyTo(buttonCmp);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonCmp);
    addBtn = new Button(buttonCmp, SWT.NONE);
    addBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.add"));
    editBtn = new Button(buttonCmp, SWT.NONE);
    editBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.editBtn"));
    editBtn.setEnabled(false);
    deleteBtn = new Button(buttonCmp, SWT.NONE);
    deleteBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.delete"));
    deleteBtn.setEnabled(false);
    Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point editPoint = editBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point delPoint = deleteBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    GridData btnData = new GridData();
    int width = Math.max(addPoint.x, Math.max(editPoint.x, delPoint.x));
    btnData.widthHint = width + 10;
    addBtn.setLayoutData(btnData);
    editBtn.setLayoutData(btnData);
    deleteBtn.setLayoutData(btnData);
    Map<String, String> comboTip = new HashMap<String, String>();
    comboTip.put(QAConstant.QA_NONTRANS_NAME, Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    comboViewer = new ComboViewer(buttonCmp, SWT.NONE);
    comboViewer.setContentProvider(new ArrayContentProvider());
    comboViewer.setLabelProvider(new NonTransElementCmbProvider());
    comboViewer.getCombo().setToolTipText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    comboViewer.setInput(internalElementList);
    comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).grab(false, false).applyTo(comboViewer.getCombo());
    // ---------------------下面是非译元素展示框---------------------------------
    tableViewer = new TableViewer(instalGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
    String[] columnNames = new String[] { Messages.getString("qa.preference.NonTranslationQAPage.tipColumn"), Messages.getString("qa.preference.NonTranslationQAPage.contentColumn"), Messages.getString("qa.preference.NonTranslationQAPage.regularColumn") };
    tableViewer.setLabelProvider(new NonTransElementTableProvider());
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableViewerColumn column = new TableViewerColumn(tableViewer, columnAlignments[i]);
        column.getColumn().setText(columnNames[i]);
        column.getColumn().setWidth(50);
        column.setLabelProvider(new NonTransElementTableProvider(i));
        if (i == 0) {
            column.getColumn().addSelectionListener(new SelectionAdapter() {

                boolean asc = true;

                public void widgetSelected(SelectionEvent e) {
                    tableViewer.setSorter(asc ? TableSorter.name_ASC : TableSorter.name_DESC);
                    asc = !asc;
                }
            });
        }
        if (i == 1) {
            column.getColumn().addSelectionListener(new SelectionAdapter() {

                boolean asc = true;

                public void widgetSelected(SelectionEvent e) {
                    tableViewer.setSorter(asc ? TableSorter.content_ASC : TableSorter.content_DESC);
                    asc = !asc;
                }
            });
        }
    }
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    tableViewer.setInput(dataList);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    // 让列表列宽动态变化
    table.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            final Table table = ((Table) event.widget);
            final TableColumn[] columns = table.getColumns();
            event.widget.getDisplay().syncExec(new Runnable() {

                public void run() {
                    double[] columnWidths = new double[] { 0.2, 0.2, 0.58 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    instalLbl.computeSize();
    initListener();
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) HashMap(java.util.HashMap) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 7 with HsImageLabel

use of net.heartsome.cat.common.ui.HsImageLabel in project translationstudio8 by heartsome.

the class QAInstalPage method createContents.

@Override
protected Control createContents(Composite parent) {
    isInit = true;
    try {
        String bundlePath = FileLocator.toFileURL(Platform.getBundle("net.heartsome.cat.ts.ui.qa").getEntry("")).getPath();
        errorImg = new Image(getShell().getDisplay(), bundlePath + "icons/error.png");
        warnImg = new Image(getShell().getDisplay(), bundlePath + "icons/warning.png");
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(Messages.getString("qa.preference.QAInstalPage.log1"), e);
    }
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group qaItemInstalGroup = new Group(tparent, SWT.NONE);
    qaItemInstalGroup.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, false).hint(600, SWT.DEFAULT).applyTo(qaItemInstalGroup);
    qaItemInstalGroup.setText(Messages.getString("qa.preference.QAInstalPage.qaInstal"));
    String tip = Messages.getString("preference.QAInstalPage.itemInstalLbl");
    HsImageLabel itemInstalLbl = new HsImageLabel(tip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_QA_instal_itemsChoose));
    Composite instalCmp = itemInstalLbl.createControl(qaItemInstalGroup);
    GridLayoutFactory.fillDefaults().numColumns(4).spacing(20, 2).applyTo(instalCmp);
    instalCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout lCmpLayout = new GridLayout(2, false);
    lCmpLayout.marginWidth = 0;
    lCmpLayout.marginHeight = 0;
    GridData separatorLblData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    separatorLblData.horizontalSpan = 4;
    // 术语一致性检查
    Label termLbl = new Label(instalCmp, SWT.NONE);
    termLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_TERM).get(QAConstant.QA_ITEM_NAME));
    batchTermBtn = new Button(instalCmp, SWT.CHECK);
    batchTermBtn.setText(CONSTANT_BATCHQA);
    autoTermBtn = new Button(instalCmp, SWT.CHECK);
    autoTermBtn.setText(CONSTANT_AUTOQA);
    Composite levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    termCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(termCmb);
    Label separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    // 数字一致性检查
    Label numberLbl = new Label(instalCmp, SWT.NONE);
    numberLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_NUMBER).get(QAConstant.QA_ITEM_NAME));
    batchNumberBtn = new Button(instalCmp, SWT.CHECK);
    batchNumberBtn.setText(CONSTANT_BATCHQA);
    autoNumberBtn = new Button(instalCmp, SWT.CHECK);
    autoNumberBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    numberCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(numberCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    // 标记一致性检查
    Label tagLbl = new Label(instalCmp, SWT.NONE);
    tagLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_TAG).get(QAConstant.QA_ITEM_NAME));
    batchTagBtn = new Button(instalCmp, SWT.CHECK);
    batchTagBtn.setText(CONSTANT_BATCHQA);
    autoTagBtn = new Button(instalCmp, SWT.CHECK);
    autoTagBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    tagCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(tagCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    // 非译元素检查
    Label nonTransLbl = new Label(instalCmp, SWT.NONE);
    nonTransLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_NONTRANSLATION).get(QAConstant.QA_ITEM_NAME));
    batchNonTransBtn = new Button(instalCmp, SWT.CHECK);
    batchNonTransBtn.setText(CONSTANT_BATCHQA);
    autoNonTransBtn = new Button(instalCmp, SWT.CHECK);
    autoNonTransBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    nonTransCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(nonTransCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    //段首段末空格检查
    Label spaceOfParaLbl = new Label(instalCmp, SWT.NONE);
    spaceOfParaLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_SPACEOFPARACHECK).get(QAConstant.QA_ITEM_NAME));
    batchSpaceOfParaBtn = new Button(instalCmp, SWT.CHECK);
    batchSpaceOfParaBtn.setText(CONSTANT_BATCHQA);
    autoSpaceOfParaBtn = new Button(instalCmp, SWT.CHECK);
    autoSpaceOfParaBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    spaceOfParaCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(spaceOfParaCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    //文本段完整性检查
    Label paraCompleteLbl = new Label(instalCmp, SWT.NONE);
    paraCompleteLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_PARACOMPLETENESS).get(QAConstant.QA_ITEM_NAME));
    batchParaCompleteBtn = new Button(instalCmp, SWT.CHECK);
    batchParaCompleteBtn.setText(CONSTANT_BATCHQA);
    autoParaCompleteBtn = new Button(instalCmp, SWT.CHECK);
    autoParaCompleteBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    paraCompleteCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(paraCompleteCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    //目标文本段长度限制检查 
    Label tgtLengthLimitLbl = new Label(instalCmp, SWT.NONE);
    tgtLengthLimitLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_TGTTEXTLENGTHLIMIT).get(QAConstant.QA_ITEM_NAME));
    batchTgtLengthLimitBtn = new Button(instalCmp, SWT.CHECK);
    batchTgtLengthLimitBtn.setText(CONSTANT_BATCHQA);
    autoTgtLengthLimitBtn = new Button(instalCmp, SWT.CHECK);
    autoTgtLengthLimitBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    tgtLengthLimitCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(tgtLengthLimitCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    //拼写检查
    Label spellLbl = new Label(instalCmp, SWT.NONE);
    spellLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_SPELL).get(QAConstant.QA_ITEM_NAME));
    batchSpellBtn = new Button(instalCmp, SWT.CHECK);
    batchSpellBtn.setText(CONSTANT_BATCHQA);
    autoSpellBtn = new Button(instalCmp, SWT.CHECK);
    autoSpellBtn.setText(CONSTANT_AUTOQA);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    spellCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(spellCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    // 文本段一致性检查
    Label paraLbl = new Label(instalCmp, SWT.NONE);
    paraLbl.setText(qaItemId_Name_Class.get(QAConstant.QA_PARAGRAPH).get(QAConstant.QA_ITEM_NAME));
    batchParaBtn = new Button(instalCmp, SWT.CHECK);
    batchParaBtn.setText(CONSTANT_BATCHQA);
    new Label(instalCmp, SWT.NONE);
    levelCmp = new Composite(instalCmp, SWT.NONE);
    levelCmp.setLayout(lCmpLayout);
    new Label(levelCmp, SWT.NONE).setText(CONSTANT_TIPLEVEL);
    paraCmb = new TableComboViewer(levelCmp, SWT.READ_ONLY | SWT.BORDER);
    createTableCombo(paraCmb);
    separatorLbl = new Label(instalCmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLbl.setLayoutData(separatorLblData);
    itemInstalLbl.computeSize();
    // ---------------------------------自动检查策略设置
    Group autoIntalGroup = new Group(tparent, SWT.NONE);
    autoIntalGroup.setLayout(new GridLayout());
    autoIntalGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    autoIntalGroup.setText(Messages.getString("qa.preference.QAInstalPage.autoQaInstal"));
    // 入库时执行
    whenAddToDbBtn = new Button(autoIntalGroup, SWT.CHECK);
    whenAddToDbBtn.setText(Messages.getString("qa.preference.QAInstalPage.autoQaWhenAddToDb"));
    whenAddToDbBtn.addListener(SWT.Selection, this);
    // 批准文本段后执行
    whenApprovalBtn = new Button(autoIntalGroup, SWT.CHECK);
    whenApprovalBtn.setText(Messages.getString("qa.preference.QAInstalPage.autoQaWhenApproval"));
    whenApprovalBtn.addListener(SWT.Selection, this);
    initValue();
    return parent;
}
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) IOException(java.io.IOException) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) Image(org.eclipse.swt.graphics.Image)

Example 8 with HsImageLabel

use of net.heartsome.cat.common.ui.HsImageLabel in project translationstudio8 by heartsome.

the class SpellPage method createAspellCmp.

/**
	 * 创建 aspell 的配置界面
	 */
private void createAspellCmp() {
    isInit = true;
    Composite groupParent = new Composite(tabFolder, SWT.NONE);
    groupParent.setLayout(new GridLayout());
    groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
    //		Group groupParent = new Group(tparent, SWT.None);
    //		groupParent.setLayout(new GridLayout());
    //		groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
    //		groupParent.setText(Messages.getString("qa.preference.SpellPage.groupParent"));
    HsImageLabel imageLabel = new HsImageLabel(Messages.getString("qa.preference.SpellPage.imageLabel"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_ASPELL_DIC));
    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(3, false));
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    cmpContent.setLayoutData(data);
    Label lbl = new Label(cmpContent, SWT.NONE);
    lbl.setText(Messages.getString("qa.preference.SpellPage.lblPath"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    txtCommandPath = new Text(cmpContent, SWT.BORDER);
    txtCommandPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    txtCommandPath.setEditable(false);
    btnBrowse = new Button(cmpContent, SWT.NONE);
    btnBrowse.setText(Messages.getString("qa.preference.SpellPage.btnBrowse"));
    //		GridData btnData = new GridData();
    //		btnData.widthHint = 70;
    //		btnBrowse.setLayoutData(btnData);
    new Label(cmpContent, SWT.NONE);
    btnUTF8 = new Button(cmpContent, SWT.CHECK);
    btnUTF8.setText(Messages.getString("qa.preference.SpellPage.btnUTF8"));
    new Label(cmpContent, SWT.NONE);
    lbl = new Label(cmpContent, SWT.NONE);
    lbl.setText(Messages.getString("qa.preference.SpellPage.lblDic"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    cmbDefaultDic = new ComboViewer(cmpContent);
    cmbDefaultDic.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnRefresh = new Button(cmpContent, SWT.NONE);
    btnRefresh.setText(Messages.getString("qa.preference.SpellPage.btnRefresh"));
    lbl = new Label(cmpContent, SWT.NONE);
    lbl.setText(Messages.getString("qa.preference.SpellPage.lblLang"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    cmbLang = new TableComboViewer(cmpContent, SWT.READ_ONLY | SWT.BORDER);
    TableCombo tableCombo = cmbLang.getTableCombo();
    tableCombo.setShowTableLines(false);
    tableCombo.setShowTableHeader(false);
    tableCombo.setDisplayColumnIndex(-1);
    tableCombo.setShowImageWithinSelection(true);
    tableCombo.setShowColorWithinSelection(false);
    tableCombo.setShowFontWithinSelection(false);
    tableCombo.setVisibleItemCount(20);
    cmbLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cmbLang.setLabelProvider(new LanguageLabelProvider());
    cmbLang.setContentProvider(new ArrayContentProvider());
    cmbLang.setInput(languages);
    cmbLang.getTableCombo().select(0);
    new Label(cmpContent, SWT.NONE);
    Composite cmpTableBtn = new Composite(cmpContent, SWT.NONE);
    GridLayout btnLayout = new GridLayout(2, false);
    btnLayout.marginWidth = 0;
    cmpTableBtn.setLayout(btnLayout);
    GridData btnData1 = new GridData(GridData.FILL_BOTH);
    btnData1.horizontalSpan = 3;
    cmpTableBtn.setLayoutData(btnData1);
    btnAdd = new Button(cmpTableBtn, SWT.NONE);
    btnAdd.setText(Messages.getString("qa.preference.SpellPage.btnAdd"));
    btnRemove = new Button(cmpTableBtn, SWT.NONE);
    btnRemove.setText(Messages.getString("qa.preference.SpellPage.btnRemove"));
    Point browsePoint = btnBrowse.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point refreshPoint = btnRefresh.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point addPoint = btnAdd.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point remPoint = btnRemove.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    GridData btnData = new GridData();
    int width = Math.max(refreshPoint.x, Math.max(browsePoint.x, Math.max(addPoint.x, remPoint.x)));
    btnData.widthHint = width + 10;
    btnBrowse.setLayoutData(btnData);
    btnRefresh.setLayoutData(btnData);
    btnAdd.setLayoutData(btnData);
    btnRemove.setLayoutData(btnData);
    table = new Table(cmpTableBtn, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    String[] arrTableHeader = new String[] { Messages.getString("qa.preference.SpellPage.arrTableHeader1"), "", Messages.getString("qa.preference.SpellPage.arrTableHeader2") };
    int[] arrWidth = new int[] { 195, 40, 195 };
    for (int i = 0; i < arrTableHeader.length; i++) {
        int style = SWT.NONE;
        if (i == 1) {
            style = SWT.CENTER;
        }
        TableColumn col = new TableColumn(table, style);
        col.setText(arrTableHeader[i]);
        col.setWidth(arrWidth[i]);
    }
    GridData dataTable = new GridData(GridData.FILL_BOTH);
    dataTable.horizontalSpan = 2;
    table.setLayoutData(dataTable);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    initProperty();
    initListener();
    imageLabel.computeSize();
    aspellTabItem.setControl(groupParent);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) Label(org.eclipse.swt.widgets.Label) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Text(org.eclipse.swt.widgets.Text) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableCombo(org.eclipse.nebula.widgets.tablecombo.TableCombo)

Example 9 with HsImageLabel

use of net.heartsome.cat.common.ui.HsImageLabel 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 10 with HsImageLabel

use of net.heartsome.cat.common.ui.HsImageLabel 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)

Aggregations

HsImageLabel (net.heartsome.cat.common.ui.HsImageLabel)28 GridData (org.eclipse.swt.layout.GridData)27 GridLayout (org.eclipse.swt.layout.GridLayout)27 Composite (org.eclipse.swt.widgets.Composite)27 Group (org.eclipse.swt.widgets.Group)24 Button (org.eclipse.swt.widgets.Button)23 Label (org.eclipse.swt.widgets.Label)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Text (org.eclipse.swt.widgets.Text)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionListener (org.eclipse.swt.events.SelectionListener)5 Link (org.eclipse.swt.widgets.Link)4 Point (org.eclipse.swt.graphics.Point)3 Spinner (org.eclipse.swt.widgets.Spinner)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 TableComboViewer (org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 Table (org.eclipse.swt.widgets.Table)2