use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class CompareWithRemoteAction method execute.
public void execute(IAction action) {
refresh = false;
fileSelected = false;
final IResource[] resources = getSelectedResources();
if (resources.length != 1 && !SVNRevision.BASE.equals(revision) && !SVNRevision.HEAD.equals(revision)) {
return;
}
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile) {
fileSelected = true;
if (!resources[i].isSynchronized(Depth.immediates)) {
refresh = MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"));
break;
}
}
}
try {
final ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
final ISVNLocalResource localResource = localResources[0];
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
if (refresh) {
for (int i = 0; i < localResources.length; i++) {
if (resources[i] instanceof IFile) {
localResources[i].getResource().refreshLocal(Depth.immediates, monitor);
}
}
}
if (SVNRevision.BASE.equals(revision)) {
if (localResources.length == 1 && localResource.getResource() instanceof IFile) {
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
SVNLocalBaseCompareInput compareInput = new SVNLocalBaseCompareInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
} else {
if (!fileSelected) {
SVNLocalCompareSummaryInput compareInput = new SVNLocalCompareSummaryInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), localResource.getUrl(), revision);
((RemoteFile) remoteFile).setPegRevision(revision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
ShowDifferencesAsUnifiedDiffOperationWC operation = null;
if (SVNRevision.HEAD.equals(revision)) {
File file = File.createTempFile("revision", ".diff");
file.deleteOnExit();
operation = new ShowDifferencesAsUnifiedDiffOperationWC(getTargetPart(), localResource.getFile(), localResource.getUrl(), SVNRevision.HEAD, file);
operation.setGraphicalCompare(true);
operation.run();
}
compareInput.setDiffOperation(operation);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (Exception e) {
handle(e, null, null);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
} catch (Exception e) {
handle(e, null, null);
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class OpenRemoteFileAction method execute.
/*
* @see SVNAction#execute(IAction)
*/
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
IWorkbench workbench = SVNUIPlugin.getPlugin().getWorkbench();
IEditorRegistry registry = workbench.getEditorRegistry();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
ISVNRemoteFile[] files = getSelectedRemoteFiles();
for (int i = 0; i < files.length; i++) {
ISVNRemoteFile file = files[i];
String filename = file.getName();
IEditorDescriptor descriptor = registry.getDefaultEditor(filename);
String id;
if (descriptor == null) {
descriptor = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
}
if (descriptor == null) {
// $NON-NLS-1$
id = "org.eclipse.ui.DefaultTextEditor";
} else {
id = descriptor.getId();
}
try {
try {
if (usePegRevision && files[i] instanceof RemoteResource)
((RemoteResource) files[i]).setPegRevision(files[i].getRevision());
else
((RemoteResource) files[i]).setPegRevision(SVNRevision.HEAD);
RemoteFileEditorInput input = new RemoteFileEditorInput(files[i], monitor);
if (descriptor != null && descriptor.isOpenExternal()) {
input.writeToTempFile();
}
page.openEditor(input, id);
} catch (PartInitException e) {
if (id.equals("org.eclipse.ui.DefaultTextEditor")) {
// $NON-NLS-1$
throw e;
} else {
RemoteFileEditorInput input = new RemoteFileEditorInput(files[i], monitor);
// $NON-NLS-1$
page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
}
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("OpenRemoteFileAction.0"), // $NON-NLS-1$
e.getMessage());
}
}
}
}, false, // $NON-NLS-1$
PROGRESS_BUSYCURSOR);
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNCompareRevisionsInput method initializeActions.
/**
* initialize the actions : - getContentsAction : get the contents for the selected revision -
* getRevisionAction : updates to the given revision
*/
private void initializeActions() {
getContentsAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.getContentsAction"), // $NON-NLS-1$
null) {
public void run() {
try {
new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
ResourceEditionNode right = (ResourceEditionNode) node.getRight();
ISVNRemoteResource edition = right.getRemoteResource();
// actually want to change the base.
try {
monitor.beginTask(null, 100);
InputStream in = ((IResourceVariant) edition).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
resource.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
} catch (TeamException e) {
throw new InvocationTargetException(e);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
} catch (InterruptedException e) {
// Do nothing
return;
} catch (InvocationTargetException e) {
handle(e);
}
// recompute the labels on the viewer
updateCurrentEdition();
viewer.refresh();
}
};
getRevisionAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.getRevisionAction"), // $NON-NLS-1$
null) {
public void run() {
try {
new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation(null) {
protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
ResourceEditionNode right = (ResourceEditionNode) node.getRight();
final ISVNRemoteFile edition = (ISVNRemoteFile) right.getRemoteResource();
new UpdateOperation(null, resource, edition.getLastChangedRevision()).run(monitor);
// recompute the labels on the viewer
getHistoryTableProvider().setRemoteResource(edition);
viewer.refresh();
}
});
} catch (InterruptedException e) {
// Do nothing
return;
} catch (InvocationTargetException e) {
handle(e);
}
}
};
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class LogEntry method createLogEntriesFrom.
/**
* create the LogEntry for the logMessages
*
* @param logMessages
* @return
*/
public static ILogEntry[] createLogEntriesFrom(ISVNRemoteFile remoteFile, ISVNLogMessage[] logMessages, Tags[] tags, SVNUrl[] urls) {
ILogEntry[] result = new ILogEntry[logMessages.length];
for (int i = 0; i < logMessages.length; i++) {
ISVNLogMessage logMessage = logMessages[i];
ISVNRemoteResource correspondingResource;
correspondingResource = new RemoteFile(null, remoteFile.getRepository(), urls[i], logMessage.getRevision(), logMessage.getRevision(), logMessage.getDate(), logMessage.getAuthor());
result[i] = new LogEntry(logMessage, remoteFile, correspondingResource, (tags[i] != null) ? tags[i].getTags() : null);
}
return result;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile 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