Search in sources :

Example 1 with ISVNResource

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

the class LocalFolder method getSVNFolders.

public IFolder[] getSVNFolders(IProgressMonitor monitor, final boolean unmanage) throws SVNException {
    final ArrayList<IFolder> svnFolders = new ArrayList<IFolder>();
    SVNProviderPlugin.run(new ISVNRunnable() {

        public void run(IProgressMonitor pm) throws SVNException {
            pm = Policy.monitorFor(pm);
            pm.beginTask(null, 100);
            ISVNResource[] members = members(Policy.subMonitorFor(pm, 20), FOLDER_MEMBERS | MANAGED_MEMBERS);
            ArrayList<IContainer> dirs = new ArrayList<IContainer>();
            for (ISVNResource member : members) {
                dirs.add((IContainer) ((ISVNLocalResource) member).getIResource());
            }
            // we add the current folder to the
            dirs.add((IContainer) getIResource());
            // list : we want to add .svn dir
            // for it too
            IProgressMonitor monitorDel = Policy.subMonitorFor(pm, 80);
            monitorDel.beginTask(null, dirs.size());
            for (IContainer container : dirs) {
                monitorDel.worked(1);
                recursiveGetSVNFolders(container, monitorDel, unmanage);
            }
            monitorDel.done();
            pm.done();
        }

        private void recursiveGetSVNFolders(IContainer container, IProgressMonitor pm, boolean unmanage) {
            try {
                // We must not add svn directories for linked resources.
                if (container.isLinked())
                    return;
                pm.beginTask(null, 10);
                pm.subTask(container.getFullPath().toOSString());
                IResource[] members = container.members(true);
                for (IResource member : members) {
                    pm.worked(1);
                    if (member.getType() != IResource.FILE) {
                        recursiveGetSVNFolders((IContainer) member, pm, unmanage);
                    }
                }
                // Post order traversal
                IFolder svnFolder = container.getFolder(new Path(SVNProviderPlugin.getPlugin().getAdminDirectoryName()));
                if (svnFolder.exists()) {
                    svnFolders.add(svnFolder);
                    if (unmanage) {
                        try {
                            svnFolder.delete(true, null);
                        } catch (CoreException e) {
                        }
                    }
                }
            } catch (CoreException e) {
            // Just ignore and continue
            } finally {
                pm.done();
            }
        }
    }, Policy.subMonitorFor(monitor, 99));
    IFolder[] folderArray = new IFolder[svnFolders.size()];
    svnFolders.toArray(folderArray);
    return folderArray;
}
Also used : Path(org.eclipse.core.runtime.Path) ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) ArrayList(java.util.ArrayList) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with ISVNResource

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

the class SVNHistoryPage method getSetCommitPropertiesAction.

private IAction getSetCommitPropertiesAction() {
    // set Action (context menu)
    if (setCommitPropertiesAction == null) {
        setCommitPropertiesAction = new // $NON-NLS-1$
        Action(// $NON-NLS-1$
        Policy.bind("HistoryView.setCommitProperties")) {

            public void run() {
                try {
                    final ISelection selection = getSelection();
                    if (!(selection instanceof IStructuredSelection))
                        return;
                    final ILogEntry ourSelection = getLogEntry((IStructuredSelection) selection);
                    // Failing that, try the resource originally selected by the user if
                    // from the Team menu
                    // TODO: Search all paths from currentSelection and find the
                    // shortest path and
                    // get the resources for that instance (in order to get the 'best'
                    // "bugtraq" properties)
                    final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : (ourSelection.getRemoteResource() != null) ? ProjectProperties.getProjectProperties(ourSelection.getRemoteResource()) : ProjectProperties.getProjectProperties(// will return null!
                    remoteResource);
                    final ISVNResource svnResource = ourSelection.getRemoteResource() != null ? ourSelection.getRemoteResource() : ourSelection.getResource();
                    SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(getSite().getShell(), ourSelection.getRevision(), resource, projectProperties);
                    // Set previous text - the text to edit
                    dialog.setOldAuthor(ourSelection.getAuthor());
                    dialog.setOldComment(ourSelection.getComment());
                    boolean doCommit = (dialog.open() == Window.OK);
                    if (doCommit) {
                        final String author;
                        final String commitComment;
                        if (ourSelection.getAuthor().equals(dialog.getAuthor()))
                            author = null;
                        else
                            author = dialog.getAuthor();
                        if (ourSelection.getComment().equals(dialog.getComment()))
                            commitComment = null;
                        else
                            commitComment = dialog.getComment();
                        final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(svnResource.getRepository(), ourSelection.getRevision(), commitComment, author);
                        PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {

                            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                                try {
                                    command.run(monitor);
                                } catch (SVNException e) {
                                    throw new InvocationTargetException(e);
                                } finally {
                                    if (ourSelection instanceof LogEntry) {
                                        LogEntry logEntry = (LogEntry) ourSelection;
                                        if (command.isLogMessageChanged())
                                            logEntry.setComment(commitComment);
                                        if (command.isAuthorChanged())
                                            logEntry.setAuthor(author);
                                    }
                                    getSite().getShell().getDisplay().asyncExec(new Runnable() {

                                        public void run() {
                                            tableHistoryViewer.refresh();
                                            tableHistoryViewer.setSelection(selection, true);
                                        }
                                    });
                                }
                            }
                        });
                    }
                } catch (InvocationTargetException e) {
                    SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_NONTEAM_EXCEPTIONS);
                } catch (InterruptedException e) {
                // Do nothing
                } catch (SVNException e) {
                    // TODO Auto-generated catch block
                    SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
                }
            }

            // we don't allow multiple selection
            public boolean isEnabled() {
                ISelection selection = getSelection();
                return selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
            }
        };
    }
    return setCommitPropertiesAction;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ChangeCommitPropertiesCommand(org.tigris.subversion.subclipse.core.commands.ChangeCommitPropertiesCommand) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) SetCommitPropertiesDialog(org.tigris.subversion.subclipse.ui.dialogs.SetCommitPropertiesDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry)

Example 3 with ISVNResource

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

the class ShowDifferencesAsUnifiedDiffAction method isEnabled.

protected boolean isEnabled() throws TeamException {
    Object[] selectedObjects = selection.toArray();
    if (selectedObjects.length == 0 || selectedObjects.length > 2)
        return false;
    ISVNResource svnResource1 = null;
    ISVNResource svnResource2 = null;
    if (selectedObjects[0] instanceof ISVNResource)
        svnResource1 = (ISVNResource) selectedObjects[0];
    else {
        if (selectedObjects[0] instanceof ILogEntry)
            svnResource1 = ((ILogEntry) selectedObjects[0]).getResource();
    }
    if (svnResource1 == null)
        return false;
    if (selectedObjects.length > 1) {
        if (selectedObjects[1] instanceof ISVNResource)
            svnResource2 = (ISVNResource) selectedObjects[1];
        else {
            if (selectedObjects[1] instanceof ILogEntry)
                svnResource2 = ((ILogEntry) selectedObjects[1]).getResource();
        }
        if (!svnResource1.getRepository().getRepositoryRoot().toString().equals(svnResource2.getRepository().getRepositoryRoot().toString()))
            return false;
        return (svnResource1.isFolder() == svnResource2.isFolder());
    }
    return true;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource)

Example 4 with ISVNResource

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

the class BaseFolder method members.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNFolder#members(org.eclipse.core.runtime.IProgressMonitor, int)
   */
public ISVNResource[] members(IProgressMonitor monitor, int flags) throws SVNException {
    final List<ISVNResource> result = new ArrayList<ISVNResource>();
    ISVNRemoteResource[] resources = getMembers(monitor);
    // RemoteFolders never have phantom members
    if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == 1) {
        return new ISVNResource[0];
    }
    boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
    boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
    boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
    for (ISVNResource svnResource : resources) {
        if ((includeFiles && (!svnResource.isFolder())) || (includeFolders && (svnResource.isFolder()))) {
            if (includeManaged) {
                result.add(svnResource);
            }
        }
    }
    return (ISVNResource[]) result.toArray(new ISVNResource[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 5 with ISVNResource

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

the class RemoteFolder method members.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNFolder#members(org.eclipse.core.runtime.IProgressMonitor, int)
   */
public ISVNResource[] members(IProgressMonitor monitor, int flags) throws SVNException {
    final List<ISVNResource> result = new ArrayList<ISVNResource>();
    ISVNRemoteResource[] resources = getMembers(monitor);
    // RemoteFolders never have phantom members
    if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == 1) {
        return new ISVNResource[0];
    }
    boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
    boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
    boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
    for (ISVNResource svnResource : resources) {
        if ((includeFiles && (!svnResource.isFolder())) || (includeFolders && (svnResource.isFolder()))) {
            if (includeManaged) {
                result.add(svnResource);
            }
        }
    }
    return (ISVNResource[]) result.toArray(new ISVNResource[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Aggregations

ISVNResource (org.tigris.subversion.subclipse.core.ISVNResource)8 ArrayList (java.util.ArrayList)3 IResource (org.eclipse.core.resources.IResource)3 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)3 SVNException (org.tigris.subversion.subclipse.core.SVNException)3 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IContainer (org.eclipse.core.resources.IContainer)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 TeamException (org.eclipse.team.core.TeamException)2 ProjectProperties (org.tigris.subversion.subclipse.ui.settings.ProjectProperties)2 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)2 IFolder (org.eclipse.core.resources.IFolder)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TaskRepositoryManager (org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager)1