Search in sources :

Example 21 with ISVNRemoteFolder

use of org.tigris.subversion.subclipse.core.ISVNRemoteFolder in project subclipse by subclipse.

the class CheckoutWizardSelectionPage method createControl.

public void createControl(Composite parent) {
    Composite outerContainer = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    outerContainer.setLayout(layout);
    outerContainer.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
    RepositoryContentProvider contentProvider = new RepositoryContentProvider();
    treeViewer.setContentProvider(contentProvider);
    treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    treeViewer.setLabelProvider(new WorkbenchLabelProvider());
    treeViewer.setInput(repositoryLocation);
    GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    data.heightHint = LIST_HEIGHT_HINT;
    data.widthHint = LIST_WIDTH_HINT;
    treeViewer.getControl().setLayoutData(data);
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            CheckoutWizard wizard = (CheckoutWizard) getWizard();
            ArrayList folderArray = new ArrayList();
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                Object object = iter.next();
                if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) {
                    if (object instanceof ISVNRepositoryLocation)
                        folderArray.add(((ISVNRepositoryLocation) object).getRootFolder());
                    else
                        folderArray.add(object);
                }
            }
            ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()];
            folderArray.toArray(remoteFolders);
            wizard.setRemoteFolders(remoteFolders);
            setPageComplete(!treeViewer.getSelection().isEmpty());
        }
    });
    final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_REFRESH)) {

        public void run() {
            refreshViewerNode();
        }
    };
    MenuManager menuMgr = new MenuManager();
    Tree tree = treeViewer.getTree();
    Menu menu = menuMgr.createContextMenu(tree);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(refreshAction);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tree.setMenu(menu);
    // $NON-NLS-1$
    setMessage(Policy.bind("CheckoutWizardSelectionPage.text"));
    setControl(outerContainer);
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) GridData(org.eclipse.swt.layout.GridData) Iterator(java.util.Iterator) 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)

Example 22 with ISVNRemoteFolder

use of org.tigris.subversion.subclipse.core.ISVNRemoteFolder in project subclipse by subclipse.

the class NewRemoteFolderWizard method performFinish.

/*
   * @see IWizard#performFinish
   */
public boolean performFinish() {
    try {
        final String folderName = mainPage.getFolderName();
        final String comment = commitCommentPage.getComment();
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                try {
                    ISVNRemoteFolder parentFolder = mainPage.getParentFolder();
                    parentFolder.createRemoteFolder(folderName, comment, monitor);
                } catch (SVNException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
        new ProgressMonitorDialog(getShell()).run(true, false, runnable);
    } catch (InterruptedException e) {
    // operation canceled
    } catch (InvocationTargetException e) {
        SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("exception"), null, e.getCause(), // $NON-NLS-1$
        SVNUIPlugin.PERFORM_SYNC_EXEC);
        return false;
    }
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 23 with ISVNRemoteFolder

use of org.tigris.subversion.subclipse.core.ISVNRemoteFolder 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)

Example 24 with ISVNRemoteFolder

use of org.tigris.subversion.subclipse.core.ISVNRemoteFolder in project subclipse by subclipse.

the class RemoteFolderElement method fetchDeferredChildren.

public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) {
    // If it's not a folder, return an empty array
    if (!(o instanceof ISVNRemoteFolder)) {
        collector.add(new Object[0], monitor);
    }
    try {
        monitor = Policy.monitorFor(monitor);
        monitor.beginTask(Policy.bind("RemoteFolderElement_fetchingRemoteMembers.message", getLabel(o)), // $NON-NLS-1$
        100);
        FetchMembersOperation operation = new FetchMembersOperation(null, (ISVNRemoteFolder) o, collector);
        operation.run(Policy.subMonitorFor(monitor, 100));
    } catch (InvocationTargetException e) {
        SVNUIPlugin.openError(null, null, null, e);
    } catch (InterruptedException e) {
    // Cancelled by the user;
    } finally {
        monitor.done();
    }
}
Also used : FetchMembersOperation(org.tigris.subversion.subclipse.ui.operations.FetchMembersOperation) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 25 with ISVNRemoteFolder

use of org.tigris.subversion.subclipse.core.ISVNRemoteFolder in project subclipse by subclipse.

the class RemoteFolderElement method getParent.

/**
 * Return null.
 */
public Object getParent(Object o) {
    if (!(o instanceof ISVNRemoteFolder))
        return null;
    ISVNRemoteFolder folder = (ISVNRemoteFolder) o;
    ISVNRemoteFolder parentFolder = folder.getParent();
    if (parentFolder != null)
        return parentFolder;
    else {
        return folder.getRepository();
    }
}
Also used : ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder)

Aggregations

ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)33 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 SVNException (org.tigris.subversion.subclipse.core.SVNException)9 ArrayList (java.util.ArrayList)8 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 IResource (org.eclipse.core.resources.IResource)6 TeamException (org.eclipse.team.core.TeamException)6 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)6 Iterator (java.util.Iterator)5 IProject (org.eclipse.core.resources.IProject)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 GridData (org.eclipse.swt.layout.GridData)5 Composite (org.eclipse.swt.widgets.Composite)5 List (java.util.List)4 CoreException (org.eclipse.core.runtime.CoreException)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)4 File (java.io.File)3