use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.
the class RemoteResourceTransfer method fromByteArray.
public Object fromByteArray(byte[] buffer) {
try {
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
DataInputStream readIn = new DataInputStream(in);
boolean isFolder = readIn.readBoolean();
// first, we read the url of the remote resource
SVNUrl urlResource = new SVNUrl(readIn.readUTF());
// then we read the url of the repository
String location = readIn.readUTF();
// we read the revision
SVNRevision revision = SVNRevision.getRevision(readIn.readUTF());
// we read the last changed revision
SVNRevision.Number lastChangedRevision = (Number) SVNRevision.getRevision(readIn.readUTF());
Date date = new Date(readIn.readLong());
String author = null;
try {
author = readIn.readUTF();
} catch (Exception e) {
// Ignore null author
}
ISVNRepositoryLocation repositoryLocation = SVNProviderPlugin.getPlugin().getRepository(location);
if (isFolder) {
return new RemoteFolder(null, repositoryLocation, urlResource, revision, lastChangedRevision, date, author);
}
return new RemoteFile(null, repositoryLocation, urlResource, revision, lastChangedRevision, date, author);
} catch (Exception ex) {
return null;
}
}
use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.
the class SummaryEditionNode method getRoots.
private SummaryEditionNode[] getRoots() throws Exception {
List<String> rootPaths = new ArrayList<String>();
ArrayList roots = new ArrayList();
for (int i = 0; i < diffSummary.length; i++) {
if (include(diffSummary[i])) {
File file = new File(diffSummary[i].getPath());
if (file.getParent() == null) {
if (diffSummary[i].getNodeKind() == SVNNodeKind.DIR.toInt()) {
RemoteFolder remoteFolder = null;
if (resource.getRevision() instanceof SVNRevision.Number)
remoteFolder = new RemoteFolder(null, resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision(), (SVNRevision.Number) resource.getRevision(), null, null);
else
remoteFolder = new RemoteFolder(resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision());
remoteFolder.setPegRevision(pegRevision);
SummaryEditionNode node = new SummaryEditionNode(remoteFolder, pegRevision);
node.setDiffSummary(diffSummary);
node.setRootFolder((RemoteFolder) resource);
node.setNodeType(nodeType);
roots.add(node);
} else {
RemoteFile remoteFile = null;
if (resource.getRevision() instanceof SVNRevision.Number)
remoteFile = new RemoteFile(null, resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision(), (SVNRevision.Number) resource.getRevision(), null, null);
else
remoteFile = new RemoteFile(resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision());
remoteFile.setPegRevision(pegRevision);
SummaryEditionNode node = new SummaryEditionNode(remoteFile, pegRevision);
node.setDiffSummary(diffSummary);
node.setRootFolder((RemoteFolder) resource);
node.setNodeType(nodeType);
roots.add(node);
}
} else {
while (file.getParent() != null) {
file = file.getParentFile();
}
String path = file.getPath();
if (!rootPaths.contains(path)) {
rootPaths.add(path);
RemoteFolder remoteFolder = null;
if (resource.getRevision() instanceof SVNRevision.Number)
remoteFolder = new RemoteFolder(null, resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + path), resource.getRevision(), (SVNRevision.Number) resource.getRevision(), null, null);
else
remoteFolder = new RemoteFolder(resource.getRepository(), new SVNUrl(resource.getUrl().toString() + "/" + path), resource.getRevision());
SummaryEditionNode node = new SummaryEditionNode(remoteFolder, pegRevision);
node.setDiffSummary(diffSummary);
node.setRootFolder((RemoteFolder) resource);
node.setNodeType(nodeType);
roots.add(node);
}
}
}
}
SummaryEditionNode[] rootArray = new SummaryEditionNode[roots.size()];
roots.toArray(rootArray);
Arrays.sort(rootArray);
return rootArray;
}
use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.
the class SummaryEditionNode method getChildNodes.
private SummaryEditionNode[] getChildNodes() throws Exception {
ArrayList childNodes = new ArrayList();
for (int i = 0; i < diffSummary.length; i++) {
if (include(diffSummary[i])) {
if (diffSummary[i].getNodeKind() == SVNNodeKind.DIR.toInt()) {
RemoteFolder remoteFolder = null;
if (resource.getRevision() instanceof SVNRevision.Number)
remoteFolder = new RemoteFolder(null, resource.getRepository(), new SVNUrl(rootFolder.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision(), (SVNRevision.Number) resource.getRevision(), null, null);
else
remoteFolder = new RemoteFolder(resource.getRepository(), new SVNUrl(rootFolder.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision());
remoteFolder.setPegRevision(pegRevision);
if (isChild(remoteFolder)) {
SummaryEditionNode node = new SummaryEditionNode(remoteFolder, pegRevision);
node.setDiffSummary(diffSummary);
node.setRootFolder(rootFolder);
node.setNodeType(nodeType);
childNodes.add(node);
}
} else {
RemoteFile remoteFile = null;
if (resource.getRevision() instanceof SVNRevision.Number)
remoteFile = new RemoteFile(null, resource.getRepository(), new SVNUrl(rootFolder.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision(), (SVNRevision.Number) resource.getRevision(), null, null);
else
remoteFile = new RemoteFile(resource.getRepository(), new SVNUrl(rootFolder.getUrl().toString() + "/" + diffSummary[i].getPath()), resource.getRevision());
remoteFile.setPegRevision(pegRevision);
if (isChild(remoteFile)) {
SummaryEditionNode node = new SummaryEditionNode(remoteFile, pegRevision);
node.setDiffSummary(diffSummary);
node.setRootFolder(rootFolder);
node.setNodeType(nodeType);
childNodes.add(node);
}
}
}
}
SummaryEditionNode[] childNodeArray = new SummaryEditionNode[childNodes.size()];
childNodes.toArray(childNodeArray);
Arrays.sort(childNodeArray);
return childNodeArray;
}
use of org.tigris.subversion.subclipse.core.resources.RemoteFolder 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.resources.RemoteFolder 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();
}
Aggregations