Search in sources :

Example 56 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project convertigo by convertigo.

the class MobilePickerComposite method makeUI.

private void makeUI(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    parent.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    SelectionListener listener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final MobilePickerContentProvider contentProvider = (MobilePickerContentProvider) checkboxTreeViewer.getContentProvider();
            if (contentProvider != null) {
                btnSequence.setSelection(false);
                btnDatabase.setSelection(false);
                btnAction.setSelection(false);
                btnShared.setSelection(false);
                btnIteration.setSelection(false);
                btnForm.setSelection(false);
                btnGlobal.setSelection(false);
                ToolItem button = (ToolItem) e.widget;
                button.setSelection(true);
                if (btnSequence.getSelection()) {
                    contentProvider.setFilterBy(Filter.Sequence);
                } else if (btnDatabase.getSelection()) {
                    contentProvider.setFilterBy(Filter.Database);
                } else if (btnAction.getSelection()) {
                    contentProvider.setFilterBy(Filter.Action);
                } else if (btnShared.getSelection()) {
                    contentProvider.setFilterBy(Filter.Shared);
                } else if (btnIteration.getSelection()) {
                    contentProvider.setFilterBy(Filter.Iteration);
                } else if (btnForm.getSelection()) {
                    contentProvider.setFilterBy(Filter.Form);
                } else if (btnGlobal.getSelection()) {
                    contentProvider.setFilterBy(Filter.Global);
                }
                modelTreeViewer.setInput(null);
                checkboxTreeViewer.getTree().removeAll();
                checkboxTreeViewer.refresh();
                initTreeSelection(checkboxTreeViewer, null);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
    SelectionListener c_listener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean isCustom = b_custom.getSelection();
            boolean doSetCustomText = false;
            if (isParentDialog) {
                MobileSmartSource cs = MobileSmartSource.valueOf(currentSource);
                if (cs != null && cs.getModel() != null && cs.getModel().getCustom().isEmpty()) {
                    doSetCustomText = true;
                }
            } else {
                doSetCustomText = true;
            }
            if (doSetCustomText) {
                MobileSmartSource nmss = MobileSmartSource.valueOf(getSmartSourceString());
                if (nmss != null) {
                    if (isCustom && !t_custom.getEnabled()) {
                        t_custom.setText(nmss.getModel().computeValue());
                    }
                    if (!isCustom && t_custom.getEnabled()) {
                        t_custom.setText("");
                    }
                }
            }
            t_custom.setEnabled(isCustom);
            t_prefix.setEnabled(!isCustom);
            t_data.setEnabled(!isCustom);
            t_suffix.setEnabled(!isCustom);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
    headerComposite = new Composite(parent, SWT.NONE);
    headerComposite.setLayout(SwtUtils.newGridLayout(2, false, 0, 0, 0, 0));
    headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1));
    ToolBar toolbar = new ToolBar(headerComposite, SWT.NONE);
    int btnStyle = SWT.CHECK;
    Image image = null;
    btnSequence = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/core/images/sequence_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnSequence.setText("SQ");
    }
    btnSequence.setImage(image);
    btnSequence.setToolTipText("Show Sequence Sources");
    btnSequence.addSelectionListener(listener);
    btnSequence.setSelection(true);
    btnDatabase = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/connectors/images/fullsyncconnector_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnDatabase.setText("FS");
    }
    btnDatabase.setImage(image);
    btnDatabase.setToolTipText("Show FullSync Databases Sources");
    btnDatabase.addSelectionListener(listener);
    btnAction = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/mobile/components/images/uicustomaction_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnAction.setText("AC");
    }
    btnAction.setImage(image);
    btnAction.setToolTipText("Show Action Sources");
    btnAction.addSelectionListener(listener);
    btnShared = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/mobile/components/images/uisharedcomponent_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnShared.setText("SH");
    }
    btnShared.setImage(image);
    btnShared.setToolTipText("Show Shared component Sources");
    btnShared.addSelectionListener(listener);
    btnIteration = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/steps/images/iterator_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnIteration.setText("IT");
    }
    btnIteration.setImage(image);
    btnIteration.setToolTipText("Show Iterators on current page Sources");
    btnIteration.addSelectionListener(listener);
    btnForm = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/mobile/components/images/uiform_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnForm.setText("FM");
    }
    btnForm.setImage(image);
    btnForm.setToolTipText("Show Forms on current page Sources");
    btnForm.addSelectionListener(listener);
    btnGlobal = new ToolItem(toolbar, btnStyle);
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/mobile/components/dynamic/images/setglobalaction_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
    } catch (Exception e) {
        btnGlobal.setText("GS");
    }
    btnGlobal.setImage(image);
    btnGlobal.setToolTipText("Show Global Shared objects");
    btnGlobal.addSelectionListener(listener);
    message = new Label(headerComposite, SWT.NONE);
    message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    SashForm treesSashForm = new SashForm(parent, SWT.NONE);
    treesSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    checkboxTreeViewer = new CheckboxTreeViewer(treesSashForm, SWT.BORDER | SWT.SINGLE);
    checkboxTreeViewer.setContentProvider(new MobilePickerContentProvider());
    checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof TVObject) {
                if (btnIteration.getSelection() || btnForm.getSelection() || btnGlobal.getSelection()) {
                    checkboxTreeViewer.setChecked(element, !event.getChecked());
                    return;
                }
                TVObject tvoChecked = (TVObject) element;
                if (event.getChecked())
                    checkedList.add(tvoChecked);
                else
                    checkedList.remove(tvoChecked);
                updateGrayChecked();
                updateTexts();
            }
        }
    });
    checkboxTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (selected instanceof TVObject && !selected.equals(lastSelected)) {
                TVObject tvoSelected = (TVObject) selected;
                lastSelected = selected;
                if (firstSelected == null) {
                    firstSelected = selected;
                }
                checkedList.clear();
                checkedList.add(tvoSelected);
                modelTreeViewer.setInput(null);
                updateModel(tvoSelected);
                updateGrayChecked();
                updateTexts();
            }
        }
    });
    modelTreeViewer = new TreeViewer(treesSashForm, SWT.BORDER);
    modelTreeViewer.setContentProvider(new MobilePickerContentProvider());
    modelTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (selected instanceof TVObject) {
                updateTexts();
            }
        }
    });
    treesSashForm.setWeights(new int[] { 1, 1 });
    Composite sourceComposite = new Composite(parent, SWT.NONE);
    sourceComposite.setLayout(new GridLayout(2, false));
    sourceComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    if (isParentDialog) {
        l_source = new Label(sourceComposite, SWT.NONE);
        ((Label) l_source).setText(" SOURCE ");
    } else {
        l_source = new Button(sourceComposite, SWT.NONE);
        ((Button) l_source).setText(" SOURCE ");
        l_source.setToolTipText("Drag me on a Mobile UI component in the project tree to bind this source to an UI component property");
    }
    Composite dataComposite = new Composite(sourceComposite, SWT.NONE);
    dataComposite.setLayout(new GridLayout(2, false));
    dataComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label l_prefix = new Label(dataComposite, SWT.NONE);
    l_prefix.setText("Prefix");
    t_prefix = new Text(dataComposite, SWT.BORDER);
    t_prefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label l_data = new Label(dataComposite, SWT.NONE);
    l_data.setText("Data");
    t_data = new Text(dataComposite, SWT.BORDER | SWT.READ_ONLY);
    t_data.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label l_suffix = new Label(dataComposite, SWT.NONE);
    l_suffix.setText("Suffix");
    t_suffix = new Text(dataComposite, SWT.BORDER);
    t_suffix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    b_custom = new Button(dataComposite, SWT.CHECK);
    b_custom.setText("Custom");
    b_custom.addSelectionListener(c_listener);
    t_custom = new Text(dataComposite, SWT.BORDER);
    t_custom.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    t_custom.setEnabled(false);
    // Add DND support
    boolean dragEnabled = !isParentDialog;
    if (dragEnabled) {
        Transfer[] dragTransfers = new Transfer[] { MobileSourceTransfer.getInstance() };
        int operations = DND.DROP_COPY | DND.DROP_MOVE;
        DragSourceAdapter dragAdapter = new DragSourceAdapter() {

            @Override
            public void dragStart(DragSourceEvent event) {
                try {
                    String jsonString = getSmartSourceString();
                    if (jsonString != null && !jsonString.isEmpty()) {
                        event.doit = true;
                        MobileSourceTransfer.getInstance().setMobileSource(new MobileSource(jsonString));
                    }
                } catch (Exception e) {
                    ConvertigoPlugin.logException(e, "Cannot drag");
                }
            }
        };
        DragSource source = null;
        source = new DragSource(modelTreeViewer.getTree(), operations);
        source.setTransfer(dragTransfers);
        source.addDragListener(dragAdapter);
        source = new DragSource(l_source, operations);
        source.setTransfer(dragTransfers);
        source.addDragListener(dragAdapter);
    }
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) DragSource(org.eclipse.swt.dnd.DragSource) MobileSource(com.twinsoft.convertigo.eclipse.dnd.MobileSource) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) SashForm(org.eclipse.swt.custom.SashForm) MobileSmartSource(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) Transfer(org.eclipse.swt.dnd.Transfer) MobileSourceTransfer(com.twinsoft.convertigo.eclipse.dnd.MobileSourceTransfer) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 57 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project knime-workbench by knime.

the class WorkflowExportPage method createTreeViewer.

private void createTreeViewer(final Composite parent) {
    final Group group = new Group(parent, SWT.V_SCROLL);
    final GridLayout gridLayout1 = new GridLayout(1, false);
    group.setLayout(gridLayout1);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    m_treeViewer = new CheckboxTreeViewer(group);
    m_treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    // provider handling file stores
    m_provider = new ExplorerFileStoreProvider();
    m_treeViewer.setContentProvider(m_provider);
    m_treeViewer.setLabelProvider(m_provider);
    m_treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            Object o = event.getElement();
            boolean isChecked = event.getChecked();
            m_treeViewer.setSubtreeChecked(o, isChecked);
            if (o instanceof AbstractExplorerFileStore) {
                AbstractExplorerFileStore sel = (AbstractExplorerFileStore) o;
                setParentTreeChecked(sel, isChecked);
            }
            dialogChanged();
        }
    });
    Composite buttons = new Composite(group, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    buttons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    m_selAll = new Button(buttons, SWT.PUSH);
    m_selAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    m_selAll.setText("Select All");
    m_selAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectAll();
        }
    });
    m_deselAll = new Button(buttons, SWT.PUSH);
    m_deselAll.setText("Deselect all");
    m_deselAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    m_deselAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            deselectAll();
        }
    });
    m_treeViewer.getTree().setVisible(false);
    m_selAll.setVisible(false);
    m_deselAll.setVisible(false);
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ContentObject(org.knime.workbench.explorer.view.ContentObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 58 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project knime-workbench by knime.

the class WorkflowImportSelectionPage method createWorkflowListComposite.

/**
 * @param parent parent composite
 * @return the lower part of the workflow selection page, the list with selected workflows to import
 */
protected Composite createWorkflowListComposite(final Composite parent) {
    Group overall = new Group(parent, SWT.FILL);
    overall.setText("Import Elements:");
    overall.setLayoutData(FILL_BOTH);
    overall.setLayout(new GridLayout(2, false));
    // list with checkboxes....
    m_workflowListUI = new CheckboxTreeViewer(overall);
    m_workflowListUI.getTree().setLayoutData(FILL_BOTH);
    m_workflowListUI.setContentProvider(new ITreeContentProvider() {

        @Override
        public Object[] getChildren(final Object parentElement) {
            if (parentElement instanceof IWorkflowImportElement) {
                ArrayList<IWorkflowImportElement> display = new ArrayList();
                Collection<IWorkflowImportElement> children = ((IWorkflowImportElement) parentElement).getChildren();
                for (IWorkflowImportElement ch : children) {
                    // don't show knime/hidden files
                    if (!ch.getName().equals(WorkflowPersistor.METAINFO_FILE) && !ch.getName().startsWith(".")) {
                        display.add(ch);
                    }
                }
                m_displayImports.addAll(display);
                return display.toArray(new IWorkflowImportElement[display.size()]);
            }
            return new Object[0];
        }

        @Override
        public Object getParent(final Object element) {
            if (element instanceof IWorkflowImportElement) {
                return ((IWorkflowImportElement) element).getParent();
            }
            return null;
        }

        @Override
        public boolean hasChildren(final Object element) {
            if (element instanceof IWorkflowImportElement) {
                return ((IWorkflowImportElement) element).getChildren().size() > 0;
            }
            return false;
        }

        @Override
        public Object[] getElements(final Object inputElement) {
            return getChildren(inputElement);
        }

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
        // should never happen
        }
    });
    m_workflowListUI.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IWorkflowImportElement) {
                IWorkflowImportElement wf = (IWorkflowImportElement) element;
                return wf.getName();
            }
            return element.toString();
        }

        @Override
        public Image getImage(final Object element) {
            if (element instanceof IWorkflowImportElement) {
                IWorkflowImportElement wf = (IWorkflowImportElement) element;
                // display invalid ones differently
                if (wf.isInvalid()) {
                    return IMG_WARN;
                } else if (wf.isWorkflow()) {
                    return ImageRepository.getIconImage(SharedImages.Workflow);
                } else if (wf.isWorkflowGroup()) {
                    return ImageRepository.getIconImage(SharedImages.WorkflowGroup);
                } else if (wf.isTemplate()) {
                    return ImageRepository.getIconImage(SharedImages.MetaNodeTemplate);
                } else if (wf.isFile()) {
                    return ImageRepository.getIconImage(SharedImages.File);
                }
            }
            return super.getImage(element);
        }
    });
    m_workflowListUI.setInput(m_importRoot);
    m_workflowListUI.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            Object o = event.getElement();
            boolean isChecked = event.getChecked();
            m_workflowListUI.setSubtreeChecked(o, isChecked);
            if (o instanceof IWorkflowImportElement) {
                IWorkflowImportElement element = (IWorkflowImportElement) o;
                setParentTreeChecked(m_workflowListUI, element, isChecked);
            }
            validateWorkflows();
        }
    });
    // and 3 buttons -> panel in second column
    GridData rightAlign = new GridData();
    rightAlign.horizontalAlignment = SWT.RIGHT;
    rightAlign.verticalAlignment = SWT.BEGINNING;
    Composite buttonPanel = new Composite(overall, SWT.NONE);
    buttonPanel.setLayout(new GridLayout(1, false));
    buttonPanel.setLayoutData(rightAlign);
    // select all
    Button selectAllBtn = new Button(buttonPanel, SWT.PUSH);
    selectAllBtn.setText("Select All");
    selectAllBtn.setLayoutData(m_btnData);
    selectAllBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (m_importRoot != null) {
                m_workflowListUI.expandAll();
                m_workflowListUI.setAllChecked(true);
                validateWorkflows();
            }
        }
    });
    // deselect all
    Button deselectAllBtn = new Button(buttonPanel, SWT.PUSH);
    deselectAllBtn.setText("Deselect All");
    deselectAllBtn.setLayoutData(m_btnData);
    deselectAllBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (m_importRoot != null) {
                m_workflowListUI.expandAll();
                m_workflowListUI.setAllChecked(false);
                validateWorkflows();
            }
        }
    });
    if (m_presetZipLocation && StringUtils.isNotEmpty(initialZipLocation)) {
        handleSelectedZipFileChange(initialZipLocation);
    }
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ArrayList(java.util.ArrayList) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Image(org.eclipse.swt.graphics.Image) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Collection(java.util.Collection) ContentObject(org.knime.workbench.explorer.view.ContentObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 59 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project windup-eclipse-plugin by windup.

the class WindupReportExportWizardPage1 method createResourcesGroup.

/**
 * Creates the checkbox tree and list for selecting resources.
 *
 * @param parent the parent control
 */
private final void createResourcesGroup(Composite parent) {
    this.resourceGroup = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    this.resourceGroup.getTable().setLayoutData(data);
    this.resourceGroup.setLabelProvider(new WorkbenchLabelProvider());
    this.resourceGroup.setContentProvider(new BaseWorkbenchContentProvider());
    this.resourceGroup.setInput(ResourcesPlugin.getWorkspace().getRoot());
    ICheckStateListener listener = new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateWidgetEnablements();
        }
    };
    this.resourceGroup.addCheckStateListener(listener);
    // select the selected projects when the wizard was launched
    List<IProject> selectedProjects = Utils.getSelectedProjects(this.initialResourceSelection);
    this.resourceGroup.setCheckedElements(selectedProjects.toArray());
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IProject(org.eclipse.core.resources.IProject)

Example 60 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project spotbugs by spotbugs.

the class DetectorConfigurationTab method createDetectorsTableViewer.

/**
 * Build rule table viewer
 */
private Table createDetectorsTableViewer(Composite parent, IProject project) {
    final BugPatternTableSorter sorter = new BugPatternTableSorter(this);
    int tableStyle = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK;
    availableFactoriesTableViewer = CheckboxTableViewer.newCheckList(parent, tableStyle);
    availableFactoriesTableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            syncUserPreferencesWithTable();
        }
    });
    int currentColumnIdx = 0;
    Table factoriesTable = availableFactoriesTableViewer.getTable();
    TableColumn factoryNameColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.detectorName"), 230, COLUMN.DETECTOR_NAME);
    addColumnSelectionListener(sorter, factoryNameColumn, COLUMN.DETECTOR_NAME);
    currentColumnIdx++;
    TableColumn bugsAbbrevColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.bugCodes"), 75, COLUMN.BUG_CODES);
    addColumnSelectionListener(sorter, bugsAbbrevColumn, COLUMN.BUG_CODES);
    currentColumnIdx++;
    TableColumn speedColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.speed"), 70, COLUMN.DETECTOR_SPEED);
    addColumnSelectionListener(sorter, speedColumn, COLUMN.DETECTOR_SPEED);
    currentColumnIdx++;
    TableColumn pluginColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.provider"), 100, COLUMN.PLUGIN);
    addColumnSelectionListener(sorter, pluginColumn, COLUMN.PLUGIN);
    currentColumnIdx++;
    TableColumn categoryColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.category"), 75, COLUMN.BUG_CATEGORIES);
    addColumnSelectionListener(sorter, categoryColumn, COLUMN.BUG_CATEGORIES);
    factoriesTable.setLinesVisible(true);
    factoriesTable.setHeaderVisible(true);
    // initial sort indicator
    factoriesTable.setSortDirection(sorter.revertOrder ? SWT.UP : SWT.DOWN);
    factoriesTable.setSortColumn(factoryNameColumn);
    sorter.setSortColumnIndex(COLUMN.DETECTOR_NAME);
    availableFactoriesTableViewer.setContentProvider(new DetectorFactoriesContentProvider());
    availableFactoriesTableViewer.setLabelProvider(new DetectorFactoryLabelProvider(this));
    availableFactoriesTableViewer.setSorter(sorter);
    populateAvailableRulesTable(project);
    factoriesTable.setEnabled(true);
    return factoriesTable;
}
Also used : Table(org.eclipse.swt.widgets.Table) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)136 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)133 GridData (org.eclipse.swt.layout.GridData)89 Composite (org.eclipse.swt.widgets.Composite)68 GridLayout (org.eclipse.swt.layout.GridLayout)61 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)45 Button (org.eclipse.swt.widgets.Button)43 Label (org.eclipse.swt.widgets.Label)42 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)31 Table (org.eclipse.swt.widgets.Table)30 Viewer (org.eclipse.jface.viewers.Viewer)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)26 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)26 TableColumn (org.eclipse.swt.widgets.TableColumn)23 ArrayList (java.util.ArrayList)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 Text (org.eclipse.swt.widgets.Text)18 List (java.util.List)16