Search in sources :

Example 1 with MergeOutput

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

the class ResumeMergeAction method run.

public void run(IAction action) {
    DialogWizard dialogWizard = new DialogWizard(DialogWizard.RESUME_MERGE);
    MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
    if (dialog.open() == MergeWizardDialog.CANCEL)
        return;
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object selectedObject = iter.next();
        if (selectedObject instanceof MergeOutput) {
            MergeOutput mergeOutput = (MergeOutput) selectedObject;
            mergeOutput.resume();
        }
    }
}
Also used : Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) DialogWizard(com.collabnet.subversion.merge.wizards.DialogWizard) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog)

Example 2 with MergeOutput

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

the class UndoMergeAction method run.

public void run(IAction action) {
    DialogWizard dialogWizard = new DialogWizard(DialogWizard.UNDO_MERGE_WARNING);
    MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
    if (dialog.open() == MergeWizardDialog.CANCEL)
        return;
    final ArrayList resources = new ArrayList();
    ArrayList mergeOutputs = new ArrayList();
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeOutput) {
            MergeOutput mergeOutput = (MergeOutput) object;
            mergeOutputs.add(mergeOutput);
            IResource resource = mergeOutput.getResource();
            resources.add(resource);
        }
    }
    final IResource[] resourceArray = new IResource[resources.size()];
    resources.toArray(resourceArray);
    UndoMergeOperation undoMergeOperation = new UndoMergeOperation(MergeResultsView.getView(), resourceArray);
    try {
        undoMergeOperation.run();
    } catch (Exception e) {
        Activator.handleError(Messages.UndoMergeAction_error, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.UndoMergeAction_title, e.getMessage());
        return;
    }
    iter = mergeOutputs.iterator();
    while (iter.hasNext()) {
        MergeOutput mergeOutput = (MergeOutput) iter.next();
        mergeOutput.delete();
    }
    MergeResultsView.getView().refresh();
    dialogWizard = new DialogWizard(DialogWizard.UNDO_MERGE_COMPLETED);
    dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
    if (dialog.open() == MergeWizardDialog.CANCEL)
        return;
    RevertAction revertAction = new RevertAction();
    revertAction.setShowNothingToRevertMessage(false);
    IStructuredSelection selection = new IStructuredSelection() {

        public Object getFirstElement() {
            return resourceArray[0];
        }

        public Iterator iterator() {
            return toList().iterator();
        }

        public int size() {
            return resourceArray.length;
        }

        public Object[] toArray() {
            return resourceArray;
        }

        public List toList() {
            return resources;
        }

        public boolean isEmpty() {
            return resources.isEmpty();
        }
    };
    revertAction.selectionChanged(null, selection);
    revertAction.run(null);
}
Also used : RevertAction(org.tigris.subversion.subclipse.ui.actions.RevertAction) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) DialogWizard(com.collabnet.subversion.merge.wizards.DialogWizard) UndoMergeOperation(com.collabnet.subversion.merge.UndoMergeOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog) IResource(org.eclipse.core.resources.IResource)

Example 3 with MergeOutput

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

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

the class MergeResultsViewContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    int mode = store.getInt(MergeResultsView.LAYOUT_PREFERENCE);
    boolean conflictsOnly = store.getBoolean(MergeResultsView.CONFLICTS_ONLY_PREFERENCE);
    if (parentElement instanceof MergeResultsView) {
        return MergeOutput.getMergeOutputs();
    }
    if (parentElement instanceof MergeOutput) {
        MergeOutput mergeOutput = (MergeOutput) parentElement;
        if (mode == MergeResultsView.MODE_FLAT) {
            if (conflictsOnly)
                return mergeOutput.getConflictedMergeResults();
            else
                // else return mergeOutput.getNonSkippedMergeResults();
                return mergeOutput.getMergeResults();
        }
        if (mode == MergeResultsView.MODE_COMPRESSED_FOLDERS) {
            MergeResult[] rootMergeResults = mergeOutput.getRootMergeResults(conflictsOnly);
            MergeResultsFolder[] mergeResultFolders = mergeOutput.getCompressedFolders(conflictsOnly);
            ArrayList returnObjects = new ArrayList();
            for (int i = 0; i < mergeResultFolders.length; i++) returnObjects.add(mergeResultFolders[i]);
            for (int i = 0; i < rootMergeResults.length; i++) returnObjects.add(rootMergeResults[i]);
            Object[] returnArray = new Object[returnObjects.size()];
            returnObjects.toArray(returnArray);
            return returnArray;
        }
    }
    if (parentElement instanceof MergeResultsFolder) {
        MergeResultsFolder folder = (MergeResultsFolder) parentElement;
        if (folder.isCompressed()) {
            return folder.getMergeResults(conflictsOnly);
        }
    }
    return new Object[0];
}
Also used : MergeOutput(com.collabnet.subversion.merge.MergeOutput) MergeResult(com.collabnet.subversion.merge.MergeResult) ArrayList(java.util.ArrayList) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Example 5 with MergeOutput

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

the class MergeResultsViewLabelProvider method getImage.

public Image getImage(Object element) {
    if (element instanceof MergeOutput) {
        Image image = null;
        if (((MergeOutput) element).isIncomplete())
            image = Activator.getImage(Activator.IMAGE_MERGE_OUTPUT_ABORTED);
        else {
            if (((MergeOutput) element).isAbnormalEnd())
                image = Activator.getImage(Activator.IMAGE_MERGE_OUTPUT_ABNORMAL);
            else if (((MergeOutput) element).isInProgress())
                image = Activator.getImage(Activator.IMAGE_MERGE_OUTPUT_IN_PROGRESS);
            else
                image = Activator.getImage(Activator.IMAGE_MERGE_OUTPUT);
        }
        return compareConfiguration.getImage(image, Differencer.NO_CHANGE);
    }
    if (element instanceof MergeResult) {
        MergeResult mergeResult = (MergeResult) element;
        if (mergeResult.getResource() == null || mergeResult.getResource().getName() == null) {
            return super.getImage(element);
        }
        return getImage(mergeResult);
    }
    if (element instanceof MergeResultsFolder) {
        MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) element;
        Image image;
        if (mergeResultsFolder.getFolder().getFullPath().makeRelative().toString().length() > mergeResultsFolder.getRootFolderLength())
            image = workbenchLabelProvider.getImage(mergeResultsFolder.getFolder());
        else
            image = workbenchLabelProvider.getImage(mergeResultsFolder.getMergeOutput().getResource());
        MergeResult mergeResult = mergeResultsFolder.getMergeResult();
        if (mergeResult != null)
            return getImage(mergeResult);
        return compareConfiguration.getImage(image, Differencer.NO_CHANGE);
    }
    return super.getImage(element);
}
Also used : MergeOutput(com.collabnet.subversion.merge.MergeOutput) MergeResult(com.collabnet.subversion.merge.MergeResult) Image(org.eclipse.swt.graphics.Image) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

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