Search in sources :

Example 1 with Scale

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

the class JaretTablePrintDialog method createParameterArea.

protected void createParameterArea(Composite parent) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;
    parent.setLayout(gl);
    _repeatHeader = new Button(parent, SWT.CHECK);
    _repeatHeader.setSelection(_configuration.getRepeatHeader());
    _repeatHeader.setText("Repeat header");
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    _repeatHeader.setLayoutData(gd);
    final Label scaleText = new Label(parent, SWT.RIGHT);
    scaleText.setText(getScaleText());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    scaleText.setLayoutData(gd);
    final Scale scale = new Scale(parent, SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    scale.setLayoutData(gd);
    scale.setMaximum(1000);
    scale.setMinimum(10);
    scale.setSelection((int) (_configuration.getScale() * 100));
    scale.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent ev) {
            int val = scale.getSelection();
            double s = (double) val / 100.0;
            _configuration.setScale(s);
            scaleText.setText(getScaleText());
            updateConf();
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    _pagesLabel = new Label(parent, SWT.RIGHT);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    _pagesLabel.setLayoutData(gd);
    _printerData = _pdatas[_printerCombo.getSelectionIndex()];
    Printer printer = new Printer(_printerData);
    _tablePrinter.setPrinter(printer);
    Point pages = _tablePrinter.calculatePageCount(_configuration);
    printer.dispose();
    _pagesLabel.setText(getPagesText(pages));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Scale(org.eclipse.swt.widgets.Scale) Point(org.eclipse.swt.graphics.Point) Printer(org.eclipse.swt.printing.Printer) JaretTablePrinter(de.jaret.util.ui.table.JaretTablePrinter) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with Scale

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

the class TableHierarchicalExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    _jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
    _jt.setLayoutData(gd);
    IHierarchicalJaretTableModel hmodel = hierarchicalModel;
    if (hierarchicalModel == null) {
        ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
        ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
        ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
        ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
        root.addNode(r1);
        root.addNode(r2);
        root.addNode(r3);
        r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
        r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));
        ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
        r3.addNode(n1);
        ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
        r3.addNode(n2);
        n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
        n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));
        DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
        hmodel = dhmodel;
        if (SUPPORT_DND) {
            // init the simple drag and drop handling
            initDND(_jt, _shell);
        }
    }
    _jt.setTableModel(hmodel);
    StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
    IColumn hcol = new HierarchyColumn();
    // create and setup hierarchy renderer
    final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
    hierarchyRenderer.setLabelProvider(new LabelProvider());
    hierarchyRenderer.setDrawIcons(true);
    hierarchyRenderer.setDrawLabels(true);
    _jt.registerCellRenderer(hcol, hierarchyRenderer);
    model.addColumn(hcol);
    model.addColumn(new PropCol("b1", "column 1", "B1"));
    model.addColumn(new PropCol("t1", "column 2", "T1"));
    model.addColumn(new PropCol("t2", "column 3", "T2"));
    model.addColumn(new PropCol("t3", "column 4", "T3"));
    JaretTableActionFactory af = new JaretTableActionFactory();
    MenuManager mm = new MenuManager();
    mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
    _jt.setHeaderContextMenu(mm.createContextMenu(_jt));
    MenuManager rm = new MenuManager();
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
    _jt.setRowContextMenu(rm.createContextMenu(_jt));
    TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);
    Label l = new Label(_shell, SWT.NONE);
    l.setText("Level width:");
    final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
    levelWidthScale.setMaximum(40);
    levelWidthScale.setMinimum(0);
    levelWidthScale.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent ev) {
            int val = levelWidthScale.getSelection();
            hierarchyRenderer.setLevelWidth(val);
            _jt.redraw();
        }
    });
}
Also used : JaretTable(de.jaret.util.ui.table.JaretTable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory) Scale(org.eclipse.swt.widgets.Scale) DefaultHierarchicalTableModel(de.jaret.util.ui.table.model.DefaultHierarchicalTableModel) TableHierarchyRenderer(de.jaret.util.ui.table.renderer.TableHierarchyRenderer) GridLayout(org.eclipse.swt.layout.GridLayout) IColumn(de.jaret.util.ui.table.model.IColumn) HierarchyColumn(de.jaret.util.ui.table.model.HierarchyColumn) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHierarchicalJaretTableModel(de.jaret.util.ui.table.model.IHierarchicalJaretTableModel) StdHierarchicalTableModel(de.jaret.util.ui.table.model.StdHierarchicalTableModel) ITableNode(de.jaret.util.ui.table.model.ITableNode) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 3 with Scale

use of org.eclipse.swt.widgets.Scale 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 4 with Scale

use of org.eclipse.swt.widgets.Scale in project eclipse.platform.swt by eclipse.

the class ControlsWithLabelsExample method main.

public static void main(String[] args) {
    display = new Display();
    shell = new Shell(display);
    shell.setLayout(new GridLayout(4, true));
    shell.setText("All Controls Test");
    new Label(shell, SWT.NONE).setText("Label for Label");
    label = new Label(shell, SWT.NONE);
    label.setText("Label");
    new Label(shell, SWT.NONE).setText("Label for CLabel");
    cLabel = new CLabel(shell, SWT.NONE);
    cLabel.setText("CLabel");
    new Label(shell, SWT.NONE).setText("Label for Push Button");
    buttonPush = new Button(shell, SWT.PUSH);
    buttonPush.setText("Push Button");
    new Label(shell, SWT.NONE).setText("Label for Radio Button");
    buttonRadio = new Button(shell, SWT.RADIO);
    buttonRadio.setText("Radio Button");
    new Label(shell, SWT.NONE).setText("Label for Check Button");
    buttonCheck = new Button(shell, SWT.CHECK);
    buttonCheck.setText("Check Button");
    new Label(shell, SWT.NONE).setText("Label for Toggle Button");
    buttonToggle = new Button(shell, SWT.TOGGLE);
    buttonToggle.setText("Toggle Button");
    new Label(shell, SWT.NONE).setText("Label for Editable Combo");
    combo = new Combo(shell, SWT.BORDER);
    for (int i = 0; i < 4; i++) {
        combo.add("item" + i);
    }
    combo.select(0);
    new Label(shell, SWT.NONE).setText("Label for Read-Only Combo");
    combo = new Combo(shell, SWT.READ_ONLY | SWT.BORDER);
    for (int i = 0; i < 4; i++) {
        combo.add("item" + i);
    }
    combo.select(0);
    new Label(shell, SWT.NONE).setText("Label for CCombo");
    cCombo = new CCombo(shell, SWT.BORDER);
    for (int i = 0; i < 5; i++) {
        cCombo.add("item" + i);
    }
    cCombo.select(0);
    new Label(shell, SWT.NONE).setText("Label for List");
    list = new List(shell, SWT.SINGLE | SWT.BORDER);
    list.setItems("Item0", "Item1", "Item2");
    new Label(shell, SWT.NONE).setText("Label for Spinner");
    spinner = new Spinner(shell, SWT.BORDER);
    new Label(shell, SWT.NONE).setText("Label for Single-line Text");
    textSingle = new Text(shell, SWT.SINGLE | SWT.BORDER);
    textSingle.setText("Contents of Single-line Text");
    new Label(shell, SWT.NONE).setText("Label for Multi-line Text");
    textMulti = new Text(shell, SWT.MULTI | SWT.BORDER);
    textMulti.setText("\nContents of Multi-line Text\n");
    new Label(shell, SWT.NONE).setText("Label for StyledText");
    styledText = new StyledText(shell, SWT.MULTI | SWT.BORDER);
    styledText.setText("\nContents of Multi-line StyledText\n");
    new Label(shell, SWT.NONE).setText("Label for Table");
    table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    for (int col = 0; col < 3; col++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText("Col " + col);
        column.setWidth(50);
    }
    for (int row = 0; row < 3; row++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText(new String[] { "C0R" + row, "C1R" + row, "C2R" + row });
    }
    new Label(shell, SWT.NONE).setText("Label for Tree");
    tree = new Tree(shell, SWT.BORDER | SWT.MULTI);
    for (int i = 0; i < 3; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Item" + i);
        for (int j = 0; j < 4; j++) {
            new TreeItem(item, SWT.NONE).setText("Item" + i + j);
        }
    }
    new Label(shell, SWT.NONE).setText("Label for Tree with columns");
    treeTable = new Tree(shell, SWT.BORDER | SWT.MULTI);
    treeTable.setHeaderVisible(true);
    treeTable.setLinesVisible(true);
    for (int col = 0; col < 3; col++) {
        TreeColumn column = new TreeColumn(treeTable, SWT.NONE);
        column.setText("Col " + col);
        column.setWidth(50);
    }
    for (int i = 0; i < 3; i++) {
        TreeItem item = new TreeItem(treeTable, SWT.NONE);
        item.setText(new String[] { "I" + i + "C0", "I" + i + "C1", "I" + i + "C2" });
        for (int j = 0; j < 4; j++) {
            new TreeItem(item, SWT.NONE).setText(new String[] { "I" + i + j + "C0", "I" + i + j + "C1", "I" + i + j + "C2" });
        }
    }
    new Label(shell, SWT.NONE).setText("Label for ToolBar");
    toolBar = new ToolBar(shell, SWT.FLAT);
    for (int i = 0; i < 3; i++) {
        ToolItem item = new ToolItem(toolBar, SWT.PUSH);
        item.setText("Item" + i);
        item.setToolTipText("ToolItem ToolTip" + i);
    }
    new Label(shell, SWT.NONE).setText("Label for CoolBar");
    coolBar = new CoolBar(shell, SWT.FLAT);
    for (int i = 0; i < 2; i++) {
        CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH);
        ToolBar coolItemToolBar = new ToolBar(coolBar, SWT.FLAT);
        int toolItemWidth = 0;
        for (int j = 0; j < 2; j++) {
            ToolItem item = new ToolItem(coolItemToolBar, SWT.PUSH);
            item.setText("Item" + i + j);
            item.setToolTipText("ToolItem ToolTip" + i + j);
            if (item.getWidth() > toolItemWidth)
                toolItemWidth = item.getWidth();
        }
        coolItem.setControl(coolItemToolBar);
        Point size = coolItemToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        Point coolSize = coolItem.computeSize(size.x, size.y);
        coolItem.setMinimumSize(toolItemWidth, coolSize.y);
        coolItem.setPreferredSize(coolSize);
        coolItem.setSize(coolSize);
    }
    new Label(shell, SWT.NONE).setText("Label for Canvas");
    canvas = new Canvas(shell, SWT.BORDER);
    canvas.setLayoutData(new GridData(64, 64));
    canvas.addPaintListener(e -> e.gc.drawString("Canvas", 15, 25));
    canvas.setCaret(new Caret(canvas, SWT.NONE));
    /* Hook key listener so canvas will take focus during traversal in. */
    canvas.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }
    });
    /* Hook traverse listener to make canvas give up focus during traversal out. */
    canvas.addTraverseListener(e -> e.doit = true);
    new Label(shell, SWT.NONE).setText("Label for Group");
    group = new Group(shell, SWT.NONE);
    group.setText("Group");
    group.setLayout(new FillLayout());
    new Text(group, SWT.SINGLE | SWT.BORDER).setText("Text in Group");
    new Label(shell, SWT.NONE).setText("Label for TabFolder");
    tabFolder = new TabFolder(shell, SWT.NONE);
    for (int i = 0; i < 3; i++) {
        TabItem item = new TabItem(tabFolder, SWT.NONE);
        item.setText("TabItem &" + i);
        item.setToolTipText("TabItem ToolTip" + i);
        Text itemText = new Text(tabFolder, SWT.SINGLE | SWT.BORDER);
        itemText.setText("Text for TabItem " + i);
        item.setControl(itemText);
    }
    new Label(shell, SWT.NONE).setText("Label for CTabFolder");
    cTabFolder = new CTabFolder(shell, SWT.BORDER);
    for (int i = 0; i < 3; i++) {
        CTabItem item = new CTabItem(cTabFolder, SWT.NONE);
        item.setText("CTabItem &" + i);
        item.setToolTipText("CTabItem ToolTip" + i);
        Text itemText = new Text(cTabFolder, SWT.SINGLE | SWT.BORDER);
        itemText.setText("Text for CTabItem " + i);
        item.setControl(itemText);
    }
    cTabFolder.setSelection(cTabFolder.getItem(0));
    new Label(shell, SWT.NONE).setText("Label for Scale");
    scale = new Scale(shell, SWT.NONE);
    new Label(shell, SWT.NONE).setText("Label for Slider");
    slider = new Slider(shell, SWT.NONE);
    new Label(shell, SWT.NONE).setText("Label for ProgressBar");
    progressBar = new ProgressBar(shell, SWT.NONE);
    progressBar.setSelection(50);
    new Label(shell, SWT.NONE).setText("Label for Sash");
    sash = new Sash(shell, SWT.NONE);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Group(org.eclipse.swt.widgets.Group) CTabFolder(org.eclipse.swt.custom.CTabFolder) Slider(org.eclipse.swt.widgets.Slider) TreeItem(org.eclipse.swt.widgets.TreeItem) Spinner(org.eclipse.swt.widgets.Spinner) TableItem(org.eclipse.swt.widgets.TableItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) List(org.eclipse.swt.widgets.List) CoolItem(org.eclipse.swt.widgets.CoolItem) ProgressBar(org.eclipse.swt.widgets.ProgressBar) ToolItem(org.eclipse.swt.widgets.ToolItem) StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) Sash(org.eclipse.swt.widgets.Sash) Canvas(org.eclipse.swt.widgets.Canvas) TabFolder(org.eclipse.swt.widgets.TabFolder) CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Scale(org.eclipse.swt.widgets.Scale) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) TabItem(org.eclipse.swt.widgets.TabItem) CTabItem(org.eclipse.swt.custom.CTabItem) CCombo(org.eclipse.swt.custom.CCombo) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) Caret(org.eclipse.swt.widgets.Caret) Display(org.eclipse.swt.widgets.Display)

Example 5 with Scale

use of org.eclipse.swt.widgets.Scale in project eclipse.platform.swt by eclipse.

the class Test_situational method test_createWidgets.

public void test_createWidgets() {
    PerformanceMeter meter = createMeter("Create composites and widgets");
    int samples;
    Performance performance = Performance.getDefault();
    performance.tagAsGlobalSummary(meter, "Create composites and widgets", Dimension.ELAPSED_PROCESS);
    for (samples = 0; samples < 10; samples++) {
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        meter.start();
        for (int i = 0; i < 50; i++) {
            Composite c = new Composite(shell, SWT.NONE);
            for (int j = 0; j < 10; j++) {
                new Button(c, SWT.PUSH);
                new Label(c, SWT.NONE);
                new Scale(c, SWT.NONE);
                new ProgressBar(c, SWT.NONE);
                new List(c, SWT.NONE);
                new Text(c, SWT.SINGLE);
                new Text(c, SWT.MULTI);
                new Slider(c, SWT.NONE);
                new Tree(c, SWT.NONE);
                new Table(c, SWT.NONE);
                new TabFolder(c, SWT.NONE);
                new Group(c, SWT.BORDER);
                new Composite(c, SWT.NONE);
            }
        }
        meter.stop();
        shell.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    disposeMeter(meter);
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Slider(org.eclipse.swt.widgets.Slider) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) Scale(org.eclipse.swt.widgets.Scale) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Tree(org.eclipse.swt.widgets.Tree) List(org.eclipse.swt.widgets.List) Performance(org.eclipse.test.performance.Performance) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Aggregations

Scale (org.eclipse.swt.widgets.Scale)25 Label (org.eclipse.swt.widgets.Label)20 Composite (org.eclipse.swt.widgets.Composite)18 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Button (org.eclipse.swt.widgets.Button)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 SelectionListener (org.eclipse.swt.events.SelectionListener)10 Group (org.eclipse.swt.widgets.Group)10 Spinner (org.eclipse.swt.widgets.Spinner)9 Point (org.eclipse.swt.graphics.Point)8 Text (org.eclipse.swt.widgets.Text)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 FillLayout (org.eclipse.swt.layout.FillLayout)4 Combo (org.eclipse.swt.widgets.Combo)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 ColorSelector (org.eclipse.jface.preference.ColorSelector)3 StyledText (org.eclipse.swt.custom.StyledText)3 RowLayout (org.eclipse.swt.layout.RowLayout)3