use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.
private IAction getCompareWithPreviousChangedPathAction() {
if (compareWithPreviousChangedPathAction == null) {
compareWithPreviousChangedPathAction = new Action() {
public void run() {
CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
delegate.init(this);
ISVNRemoteResource remoteResource1 = null;
Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
if (firstSelection instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
try {
remoteResource1 = logEntryChangePath.getRemoteResource();
} catch (SVNException e1) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
return;
}
} else if (firstSelection instanceof HistoryFolder) {
HistoryFolder historyFolder = (HistoryFolder) firstSelection;
Object[] children = historyFolder.getChildren();
if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
try {
SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
} catch (Exception e) {
}
}
}
if (remoteResource1 == null) {
return;
}
int from = Integer.parseInt(remoteResource1.getRevision().toString());
from--;
String to = Integer.toString(from);
SVNRevision toRevision = null;
try {
toRevision = SVNRevision.getRevision(to);
} catch (ParseException e) {
}
ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
ISVNRemoteResource remoteResource2;
if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
} else {
remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
}
remoteResources[0] = remoteResource1;
remoteResources[1] = remoteResource2;
delegate.selectionChanged(this, new StructuredSelection(remoteResources));
delegate.setRemoteResources(remoteResources);
delegate.setLocalResource(remoteResource1.getResource());
delegate.setLocalResources(remoteResources);
SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
delegate.setPegRevisions(pegRevisions);
delegate.run(this);
}
};
}
return compareWithPreviousChangedPathAction;
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class SVNHistoryPage method inputSet.
public boolean inputSet() {
Object input = getInput();
if (input instanceof IResource) {
IResource res = (IResource) input;
RepositoryProvider teamProvider = RepositoryProvider.getProvider(res.getProject(), SVNProviderPlugin.getTypeId());
if (teamProvider != null) {
try {
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(res);
LocalResourceStatus localResourceStatus = (localResource != null) ? localResource.getStatus() : null;
if (localResource != null && localResourceStatus.isManaged() && (!localResourceStatus.isAdded() || localResourceStatus.isCopied())) {
this.resource = res;
this.remoteResource = localResource.getBaseResource();
this.projectProperties = ProjectProperties.getProjectProperties(res);
boolean includeBugs = projectProperties != null;
boolean includeTags = tagsPropertySet(res);
if (includeTags != this.includeTags || this.includeBugs != includeBugs) {
this.includeTags = includeTags;
this.includeBugs = includeBugs;
refreshTable();
}
this.historyTableProvider.setRemoteResource(this.remoteResource);
this.historyTableProvider.setProjectProperties(this.projectProperties);
if (historySearchViewerFilter != null) {
// HistorySearchViewerFilter[] filters = { historySearchViewerFilter };
// this.tableHistoryViewer.setFilters(filters);
this.tableHistoryViewer.resetFilters();
this.tableHistoryViewer.addFilter(historySearchViewerFilter);
historySearchDialog = new HistorySearchDialog(getSite().getShell(), remoteResource);
historySearchDialog.setSearchAll(false);
historySearchDialog.setStartRevision(historySearchViewerFilter.getStartRevision());
historySearchDialog.setEndRevision(historySearchViewerFilter.getEndRevision());
historySearchViewerFilter = null;
getClearSearchAction().setEnabled(true);
} else {
this.tableHistoryViewer.resetFilters();
getClearSearchAction().setEnabled(false);
}
this.tableHistoryViewer.setInput(this.remoteResource);
// setTitleToolTip(baseResource.getRepositoryRelativePath());
return true;
}
} catch (TeamException e) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e);
}
}
} else if (input instanceof ISVNRemoteResource) {
this.resource = null;
this.remoteResource = (ISVNRemoteResource) input;
boolean includeTags = tagsPropertySet(remoteResource);
if (includeTags != this.includeTags) {
this.includeTags = includeTags;
refreshTable();
}
try {
this.projectProperties = ProjectProperties.getProjectProperties(this.remoteResource);
} catch (SVNException e) {
if (!e.operationInterrupted()) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e);
}
}
boolean includeBugs = projectProperties != null;
if (includeTags != this.includeTags || this.includeBugs != includeBugs) {
this.includeTags = includeTags;
this.includeBugs = includeBugs;
refreshTable();
}
this.historyTableProvider.setRemoteResource(this.remoteResource);
this.historyTableProvider.setProjectProperties(this.projectProperties);
if (historySearchViewerFilter != null) {
// HistorySearchViewerFilter[] filters = { historySearchViewerFilter };
// this.tableHistoryViewer.setFilters(filters);
this.tableHistoryViewer.resetFilters();
this.tableHistoryViewer.addFilter(historySearchViewerFilter);
historySearchDialog = new HistorySearchDialog(getSite().getShell(), remoteResource);
historySearchDialog.setSearchAll(false);
historySearchDialog.setStartRevision(historySearchViewerFilter.getStartRevision());
historySearchDialog.setEndRevision(historySearchViewerFilter.getEndRevision());
historySearchViewerFilter = null;
getClearSearchAction().setEnabled(true);
} else {
this.tableHistoryViewer.resetFilters();
getClearSearchAction().setEnabled(false);
}
this.tableHistoryViewer.setInput(this.remoteResource);
// setTitleToolTip(remoteResource.getRepositoryRelativePath());
return true;
}
return false;
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class SVNHistoryPage method getSetCommitPropertiesAction.
private IAction getSetCommitPropertiesAction() {
// set Action (context menu)
if (setCommitPropertiesAction == null) {
setCommitPropertiesAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.setCommitProperties")) {
public void run() {
try {
final ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
final ILogEntry ourSelection = getLogEntry((IStructuredSelection) selection);
// Failing that, try the resource originally selected by the user if
// from the Team menu
// TODO: Search all paths from currentSelection and find the
// shortest path and
// get the resources for that instance (in order to get the 'best'
// "bugtraq" properties)
final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : (ourSelection.getRemoteResource() != null) ? ProjectProperties.getProjectProperties(ourSelection.getRemoteResource()) : ProjectProperties.getProjectProperties(// will return null!
remoteResource);
final ISVNResource svnResource = ourSelection.getRemoteResource() != null ? ourSelection.getRemoteResource() : ourSelection.getResource();
SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(getSite().getShell(), ourSelection.getRevision(), resource, projectProperties);
// Set previous text - the text to edit
dialog.setOldAuthor(ourSelection.getAuthor());
dialog.setOldComment(ourSelection.getComment());
boolean doCommit = (dialog.open() == Window.OK);
if (doCommit) {
final String author;
final String commitComment;
if (ourSelection.getAuthor().equals(dialog.getAuthor()))
author = null;
else
author = dialog.getAuthor();
if (ourSelection.getComment().equals(dialog.getComment()))
commitComment = null;
else
commitComment = dialog.getComment();
final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(svnResource.getRepository(), ourSelection.getRevision(), commitComment, author);
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
command.run(monitor);
} catch (SVNException e) {
throw new InvocationTargetException(e);
} finally {
if (ourSelection instanceof LogEntry) {
LogEntry logEntry = (LogEntry) ourSelection;
if (command.isLogMessageChanged())
logEntry.setComment(commitComment);
if (command.isAuthorChanged())
logEntry.setAuthor(author);
}
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
tableHistoryViewer.refresh();
tableHistoryViewer.setSelection(selection, true);
}
});
}
}
});
}
} catch (InvocationTargetException e) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_NONTEAM_EXCEPTIONS);
} catch (InterruptedException e) {
// Do nothing
} catch (SVNException e) {
// TODO Auto-generated catch block
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
}
// we don't allow multiple selection
public boolean isEnabled() {
ISelection selection = getSelection();
return selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
}
};
}
return setCommitPropertiesAction;
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class SVNHistoryPage method getGetAllAction.
// Get Get All action (toolbar)
private IAction getGetAllAction() {
if (getAllAction == null) {
SVNUIPlugin plugin = SVNUIPlugin.getPlugin();
getAllAction = new Action(Policy.bind("HistoryView.getAll"), // $NON-NLS-1$
plugin.getImageDescriptor(ISVNUIConstants.IMG_GET_ALL)) {
public void run() {
final ISVNRemoteResource remoteResource = historyTableProvider.getRemoteResource();
if (fetchAllLogEntriesJob == null) {
fetchAllLogEntriesJob = new FetchAllLogEntriesJob();
}
if (fetchAllLogEntriesJob.getState() != Job.NONE) {
fetchAllLogEntriesJob.cancel();
try {
fetchAllLogEntriesJob.join();
} catch (InterruptedException e) {
SVNUIPlugin.log(new SVNException(Policy.bind("HistoryView.errorFetchingEntries", remoteResource.getName()), // $NON-NLS-1$
e));
}
}
fetchAllLogEntriesJob.setRemoteFile(remoteResource);
Utils.schedule(fetchAllLogEntriesJob, getSite());
}
};
// $NON-NLS-1$
getAllAction.setToolTipText(Policy.bind("HistoryView.getAll"));
}
return getAllAction;
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class SVNHistoryPage method createTableHistory.
protected void createTableHistory(Composite parent) {
boolean redraw = false;
if (tableParent == null) {
tableParent = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
tableParent.setLayout(layout);
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalIndent = 0;
gridData.verticalIndent = 0;
tableParent.setLayoutData(gridData);
} else {
Control[] children = tableParent.getChildren();
for (int i = 0; i < children.length; i++) {
children[i].dispose();
}
redraw = true;
}
this.historyTableProvider = new HistoryTableProvider(SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, // $NON-NLS-1$
"SVNHistoryPage");
this.historyTableProvider.setRemoteResource(remoteResource);
this.historyTableProvider.setProjectProperties(this.projectProperties);
historyTableProvider.setIncludeMergeRevisions(store.getBoolean(ISVNUIConstants.PREF_INCLUDE_MERGED_REVISIONS));
historyTableProvider.setIncludeTags(includeTags);
historyTableProvider.setIncludeBugs(includeBugs);
this.tableHistoryViewer = historyTableProvider.createTable(tableParent);
if (redraw) {
tableParent.layout(true);
tableParent.redraw();
}
this.tableHistoryViewer.getTable().addKeyListener(this);
// set the content provider for the table
this.tableHistoryViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
// Short-circuit to optimize
if (entries != null)
return entries;
if (!(inputElement instanceof ISVNRemoteResource))
return null;
final ISVNRemoteResource remoteResource = (ISVNRemoteResource) inputElement;
int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH);
// If we are filtering by revision range, override entries to fetch.
if (historySearchDialog != null && !historySearchDialog.getSearchAllLogs()) {
if (historySearchDialog.getStartRevision() != null || historySearchDialog.getEndRevision() != null) {
if (getClearSearchAction().isEnabled())
entriesToFetch = 0;
}
}
if (entriesToFetch > 0)
fetchLogEntriesJob = new FetchLogEntriesJob();
else
fetchLogEntriesJob = new FetchAllLogEntriesJob();
if (fetchLogEntriesJob.getState() != Job.NONE) {
fetchLogEntriesJob.cancel();
try {
fetchLogEntriesJob.join();
} catch (InterruptedException e) {
SVNUIPlugin.log(new SVNException(Policy.bind("HistoryView.errorFetchingEntries", remoteResource.getName()), // $NON-NLS-1$
e));
}
}
fetchLogEntriesJob.setRemoteFile(remoteResource);
IWorkbenchWindow window = SVNUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow();
if (window.getActivePage() != null && window.getActivePage().getActivePart() != null && window.getActivePage().getActivePart().getSite() != null) {
Utils.schedule(fetchLogEntriesJob, window.getActivePage().getActivePart().getSite());
} else {
Utils.schedule(fetchLogEntriesJob, null);
}
return new Object[0];
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
entries = null;
lastEntry = null;
revisionStart = SVNRevision.HEAD;
}
});
// set the selectionchanged listener for the table
// updates the comments and affected paths when selection changes
this.tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
private ILogEntry currentLogEntry;
private int currentSelectionSize = -1;
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
ILogEntry logEntry = getLogEntry((IStructuredSelection) selection);
if (logEntry != currentLogEntry || ((IStructuredSelection) selection).size() != currentSelectionSize) {
this.currentLogEntry = logEntry;
this.currentSelectionSize = ((IStructuredSelection) selection).size();
updatePanels(selection);
}
SVNHistoryPage.this.selection = selection;
}
});
// Double click open action
this.tableHistoryViewer.getTable().addListener(SWT.DefaultSelection, new Listener() {
public void handleEvent(Event e) {
if (toggleCompareToPreviousAction.isChecked()) {
getCompareWithPreviousAction().run();
} else {
getOpenRemoteFileAction().run();
}
}
});
// Contribute actions to popup menu for the table
{
MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable());
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuMgr) {
fillTableMenu(menuMgr);
}
});
menuMgr.setRemoveAllWhenShown(true);
tableHistoryViewer.getTable().setMenu(menu);
getHistoryPageSite().getPart().getSite().registerContextMenu(menuMgr, tableHistoryViewer);
}
if (redraw) {
parent.layout(true);
parent.redraw();
}
}
Aggregations