Search in sources :

Example 81 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project hale by halestudio.

the class LayersDialog method createDialogArea.

/**
 * @see TitleAreaDialog#createDialogArea(Composite)
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    page.setLayoutData(data);
    page.setLayout(new FillLayout());
    CheckboxTableViewer table = CheckboxTableViewer.newCheckList(page, SWT.V_SCROLL | SWT.BORDER);
    TableColumn names = new TableColumn(table.getTable(), SWT.NONE);
    names.setWidth(200);
    names.setText(Messages.LayersDialog_2);
    TableColumn descs = new TableColumn(table.getTable(), SWT.NONE);
    descs.setWidth(200);
    descs.setText(Messages.LayersDialog_3);
    // labels
    table.setLabelProvider(new LayerLabelProvider());
    table.setCheckStateProvider(new LayerCheckStateProvider());
    table.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            ((Layer) event.getElement()).setSelected(event.getChecked());
        }
    });
    // content
    table.setContentProvider(new IStructuredContentProvider() {

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

        @Override
        public void dispose() {
        // ignore
        }

        @Override
        @SuppressWarnings("unchecked")
        public Object[] getElements(Object inputElement) {
            return ((List<Layer>) inputElement).toArray();
        }
    });
    table.setInput(layers);
    table.getTable().setLinesVisible(true);
    table.getTable().setHeaderVisible(true);
    // pack columns
    names.pack();
    descs.pack();
    return page;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) Layer(de.fhg.igd.mapviewer.server.wms.capabilities.Layer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 82 with ICheckStateListener

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

the class BranchSelectionDialog method createCustomArea.

@Override
protected Control createCustomArea(Composite parent) {
    Composite area = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(area);
    area.setLayout(new GridLayout(1, false));
    if (multiMode) {
        fTree = new FilteredCheckboxTree(area, null, SWT.NONE, new PatternFilter()) {

            /*
				 * Overridden to check page when refreshing is done.
				 */
            @Override
            protected WorkbenchJob doCreateRefreshJob() {
                WorkbenchJob refreshJob = super.doCreateRefreshJob();
                refreshJob.addJobChangeListener(new JobChangeAdapter() {

                    @Override
                    public void done(IJobChangeEvent event) {
                        if (event.getResult().isOK()) {
                            getDisplay().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    checkPage();
                                }
                            });
                        }
                    }
                });
                return refreshJob;
            }
        };
        CachedCheckboxTreeViewer viewer = fTree.getCheckboxTreeViewer();
        GridDataFactory.fillDefaults().grab(true, true).applyTo(fTree);
        viewer.setContentProvider(new ITreeContentProvider() {

            @Override
            public void inputChanged(Viewer actViewer, Object oldInput, Object newInput) {
            // nothing
            }

            @Override
            public void dispose() {
            // nothing
            }

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

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

            @Override
            public Object[] getElements(Object inputElement) {
                return ((List) inputElement).toArray();
            }

            @Override
            public Object[] getChildren(Object parentElement) {
                return null;
            }
        });
        viewer.addCheckStateListener(new ICheckStateListener() {

            @Override
            public void checkStateChanged(CheckStateChangedEvent event) {
                checkPage();
            }
        });
        viewer.setLabelProvider(new GitLabelProvider());
        viewer.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
        viewer.setInput(nodes);
        preselectBranchMultiMode(nodes, fTree);
    } else {
        branchesList = new TableViewer(area, this.style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
        GridDataFactory.fillDefaults().grab(true, true).applyTo(branchesList.getControl());
        branchesList.setContentProvider(ArrayContentProvider.getInstance());
        branchesList.setLabelProvider(new GitLabelProvider());
        branchesList.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
        branchesList.setInput(nodes);
        preselectBranchSingleMode(nodes, branchesList);
        branchesList.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                checkPage();
            }
        });
        branchesList.addDoubleClickListener(new IDoubleClickListener() {

            @Override
            public void doubleClick(DoubleClickEvent event) {
                buttonPressed(OK);
            }
        });
    }
    return area;
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Composite(org.eclipse.swt.widgets.Composite) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GitLabelProvider(org.eclipse.egit.ui.internal.GitLabelProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 83 with ICheckStateListener

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

the class CommitViewerComparator method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    parent.getShell().setText(UIText.CommitDialog_CommitChanges);
    container = toolkit.createComposite(container);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
    toolkit.paintBordersFor(container);
    GridLayoutFactory.swtDefaults().applyTo(container);
    final SashForm sashForm = new SashForm(container, SWT.VERTICAL | SWT.FILL);
    toolkit.adapt(sashForm, true, true);
    sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    createMessageAndPersonArea(sashForm);
    filesSection = createFileSection(sashForm);
    sashForm.setWeights(new int[] { 50, 50 });
    applyDialogFont(container);
    container.pack();
    commitText.setFocus();
    Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage();
    UIUtils.hookDisposal(parent, titleImage);
    setTitleImage(titleImage);
    setTitle(UIText.CommitDialog_Title);
    if (ignoreErrors != null) {
        setMessage(UIText.CommitDialog_MessageErrors, IMessageProvider.WARNING);
    } else {
        setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION);
    }
    filesViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateMessage();
        }
    });
    updateFileSectionText();
    return container;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Image(org.eclipse.swt.graphics.Image) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 84 with ICheckStateListener

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

the class SourceBranchPage method createControl.

@Override
public void createControl(final Composite parent) {
    final Composite panel = new Composite(parent, SWT.NULL);
    final GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    panel.setLayout(layout);
    label = new Label(panel, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    FilteredCheckboxTree fTree = new FilteredCheckboxTree(panel, null, SWT.NONE, new PatternFilter()) {

        /*
			 * Overridden to check page when refreshing is done.
			 */
        @Override
        protected WorkbenchJob doCreateRefreshJob() {
            WorkbenchJob refreshJob = super.doCreateRefreshJob();
            refreshJob.addJobChangeListener(new JobChangeAdapter() {

                @Override
                public void done(IJobChangeEvent event) {
                    if (event.getResult().isOK()) {
                        getDisplay().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                checkPage();
                            }
                        });
                    }
                }
            });
            return refreshJob;
        }
    };
    refsViewer = fTree.getCheckboxTreeViewer();
    ITreeContentProvider provider = new ITreeContentProvider() {

        @Override
        public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
        // nothing
        }

        @Override
        public void dispose() {
        // nothing
        }

        @Override
        public Object[] getElements(Object input) {
            return ((List) input).toArray();
        }

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

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

        @Override
        public Object[] getChildren(Object parentElement) {
            return null;
        }
    };
    refsViewer.setContentProvider(provider);
    refsViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (((Ref) element).getName().startsWith(Constants.R_HEADS))
                return ((Ref) element).getName().substring(Constants.R_HEADS.length());
            return ((Ref) element).getName();
        }

        @Override
        public Image getImage(Object element) {
            return RepositoryTreeNodeType.REF.getIcon();
        }
    });
    refsViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            checkPage();
        }
    });
    final Composite bPanel = new Composite(panel, SWT.NONE);
    bPanel.setLayout(new RowLayout());
    selectB = new Button(bPanel, SWT.PUSH);
    selectB.setText(UIText.SourceBranchPage_selectAll);
    selectB.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            refsViewer.setAllChecked(true);
            checkPage();
        }
    });
    unselectB = new Button(bPanel, SWT.PUSH);
    unselectB.setText(UIText.SourceBranchPage_selectNone);
    unselectB.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            refsViewer.setAllChecked(false);
            checkPage();
        }
    });
    bPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    Dialog.applyDialogFont(panel);
    setControl(panel);
    checkPage();
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) Label(org.eclipse.swt.widgets.Label) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) Composite(org.eclipse.swt.widgets.Composite) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Ref(org.eclipse.jgit.lib.Ref) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 85 with ICheckStateListener

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

the class GitProjectsImportPage method createProjectsList.

/**
 * Create the checkbox list for the found projects.
 *
 * @param workArea
 */
private void createProjectsList(Composite workArea) {
    Label title = new Label(workArea, SWT.NONE);
    title.setText(UIText.WizardProjectsImportPage_ProjectsListTitle);
    Composite listComposite = new Composite(workArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    listComposite.setLayout(layout);
    listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
    PatternFilter filter = new PatternFilter() {

        @Override
        public boolean isElementVisible(Viewer viewer, Object element) {
            if (getCheckedProjects().contains(element))
                return true;
            if (element instanceof ProjectRecord) {
                ProjectRecord p = (ProjectRecord) element;
                if (wordMatches(p.getProjectName()))
                    return true;
                String projectPath = p.getProjectSystemFile().getParent();
                if (projectPath.startsWith(lastPath)) {
                    String distinctPath = projectPath.substring(lastPath.length());
                    return wordMatches(distinctPath);
                } else {
                    return wordMatches(projectPath);
                }
            }
            return false;
        }
    };
    filter.setIncludeLeadingWildcard(true);
    FilteredCheckboxTree filteredTree = new FilteredCheckboxTree(listComposite, null, SWT.NONE, filter);
    filteredTree.setInitialText(UIText.WizardProjectsImportPage_filterText);
    projectsList = filteredTree.getCheckboxTreeViewer();
    GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    projectsList.getControl().setLayoutData(listData);
    projectsList.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            ProjectRecord element = (ProjectRecord) event.getElement();
            if (isProjectInWorkspace(element.getProjectName())) {
                projectsList.setChecked(element, false);
            }
            enableSelectAllButtons();
        }
    });
    // a bug in the CachedCheckboxTreeView requires us to not return null
    final Object[] children = new Object[0];
    projectsList.setContentProvider(new ITreeContentProvider() {

        @Override
        public Object[] getChildren(Object parentElement) {
            return children;
        }

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

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

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

        @Override
        public void dispose() {
        // ignore
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // ignore
        }
    });
    projectsList.getTree().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkPageComplete();
        }
    });
    projectsList.setLabelProvider(new ProjectLabelProvider());
    projectsList.setInput(this);
    projectsList.setComparator(new ViewerComparator());
    createSelectionButtons(listComposite);
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Composite(org.eclipse.swt.widgets.Composite) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) 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