Search in sources :

Example 1 with ColumnLayoutData

use of org.eclipse.jface.viewers.ColumnLayoutData in project xtext-eclipse by eclipse.

the class AbstractCallHierarchyViewPart method getLocationColumnDescriptions.

protected Pair<String, ColumnLayoutData>[] getLocationColumnDescriptions() {
    ColumnWeightData _columnWeightData = new ColumnWeightData(60);
    Pair<String, ColumnLayoutData> _mappedTo = Pair.<String, ColumnLayoutData>of("Line", _columnWeightData);
    ColumnWeightData _columnWeightData_1 = new ColumnWeightData(300);
    Pair<String, ColumnLayoutData> _mappedTo_1 = Pair.<String, ColumnLayoutData>of("Call", _columnWeightData_1);
    return new Pair[] { _mappedTo, _mappedTo_1 };
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 2 with ColumnLayoutData

use of org.eclipse.jface.viewers.ColumnLayoutData in project xtext-eclipse by eclipse.

the class ListDialogField method getListControl.

// ------ UI creation
/**
 * Returns the list control. When called the first time, the control will be
 * created.
 *
 * @param parent
 *            The parent composite when called the first time, or
 *            <code>null</code> after.
 */
public Control getListControl(Composite parent) {
    if (fTableControl == null) {
        assertCompositeNotNull(parent);
        if (fTableColumns == null) {
            fTable = createTableViewer(parent);
            Table tableControl = fTable.getTable();
            fTableControl = tableControl;
            tableControl.setLayout(new TableLayout());
        } else {
            TableLayoutComposite composite = new TableLayoutComposite(parent, SWT.NONE);
            composite.setFont(parent.getFont());
            fTableControl = composite;
            fTable = createTableViewer(composite);
            Table tableControl = fTable.getTable();
            tableControl.setHeaderVisible(fTableColumns.headers != null);
            tableControl.setLinesVisible(fTableColumns.drawLines);
            ColumnLayoutData[] columns = fTableColumns.columns;
            for (int i = 0; i < columns.length; i++) {
                composite.addColumnData(columns[i]);
                TableColumn column = new TableColumn(tableControl, SWT.NONE);
                // tableLayout.addColumnData(columns[i]);
                if (fTableColumns.headers != null) {
                    column.setText(fTableColumns.headers[i]);
                }
            }
        }
        fTable.getTable().addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                handleKeyPressed(e);
            }
        });
        // fTableControl.setLayout(tableLayout);
        fTable.setContentProvider(fListViewerAdapter);
        fTable.setLabelProvider(fLabelProvider);
        fTable.addSelectionChangedListener(fListViewerAdapter);
        fTable.addDoubleClickListener(fListViewerAdapter);
        fTable.setInput(fParentElement);
        if (fViewerComparator != null) {
            fTable.setComparator(fViewerComparator);
        }
        fTableControl.setEnabled(isEnabled());
        if (fSelectionWhenEnabled != null) {
            selectElements(fSelectionWhenEnabled);
        }
    }
    return fTableControl;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) TableLayout(org.eclipse.jface.viewers.TableLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Example 3 with ColumnLayoutData

use of org.eclipse.jface.viewers.ColumnLayoutData in project erlide_eclipse by erlang.

the class ListDialogField method getListControl.

// ------ ui creation
/**
 * Returns the list control. When called the first time, the control will be created.
 *
 * @param parent
 *            The parent composite when called the first time, or <code>null</code>
 *            after.
 */
public Control getListControl(final Composite parent) {
    if (fTableControl == null) {
        assertCompositeNotNull(parent);
        if (fTableColumns == null) {
            fTable = createTableViewer(parent);
            final Table tableControl = fTable.getTable();
            fTableControl = tableControl;
            tableControl.setLayout(new TableLayout());
        } else {
            final TableLayoutComposite composite = new TableLayoutComposite(parent, SWT.NONE);
            fTableControl = composite;
            fTable = createTableViewer(composite);
            final Table tableControl = fTable.getTable();
            tableControl.setHeaderVisible(fTableColumns.fHeaders != null);
            tableControl.setLinesVisible(fTableColumns.fDrawLines);
            final ColumnLayoutData[] columns = fTableColumns.fColumns;
            for (int i = 0; i < columns.length; i++) {
                composite.addColumnData(columns[i]);
                final TableColumn column = new TableColumn(tableControl, SWT.NONE);
                // tableLayout.addColumnData(columns[i]);
                if (fTableColumns.fHeaders != null) {
                    column.setText(fTableColumns.fHeaders[i]);
                }
            }
        }
        fTable.getTable().addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(final KeyEvent e) {
                handleKeyPressed(e);
            }
        });
        // fTableControl.setLayout(tableLayout);
        fTable.setContentProvider(fListViewerAdapter);
        fTable.setLabelProvider(fLabelProvider);
        fTable.addSelectionChangedListener(fListViewerAdapter);
        fTable.addDoubleClickListener(fListViewerAdapter);
        fTable.setInput(fParentElement);
        if (fViewerSorter != null) {
            fTable.setComparator(fViewerSorter);
        }
        fTableControl.setEnabled(isEnabled());
        if (fSelectionWhenEnabled != null) {
            postSetSelection(fSelectionWhenEnabled);
        }
    }
    return fTableControl;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) TableLayoutComposite(org.erlide.ui.internal.util.TableLayoutComposite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) TableLayout(org.eclipse.jface.viewers.TableLayout) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 4 with ColumnLayoutData

use of org.eclipse.jface.viewers.ColumnLayoutData in project erlide_eclipse by erlang.

the class TableLayoutComposite method computeTableSize.

// ---- Helpers
// -------------------------------------------------------------------------------------
protected Point computeTableSize(final Table table) {
    final Point result = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int width = 0;
    for (final ColumnLayoutData layoutData : columns) {
        if (layoutData instanceof ColumnPixelData) {
            final ColumnPixelData col = (ColumnPixelData) layoutData;
            width += col.width;
        } else if (layoutData instanceof ColumnWeightData) {
            final ColumnWeightData col = (ColumnWeightData) layoutData;
            width += col.minimumWidth;
        } else {
            // $NON-NLS-1$
            Assert.isTrue(false, "Unknown column layout data");
        }
    }
    if (width > result.x) {
        result.x = width;
    }
    return result;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 5 with ColumnLayoutData

use of org.eclipse.jface.viewers.ColumnLayoutData in project liferay-ide by liferay.

the class ContextProperties method createContextPage.

// private DirectoryEditor rootDirectory;
private Control createContextPage(Composite parent) {
    contextValues = new Properties();
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout(1, true));
    if (getElement() instanceof IProject) {
        IProject project = (IProject) getElement();
        Composite subComp = new Composite(composite, SWT.NULL);
        subComp.setLayout(new GridLayout(2, false));
        subComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // try {
    // javascriptDirectory = new DirectoryEditor(getShell(), subComp, "Javascript Direcotory", project.getPersistentProperty(Constants.newQualifiedName(Constants.DIR_JAVASCRIPT)));
    // }
    // catch (CoreException ce) {}
    }
    Composite subComp = new Composite(composite, SWT.NULL);
    subComp.setLayout(new GridLayout(1, false));
    subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    contextValuesTable = new Table(subComp, SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    contextValuesTable.setVisible(true);
    contextValuesTable.setLinesVisible(false);
    contextValuesTable.setHeaderVisible(true);
    contextValuesTable.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            editContextValueButton.setEnabled(true);
            deleteContextValueButton.setEnabled(true);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    contextValuesTable.addKeyListener(new ContextValueDeleteKeyListener());
    contextValuesTable.addMouseListener(new EditContextValueButtonListener());
    // create the columns
    TableColumn keyColumn = new TableColumn(contextValuesTable, SWT.LEFT);
    TableColumn valueColumn = new TableColumn(contextValuesTable, SWT.LEFT);
    keyColumn.setText(Messages.ContextProperties_KeyColumn);
    valueColumn.setText(Messages.ContextProperties_ValueColumn);
    ColumnLayoutData keyColumnLayout = new ColumnWeightData(30, false);
    ColumnLayoutData valueColumnLayout = new ColumnWeightData(70, false);
    // set columns in Table layout
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(keyColumnLayout);
    tableLayout.addColumnData(valueColumnLayout);
    contextValuesTable.setLayout(tableLayout);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 50;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    contextValuesTable.setLayoutData(data);
    Composite buttonComposite = new Composite(subComp, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.BEGINNING;
    data.verticalAlignment = GridData.BEGINNING;
    buttonComposite.setLayoutData(data);
    GridLayout gl = new GridLayout(3, true);
    buttonComposite.setLayout(gl);
    buttonComposite.setVisible(true);
    addContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    addContextValueButton.setText(Messages.ContextProperties_NewButton);
    addContextValueButton.setVisible(true);
    addContextValueButton.addSelectionListener(new AddContextValueButtonListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    addContextValueButton.setLayoutData(data);
    editContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    editContextValueButton.setText(Messages.ContextProperties_EditButton);
    editContextValueButton.addSelectionListener(new EditContextValueButtonListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    editContextValueButton.setLayoutData(data);
    deleteContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    deleteContextValueButton.setText(Messages.ContextProperties_DeleteButton);
    deleteContextValueButton.addSelectionListener(new ContextValueDeleteKeyListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    deleteContextValueButton.setLayoutData(data);
    reloadContextValues();
    return composite;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Properties(java.util.Properties) TableColumn(org.eclipse.swt.widgets.TableColumn) IProject(org.eclipse.core.resources.IProject) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) TableLayout(org.eclipse.jface.viewers.TableLayout) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ColumnLayoutData (org.eclipse.jface.viewers.ColumnLayoutData)13 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)10 TableColumn (org.eclipse.swt.widgets.TableColumn)8 Point (org.eclipse.swt.graphics.Point)6 Table (org.eclipse.swt.widgets.Table)6 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)5 TableLayout (org.eclipse.jface.viewers.TableLayout)5 KeyEvent (org.eclipse.swt.events.KeyEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Pair (org.eclipse.xtext.xbase.lib.Pair)3 Properties (java.util.Properties)2 KeyAdapter (org.eclipse.swt.events.KeyAdapter)2 Button (org.eclipse.swt.widgets.Button)2 IProject (org.eclipse.core.resources.IProject)1 PixelConverter (org.eclipse.jface.layout.PixelConverter)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1