Search in sources :

Example 61 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class MergeWizardUnblockRevisionsPage method refresh.

private void refresh() {
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                monitor.setTaskName(Messages.MergeWizardUnblockRevisionsPage_retrievingRemoteResource);
                monitor.beginTask(Messages.MergeWizardUnblockRevisionsPage_retrievingRemoteResource, 2);
                monitor.worked(1);
                remoteResource = repositoryLocation.getRemoteFile(new SVNUrl(fromUrl));
                monitor.worked(1);
                monitor.done();
            } catch (Exception e) {
                Activator.handleError(e);
            }
        }
    };
    setPageComplete(false);
    setErrorMessage(null);
    fromUrl = standardPage.getFromUrl();
    ISVNMergeInfo mergeInfo = standardPage.getMergeInfo();
    if (mergeInfo == null) {
        entries = new ILogEntry[0];
        return;
    }
    revisionRanges = mergeInfo.getRevisionRange(fromUrl);
    remoteResource = null;
    try {
        getContainer().run(false, false, runnable);
        if (remoteResource == null) {
            setErrorMessage(Messages.MergeWizardUnblockRevisionsPage_errorRetrievingRemoteResource);
            entries = new ILogEntry[0];
        } else
            getLogEntries();
    } catch (Exception e) {
        setErrorMessage(e.getMessage());
        entries = new ILogEntry[0];
    }
    if (tableHistoryViewer.getInput() == null)
        tableHistoryViewer.setInput(fromUrl);
    else
        tableHistoryViewer.refresh();
    setPageComplete(canFinish());
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISVNMergeInfo(org.tigris.subversion.svnclientadapter.ISVNMergeInfo) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 62 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class MergeWizardAdvancedPage method showLog.

private void showLog(Text text) {
    ISVNRemoteResource remoteResource = null;
    if (text == fromRevisionText) {
        try {
            fromUrl = new SVNUrl(getUrl(getFrom()));
            remoteResource = svnResource.getRepository().getRemoteFile(fromUrl);
        } catch (Exception e) {
            Activator.handleError(Messages.MergeWizardAdvancedPage_showLogError, e);
            MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, e.toString());
            return;
        }
        if (remoteResource == null) {
            MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, Messages.MergeWizardAdvancedPage_invalidUrl + getFrom());
            return;
        }
    }
    if (text == toRevisionText) {
        try {
            toUrl = new SVNUrl(getUrl(getTo()));
            remoteResource = svnResource.getRepository().getRemoteFile(toUrl);
        } catch (Exception e) {
            Activator.handleError(Messages.MergeWizardAdvancedPage_showLogError, e);
            MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, e.toString());
            return;
        }
        if (remoteResource == null) {
            MessageDialog.openError(getShell(), Messages.MergeWizardAdvancedPage_showLog, Messages.MergeWizardAdvancedPage_invalidUrl + getTo());
            return;
        }
    }
    HistoryDialog dialog = null;
    if ((text == fromRevisionText) || (text == toRevisionText))
        dialog = new HistoryDialog(getShell(), remoteResource);
    else
        dialog = new HistoryDialog(getShell(), resource);
    if (dialog.open() == HistoryDialog.CANCEL)
        return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0)
        return;
    if ((text != null) && useFromButton.getSelection()) {
        fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber() - 1));
        fromRevisionButton.setSelection(true);
        fromHeadButton.setSelection(false);
        toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
        toRevisionButton.setSelection(true);
        toHeadButton.setSelection(false);
        fromRevisionText.setEnabled(true);
        toRevisionText.setEnabled(true);
        return;
    }
    if ((text == fromRevisionText) || ((text == null) && (fromRevisionText.getText().trim().length() == 0))) {
        fromRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
        fromRevisionButton.setSelection(true);
        fromHeadButton.setSelection(false);
        fromRevisionText.setEnabled(true);
    }
    if (text == toRevisionText) {
        toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
        toRevisionButton.setSelection(true);
        toHeadButton.setSelection(false);
        toRevisionText.setEnabled(true);
    }
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ParseException(java.text.ParseException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException)

Example 63 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class MergeWizardAdvancedPage method initializeLocations.

private void initializeLocations() {
    combosInitialized = true;
    MergeWizard wizard = (MergeWizard) getWizard();
    resource = wizard.getResource();
    resources = wizard.getResources();
    svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    mergeInfoPaths = null;
    repositoryLocation = svnResource.getRepository().getLocation();
    if (((MergeWizard) getWizard()).suggestMergeSources()) {
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.setTaskName(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo);
                monitor.beginTask(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo, IProgressMonitor.UNKNOWN);
                // $NON-NLS-1$
                monitor.subTask("");
                ISVNClientAdapter svnClient = null;
                try {
                    svnClient = svnResource.getRepository().getSVNClient();
                    try {
                        mergeInfoPaths = svnClient.suggestMergeSources(new SVNUrl(commonRoot), SVNRevision.HEAD);
                    } catch (Exception e1) {
                    }
                } catch (Exception e) {
                    Activator.handleError(e);
                } finally {
                    svnResource.getRepository().returnSVNClient(svnClient);
                }
                monitor.done();
            }
        };
        try {
            getContainer().run(true, false, runnable);
        } catch (Exception e2) {
            Activator.handleError(e2);
        }
    }
    boolean valueAdded = false;
    List<String> fromUrls = new ArrayList<String>();
    if (mergeInfoPaths != null) {
        for (int i = 0; i < mergeInfoPaths.length; i++) {
            String url = mergeInfoPaths[i].substring(repositoryLocation.length());
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
    }
    String previousFromUrls = null;
    String previousFromUrl = null;
    try {
        previousFromUrls = Activator.getDefault().getDialogSettings().get("mergeFromUrls_" + commonRoot);
    } catch (Exception e) {
    }
    if (previousFromUrls != null) {
        String[] urls = previousFromUrls.split("\\,");
        for (String url : urls) {
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
        if (urls.length > 0)
            previousFromUrl = urls[0];
    }
    if (!valueAdded && commonRoot != null) {
        fromUrls.add(commonRoot.substring(repositoryLocation.length()));
    }
    for (String url : fromUrls) {
        fromCombo.add(url);
        toCombo.add(url);
    }
    if (previousFromUrl != null)
        fromCombo.setText(previousFromUrl);
    else if (fromCombo.getItemCount() > 0)
        fromCombo.setText(fromCombo.getItem(0));
    if (fromCombo.getText() != null && fromCombo.getText().length() > 0) {
        try {
            String previousToUrl = Activator.getDefault().getDialogSettings().get("mergeToUrl_" + fromCombo.getText());
            if (previousToUrl != null) {
                if (toCombo.indexOf(previousToUrl) == -1) {
                    toCombo.add(previousToUrl);
                }
                try {
                    boolean useFromDeselected = Activator.getDefault().getDialogSettings().getBoolean("mergeUseFromDeselected_" + fromCombo.getText());
                    if (useFromDeselected) {
                        useFromButton.setSelection(false);
                    }
                } catch (Exception e) {
                }
                if (!useFromButton.getSelection()) {
                    toCombo.setVisible(true);
                    toCombo.setText(previousToUrl);
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 64 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class MergeResultsView method createPartControl.

public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 2;
    parent.setLayout(layout);
    treeViewer = new TreeViewer(parent);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setContentProvider(new MergeResultsViewContentProvider());
    treeViewer.setUseHashlookup(true);
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    treeViewer.getControl().setLayoutData(layoutData);
    treeViewer.setInput(this);
    treeViewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent event) {
            treeConflict = null;
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Object selectedItem = selection.getFirstElement();
            MergeResult mergeResult = null;
            if (selectedItem instanceof AdaptableMergeResult)
                mergeResult = (MergeResult) selectedItem;
            if (selectedItem instanceof AdaptableMergeResultsFolder) {
                MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedItem;
                mergeResult = mergeResultsFolder.getMergeResult();
            }
            if (mergeResult != null) {
                if (mergeResult.getResource() instanceof IFile && mergeResult.isConflicted() && !mergeResult.isResolved()) {
                    editConflicts(mergeResult);
                    return;
                }
                if (mergeResult.getResource() instanceof IFile && mergeResult.hasTreeConflict() && !mergeResult.isTreeConflictResolved()) {
                    boolean addAddConflict = false;
                    if (mergeResult.getResource() != null && mergeResult.getResource().exists()) {
                        treeConflict = getTreeConflict(mergeResult.getResource());
                        if (treeConflict != null && treeConflict.getDescription() != null && treeConflict.getDescription().contains("local add") && treeConflict.getDescription().contains("incoming add")) {
                            // $NON-NLS-1$ //$NON-NLS-2$
                            addAddConflict = true;
                        }
                        if (!addAddConflict) {
                            openAction.run();
                        }
                    }
                    if (!addAddConflict) {
                        return;
                    }
                }
                if (!mergeResult.getAction().equals(MergeResult.ACTION_DELETE)) {
                    final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(mergeResult.getResource());
                    if (!localResource.exists()) {
                        return;
                    }
                    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                        public void run() {
                            try {
                                if (treeConflict != null) {
                                    if (!localResource.isFolder()) {
                                        SVNConflictDescriptor descriptor = treeConflict.getConflictDescriptor();
                                        SVNConflictVersion rightVersion = descriptor.getSrcRightVersion();
                                        try {
                                            ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), new SVNUrl(rightVersion.getReposURL() + "/" + rightVersion.getPathInRepos()), new SVNRevision.Number(rightVersion.getPegRevision()));
                                            SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
                                            CompareUI.openCompareEditorOnPage(compareInput, getSite().getPage());
                                        } catch (Exception e) {
                                        }
                                    }
                                    return;
                                }
                                CompareUI.openCompareEditorOnPage(new SVNLocalCompareInput(localResource, SVNRevision.BASE), getSite().getPage());
                            } catch (SVNException e) {
                                if (!e.operationInterrupted()) {
                                    Activator.handleError(Messages.MergeResultsView_compareError, e);
                                    MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
                                }
                            } catch (SVNClientException e) {
                                Activator.handleError(Messages.MergeResultsView_compareError, e);
                                MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
                            }
                        }
                    });
                }
            }
        }
    });
    treeViewer.getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            boolean mergeOutputSelected = false;
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                if (iter.next() instanceof MergeOutput) {
                    mergeOutputSelected = true;
                    break;
                }
            }
            removeAction.setEnabled(mergeOutputSelected);
        }
    });
    createMenus();
    createToolbar();
    getSite().setSelectionProvider(treeViewer);
    if (Activator.getDefault().getPreferenceStore().getBoolean(CONFLICTS_ONLY_PREFERENCE))
        setContentDescription(Messages.MergeResultsView_conflictsMode);
}
Also used : IFile(org.eclipse.core.resources.IFile) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MergeResult(com.collabnet.subversion.merge.MergeResult) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) GridLayout(org.eclipse.swt.layout.GridLayout) AdaptableMergeResultsFolder(com.collabnet.subversion.merge.AdaptableMergeResultsFolder) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) SVNConflictVersion(org.tigris.subversion.svnclientadapter.SVNConflictVersion) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) AdaptableMergeResultsFolder(com.collabnet.subversion.merge.AdaptableMergeResultsFolder) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SVNConflictDescriptor(org.tigris.subversion.svnclientadapter.SVNConflictDescriptor) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 65 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class ShowRemoteHistoryAction method getSelectedRemoteResources.

protected ISVNRemoteResource[] getSelectedRemoteResources() {
    MergeOutput mergeOutput = null;
    ISVNRemoteResource remoteResource = null;
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeResult) {
            MergeResult mergeResult = (MergeResult) object;
            IResource resource = mergeResult.getResource();
            mergeOutput = mergeResult.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
        if (object instanceof MergeResultsFolder) {
            MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
            IContainer folder = mergeResultsFolder.getFolder();
            mergeOutput = mergeResultsFolder.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
            try {
                String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
    }
    if (remoteResource != null) {
        ISVNRemoteResource[] selectedResource = { remoteResource };
        SVNRevision.Number startRevision = null;
        try {
            startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
        } catch (ParseException e) {
        }
        SVNRevision.Number endRevision = null;
        if (mergeOutput.getUpperRevision() > 0) {
            try {
                endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
            } catch (ParseException e) {
            }
        }
        HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
        SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
        return selectedResource;
    }
    return new ISVNRemoteResource[0];
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) MergeResult(com.collabnet.subversion.merge.MergeResult) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ParseException(java.text.ParseException) MergeOutput(com.collabnet.subversion.merge.MergeOutput) Iterator(java.util.Iterator) HistorySearchViewerFilter(org.tigris.subversion.subclipse.ui.history.HistorySearchViewerFilter) MergeOptions(com.collabnet.subversion.merge.MergeOptions) ParseException(java.text.ParseException) IContainer(org.eclipse.core.resources.IContainer) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Aggregations

SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)83 SVNException (org.tigris.subversion.subclipse.core.SVNException)29 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)26 MalformedURLException (java.net.MalformedURLException)25 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)21 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 ParseException (java.text.ParseException)18 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)17 IResource (org.eclipse.core.resources.IResource)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)14 TeamException (org.eclipse.team.core.TeamException)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)13 ArrayList (java.util.ArrayList)12 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)8