Example usage for org.eclipse.jface.viewers CheckboxCellEditor CheckboxCellEditor

List of usage examples for org.eclipse.jface.viewers CheckboxCellEditor CheckboxCellEditor

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers CheckboxCellEditor CheckboxCellEditor.

Prototype

public CheckboxCellEditor() 

Source Link

Document

Creates a new checkbox cell editor with no control

Usage

From source file:ar.com.fluxit.jqa.wizard.page.CommonsTypesDefinitionWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/* ww w  . ja  v a  2  s  .  c  om*/
    container.setLayout(layout);

    Tree commonTypesTree = new Tree(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    commonTypesTree.setHeaderVisible(true);
    commonTypesTree.setLinesVisible(true);
    commonTypesTree.setLayoutData(new GridData(GridData.FILL_BOTH));
    commonTypesTreeViewer = new TreeViewer(commonTypesTree);

    TreeViewerColumn layerColumn = new TreeViewerColumn(commonTypesTreeViewer, SWT.LEFT);
    layerColumn.getColumn().setText("Layer/Types");
    layerColumn.getColumn().setWidth(400);

    final CellEditor checkboxCellEditor = new CheckboxCellEditor();
    TreeViewerColumn commonTypeColumn = new TreeViewerColumn(commonTypesTreeViewer, SWT.LEFT);
    commonTypeColumn.getColumn().setText("Is common?");
    commonTypeColumn.getColumn().setWidth(50);
    commonTypeColumn.setEditingSupport(new EditingSupport(commonTypesTreeViewer) {

        @Override
        protected boolean canEdit(Object arg0) {
            return true;
        }

        @Override
        protected CellEditor getCellEditor(Object arg0) {
            return checkboxCellEditor;
        }

        @Override
        protected Object getValue(Object arg0) {
            return ((CommonDescriptor) arg0).isCommon();
        }

        @Override
        protected void setValue(Object arg0, Object arg1) {
            ((CommonDescriptor) arg0).setCommon((Boolean) arg1);
            commonTypesTreeViewer.update(arg0, null);
        }
    });

    commonTypesTreeViewer.setContentProvider(new CommonTypesContentProvider());
    commonTypesTreeViewer.setLabelProvider(new CommonTypesLabelProvider());
    commonTypesTreeViewer.setInput(getArchitectureDescriptor());
    commonTypesTreeViewer.expandAll();
    commonTypesTreeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer arg0, Object arg1, Object arg2) {
            if (arg2 instanceof LayerDescriptor) {
                return !((LayerDescriptor) arg2).getCommons().isEmpty();
            } else {
                return true;
            }
        }
    });

    setControl(container);
    ((WizardDialog) getContainer()).addPageChangedListener(this);
}

From source file:com.aptana.ide.syncing.ui.old.views.SmartSyncViewer.java

License:Open Source License

private TreeViewer createContents(final Composite parent) {
    final TreeViewer viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
    viewer.setContentProvider(fContentProvider = new SmartSyncContentProvider());
    viewer.setLabelProvider(fLabelProvider = new SmartSyncLabelProvider(parent.getDisplay()));

    Tree tree = viewer.getTree();// w w  w  . j a  v a2 s.co  m
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    viewer.setAutoExpandLevel(2);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    fInitBackground = new Color(tree.getDisplay(), 175, 238, 238);
    fProgressBackground = new Color(tree.getDisplay(), 72, 209, 204);
    tree.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            fInitBackground.dispose();
            fProgressBackground.dispose();
        }

    });
    parent.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            setWidth(parent.getSize().x);
        }

    });

    // file column
    TreeColumn file = new TreeColumn(tree, SWT.LEFT);
    file.setWidth(250);
    file.setText(Messages.SmartSyncDialog_ColumnResources);
    file.setToolTipText(Messages.SmartSyncViewer_ColumnResourcesTooltip);

    // the column to specify whether the file should be skipped
    TreeColumn skip = new TreeColumn(tree, SWT.CENTER);
    skip.setWidth(40);
    skip.setText(Messages.SmartSyncDialog_ColumnSkip);
    skip.setToolTipText(Messages.SmartSyncViewer_ColumnSkipTooltip);

    // the state column on what will be done, if any, to the files from first end point
    fColumnEnd1 = new TreeColumn(tree, SWT.CENTER);
    fColumnEnd1.setWidth(125);

    // the state column on what will be done, if any, to the files from second end point
    fColumnEnd2 = new TreeColumn(tree, SWT.CENTER);
    fColumnEnd2.setWidth(125);

    Menu menu = new Menu(tree);
    fShowDiffs = new MenuItem(menu, SWT.PUSH);
    fShowDiffs.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (!viewer.getSelection().isEmpty() && viewer.getSelection() instanceof IStructuredSelection) {
                Object selection = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                if (selection instanceof SyncFile) {
                    SyncFile file = (SyncFile) selection;
                    if (file.getSyncState() == SyncState.ClientItemIsNewer
                            || file.getSyncState() == SyncState.ServerItemIsNewer) {
                        final VirtualFileSyncPair pair = file.getPair();
                        FileStoreCompareEditorInput input = new FileStoreCompareEditorInput(
                                new CompareConfiguration());
                        input.setLeftFileStore(pair.getSourceFile());
                        IFileStore destinationFile = pair.getDestinationFile();
                        String name = destinationFile.getName();
                        if (destinationFile instanceof IExtendedFileStore) {
                            // this is a remote file, so downloads to a local temp copy first for speed purpose
                            try {
                                File localFile = destinationFile.toLocalFile(EFS.CACHE, null);
                                destinationFile = EFS.getLocalFileSystem()
                                        .getStore(Path.fromOSString(localFile.getAbsolutePath()));
                            } catch (CoreException ce) {
                                // logs as warning since we will fall back to use the remote file store directly in
                                // this case
                                IdeLog.logWarning(SyncingUIPlugin.getDefault(), ce);
                            }
                        }
                        input.setRightFileStore(destinationFile, name);
                        input.initializeCompareConfiguration();
                        CompareUI.openCompareDialog(input);
                    }
                }
            }
        }
    });
    fShowDiffs.setImage(SyncingUIPlugin.getImage("icons/full/obj16/compare_view.gif")); //$NON-NLS-1$
    fShowDiffs.setText(Messages.SmartSyncDialog_ShowDiffs);
    fShowDiffs.setEnabled(true);
    tree.setMenu(menu);

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!viewer.getSelection().isEmpty() && viewer.getSelection() instanceof IStructuredSelection) {
                Object selection = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                if (selection instanceof SyncFile) {
                    SyncFile file = (SyncFile) selection;
                    if (file.getSyncState() == SyncState.ClientItemIsNewer
                            || file.getSyncState() == SyncState.ServerItemIsNewer) {
                        fShowDiffs.setEnabled(true);
                        return;
                    }
                }
            }
            fShowDiffs.setEnabled(false);
        }

    });
    viewer.setCellEditors(new CellEditor[] { null, new CheckboxCellEditor(), null, null });
    viewer.setColumnProperties(
            new String[] { Messages.SmartSyncDialog_ColumnName, Messages.SmartSyncDialog_ColumnSkip,
                    Messages.SmartSyncDialog_ColumnLocal, Messages.SmartSyncDialog_ColumnRemote });

    return viewer;
}

From source file:com.aptana.ide.syncing.ui.views.SmartSyncViewer.java

License:Open Source License

private TreeViewer createContents(final Composite parent) {
    final TreeViewer viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
    viewer.setContentProvider(fContentProvider = new SmartSyncContentProvider());
    viewer.setLabelProvider(fLabelProvider = new SmartSyncLabelProvider(parent.getDisplay()));

    Tree tree = viewer.getTree();/*from ww  w . ja  v a 2 s.com*/
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    viewer.setAutoExpandLevel(2);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    fInitBackground = new Color(tree.getDisplay(), 175, 238, 238);
    fProgressBackground = new Color(tree.getDisplay(), 72, 209, 204);
    tree.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            fInitBackground.dispose();
            fProgressBackground.dispose();
        }

    });
    parent.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            setWidth(parent.getSize().x);
        }

    });

    // file column
    TreeColumn file = new TreeColumn(tree, SWT.LEFT);
    file.setWidth(250);
    file.setText(Messages.SmartSyncDialog_ColumnResources);
    file.setToolTipText(Messages.SmartSyncViewer_ColumnResourcesTooltip);

    // the column to specify whether the file should be skipped
    TreeColumn skip = new TreeColumn(tree, SWT.CENTER);
    skip.setWidth(40);
    skip.setText(Messages.SmartSyncDialog_ColumnSkip);
    skip.setToolTipText(Messages.SmartSyncViewer_ColumnSkipTooltip);

    // the state column on what will be done, if any, to the files from first end point
    fColumnEnd1 = new TreeColumn(tree, SWT.CENTER);
    fColumnEnd1.setWidth(125);

    // the state column on what will be done, if any, to the files from second end point
    fColumnEnd2 = new TreeColumn(tree, SWT.CENTER);
    fColumnEnd2.setWidth(125);

    Menu menu = new Menu(tree);
    fShowDiffs = new MenuItem(menu, SWT.PUSH);
    fShowDiffs.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (!viewer.getSelection().isEmpty() && viewer.getSelection() instanceof IStructuredSelection) {
                Object selection = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                if (selection instanceof SyncFile) {
                    SyncFile file = (SyncFile) selection;
                    if (file.getSyncState() == SyncState.ClientItemIsNewer
                            || file.getSyncState() == SyncState.ServerItemIsNewer) {
                        final VirtualFileSyncPair pair = file.getPair();
                        File local = null;
                        try {
                            local = pair.getSourceFile().toLocalFile(EFS.CACHE, null);
                        } catch (CoreException ex) {
                            ex.printStackTrace();
                        }

                        FileCompareEditorInput input = new FileCompareEditorInput(new CompareConfiguration()) {
                            protected void prepareFiles() {
                                File temp = null;
                                try {
                                    temp = pair.getDestinationFile().toLocalFile(EFS.CACHE, null);
                                } catch (CoreException e) {
                                    e.printStackTrace();
                                }
                                setRightResource(temp);
                            }
                        };
                        input.setLeftResource(local);
                        CompareUI.openCompareDialog(input);
                    }
                }
            }
        }

    });
    fShowDiffs.setImage(SyncingUIPlugin.getImage("icons/full/obj16/compare_view.gif")); //$NON-NLS-1$
    fShowDiffs.setText(Messages.SmartSyncDialog_ShowDiffs);
    fShowDiffs.setEnabled(true);
    tree.setMenu(menu);

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!viewer.getSelection().isEmpty() && viewer.getSelection() instanceof IStructuredSelection) {
                Object selection = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                if (selection instanceof SyncFile) {
                    SyncFile file = (SyncFile) selection;
                    if (file.getSyncState() == SyncState.ClientItemIsNewer
                            || file.getSyncState() == SyncState.ServerItemIsNewer) {
                        fShowDiffs.setEnabled(true);
                        return;
                    }
                }
            }
            fShowDiffs.setEnabled(false);
        }

    });
    viewer.setCellEditors(new CellEditor[] { null, new CheckboxCellEditor(), null, null });
    viewer.setColumnProperties(
            new String[] { Messages.SmartSyncDialog_ColumnName, Messages.SmartSyncDialog_ColumnSkip,
                    Messages.SmartSyncDialog_ColumnLocal, Messages.SmartSyncDialog_ColumnRemote });

    return viewer;
}

From source file:com.clustercontrol.editor.BooleanPropertyDefine.java

License:Open Source License

/**
 * 
 */
public BooleanPropertyDefine() {
    m_cellEditor = new CheckboxCellEditor();

}

From source file:name.schedenig.eclipse.grepconsole.view.items.TristateEditingSupport.java

License:Open Source License

/**
 * Returns a checkbox editor in two state mode or a tristate editor in
 * tristate mode.//w w  w .  j  a  v a 2s. c o  m
 * 
 * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
 */
@Override
protected CellEditor getCellEditor(Object element) {
    return getInheritanceMap() == null ? new CheckboxCellEditor() : new TristateCellEditor();
}

From source file:org.eclipse.gmf.internal.bridge.wizards.pages.simple.DomainModelViewerFactory.java

License:Open Source License

public static TreeViewer createViewer(Tree tree, boolean withLabes) {
    TreeViewer viewer = new TreeViewer(tree);
    viewer.setContentProvider(new ResolverContentProvider());
    AdapterFactory adapterFactory = new EcoreItemProviderAdapterFactory();
    viewer.setLabelProvider(new ResolverLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)));
    if (withLabes) {
        viewer.setColumnProperties(new String[] { "no", P_NODE, P_LINK, P_LABEL }); //$NON-NLS-1$
        viewer.setCellEditors(new CellEditor[] { null, new CheckboxCellEditor(), new CheckboxCellEditor(),
                new CheckboxCellEditor() });
    } else {/*from  w  ww .j  a  v  a  2  s .c  o m*/
        viewer.setColumnProperties(new String[] { "no", P_NODE, P_LINK }); //$NON-NLS-1$
        viewer.setCellEditors(new CellEditor[] { null, new CheckboxCellEditor(), new CheckboxCellEditor() });
    }
    viewer.setCellModifier(new ResolverCellModifier(viewer, withLabes));
    return viewer;
}

From source file:org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection.java

License:Open Source License

@Override
protected void configureTableViewer(TableViewer viewer) {
    super.configureTableViewer(viewer);

    ColumnViewerToolTipSupport.enableFor(viewer);

    final Table table = viewer.getTable();

    if (viewer instanceof CheckboxTableViewer) {
        ((CheckboxTableViewer) viewer).setCheckStateProvider(new FileTransferCheckStateProvider());
        ((CheckboxTableViewer) viewer).addCheckStateListener(new ICheckStateListener() {
            @Override/*from   ww w.j a v  a 2  s .c  o m*/
            public void checkStateChanged(CheckStateChangedEvent event) {
                if (event.getElement() instanceof IFileTransferItem) {
                    IFileTransferItem item = (IFileTransferItem) event.getElement();
                    item.setProperty(IFileTransferItem.PROPERTY_ENABLED, event.getChecked());
                    getManagedForm().dirtyStateChanged();
                }
            }
        });
    }

    TableViewerColumn tvEnableCol = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn colEnable = tvEnableCol.getColumn();
    colEnable.setResizable(false);
    tvEnableCol.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            return null;
        }
    });

    TableViewerColumn tvHostCol = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn colHost = tvHostCol.getColumn();
    colHost.setText(Messages.FileTransferSection_host_column);
    colHost.setResizable(true);
    tvHostCol.setLabelProvider(new ColumnLabelProvider() {
        @SuppressWarnings("unchecked")
        @Override
        public String getToolTipText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                Map<String, String> invalid = (Map<String, String>) item
                        .getProperty(PROPERTY_VALIDATION_RESULT);
                if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
                    return invalid.get(IFileTransferItem.PROPERTY_HOST);
                }
                String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
                return host != null ? new Path(host).toOSString() : host;
            }
            return super.getText(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
                return host != null ? new Path(host).toOSString() : host;
            }
            return super.getText(element);
        }
    });

    TableViewerColumn tvDirCol = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn colDir = tvDirCol.getColumn();
    colDir.setResizable(false);
    colDir.setAlignment(SWT.CENTER);
    tvDirCol.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public String getToolTipText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
                case IFileTransferItem.TARGET_TO_HOST:
                    return Messages.FileTransferSection_toHost_tooltip;
                default:
                    return Messages.FileTransferSection_toTarget_tooltip;
                }
            }
            return super.getToolTipText(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
                case IFileTransferItem.TARGET_TO_HOST:
                    return Messages.FileTransferSection_toHost_text;
                default:
                    return Messages.FileTransferSection_toTarget_text;
                }
            }
            return super.getText(element);
        }
    });
    tvDirCol.setEditingSupport(new EditingSupport(tvDirCol.getViewer()) {
        @Override
        protected void setValue(Object element, Object value) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                item.setProperty(IFileTransferItem.PROPERTY_DIRECTION,
                        Boolean.parseBoolean(value.toString()) ? IFileTransferItem.HOST_TO_TARGET
                                : IFileTransferItem.TARGET_TO_HOST);
                getManagedForm().dirtyStateChanged();
                getViewer().refresh();
            }
        }

        @Override
        protected Object getValue(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                return Boolean.valueOf(item.getIntProperty(
                        IFileTransferItem.PROPERTY_DIRECTION) != IFileTransferItem.TARGET_TO_HOST);
            }
            return null;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            return new CheckboxCellEditor();
        }

        @Override
        protected boolean canEdit(Object element) {
            return true;
        }
    });

    TableViewerColumn tvTargetCol = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn colTarget = tvTargetCol.getColumn();
    colTarget.setText(Messages.FileTransferSection_target_column);
    colTarget.setResizable(true);
    tvTargetCol.setLabelProvider(new ColumnLabelProvider() {
        @SuppressWarnings("unchecked")
        @Override
        public String getToolTipText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                Map<String, String> invalid = (Map<String, String>) item
                        .getProperty(PROPERTY_VALIDATION_RESULT);
                if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET_STRING)) {
                    return invalid.get(IFileTransferItem.PROPERTY_TARGET_STRING);
                }
                return item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
            }
            return super.getText(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                return item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
            }
            return super.getText(element);
        }
    });

    TableViewerColumn tvOptionCol = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn colOption = tvOptionCol.getColumn();
    colOption.setText(Messages.FileTransferSection_options_column);
    colOption.setResizable(true);
    tvOptionCol.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public String getToolTipText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
            }
            return super.getText(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) element;
                return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
            }
            return super.getText(element);
        }
    });

    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(30, true));
    tableLayout.addColumnData(new ColumnPixelData(200, true));
    tableLayout.addColumnData(new ColumnPixelData(30, true));
    tableLayout.addColumnData(new ColumnPixelData(200, true));
    tableLayout.addColumnData(new ColumnPixelData(100, true));
    table.setLayout(tableLayout);
    GridData data = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
    table.setLayoutData(data);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    table.addListener(SWT.Resize, new Listener() {
        @Override
        public void handleEvent(Event event) {
            int width = table.getSize().x - 4 - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth()
                    - colTarget.getWidth();
            colOption.setWidth(Math.max(width, 100));
        }
    });
    colHost.addListener(SWT.Resize, new Listener() {
        @Override
        public void handleEvent(Event event) {
            int colWidth = colHost.getWidth();
            if (colWidth < 100) {
                event.doit = false;
                colHost.setWidth(100);
                colWidth = 100;
            }
            int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colDir.getWidth()
                    - colTarget.getWidth();
            colOption.setWidth(Math.max(width, 100));
        }
    });
    colTarget.addListener(SWT.Resize, new Listener() {
        @Override
        public void handleEvent(Event event) {
            int colWidth = colTarget.getWidth();
            if (colWidth < 100) {
                event.doit = false;
                colTarget.setWidth(100);
                colWidth = 100;
            }
            int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colHost.getWidth()
                    - colDir.getWidth();
            colOption.setWidth(Math.max(width, 100));
        }
    });

    @SuppressWarnings("unused")
    AbstractDecorationCellPaintListener cpl = new AbstractDecorationCellPaintListener(table, 1, 3) {
        @SuppressWarnings("unchecked")
        @Override
        protected int getDecorationState(Object data, int columnIndex) {
            if (data instanceof IFileTransferItem) {
                IFileTransferItem item = (IFileTransferItem) data;
                if (item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED)) {
                    Map<String, String> invalid = (Map<String, String>) item
                            .getProperty(PROPERTY_VALIDATION_RESULT);
                    if (invalid != null) {
                        switch (columnIndex) {
                        case 1:
                            if (invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
                                return STATE_ERROR;
                            }
                            break;
                        case 3:
                            if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET_STRING)) {
                                return STATE_ERROR;
                            }
                            break;
                        }
                    }
                }
            }
            return STATE_NONE;
        }
    };

    viewer.setContentProvider(new FileTransferContentProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            initializeButtonsEnablement();
        }
    });

    doCreateControlDecoration(table);
    configureControlDecoration(getControlDecoration());
}

From source file:org.libreoffice.ide.eclipse.core.wizards.pages.InterfacesTable.java

License:LGPL

/**
 * {@inheritDoc}/* w  w  w .  j  a va2  s.c  o  m*/
 */
@Override
protected CellEditor[] createCellEditors(Table pTable) {
    CellEditor[] editors = new CellEditor[] { new CheckboxCellEditor(), null };

    return editors;
}

From source file:org.objectstyle.wolips.eomodeler.editors.relationships.EORelationshipsTableViewer.java

License:Open Source License

public EORelationshipsTableViewer(Composite _parent, int _style) {
    super(_parent, _style);
    setLayout(new FillLayout());
    mySelectionListeners = new LinkedList<ISelectionChangedListener>();
    myRelationshipsTableViewer = TableUtils.createTableViewer(this, SWT.MULTI | SWT.FULL_SELECTION,
            "EORelationship", EORelationship.class.getName(), new EORelationshipsContentProvider(), null,
            new EORelationshipsViewerSorter(EORelationship.class.getName()));
    myRelationshipsTableViewer.setLabelProvider(
            new EORelationshipsLabelProvider(myRelationshipsTableViewer, EORelationship.class.getName()));
    new DoubleClickNewRelationshipHandler(myRelationshipsTableViewer).attach();
    myRelationshipsChangedRefresher = new TableRefreshPropertyListener("RelationshipsChanged",
            myRelationshipsTableViewer);
    myParentChangedRefresher = new TableRefreshPropertyListener("EntityParentChanged",
            myRelationshipsTableViewer);
    myTableRowRefresher = new TableRowRefreshPropertyListener(myRelationshipsTableViewer);

    Table relationshipsTable = myRelationshipsTableViewer.getTable();
    relationshipsTable.setLayoutData(new GridData(GridData.FILL_BOTH));

    TableColumn toManyColumn = TableUtils.getColumn(myRelationshipsTableViewer, EORelationship.class.getName(),
            EORelationship.TO_MANY);//  w  w w.jav a2 s.c om
    if (toManyColumn != null) {
        toManyColumn.setText("");
    }

    TableColumn classPropertyColumn = TableUtils.getColumn(myRelationshipsTableViewer,
            EORelationship.class.getName(), EORelationship.CLASS_PROPERTY);
    if (classPropertyColumn != null) {
        classPropertyColumn.setText("");
        classPropertyColumn
                .setImage(Activator.getDefault().getImageRegistry().get(Activator.CLASS_PROPERTY_ICON));
    }

    TableColumn allowNullColumn = TableUtils.getColumn(myRelationshipsTableViewer,
            EORelationship.class.getName(), EORelationship.OPTIONAL);
    if (allowNullColumn != null) {
        allowNullColumn.setText("");
        allowNullColumn.setImage(Activator.getDefault().getImageRegistry().get(Activator.ALLOW_NULL_ICON));
        //allowNullColumn.setAlignment(SWT.CENTER);
    }

    TableUtils.sort(myRelationshipsTableViewer, EORelationship.NAME);

    CellEditor[] cellEditors = new CellEditor[TableUtils
            .getColumnsForTableNamed(EORelationship.class.getName()).length];
    TableUtils.setCellEditor(EORelationship.class.getName(), EORelationship.TO_MANY, new CheckboxCellEditor(),
            cellEditors);
    TableUtils.setCellEditor(EORelationship.class.getName(), EORelationship.CLASS_PROPERTY,
            new CheckboxCellEditor(), cellEditors);
    TableUtils.setCellEditor(EORelationship.class.getName(), EORelationship.OPTIONAL, new CheckboxCellEditor(),
            cellEditors);
    TableUtils.setCellEditor(EORelationship.class.getName(), EORelationship.NAME,
            new WOTextCellEditor(relationshipsTable), cellEditors);
    myRelationshipsTableViewer.setCellModifier(new EORelationshipsCellModifier(myRelationshipsTableViewer));
    myRelationshipsTableViewer.setCellEditors(cellEditors);

    new StayEditingCellEditorListener(myRelationshipsTableViewer, EORelationship.class.getName(),
            EORelationship.NAME);
}

From source file:org.opaeum.runtime.jface.editingsupport.CheckboxEditingSupport.java

License:Open Source License

@Override
protected CellEditor getCellEditor(Object element) {
    return new CheckboxCellEditor();
}