Search in sources :

Example 66 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project epp.mpc by eclipse.

the class ShowNatureProposalsDialog method createDialogArea.

@Override
public Control createDialogArea(Composite parent) {
    setTitle(Messages.MissingNatureDetector_Title);
    setMessage(Messages.MissingNatureDetector_Desc);
    wizban = DiscoveryImages.BANNER_DISOVERY.createImage();
    setTitleImage(wizban);
    Composite res = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(res);
    GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).equalWidth(false).applyTo(res);
    Label label = new Label(res, SWT.WRAP);
    label.setText(Messages.MissingNatureDetector_Message);
    naturesCheckList = CheckboxTableViewer.newCheckList(res, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    naturesCheckList.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            return ((Set<?>) inputElement).toArray();
        }
    });
    naturesCheckList.setComparator(new ViewerComparator());
    naturesCheckList.setInput(candidates.keySet());
    naturesCheckList.setAllChecked(true);
    GridDataFactory.fillDefaults().applyTo(naturesCheckList.getControl());
    naturesCheckList.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            Button okButton = getButton(IDialogConstants.OK_ID);
            if (okButton != null) {
                okButton.setEnabled(canComplete());
            }
            updateSelectedNatures();
        }
    });
    Link preferencesLink = new Link(res, SWT.NONE);
    preferencesLink.setText(Messages.MissingNatureDetector_linkToPreferences);
    preferencesLink.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(), ProjectNaturesPreferencePage.ID, null, null);
            pref.setBlockOnOpen(false);
            pref.open();
        }
    });
    return res;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) Button(org.eclipse.swt.widgets.Button) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Link(org.eclipse.swt.widgets.Link)

Example 67 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project epp.mpc by eclipse.

the class FeatureSelectionWizardPage method createControl.

public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NONE);
    switchResultLayout = new StackLayout();
    container.setLayout(switchResultLayout);
    GridData data = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(data);
    defaultComposite = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
    Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
    TreeColumnLayout columnLayout = new TreeColumnLayout();
    treeContainer.setLayout(columnLayout);
    viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.setUseHashlookup(true);
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 == e2) {
                return 0;
            }
            String s1;
            String s2;
            if (e1 instanceof CatalogItemEntry) {
                s1 = ((CatalogItemEntry) e1).getItem().getName();
                s2 = ((CatalogItemEntry) e2).getItem().getName();
            } else {
                FeatureEntry fe1 = (FeatureEntry) e1;
                FeatureEntry fe2 = (FeatureEntry) e2;
                if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
                    // required items first
                    return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
                }
                s1 = fe1.getFeatureDescriptor().getName();
                s2 = fe2.getFeatureDescriptor().getName();
            }
            int i = s1.compareToIgnoreCase(s2);
            if (i == 0) {
                i = s1.compareTo(s2);
                if (i == 0) {
                    i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
                }
            }
            return i;
        }
    });
    viewer.setContentProvider(new ContentProvider());
    viewer.setInput(getWizard().getSelectionModel());
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean checked = event.getChecked();
            if (event.getElement() instanceof CatalogItemEntry) {
                CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
                for (FeatureEntry child : entry.getChildren()) {
                    child.setChecked(checked);
                }
            } else if (event.getElement() instanceof FeatureEntry) {
                FeatureEntry featureEntry = (FeatureEntry) event.getElement();
                featureEntry.setChecked(checked);
            }
            refreshState();
        }
    });
    column = new TreeViewerColumn(viewer, SWT.NONE);
    column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
    columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
    detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
    detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
    GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
    GridLayoutFactory.fillDefaults().applyTo(detailsControl);
    detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
    setControl(container);
    Dialog.applyDialogFont(container);
    MarketplaceClientUi.setDefaultHelp(getControl());
    flipToDefaultComposite();
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) RemediationGroup(org.eclipse.equinox.internal.p2.ui.dialogs.RemediationGroup) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Text(org.eclipse.swt.widgets.Text) StyledString(org.eclipse.jface.viewers.StyledString) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) StackLayout(org.eclipse.swt.custom.StackLayout) GridData(org.eclipse.swt.layout.GridData) CatalogItemEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) IStyledLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider)

Example 68 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project n4js by eclipse.

the class AbstractExportToSingleFileWizardPage method createProjectList.

/**
 * Creates the checkbox tree and list for selecting resources.
 *
 * @param parent
 *            the parent control
 */
protected void createProjectList(Composite parent) {
    // create the input element, which has the root resource
    // as its only child
    List<IProject> input = new ArrayList<>();
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
        if (projects[i].isOpen()) {
            input.add(projects[i]);
        }
    }
    listViewer = CheckboxTableViewer.newCheckList(parent, SWT.TOP | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    listViewer.getTable().setLayoutData(data);
    listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    listViewer.setContentProvider(getContentProvider());
    listViewer.setComparator(new ViewerComparator());
    // check for initial modification to avoid work if no changes are made
    listViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                for (Object currentlyChecked : listViewer.getCheckedElements()) {
                    if (currentlyChecked != event.getElement()) {
                        listViewer.setChecked(currentlyChecked, false);
                    }
                }
            }
            updateWidgetEnablements();
        }
    });
    listViewer.setInput(workspace);
}
Also used : ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IProject(org.eclipse.core.resources.IProject)

Example 69 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project liferay-ide by liferay.

the class SDKProjectConvertWizardPage method createProjectsList.

protected void createProjectsList(Composite workArea) {
    Label title = new Label(workArea, SWT.NONE);
    title.setText(Msgs.importProjectLabel);
    title.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    // Composite listComposite = new Composite(workArea, SWT.NONE);
    // GridLayout layout = new GridLayout();
    // layout.numColumns = 2;
    // layout.marginWidth = 0;
    // layout.makeColumnsEqualWidth = false;
    // listComposite.setLayout(layout);
    // GridData gd = new GridData(GridData.GRAB_HORIZONTAL
    // | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    // gd.grabExcessHorizontalSpace = true;
    // gd.horizontalSpan = 3;
    // listComposite.setLayoutData(gd);
    projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
    gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
    projectsList.getControl().setLayoutData(gridData);
    projectsList.setContentProvider(new ITreeContentProvider() {

        public void dispose() {
        }

        public Object[] getChildren(Object parentElement) {
            return null;
        }

        public Object[] getElements(Object inputElement) {
            return (Object[]) getDataModel().getProperty(SELECTED_PROJECTS);
        }

        public Object getParent(Object element) {
            return null;
        }

        public boolean hasChildren(Object element) {
            return false;
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    projectsList.setLabelProvider(new ProjectLabelProvider());
    projectsList.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            ProjectRecord element = (ProjectRecord) event.getElement();
            if (element.hasConflicts()) {
                projectsList.setChecked(element, false);
            }
            getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
            setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
        }
    });
    projectsList.setInput(this);
    projectsList.setComparator(new ViewerComparator());
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) ProjectRecord(com.liferay.ide.project.core.ProjectRecord) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 70 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project liferay-ide by liferay.

the class SDKProjectsImportWizardPage method createProjectsList.

protected void createProjectsList(Composite workArea) {
    labelProjectsList = new Label(workArea, SWT.NONE);
    labelProjectsList.setText(Msgs.importProjectsLabel);
    labelProjectsList.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
    gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
    projectsList.getControl().setLayoutData(gridData);
    projectsList.setContentProvider(new ITreeContentProvider() {

        public void dispose() {
        }

        public Object[] getChildren(Object parentElement) {
            return null;
        }

        public Object[] getElements(Object inputElement) {
            return getProjectRecords();
        }

        public Object getParent(Object element) {
            return null;
        }

        public boolean hasChildren(Object element) {
            return false;
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    projectsList.setLabelProvider(createProjectsListLabelProvider());
    projectsList.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            handleCheckStateChangedEvent(event);
        }
    });
    projectsList.setInput(this);
    projectsList.setComparator(new ViewerComparator());
    createSelectionButtons(workArea);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)98 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)93 GridData (org.eclipse.swt.layout.GridData)61 Composite (org.eclipse.swt.widgets.Composite)48 GridLayout (org.eclipse.swt.layout.GridLayout)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)39 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)33 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)31 Button (org.eclipse.swt.widgets.Button)30 Label (org.eclipse.swt.widgets.Label)30 Viewer (org.eclipse.jface.viewers.Viewer)21 ArrayList (java.util.ArrayList)20 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)20 Table (org.eclipse.swt.widgets.Table)19 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)16 Event (org.eclipse.swt.widgets.Event)16 TableColumn (org.eclipse.swt.widgets.TableColumn)16 List (java.util.List)14 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)14 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)14