Search in sources :

Example 71 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.

the class SpreadSheetTable method insertColumn.

/**
 * Insert a column. Default values for the new column are empty strings.
 *
 * @param index
 *            index of the column.
 */
public void insertColumn(int index) {
    for (List<String> row : input) {
        // $NON-NLS-1$
        row.add(index, "");
    }
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE, index);
    viewerColumn.getColumn().setMoveable(false);
    viewerColumn.getColumn().setWidth(DEFAULT_COLUMN_WIDTH);
    TextEditingSupport textEditingSupport = new TextEditingSupport(tableViewer);
    viewerColumn.setEditingSupport(textEditingSupport);
    viewerColumn.getColumn().setData(TEXT_EDITING_SUPPORT_KEY, textEditingSupport);
    tableViewer.setLabelProvider(new TextTableLableProvider());
    fireTableModified();
}
Also used : TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 72 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.

the class ActionsInputDialog method createPropertiesViewer.

private TableViewer createPropertiesViewer(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn tvColumn = new TableViewerColumn(viewer, SWT.NONE);
    tvColumn.getColumn().setText("Property");
    tvColumn.getColumn().setMoveable(false);
    tvColumn.getColumn().setWidth(100);
    tvColumn = new TableViewerColumn(viewer, SWT.NONE);
    tvColumn.getColumn().setText("Value");
    tvColumn.getColumn().setMoveable(false);
    tvColumn.getColumn().setWidth(300);
    EditingSupport editingSupport = new PropertiesEditingSupport(viewer, viewer.getTable());
    tvColumn.setEditingSupport(editingSupport);
    viewer.setContentProvider(new WidgetPropertiesContentProvider());
    viewer.setLabelProvider(new PropertiesLabelProvider());
    viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    viewer.getTable().setEnabled(false);
    return viewer;
}
Also used : GridData(org.eclipse.swt.layout.GridData) EditingSupport(org.eclipse.jface.viewers.EditingSupport) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 73 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.

the class RuleDataEditDialog method createExpressionsTableViewer.

/**
 * Creates and configures a {@link TableViewer}.
 *
 * @param parent
 *            The parent for the table
 * @return The {@link TableViewer}
 */
private TableViewer createExpressionsTableViewer(final Composite parent) {
    final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn expressionColumn = new TableViewerColumn(viewer, SWT.NONE);
    expressionColumn.getColumn().setText("Boolean Expression");
    expressionColumn.getColumn().setMoveable(false);
    expressionColumn.getColumn().setWidth(200);
    expressionColumn.setEditingSupport(new EditingSupport(viewer) {

        @Override
        protected void setValue(Object element, Object value) {
            if (element instanceof Expression)
                ((Expression) element).setBooleanExpression(value.toString());
            viewer.refresh();
        }

        @Override
        protected Object getValue(Object element) {
            if (element instanceof Expression)
                return ((Expression) element).getBooleanExpression();
            return null;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            return new TextCellEditor(viewer.getTable());
        }

        @Override
        protected boolean canEdit(Object element) {
            return true;
        }
    });
    valueColumn = new TableViewerColumn(viewer, SWT.NONE);
    valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
    valueColumn.getColumn().setMoveable(false);
    valueColumn.getColumn().setWidth(200);
    EditingSupport editingSupport = new EditingSupport(viewer) {

        @Override
        protected void setValue(Object element, Object value) {
            if (element instanceof Expression) {
                ((Expression) element).setValue(value);
            }
            viewer.refresh();
        }

        @Override
        protected Object getValue(Object element) {
            if (element instanceof Expression) {
                if (((Expression) element).getValue() == null)
                    // $NON-NLS-1$
                    return "";
                return ((Expression) element).getValue();
            }
            return null;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            if (element instanceof Expression) {
                if (ruleData.isOutputExpValue() || ruleData.getProperty().getPropertyDescriptor() == null)
                    return new TextCellEditor(viewer.getTable());
                else
                    return ruleData.getProperty().getPropertyDescriptor().createPropertyEditor(viewer.getTable());
            }
            return null;
        }

        @Override
        protected boolean canEdit(Object element) {
            return true;
        }
    };
    valueColumn.setEditingSupport(editingSupport);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ExpressionLabelProvider());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    viewer.getTable().setLayoutData(gd);
    return viewer;
}
Also used : Expression(org.csstudio.opibuilder.script.Expression) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) EditingSupport(org.eclipse.jface.viewers.EditingSupport) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 74 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.

the class PropertyDataLabelProvider method createPropertiesViewer.

private TableViewer createPropertiesViewer(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn tvColumn = new TableViewerColumn(viewer, SWT.NONE);
    tvColumn.getColumn().setText("Property");
    tvColumn.getColumn().setMoveable(false);
    tvColumn.getColumn().setWidth(150);
    tvColumn = new TableViewerColumn(viewer, SWT.NONE);
    tvColumn.getColumn().setText("Value");
    tvColumn.getColumn().setMoveable(false);
    tvColumn.getColumn().setWidth(200);
    EditingSupport editingSupport = new PropertyDataEditingSupport(viewer, viewer.getTable());
    tvColumn.setEditingSupport(editingSupport);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new PropertyDataLabelProvider());
    viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    return viewer;
}
Also used : ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) EditingSupport(org.eclipse.jface.viewers.EditingSupport) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 75 with TableViewerColumn

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

the class BrokerConfigEditComposite method createCubridBrokerConfPropTable.

/**
	 * Create property table
	 *
	 * @param cubridBrokerConfTabFolder
	 */
public void createCubridBrokerConfPropTable(CTabFolder cubridBrokerConfTabFolder) {
    final Composite comp = new Composite(cubridBrokerConfTabFolder, SWT.NONE);
    comp.setLayoutData(new GridData(FILL_HORIZONTAL));
    comp.setLayout(new GridLayout(1, false));
    tableCTabItem = new CTabItem(cubridBrokerConfTabFolder, SWT.NONE);
    tableCTabItem.setText(inputName);
    confTableViewer = new TableViewer(comp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    final Table confTable = confTableViewer.getTable();
    confTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    confTable.setHeaderVisible(true);
    confTable.setLinesVisible(true);
    confTableViewer.setUseHashlookup(true);
    CommonUITool.hackForYosemite(confTable);
    // create column
    final TableViewerColumn column = new TableViewerColumn(confTableViewer, SWT.LEFT);
    column.getColumn().setWidth(0);
    column.getColumn().setText("");
    confTableViewer.setContentProvider(confTableContentProvider);
    confTableViewer.setLabelProvider(confTableLabelProvider);
    confTableViewer.setSorter(new BrokerConfTableViewerSorter());
    // use to mark click point, the right click menu use this point
    confTable.addListener(SWT.MouseDown, new Listener() {

        public void handleEvent(Event event) {
            clickPoint = new Point(event.x, event.y);
            clickPointTiming = System.currentTimeMillis();
        }
    });
    registerContextMenu();
    tableCTabItem.setControl(comp);
}
Also used : CommonUITool.createGridLayout(com.cubrid.common.ui.spi.util.CommonUITool.createGridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuEvent(org.eclipse.swt.events.MenuEvent) DocumentEvent(org.eclipse.jface.text.DocumentEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) CTabItem(org.eclipse.swt.custom.CTabItem) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)134 TableViewer (org.eclipse.jface.viewers.TableViewer)72 Composite (org.eclipse.swt.widgets.Composite)53 GridData (org.eclipse.swt.layout.GridData)52 SelectionEvent (org.eclipse.swt.events.SelectionEvent)45 TableColumn (org.eclipse.swt.widgets.TableColumn)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 GridLayout (org.eclipse.swt.layout.GridLayout)32 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)28 Table (org.eclipse.swt.widgets.Table)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 Point (org.eclipse.swt.graphics.Point)15 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)14 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 Button (org.eclipse.swt.widgets.Button)14 Image (org.eclipse.swt.graphics.Image)13 Text (org.eclipse.swt.widgets.Text)11