use of org.tigris.subversion.subclipse.core.resources.RemoteResource in project subclipse by subclipse.
the class SVNHistoryPage method getGetContentsAction.
// get contents Action (context menu)
private IAction getGetContentsAction() {
if (getContentsAction == null) {
getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), new // $NON-NLS-1$
IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
monitor.beginTask(null, 100);
try {
if (remoteFile != null) {
if (confirmOverwrite()) {
if (remoteFile instanceof RemoteResource) {
if (resource != null) {
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
((RemoteResource) remoteFile).setPegRevision(localResource.getRevision());
} else {
((RemoteResource) remoteFile).setPegRevision(SVNRevision.HEAD);
}
}
InputStream in = ((IResourceVariant) remoteFile).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
IFile file = (IFile) resource;
file.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
}
}
} catch (TeamException e) {
throw new CoreException(e.getStatus());
} finally {
monitor.done();
}
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION);
}
return getContentsAction;
}
use of org.tigris.subversion.subclipse.core.resources.RemoteResource in project subclipse by subclipse.
the class SvnWizardAnnotatePage method createControls.
public void createControls(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(data);
includeMergedRevisionsButton = new Button(composite, SWT.CHECK);
includeMergedRevisionsButton.setText(// $NON-NLS-1$
Policy.bind("AnnotateDialog.includeMerged"));
includeMergedRevisionsButton.setSelection(// $NON-NLS-1$
settings.getBoolean("AnnotateDialog.includeMerged"));
includeMergedRevisionsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
settings.put("AnnotateDialog.includeMerged", // $NON-NLS-1$
includeMergedRevisionsButton.getSelection());
}
});
ignoreMimeTypeButton = new Button(composite, SWT.CHECK);
// $NON-NLS-1$
ignoreMimeTypeButton.setText(Policy.bind("AnnotateDialog.ignoreMimeType"));
Group fromGroup = new Group(composite, SWT.NONE);
// $NON-NLS-1$
fromGroup.setText(Policy.bind("AnnotateDialog.from"));
GridLayout fromLayout = new GridLayout();
fromLayout.numColumns = 3;
fromGroup.setLayout(fromLayout);
fromGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Label fromRevisionLabel = new Label(fromGroup, SWT.NONE);
// $NON-NLS-1$
fromRevisionLabel.setText(Policy.bind("AnnotateDialog.revision"));
fromRevisionText = new Text(fromGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 40;
fromRevisionText.setLayoutData(data);
// $NON-NLS-1$
fromRevisionText.setText("1");
selectFromRevisionButton = new Button(fromGroup, SWT.PUSH);
// $NON-NLS-1$
selectFromRevisionButton.setText(Policy.bind("AnnotateDialog.showLog"));
Group toGroup = new Group(composite, SWT.NONE);
// $NON-NLS-1$
toGroup.setText(Policy.bind("AnnotateDialog.to"));
GridLayout toLayout = new GridLayout();
toLayout.numColumns = 5;
toGroup.setLayout(toLayout);
toGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
toHeadButton = new Button(toGroup, SWT.RADIO);
// $NON-NLS-1$
toHeadButton.setText(Policy.bind("AnnotateDialog.head"));
toRevisionButton = new Button(toGroup, SWT.RADIO);
// $NON-NLS-1$
toRevisionButton.setText(Policy.bind("AnnotateDialog.toRevision"));
toRevisionText = new Text(toGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 40;
toRevisionText.setLayoutData(data);
toRevisionText.setEnabled(false);
if (toRevision == null) {
if (svnResource instanceof RemoteResource) {
if (((RemoteResource) svnResource).getPegRevision() != null) {
toRevision = ((RemoteResource) svnResource).getPegRevision();
}
}
}
if (toRevision == null)
toHeadButton.setSelection(true);
else {
toRevisionText.setText(toRevision.toString());
toRevisionButton.setSelection(true);
toRevisionText.setEnabled(true);
}
selectToRevisionButton = new Button(toGroup, SWT.PUSH);
// $NON-NLS-1$
selectToRevisionButton.setText(Policy.bind("AnnotateDialog.showToLog"));
SelectionListener selectionListener = getSelectionListener();
selectFromRevisionButton.addSelectionListener(selectionListener);
toHeadButton.addSelectionListener(selectionListener);
toRevisionButton.addSelectionListener(selectionListener);
selectToRevisionButton.addSelectionListener(selectionListener);
ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
setPageComplete(canFinish());
}
};
fromRevisionText.addModifyListener(modifyListener);
toRevisionText.addModifyListener(modifyListener);
FocusListener focusListener = new FocusAdapter() {
public void focusGained(FocusEvent e) {
((Text) e.getSource()).selectAll();
}
public void focusLost(FocusEvent e) {
((Text) e.getSource()).setText(((Text) e.getSource()).getText());
}
};
fromRevisionText.addFocusListener(focusListener);
toRevisionText.addFocusListener(focusListener);
}
use of org.tigris.subversion.subclipse.core.resources.RemoteResource 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.resources.RemoteResource 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.resources.RemoteResource in project subclipse by subclipse.
the class DifferencesDialog method compare.
private void compare() {
if (fromResource instanceof ISVNRemoteResource && toResource != null && toResource instanceof ISVNRemoteResource) {
SVNUrl fromUrl = null;
SVNUrl toUrl = null;
SVNRevision fromRevision;
SVNRevision toRevision;
if (fromHeadButton.getSelection())
fromRevision = SVNRevision.HEAD;
else {
int fromRevisionInt = Integer.parseInt(fromRevisionText.getText().trim());
long fromRevisionLong = fromRevisionInt;
fromRevision = new SVNRevision.Number(fromRevisionLong);
}
if (toHeadButton.getSelection())
toRevision = SVNRevision.HEAD;
else {
int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
long toRevisionLong = toRevisionInt;
toRevision = new SVNRevision.Number(toRevisionLong);
}
try {
fromUrl = new SVNUrl(fromUrlText.getText().trim());
toUrl = new SVNUrl(toUrlText.getText().trim());
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("DifferencesDialog.compare"), e.getMessage());
success = false;
return;
}
ISVNRemoteResource resource1 = null;
SVNRevision.Number lastChangedRevision1 = null;
ISVNRemoteResource resource2 = null;
SVNRevision.Number lastChangedRevision2 = null;
if (fromRevision instanceof SVNRevision.Number) {
lastChangedRevision1 = (SVNRevision.Number) fromRevision;
} else {
lastChangedRevision1 = ((ISVNRemoteResource) remoteResources[0]).getLastChangedRevision();
}
if (fromResource.isFolder()) {
resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
if (!fromUrl.equals(fromResource.getUrl())) {
try {
resource1.members(null);
} catch (TeamException e) {
resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
}
}
} else {
resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
if (!fromUrl.equals(fromResource.getUrl())) {
IStorage storage = null;
try {
storage = resource1.getStorage(null);
} catch (TeamException e) {
}
if (storage == null) {
resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
}
}
}
if (fromRevision instanceof SVNRevision.Number) {
if (usePegRevision && resource1 instanceof RemoteResource) {
((RemoteResource) resource1).setPegRevision(fromRevision);
}
}
if (toRevision instanceof SVNRevision.Number) {
lastChangedRevision2 = (SVNRevision.Number) toRevision;
} else {
lastChangedRevision2 = ((ISVNRemoteResource) remoteResources[1]).getLastChangedRevision();
}
if (toResource.isFolder()) {
resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
if (!toUrl.equals(toResource.getUrl())) {
try {
resource2.members(null);
} catch (TeamException e) {
resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
}
}
} else {
resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
if (!toUrl.equals(toResource.getUrl())) {
IStorage storage = null;
try {
storage = resource2.getStorage(null);
} catch (TeamException e) {
}
if (storage == null) {
resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
}
}
}
if (toRevision instanceof SVNRevision.Number) {
if (usePegRevision && resource2 instanceof RemoteResource) {
((RemoteResource) resource2).setPegRevision(toRevision);
}
}
ISVNRemoteResource[] remotes = { resource1, resource2 };
CompareRemoteResourcesAction compareAction = new CompareRemoteResourcesAction();
compareAction.setLocalResource(localResource);
compareAction.setRemoteResources(remotes);
compareAction.setPegRevisions(pegRevisions);
compareAction.setLocalResources(remoteResources);
try {
compareAction.execute(null);
} catch (InvocationTargetException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
} catch (InterruptedException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
Aggregations