Search in sources :

Example 6 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class SVNHistoryPage method getRevisionRanges.

private SVNRevisionRange[] getRevisionRanges() {
    List revisionRanges = new ArrayList();
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        List selectionList = ss.toList();
        TableItem[] items = tableHistoryViewer.getTable().getItems();
        SVNRevision revision1 = null;
        SVNRevision revision2 = null;
        for (int i = 0; i < items.length; i++) {
            if (items[i].getData() instanceof ILogEntry) {
                ILogEntry logEntry = (ILogEntry) items[i].getData();
                if (selectionList.contains(logEntry)) {
                    if (revision1 == null) {
                        revision1 = logEntry.getRevision();
                    }
                    revision2 = logEntry.getRevision();
                    revertEnabled = true;
                    LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
                    if (changePaths != null) {
                        for (LogEntryChangePath changePath : changePaths) {
                            if (changePath.getPath().equals(remoteResource.getRepositoryRelativePath())) {
                                if (changePath.getAction() == 'A') {
                                    revertEnabled = false;
                                }
                                break;
                            }
                        }
                    }
                } else {
                    if (revision1 != null) {
                        SVNRevisionRange revisionRange = new SVNRevisionRange(revision1, revision2);
                        revisionRanges.add(revisionRange);
                        revision1 = null;
                        revision2 = null;
                    }
                }
            }
        }
        if (revision1 != null) {
            SVNRevisionRange revisionRange = new SVNRevisionRange(revision1, revision2);
            revisionRanges.add(revisionRange);
        }
    }
    SVNRevisionRange[] revisionRangeArray = new SVNRevisionRange[revisionRanges.size()];
    revisionRanges.toArray(revisionRangeArray);
    return revisionRangeArray;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) SVNRevisionRange(org.tigris.subversion.svnclientadapter.SVNRevisionRange) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) List(java.util.List) LinkList(org.tigris.subversion.subclipse.ui.util.LinkList) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 7 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class SVNHistoryPage method getCopyChangedPathAction.

private IAction getCopyChangedPathAction() {
    if (copyChangedPathAction == null) {
        copyChangedPathAction = new // $NON-NLS-1$
        Action(// $NON-NLS-1$
        Policy.bind("HistoryView.copyChangedPath")) {

            public void run() {
                ContainerSelectionDialog dialog = new ContainerSelectionDialog(Display.getDefault().getActiveShell(), null, false, // $NON-NLS-1$
                Policy.bind("CopyAction.selectionLabel"));
                if (dialog.open() == ContainerSelectionDialog.OK) {
                    Object[] result = dialog.getResult();
                    if (result == null || result.length == 0)
                        return;
                    final Path path = (Path) result[0];
                    IProject selectedProject;
                    File target = null;
                    if (path.segmentCount() == 1) {
                        selectedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.toString());
                        target = selectedProject.getLocation().toFile();
                    } else {
                        IFile targetFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
                        selectedProject = targetFile.getProject();
                        target = targetFile.getLocation().toFile();
                    }
                    final IProject targetProject = selectedProject;
                    final File destPath = target;
                    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                        public void run() {
                            ISVNClientAdapter client = null;
                            try {
                                IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
                                if (sel.getFirstElement() instanceof LogEntryChangePath) {
                                    LogEntryChangePath changePath = (LogEntryChangePath) sel.getFirstElement();
                                    SVNRevision revision = changePath.getRevision();
                                    if (changePath.getAction() == 'D') {
                                        long rev = Long.parseLong(revision.toString());
                                        rev--;
                                        revision = new SVNRevision.Number(rev);
                                    }
                                    client = SVNProviderPlugin.getPlugin().getSVNClient();
                                    client.copy(changePath.getUrl(), destPath, revision, revision, true, false);
                                    targetProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                                    SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
                                }
                            } catch (Exception e) {
                                MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.copyError"), // $NON-NLS-1$
                                e.getMessage());
                            } finally {
                                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                            }
                        }
                    });
                }
            }
        };
    }
    return copyChangedPathAction;
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) IFile(org.eclipse.core.resources.IFile) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) File(java.io.File) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 8 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class SVNHistoryPage method fillChangePathsMenu.

private void fillChangePathsMenu(IMenuManager manager) {
    // 
    // Commented out Get Contents, Revert and Switch options until when/if
    // they can be fixed.  Problem is that we need a way to get the local
    // resource from the LogEntryChangePath.
    // 
    IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
    if (sel.size() == 1) {
        if (sel.getFirstElement() instanceof LogEntryChangePath) {
        // manager.add(getGetContentsAction());
        }
        manager.add(getCreateTagFromRevisionChangedPathAction());
    }
    // manager.add(getRevertChangesChangedPathAction());
    // manager.add(getSwitchChangedPathAction());
    // $NON-NLS-1$
    manager.add(new Separator("exportImportGroup"));
    if (sel.size() == 1) {
        if (sel.getFirstElement() instanceof LogEntryChangePath) {
            manager.add(getExportAction());
            if (((LogEntryChangePath) sel.getFirstElement()).getAction() == 'D') {
                manager.add(getCopyChangedPathAction());
            }
        }
    }
    // $NON-NLS-1$
    manager.add(new Separator("openGroup"));
    if (sel.size() == 1) {
        if (sel.getFirstElement() instanceof LogEntryChangePath) {
            manager.add(getShowAnnotationAction());
        }
        manager.add(getCompareAction());
    }
    if (sel.getFirstElement() instanceof LogEntryChangePath) {
        manager.add(getOpenChangedPathAction());
    }
    if (sel.size() == 1)
        manager.add(getShowHistoryAction());
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Aggregations

LogEntryChangePath (org.tigris.subversion.subclipse.core.history.LogEntryChangePath)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 TeamException (org.eclipse.team.core.TeamException)5 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)4 SVNException (org.tigris.subversion.subclipse.core.SVNException)4 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)4 ParseException (java.text.ParseException)3 CoreException (org.eclipse.core.runtime.CoreException)3 PartInitException (org.eclipse.ui.PartInitException)3 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)3 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)3 MalformedURLException (java.net.MalformedURLException)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)2 ResourceEditionNode (org.tigris.subversion.subclipse.ui.compare.ResourceEditionNode)2 SVNCompareEditorInput (org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput)2 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)2