Search in sources :

Example 86 with ICheckStateListener

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

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

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

Example 89 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project InformationSystem by ObeoNetwork.

the class ChooseTypesAndReferencesPage method createControl.

/**
 * Create contents of the wizard.
 * @param parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(2, true));
    Label lblTypes = new Label(container, SWT.NONE);
    lblTypes.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblTypes.setText("Types :");
    Label lblReferences = new Label(container, SWT.NONE);
    lblReferences.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblReferences.setText("References :");
    typesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
    typesTreeViewer.setUseHashlookup(true);
    final Tree typesTree = typesTreeViewer.getTree();
    typesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    typesTreeViewer.setContentProvider(new StructuredTypesContentProvider(sourceTypeName));
    typesTreeViewer.setLabelProvider(labelProvider);
    typesTreeViewer.setSorter(new ViewerSorter());
    referencesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
    referencesTreeViewer.setUseHashlookup(true);
    Tree referencesTree = referencesTreeViewer.getTree();
    referencesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    referencesTreeViewer.setContentProvider(new ArrayTreeContentProvider());
    referenceLabelProvider = new ReferenceLabelProvider();
    referencesTreeViewer.setLabelProvider(referenceLabelProvider);
    referencesTreeViewer.setSorter(new ViewerSorter());
    typesTreeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            // Check/uncheck all subtree
            typesTreeViewer.setSubtreeChecked(event.getElement(), event.getChecked());
            Collection<StructuredType> checkedTypes = getCheckedTypes();
            setPageComplete(!checkedTypes.isEmpty());
            List<Reference> references = referencesServices.getReferencesBetweenTypes(checkedTypes);
            referencesTreeViewer.setInput(references);
        }
    });
    initContents();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ReferenceLabelProvider(org.obeonetwork.dsl.environment.design.ui.providers.ReferenceLabelProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Label(org.eclipse.swt.widgets.Label) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) ArrayTreeContentProvider(org.obeonetwork.dsl.environment.design.ui.providers.ArrayTreeContentProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) StructuredTypesContentProvider(org.obeonetwork.dsl.environment.design.ui.providers.StructuredTypesContentProvider) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 90 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project InformationSystem by ObeoNetwork.

the class UserStoriesView method createPartControl.

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
public void createPartControl(Composite parent) {
    viewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    viewer.setUseHashlookup(true);
    viewer.setContentProvider(new UserStoriesContentProvider());
    viewer.setLabelProvider(new UserStoryLabelProvider(this, adapterFactory));
    viewer.setCheckStateProvider(new UserStoriesCheckStateProvider(viewer));
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getElement() instanceof UserStory) {
                UserStory story = (UserStory) event.getElement();
                if (viewer.getInput() instanceof UserStoryElement) {
                    TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(viewer.getInput());
                    if (editingDomain != null) {
                        if (event.getChecked()) {
                            LinkStory command = new LinkStory(story, (UserStoryElement) viewer.getInput());
                            editingDomain.getCommandStack().execute(command);
                        } else {
                            UnlinkStory command = new UnlinkStory(story, (UserStoryElement) viewer.getInput());
                            editingDomain.getCommandStack().execute(command);
                        }
                    }
                } else if (viewer.getInput() instanceof Collection<?>) {
                    List<UserStoryElement> selection = new ArrayList<UserStoryElement>();
                    for (Object next : (Collection<?>) viewer.getInput()) {
                        if (next instanceof UserStoryElement) {
                            selection.add((UserStoryElement) next);
                        }
                    }
                    if (!selection.isEmpty()) {
                        TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(selection.get(0));
                        if (editingDomain != null) {
                            if (event.getChecked()) {
                                LinkStory command = new LinkStory(story, selection);
                                editingDomain.getCommandStack().execute(command);
                            } else {
                                UnlinkStory command = new UnlinkStory(story, selection);
                                editingDomain.getCommandStack().execute(command);
                            }
                        }
                    }
                }
            }
            viewer.refresh();
        }
    });
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
            state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
            service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            updateUserStoryHighlightment();
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
            state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
            service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
        }
    });
    getSite().setSelectionProvider(viewer);
    selectionListener = new ViewpointMultiSelectionListener(this) {

        @Override
        protected void eObjectSelected(Session session, List<EObject> selectedEObjects) {
            update(session, selectedEObjects);
        }
    };
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
Also used : LinkStory(org.obeonetwork.graal.design.command.LinkStory) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) UnlinkStory(org.obeonetwork.graal.design.command.UnlinkStory) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ICommandService(org.eclipse.ui.commands.ICommandService) UserStory(org.obeonetwork.graal.UserStory) UserStoriesContentProvider(org.obeonetwork.graal.design.ui.view.util.UserStoriesContentProvider) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) EObject(org.eclipse.emf.ecore.EObject) UserStoryLabelProvider(org.obeonetwork.graal.design.ui.view.util.UserStoryLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) UserStoriesCheckStateProvider(org.obeonetwork.graal.design.ui.view.util.UserStoriesCheckStateProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) State(org.eclipse.core.commands.State) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) UserStoryElement(org.obeonetwork.graal.UserStoryElement) ViewpointMultiSelectionListener(org.obeonetwork.graal.design.ui.view.util.ViewpointMultiSelectionListener) Session(org.eclipse.sirius.business.api.session.Session)

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