Search in sources :

Example 16 with ColumnWeightData

use of org.eclipse.jface.viewers.ColumnWeightData in project sling by apache.

the class JcrPropertiesView method createPartControl.

/**
	 * This is a callback that will allow us
	 * to create the viewer and initialize it.
	 */
public void createPartControl(Composite parent) {
    SyncDirManager.registerUpdateListener(new UpdateHandler() {

        @Override
        public void syncDirUpdated(SyncDir syncDir) {
            refreshContent();
        }
    });
    mainControl = new Composite(parent, SWT.NONE);
    final GridLayout gridLayout = new GridLayout(1, true);
    mainControl.setLayout(gridLayout);
    if (getViewSite() != null) {
        titleLabel = new Label(mainControl, SWT.WRAP);
        titleLabel.setText("");
        GridData data = new GridData(GridData.FILL_HORIZONTAL);
        titleLabel.setLayoutData(data);
        Label horizontalLine = new Label(mainControl, SWT.SEPARATOR | SWT.HORIZONTAL);
        data = new GridData(GridData.FILL_HORIZONTAL);
        horizontalLine.setLayoutData(data);
    }
    Font font;
    if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
        FontData[] fontData = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData();
        /* title font is 2pt larger than that used in the tabs. */
        fontData[0].setHeight(fontData[0].getHeight() + 2);
        JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
    }
    font = JFaceResources.getFont(TITLE_FONT);
    if (titleLabel != null) {
        titleLabel.setFont(font);
    }
    Composite tableParent = new Composite(mainControl, SWT.NONE);
    //        tableParent.setBackground(new Color(Display.getDefault(), 100,20,180));
    GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    // shrink to min - table settings will resize to correct ratios
    tableLayoutData.widthHint = 1;
    tableLayoutData.heightHint = SWT.DEFAULT;
    tableParent.setLayoutData(tableLayoutData);
    TableColumnLayout tableLayout = new TableColumnLayout() {

        @Override
        protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
            Point p = super.computeSize(composite, wHint, hHint, flushCache);
            return new Point(p.x, p.y);
        }
    };
    tableParent.setLayout(tableLayout);
    viewer = new TableViewer(tableParent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HIDE_SELECTION | SWT.FULL_SELECTION);
    TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer), new CellNavigationStrategy());
    ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {

        @Override
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            resetLastValueEdited();
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        }
    };
    int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK;
    TableViewerEditor.create(viewer, focusCellManager, actSupport, features);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection iss = (IStructuredSelection) selection;
                if (iss.isEmpty()) {
                    deleteAction.setEnabled(false);
                } else {
                    deleteAction.setEnabled(true);
                }
            } else {
                deleteAction.setEnabled(false);
            }
        }
    });
    CellLabelProvider clp = new JcrCellLabelProvider(viewer);
    TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.NONE);
    column0.getColumn().setText("Name");
    column0.getColumn().setResizable(true);
    column0.getColumn().setWidth(200);
    tableLayout.setColumnData(column0.getColumn(), new ColumnWeightData(30, 140));
    final TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
    column1.getColumn().setText("Type");
    column1.getColumn().setResizable(true);
    column1.getColumn().setWidth(300);
    column1.setLabelProvider(clp);
    tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(10, 80));
    final TableViewerColumn column2 = new TableViewerColumn(viewer, SWT.NONE);
    column2.getColumn().setText("Value");
    column2.getColumn().setResizable(true);
    column2.getColumn().setWidth(300);
    tableLayout.setColumnData(column2.getColumn(), new ColumnWeightData(70, 220));
    final TableViewerColumn column3 = new TableViewerColumn(viewer, SWT.NONE);
    column3.getColumn().setText("Protected");
    column3.getColumn().setResizable(true);
    column3.getColumn().setWidth(300);
    column3.setLabelProvider(clp);
    tableLayout.setColumnData(column3.getColumn(), new ColumnWeightData(5, 57));
    final TableViewerColumn column4 = new TableViewerColumn(viewer, SWT.NONE);
    column4.getColumn().setText("Mandatory");
    column4.getColumn().setResizable(true);
    column4.getColumn().setWidth(300);
    column4.setLabelProvider(clp);
    tableLayout.setColumnData(column4.getColumn(), new ColumnWeightData(5, 62));
    final TableViewerColumn column5 = new TableViewerColumn(viewer, SWT.NONE);
    column5.getColumn().setText("Multiple");
    column5.getColumn().setResizable(true);
    column5.getColumn().setWidth(300);
    column5.setLabelProvider(clp);
    tableLayout.setColumnData(column5.getColumn(), new ColumnWeightData(5, 82));
    final TableViewerColumn column6 = new TableViewerColumn(viewer, SWT.NONE);
    column6.getColumn().setText("Auto Created");
    column6.getColumn().setResizable(true);
    column6.getColumn().setWidth(300);
    column6.setLabelProvider(clp);
    tableLayout.setColumnData(column6.getColumn(), new ColumnWeightData(5, 77));
    column0.setLabelProvider(clp);
    column0.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.NAME));
    column1.setLabelProvider(clp);
    column1.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.TYPE));
    column2.setLabelProvider(clp);
    column2.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.VALUE));
    column5.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.MULTIPLE));
    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.apache.sling.ide.eclipse-ui.viewer");
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
    listener = new ISelectionListener() {

        @Override
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection iss = (IStructuredSelection) selection;
                Object firstElem = iss.getFirstElement();
                if (firstElem instanceof JcrNode) {
                    JcrNode jcrNode = (JcrNode) firstElem;
                    setInput(jcrNode);
                    return;
                }
            }
        }
    };
    if (getViewSite() != null) {
        getViewSite().getPage().addSelectionListener(listener);
        final ISelection selection = getViewSite().getPage().getSelection();
        Display.getCurrent().asyncExec(new Runnable() {

            @Override
            public void run() {
                listener.selectionChanged(null, selection);
            }
        });
    }
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Label(org.eclipse.swt.widgets.Label) SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Font(org.eclipse.swt.graphics.Font) ISelectionListener(org.eclipse.ui.ISelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) FocusCellOwnerDrawHighlighter(org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter) ColumnViewerEditorActivationStrategy(org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider) UpdateHandler(org.apache.sling.ide.eclipse.ui.nav.model.UpdateHandler) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Point(org.eclipse.swt.graphics.Point) CellNavigationStrategy(org.eclipse.jface.viewers.CellNavigationStrategy) ColumnViewerEditorActivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) Point(org.eclipse.swt.graphics.Point) TableViewerFocusCellManager(org.eclipse.jface.viewers.TableViewerFocusCellManager) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 17 with ColumnWeightData

use of org.eclipse.jface.viewers.ColumnWeightData in project bndtools by bndtools.

the class ProjectListControl method createTableLayout.

private void createTableLayout(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // Add TableColumnLayout
    TableColumnLayout layout = new TableColumnLayout();
    composite.setLayout(layout);
    // Instantiate TableViewer
    projects = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    projects.setHeaderVisible(true);
    projects.setLinesVisible(true);
    projects.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            selectionListener.widgetSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            selectionListener.widgetDefaultSelected(e);
        }
    });
    tableViewer = new CheckboxTableViewer(projects);
    tableViewer.setUseHashlookup(true);
    // Project
    TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    TableColumn tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(60, 100, true));
    tableCol.setText(Messages.project1);
    // Repository
    tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(26, 80, true));
    tableCol.setText(Messages.repository);
    tableViewerColumn.setEditingSupport(new InlineComboEditingSupport(tableViewer));
    // Bundles
    tableViewerColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
    tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(14, 35, true));
    tableCol.setText(Messages.bundles);
    contentProvider = new ContentProvider();
    tableViewer.setContentProvider(contentProvider);
    tableViewer.setLabelProvider(new TableLabelProvider());
    tableViewer.setColumnProperties(columnNames);
    tableViewer.setCheckStateProvider(new ICheckStateProvider() {

        public boolean isGrayed(Object element) {
            return false;
        }

        public boolean isChecked(Object element) {
            ProjectDiff diff = (ProjectDiff) element;
            return diff.isRelease();
        }
    });
    projects.pack();
    TableSortingEnabler.applyTableColumnSorting(tableViewer);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) ProjectDiff(bndtools.release.ProjectDiff) Composite(org.eclipse.swt.widgets.Composite) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IColumnContentProvider(bndtools.release.ui.TableSortingEnabler.IColumnContentProvider) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 18 with ColumnWeightData

use of org.eclipse.jface.viewers.ColumnWeightData in project bndtools by bndtools.

the class BundleTree method createBundleTreeViewer.

private void createBundleTreeViewer(Composite container) {
    bundleTreeViewerComposite = new Composite(container, SWT.NONE);
    bundleTreeViewerComposite.setLayoutData(createFillGridData());
    TreeColumnLayout layout = new TreeColumnLayout();
    bundleTreeViewerComposite.setLayout(layout);
    bundleTreeViewer = new TreeViewer(bundleTreeViewerComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    bundleTreeViewer.setUseHashlookup(true);
    bundleTreeViewer.getTree().setHeaderVisible(true);
    TreeViewerColumn treeViewerColumn = new TreeViewerColumn(bundleTreeViewer, SWT.NONE);
    TreeColumn treeColumn = treeViewerColumn.getColumn();
    layout.setColumnData(treeColumn, new ColumnWeightData(100, 340, true));
    treeColumn.setText(Messages.symbNameResources);
    treeViewerColumn.setLabelProvider(new TreeLabelProvider());
    bundleTreeViewer.setContentProvider(bundleTreeViewerProvider);
    bundleTreeViewer.setAutoExpandLevel(3);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Example 19 with ColumnWeightData

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

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

the class InsertTableDataDialog method createAttrTable.

/**
	 * Create the table attribute table
	 */
private void createAttrTable() {
    attrTable = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    attrTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    attrTable.setHeaderVisible(true);
    attrTable.setLinesVisible(true);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(40, 160));
    attrTable.setLayout(layout);
    TableColumn[] tblColumns = new TableColumn[4];
    tblColumns[0] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[0].setText(Messages.metaAttribute);
    tblColumns[1] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[1].setText(Messages.metaDomain);
    tblColumns[2] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[2].setText(Messages.metaConstaints);
    tblColumns[3] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[3].setText(Messages.metaValue);
    TableItem item;
    for (int i = 0, n = schemaInfo.getAttributes().size(); i < n; i++) {
        DBAttribute da = (DBAttribute) schemaInfo.getAttributes().get(i);
        String type = DataType.getShownType(da.getType());
        if (type.toUpperCase(Locale.getDefault()).startsWith(DataType.DATATYPE_BLOB) || type.toUpperCase(Locale.getDefault()).startsWith(DataType.DATATYPE_CLOB)) {
            continue;
        }
        item = new TableItem(attrTable, SWT.NONE);
        item.setText(0, da.getName());
        item.setText(1, type);
        item.setText(2, getConstaintString(da));
    }
    packTable();
    tableEditor = new TableEditor(attrTable);
    tableEditor.horizontalAlignment = SWT.LEFT;
    tableEditor.grabHorizontal = true;
    attrTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // Identify the selected row
            TableItem item = (TableItem) event.item;
            if (item == null) {
                return;
            }
            handleValue(item);
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)31 TableLayout (org.eclipse.jface.viewers.TableLayout)22 GridData (org.eclipse.swt.layout.GridData)15 TableColumn (org.eclipse.swt.widgets.TableColumn)14 Composite (org.eclipse.swt.widgets.Composite)11 Table (org.eclipse.swt.widgets.Table)11 TableViewer (org.eclipse.jface.viewers.TableViewer)9 GridLayout (org.eclipse.swt.layout.GridLayout)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 Label (org.eclipse.swt.widgets.Label)5 TableItem (org.eclipse.swt.widgets.TableItem)5 BrokerEnvStatusColumn (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn)4 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)4 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 Viewer (org.eclipse.jface.viewers.Viewer)4 CellEditor (org.eclipse.jface.viewers.CellEditor)3