Example usage for org.eclipse.jface.dialogs IDialogConstants SELECT_ALL_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants SELECT_ALL_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants SELECT_ALL_ID.

Prototype

int SELECT_ALL_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants SELECT_ALL_ID.

Click Source Link

Document

Button id for a "Select All" button (value 18).

Usage

From source file:org.eclipse.ice.viz.service.widgets.TreeSelectionDialogProvider.java

License:Open Source License

/**
 * Creates a dialog used to select <i>multiple</i> values from the input
 * tree./*from   ww w . j  a v  a 2 s  . co  m*/
 * 
 * @param shell
 *            The parent shell for the dialog.
 * @param labelProvider
 *            The label provider for the tree.
 * @param contentProvider
 *            The content provider for the tree.
 * @return The new dialog.
 */
private CheckedTreeSelectionDialog createCheckedTreeSelectionDialog(Shell shell, ILabelProvider labelProvider,
        ITreeContentProvider contentProvider) {

    // Create a custom check-state listener to update the selected elements
    // on the fly.
    final ICheckStateListener checkStateListener = createCheckStateListener();

    CheckedTreeSelectionDialog treeDialog = new CheckedTreeSelectionDialog(shell, labelProvider,
            contentProvider) {
        /*
         * Overrides a method from CheckedTreeSelectionDialog.
         */
        @Override
        protected Composite createSelectionButtons(Composite composite) {
            Composite buttonComposite = super.createSelectionButtons(composite);

            // Add listeners to the select-all and deselect-all buttons
            // because they do not trigger the check-state listener.
            getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    newSelection.clear();
                    checkNode(root, true);
                }
            });
            getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    newSelection.clear();
                }
            });

            return buttonComposite;
        }

        /*
         * Overrides a method from CheckedTreeSelectionDialog.
         */
        @Override
        protected CheckboxTreeViewer createTreeViewer(Composite parent) {
            // Create the default TreeViewer.
            CheckboxTreeViewer viewer = super.createTreeViewer(parent);

            // Add the check state provider and listener.
            viewer.addCheckStateListener(checkStateListener);

            return viewer;
        }
    };

    // Set this flag so the "grayed" state of parent nodes is handled
    // properly.
    treeDialog.setContainerMode(true);

    return treeDialog;
}

From source file:org.eclipse.jdt.internal.junit.util.CheckedTableSelectionDialog.java

License:Open Source License

/**
 * Add the selection and deselection buttons to the dialog.
 * @param composite org.eclipse.swt.widgets.Composite
 * @return the created composite/*from   w ww  .  j a v a 2  s  .c  o  m*/
 */
private Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    buttonComposite.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    composite.setData(data);

    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            WizardMessages.CheckedTableSelectionDialog_selectAll, false);

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(fContentProvider.getElements(fInput));
            updateOKStatus();
        }
    };
    selectButton.addSelectionListener(listener);

    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            WizardMessages.CheckedTableSelectionDialog_deselectAll, false);

    listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(new Object[0]);
            updateOKStatus();
        }
    };
    deselectButton.addSelectionListener(listener);
    return buttonComposite;
}

From source file:org.eclipse.jubula.client.ui.rcp.wizards.pages.ImportXLSTestdataWizardPage.java

License:Open Source License

/**
 * Creates the buttons for selecting specific types or selecting all or none
 * of the elements./*from   w  w w  .j av  a 2s  .  co m*/
 * 
 * @param parent
 *            the parent control
 */
protected final void createButtonsGroup(Composite parent) {
    // top level group
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = true;
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(parent.getFont());
    GridData buttonData = new GridData(SWT.FILL, SWT.FILL, true, false);
    buttonComposite.setLayoutData(buttonData);

    // types edit button
    m_selectTypesButton = createButton(buttonComposite, IDialogConstants.SELECT_TYPES_ID, SELECT_TYPES_TITLE,
            false);

    SelectionListener listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleTypesEditButtonPressed();
        }
    };
    m_selectTypesButton.addSelectionListener(listener);
    setButtonLayoutData(m_selectTypesButton);

    m_selectAllButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, SELECT_ALL_TITLE, false);

    listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setAllSelections(true);
            updateWidgetEnablements();
        }
    };
    m_selectAllButton.addSelectionListener(listener);
    setButtonLayoutData(m_selectAllButton);

    m_deselectAllButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, DESELECT_ALL_TITLE,
            false);

    listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setAllSelections(false);
            updateWidgetEnablements();
        }
    };
    m_deselectAllButton.addSelectionListener(listener);
    setButtonLayoutData(m_deselectAllButton);

}

From source file:org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.ImportDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button selectAllButton = createButton(parent, IDialogConstants.SELECT_ALL_ID,
            Messages.TraceControl_ImportDialog_SelectAll, true);
    selectAllButton.addSelectionListener(new SelectionAdapter() {
        @Override//  w ww .  ja v a2 s  . c  om
        public void widgetSelected(SelectionEvent e) {
            setFolderChildrenChecked(true);
        }
    });

    Button deselectAllButton = createButton(parent, IDialogConstants.DESELECT_ALL_ID,
            Messages.TraceControl_ImportDialog_DeselectAll, true);
    deselectAllButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            setFolderChildrenChecked(false);
        }
    });
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    updateOKButtonEnablement();
}

From source file:org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphFilterDialog.java

License:Open Source License

/**
 * Adds the selection and deselection buttons to the dialog.
 *
 * @param composite//  ww w . ja  v  a 2s  .c om
 *            the parent composite
 * @return Composite the composite the buttons were created in.
 */
protected Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    buttonComposite.setLayoutData(data);

    /* Create the buttons in the good order to place them as we want */
    Button checkSelectedButton = createButton(buttonComposite, BUTTON_CHECK_SELECTED_ID,
            Messages.TmfTimeFilterDialog_CHECK_SELECTED, false);
    Button checkSubtreeButton = createButton(buttonComposite, BUTTON_CHECK_SUBTREE_ID,
            Messages.TmfTimeFilterDialog_CHECK_SUBTREE, false);
    Button checkAllButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            Messages.TmfTimeFilterDialog_CHECK_ALL, false);

    Button uncheckSelectedButton = createButton(buttonComposite, BUTTON_UNCHECK_SELECTED_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_SELECTED, false);
    Button uncheckSubtreeButton = createButton(buttonComposite, BUTTON_UNCHECK_SUBTREE_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_SUBTREE, false);
    Button uncheckAllButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_ALL, false);

    /*
     * Apply the layout again after creating the buttons to override
     * createButton messing with the columns
     */
    layout.numColumns = 3;
    buttonComposite.setLayout(layout);

    /* Add a listener to each button */
    checkSelectedButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fViewer.getSelection();

            for (Object element : selection.toArray()) {
                checkElement(element);
            }

            updateOKStatus();
        }
    });

    checkSubtreeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fViewer.getSelection();

            for (Object element : selection.toArray()) {
                checkElementAndSubtree(element);
            }
        }
    });

    checkAllButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);

            for (int i = 0; i < viewerElements.length; i++) {
                fViewer.setSubtreeChecked(viewerElements[i], true);
            }

            updateOKStatus();
        }
    });

    uncheckSelectedButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fViewer.getSelection();

            for (Object element : selection.toArray()) {
                uncheckElement(element);
            }

            updateOKStatus();
        }
    });

    uncheckSubtreeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fViewer.getSelection();

            for (Object element : selection.toArray()) {
                uncheckElement(element);
            }

            updateOKStatus();
        }
    });

    uncheckAllButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(new Object[0]);
            updateOKStatus();
        }
    });

    return buttonComposite;
}

From source file:org.eclipse.osee.framework.ui.data.model.editor.wizard.ODMSelectPage.java

License:Open Source License

protected Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from w  w  w. ja  va 2  s . c  o  m
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    composite.setData(data);
    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, "Select All", false);
    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);
            if (fContainerMode) {
                fViewer.setCheckedElements(viewerElements);
            } else {
                for (int i = 0; i < viewerElements.length; i++) {
                    fViewer.setSubtreeChecked(viewerElements[i], true);
                }
            }
            updateOKStatus();
        }
    };
    selectButton.addSelectionListener(listener);
    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, "De-select All",
            false);
    listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(new Object[0]);
            updateOKStatus();
        }
    };
    deselectButton.addSelectionListener(listener);
    return buttonComposite;
}

From source file:org.eclipse.osee.ote.ui.define.importer.OutfileImportPage.java

License:Open Source License

private Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from w  ww  . j  av a  2 s  .  c o m
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.grabExcessHorizontalSpace = true;
    composite.setData(data);
    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, "Select All", false);
    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = contentProvider.getElements(treeInput);
            if (treeSelectionMode) {
                treeViewer.setCheckedElements(viewerElements);
            } else {
                for (int i = 0; i < viewerElements.length; i++) {
                    treeViewer.setSubtreeChecked(viewerElements[i], true);
                }
            }
            updateWidgetEnablements();
        }
    };
    selectButton.addSelectionListener(listener);
    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, "Deselect All",
            false);
    listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            treeViewer.setCheckedElements(new Object[0]);
            updateWidgetEnablements();
        }
    };
    deselectButton.addSelectionListener(listener);
    return buttonComposite;
}

From source file:org.eclipse.papyrus.diagram.common.dialogs.CustomCheckedTreeSelectionDialog.java

License:Open Source License

/**
 * Adds the selection and deselection buttons to the dialog.
 * /*from   ww  w  .  j  av a  2s . co m*/
 * @param composite
 *        the parent composite
 * @return Composite the composite the buttons were created in.
 */
protected Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    buttonComposite.setLayoutData(data);
    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            WorkbenchMessages.CheckedTreeSelectionDialog_select_all, false);
    SelectionListener listener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);
            if (fContainerMode) {
                fViewer.setCheckedElements(viewerElements);
            } else {
                for (int i = 0; i < viewerElements.length; i++) {
                    fViewer.setSubtreeChecked(viewerElements[i], true);
                }
            }
            updateOKStatus();
        }
    };
    selectButton.addSelectionListener(listener);
    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            WorkbenchMessages.CheckedTreeSelectionDialog_deselect_all, false);
    listener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(new Object[0]);
            updateOKStatus();
        }
    };
    deselectButton.addSelectionListener(listener);
    return buttonComposite;
}

From source file:org.eclipse.ptp.etfw.tau.papiselect.papic.PapiListSelectionDialog.java

License:Open Source License

/**
 * Add the selection, deselection and help buttons to the dialog.
 * //from  w  ww .  j a  v a 2  s.c o  m
 * @param composite
 *            org.eclipse.swt.widgets.Composite
 */
private void addSelectionButtons(Composite composite) {
    final Composite buttonComposite = new Composite(composite, SWT.NONE);
    final GridLayout layout = new GridLayout();
    layout.numColumns = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonComposite.setLayout(layout);
    buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false));

    final Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            Messages.PapiListSelectionDialog_SelectAll, false);

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            final Object[] masterlist = contentProvider.getElements(inputElement);
            for (final Object element : masterlist) {
                // System.out.println(masterlist[i]);
                listViewer.setChecked(element, true);
                updateGrey(element);
            }
        }
    };
    selectButton.addSelectionListener(listener);

    final Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            Messages.PapiListSelectionDialog_DeselectAll, false);

    listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            listViewer.setAllChecked(false);
            listViewer.setAllGrayed(false);
        }
    };
    deselectButton.addSelectionListener(listener);

    final Button helpButton = createButton(buttonComposite, IDialogConstants.HELP_ID,
            Messages.PapiListSelectionDialog_CounterDescs, false);
    listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            displayPapiDescs();
        }
    };
    helpButton.addSelectionListener(listener);
}

From source file:org.eclipse.tcf.te.tcf.ui.wizards.pages.PeerExportWizardPage.java

License:Open Source License

/**
 * Creates the checkbox tree and list for selecting peers.
 *
 * @param parent the parent control//from  w  ww  . jav  a  2  s  .  c  o m
 */
private final void createPeersGroup(Composite parent) {
    Composite resourcesGroup = new Composite(parent, SWT.NONE);
    resourcesGroup.setLayout(new GridLayout());
    resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    resourcesGroup.setFont(parent.getFont());

    new Label(resourcesGroup, SWT.NONE).setText(Messages.PeerExportWizardPage_peers_label);
    Table table = new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    fViewer = new CheckboxTableViewer(table);
    fViewer.setContentProvider(new ITreePathContentProvider() {
        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof IPeerModel) {
                IPeerNode[] nodes = ((IPeerModel) inputElement).getPeerNodes();
                List<IPeerNode> filteredNodes = new ArrayList<IPeerNode>();
                for (IPeerNode node : nodes) {
                    if (node.isVisible()) {
                        filteredNodes.add(node);
                    }
                }
                return filteredNodes.toArray();
            }
            return new Object[0];
        }

        @Override
        public Object[] getChildren(TreePath parentPath) {
            return null;
        }

        @Override
        public boolean hasChildren(TreePath path) {
            return false;
        }

        @Override
        public TreePath[] getParents(Object element) {
            return null;
        }
    });
    fViewer.setLabelProvider(new DelegatingLabelProvider());
    ICheckStateListener checkListener = new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            setPageComplete(isComplete());
        }
    };
    fViewer.addCheckStateListener(checkListener);
    fViewer.setInput(ModelManager.getPeerModel());

    // top level group
    Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
    buttonComposite.setFont(parent.getFont());

    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = layout.marginWidth = 0;
    buttonComposite.setLayout(layout);
    buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));

    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            Messages.PeerExportWizardPage_selectAll, false);

    selectButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setAllChecked(true);
            setPageComplete(isComplete());
        }
    });

    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            Messages.PeerExportWizardPage_deselectAll, false);

    deselectButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fViewer.setAllChecked(false);
            setPageComplete(isComplete());
        }
    });
}