Search in sources :

Example 1 with CachedCheckboxTreeViewer

use of org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer 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 2 with CachedCheckboxTreeViewer

use of org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer in project egit by eclipse.

the class PushTagsPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(GridLayoutFactory.swtDefaults().spacing(LayoutConstants.getSpacing()).numColumns(2).create());
    Label remoteLabel = new Label(main, SWT.NONE);
    remoteLabel.setText(UIText.PushTagsPage_RemoteLabel);
    RemoteSelectionCombo remoteSelectionCombo = new RemoteSelectionCombo(main, SWT.NONE, SelectionType.PUSH);
    remoteSelectionCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    selectedRemoteConfig = remoteSelectionCombo.setItems(getRemoteConfigs());
    remoteSelectionCombo.addRemoteSelectionListener(new RemoteSelectionCombo.IRemoteSelectionListener() {

        @Override
        public void remoteSelected(RemoteConfig remoteConfig) {
            selectedRemoteConfig = remoteConfig;
        }
    });
    tagsLabel = new Label(main, SWT.NONE);
    tagsLabel.setText(UIText.PushTagsPage_TagsLabelNoneSelected);
    tagsLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    FilteredCheckboxTree tree = new FilteredCheckboxTree(main, null, SWT.BORDER);
    tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(400, 300).create());
    final Button forceUpdateButton = new Button(main, SWT.CHECK);
    forceUpdateButton.setText(UIText.PushTagsPage_ForceUpdateButton);
    forceUpdateButton.setSelection(false);
    forceUpdateButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    forceUpdateButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            forceUpdateSelected = forceUpdateButton.getSelection();
        }
    });
    final CachedCheckboxTreeViewer treeViewer = tree.getCheckboxTreeViewer();
    TagsNode tagsNode = new TagsNode(null, repository);
    ContentProvider contentProvider = new ContentProvider(tagsNode);
    treeViewer.setContentProvider(contentProvider);
    treeViewer.setLabelProvider(new RepositoriesViewStyledCellLabelProvider());
    treeViewer.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
    treeViewer.setInput(tagsNode);
    final Object[] tagNodes = contentProvider.getElements(tagsNode);
    initiallySelectTags(tagNodes, treeViewer);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            setSelectedTags(treeViewer.getCheckedElements());
        }
    });
    setControl(main);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) RepositoriesViewContentProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TagsNode(org.eclipse.egit.ui.internal.repository.tree.TagsNode) Label(org.eclipse.swt.widgets.Label) RepositoriesViewStyledCellLabelProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RemoteSelectionCombo(org.eclipse.egit.ui.internal.components.RemoteSelectionCombo) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

CachedCheckboxTreeViewer (org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer)2 FilteredCheckboxTree (org.eclipse.egit.ui.internal.components.FilteredCheckboxTree)2 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 Composite (org.eclipse.swt.widgets.Composite)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 GitLabelProvider (org.eclipse.egit.ui.internal.GitLabelProvider)1 RemoteSelectionCombo (org.eclipse.egit.ui.internal.components.RemoteSelectionCombo)1 RepositoriesViewContentProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider)1 RepositoriesViewStyledCellLabelProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider)1 TagsNode (org.eclipse.egit.ui.internal.repository.tree.TagsNode)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1