use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SVNHistoryPage method getRevertChangesAction.
// get revert changes action (context menu)
private IAction getRevertChangesAction() {
revisionRanges = getRevisionRanges();
if (revertChangesAction == null) {
revertChangesAction = new Action() {
public void run() {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
final IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevision"), Policy.bind("HistoryView.confirmRevertRevision", // $NON-NLS-1$
resource.getFullPath().toString())))
return;
} else {
if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevisions"), Policy.bind("HistoryView.confirmRevertRevisions", // $NON-NLS-1$
resource.getFullPath().toString())))
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ILogEntry firstElement = getFirstElement();
ILogEntry lastElement = getLastElement();
final IResource[] resources = { resource };
try {
final SVNUrl path1 = new SVNUrl(firstElement.getResource().getUrl() + "@HEAD");
final SVNUrl path2 = new SVNUrl(lastElement.getResource().getUrl() + "@HEAD");
for (int i = 0; i < revisionRanges.length; i++) {
final SVNRevision revision1 = revisionRanges[i].getFromRevision();
final SVNRevision revision2 = new SVNRevision.Number(((SVNRevision.Number) revisionRanges[i].getToRevision()).getNumber() - 1);
WorkspaceAction mergeAction = new WorkspaceAction() {
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
new MergeOperation(getSite().getPage().getActivePart(), resources, path1, revision1, path2, revision2).run();
}
};
mergeAction.run(null);
}
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), revertChangesAction.getText(), e.getMessage());
}
}
});
}
};
}
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
revertChangesAction.setText(Policy.bind("HistoryView.revertChangesFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + currentSelection.getRevision().getNumber()));
}
if (ss.size() > 1) {
revertChangesAction.setText(// $NON-NLS-1$
Policy.bind("HistoryView.revertChangesFromRevisions"));
}
}
revertChangesAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_MARKMERGED));
revertChangesAction.setEnabled(revertEnabled);
return revertChangesAction;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class ShowRevisionsDialog method getShowDifferencesAsUnifiedDiffAction.
// get differences as unified diff action (context menu)
private IAction getShowDifferencesAsUnifiedDiffAction() {
if (showDifferencesAsUnifiedDiffAction == null) {
showDifferencesAsUnifiedDiffAction = new Action(Policy.bind("HistoryView.showDifferences"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
ISVNUIConstants.IMG_MENU_DIFF)) {
public void run() {
ISelection selection = treeHistoryViewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ILogEntry currentSelection = (ILogEntry) ss.getFirstElement();
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setText("Select Unified Diff Output File");
dialog.setFileName(// $NON-NLS-1$
"revision" + currentSelection.getRevision().getNumber() + ".diff");
String outFile = dialog.open();
if (outFile != null) {
final SVNUrl url = currentSelection.getResource().getUrl();
final SVNRevision oldUrlRevision = new SVNRevision.Number(currentSelection.getRevision().getNumber() - 1);
final SVNRevision newUrlRevision = currentSelection.getRevision();
final File file = new File(outFile);
if (file.exists()) {
if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.diff(url, oldUrlRevision, newUrlRevision, file, true);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
}
}
};
}
return showDifferencesAsUnifiedDiffAction;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class ShowRevisionsDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
if (title == null)
// $NON-NLS-1$
getShell().setText(Policy.bind("HistoryView.showMergedRevisions"));
else
getShell().setText(title);
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(data);
sashForm = new SashForm(composite, SWT.VERTICAL);
sashForm.setLayout(new GridLayout());
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite historyGroup = new Composite(sashForm, SWT.NULL);
historyGroup.setLayout(new GridLayout());
historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Tree tree = new Tree(historyGroup, SWT.BORDER | SWT.FULL_SELECTION);
treeHistoryViewer = new TreeViewer(tree);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = WIDTH_HINT;
data.heightHint = LOG_HEIGHT_HINT;
treeHistoryViewer.getTree().setLayoutData(data);
treeHistoryViewer.getTree().setHeaderVisible(true);
revisionColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
revisionColumn.setResizable(true);
// $NON-NLS-1$
revisionColumn.setText(Policy.bind("HistoryView.revision"));
int revisionWidth = 75;
int tagsWidth = 225;
int dateWidth = 100;
int authorWidth = 100;
int commentWidth = 300;
try {
revisionWidth = settings.getInt("ShowRevisionsDialog.width_revision");
dateWidth = settings.getInt("ShowRevisionsDialog.width_date");
authorWidth = settings.getInt("ShowRevisionsDialog.width_author");
commentWidth = settings.getInt("ShowRevisionsDialog.width_comment");
tagsWidth = settings.getInt("ShowRevisionsDialog.width_tag");
} catch (Exception e) {
}
revisionColumn.setWidth(revisionWidth);
if (includeTags) {
tagsColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
tagsColumn.setResizable(true);
// $NON-NLS-1$
tagsColumn.setText(Policy.bind("HistoryView.tags"));
tagsColumn.setWidth(tagsWidth);
}
dateColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
dateColumn.setResizable(true);
// $NON-NLS-1$
dateColumn.setText(Policy.bind("HistoryView.date"));
dateColumn.setWidth(dateWidth);
authorColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
authorColumn.setResizable(true);
// $NON-NLS-1$
authorColumn.setText(Policy.bind("HistoryView.author"));
authorColumn.setWidth(authorWidth);
commentColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
commentColumn.setResizable(true);
// $NON-NLS-1$
commentColumn.setText(Policy.bind("HistoryView.comment"));
commentColumn.setWidth(commentWidth);
treeHistoryViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
ILogEntry entry = (ILogEntry) element;
int index = columnIndex;
if (index > 0 && !includeTags)
index++;
switch(index) {
case COL_REVISION:
String revision = entry.getRevision().toString();
return revision;
case COL_TAGS:
return AliasManager.getAliasesAsString(entry.getTags());
case COL_DATE:
Date date = entry.getDate();
// $NON-NLS-1$
if (date == null)
return Policy.bind("notAvailable");
return DateFormat.getInstance().format(date);
case COL_AUTHOR:
// $NON-NLS-1$
if (entry.getAuthor() == null)
return Policy.bind("noauthor");
return entry.getAuthor();
case COL_COMMENT:
String comment = entry.getComment();
// $NON-NLS-1$
if (comment == null)
return "";
// $NON-NLS-1$
int rIndex = comment.indexOf("\r");
// $NON-NLS-1$
int nIndex = comment.indexOf("\n");
if ((rIndex == -1) && (nIndex == -1))
return comment;
if ((rIndex == 0) || (nIndex == 0))
// $NON-NLS-1$
return Policy.bind("HistoryView.[...]_4");
if (rIndex != -1)
return Policy.bind("SVNCompareRevisionsInput.truncate", // $NON-NLS-1$
comment.substring(0, rIndex));
else
return Policy.bind("SVNCompareRevisionsInput.truncate", // $NON-NLS-1$
comment.substring(0, nIndex));
}
return null;
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
treeHistoryViewer.setContentProvider(new WorkbenchContentProvider() {
public Object[] getChildren(Object element) {
if (element instanceof ILogEntry) {
return ((ILogEntry) element).getChildMessages();
}
ILogEntry[] logEntries = { logEntry };
return logEntries;
}
public Object[] getElements(Object element) {
return getChildren(element);
}
public boolean hasChildren(Object element) {
if (element instanceof ILogEntry) {
return ((ILogEntry) element).getNumberOfChildren() > 0;
}
return false;
}
});
treeHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection == null || !(selection instanceof IStructuredSelection)) {
// $NON-NLS-1$
textViewer.setDocument(new Document(""));
changePathsViewer.setInput(null);
return;
}
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() != 1) {
// $NON-NLS-1$
textViewer.setDocument(new Document(""));
changePathsViewer.setInput(null);
return;
}
LogEntry entry = (LogEntry) ss.getFirstElement();
textViewer.setDocument(new Document(entry.getComment()));
changePathsViewer.setInput(entry);
}
});
if (resource == null)
treeHistoryViewer.setInput(remoteResource);
else
treeHistoryViewer.setInput(resource);
treeHistoryViewer.resetFilters();
treeHistoryViewer.expandToLevel(2);
MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(treeHistoryViewer.getTree());
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuMgr) {
fillTreeMenu(menuMgr);
}
});
menuMgr.setRemoveAllWhenShown(true);
treeHistoryViewer.getTree().setMenu(menu);
Composite commentGroup = new Composite(sashForm, SWT.NULL);
commentGroup.setLayout(new GridLayout());
commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY);
data = new GridData(GridData.FILL_BOTH);
data.heightHint = COMMENT_HEIGHT_HINT;
data.widthHint = WIDTH_HINT;
textViewer.getControl().setLayoutData(data);
Composite pathGroup = new Composite(sashForm, SWT.NULL);
pathGroup.setLayout(new GridLayout());
pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore();
int mode = store.getInt(ISVNUIConstants.PREF_AFFECTED_PATHS_MODE);
IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
if ((inputElement == null) || (!(inputElement instanceof ILogEntry))) {
return null;
}
ILogEntry logEntry = (ILogEntry) inputElement;
return logEntry.getLogEntryChangePaths();
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
};
switch(mode) {
case ISVNUIConstants.MODE_COMPRESSED:
changePathsViewer = new ChangePathsTreeViewer(pathGroup, historyPage);
break;
case ISVNUIConstants.MODE_FLAT2:
changePathsViewer = new ChangePathsFlatViewer(pathGroup, historyPage);
break;
default:
changePathsViewer = new ChangePathsTableProvider(pathGroup, contentProvider);
break;
}
try {
int[] weights = new int[3];
// $NON-NLS-1$
weights[0] = settings.getInt("ShowRevisionsDialog.weights.0");
// $NON-NLS-1$
weights[1] = settings.getInt("ShowRevisionsDialog.weights.1");
// $NON-NLS-1$
weights[2] = settings.getInt("ShowRevisionsDialog.weights.2");
sashForm.setWeights(weights);
} catch (Exception e) {
}
if (selectFirst && treeHistoryViewer.getTree().getItemCount() > 0) {
TreeItem item = treeHistoryViewer.getTree().getItem(0);
treeHistoryViewer.getTree().setSelection(item);
// Method not available in 3.3
// treeHistoryViewer.getTree().select(item);
treeHistoryViewer.setSelection(treeHistoryViewer.getSelection());
changePathsViewer.refresh();
if (changePathsViewer instanceof ChangePathsTreeViewer)
((ChangePathsTreeViewer) changePathsViewer).expandAll();
}
return composite;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class SvnWizardCompareMultipleResourcesWithBranchTagPage method showLog.
protected void showLog() {
ISVNRemoteResource remoteResource = null;
try {
remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(urlCombo.getText()));
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
urlCombo.getText());
return;
}
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
setPageComplete(canFinish());
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class CheckoutWizardCheckoutAsMultiplePage method showLog.
private void showLog() {
HistoryDialog dialog = new HistoryDialog(getShell(), getCommonParent());
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
revisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
revisionText.setEnabled(true);
headButton.setSelection(false);
}
Aggregations