Search in sources :

Example 6 with MergeOutput

use of com.collabnet.subversion.merge.MergeOutput in project subclipse by subclipse.

the class MergeViewResolveAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    boolean treeConflictDialogShown = false;
    boolean compare = false;
    mergePath = null;
    if (showDialog) {
        List resources = new ArrayList();
        Iterator iter = fSelection.iterator();
        boolean folderSelected = false;
        boolean textConflicts = false;
        boolean propertyConflicts = false;
        boolean treeConflicts = false;
        while (iter.hasNext()) {
            MergeResult mergeResult = null;
            Object selectedObject = iter.next();
            if (selectedObject instanceof MergeResult)
                mergeResult = (MergeResult) selectedObject;
            if (selectedObject instanceof MergeResultsFolder) {
                folderSelected = true;
                MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedObject;
                resources.add(mergeResultsFolder.getFolder());
                mergeResult = mergeResultsFolder.getMergeResult();
            }
            if (mergeResult != null && (mergeResult.hasTreeConflict() || mergeResult.isConflicted() || mergeResult.isPropertyConflicted())) {
                if (mergeResult.isConflicted())
                    textConflicts = true;
                if (mergeResult.isPropertyConflicted())
                    propertyConflicts = true;
                if (mergeResult.hasTreeConflict())
                    treeConflicts = true;
                if (!(selectedObject instanceof MergeResultsFolder)) {
                    resources.add(mergeResult.getResource());
                }
            }
        }
        if (resources.size() > 1) {
            if (!MessageDialog.openConfirm(getShell(), Messages.MergeViewResolveAction_confirm, Messages.MergeViewResolveAction_confirmMultiple))
                return;
            setResolution(ISVNConflictResolver.Choice.chooseMerged);
        } else if (treeConflicts) {
            IResource resource = (IResource) resources.get(0);
            treeConflict = getTreeConflict(resource);
            if (treeConflict == null) {
                String message = Messages.MergeViewResolveAction_confirmTreeConflict + resource.getName() + // $NON-NLS-1$
                "?";
                if (!MessageDialog.openConfirm(getShell(), Messages.MergeViewResolveAction_confirm, message))
                    return;
                setResolution(ISVNConflictResolver.Choice.chooseMerged);
            } else {
                ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, getTargetPart());
                WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
                "ResolveTreeConflict");
                if (dialog.open() != WizardDialog.OK)
                    return;
                treeConflictDialogShown = true;
                compare = wizard.isCompare();
                mergePath = wizard.getMergePath();
            }
        } else if (folderSelected) {
            IResource resource = (IResource) resources.get(0);
            String message = Messages.MergeViewResolveAction_confirmProperty + resource.getFullPath() + // $NON-NLS-1$
            "?";
            if (!MessageDialog.openConfirm(getShell(), Messages.MergeViewResolveAction_confirm, message))
                return;
            selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
            setResolution(selectedResolution);
        } else {
            IResource[] resourceArray = new IResource[resources.size()];
            resources.toArray(resourceArray);
            DialogWizard dialogResolveWizard = new DialogWizard(DialogWizard.MARK_RESOLVED);
            dialogResolveWizard.setResources(resourceArray);
            dialogResolveWizard.setTextConflicts(textConflicts);
            dialogResolveWizard.setPropertyConflicts(propertyConflicts);
            dialogResolveWizard.setTreeConflicts(treeConflicts);
            MergeWizardDialog resolveDialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogResolveWizard);
            if (resolveDialog.open() == MergeWizardDialog.CANCEL)
                return;
            selectedResolution = dialogResolveWizard.getResolution();
            setResolution(selectedResolution);
        }
    }
    if (!treeConflictDialogShown)
        super.execute(action);
    ArrayList mergeOutputs = new ArrayList();
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        MergeResult mergeResult = null;
        Object selectedObject = iter.next();
        if (selectedObject instanceof MergeResult)
            mergeResult = (MergeResult) selectedObject;
        if (selectedObject instanceof MergeResultsFolder) {
            MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedObject;
            mergeResult = mergeResultsFolder.getMergeResult();
        }
        if (mergeResult != null && (mergeResult.hasTreeConflict() || mergeResult.isConflicted() || mergeResult.isPropertyConflicted())) {
            if (!compare) {
                String conflictResolution = Integer.toString(selectedResolution);
                mergeResult.setConflictResolution(conflictResolution);
                mergeResult.setPropertyResolution(conflictResolution);
                mergeResult.setTreeConflictResolution(conflictResolution);
                if (mergePath != null) {
                    MergeResult[] allResults = mergeResult.getMergeOutput().getMergeResults();
                    for (MergeResult checkResult : allResults) {
                        if (checkResult.getResource().getLocation().toFile().equals(mergePath)) {
                            try {
                                LocalResourceStatus status = SVNProviderPlugin.getPlugin().getStatusCacheManager().getStatus(checkResult.getResource());
                                if (status.isTextConflicted()) {
                                    checkResult.setAction(MergeResult.ACTION_CONFLICT);
                                    checkResult.setConflictResolution(" ");
                                    checkResult.setError(true);
                                }
                            } catch (SVNException e) {
                            }
                            break;
                        }
                    }
                }
            }
            if (!mergeOutputs.contains(mergeResult.getMergeOutput()))
                mergeOutputs.add(mergeResult.getMergeOutput());
        }
    }
    iter = mergeOutputs.iterator();
    while (iter.hasNext()) {
        MergeOutput mergeOutput = (MergeOutput) iter.next();
        mergeOutput.store();
    }
    MergeResultsView.getView().refresh();
    iter = mergeOutputs.iterator();
    while (iter.hasNext()) {
        MergeOutput mergeOutput = (MergeOutput) iter.next();
        if (!mergeOutput.hasUnresolvedConflicts()) {
            DialogWizard dialogWizard = new DialogWizard(DialogWizard.CONFLICTS_RESOLVED);
            dialogWizard.setMergeOutput(mergeOutput);
            MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
            if (dialog.open() != MergeWizardDialog.CANCEL)
                MergeResultsView.getView().refresh();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MergeResult(com.collabnet.subversion.merge.MergeResult) ResolveTreeConflictWizard(org.tigris.subversion.subclipse.ui.conflicts.ResolveTreeConflictWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) Iterator(java.util.Iterator) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) MergeOutput(com.collabnet.subversion.merge.MergeOutput) DialogWizard(com.collabnet.subversion.merge.wizards.DialogWizard) ArrayList(java.util.ArrayList) List(java.util.List) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Example 7 with MergeOutput

use of com.collabnet.subversion.merge.MergeOutput in project subclipse by subclipse.

the class ResumeMergeAction method selectionChanged.

public void selectionChanged(IAction action, ISelection sel) {
    boolean enabled = true;
    if (sel instanceof IStructuredSelection) {
        fSelection = (IStructuredSelection) sel;
        Iterator iter = fSelection.iterator();
        iterTag: while (iter.hasNext()) {
            Object selectedObject = iter.next();
            if (!(selectedObject instanceof MergeOutput)) {
                enabled = false;
                break;
            }
            MergeOutput mergeOutput = (MergeOutput) selectedObject;
            if (!mergeOutput.isIncomplete()) {
                enabled = false;
                break;
            }
            MergeResult[] conflictedMergeResults = mergeOutput.getConflictedMergeResults();
            for (int i = 0; i < conflictedMergeResults.length; i++) {
                if (!conflictedMergeResults[i].isResolved()) {
                    enabled = false;
                    break iterTag;
                }
            }
        }
    }
    action.setEnabled(enabled);
}
Also used : Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with MergeOutput

use of com.collabnet.subversion.merge.MergeOutput 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)

Example 9 with MergeOutput

use of com.collabnet.subversion.merge.MergeOutput in project subclipse by subclipse.

the class DeleteMergeOutputAction method run.

public void run(IAction action) {
    ArrayList deletions = new ArrayList();
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeOutput) {
            deletions.add(object);
        }
    }
    if (deletions.size() == 0)
        return;
    String message;
    if (deletions.size() == 1) {
        MergeOutput mergeOutput = (MergeOutput) deletions.get(0);
        message = Messages.DeleteMergeOutputAction_confirm + mergeOutput.getEditableValue() + // $NON-NLS-1$
        "'?";
    } else {
        message = Messages.DeleteMergeOutputAction_confirmMultiple + deletions.size() + Messages.DeleteMergeOutputAction_confirmMultiple2;
    }
    if (!MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.DeleteMergeOutputAction_title, message))
        return;
    iter = deletions.iterator();
    while (iter.hasNext()) {
        MergeOutput mergeOutput = (MergeOutput) iter.next();
        mergeOutput.delete();
    }
    if (MergeResultsView.getView() != null)
        MergeResultsView.getView().refresh();
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput)

Aggregations

MergeOutput (com.collabnet.subversion.merge.MergeOutput)9 Iterator (java.util.Iterator)7 MergeResult (com.collabnet.subversion.merge.MergeResult)5 MergeResultsFolder (com.collabnet.subversion.merge.MergeResultsFolder)5 ArrayList (java.util.ArrayList)4 DialogWizard (com.collabnet.subversion.merge.wizards.DialogWizard)3 MergeWizardDialog (com.collabnet.subversion.merge.wizards.MergeWizardDialog)3 IResource (org.eclipse.core.resources.IResource)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 AdaptableMergeResult (com.collabnet.subversion.merge.AdaptableMergeResult)1 AdaptableMergeResultsFolder (com.collabnet.subversion.merge.AdaptableMergeResultsFolder)1 MergeOptions (com.collabnet.subversion.merge.MergeOptions)1 UndoMergeOperation (com.collabnet.subversion.merge.UndoMergeOperation)1 ParseException (java.text.ParseException)1 List (java.util.List)1 IContainer (org.eclipse.core.resources.IContainer)1