Search in sources :

Example 1 with RemoteContentProvider

use of org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider in project subclipse by subclipse.

the class RepositoriesView method createPartControl.

/*
   * @see WorkbenchPart#createPartControl
   */
public void createPartControl(Composite parent) {
    treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new RemoteContentProvider();
    treeViewer.setContentProvider(contentProvider);
    final RepositoriesViewDecorator decorator = new RepositoriesViewDecorator();
    DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), new ILabelDecorator() {

        public Image decorateImage(Image image, Object obj) {
            if (obj instanceof RemoteFile) {
                RemoteFile remoteFile = (RemoteFile) obj;
                if (remoteFile.getLock() != null) {
                    return decorator.getImage(image);
                }
            }
            return null;
        }

        public String decorateText(String text, Object obj) {
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object obj, String prop) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    treeViewer.setLabelProvider(labelProvider);
    getSite().setSelectionProvider(treeViewer);
    root = new AllRootsElement();
    treeViewer.setInput(root);
    treeViewer.setSorter(new RepositorySorter());
    drillPart = new DrillDownAdapter(treeViewer);
    contributeActions();
    // F1 Help
    String helpID = getHelpContextId();
    if (helpID != null)
        PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(), helpID);
    initializeListeners();
    SVNUIPlugin.getPlugin().getRepositoryManager().addRepositoryListener(repositoryListener);
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) ILabelDecorator(org.eclipse.jface.viewers.ILabelDecorator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) Image(org.eclipse.swt.graphics.Image) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile)

Example 2 with RemoteContentProvider

use of org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider in project subclipse by subclipse.

the class ChooseUrlDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    // $NON-NLS-1$
    getShell().setText(Policy.bind("ChooseUrlDialog.title"));
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (message != null) {
        Label messageLabel = new Label(composite, SWT.NONE);
        messageLabel.setText(message);
    }
    if (multipleSelect)
        treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    else
        treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new RemoteContentProvider();
    contentProvider.setIncludeBranchesAndTags(includeBranchesAndTags);
    contentProvider.setResource(resource);
    treeViewer.setContentProvider(contentProvider);
    if (foldersOnly)
        treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    // treeViewer.setLabelProvider(new WorkbenchLabelProvider());
    treeViewer.setLabelProvider(new RemoteLabelProvider());
    ISVNRepositoryLocation repository = null;
    if (repositoryLocation == null) {
        if (resource == null)
            treeViewer.setInput(new AllRootsElement());
        else {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                LocalResourceStatus status = svnResource.getStatus();
                if (status != null) {
                    repository = svnResource.getStatus().getRepository();
                }
            } catch (SVNException e1) {
            }
            if (repository == null) {
                repository = svnResource.getRepository();
            }
            if (!repository.getUrl().toString().equals(repository.getRepositoryRoot().toString())) {
                RepositoryRootFolder rootFolder = new RepositoryRootFolder(repository, repository.getRepositoryRoot(), repository.getRootFolder().getRevision());
                contentProvider.setRootFolder(rootFolder);
            }
        }
    } else {
        repository = repositoryLocation;
    }
    if (repository == null)
        treeViewer.setInput(new AllRootsElement());
    else {
        try {
            repository.validateConnection(new NullProgressMonitor());
            treeViewer.setInput(repository);
        } catch (SVNException e) {
            MessageDialog.openError(getShell(), Policy.bind("ChooseUrlDialog.title"), e.getMessage());
            saveLocation = false;
            cancelPressed();
            return composite;
        }
    }
    GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    data.heightHint = LIST_HEIGHT_HINT;
    data.widthHint = LIST_WIDTH_HINT;
    treeViewer.getControl().setLayoutData(data);
    // when F5 is pressed, refresh
    treeViewer.getControl().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.F5) {
                refreshAction.run();
            }
        }
    });
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent e) {
            okPressed();
        }
    });
    // Create the popup menu
    MenuManager menuMgr = new MenuManager();
    Tree tree = treeViewer.getTree();
    Menu menu = menuMgr.createContextMenu(tree);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(newFolderAction);
            if (!treeViewer.getSelection().isEmpty())
                manager.add(deleteFolderAction);
            manager.add(refreshAction);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tree.setMenu(menu);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHOOSE_URL_DIALOG);
    return composite;
}
Also used : RepositoryRootFolder(org.tigris.subversion.subclipse.core.resources.RepositoryRootFolder) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

Example 3 with RemoteContentProvider

use of org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider in project subclipse by subclipse.

the class MoveRemoteResourceWizardMainPage method createControl.

/**
 * Creates the UI part of the page.
 *
 * @param parent the parent of the created widgets
 */
public void createControl(Composite parent) {
    Composite composite = createComposite(parent, 1);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.MOVE_RENAME_REMOTE_RESOURCE_PAGE);
    Listener listener = new Listener() {

        public void handleEvent(Event event) {
            resourceName = resourceNameText.getText();
            validateFields();
        }
    };
    // the text field for the parent folder
    createLabel(composite, // $NON-NLS-1$
    Policy.bind("MoveRemoteResourceWizardMainPage.selectParentUrl"));
    urlParentText = createTextField(composite);
    urlParentText.addListener(SWT.Selection, listener);
    urlParentText.addListener(SWT.Modify, listener);
    urlParentText.setEditable(false);
    // Create drill down.
    DrillDownComposite drillDown = new DrillDownComposite(composite, SWT.BORDER);
    GridData spec = new GridData(GridData.FILL_BOTH);
    spec.widthHint = LIST_WIDTH;
    spec.heightHint = LIST_HEIGHT;
    drillDown.setLayoutData(spec);
    // Create tree viewer inside drill down.
    viewer = new TreeViewer(drillDown, SWT.H_SCROLL | SWT.V_SCROLL);
    drillDown.setChildTree(viewer);
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setContentProvider(new RemoteContentProvider());
    viewer.setInput(new AllRootsElement());
    viewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    viewer.addSelectionChangedListener(treeSelectionChangedListener);
    // the text field for the resource name
    createLabel(composite, // $NON-NLS-1$
    Policy.bind("MoveRemoteResourceWizardMainPage.resourceName"));
    resourceNameText = createTextField(composite);
    resourceNameText.addListener(SWT.Selection, listener);
    resourceNameText.addListener(SWT.Modify, listener);
    resourceNameText.setText(resourceName);
    validateFields();
    resourceNameText.setFocus();
    setControl(composite);
    // set the initial selection in the tree
    if (parentFolder != null) {
        Object toSelect = null;
        if (parentFolder.getParent() == null) {
            // the root folder : select the repository
            toSelect = parentFolder.getRepository();
        } else
            toSelect = parentFolder;
        viewer.expandToLevel(toSelect, 0);
        viewer.setSelection(new StructuredSelection(toSelect), true);
    }
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) DrillDownComposite(org.eclipse.ui.part.DrillDownComposite) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DrillDownComposite(org.eclipse.ui.part.DrillDownComposite)

Example 4 with RemoteContentProvider

use of org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider in project subclipse by subclipse.

the class NewRemoteFolderWizardMainPage method createControl.

/**
 * Creates the UI part of the page.
 *
 * @param parent the parent of the created widgets
 */
public void createControl(Composite parent) {
    Composite composite = createComposite(parent, 1);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CREATE_REMOTE_FOLDER_PAGE);
    Listener listener = new Listener() {

        public void handleEvent(Event event) {
            validateFields();
        }
    };
    // the text field for the parent folder
    createLabel(composite, // $NON-NLS-1$
    Policy.bind("NewRemoteFolderWizardMainPage.selectParentUrl"));
    urlParentText = createTextField(composite);
    urlParentText.addListener(SWT.Selection, listener);
    urlParentText.addListener(SWT.Modify, listener);
    urlParentText.setEditable(false);
    // Create drill down.
    DrillDownComposite drillDown = new DrillDownComposite(composite, SWT.BORDER);
    GridData spec = new GridData(GridData.FILL_BOTH);
    spec.widthHint = LIST_WIDTH;
    spec.heightHint = LIST_HEIGHT;
    drillDown.setLayoutData(spec);
    // Create tree viewer inside drill down.
    viewer = new TreeViewer(drillDown, SWT.H_SCROLL | SWT.V_SCROLL);
    drillDown.setChildTree(viewer);
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    RemoteContentProvider remoteContentProvider = new RemoteContentProvider();
    remoteContentProvider.setUseDeferredContentManager(false);
    viewer.setContentProvider(remoteContentProvider);
    viewer.setInput(new AllRootsElement());
    viewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    viewer.addSelectionChangedListener(treeSelectionChangedListener);
    // the text field for the folder name
    // $NON-NLS-1$
    createLabel(composite, Policy.bind("NewRemoteFolderWizardMainPage.folderName"));
    folderNameText = createTextField(composite);
    folderNameText.addListener(SWT.Selection, listener);
    folderNameText.addListener(SWT.Modify, listener);
    validateFields();
    folderNameText.setFocus();
    setControl(composite);
    // set the initial selection in the tree
    if (parentFolder != null) {
        List itemsToExpand = new ArrayList();
        ISVNRemoteFolder remoteParent = parentFolder.getParent();
        while (remoteParent != null) {
            if (remoteParent.getParent() == null)
                itemsToExpand.add(0, remoteParent.getRepository());
            else
                itemsToExpand.add(0, remoteParent);
            remoteParent = remoteParent.getParent();
        }
        viewer.setExpandedElements(itemsToExpand.toArray());
        if (parentFolder.getParent() == null)
            viewer.setSelection(new StructuredSelection(parentFolder.getRepository()), true);
        else
            viewer.setSelection(new StructuredSelection(parentFolder), true);
    }
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) DrillDownComposite(org.eclipse.ui.part.DrillDownComposite) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DrillDownComposite(org.eclipse.ui.part.DrillDownComposite) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 AllRootsElement (org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement)4 RemoteContentProvider (org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider)4 GridData (org.eclipse.swt.layout.GridData)3 Composite (org.eclipse.swt.widgets.Composite)3 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 DrillDownComposite (org.eclipse.ui.part.DrillDownComposite)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 DecoratingLabelProvider (org.eclipse.jface.viewers.DecoratingLabelProvider)1