Search in sources :

Example 26 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData 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 27 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project translationstudio8 by heartsome.

the class WebSearchPreferencePage method createTableArea.

private Composite createTableArea(Composite parent) {
    Composite tableArea = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginWidth = 0;
    tableArea.setLayout(gridLayout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    tableArea.setLayoutData(gridData);
    checkboxTableViewer = CheckboxTableViewer.newCheckList(tableArea, SWT.BORDER | SWT.FULL_SELECTION);
    table = checkboxTableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(false);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(40));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(70, 50, true));
    table.setLayout(tableLayout);
    GridData tableGridData = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(tableGridData);
    WebSearchLableProvider webSearchLableProvider = new WebSearchLableProvider();
    webSearchLableProvider.createColumns(checkboxTableViewer);
    checkboxTableViewer.setContentProvider(new WebSearchContentProvider());
    checkboxTableViewer.setLabelProvider(webSearchLableProvider);
    checkboxTableViewer.setCheckStateProvider(new CheckProvider());
    checkboxTableViewer.addCheckStateListener(new CheckListener());
    // checkboxTableViewer.setCellEditors(new CellEditor[] { null, new TextCellEditor(table),
    // new TextCellEditor(table) });
    // checkboxTableViewer.setCellModifier(new NameModifier());
    checkboxTableViewer.setColumnProperties(new String[] { APP_PROP, NAME_PROP, URL_PROP });
    cache = WebSearchPreferencStore.getIns().getSearchConfig();
    checkboxTableViewer.setInput((Object) cache);
    return tableArea;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 28 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project cubrid-manager by CUBRID.

the class FavoriteQueryNavigatorView method createTableGroup.

private void createTableGroup(Composite composite) {
    final String[] columnNames = new String[] { "", com.cubrid.common.ui.query.Messages.msgBatchRunSqlFile, com.cubrid.common.ui.query.Messages.msgBatchRunMemo, com.cubrid.common.ui.query.Messages.msgBatchRunRegdate };
    tv = CommonUITool.createCommonTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    tv.setInput(FavoriteQueryPersistUtil.getInstance().getListData());
    {
        TableLayout tableLayout = new TableLayout();
        tableLayout.addColumnData(new ColumnPixelData(0));
        tableLayout.addColumnData(new ColumnPixelData(209));
        tableLayout.addColumnData(new ColumnPixelData(80));
        tableLayout.addColumnData(new ColumnPixelData(118));
        tv.getTable().setLayout(tableLayout);
    }
    editor = new TableEditor(tv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    tv.getTable().addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateButtonStatus();
        }
    });
    tv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            updateButtonStatus();
            Point pt = new Point(event.x, event.y);
            int newIndex = tv.getTable().getSelectionIndex();
            if (tv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = tv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            Rectangle rect = item.getBounds(2);
            if (rect.contains(pt)) {
                focusCell(item, newIndex, 2);
            }
        }
    });
    tv.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            openSelectedFile(selection);
        }
    });
    createContextMenu();
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MenuListener(org.eclipse.swt.events.MenuListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Rectangle(org.eclipse.swt.graphics.Rectangle) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MenuEvent(org.eclipse.swt.events.MenuEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 29 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project cubrid-manager by CUBRID.

the class SqlmapNavigatorView method createParamView.

private void createParamView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapName, Messages.lblSqlmapValue, Messages.lblSqlmapType };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapParameters);
    paramView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 120));
    paramView.setColumnProperties(columnNames);
    paramView.setContentProvider(new TableContentProvider());
    paramView.setLabelProvider(new TableLabelProvider());
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(100));
    tableLayout.addColumnData(new ColumnPixelData(80));
    tableLayout.addColumnData(new ColumnPixelData(70));
    paramView.getTable().setLayout(tableLayout);
    paramView.addDoubleClickListener(new IDoubleClickListener() {

        @SuppressWarnings("unchecked")
        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            Map<String, String> data = (Map<String, String>) sel.getFirstElement();
            modifyParam(data);
        }
    });
    Menu menu = new Menu(paramView.getTable().getShell(), SWT.POP_UP);
    paramView.getTable().setMenu(menu);
    final MenuItem addMenuItem = new MenuItem(menu, SWT.PUSH);
    addMenuItem.setText(Messages.mnuSqlmapAdd);
    addMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            addParameter();
        }
    });
    final MenuItem modifyMenuItem = new MenuItem(menu, SWT.PUSH);
    modifyMenuItem.setText(Messages.mnuSqlmapModify);
    modifyMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            modifyParameterByCurrentSelected();
        }
    });
    final MenuItem delMenuItem = new MenuItem(menu, SWT.PUSH);
    delMenuItem.setText(Messages.mnuSqlmapRemove);
    delMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.msgSqlmapRemove)) {
                removeParameterByCurrentSelected();
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableLayout(org.eclipse.jface.viewers.TableLayout) Map(java.util.Map) HashMap(java.util.HashMap)

Example 30 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project tdi-studio-se by Talend.

the class AssignmentPropertySection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    // PTODO mhelleboid externalize tableviewer creation
    adapterFactory = new BusinessItemProviderAdapterFactory();
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
    Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Messages.getString("AssignmentPropertySection.Comment") };
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column3.setText(columnProperties[2]);
    tableViewer.setColumnProperties(columnProperties);
    final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
    tableViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            return property.equals(columnProperties[2]);
        }

        public Object getValue(Object element, String property) {
            return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
        }

        public void modify(Object element, String property, Object value) {
            if (element instanceof TableItem) {
                TableItem tableItem = (TableItem) element;
                itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
            }
        }
    });
    CellEditor[] cellEditors = new CellEditor[3];
    cellEditors[2] = new TextCellEditor(table);
    tableViewer.setCellEditors(cellEditors);
    createKeyListener(table);
    createSelectionListener();
    createPopupMenu();
    createDoubleClickListener();
    handleLayout(parent, table, column1, column2, column3);
    aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)45 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)20 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)17 TableLayout (org.eclipse.jface.viewers.TableLayout)16 Composite (org.eclipse.swt.widgets.Composite)15 TableViewer (org.eclipse.jface.viewers.TableViewer)14 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)13 Image (org.eclipse.swt.graphics.Image)13 GridData (org.eclipse.swt.layout.GridData)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)8 Point (org.eclipse.swt.graphics.Point)8 Table (org.eclipse.swt.widgets.Table)8 ArrayList (java.util.ArrayList)6 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)6 Viewer (org.eclipse.jface.viewers.Viewer)6 GridLayout (org.eclipse.swt.layout.GridLayout)6