1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 451392 - [visualizer] improve selection synchronization from MV view

to debug view back to cloned MV view(s)

Change-Id: I16abf3022a2b4fa0478624c1a9a6b4589cbdc311
Reviewed-on: https://git.eclipse.org/r/36434
Tested-by: Hudson CI
Reviewed-by: William Swanson <WilliamRSwanson@gmail.com>
Reviewed-by: Marc Dumais <marc.dumais@ericsson.com>
Tested-by: Marc Dumais <marc.dumais@ericsson.com>
This commit is contained in:
Marc Dumais 2014-11-13 14:09:56 -05:00
parent 13b0270d5c
commit 2d511d95a6
2 changed files with 38 additions and 1 deletions

View file

@ -19,6 +19,7 @@
* Xavier Raynaud (kalray) - Bug 431935
* Marc Dumais (Ericsson) - Bug 441713
* Marc Dumais (Ericsson) - Bug 442312
* Marc Dumais (Ericsson) - Bug 451392
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -86,6 +87,7 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
@ -128,6 +130,10 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
/** Model changed listener, attached to Debug View. */
protected IModelChangedListener m_modelChangedListener = null;
/** Debug view selection changed listener, attached to Debug View. */
protected ISelectionChangedListener m_debugViewSelectionChangedListener = null;
// These two arrays are used to cache the CPU and core
// contexts, each time the model is recreated. This way
// we can avoid asking the backend for the CPU/core
@ -751,7 +757,19 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
}});
}
};
m_debugViewSelectionChangedListener =
new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// Execute a refresh after any pending UI updates.
GUIUtils.exec( new Runnable() { @Override public void run() {
// Update canvas selection to match to dbg view selection
updateCanvasSelectionFromDebugView();
}});
}
};
m_debugViewer.addModelChangedListener(m_modelChangedListener);
m_debugViewer.addSelectionChangedListener(m_debugViewSelectionChangedListener);
}
}
}
@ -759,11 +777,13 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
/** Removes debug viewer listener. */
protected void removeDebugViewerListener()
{
if (m_modelChangedListener != null) {
if (m_modelChangedListener != null && m_debugViewSelectionChangedListener != null) {
if (m_debugViewer != null) {
m_debugViewer.removeModelChangedListener(m_modelChangedListener);
m_debugViewer.removeSelectionChangedListener(m_debugViewSelectionChangedListener);
m_debugViewer = null;
m_modelChangedListener = null;
m_debugViewSelectionChangedListener = null;
}
}
}
@ -1052,6 +1072,13 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
updateCanvasSelectionInternal(SelectionUtils.getWorkbenchSelection());
}
/** Updates canvas selection from current debug view selection.
* Note: this method assumes it is called on the UI thread. */
protected void updateCanvasSelectionFromDebugView()
{
updateCanvasSelectionInternal(DebugViewUtils.getDebugViewSelection());
}
/** Updates canvas selection from current workbench selection.
* Note: this method assumes it is called on the UI thread. */
protected void updateCanvasSelectionInternal(ISelection selection)

View file

@ -7,6 +7,7 @@
*
* Contributors:
* William R. Swanson (Tilera Corporation)
* Marc Dumais (Ericsson) - Bug 451392
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
@ -76,4 +77,13 @@ public class DebugViewUtils
if (viewer == null || selection == null) return false;
return viewer.trySelection(selection, true, true);
}
/**
* Returns the debug view selection.
*/
public static ISelection getDebugViewSelection() {
TreeModelViewer viewer = DebugViewUtils.getDebugViewer();
if (viewer == null) return null;
return viewer.getSelection();
}
}