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));
}
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;
}
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);
}
Aggregations