use of com.collabnet.subversion.merge.wizards.MergeWizardDialog 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();
}
}
}
use of com.collabnet.subversion.merge.wizards.MergeWizardDialog in project subclipse by subclipse.
the class MergeOperation method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
monitor.beginTask(getTaskName(), mergedResources.length);
ArrayList mergeOutputs = new ArrayList();
for (int i = 0; i < mergedResources.length; i++) {
try {
monitor.subTask(mergedResources[i].getName());
incompleteOutput = null;
if (mergeOutput == null) {
incompleteOutput = MergeOutput.getIncompleteMerge(mergedResources[i], svnUrls1[i].toString(), svnUrls2[i].toString());
}
if (incompleteOutput == null)
command = new MergeCommand(mergedResources[i], svnUrls1[i], svnRevision1, svnUrls2[i], svnRevision2, revisions, mergeOutput);
else {
if (incompleteOutput.hasUnresolvedConflicts()) {
unresolvedConflicts = true;
break;
}
command = new MergeCommand(mergedResources[i], svnUrls1[i], svnRevision1, svnUrls2[i], svnRevision2, revisions, incompleteOutput);
}
command.setPart(getPart());
command.setForce(force);
command.setIgnoreAncestry(ignoreAncestry);
command.setDepth(depth);
command.setTextConflictHandling(textConflictHandling);
command.setBinaryConflictHandling(binaryConflictHandling);
command.setPropertyConflictHandling(propertyConflictHandling);
command.setTreeConflictHandling(treeConflictHandling);
command.setRecordOnly(recordOnly);
command.run(Policy.subMonitorFor(monitor, 1000));
monitor.worked(1);
if (recordOnly) {
MergeOutput mergeOutput = command.getMergeOutput();
MergeSummaryResult[] summaryResults = { new MergeSummaryResult(MergeSummaryResult.PROPERTY, "Updated", "1") };
// $NON-NLS-1$ //$NON-NLS-2$
mergeOutput.setMergeSummaryResults(summaryResults);
MergeResult[] mergeResults = { new AdaptableMergeResult(" ", "U", " ", mergedResources[i].getLocation().toString(), false) };
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
mergeOutput.setMergeResults(mergeResults);
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(mergedResources[i]);
if (svnResource != null) {
svnResource.refreshStatus();
}
}
} catch (SVNException e) {
if (e.operationInterrupted()) {
showCancelledMessage();
} else {
collectStatus(e.getStatus());
}
abnormalEnd = true;
}
MergeOutput mergeOutput = command.getMergeOutput();
mergeOutputs.add(mergeOutput);
if (command.isMergeAborted()) {
mergeOutput.setIncomplete(true);
mergeOutput.setNormalEnd(true);
mergeOutput.store();
abortedMergeOutput = mergeOutput;
MergeResultsView view = MergeResultsView.getView();
if (view != null)
view.refreshAsync(mergeOutput);
break;
} else {
mergeOutput.setIncomplete(false);
if (!recordOnly && !abnormalEnd) {
mergeOutput.setNormalEnd(true);
mergeOutput.store();
MergeResultsView view = MergeResultsView.getView();
if (view != null)
view.refreshAsync(mergeOutput);
}
}
}
if (recordOnly) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
DialogWizard dialogWizard = new DialogWizard(DialogWizard.COMMIT_MERGEINFO_PROPERTY);
dialogWizard.setUnblock(unblock);
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
if (dialog.open() == MergeWizardDialog.CANCEL)
return;
CommitAction commitAction = new CommitAction();
commitAction.setSelectedResources(mergedResources);
commitAction.run(null);
}
});
} else {
final MergeOutput[] mergeOutputArray = new MergeOutput[mergeOutputs.size()];
mergeOutputs.toArray(mergeOutputArray);
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (unresolvedConflicts) {
DialogWizard dialogWizard = new DialogWizard(DialogWizard.UNRESOLVED_CONFLICTS);
dialogWizard.setMergeOutput(incompleteOutput);
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
} else {
if (command.isMergeAborted()) {
DialogWizard dialogWizard = new DialogWizard(DialogWizard.MERGE_ABORTED);
dialogWizard.setMergeOutput(abortedMergeOutput);
dialogWizard.setErrorMessage(command.getErrorMessage());
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
}
if (mergeOutputArray.length > 0 && !abnormalEnd) {
DialogWizard dialogWizard = new DialogWizard(DialogWizard.SUMMARY);
dialogWizard.setMergeOutputs(mergeOutputArray);
dialogWizard.setResumed(resumed);
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
}
});
}
monitor.done();
}
use of com.collabnet.subversion.merge.wizards.MergeWizardDialog in project subclipse by subclipse.
the class SVNConflictResolver method getConflictResolution.
private ConflictResolution getConflictResolution(final SVNConflictDescriptor descrip) {
wait = false;
dialogWizard = null;
ConflictResolution conflictResolution = null;
if (descrip.isTreeConflict() && applyToAllTreeConflictResolution != null) {
conflictResolution = new ConflictResolution(descrip, applyToAllTreeConflictResolution.getResolution());
} else if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property && applyToAllPropertyResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllPropertyResolution.getResolution());
else if (descrip.isBinary() && applyToAllBinaryResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllBinaryResolution.getResolution());
else if (descrip.getConflictKind() != SVNConflictDescriptor.Kind.property && !descrip.isBinary() && applyToAllTextResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllTextResolution.getResolution());
if (conflictResolution == null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
dialogWizard = new DialogWizard(DialogWizard.CONFLICT_HANDLING);
dialogWizard.setConflictDescriptor(descrip);
dialogWizard.setResources(new IResource[] { resource });
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
});
while (dialogWizard == null || dialogWizard.getConflictResolution() == null) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// we're still waiting...
}
}
conflictResolution = dialogWizard.getConflictResolution();
if (conflictResolution.isApplyToAll()) {
if (descrip.isTreeConflict()) {
applyToAllTreeConflictResolution = conflictResolution;
} else if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = conflictResolution;
else if (descrip.isBinary())
applyToAllBinaryResolution = conflictResolution;
else
applyToAllTextResolution = conflictResolution;
}
}
try {
if (conflictResolution.getResolution() == ConflictResolution.FILE_EDITOR) {
finished = false;
// resolved = false;
workingTempFile = null;
File pathFile = new File(descrip.getPath());
mergedFile = new File(descrip.getMergedPath());
try {
workingTempFile = createTempFile(pathFile);
copyFile(mergedFile, workingTempFile);
} catch (IOException e) {
e.printStackTrace();
}
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(workingTempFile.getAbsolutePath()));
final IWorkbenchPage page = part.getSite().getPage();
final IEditorInput editorInput = new ExternalFileEditorInput(fileStore);
final String editorId = getEditorId(fileStore);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
// final IEditorPart editorPart = IDE.openEditorOnFileStore(page,
// fileStore);
final IEditorPart editorPart = page.openEditor(editorInput, editorId);
if (editorPart == null) {
resolution = ISVNConflictResolver.Choice.postpone;
// resolved = false;
finished = true;
// finishEditing();
} else {
IPartListener2 closeListener = new IPartListener2() {
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == editorPart) {
finishEditing(descrip);
}
}
public void partActivated(IWorkbenchPartReference partRef) {
}
public void partBroughtToTop(IWorkbenchPartReference partRef) {
}
public void partDeactivated(IWorkbenchPartReference partRef) {
}
public void partHidden(IWorkbenchPartReference partRef) {
}
public void partInputChanged(IWorkbenchPartReference partRef) {
}
public void partOpened(IWorkbenchPartReference partRef) {
}
public void partVisible(IWorkbenchPartReference partRef) {
}
};
page.addPartListener(closeListener);
}
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
while (!finished) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
conflictResolution = new ConflictResolution(descrip, resolution);
if (!conflictResolution.isResolved()) {
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = null;
else if (descrip.isBinary())
applyToAllBinaryResolution = null;
else
applyToAllTextResolution = null;
}
}
if (conflictResolution.getResolution() == ConflictResolution.CONFLICT_EDITOR) {
File pathFile = new File(descrip.getPath());
File conflictNewFile = new File(descrip.getTheirPath());
File conflictWorkingFile = new File(descrip.getMyPath());
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property && descrip.getMergedPath() == null) {
try {
final String theirValue = getPropertyValue(conflictNewFile);
final String myValue = getPropertyValue(conflictWorkingFile);
dialogWizard = null;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
dialogWizard = new DialogWizard(DialogWizard.PROPERTY_VALUE_SELECTION);
dialogWizard.setConflictDescriptor(descrip);
dialogWizard.setMyValue(myValue);
dialogWizard.setIncomingValue(theirValue);
dialogWizard.setResources(new IResource[] { resource });
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
});
while (dialogWizard == null || dialogWizard.getValueToUse() == null) {
}
String valueToUse = dialogWizard.getValueToUse();
if (!dialogWizard.isConflictResolved()) {
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.postpone);
return conflictResolution;
} else {
mergeTempFile = createTempFile(pathFile);
setPropertyValue(mergeTempFile, valueToUse);
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.chooseMerged);
conflictResolution.setMergedPath(mergeTempFile.getAbsolutePath());
return conflictResolution;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
workingTempFile = null;
mergeTempFile = null;
File mergedFile;
if (descrip.getMergedPath() == null) {
mergedFile = new File(descrip.getPath());
} else {
mergedFile = new File(descrip.getMergedPath());
}
try {
workingTempFile = createTempFile(pathFile);
copyFile(conflictWorkingFile, workingTempFile);
mergeTempFile = createTempFile(pathFile);
copyFile(mergedFile, mergeTempFile);
} catch (IOException e) {
e.printStackTrace();
}
File conflictOldFile = new File(descrip.getBasePath());
final MergeEditConflictsAction editConflictsAction = new MergeEditConflictsAction(conflictNewFile, conflictOldFile, workingTempFile, mergedFile, pathFile.getName(), descrip);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
editConflictsAction.run(null);
}
});
while (editConflictsAction.getMergeConflictsCompareInput() == null || !editConflictsAction.getMergeConflictsCompareInput().isFinished()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
if (editConflictsAction.getMergeConflictsCompareInput().isResolved()) {
// conflictResolution = new ConflictResolution(descrip,
// ISVNConflictResolver.Result.resolved);
conflictResolution = new ConflictResolution(descrip, editConflictsAction.getMergeConflictsCompareInput().getResolution());
} else {
// conflictResolution = new ConflictResolution(descrip,
// ISVNConflictResolver.Result.conflicted);
conflictResolution = new ConflictResolution(descrip, editConflictsAction.getMergeConflictsCompareInput().getResolution());
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = null;
else if (descrip.isBinary())
applyToAllBinaryResolution = null;
else
applyToAllTextResolution = null;
try {
copyFile(mergeTempFile, mergedFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (final RuntimeException re) {
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.postpone);
wait = true;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Activator.handleError(Messages.SVNConflictResolver_handleConflictError, re);
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.SVNConflictResolver_handleConflict, Messages.SVNConflictResolver_conflictNotHandled + re.getLocalizedMessage() + Messages.SVNConflictResolver_resolveLater);
re.printStackTrace();
wait = false;
}
});
}
while (wait) {
}
return conflictResolution;
}
Aggregations