use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class CompareWithRevisionAction method execute.
/*
* @see SVNAction#execute(IAction)
*/
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
refresh = false;
// Setup holders
final ISVNRemoteResource[] resource = new ISVNRemoteResource[] { null };
final ILogEntry[][] entries = new ILogEntry[][] { null };
// Get the selected resource
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
resource[0] = getSelectedRemoteResource();
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
if (resource[0] == null) {
// No revisions for selected resource
MessageDialog.openWarning(getShell(), Policy.bind("CompareWithRevisionAction.noRevisions"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("CompareWithRevisionAction.noRevisionsLong"));
return;
}
if (resource[0] instanceof IFile && !resource[0].getResource().isSynchronized(Depth.immediates)) {
refresh = MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"));
}
// Fetch the log entries
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
monitor.beginTask(Policy.bind("CompareWithRevisionAction.fetching"), // $NON-NLS-1$
100);
AliasManager tagManager = null;
IResource[] resources = getSelectedResources();
if (refresh)
resources[0].refreshLocal(Depth.immediates, monitor);
if (resources.length == 1)
tagManager = new AliasManager(resources[0]);
GetLogsCommand logCmd = new GetLogsCommand(resource[0], SVNRevision.HEAD, SVNRevision.HEAD, new SVNRevision.Number(0), false, 0, tagManager, false);
logCmd.run(Policy.subMonitorFor(monitor, 100));
entries[0] = logCmd.getLogEntries();
monitor.done();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
}, true, /* cancelable */
PROGRESS_DIALOG);
if (entries[0] == null)
return;
final IResource selectedResource = getSelectedResources()[0];
if (!(selectedResource instanceof IFile)) {
HistoryDialog dialog = new HistoryDialog(getShell(), resource[0]);
if (dialog.open() == HistoryDialog.CANCEL) {
return;
}
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0) {
return;
}
ISVNRemoteFolder remoteFolder = new RemoteFolder(resource[0].getRepository(), selectedEntries[0].getResource().getUrl(), selectedEntries[0].getRevision());
((RemoteFolder) remoteFolder).setPegRevision(selectedEntries[0].getRevision());
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(selectedResource);
try {
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFolder, SVNRevision.HEAD);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} catch (SVNException e) {
MessageDialog.openError(getShell(), getErrorTitle(), e.getMessage());
}
return;
}
// Show the compare viewer
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SVNCompareRevisionsInput input = new SVNCompareRevisionsInput((IFile) selectedResource, entries[0]);
if (SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG)) {
// running with a null progress monitor is fine because we have already pre-fetched
// the log entries above.
input.run(new NullProgressMonitor());
SaveablePartDialog cd = createCompareDialog(getShell(), input);
cd.setBlockOnOpen(true);
cd.open();
} else {
CompareUI.openCompareEditorOnPage(input, getTargetPage());
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class SVNAction method getSelectedRemoteResources.
/**
* Returns the selected remote resources
*/
protected ISVNRemoteResource[] getSelectedRemoteResources() {
ArrayList resources = null;
if (selection != null && !selection.isEmpty()) {
resources = new ArrayList();
Iterator elements = selection.iterator();
while (elements.hasNext()) {
Object next = elements.next();
if (next instanceof ISVNRemoteResource) {
resources.add(next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(ISVNRemoteResource.class);
if (adapter instanceof ISVNRemoteResource) {
resources.add(adapter);
continue;
}
}
}
}
if (resources != null && !resources.isEmpty()) {
ISVNRemoteResource[] result = new ISVNRemoteResource[resources.size()];
resources.toArray(result);
return result;
}
return new ISVNRemoteResource[0];
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffAction method execute.
//
// private IResource localResource;
//
// public void setLocalResource(IResource localResource) {
// this.localResource = localResource;
// }
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
pegRevision1 = null;
pegRevision2 = null;
String fromRevision = null;
String toRevision = null;
ISVNResource[] selectedResources = getSelectedRemoteResources();
SVNUrl fromUrl = null;
SVNUrl toUrl = null;
if (selectedResources == null || (selectedResources.length == 0)) {
Object[] selectedObjects = selection.toArray();
if (selectedObjects[0] instanceof ILogEntry) {
selectedResources = new ISVNResource[2];
selectedResources[0] = ((ILogEntry) selectedObjects[0]).getResource();
fromRevision = ((ILogEntry) selectedObjects[0]).getRevision().toString();
ILogEntry logEntry1 = (ILogEntry) selectedObjects[0];
RemoteResource remoteResource;
IResource resource1 = logEntry1.getResource().getResource();
if (resource1 != null) {
try {
ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource1);
if (baseResource != null) {
pegRevision1 = baseResource.getLastChangedRevision();
}
} catch (Exception e) {
}
}
if (logEntry1.getResource().getResource() instanceof IContainer) {
remoteResource = new RemoteFolder(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
} else {
remoteResource = new RemoteFile(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
}
fromUrl = remoteResource.getUrl();
if (selectedObjects.length > 1) {
selectedResources[1] = ((ILogEntry) selectedObjects[1]).getResource();
toRevision = ((ILogEntry) selectedObjects[1]).getRevision().toString();
ILogEntry logEntry2 = (ILogEntry) selectedObjects[1];
IResource resource2 = logEntry2.getResource().getResource();
if (resource2 != null) {
try {
ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource2);
if (baseResource != null) {
pegRevision2 = baseResource.getLastChangedRevision();
}
} catch (Exception e) {
}
}
if (logEntry2.getResource().getResource() instanceof IContainer) {
remoteResource = new RemoteFolder(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
} else {
remoteResource = new RemoteFile(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
}
toUrl = remoteResource.getUrl();
} else {
int from = Integer.parseInt(fromRevision);
from--;
toRevision = Integer.toString(from);
toUrl = remoteResource.getUrl();
}
}
} else {
if (selectedResources[0] instanceof ISVNRemoteResource)
fromRevision = ((ISVNRemoteResource) selectedResources[0]).getRevision().toString();
if (selectedResources.length > 1 && selectedResources[1] instanceof ISVNRemoteResource)
toRevision = ((ISVNRemoteResource) selectedResources[1]).getRevision().toString();
}
if (pegRevision1 == null) {
pegRevision1 = SVNRevision.HEAD;
}
if (pegRevision2 == null) {
pegRevision2 = pegRevision1;
}
DifferencesDialog dialog = new DifferencesDialog(getShell(), null, selectedResources, new SVNRevision[] { pegRevision1, pegRevision2 }, getTargetPart());
dialog.setUsePegRevision(usePegRevision);
dialog.setFromUrl(fromUrl);
dialog.setToUrl(toUrl);
IResource localResource = null;
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
if (part instanceof GenericHistoryView) {
IHistoryPage historyPage = ((GenericHistoryView) part).getHistoryPage();
if (historyPage instanceof SVNHistoryPage) {
localResource = ((SVNHistoryPage) historyPage).getResource();
}
}
dialog.setLocalResource(localResource);
// $NON-NLS-1$
if (!fromRevision.equals("HEAD"))
dialog.setFromRevision(fromRevision);
if (toRevision != null && !toRevision.equals("HEAD"))
// $NON-NLS-1$
dialog.setToRevision(toRevision);
dialog.open();
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ExportRemoteFolderAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
ISVNRemoteResource[] resources = getSelectedRemoteResources();
ExportRemoteFolderDialog dialog = new ExportRemoteFolderDialog(getShell(), resources[0], getTargetPart());
dialog.open();
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class RemoteResourcePropertiesAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
ISVNRemoteResource[] remoteResources = getSelectedRemoteResources();
RemoteResourcePropertiesDialog dialog = new RemoteResourcePropertiesDialog(getShell(), remoteResources[0]);
dialog.open();
}
Aggregations