Search in sources :

Example 36 with GridLayout

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

the class PPTXPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group groupCommon = new Group(tparent, SWT.NONE);
    groupCommon.setLayout(new GridLayout());
    groupCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupCommon.setText(Messages.getString("preference.PPTXPreferencePage.groupCommon"));
    HsImageLabel imageLabel = new HsImageLabel(Messages.getString("preference.PPTXPreferencePage.imageLabel"), Activator.getImageDescriptor(Constants.PREFERENCE_PPTX_32));
    Composite cmpCommon = imageLabel.createControl(groupCommon);
    cmpCommon.setLayout(new GridLayout());
    cmpCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnNote = new Button(cmpCommon, SWT.CHECK);
    btnNote.setText(Messages.getString("preference.PPTXPreferencePage.btnNote"));
    GridDataFactory.fillDefaults().applyTo(btnNote);
    imageLabel.computeSize();
    btnNote.setSelection(preferenceStore.getBoolean(Constants.PPTX_FILTER));
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData)

Example 37 with GridLayout

use of org.eclipse.swt.layout.GridLayout 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 38 with GridLayout

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

the class MultiLineListExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls() {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    _jt = new JaretTable(_shell, SWT.V_SCROLL);
    _jt.setLayoutData(gd);
    if (_tableModel == null) {
        DefaultJaretTableModel model = new PropListeningTableModel();
        model.addRow(new DummyRow("r1", "line 1", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r2", "another first line", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r3", "and yet another one", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r5", "4444444444", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r6", "555555555", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r7", "6666666666", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r8", "7777777777", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r9", "88888888888", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        PropCol ct1 = new PropCol("t1", "column 1", "T1");
        ct1.setEditable(false);
        model.addColumn(ct1);
        _tableModel = model;
    }
    DefaultCellStyle cs = (DefaultCellStyle) _jt.getTableViewState().getCellStyleProvider().getDefaultCellStyle().copy();
    cs.setBorderConfiguration(new DefaultBorderConfiguration(0, 0, 0, 0));
    _jt.getTableViewState().getCellStyleProvider().setColumnCellStyle(_tableModel.getColumn(0), cs);
    _jt.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.FIXED);
    // has to be replaced
    for (int i = 0; i < _tableModel.getRowCount(); i++) {
        _jt.getTableViewState().setRowHeight(_tableModel.getRow(i), 60);
    }
    // _jt.getTableViewState().setColumnResizeMode(ITableViewState.ColumnResizeMode.ALL);
    _jt.setHeaderHeight(0);
    _jt.registerCellRenderer(_tableModel.getColumn(0), new MultilineListCellRenderer());
    _jt.setTableModel(_tableModel);
    _jt.getTableViewState().setColumnWidth(_tableModel.getColumn(0), 230);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) DummyRow(de.jaret.examples.table.DummyRow) DefaultCellStyle(de.jaret.util.ui.table.renderer.DefaultCellStyle) PropCol(de.jaret.util.ui.table.model.PropCol) JaretTable(de.jaret.util.ui.table.JaretTable) DefaultJaretTableModel(de.jaret.util.ui.table.model.DefaultJaretTableModel) GridData(org.eclipse.swt.layout.GridData) PropListeningTableModel(de.jaret.util.ui.table.model.PropListeningTableModel) DefaultBorderConfiguration(de.jaret.util.ui.table.renderer.DefaultBorderConfiguration) Date(java.util.Date)

Example 39 with GridLayout

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

the class TSWizardDialog method createPreviousAndNextButtons.

/**
	 * Creates the Previous and Next buttons for this wizard dialog. Creates
	 * standard (<code>SWT.PUSH</code>) buttons and registers for their
	 * selection events. Note that the number of columns in the button bar
	 * composite is incremented. These buttons are created specially to prevent
	 * any space between them.
	 * 
	 * @param parent
	 *            the parent button bar
	 * @return a composite containing the new buttons
	 */
private Composite createPreviousAndNextButtons(Composite parent) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size.
    GridLayout layout = new GridLayout();
    // will be incremented by createButton
    layout.numColumns = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER);
    composite.setLayoutData(data);
    composite.setFont(parent.getFont());
    backButton = createButton(composite, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    nextButton = createButton(composite, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    // make sure screen readers skip visual '<', '>' chars on buttons:
    final String backReaderText = IDialogConstants.BACK_LABEL.replace('<', ' ');
    backButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            e.result = backReaderText;
        }
    });
    final String nextReaderText = IDialogConstants.NEXT_LABEL.replace('>', ' ');
    nextButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            e.result = nextReaderText;
        }
    });
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent)

Example 40 with GridLayout

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

the class SimpleModelExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls() {
    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);
    if (_tableModel == null) {
        SimpleJaretTableModel model = new SimpleJaretTableModel();
        for (int x = 0; x <= NUMCOLS; x++) {
            model.setHeaderLabel(x, "" + x);
            for (int y = 0; y <= NUMROWS; y++) {
                model.setValueAt(x, y, x + "/" + y);
            }
        }
        _tableModel = model;
    }
    _jt.setTableModel(_tableModel);
    // set rowheight mode to variable .. optimal would be quite expensive on each col resize
    _jt.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
    for (int i = 0; i < NUMCOLS; i++) {
        IColumn col = _tableModel.getColumn(i);
        _jt.getTableViewState().setColumnWidth(col, 40);
    }
    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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) IColumn(de.jaret.util.ui.table.model.IColumn) JaretTable(de.jaret.util.ui.table.JaretTable) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SimpleJaretTableModel(de.jaret.util.ui.table.model.simple.SimpleJaretTableModel) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)1868 GridData (org.eclipse.swt.layout.GridData)1646 Composite (org.eclipse.swt.widgets.Composite)1417 Label (org.eclipse.swt.widgets.Label)839 Button (org.eclipse.swt.widgets.Button)672 SelectionEvent (org.eclipse.swt.events.SelectionEvent)597 Text (org.eclipse.swt.widgets.Text)510 Group (org.eclipse.swt.widgets.Group)491 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)481 Combo (org.eclipse.swt.widgets.Combo)215 ModifyListener (org.eclipse.swt.events.ModifyListener)199 SelectionListener (org.eclipse.swt.events.SelectionListener)197 ModifyEvent (org.eclipse.swt.events.ModifyEvent)190 Table (org.eclipse.swt.widgets.Table)138 Point (org.eclipse.swt.graphics.Point)131 TableViewer (org.eclipse.jface.viewers.TableViewer)112 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)109 Shell (org.eclipse.swt.widgets.Shell)107 FillLayout (org.eclipse.swt.layout.FillLayout)96 ArrayList (java.util.ArrayList)89