Search in sources :

Example 6 with RepositoriesViewContentProvider

use of org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider 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

RepositoriesViewContentProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider)6 Path (org.eclipse.core.runtime.Path)3 RepositoriesViewLabelProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider)3 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 IOException (java.io.IOException)1 URI (java.net.URI)1