Search in sources :

Example 6 with RowLayout

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

the class ConfigureColumnsAction method createColumnControlPanel.

/**
     * Create the dialog area. TODO can be done much nicer ... but works for the first draft
     * 
     * @param parent parent composite
     * @return initialized control
     */
private Control createColumnControlPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NULL);
    panel.setLayout(new RowLayout());
    Label l = new Label(panel, SWT.NULL);
    l.setText("Configure the columns");
    Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    _chkBoxViewer = new CheckboxTableViewer(table);
    _chkBoxViewer.setContentProvider(new ColTableContentProvider());
    _chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
    TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
    column.setText("Column");
    column.setWidth(100);
    _chkBoxViewer.getTable().setHeaderVisible(true);
    _chkBoxViewer.setInput("x");
    final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
    for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
        IColumn col = _table.getTableModel().getColumn(i);
        _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
    }
    table.getColumn(0).pack();
    table.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (event.detail == SWT.CHECK) {
                TableItem item = (TableItem) event.item;
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
                    _tvs.setColumnVisible(col, item.getChecked());
                } else {
                    _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
                }
            }
        }
    });
    Button upButton = new Button(panel, SWT.PUSH);
    upButton.setText("up");
    upButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx > firstColIdx) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx - 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    Button downButton = new Button(panel, SWT.PUSH);
    downButton.setText("down");
    downButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx < _tvs.getSortedColumns().size() - 1) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx + 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    return panel;
}
Also used : Table(org.eclipse.swt.widgets.Table) JaretTable(de.jaret.util.ui.table.JaretTable) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) TableColumn(org.eclipse.swt.widgets.TableColumn) IColumn(de.jaret.util.ui.table.model.IColumn) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 7 with RowLayout

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

the class TableControlPanel method createControls.

/**
     * @param panel
     */
private void createControls() {
    RowLayout rl = new RowLayout();
    rl.type = SWT.HORIZONTAL;
    this.setLayout(rl);
    Composite col1 = new Composite(this, SWT.NULL);
    rl = new RowLayout();
    rl.type = SWT.VERTICAL;
    col1.setLayout(rl);
    Composite col2 = new Composite(this, SWT.NULL);
    rl = new RowLayout();
    rl.type = SWT.VERTICAL;
    col2.setLayout(rl);
    Composite col3 = new Composite(this, SWT.NULL);
    rl = new RowLayout();
    rl.type = SWT.VERTICAL;
    col3.setLayout(rl);
    final Button autoFilterCheck = new Button(col1, SWT.CHECK);
    autoFilterCheck.setText("AutoFilter");
    autoFilterCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setAutoFilterEnable(autoFilterCheck.getSelection());
        }
    });
    final Button drawHeaderCheck = new Button(col1, SWT.CHECK);
    drawHeaderCheck.setSelection(_table.getDrawHeader());
    drawHeaderCheck.setText("Draw header");
    drawHeaderCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setDrawHeader(drawHeaderCheck.getSelection());
        }
    });
    final Button fillDragCheck = new Button(col1, SWT.CHECK);
    fillDragCheck.setSelection(_table.isSupportFillDragging());
    fillDragCheck.setText("Support fill dragging");
    fillDragCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setSupportFillDragging(fillDragCheck.getSelection());
        }
    });
    Button b = new Button(col2, SWT.PUSH);
    b.setText("Print");
    b.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            print();
        }
    });
    final Scale headerRotationScale = new Scale(col2, SWT.HORIZONTAL);
    headerRotationScale.setMaximum(90);
    headerRotationScale.setMinimum(0);
    headerRotationScale.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent ev) {
            int val = headerRotationScale.getSelection();
            ((DefaultTableHeaderRenderer) _table.getHeaderRenderer()).setRotation(val);
            if (val > 0) {
                _table.setHeaderHeight(50);
            } else {
                _table.setHeaderHeight(18);
            }
            _table.redraw();
        }
    });
    final Button allowHeaderResizeCheck = new Button(col1, SWT.CHECK);
    allowHeaderResizeCheck.setSelection(_table.getDrawHeader());
    allowHeaderResizeCheck.setText("Allow header resize");
    allowHeaderResizeCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setHeaderResizeAllowed(allowHeaderResizeCheck.getSelection());
        }
    });
    final Button allowRowResizeCheck = new Button(col1, SWT.CHECK);
    allowRowResizeCheck.setSelection(_table.getDrawHeader());
    allowRowResizeCheck.setText("Allow row resize");
    allowRowResizeCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setRowResizeAllowed(allowRowResizeCheck.getSelection());
        }
    });
    final Button allowColResizeCheck = new Button(col1, SWT.CHECK);
    allowColResizeCheck.setSelection(_table.getDrawHeader());
    allowColResizeCheck.setText("Allow column resize");
    allowColResizeCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setColumnResizeAllowed(allowColResizeCheck.getSelection());
        }
    });
    Label l = new Label(col2, SWT.NULL);
    l.setText("Fixed columns");
    final Combo fixedColCombo = new Combo(col2, SWT.BORDER | SWT.READ_ONLY);
    fixedColCombo.setItems(new String[] { "0", "1", "2", "3", "4" });
    fixedColCombo.select(0);
    fixedColCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setFixedColumns(fixedColCombo.getSelectionIndex());
        }
    });
    l = new Label(col2, SWT.NULL);
    l.setText("Fixed rows");
    final Combo fixedRowCombo = new Combo(col2, SWT.BORDER | SWT.READ_ONLY);
    fixedRowCombo.setItems(new String[] { "0", "1", "2", "3", "4" });
    fixedRowCombo.select(0);
    fixedRowCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setFixedRows(fixedRowCombo.getSelectionIndex());
        }
    });
    final Button resizeRestrictionCheck = new Button(col1, SWT.CHECK);
    resizeRestrictionCheck.setSelection(_table.getResizeRestriction());
    resizeRestrictionCheck.setText("Restrict resizing to headers/row headers");
    resizeRestrictionCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setResizeRestriction(resizeRestrictionCheck.getSelection());
        }
    });
    final Button excludeFixedRowsCheck = new Button(col1, SWT.CHECK);
    excludeFixedRowsCheck.setSelection(_table.getExcludeFixedRowsFromSorting());
    excludeFixedRowsCheck.setText("Exclude fixed rows from sorting");
    excludeFixedRowsCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.setExcludeFixedRowsFromSorting(excludeFixedRowsCheck.getSelection());
        }
    });
    final Button rowFilterCheck = new Button(col1, SWT.CHECK);
    rowFilterCheck.setSelection(false);
    rowFilterCheck.setText("Set rowfilter (even char count on col2)");
    rowFilterCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            boolean sel = rowFilterCheck.getSelection();
            if (sel) {
                _table.setRowFilter(new AbstractRowFilter() {

                    public boolean isInResult(IRow row) {
                        return ((DummyRow) row).getT2() != null && ((DummyRow) row).getT2().length() % 2 == 0;
                    }
                });
            } else {
                _table.setRowFilter(null);
            }
        }
    });
    final Button rowSorterCheck = new Button(col1, SWT.CHECK);
    rowSorterCheck.setSelection(false);
    rowSorterCheck.setText("Set rowsorter (char count on col3)");
    rowSorterCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            boolean sel = rowSorterCheck.getSelection();
            if (sel) {
                _table.setRowSorter(new AbstractRowSorter() {

                    public int compare(IRow o1, IRow o2) {
                        int c1 = ((DummyRow) o1).getT3() != null ? ((DummyRow) o1).getT3().length() : 0;
                        int c2 = ((DummyRow) o2).getT3() != null ? ((DummyRow) o2).getT3().length() : 0;
                        return c1 - c2;
                    }
                });
            } else {
                _table.setRowSorter(null);
            }
        }
    });
    final Button onlyRowSelectionCheck = new Button(col1, SWT.CHECK);
    onlyRowSelectionCheck.setSelection(false);
    onlyRowSelectionCheck.setText("Only row selection allowed");
    onlyRowSelectionCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            boolean sel = onlyRowSelectionCheck.getSelection();
            _table.getSelectionModel().setOnlyRowSelectionAllowed(sel);
            _table.getSelectionModel().clearSelection();
        }
    });
    final Button optimizeScrollingCheck = new Button(col1, SWT.CHECK);
    optimizeScrollingCheck.setSelection(_table.getOptimizeScrolling());
    optimizeScrollingCheck.setText("Optimize scrolling");
    optimizeScrollingCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            boolean sel = optimizeScrollingCheck.getSelection();
            _table.setOptimizeScrolling(sel);
        }
    });
    /**
         * Style strategy coloring the background of odd row indizes. The implementation is brute force creating
         * tons of objects underway ... so be careful.
         */
    final IStyleStrategy _styleStrategy = new IStyleStrategy() {

        public ICellStyle getCellStyle(IRow row, IColumn column, ICellStyle incomingStyle, ICellStyle defaultCellStyle) {
            if (_table.getInternalRowIndex(row) % 2 == 0) {
                return incomingStyle;
            } else {
                ICellStyle s = incomingStyle.copy();
                s.setBackgroundColor(new RGB(230, 230, 230));
                return s;
            }
        }
    };
    final Button bgColoringCheck = new Button(col1, SWT.CHECK);
    bgColoringCheck.setSelection(_table.getTableViewState().getCellStyleProvider().getStyleStrategy() != null);
    bgColoringCheck.setText("BG coloring (IStyleStrategy)");
    bgColoringCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            boolean sel = bgColoringCheck.getSelection();
            if (!sel) {
                _table.getTableViewState().getCellStyleProvider().setStyleStrategy(null);
                _table.redraw();
            } else {
                _table.getTableViewState().getCellStyleProvider().setStyleStrategy(_styleStrategy);
                _table.redraw();
            }
        }
    });
    Button b2 = new Button(col2, SWT.PUSH);
    b2.setText("Spawn new window");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            // hack
            if (_table.getHierarchicalModel() == null) {
                if (_table.getTableModel() instanceof SimpleJaretTableModel) {
                    new SimpleModelExample(_table.getTableModel());
                } else {
                    new TableExample(_table.getTableModel());
                }
            } else {
                new TableHierarchicalExample(_table.getHierarchicalModel());
            }
        }
    });
    b2 = new Button(col2, SWT.PUSH);
    b2.setText("Start changing bars");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            for (int i = 0; i < _table.getTableModel().getRowCount(); i++) {
                Runnable r = new Changer(_table.getTableModel(), i);
                Thread t = new Thread(r);
                t.start();
            }
        }
    });
    b2 = new Button(col3, SWT.PUSH);
    b2.setText("Set heightmode OPTIMAL");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.OPTIMAL);
        }
    });
    b2 = new Button(col3, SWT.PUSH);
    b2.setText("Set heightmode OPTANDVAR");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.OPTANDVAR);
        }
    });
    b2 = new Button(col3, SWT.PUSH);
    b2.setText("Set heightmode VARIABLE");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
        }
    });
    b2 = new Button(col3, SWT.PUSH);
    b2.setText("Set heightmode FIXED");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            _table.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.FIXED);
        }
    });
    l = new Label(col3, SWT.NULL);
    l.setText("Column resize mode");
    final Combo colModeCombo = new Combo(col3, SWT.BORDER | SWT.READ_ONLY);
    colModeCombo.setItems(new String[] { "NONE", "SUBSEQUENT", "ALLSUBSEQUENT", "ALL" });
    colModeCombo.select(0);
    colModeCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            String sel = colModeCombo.getText();
            _table.getTableViewState().setColumnResizeMode(ITableViewState.ColumnResizeMode.valueOf(sel));
        }
    });
    b2 = new Button(col3, SWT.PUSH);
    b2.setText("Clipboard info");
    b2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            Clipboard cb = new Clipboard(Display.getCurrent());
            System.out.println("Clipboard info");
            TextTransfer textTransfer = TextTransfer.getInstance();
            Object content = cb.getContents(textTransfer);
            if (content != null) {
                System.out.println("TEXT: " + content.getClass() + ":" + content.toString());
            }
            RTFTransfer rtfTransfer = RTFTransfer.getInstance();
            content = cb.getContents(rtfTransfer);
            if (content != null) {
                System.out.println("RTF: " + content.getClass() + ":" + content.toString());
            }
            HTMLTransfer htmlTransfer = HTMLTransfer.getInstance();
            content = cb.getContents(htmlTransfer);
            if (content != null) {
                System.out.println("HTML: " + content.getClass() + ":" + content.toString());
            }
        }
    });
    final Button includeColHeadingsWhenCopying = new Button(col3, SWT.CHECK);
    includeColHeadingsWhenCopying.setText("Include col header when copying");
    if (_table.getCcpStrategy() instanceof DefaultCCPStrategy) {
        DefaultCCPStrategy stategy = (DefaultCCPStrategy) _table.getCcpStrategy();
        includeColHeadingsWhenCopying.setSelection(stategy.getIncludeHeadersInCopy());
        includeColHeadingsWhenCopying.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent arg0) {
                boolean sel = includeColHeadingsWhenCopying.getSelection();
                DefaultCCPStrategy stategy = (DefaultCCPStrategy) _table.getCcpStrategy();
                stategy.setIncludeHeadersInCopy(sel);
            }
        });
    } else {
        includeColHeadingsWhenCopying.setEnabled(false);
    }
}
Also used : ICellStyle(de.jaret.util.ui.table.renderer.ICellStyle) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) SimpleJaretTableModel(de.jaret.util.ui.table.model.simple.SimpleJaretTableModel) DefaultCCPStrategy(de.jaret.util.ui.table.strategies.DefaultCCPStrategy) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) IStyleStrategy(de.jaret.util.ui.table.renderer.IStyleStrategy) AbstractRowSorter(de.jaret.util.ui.table.model.AbstractRowSorter) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Scale(org.eclipse.swt.widgets.Scale) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) RGB(org.eclipse.swt.graphics.RGB) IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn) AbstractRowFilter(de.jaret.util.ui.table.model.AbstractRowFilter) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 8 with RowLayout

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

the class SearchDialog method createOptionsPanel.

private Composite createOptionsPanel(final Composite composite) {
    final Composite row = new Composite(composite, SWT.NONE);
    row.setLayout(new GridLayout(2, true));
    final Group directionGroup = new Group(row, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(directionGroup);
    directionGroup.setText("Direction");
    final RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
    rowLayout.marginHeight = rowLayout.marginWidth = 3;
    directionGroup.setLayout(rowLayout);
    forwardButton = new Button(directionGroup, SWT.RADIO);
    forwardButton.setText("F&orward");
    forwardButton.setSelection(true);
    final Button backwardButton = new Button(directionGroup, SWT.RADIO);
    backwardButton.setText("&Backward");
    final Group optionsGroup = new Group(row, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(optionsGroup);
    optionsGroup.setText("Options");
    optionsGroup.setLayout(rowLayout);
    caseSensitiveButton = new Button(optionsGroup, SWT.CHECK);
    caseSensitiveButton.setText("&Case Sensitive");
    wrapSearchButton = new Button(optionsGroup, SWT.CHECK);
    wrapSearchButton.setText("&Wrap Search");
    wrapSearchButton.setSelection(true);
    return row;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout)

Example 9 with RowLayout

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

the class CustomMatchConditionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    gray = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);
    black = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
    tParent = (Composite) super.createDialogArea(parent);
    tParent.setLayout(new GridLayout(2, false));
    tParent.setLayoutData(new GridData(720, 410));
    Composite c = new Composite(tParent, SWT.BORDER);
    c.setLayout(new GridLayout(2, false));
    c.setLayoutData(new GridData(200, 388));
    Composite c1 = new Composite(c, SWT.NONE);
    c1.setLayout(new GridLayout(1, true));
    c1.setLayoutData(new GridData(150, 380));
    new Label(c1, SWT.NONE).setText("自定义过滤器:");
    initCustomFilterList(c1);
    Composite c2 = new Composite(c, SWT.NONE);
    RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
    rowLayout.marginLeft = 0;
    rowLayout.marginTop = 150;
    rowLayout.spacing = 5;
    c2.setLayout(rowLayout);
    c2.setLayoutData(new GridData(50, 380));
    Button addCustom = new Button(c2, SWT.PUSH);
    addCustom.setText("新增");
    addCustom.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // 新增自定义过滤器方法
            if (isChange()) {
                if (!MessageDialog.openConfirm(getShell(), "", "不保存当前内容吗?")) {
                    return;
                }
            }
            refresh();
        }
    });
    Button delCustom = new Button(c2, SWT.PUSH);
    delCustom.setText("删除");
    delCustom.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // 删除已保存的自定义过滤器方法
            String[] filters = customFilterList.getSelection();
            if (filters != null && filters.length > 0) {
                if (MessageDialog.openConfirm(getShell(), "", "确定要删除选中的自定义过滤器吗?")) {
                    deletePreference(filters);
                }
            } else {
                MessageDialog.openInformation(getShell(), "", "请选择要删除的自定义过滤器。");
            }
        }
    });
    Button editCustom = new Button(c2, SWT.PUSH);
    editCustom.setText("编辑");
    editCustom.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // 编辑已有的自定义过滤器方法
            edit();
        }
    });
    Composite c3 = new Composite(tParent, SWT.NONE);
    c3.setLayout(new GridLayout(1, true));
    c3.setLayoutData(new GridData(500, 400));
    Composite top = new Composite(c3, SWT.NONE);
    top.setLayout(new GridLayout(2, false));
    new Label(top, SWT.NONE).setText("过滤器名称:");
    filterNameTxt = new Text(top, SWT.BORDER);
    filterNameTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    andBtn = new Button(top, SWT.RADIO);
    andBtn.setText("满足所有条件");
    andBtn.setSelection(true);
    orBtn = new Button(top, SWT.RADIO);
    orBtn.setText("满足以下任一条件");
    scroll = new ScrolledComposite(c3, SWT.V_SCROLL | SWT.BORDER);
    scroll.setAlwaysShowScrollBars(true);
    scroll.setLayoutData(new GridData(470, 250));
    scroll.setExpandHorizontal(true);
    scroll.setExpandVertical(true);
    dynaComp = new Composite(scroll, SWT.BORDER);
    scroll.setContent(dynaComp);
    dynaComp.setLayout(new GridLayout(1, true));
    new DynaComposite(dynaComp, SWT.NONE);
    Composite c4 = new Composite(c3, SWT.BORDER);
    c4.setLayout(new GridLayout(2, true));
    c4.setLayoutData(new GridData(470, 60));
    btnIsTagged = new Button(c4, SWT.CHECK);
    btnIsTagged.setText("标记的匹配");
    btnQT = new Button(c4, SWT.CHECK);
    btnQT.setText("快速翻译匹配");
    // propagate translation
    btnPT = new Button(c4, SWT.CHECK);
    btnPT.setText("自动繁殖翻译匹配");
    if (isTEInstalled()) {
        btnIsRemoveFromSrc = new Button(c4, SWT.CHECK);
        btnIsRemoveFromSrc.setText("从来源中删除");
    }
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Text(org.eclipse.swt.widgets.Text)

Example 10 with RowLayout

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

the class LicenseManageDialog method createStatusComp.

private void createStatusComp(Composite parent) {
    Group statusGroup = new Group(parent, SWT.NONE);
    statusGroup.setText(Messages.getString("license.LicenseManageDialog.statusGroup"));
    GridData dataStatusGroup = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    dataStatusGroup.heightHint = 150;
    statusGroup.setLayoutData(dataStatusGroup);
    statusGroup.setLayout(new GridLayout());
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    RowLayout layout = new RowLayout();
    layout.center = true;
    Composite comp0 = new Composite(statusGroup, SWT.NONE);
    comp0.setLayoutData(data);
    comp0.setLayout(layout);
    Label statusLbl = new Label(comp0, SWT.NONE);
    statusLbl.setText(Messages.getString("license.LicenseManageDialog.statusLabel"));
    if (type == Constants.STATE_NOT_ACTIVATED) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.notActiveLabel"));
    } else if (type == Constants.STATE_VALID) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.activeLabel"));
        new Label(comp0, SWT.NONE).setLayoutData(new RowData(30, SWT.DEFAULT));
        Button btnCancelActive = new Button(comp0, SWT.NONE);
        btnCancelActive.setText(Messages.getString("license.LicenseManageDialog.cancelActiveButton"));
        btnCancelActive.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean result = MessageDialog.openConfirm(getShell(), Messages.getString("license.LicenseManageDialog.confirm"), Messages.getString("license.LicenseManageDialog.confirmMessage"));
                if (result) {
                    try {
                        int re = ServiceUtil.cancel();
                        if (re == Constants.LOGOUT_SUCCESS) {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveSuccess"));
                            LicenseManageDialog.this.close();
                            PlatformUI.getWorkbench().restart();
                        } else {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveFail"));
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        Throwable t = e1;
                        while (t.getCause() != null) {
                            t = t.getCause();
                        }
                        if (t instanceof java.security.cert.CertificateException) {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING16));
                        } else {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING17));
                        }
                    }
                }
            }
        });
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        comp1.setLayoutData(data);
        comp1.setLayout(layout);
        Label typeLbl = new Label(comp1, SWT.NONE);
        typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
        Label typeLbl1 = new Label(comp1, SWT.NONE);
        typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
        if (utilDate != null) {
            Composite comp2 = new Composite(statusGroup, SWT.NONE);
            comp2.setLayoutData(data);
            comp2.setLayout(layout);
            Label typeLbl2 = new Label(comp2, SWT.NONE);
            typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
            Label dateLbl = new Label(comp2, SWT.NONE);
            dateLbl.setText(utilDate);
        }
    } else if (type == Constants.STATE_INVALID) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.invalidLicense"));
    } else if (type == Constants.STATE_EXPIRED) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.expired"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        comp1.setLayoutData(data);
        comp1.setLayout(layout);
        Label typeLbl = new Label(comp1, SWT.NONE);
        typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
        Label typeLbl1 = new Label(comp1, SWT.NONE);
        typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
        if (utilDate != null) {
            Composite comp2 = new Composite(statusGroup, SWT.NONE);
            comp2.setLayoutData(data);
            comp2.setLayout(layout);
            Label typeLbl2 = new Label(comp2, SWT.NONE);
            typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
            Label dateLbl = new Label(comp2, SWT.NONE);
            dateLbl.setText(utilDate);
        }
    } else if (type == Constants.EXCEPTION_INT16 || type == Constants.EXCEPTION_INT17) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.unvalidate"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noticeLbl"), StringUtils.getErrorCode(type)));
    } else if (type == Constants.EXCEPTION_INT14) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noSameVersion"), getVersionContent(System.getProperty("TSEdition")), getVersionContent(new LicenseIdGenerator(licenseId).getVersion())));
    } else if (type == Constants.EXCEPTION_INT15) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(Messages.getString("license.LicenseManageDialog.maccodeError"));
    } else if (type == Constants.EXCEPTION_INT1 || type == Constants.EXCEPTION_INT2 || type == Constants.EXCEPTION_INT3 || type == Constants.EXCEPTION_INT4) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo1"), StringUtils.getErrorCode(type)));
    } else {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo"), StringUtils.getErrorCode(type)));
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) LicenseIdGenerator(net.heartsome.license.generator.LicenseIdGenerator) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)56 Composite (org.eclipse.swt.widgets.Composite)51 Button (org.eclipse.swt.widgets.Button)39 GridData (org.eclipse.swt.layout.GridData)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)35 GridLayout (org.eclipse.swt.layout.GridLayout)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 Label (org.eclipse.swt.widgets.Label)26 Group (org.eclipse.swt.widgets.Group)19 Text (org.eclipse.swt.widgets.Text)11 Combo (org.eclipse.swt.widgets.Combo)9 SelectionListener (org.eclipse.swt.events.SelectionListener)8 ArrayList (java.util.ArrayList)6 RowData (org.eclipse.swt.layout.RowData)6 Event (org.eclipse.swt.widgets.Event)6 Listener (org.eclipse.swt.widgets.Listener)6 List (java.util.List)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 StyledText (org.eclipse.swt.custom.StyledText)5 Table (org.eclipse.swt.widgets.Table)5