Search in sources :

Example 1 with MergeResultsFolder

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

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

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

the class MergeResultsViewLabelProvider method getForeground.

public Color getForeground(Object element) {
    if (element instanceof MergeResult) {
        MergeResult mergeResult = (MergeResult) element;
        if (mergeResult.getAction().equals(MergeResult.ACTION_SKIP))
            return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
    }
    if (element instanceof MergeResultsFolder) {
        MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) element;
        MergeResult mergeResult = mergeResultsFolder.getMergeResult();
        if (mergeResult != null && mergeResult.getAction().equals(MergeResult.ACTION_SKIP))
            return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
    }
    return null;
}
Also used : MergeResult(com.collabnet.subversion.merge.MergeResult) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Example 4 with MergeResultsFolder

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

Example 5 with MergeResultsFolder

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

Aggregations

MergeResult (com.collabnet.subversion.merge.MergeResult)6 MergeResultsFolder (com.collabnet.subversion.merge.MergeResultsFolder)6 MergeOutput (com.collabnet.subversion.merge.MergeOutput)5 Iterator (java.util.Iterator)3 ArrayList (java.util.ArrayList)2 IResource (org.eclipse.core.resources.IResource)2 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 DialogWizard (com.collabnet.subversion.merge.wizards.DialogWizard)1 MergeWizardDialog (com.collabnet.subversion.merge.wizards.MergeWizardDialog)1 ParseException (java.text.ParseException)1 List (java.util.List)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1