use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class RepositoriesView method getStatusLineMessage.
/**
* When selection is changed we update the status line
*/
private String getStatusLineMessage(ISelection selection) {
// $NON-NLS-1$
if (selection == null || selection.isEmpty())
return "";
// $NON-NLS-1$
if (!(selection instanceof IStructuredSelection))
return "";
IStructuredSelection s = (IStructuredSelection) selection;
if (s.size() > 1)
return Policy.bind("RepositoriesView.NItemsSelected", // $NON-NLS-1$
String.valueOf(s.size()));
Object element = SVNAction.getAdapter(s.getFirstElement(), ISVNResource.class);
if (element instanceof ISVNRemoteResource) {
ISVNRemoteResource res = (ISVNRemoteResource) element;
String name;
if (res.isContainer()) {
name = res.getRepositoryRelativePath();
} else {
name = res.getRepositoryRelativePath() + " " + // $NON-NLS-1$
((ISVNRemoteFile) res).getLastChangedRevision();
}
return Policy.bind("RepositoriesView.ResourceInRepository", name, // $NON-NLS-1$
res.getRepository().getLocation());
}
// $NON-NLS-1$
return Policy.bind("RepositoriesView.OneItemSelected");
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNCompareEditorInput method getLabel.
/**
* Returns the label for the given input element (which is a ResourceEditionNode).
*/
private String getLabel(ITypedElement element) {
if (element instanceof ResourceEditionNode) {
ISVNRemoteResource edition = ((ResourceEditionNode) element).getRemoteResource();
SVNRevision revision = edition.getLastChangedRevision();
if (revision == null) {
revision = edition.getRevision();
}
if (edition instanceof ISVNRemoteFile) {
return Policy.bind("nameAndRevision", edition.getName(), // $NON-NLS-1$
revision.toString());
}
if (edition.isContainer()) {
// $NON-NLS-1$
return Policy.bind("SVNCompareEditorInput.inHead", edition.getName());
} else {
return Policy.bind("SVNCompareEditorInput.repository", // $NON-NLS-1$
new Object[] { edition.getName(), revision.toString() });
}
}
return element.getName();
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNPristineCopyQuickDiffProvider method readDocument.
/**
* Creates a document and initializes it with the contents of a SVN remote resource.
*
* @param monitor the progress monitor
* @throws CoreException
*/
private void readDocument(IProgressMonitor monitor) throws CoreException {
if (!isReferenceInitialized)
return;
if (referenceDocument == null)
referenceDocument = new Document();
if (computeChange(monitor)) {
ISVNRemoteFile remoteFile = (ISVNRemoteFile) fLastSyncState.getBase();
if (remoteFile != null && documentProvider instanceof IStorageDocumentProvider) {
IStorageDocumentProvider provider = (IStorageDocumentProvider) documentProvider;
String encoding = provider.getEncoding(editor.getEditorInput());
if (encoding == null) {
encoding = provider.getDefaultEncoding();
}
if (monitor.isCanceled())
return;
InputStream stream = remoteFile.getStorage(monitor).getContents();
if (stream == null || monitor.isCanceled() || !isReferenceInitialized) {
return;
}
setDocumentContent(referenceDocument, stream, encoding);
} else {
// the remote is null, so ensure that the document is null
if (monitor.isCanceled())
return;
// $NON-NLS-1$
referenceDocument.set("");
}
if (DEBUG)
System.out.println("+ SVNQuickDiff: updating document " + (referenceDocument != null ? "remote found" : // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"remote empty"));
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNAction method getSelectedRemoteFiles.
/**
* Returns the selected remote files
*/
protected ISVNRemoteFile[] getSelectedRemoteFiles() {
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 ISVNRemoteFile) {
resources.add(next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(ISVNRemoteFile.class);
if (adapter instanceof ISVNRemoteFile) {
resources.add(adapter);
continue;
}
}
}
}
if (resources != null && !resources.isEmpty()) {
ISVNRemoteFile[] result = new ISVNRemoteFile[resources.size()];
resources.toArray(result);
return result;
}
return new ISVNRemoteFile[0];
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffActionWC method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
IResource[] resources = getSelectedResources();
boolean refreshFile = false;
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile && !resources[i].isSynchronized(Depth.immediates)) {
if (refreshFile || MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"))) {
refreshFile = true;
try {
resources[i].refreshLocal(Depth.immediates, new NullProgressMonitor());
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
} else {
break;
}
}
}
if (resources.length > 1) {
SvnWizardCompareMultipleResourcesWithBranchTagPage comparePage = new SvnWizardCompareMultipleResourcesWithBranchTagPage(resources);
SvnWizard wizard = new SvnWizard(comparePage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
if (dialog.open() == SvnWizardDialog.OK) {
ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
try {
SVNLocalBranchTagCompareInput compareInput = new SVNLocalBranchTagCompareInput(localResources, comparePage.getUrls(), comparePage.getRevision(), getTargetPart());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
return;
}
ShowDifferencesAsUnifiedDiffDialogWC dialog = new ShowDifferencesAsUnifiedDiffDialogWC(getShell(), resources[0], getTargetPart());
if (dialog.open() == ShowDifferencesAsUnifiedDiffDialogWC.OK) {
try {
if (dialog.isDiffToOutputFile())
dialog.getOperation().run();
if (!dialog.isDiffToOutputFile()) {
SVNRevision pegRevision = dialog.getPegRevision();
if (pegRevision == null) {
pegRevision = SVNRevision.HEAD;
}
if (resources[0] instanceof IContainer) {
ISVNRemoteFolder remoteFolder = new RemoteFolder(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFolder) remoteFolder).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFolder, pegRevision);
compareInput.setDiffOperation(dialog.getOperation());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFile) remoteFile).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFile, pegRevision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
}
Aggregations