use of org.tigris.subversion.subclipse.core.history.ILogEntry 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.history.ILogEntry 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.history.ILogEntry in project subclipse by subclipse.
the class OpenBugUrlAction method isEnabled.
protected boolean isEnabled() throws TeamException {
Object[] selectedObjects = selection.toArray();
for (int i = 0; i < selectedObjects.length; i++) {
if (selectedObjects[i] instanceof ILogEntry) {
ILogEntry logEntry = (ILogEntry) selectedObjects[i];
ProjectProperties projectProperties = ProjectProperties.getProjectProperties(logEntry.getResource().getResource());
if (projectProperties == null)
return false;
LinkList linkList = projectProperties.getLinkList(logEntry.getComment());
return linkList.getUrls().length != 0;
}
}
return false;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method getLastElement.
private ILogEntry getLastElement() {
ILogEntry lastElement = null;
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
Iterator iter = ss.iterator();
while (iter.hasNext()) {
ILogEntry element = (ILogEntry) iter.next();
if (lastElement == null || element.getRevision().getNumber() < lastElement.getRevision().getNumber())
lastElement = element;
}
}
return lastElement;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method getRevisionRanges.
private SVNRevisionRange[] getRevisionRanges() {
List revisionRanges = new ArrayList();
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
List selectionList = ss.toList();
TableItem[] items = tableHistoryViewer.getTable().getItems();
SVNRevision revision1 = null;
SVNRevision revision2 = null;
for (int i = 0; i < items.length; i++) {
if (items[i].getData() instanceof ILogEntry) {
ILogEntry logEntry = (ILogEntry) items[i].getData();
if (selectionList.contains(logEntry)) {
if (revision1 == null) {
revision1 = logEntry.getRevision();
}
revision2 = logEntry.getRevision();
revertEnabled = true;
LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
if (changePaths != null) {
for (LogEntryChangePath changePath : changePaths) {
if (changePath.getPath().equals(remoteResource.getRepositoryRelativePath())) {
if (changePath.getAction() == 'A') {
revertEnabled = false;
}
break;
}
}
}
} else {
if (revision1 != null) {
SVNRevisionRange revisionRange = new SVNRevisionRange(revision1, revision2);
revisionRanges.add(revisionRange);
revision1 = null;
revision2 = null;
}
}
}
}
if (revision1 != null) {
SVNRevisionRange revisionRange = new SVNRevisionRange(revision1, revision2);
revisionRanges.add(revisionRange);
}
}
SVNRevisionRange[] revisionRangeArray = new SVNRevisionRange[revisionRanges.size()];
revisionRanges.toArray(revisionRangeArray);
return revisionRangeArray;
}
Aggregations