mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[229914] Implement Update Policy support for Memory View
This commit is contained in:
parent
2546c72207
commit
429d7531fc
3 changed files with 306 additions and 0 deletions
|
@ -417,4 +417,64 @@
|
|||
</viewerContribution>
|
||||
</extension>
|
||||
|
||||
|
||||
<!-- memory update policy -->
|
||||
<extension point="org.eclipse.ui.popupMenus">
|
||||
<viewerContribution
|
||||
id="org.eclipse.debug.ui.MemoryView.updatePolicy"
|
||||
targetID="org.eclipse.debug.ui.MemoryView.MemoryBlocksTreeViewPane">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.internal.provisional.ui.memory.SelectUpdatePolicyAction"
|
||||
id="org.eclipse.debug.ui.views.memory.update.selectUpdatePolicy"
|
||||
label="Update Policy"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.2"
|
||||
id="org.eclipse.debug.ui.memory.renderingviewpane.2.updatepolicy">
|
||||
<action
|
||||
label="Update Policy"
|
||||
class="org.eclipse.dd.dsf.debug.internal.provisional.ui.memory.SelectUpdatePolicyAction"
|
||||
menubarPath="org.eclipse.debug.ui.memory.renderingviewpane.2"
|
||||
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.2.updatepolicy"/>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1"
|
||||
id="org.eclipse.debug.ui.memory.renderingviewpane.1.updatepolicy">
|
||||
<action
|
||||
label="Update Policy"
|
||||
class="org.eclipse.dd.dsf.debug.internal.provisional.ui.memory.SelectUpdatePolicyAction"
|
||||
menubarPath="org.eclipse.debug.ui.memory.renderingviewpane.1"
|
||||
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1.updatepolicy"/>
|
||||
</viewerContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.viewActions">
|
||||
<viewContribution
|
||||
targetID="org.eclipse.debug.ui.MemoryView"
|
||||
id="org.eclipse.debug.ui.memoryView.toolbar">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.internal.provisional.ui.memory.RefreshAction"
|
||||
icon="icons/refresh.gif"
|
||||
id="org.eclipse.debug.ui.MemoryView.memoryViewRefresh"
|
||||
label="Refresh"
|
||||
toolbarPath="additions">
|
||||
</action>
|
||||
</viewContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.viewActions">
|
||||
<viewContribution
|
||||
id="org.eclipse.debug.ui.MemoryView.updatepolicy"
|
||||
targetID="org.eclipse.debug.ui.MemoryView">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.internal.provisional.ui.memory.SelectUpdatePolicyAction"
|
||||
id="org.eclipse.debug.ui.MemoryView.updatepolicy"
|
||||
label="Update Policy"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
</viewContribution>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - Ted Williams - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.internal.provisional.ui.memory;
|
||||
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.core.model.IMemoryBlock;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockUpdatePolicy;
|
||||
import org.eclipse.debug.internal.ui.views.memory.MemoryView;
|
||||
import org.eclipse.debug.ui.memory.IMemoryRendering;
|
||||
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RefreshAction implements IViewActionDelegate {
|
||||
|
||||
private IMemoryBlock fMemoryBlock = null;
|
||||
|
||||
private MemoryView fView;
|
||||
|
||||
public void init(IViewPart view) {
|
||||
fView = (MemoryView) view;
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
|
||||
if(fMemoryBlock instanceof IMemoryBlockUpdatePolicy)
|
||||
{
|
||||
((IMemoryBlockUpdatePolicy) fMemoryBlock).clearCache();
|
||||
IMemoryRenderingContainer containers[] = fView.getMemoryRenderingContainers();
|
||||
for(int i = 0; i < containers.length; i++)
|
||||
{
|
||||
IMemoryRendering renderings[] = containers[i].getRenderings();
|
||||
for(int j = 0; j < renderings.length; j++)
|
||||
{
|
||||
if (renderings[j].getControl() instanceof IDebugEventSetListener)
|
||||
{
|
||||
((IDebugEventSetListener) renderings[j].getControl()).handleDebugEvents(
|
||||
new DebugEvent[] { new DebugEvent(fMemoryBlock, DebugEvent.CHANGE) } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
fMemoryBlock = null;
|
||||
action.setEnabled(false);
|
||||
if(selection instanceof IStructuredSelection)
|
||||
{
|
||||
if(((IStructuredSelection) selection).getFirstElement() instanceof IMemoryBlock)
|
||||
{
|
||||
fMemoryBlock = (IMemoryBlock) ((IStructuredSelection) selection).getFirstElement();
|
||||
action.setEnabled(true);
|
||||
}
|
||||
else if(((IStructuredSelection) selection).getFirstElement() instanceof IMemoryRendering)
|
||||
{
|
||||
fMemoryBlock = ((IMemoryRendering) ((IStructuredSelection) selection).getFirstElement()).getMemoryBlock();
|
||||
action.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - Ted Williams - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.internal.provisional.ui.memory;
|
||||
|
||||
import org.eclipse.debug.core.model.IMemoryBlock;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockUpdatePolicy;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.debug.ui.memory.IMemoryRendering;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.action.IMenuCreator;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.events.MenuAdapter;
|
||||
import org.eclipse.swt.events.MenuEvent;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.ui.IActionDelegate2;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SelectUpdatePolicyAction implements IMenuCreator, IViewActionDelegate, IDebugContextListener, IActionDelegate2 {
|
||||
|
||||
private IAction fAction = null;
|
||||
private IMemoryBlock fMemoryBlock = null;
|
||||
|
||||
private String fUpdatePolicy = null;
|
||||
|
||||
public void dispose() {
|
||||
// do nothing
|
||||
|
||||
}
|
||||
|
||||
public void runWithEvent(IAction action, Event event) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
class SelectPolicy extends Action {
|
||||
|
||||
String fID;
|
||||
String fDescription;
|
||||
|
||||
public SelectPolicy(String id, String description) {
|
||||
fID = id;
|
||||
fDescription = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return fDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
((IMemoryBlockUpdatePolicy) fMemoryBlock).setUpdatePolicy(fID);
|
||||
fUpdatePolicy = fID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Menu getMenu(Control parent) {
|
||||
// Never called
|
||||
return null;
|
||||
}
|
||||
|
||||
protected IAction getAction() { return fAction; }
|
||||
|
||||
public void init(IViewPart view) {
|
||||
}
|
||||
|
||||
public void init(IAction action) {
|
||||
fAction = action;
|
||||
action.setMenuCreator(this);
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
// Do nothing, this is a pull-down menu
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
fMemoryBlock = null;
|
||||
action.setEnabled(false);
|
||||
if(selection instanceof IStructuredSelection)
|
||||
{
|
||||
if(((IStructuredSelection) selection).getFirstElement() instanceof IMemoryBlock)
|
||||
{
|
||||
fMemoryBlock = (IMemoryBlock) ((IStructuredSelection) selection).getFirstElement();
|
||||
action.setMenuCreator(this);
|
||||
action.setEnabled(true);
|
||||
}
|
||||
else if(((IStructuredSelection) selection).getFirstElement() instanceof IMemoryRendering)
|
||||
{
|
||||
fMemoryBlock = ((IMemoryRendering) ((IStructuredSelection) selection).getFirstElement()).getMemoryBlock();
|
||||
action.setMenuCreator(this);
|
||||
action.setEnabled(true);
|
||||
}
|
||||
|
||||
if(fMemoryBlock != null)
|
||||
{
|
||||
if(fMemoryBlock instanceof IMemoryBlockUpdatePolicy)
|
||||
{
|
||||
String currentPolicy = ((IMemoryBlockUpdatePolicy) fMemoryBlock).getUpdatePolicy();
|
||||
if(fUpdatePolicy == null)
|
||||
fUpdatePolicy = currentPolicy;
|
||||
|
||||
((IMemoryBlockUpdatePolicy) fMemoryBlock).setUpdatePolicy(fUpdatePolicy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void debugContextChanged(DebugContextEvent event) {
|
||||
}
|
||||
|
||||
public Menu getMenu(Menu parent) {
|
||||
Menu menu = new Menu(parent);
|
||||
menu.addMenuListener(new MenuAdapter() {
|
||||
@Override
|
||||
public void menuShown(MenuEvent e) {
|
||||
Menu m = (Menu)e.widget;
|
||||
MenuItem[] items = m.getItems();
|
||||
for (int i=0; i < items.length; i++) {
|
||||
items[i].dispose();
|
||||
}
|
||||
fillMenu(m);
|
||||
}
|
||||
});
|
||||
return menu;
|
||||
}
|
||||
|
||||
private void fillMenu(Menu menu) {
|
||||
if(fMemoryBlock instanceof IMemoryBlockUpdatePolicy)
|
||||
{
|
||||
IMemoryBlockUpdatePolicy blockPolicy = (IMemoryBlockUpdatePolicy) fMemoryBlock;
|
||||
|
||||
String currentPolicy = blockPolicy.getUpdatePolicy();
|
||||
|
||||
String policies[] = blockPolicy.getUpdatePolicies();
|
||||
for(int i = 0; i < policies.length; i++)
|
||||
{
|
||||
SelectPolicy action = new SelectPolicy(policies[i], blockPolicy.getUpdatePolicyDescription(policies[i]));
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
action.setChecked(policies[i].equals(currentPolicy));
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue