use of com.collabnet.subversion.merge.MergeResult 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.MergeResult in project subclipse by subclipse.
the class MergeOutputDocument method createDocument.
private Document createDocument() {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
// $NON-NLS-1$
Element rootElement = doc.createElement("mergeOutput");
rootElement.setAttribute("resource", // $NON-NLS-1$
mergeOutput.getResource().getFullPath().toString());
// $NON-NLS-1$
rootElement.setAttribute("date", mergeOutput.getMergeDate().toString());
String status = null;
if (// $NON-NLS-1$
mergeOutput.isInProgress())
// $NON-NLS-1$
status = "inProgress";
else if (// $NON-NLS-1$
mergeOutput.isAbnormalEnd())
// $NON-NLS-1$
status = "aborted";
else
// $NON-NLS-1$
status = "normal";
// $NON-NLS-1$
rootElement.setAttribute("status", status);
rootElement.setAttribute("revisionStart", // $NON-NLS-1$
Long.toString(mergeOutput.getLowerRevision()));
rootElement.setAttribute("revisionEnd", // $NON-NLS-1$
Long.toString(mergeOutput.getUpperRevision()));
// $NON-NLS-1$
Element workspaceElement = doc.createElement("workspace");
// $NON-NLS-1$
workspaceElement.setAttribute("url", mergeOutput.getWorkspaceUrl());
workspaceElement.setAttribute("revision", // $NON-NLS-1$
Long.toString(mergeOutput.getWorkspaceRevision()));
rootElement.appendChild(workspaceElement);
// $NON-NLS-1$
Element commandElement = doc.createElement("mergeCommand");
commandElement.appendChild(doc.createTextNode(mergeOutput.getMergeCommand()));
rootElement.appendChild(commandElement);
// $NON-NLS-1$
Element optionsElement = doc.createElement("mergeOptions");
optionsElement.setAttribute("force", // $NON-NLS-1$
getBoolean(mergeOutput.getMergeOptions().isForce()));
optionsElement.setAttribute("ignoreAncestry", // $NON-NLS-1$
getBoolean(mergeOutput.getMergeOptions().isIgnoreAncestry()));
optionsElement.setAttribute("recurse", // $NON-NLS-1$
getBoolean(mergeOutput.getMergeOptions().isRecurse()));
String depth;
switch(mergeOutput.getMergeOptions().getDepth()) {
case Depth.empty:
// $NON-NLS-1$
depth = "thisItem";
break;
case Depth.files:
// $NON-NLS-1$
depth = "fileChildren";
break;
case Depth.immediates:
// $NON-NLS-1$
depth = "immediateChildren";
break;
case Depth.infinity:
// $NON-NLS-1$
depth = "infinite";
break;
default:
// $NON-NLS-1$
depth = "workingCopy";
break;
}
// $NON-NLS-1$
optionsElement.setAttribute("depth", depth);
if (mergeOutput.getMergeOptions().getFromRevision() != null)
optionsElement.setAttribute("revisionFrom", // $NON-NLS-1$
mergeOutput.getMergeOptions().getFromRevision().toString());
if (mergeOutput.getMergeOptions().getToRevision() != null)
optionsElement.setAttribute("revisionTo", // $NON-NLS-1$
mergeOutput.getMergeOptions().getToRevision().toString());
// $NON-NLS-1$
Element fromUrlElement = doc.createElement("fromUrl");
fromUrlElement.appendChild(doc.createTextNode(mergeOutput.getMergeOptions().getFromUrl().toString()));
optionsElement.appendChild(fromUrlElement);
if (mergeOutput.getMergeOptions().getRevisions() != null) {
// $NON-NLS-1$
Element revisionRangesElement = doc.createElement("revisionRanges");
SVNRevisionRange[] revisionRanges = mergeOutput.getMergeOptions().getRevisions();
for (int i = 0; i < revisionRanges.length; i++) {
// $NON-NLS-1$
Element revisionRangeElement = doc.createElement("revisionRange");
revisionRangeElement.appendChild(doc.createTextNode(revisionRanges[i].toString()));
revisionRangesElement.appendChild(revisionRangeElement);
}
optionsElement.appendChild(revisionRangesElement);
}
if (!(mergeOutput.getMergeOptions().getToUrl() == null) && (!mergeOutput.getMergeOptions().getToUrl().toString().equals(mergeOutput.getMergeOptions().getFromUrl().toString()))) {
// $NON-NLS-1$
Element toUrlElement = doc.createElement("toUrl");
toUrlElement.appendChild(doc.createTextNode(mergeOutput.getMergeOptions().getToUrl().toString()));
optionsElement.appendChild(toUrlElement);
}
rootElement.appendChild(optionsElement);
// $NON-NLS-1$
Element summaryElement = doc.createElement("summary");
// $NON-NLS-1$
Element fileStatisticsElement = doc.createElement("fileStats");
// $NON-NLS-1$
Element propertyStatisticsElement = doc.createElement("propertiesStats");
// $NON-NLS-1$
Element treeConflictStatisticsElement = doc.createElement("treeConflictStats");
MergeSummaryResult[] summaryResults = mergeOutput.getMergeSummaryResults();
boolean fileStats = false;
boolean propStats = false;
boolean treeStats = false;
for (int i = 0; i < summaryResults.length; i++) {
if (summaryResults[i].getType() == MergeSummaryResult.FILE) {
fileStatisticsElement.setAttribute(summaryResults[i].getCategory().replaceAll(" ", "_"), // $NON-NLS-1$ //$NON-NLS-2$
summaryResults[i].getNumber());
fileStats = true;
}
if (summaryResults[i].getType() == MergeSummaryResult.PROPERTY) {
propertyStatisticsElement.setAttribute(summaryResults[i].getCategory().replaceAll(" ", "_"), // $NON-NLS-1$ //$NON-NLS-2$
summaryResults[i].getNumber());
propStats = true;
}
if (summaryResults[i].getType() == MergeSummaryResult.TREE) {
treeConflictStatisticsElement.setAttribute(summaryResults[i].getCategory().replaceAll(" ", "_"), // $NON-NLS-1$ //$NON-NLS-2$
summaryResults[i].getNumber());
treeStats = true;
}
}
if (fileStats)
summaryElement.appendChild(fileStatisticsElement);
if (propStats)
summaryElement.appendChild(propertyStatisticsElement);
if (treeStats)
summaryElement.appendChild(treeConflictStatisticsElement);
rootElement.appendChild(summaryElement);
// $NON-NLS-1$
Element resultsElement = doc.createElement("mergeResults");
// $NON-NLS-1$
Element textElement = doc.createElement("text");
// $NON-NLS-1$
Element mergedTextElement = doc.createElement("merged");
// $NON-NLS-1$
Element conflictedTextElement = doc.createElement("conflicted");
// $NON-NLS-1$
Element skippedTextElement = doc.createElement("skipped");
// $NON-NLS-1$
Element propertiesElement = doc.createElement("properties");
// $NON-NLS-1$
Element mergedPropertiesElement = doc.createElement("merged");
// $NON-NLS-1$
Element conflictedPropertiesElement = doc.createElement("conflicted");
// $NON-NLS-1$
Element skippedPropertiesElement = doc.createElement("skipped");
// $NON-NLS-1$
Element treeConflictsElement = doc.createElement("treeConflicts");
boolean treeConflicts = false;
boolean mergedText = false;
boolean conflictedText = false;
boolean skippedText = false;
boolean mergedProperties = false;
boolean conflictedProperties = false;
boolean skippedProperties = false;
MergeResult[] mergeResults = mergeOutput.getMergeResults();
for (int i = 0; i < mergeResults.length; i++) {
if (mergeResults[i].hasTreeConflict()) {
// $NON-NLS-1$
Element resultElement = doc.createElement("result");
resultElement.setAttribute("resource", // $NON-NLS-1$
mergeResults[i].getResource().getFullPath().toString());
resultElement.setAttribute("resolved", // $NON-NLS-1$
getBoolean(mergeResults[i].isTreeConflictResolved()));
treeConflictsElement.appendChild(resultElement);
treeConflicts = true;
}
if (mergeResults[i].getAction() != null && mergeResults[i].getAction().trim().length() > 0) {
// $NON-NLS-1$
Element resultElement = doc.createElement("result");
resultElement.setAttribute("resource", // $NON-NLS-1$
mergeResults[i].getResource().getFullPath().toString());
if (mergeResults[i].isConflicted()) {
resultElement.setAttribute("resolved", // $NON-NLS-1$
getBoolean(mergeResults[i].isResolved()));
if (mergeResults[i].getAction().equals(MergeResult.ACTION_ADD))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("added", "true");
else if (mergeResults[i].getAction().equals(MergeResult.ACTION_DELETE))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("deleted", "true");
conflictedTextElement.appendChild(resultElement);
conflictedText = true;
} else if (mergeResults[i].isSkip()) {
skippedTextElement.appendChild(resultElement);
skippedText = true;
} else {
if (mergeResults[i].getAction().equals(MergeResult.ACTION_ADD))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("added", "true");
else if (mergeResults[i].getAction().equals(MergeResult.ACTION_DELETE))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("deleted", "true");
mergedTextElement.appendChild(resultElement);
mergedText = true;
}
}
if (mergeResults[i].getPropertyAction() != null && mergeResults[i].getPropertyAction().trim().length() > 0) {
// $NON-NLS-1$
Element resultElement = doc.createElement("result");
resultElement.setAttribute("resource", // $NON-NLS-1$
mergeResults[i].getResource().getFullPath().toString());
if (mergeResults[i].isPropertyConflicted()) {
resultElement.setAttribute("resolved", // $NON-NLS-1$
getBoolean(mergeResults[i].isPropertyResolved()));
if (mergeResults[i].getPropertyAction().equals(MergeResult.ACTION_ADD))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("added", "true");
else if (mergeResults[i].getPropertyAction().equals(MergeResult.ACTION_DELETE))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("deleted", "true");
conflictedPropertiesElement.appendChild(resultElement);
conflictedProperties = true;
} else if (mergeResults[i].isSkip()) {
skippedPropertiesElement.appendChild(resultElement);
skippedProperties = true;
} else {
if (mergeResults[i].getPropertyAction().equals(MergeResult.ACTION_ADD))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("added", "true");
else if (mergeResults[i].getPropertyAction().equals(MergeResult.ACTION_DELETE))
// $NON-NLS-1$ //$NON-NLS-2$
resultElement.setAttribute("deleted", "true");
mergedPropertiesElement.appendChild(resultElement);
mergedProperties = true;
}
}
}
if (mergedText || conflictedText || skippedText) {
if (mergedText)
textElement.appendChild(mergedTextElement);
if (conflictedText)
textElement.appendChild(conflictedTextElement);
if (skippedText)
textElement.appendChild(skippedTextElement);
resultsElement.appendChild(textElement);
}
if (mergedProperties || conflictedProperties || skippedProperties) {
if (mergedProperties)
propertiesElement.appendChild(mergedPropertiesElement);
if (conflictedProperties)
propertiesElement.appendChild(conflictedPropertiesElement);
if (skippedProperties)
propertiesElement.appendChild(skippedPropertiesElement);
resultsElement.appendChild(propertiesElement);
}
if (treeConflicts) {
resultsElement.appendChild(treeConflictsElement);
}
rootElement.appendChild(resultsElement);
doc.appendChild(rootElement);
return doc;
} catch (Exception e) {
return null;
}
}
use of com.collabnet.subversion.merge.MergeResult 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.MergeResult in project subclipse by subclipse.
the class MergeConflictsCompareInput method markResolved.
private void markResolved() {
if (!resolved || mergeResult == null)
return;
MergeViewResolveAction resolveAction = new MergeViewResolveAction();
resolveAction.setShowDialog(false);
resolveAction.setResolution(resolution);
IStructuredSelection selection = new IStructuredSelection() {
public Object getFirstElement() {
return mergeResult;
}
public Iterator iterator() {
return toList().iterator();
}
public int size() {
return 1;
}
public Object[] toArray() {
MergeResult[] mergeResults = { mergeResult };
return mergeResults;
}
public List toList() {
List mergeResults = new ArrayList();
mergeResults.add(mergeResult);
return mergeResults;
}
public boolean isEmpty() {
return false;
}
};
resolveAction.selectionChanged(null, selection);
resolveAction.run(null);
}
use of com.collabnet.subversion.merge.MergeResult 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