|
15 | 15 |
|
16 | 16 | import org.eclipse.compare.CompareConfiguration; |
17 | 17 | import org.eclipse.compare.CompareUI; |
| 18 | +import org.eclipse.compare.CompareViewerPane; |
18 | 19 | import org.eclipse.compare.structuremergeviewer.ICompareInput; |
19 | 20 | import org.eclipse.core.resources.IFile; |
20 | 21 | import org.eclipse.core.resources.IFileState; |
21 | 22 | import org.eclipse.core.runtime.CoreException; |
22 | 23 | import org.eclipse.jface.action.IAction; |
| 24 | +import org.eclipse.jface.action.IToolBarManager; |
| 25 | +import org.eclipse.swt.SWT; |
| 26 | +import org.eclipse.swt.events.SelectionAdapter; |
| 27 | +import org.eclipse.swt.events.SelectionEvent; |
| 28 | +import org.eclipse.swt.widgets.Composite; |
| 29 | +import org.eclipse.swt.widgets.Control; |
| 30 | +import org.eclipse.swt.widgets.Event; |
23 | 31 | import org.eclipse.swt.widgets.Shell; |
| 32 | +import org.eclipse.swt.widgets.Tree; |
24 | 33 | import org.eclipse.team.internal.ui.TeamUIMessages; |
25 | 34 | import org.eclipse.team.internal.ui.TeamUIPlugin; |
26 | 35 | import org.eclipse.team.internal.ui.Utils; |
27 | 36 | import org.eclipse.team.ui.history.HistoryPageCompareEditorInput; |
28 | 37 | import org.eclipse.team.ui.history.IHistoryPageSource; |
| 38 | +import org.eclipse.ui.part.IPage; |
29 | 39 |
|
30 | 40 | public class ReplaceLocalHistory extends ShowLocalHistory { |
31 | 41 |
|
@@ -54,6 +64,48 @@ public boolean isEditionSelectionDialog() { |
54 | 64 | public String getOKButtonLabel() { |
55 | 65 | return TeamUIMessages.ReplaceLocalHistory_0; |
56 | 66 | } |
| 67 | + |
| 68 | + @Override |
| 69 | + protected IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager) { |
| 70 | + var page = super.createPage(parent, toolBarManager); |
| 71 | + Tree tree = getTree(page); |
| 72 | + runDefaultSelectionEventOnSelectionChange(tree); |
| 73 | + return page; |
| 74 | + } |
| 75 | + |
| 76 | + private void runDefaultSelectionEventOnSelectionChange(Tree tree) { |
| 77 | + if (tree == null) { |
| 78 | + return; |
| 79 | + } |
| 80 | + tree.addSelectionListener(new SelectionAdapter() { |
| 81 | + |
| 82 | + @Override |
| 83 | + public void widgetSelected(SelectionEvent e) { |
| 84 | + if (tree.getSelectionCount() != 1) { |
| 85 | + return; |
| 86 | + } |
| 87 | + Event event = new Event(); |
| 88 | + event.item = e.item; |
| 89 | + tree.notifyListeners(SWT.DefaultSelection, event); |
| 90 | + } |
| 91 | + }); |
| 92 | + } |
| 93 | + private Tree getTree(IPage page) { |
| 94 | + Control control = page.getControl(); |
| 95 | + if (!(control instanceof Composite composite)) { |
| 96 | + return null; |
| 97 | + } |
| 98 | + Control[] children = composite.getChildren(); |
| 99 | + if (children == null) { |
| 100 | + return null; |
| 101 | + } |
| 102 | + for (Control child : children) { |
| 103 | + if (child instanceof Tree t) { |
| 104 | + return t; |
| 105 | + } |
| 106 | + } |
| 107 | + return null; |
| 108 | + } |
57 | 109 | @Override |
58 | 110 | public boolean okPressed() { |
59 | 111 | try { |
|
0 commit comments