diff --git a/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF index 62161645980..69f24141ff5 100644 --- a/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.ui; singleton:=true -Bundle-Version: 3.10.500.qualifier +Bundle-Version: 3.10.600.qualifier Bundle-Activator: org.eclipse.team.internal.ui.TeamUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java index e67388075a7..6e6e3e617db 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java @@ -336,9 +336,7 @@ private IWorkbenchPartSite getWorkbenchSite(IHistoryPageSite parentSite) { return null; } - @Override - public void createControl(Composite parent) { - + public final void createControl(Composite parent, boolean allowMultiSelection) { localComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; @@ -348,7 +346,7 @@ public void createControl(Composite parent) { data.grabExcessVerticalSpace = true; localComposite.setLayoutData(data); - treeViewer = createTree(localComposite); + treeViewer = createTree(localComposite, allowMultiSelection); contributeActions(); @@ -362,6 +360,11 @@ public void createControl(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(localComposite, IHelpContextIds.LOCAL_HISTORY_PAGE); } + @Override + public void createControl(Composite parent) { + createControl(parent, true); + } + private void contributeActions() { final IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); //Group by Date @@ -599,8 +602,12 @@ private boolean showGetContentsAction(ITreeSelection sel) { * @return the group control */ protected TreeViewer createTree(Composite parent) { + return createTree(parent, true); + } + + protected final TreeViewer createTree(Composite parent, boolean allowMultiSelection) { historyTableProvider = new LocalFileHistoryTableProvider(); - TreeViewer viewer = historyTableProvider.createTree(parent); + TreeViewer viewer = historyTableProvider.createTree(parent, allowMultiSelection); viewer.setContentProvider(new LocalHistoryContentProvider()); return viewer; } diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java index f685895eaae..72c1c634bfe 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java @@ -291,7 +291,15 @@ public void widgetSelected(SelectionEvent e) { * @return TableViewer */ public TreeViewer createTree(Composite parent) { - Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); + return createTree(parent, true); + } + + public TreeViewer createTree(Composite parent, boolean allowMultiSelection) { + int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION; + if (allowMultiSelection) { + style = style | SWT.MULTI; + } + Tree tree = new Tree(parent, style); tree.setHeaderVisible(true); tree.setLinesVisible(false); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/ReplaceLocalHistory.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/ReplaceLocalHistory.java index 9aa593b859e..ec6c6322a01 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/ReplaceLocalHistory.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/ReplaceLocalHistory.java @@ -13,19 +13,33 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.history; +import java.lang.reflect.InvocationTargetException; + import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareUI; +import org.eclipse.compare.CompareViewerPane; import org.eclipse.compare.structuremergeviewer.ICompareInput; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFileState; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.history.HistoryPageCompareEditorInput; import org.eclipse.team.ui.history.IHistoryPageSource; +import org.eclipse.ui.part.IPage; public class ReplaceLocalHistory extends ShowLocalHistory { @@ -46,6 +60,14 @@ private void showCompareInDialog(Shell shell, Object object){ cc.setLeftEditable(false); cc.setRightEditable(false); HistoryPageCompareEditorInput input = new HistoryPageCompareEditorInput(cc, pageSource, object) { + @Override + public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) + throws InvocationTargetException, InterruptedException { + // Avoid using super.run() on macOS as it causes layout issues. + // The compare viewer controls appear small and do not fill the entire dialog. + runnable.run(new NullProgressMonitor()); + } + @Override public boolean isEditionSelectionDialog() { return true; @@ -54,6 +76,48 @@ public boolean isEditionSelectionDialog() { public String getOKButtonLabel() { return TeamUIMessages.ReplaceLocalHistory_0; } + + @Override + protected IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager) { + var page = super.createPage(parent, toolBarManager, false); + Tree tree = getTree(page); + runDefaultSelectionEventOnSelectionChange(tree); + return page; + } + + private void runDefaultSelectionEventOnSelectionChange(Tree tree) { + if (tree == null) { + return; + } + tree.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + if (tree.getSelectionCount() != 1) { + return; + } + Event event = new Event(); + event.item = e.item; + tree.notifyListeners(SWT.DefaultSelection, event); + } + }); + } + private Tree getTree(IPage page) { + Control control = page.getControl(); + if (!(control instanceof Composite composite)) { + return null; + } + Control[] children = composite.getChildren(); + if (children == null) { + return null; + } + for (Control child : children) { + if (child instanceof Tree t) { + return t; + } + } + return null; + } @Override public boolean okPressed() { try { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/HistoryPageCompareEditorInput.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/HistoryPageCompareEditorInput.java index 79b87f5e714..f58329859b6 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/HistoryPageCompareEditorInput.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/HistoryPageCompareEditorInput.java @@ -31,6 +31,7 @@ import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.history.DialogHistoryPageSite; +import org.eclipse.team.internal.ui.history.LocalHistoryPage; import org.eclipse.team.ui.PageCompareEditorInput; import org.eclipse.ui.part.IPage; import org.eclipse.ui.part.Page; @@ -79,11 +80,23 @@ protected void handleDispose() { @Override protected IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager) { + return createPage(parent, toolBarManager, true); + } + + /** + * @since 3.10.600 + */ + protected final IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager, + boolean allowMultiSelection) { site = new DialogHistoryPageSite(parent.getShell()); historyPage = (IHistoryPage)pageSource.createPage(object); historyPage.setSite(site); site.setToolBarManager(toolBarManager); - ((Page) historyPage).createControl(parent); + if (historyPage instanceof LocalHistoryPage localHistoryPage) { + localHistoryPage.createControl(parent, allowMultiSelection); + } else { + ((Page) historyPage).createControl(parent); + } historyPage.setInput(object); String description = historyPage.getDescription(); if (description == null)