Search in sources :

Example 31 with Composite

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

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

the class SelectionStatusDialog method createButtonBar.

/*
     * @see Dialog#createButtonBar(Composite)
     */
protected Control createButtonBar(Composite parent) {
    Font font = parent.getFont();
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    if (!fStatusLineAboveButtons) {
        layout.numColumns = 2;
    }
    layout.marginHeight = 0;
    layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setFont(font);
    if (!fStatusLineAboveButtons && isHelpAvailable()) {
        createHelpControl(composite);
    }
    fStatusLine = new MessageLine(composite);
    fStatusLine.setAlignment(SWT.LEFT);
    GridData statusData = new GridData(GridData.FILL_HORIZONTAL);
    fStatusLine.setErrorStatus(null);
    fStatusLine.setFont(font);
    if (fStatusLineAboveButtons && isHelpAvailable()) {
        statusData.horizontalSpan = 2;
        createHelpControl(composite);
    }
    fStatusLine.setLayoutData(statusData);
    /*
		 * Create the rest of the button bar, but tell it not to
		 * create a help button (we've already created it).
		 */
    boolean helpAvailable = isHelpAvailable();
    setHelpAvailable(false);
    super.createButtonBar(composite);
    setHelpAvailable(helpAvailable);
    return composite;
}
Also used : MessageLine(org.eclipse.ui.internal.MessageLine) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Font(org.eclipse.swt.graphics.Font)

Example 33 with Composite

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

the class HsImageLabel method createControl.

public Composite createControl(Composite parent) {
    parent.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            dispose();
        }
    });
    Composite content = new Composite(parent, SWT.NONE);
    GridLayout contentLayout = new GridLayout(2, false);
    contentLayout.marginWidth = 0;
    contentLayout.marginHeight = 0;
    content.setLayout(contentLayout);
    content.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    this.control = content;
    imageLabel = createImageLabel(content);
    if (imageLabel != null) {
        imageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    }
    Composite composite = new Composite(content, SWT.NONE);
    GridLayout comLayout = new GridLayout();
    comLayout.marginWidth = 0;
    comLayout.marginHeight = 0;
    composite.setLayout(comLayout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    descriptionLabel = createDescriptionLabel(composite);
    if (descriptionLabel != null) {
        descriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    body = new Composite(composite, SWT.NONE);
    GridLayout gd = new GridLayout();
    gd.marginRight = 0;
    gd.marginHeight = 0;
    body.setLayout(gd);
    if (body != null) {
        body.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    return body;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 34 with Composite

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

the class TSWizardDialog method createPageContainer.

/**
	 * Creates the container that holds all pages.
	 * 
	 * @param parent
	 * @return Composite
	 */
private Composite createPageContainer(Composite parent) {
    Composite result = new Composite(parent, SWT.NULL);
    result.setLayout(pageContainerLayout);
    return result;
}
Also used : Composite(org.eclipse.swt.widgets.Composite)

Example 35 with Composite

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

the class TSWizardDialog method createDialogArea.

/*
	 * (non-Javadoc) Method declared on Dialog.
	 */
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    // Build the Page container
    pageContainer = createPageContainer(composite);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = pageWidth;
    gd.heightHint = pageHeight;
    pageContainer.setLayoutData(gd);
    pageContainer.setFont(parent.getFont());
    // Insert a progress monitor
    progressMonitorPart = createProgressMonitorPart(composite, new GridLayout());
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    progressMonitorPart.setLayoutData(gridData);
    progressMonitorPart.setVisible(false);
    // Build the separator line
    Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    applyDialogFont(progressMonitorPart);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)2054 GridData (org.eclipse.swt.layout.GridData)1441 GridLayout (org.eclipse.swt.layout.GridLayout)1419 Label (org.eclipse.swt.widgets.Label)853 Button (org.eclipse.swt.widgets.Button)694 SelectionEvent (org.eclipse.swt.events.SelectionEvent)577 Text (org.eclipse.swt.widgets.Text)519 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)463 Group (org.eclipse.swt.widgets.Group)305 Combo (org.eclipse.swt.widgets.Combo)210 Point (org.eclipse.swt.graphics.Point)198 FillLayout (org.eclipse.swt.layout.FillLayout)188 ModifyListener (org.eclipse.swt.events.ModifyListener)186 SelectionListener (org.eclipse.swt.events.SelectionListener)183 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)182 ModifyEvent (org.eclipse.swt.events.ModifyEvent)168 Table (org.eclipse.swt.widgets.Table)159 TableViewer (org.eclipse.jface.viewers.TableViewer)153 Control (org.eclipse.swt.widgets.Control)149 ArrayList (java.util.ArrayList)107