Search in sources :

Example 1 with RepositoriesViewStyledCellLabelProvider

use of org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider in project egit by eclipse.

the class AbstractBranchSelectionDialog method createDialogArea.

@Override
protected final Composite createDialogArea(Composite base) {
    Composite parent = (Composite) super.createDialogArea(base);
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    int selectionModel = -1;
    if ((settings & ALLOW_MULTISELECTION) != 0)
        selectionModel = SWT.MULTI;
    else
        selectionModel = SWT.SINGLE;
    FilteredTree tree = new FilteredTree(composite, selectionModel | SWT.BORDER, new PatternFilter(), true);
    branchTree = tree.getViewer();
    branchTree.setUseHashlookup(true);
    branchTree.setLabelProvider(new RepositoriesViewStyledCellLabelProvider());
    branchTree.setContentProvider(new RepositoriesViewContentProvider());
    ColumnViewerToolTipSupport.enableFor(branchTree);
    GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(tree);
    branchTree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            String refName = refNameFromDialog();
            refNameSelected(refName);
        }
    });
    // double-click support
    branchTree.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            RepositoryTreeNode node = (RepositoryTreeNode) ((IStructuredSelection) branchTree.getSelection()).getFirstElement();
            if (node == null)
                return;
            final RepositoryTreeNodeType type = node.getType();
            if (type != RepositoryTreeNodeType.REF && type != RepositoryTreeNodeType.TAG && type != RepositoryTreeNodeType.ADDITIONALREF)
                branchTree.setExpandedState(node, !branchTree.getExpandedState(node));
            else if (isOkButtonEnabled())
                buttonPressed(OK);
        }
    });
    branchTree.setComparator(new ViewerComparator(STRING_ASCENDING_COMPARATOR));
    createCustomArea(composite);
    setTitle(getTitle());
    setMessage(getMessageText());
    getShell().setText(getWindowTitle());
    applyDialogFont(composite);
    return composite;
}
Also used : RepositoryTreeNodeType(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoriesViewContentProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider) RepositoriesViewStyledCellLabelProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener)

Example 2 with RepositoriesViewStyledCellLabelProvider

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

RepositoriesViewContentProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider)2 RepositoriesViewStyledCellLabelProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 Composite (org.eclipse.swt.widgets.Composite)2 CachedCheckboxTreeViewer (org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer)1 FilteredCheckboxTree (org.eclipse.egit.ui.internal.components.FilteredCheckboxTree)1 RemoteSelectionCombo (org.eclipse.egit.ui.internal.components.RemoteSelectionCombo)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 RepositoryTreeNodeType (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType)1 TagsNode (org.eclipse.egit.ui.internal.repository.tree.TagsNode)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 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1