Search in sources :

Example 46 with CheckStateChangedEvent

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

the class RuleSetSelectionDialog method setupRuleTable.

private void setupRuleTable() {
    Table tbl = ruleTable.getTable();
    tbl.setLinesVisible(true);
    tbl.setHeaderVisible(true);
    ruleTable.setContentProvider(new AbstractStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            RuleSet rs = selectedRuleset();
            return rs == null ? new Object[0] : rs.getRules().toArray();
        }
    });
    ruleTable.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            ruleChecked();
        }
    });
    createCheckBoxColumn(tbl);
    for (int i = 0; i < columns.length; i++) {
        columns[i].newTableColumnFor(tbl, i + 1, null, null);
    }
    ruleTable.setLabelProvider(new RuleLabelProvider(columns));
}
Also used : RuleSet(net.sourceforge.pmd.RuleSet) Table(org.eclipse.swt.widgets.Table) RuleLabelProvider(net.sourceforge.pmd.eclipse.ui.preferences.br.RuleLabelProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 47 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project Pydev by fabioz.

the class GeneratePropertiesPage method createTreeViewer.

private void createTreeViewer(Composite treeComp) {
    treeViewer = new ContainerCheckedTreeViewer(treeComp);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            getRequestProcsseor().setCheckedElements(treeViewer.getCheckedElements());
            GeneratePropertiesPage.this.getWizard().getContainer().updateButtons();
        }
    });
    treeViewer.setContentProvider(classProvider);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setAutoExpandLevel(2);
    treeViewer.setInput("");
    treeViewer.setSelection(new StructuredSelection(treeViewer.getExpandedElements()[0]));
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 48 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project Pydev by fabioz.

the class ConstructorFieldPage method createTreeViewer.

private void createTreeViewer(Composite treeComp) {
    treeViewer = new ContainerCheckedTreeViewer(treeComp);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            getRequestProcessor().setCheckedElements(treeViewer.getCheckedElements());
            ConstructorFieldPage.this.getWizard().getContainer().updateButtons();
        }
    });
    treeViewer.setContentProvider(classProvider);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setAutoExpandLevel(2);
    treeViewer.setInput("");
    treeViewer.setSelection(new StructuredSelection(treeViewer.getExpandedElements()[0]));
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 49 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project Pydev by fabioz.

the class PyEditorHoverConfigurationBlock method createControl.

/**
 * Creates page for hover preferences.
 *
 * @param parent the parent composite
 * @return the control for the preference page
 */
@Override
public Control createControl(final Composite parent) {
    priorityHelpRange = new StyleRange(PyEditorMessages.PyEditorHoverConfigurationBlock_hoverPreferences.length(), priorityHelpStr.length(), parent.getDisplay().getSystemColor(SWT.COLOR_BLUE), null);
    fComp = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(fComp);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(fComp);
    fButtonComp = new Composite(fComp, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fButtonComp);
    fUseFirstHover = new Button(fButtonComp, SWT.RADIO | SWT.BORDER);
    fUseFirstHover.setText("Use highest priority Hover");
    GridDataFactory.fillDefaults().applyTo(fUseFirstHover);
    fCombineHovers = new Button(fButtonComp, SWT.RADIO | SWT.BORDER);
    fCombineHovers.setText("Combine Hovers");
    GridDataFactory.fillDefaults().applyTo(fCombineHovers);
    fCombineHovers.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fCombiningHoverModifierEditor.setEnabled(fCombineHovers.getSelection());
            fCombiningHoverLabel.setEnabled(fCombineHovers.getSelection());
            showColumn(fPreemptColumn, fCombineHovers.getSelection());
            showColumn(fModifierColumn, !fCombineHovers.getSelection());
            fModifierFieldLabel.setEnabled(!fCombineHovers.getSelection());
        }
    });
    fCombiningHoverLabel = new Label(fComp, SWT.PUSH);
    fCombiningHoverLabel.setText("Combined Hovers Key Modifier:");
    fCombiningHoverModifierEditor = new Text(fComp, SWT.BORDER);
    fCombiningHoverModifierEditor.addKeyListener(new KeyModifierListener(fCombiningHoverModifierEditor));
    fCombiningHoverModifierEditor.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            handleModifierModified(fCombiningHoverModifierEditor);
        }
    });
    GridDataFactory.fillDefaults().grab(true, false).applyTo(fCombiningHoverModifierEditor);
    ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    Composite hoverComposite = new Composite(scrolled, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    hoverComposite.setLayout(layout);
    addFiller(hoverComposite);
    fTableLabel = new StyledText(hoverComposite, SWT.NONE);
    fTableLabel.setEditable(false);
    fTableLabel.setEnabled(false);
    fTableLabel.setBackground(fTableLabel.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    fTableLabel.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_hoverPreferences);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    fTableLabel.setLayoutData(gd);
    TableLayoutComposite layouter = new TableLayoutComposite(hoverComposite, SWT.NONE);
    addColumnLayoutData(layouter, fColWidths);
    // Hover table
    fHoverTable = new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK);
    fHoverTable.setHeaderVisible(true);
    fHoverTable.setLinesVisible(true);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = SWTUtil.getTableHeightHint(fHoverTable, 10);
    gd.horizontalSpan = 2;
    gd.widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(100);
    layouter.setLayoutData(gd);
    fHoverTable.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    TableLayout tableLayout = new TableLayout();
    fHoverTable.setLayout(tableLayout);
    fHoverTableViewer = new CheckboxTableViewer(fHoverTable);
    TableViewerColumn nameColumnViewer = new TableViewerColumn(fHoverTableViewer, SWT.NONE);
    nameColumnViewer.setLabelProvider(new PyEditorTextHoverDescriptorLabelProvider(fHoverTableViewer));
    fNameColumn = nameColumnViewer.getColumn();
    fNameColumn.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_nameColumnTitle);
    fNameColumn.setResizable(true);
    TableViewerColumn priorityViewerColumn = new TableViewerColumn(fHoverTableViewer, SWT.NONE);
    priorityViewerColumn.setEditingSupport(new HoverTableEditingSupport(fHoverTableViewer, PRIORITY_PROP));
    priorityViewerColumn.setLabelProvider(new PyEditorTextHoverDescriptorLabelProvider(fHoverTableViewer));
    fPriorityColumn = priorityViewerColumn.getColumn();
    fPriorityColumn.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_priorityColumnTitle);
    fPriorityColumn.setResizable(true);
    TableViewerColumn modifierColumnViewer = new TableViewerColumn(fHoverTableViewer, SWT.NONE);
    modifierColumnViewer.setLabelProvider(new PyEditorTextHoverDescriptorLabelProvider(fHoverTableViewer));
    fModifierColumn = modifierColumnViewer.getColumn();
    fModifierColumn.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_modifierColumnTitle);
    fModifierColumn.setResizable(true);
    TableViewerColumn preemptViewerColumn = new TableViewerColumn(fHoverTableViewer, SWT.NONE);
    preemptViewerColumn.setEditingSupport(new HoverTableEditingSupport(fHoverTableViewer, PREEMPT_PROP));
    preemptViewerColumn.setLabelProvider(new PyEditorTextHoverDescriptorLabelProvider(fHoverTableViewer));
    fPreemptColumn = preemptViewerColumn.getColumn();
    fPreemptColumn.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_preemptColumnTitle);
    fPreemptColumn.setResizable(true);
    fHoverTableViewer.setUseHashlookup(true);
    fHoverTableViewer.setContentProvider(new PyEditorTextHoverDescriptorContentProvider());
    fHoverTableViewer.addCheckStateListener(new ICheckStateListener() {

        /*
             * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.Che((CheckboxTreeViewer) fHoverTableViewer)nt)
             */
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            String id = ((PyEditorTextHoverDescriptor) event.getElement()).getId();
            if (id == null) {
                return;
            }
            PyEditorTextHoverDescriptor[] descriptors = fHoverDescs;
            PyEditorTextHoverDescriptor hover = null;
            int i = 0, length = fHoverDescs.length;
            while (i < length) {
                if (id.equals(descriptors[i].getId())) {
                    hover = fHoverDescs[i];
                    hover.setIsEnabled(event.getChecked());
                    fModifierEditor.setEnabled(event.getChecked());
                    fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
                }
                i++;
            }
            handleHoverListSelection();
            updateStatus(hover);
        }
    });
    fHoverTableViewer.setSorter(new ViewerSorter() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((PyEditorTextHoverDescriptor) e1).getPriority().compareTo(((PyEditorTextHoverDescriptor) e2).getPriority());
        }
    });
    // Text field for modifier string
    fModifierFieldLabel = new Label(hoverComposite, SWT.LEFT);
    fModifierFieldLabel.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_keyModifier);
    fModifierEditor = new Text(hoverComposite, SWT.BORDER);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    fModifierEditor.setLayoutData(gd);
    fModifierEditor.addKeyListener(new KeyModifierListener(fModifierEditor));
    fModifierEditor.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            handleModifierModified(fModifierEditor);
        }
    });
    // Description
    Label label = new Label(hoverComposite, SWT.LEFT);
    label.setText(PyEditorMessages.PyEditorHoverConfigurationBlock_description);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    fDescription = new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
    SWTUtil.fixReadonlyTextBackground(fDescription);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    fDescription.setLayoutData(gd);
    fDebugShowVars = new Button(parent, SWT.CHECK);
    fDebugShowVars.setText("Show variables values while debugging");
    fDebugShowVars.setSelection(PyHoverPreferencesPage.getShowValuesWhileDebuggingOnHover());
    fUseHoverDivider = new Button(parent, SWT.CHECK);
    fUseHoverDivider.setText("Add divider between contributions when combining hovers");
    fUseHoverDivider.setSelection(PyHoverPreferencesPage.getUseHoverDelimiters());
    scrolled.setContent(hoverComposite);
    final Point size = hoverComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrolled.setMinSize(size.x, size.y);
    Dialog.applyDialogFont(scrolled);
    return fComp;
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) TableLayoutComposite(org.python.pydev.ui.TableLayoutComposite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) StyleRange(org.eclipse.swt.custom.StyleRange) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) ColumnViewer(org.eclipse.jface.viewers.ColumnViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Viewer(org.eclipse.jface.viewers.Viewer) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) ScrolledPageContent(org.python.pydev.ui.ScrolledPageContent) StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableLayoutComposite(org.python.pydev.ui.TableLayoutComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 50 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project Pydev by fabioz.

the class PyConfigureExceptionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // page group
    Composite composite = (Composite) super.createDialogArea(parent);
    initializeDialogUnits(composite);
    createMessageArea(composite);
    listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    listViewer.getTable().setLayoutData(data);
    listViewer.setLabelProvider(labelProvider);
    listViewer.setContentProvider(contentProvider);
    createSelectionButtons(composite);
    initContent();
    // initialize page
    if (!getInitialElementSelections().isEmpty()) {
        checkInitialSelections();
    }
    Dialog.applyDialogFont(composite);
    getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (getCheckBoxTableViewer().getChecked(element)) {
                addToSelectedElements(element);
            }
            return matchExceptionToShowInList(element);
        }
    });
    getCheckBoxTableViewer().addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                addToSelectedElements(event.getElement());
            } else {
                removeFromSelectedElements(event.getElement());
            }
        }
    });
    createCustomExceptionUI(composite);
    createDealingWithExceptionsOptions(composite);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)131 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)128 GridData (org.eclipse.swt.layout.GridData)87 Composite (org.eclipse.swt.widgets.Composite)66 GridLayout (org.eclipse.swt.layout.GridLayout)59 SelectionEvent (org.eclipse.swt.events.SelectionEvent)55 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)44 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)44 Button (org.eclipse.swt.widgets.Button)43 Label (org.eclipse.swt.widgets.Label)39 Table (org.eclipse.swt.widgets.Table)29 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)28 Viewer (org.eclipse.jface.viewers.Viewer)28 TableColumn (org.eclipse.swt.widgets.TableColumn)22 ArrayList (java.util.ArrayList)21 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 Text (org.eclipse.swt.widgets.Text)18 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)17