Search in sources :

Example 91 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent 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 92 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent 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)

Example 93 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent 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)

Example 94 with CheckStateChangedEvent

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

the class CleanRepositoryPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
    main.setLayout(new GridLayout());
    final Button radioCleanFiles = new Button(main, SWT.RADIO);
    radioCleanFiles.setText(UIText.CleanRepositoryPage_cleanFiles);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(radioCleanFiles);
    final Button radioCleanDirs = new Button(main, SWT.RADIO);
    radioCleanDirs.setText(UIText.CleanRepositoryPage_cleanDirs);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(radioCleanDirs);
    SelectionAdapter listener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cleanDirectories = radioCleanDirs.getSelection();
            updateCleanItems();
        }
    };
    radioCleanFiles.addSelectionListener(listener);
    radioCleanDirs.addSelectionListener(listener);
    radioCleanFiles.setSelection(true);
    final Image fileImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
    final Image dirImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
    cleanTable = CheckboxTableViewer.newCheckList(main, SWT.BORDER);
    cleanTable.setContentProvider(ArrayContentProvider.getInstance());
    cleanTable.setLabelProvider(new LabelProvider() {

        @Override
        public Image getImage(Object element) {
            if (!(element instanceof String))
                return null;
            if (// $NON-NLS-1$
            ((String) element).endsWith("/"))
                return dirImage;
            else
                return fileImage;
        }
    });
    setPageComplete(false);
    cleanTable.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updatePageComplete();
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).applyTo(cleanTable.getControl());
    Composite lowerComp = new Composite(main, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(lowerComp);
    lowerComp.setLayout(new GridLayout(3, false));
    final Button checkIncludeIgnored = new Button(lowerComp, SWT.CHECK);
    checkIncludeIgnored.setText(UIText.CleanRepositoryPage_includeIgnored);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(checkIncludeIgnored);
    checkIncludeIgnored.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            includeIgnored = checkIncludeIgnored.getSelection();
            updateCleanItems();
        }
    });
    Button selAll = new Button(lowerComp, SWT.PUSH);
    selAll.setText(UIText.WizardProjectsImportPage_selectAll);
    GridDataFactory.defaultsFor(selAll).applyTo(selAll);
    Button selNone = new Button(lowerComp, SWT.PUSH);
    selNone.setText(UIText.WizardProjectsImportPage_deselectAll);
    GridDataFactory.defaultsFor(selNone).applyTo(selNone);
    selAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (cleanTable.getInput() instanceof Set<?>) {
                Set<?> input = (Set<?>) cleanTable.getInput();
                cleanTable.setCheckedElements(input.toArray());
                updatePageComplete();
            }
        }
    });
    selNone.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cleanTable.setCheckedElements(new Object[0]);
            updatePageComplete();
        }
    });
    setControl(main);
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 95 with CheckStateChangedEvent

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

the class CommitSearchPage method addRepositoryControl.

private void addRepositoryControl(Composite parent) {
    repositoryGroup = new Group(parent, SWT.NONE);
    repositoryGroup.setBackgroundMode(SWT.INHERIT_DEFAULT);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(repositoryGroup);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(repositoryGroup);
    this.repositoryViewer = CheckboxTableViewer.newCheckList(repositoryGroup, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    this.repositoryViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new RepositoriesViewLabelProvider()));
    this.repositoryViewer.setContentProvider(new RepositoriesViewContentProvider());
    this.repositoryViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    this.repositoryViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
            repositoryGroup.setText(getRepositoryText());
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 40).applyTo(this.repositoryViewer.getControl());
    ToolBar checkBar = new ToolBar(repositoryGroup, SWT.FLAT | SWT.VERTICAL);
    GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).grab(false, true).applyTo(checkBar);
    ToolItem checkItem = new ToolItem(checkBar, SWT.PUSH);
    checkItem.setToolTipText(UIText.CommitSearchPage_CheckAll);
    Image checkImage = UIIcons.CHECK_ALL.createImage();
    UIUtils.hookDisposal(checkItem, checkImage);
    checkItem.setImage(checkImage);
    checkItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            repositoryViewer.setAllChecked(true);
            repositoryGroup.setText(getRepositoryText());
            updateOKStatus();
        }
    });
    ToolItem uncheckItem = new ToolItem(checkBar, SWT.PUSH);
    uncheckItem.setToolTipText(UIText.CommitSearchPage_UncheckAll);
    Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
    UIUtils.hookDisposal(uncheckItem, uncheckImage);
    uncheckItem.setImage(uncheckImage);
    uncheckItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            repositoryViewer.setAllChecked(false);
            repositoryGroup.setText(getRepositoryText());
            updateOKStatus();
        }
    });
    this.searchAllBranchesButton = new Button(repositoryGroup, SWT.CHECK);
    this.searchAllBranchesButton.setText(UIText.CommitSearchPage_SearchAllBranches);
    GridDataFactory.swtDefaults().grab(true, false).span(2, 1).applyTo(this.searchAllBranchesButton);
    repositoryGroup.setText(getRepositoryText());
}
Also used : Group(org.eclipse.swt.widgets.Group) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RepositoriesViewLabelProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider) RepositoriesViewContentProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider) Image(org.eclipse.swt.graphics.Image) Button(org.eclipse.swt.widgets.Button) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)136 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)133 GridData (org.eclipse.swt.layout.GridData)89 Composite (org.eclipse.swt.widgets.Composite)68 GridLayout (org.eclipse.swt.layout.GridLayout)61 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)45 Button (org.eclipse.swt.widgets.Button)43 Label (org.eclipse.swt.widgets.Label)42 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)31 Table (org.eclipse.swt.widgets.Table)30 Viewer (org.eclipse.jface.viewers.Viewer)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)26 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)26 TableColumn (org.eclipse.swt.widgets.TableColumn)23 ArrayList (java.util.ArrayList)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 Text (org.eclipse.swt.widgets.Text)18 List (java.util.List)16