use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method getFirstElement.
private ILogEntry getFirstElement() {
ILogEntry firstElement = 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 (firstElement == null || element.getRevision().getNumber() > firstElement.getRevision().getNumber())
firstElement = element;
}
}
return firstElement;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method getSwitchAction.
// get switch action (context menu)
private IAction getSwitchAction() {
if (switchAction == null) {
switchAction = new Action() {
public void run() {
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
IResource[] resources = { resource };
SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(resources, currentSelection.getRevision().getNumber());
SvnWizard wizard = new SvnWizard(switchPage);
SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
SVNUrl[] svnUrls = switchPage.getUrls();
SVNRevision svnRevision = switchPage.getRevision();
SwitchOperation switchOperation = new SwitchOperation(getSite().getPage().getActivePart(), resources, svnUrls, svnRevision);
switchOperation.setDepth(switchPage.getDepth());
switchOperation.setSetDepth(switchPage.isSetDepth());
switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
switchOperation.setForce(switchPage.isForce());
switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
switchOperation.setConflictResolver(switchPage.getConflictResolver());
try {
switchOperation.run();
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), switchAction.getText(), e.getMessage());
}
}
}
}
}
};
}
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
switchAction.setText(Policy.bind("HistoryView.switchToRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + currentSelection.getRevision().getNumber()));
}
}
switchAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_SWITCH));
return switchAction;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method fillTableMenu.
private void fillTableMenu(IMenuManager manager) {
// file actions go first (view file)
manager.add(new Separator(IWorkbenchActionConstants.GROUP_FILE));
// Add the "Add to Workspace" action if 1 revision is selected.
ISelection sel = tableHistoryViewer.getSelection();
if (!sel.isEmpty()) {
if (sel instanceof IStructuredSelection) {
if (((IStructuredSelection) sel).size() == 1) {
if (resource != null && resource instanceof IFile) {
manager.add(getGetContentsAction());
manager.add(getUpdateToRevisionAction());
}
// manager.add(getShowDifferencesAsUnifiedDiffAction());
// if (resource != null) {
manager.add(getCreateTagFromRevisionAction());
// }
manager.add(getSetCommitPropertiesAction());
manager.add(getShowRevisionPropertiesAction());
ILogEntry logEntry = (ILogEntry) ((IStructuredSelection) sel).getFirstElement();
if (logEntry.getNumberOfChildren() > 0)
manager.add(getShowRevisionsAction());
}
if (resource != null) {
manager.add(getRevertChangesAction());
if (((IStructuredSelection) sel).size() == 1)
manager.add(getSwitchAction());
}
// $NON-NLS-1$
manager.add(new Separator("exportImportGroup"));
getGenerateChangeLogAction().setEnabled(!store.getBoolean(ISVNUIConstants.PREF_FETCH_CHANGE_PATH_ON_DEMAND));
manager.add(getGenerateChangeLogAction());
}
}
// $NON-NLS-1$
manager.add(new Separator("additions"));
manager.add(getRefreshAction());
// $NON-NLS-1$
manager.add(new Separator("additions-end"));
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry 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.history.ILogEntry 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