Search in sources :

Example 1 with AdaptableMergeResult

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

the class MergeResultsView method fillContextMenu.

private void fillContextMenu(IMenuManager manager) {
    boolean enableOpen = false;
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object element = iter.next();
        if (element instanceof AdaptableMergeResult) {
            MergeResult mergeResult = (MergeResult) element;
            if (mergeResult.getResource() instanceof IFile && !mergeResult.isDelete()) {
                enableOpen = true;
            }
        }
        if (enableOpen)
            break;
    }
    if (enableOpen) {
        manager.add(openAction);
    }
    if (enableOpen && selection.size() == 1) {
        MenuManager submenu = new MenuManager(Messages.MergeResultsView_openWith);
        MergeResult mergeResult = (MergeResult) selection.getFirstElement();
        submenu.add(new OpenWithMenu(getSite().getPage(), mergeResult.getResource()));
        manager.add(submenu);
    }
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
Also used : AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) IFile(org.eclipse.core.resources.IFile) Iterator(java.util.Iterator) MergeResult(com.collabnet.subversion.merge.MergeResult) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) OpenWithMenu(org.eclipse.ui.actions.OpenWithMenu) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 2 with AdaptableMergeResult

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

the class OpenFileInSystemEditorAction method getSelectedResources.

protected List getSelectedResources() {
    ArrayList openableFiles = new ArrayList();
    IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object element = iter.next();
        if (element instanceof AdaptableMergeResult) {
            MergeResult mergeResult = (MergeResult) element;
            if (mergeResult.getResource() instanceof IFile && !mergeResult.isDelete())
                openableFiles.add(mergeResult.getResource());
        }
    }
    return openableFiles;
}
Also used : AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) MergeResult(com.collabnet.subversion.merge.MergeResult) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with AdaptableMergeResult

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

Aggregations

AdaptableMergeResult (com.collabnet.subversion.merge.AdaptableMergeResult)3 MergeResult (com.collabnet.subversion.merge.MergeResult)3 Iterator (java.util.Iterator)3 IFile (org.eclipse.core.resources.IFile)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 AdaptableMergeResultsFolder (com.collabnet.subversion.merge.AdaptableMergeResultsFolder)1 MergeOutput (com.collabnet.subversion.merge.MergeOutput)1 MergeResultsFolder (com.collabnet.subversion.merge.MergeResultsFolder)1 ArrayList (java.util.ArrayList)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1 OpenEvent (org.eclipse.jface.viewers.OpenEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 OpenWithMenu (org.eclipse.ui.actions.OpenWithMenu)1