Search in sources :

Example 1 with GitLabelProvider

use of org.eclipse.egit.ui.internal.GitLabelProvider in project egit by eclipse.

the class UnmergedBranchDialog method createCustomArea.

@Override
protected Control createCustomArea(Composite parent) {
    Composite area = new Composite(parent, SWT.NONE);
    area.setLayoutData(new GridData(GridData.FILL_BOTH));
    area.setLayout(new FillLayout());
    TableViewer branchesList = new TableViewer(area);
    branchesList.setContentProvider(ArrayContentProvider.getInstance());
    branchesList.setLabelProvider(new GitLabelProvider());
    branchesList.setInput(nodes);
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) GitLabelProvider(org.eclipse.egit.ui.internal.GitLabelProvider) FillLayout(org.eclipse.swt.layout.FillLayout) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with GitLabelProvider

use of org.eclipse.egit.ui.internal.GitLabelProvider in project egit by eclipse.

the class CommitEditorPage method createBranchesArea.

private void createBranchesArea(Composite parent, FormToolkit toolkit, int span) {
    branchSection = createSection(parent, toolkit, UIText.CommitEditorPage_SectionBranchesEmpty, span, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
    ((GridData) branchSection.getLayoutData()).grabExcessVerticalSpace = false;
    Composite branchesArea = createSectionClient(branchSection, toolkit);
    branchViewer = new TableViewer(toolkit.createTable(branchesArea, SWT.V_SCROLL | SWT.H_SCROLL));
    Control control = branchViewer.getControl();
    control.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 50).applyTo(control);
    addToFocusTracking(control);
    branchViewer.setComparator(new ViewerComparator());
    branchViewer.setLabelProvider(new GitLabelProvider() {

        @Override
        public String getText(Object element) {
            return Repository.shortenRefName(super.getText(element));
        }
    });
    branchViewer.setContentProvider(ArrayContentProvider.getInstance());
    updateSectionClient(branchSection, branchesArea, toolkit);
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) GitLabelProvider(org.eclipse.egit.ui.internal.GitLabelProvider) PlatformObject(org.eclipse.core.runtime.PlatformObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 3 with GitLabelProvider

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

Aggregations

GitLabelProvider (org.eclipse.egit.ui.internal.GitLabelProvider)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 Composite (org.eclipse.swt.widgets.Composite)3 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 PlatformObject (org.eclipse.core.runtime.PlatformObject)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 CachedCheckboxTreeViewer (org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer)1 FilteredCheckboxTree (org.eclipse.egit.ui.internal.components.FilteredCheckboxTree)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)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 Viewer (org.eclipse.jface.viewers.Viewer)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1