mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 439624 - Per-element formatting for expressions and variables
Change-Id: I25d2c0656d9a21b74693d459e66c0fbe4131038d Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/30192 Tested-by: Hudson CI Reviewed-by: Alvaro Sanchez-Leon <alvsan09@gmail.com>
This commit is contained in:
parent
08fd13ed9f
commit
126e67237d
20 changed files with 734 additions and 184 deletions
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
|
||||||
Bundle-Version: 2.4.100.qualifier
|
Bundle-Version: 2.5.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
||||||
|
|
|
@ -890,4 +890,11 @@
|
||||||
targetId="org.eclipse.cdt.ui.cCode">
|
targetId="org.eclipse.cdt.ui.cCode">
|
||||||
</hyperlinkDetector>
|
</hyperlinkDetector>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.elementFactories">
|
||||||
|
<factory
|
||||||
|
class="org.eclipse.cdt.dsf.debug.ui.viewmodel.SimpleMapPersistableFactory"
|
||||||
|
id="org.eclipse.cdt.dsf.ui.simpleMapPersistableFactory">
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>2.4.100-SNAPSHOT</version>
|
<version>2.5.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*****************************************************************
|
||||||
|
* Copyright (c) 2011, 2014 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 - initial API and implementation
|
||||||
|
*****************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||||
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.ui.IMemento;
|
||||||
|
import org.eclipse.ui.IPersistableElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic persistable for storing a map of simple values.
|
||||||
|
* <br>
|
||||||
|
* Currently supported value types are {@link Integer} and {@link String}.
|
||||||
|
*
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
public class SimpleMapPersistable<V> implements IPersistableElement, IAdaptable {
|
||||||
|
|
||||||
|
private static final String KEY_TYPE = "type"; //$NON-NLS-1$
|
||||||
|
private static final String KEY_NAME = "name"; //$NON-NLS-1$
|
||||||
|
private static final String KEY_VALUE = "value"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private Class<V> fType;
|
||||||
|
private Map<String, V> fValues = new TreeMap<String, V>();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public SimpleMapPersistable(IMemento memento) throws CoreException {
|
||||||
|
IMemento type = memento.getChild(KEY_TYPE);
|
||||||
|
if (type == null) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE,
|
||||||
|
"Missing key for type.", null)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fType = (Class<V>)Class.forName(type.getTextData());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE,
|
||||||
|
e.getMessage(), e));
|
||||||
|
}
|
||||||
|
|
||||||
|
IMemento[] list = memento.getChildren(KEY_NAME);
|
||||||
|
Map<String, V> values = new TreeMap<String, V>();
|
||||||
|
for (IMemento elem : list) {
|
||||||
|
values.put(elem.getID(), getValue(elem));
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized(fValues) {
|
||||||
|
// We should not assign 'values' directly to 'fValues'
|
||||||
|
// if we want synchronization to work. Instead, we must use
|
||||||
|
// the same map as before for 'fValues'
|
||||||
|
fValues.clear();
|
||||||
|
fValues.putAll(values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleMapPersistable(Class<V> type) {
|
||||||
|
fType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveState(IMemento memento) {
|
||||||
|
Map<String, V> values = null;
|
||||||
|
synchronized (fValues) {
|
||||||
|
values = new TreeMap<String, V>(fValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMemento type = memento.createChild(KEY_TYPE);
|
||||||
|
synchronized (fType) {
|
||||||
|
type.putTextData(fType.getName());
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, V> entry : values.entrySet()) {
|
||||||
|
IMemento value = memento.createChild(KEY_NAME, entry.getKey());
|
||||||
|
putValue(value, entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putValue(IMemento memento, Object value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
memento.putString(KEY_VALUE, (String)value);
|
||||||
|
} else if (value instanceof Integer) {
|
||||||
|
memento.putInteger(KEY_VALUE, (Integer)value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private V getValue(IMemento memento) {
|
||||||
|
synchronized (fType) {
|
||||||
|
if (String.class.equals(fType)) {
|
||||||
|
return (V)memento.getString(KEY_VALUE);
|
||||||
|
} else if (Integer.class.equals(fType)) {
|
||||||
|
return (V)memento.getInteger(KEY_VALUE);
|
||||||
|
} else {
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public V getValue(String key) {
|
||||||
|
if (key == null)
|
||||||
|
return null;
|
||||||
|
synchronized (fValues) {
|
||||||
|
return fValues.get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String key, V value) {
|
||||||
|
synchronized (fValues) {
|
||||||
|
if (value == null) {
|
||||||
|
fValues.remove(key);
|
||||||
|
} else {
|
||||||
|
fValues.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFactoryId() {
|
||||||
|
return SimpleMapPersistableFactory.getFactoryId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
||||||
|
if (adapter.isInstance(this)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*****************************************************************
|
||||||
|
* Copyright (c) 2011, 2014 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 - initial API and implementation
|
||||||
|
*****************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.ui.IElementFactory;
|
||||||
|
import org.eclipse.ui.IMemento;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistable factory the simple map persistable.
|
||||||
|
*
|
||||||
|
* @since 2.5
|
||||||
|
*
|
||||||
|
* @see SimpleMapPersistable
|
||||||
|
*/
|
||||||
|
public class SimpleMapPersistableFactory implements IElementFactory {
|
||||||
|
|
||||||
|
public static String getFactoryId() {
|
||||||
|
// Must be the same id as the one used in the plugin.xml file
|
||||||
|
return "org.eclipse.cdt.dsf.ui.simpleMapPersistableFactory"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAdaptable createElement(IMemento memento) {
|
||||||
|
try {
|
||||||
|
SimpleMapPersistable<Object> x = new SimpleMapPersistable<>(memento);
|
||||||
|
return x;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
DsfUIPlugin.log(new Status(
|
||||||
|
IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, "Cannot restore persistable." , e)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 Wind River Systems and others.
|
* Copyright (c) 2008, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,16 +13,20 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMAdapter;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMAdapter;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||||
|
import org.eclipse.debug.ui.AbstractDebugView;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.IDebugView;
|
import org.eclipse.debug.ui.IDebugView;
|
||||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.ui.IPartService;
|
import org.eclipse.ui.IPartService;
|
||||||
import org.eclipse.ui.ISelectionService;
|
import org.eclipse.ui.ISelectionService;
|
||||||
|
@ -152,4 +156,34 @@ public class VMHandlerUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the viewer input element for the viewer in the given
|
||||||
|
* presentation context. The input element is retrieved only if the
|
||||||
|
* presentation context's view is based on the {@link AbstractDebugView}.
|
||||||
|
* Returns <code>null</code> if not found.
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
public static Object getViewerInput(IPresentationContext context) {
|
||||||
|
if (context.getPart() instanceof AbstractDebugView) {
|
||||||
|
Viewer viewer = ((AbstractDebugView)context.getPart()).getViewer();
|
||||||
|
if (viewer != null) {
|
||||||
|
return viewer.getInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link IVMNode} associated with the element in the
|
||||||
|
* given path. Returns <code>null</code> if not found.
|
||||||
|
*
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
public static IVMNode getVMNode(Object viewerInput, TreePath path) {
|
||||||
|
if (path.getSegmentCount() != 0) {
|
||||||
|
return (IVMNode) DebugPlugin.getAdapter(path.getLastSegment(), IVMNode.class);
|
||||||
|
} else {
|
||||||
|
return (IVMNode) DebugPlugin.getAdapter(viewerInput, IVMNode.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
* Copyright (c) 2006, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -20,12 +20,13 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.DsfCastToTypeSupport;
|
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.DsfCastToTypeSupport;
|
||||||
import org.eclipse.cdt.dsf.debug.service.ICachingService;
|
import org.eclipse.cdt.dsf.debug.service.ICachingService;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.AbstractElementVMProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterBitFieldVMNode;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterBitFieldVMNode;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMNode;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMNode;
|
||||||
|
@ -41,7 +42,6 @@ import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMModelProxy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMModelProxy;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
|
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||||
|
@ -70,7 +70,7 @@ import org.eclipse.jface.viewers.TreePath;
|
||||||
* should implement {@link IExpressionVMNode}.
|
* should implement {@link IExpressionVMNode}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class ExpressionVMProvider extends AbstractDMVMProvider
|
public class ExpressionVMProvider extends AbstractElementVMProvider
|
||||||
implements IExpressionsListener2
|
implements IExpressionsListener2
|
||||||
{
|
{
|
||||||
private IExpressionVMNode[] fExpressionNodes;
|
private IExpressionVMNode[] fExpressionNodes;
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*****************************************************************
|
||||||
|
* Copyright (c) 2014 Ericsson 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:
|
||||||
|
* Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for view model providers that can support individual element formatting.
|
||||||
|
* Extending classes can override {@link #supportFormat(IVMContext)} to return false
|
||||||
|
* if they do not want to support individual element formatting.
|
||||||
|
*/
|
||||||
|
abstract public class AbstractElementVMProvider extends AbstractDMVMProvider implements IElementFormatProvider
|
||||||
|
{
|
||||||
|
private final IElementFormatProvider fElementFormatProvider;
|
||||||
|
|
||||||
|
public AbstractElementVMProvider(AbstractVMAdapter adapter, IPresentationContext context, DsfSession session) {
|
||||||
|
super(adapter, context, session);
|
||||||
|
fElementFormatProvider = createElementNumberFormatProvider(this, getSession());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
if (fElementFormatProvider instanceof ElementNumberFormatProvider) {
|
||||||
|
((ElementNumberFormatProvider)fElementFormatProvider).dispose();
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
protected IElementFormatProvider createElementNumberFormatProvider(IVMProvider provider, DsfSession session) {
|
||||||
|
return new ElementNumberFormatProvider(provider, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportFormat(IVMContext context) {
|
||||||
|
return fElementFormatProvider.supportFormat(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getActiveFormat(IPresentationContext context, IVMNode node, Object viewerInput, TreePath elementPath,
|
||||||
|
DataRequestMonitor<String> rm) {
|
||||||
|
fElementFormatProvider.getActiveFormat(context, node, viewerInput, elementPath, rm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActiveFormat(IPresentationContext context, IVMNode[] node, Object viewerInput, TreePath[] elementPaths, String format) {
|
||||||
|
fElementFormatProvider.setActiveFormat(context, node, viewerInput, elementPaths, format);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,243 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010, 2014 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.ImmediateCountingRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionGroupDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMData;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SimpleMapPersistable;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.ElementFormatEvent;
|
||||||
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.osgi.framework.Filter;
|
||||||
|
import org.osgi.framework.InvalidSyntaxException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of the {@link IElementFormatProvider}. It can be
|
||||||
|
* used within any {@link IVMProvider} to store and persist number-formats
|
||||||
|
* selected by user for different elements.
|
||||||
|
*
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
public class ElementNumberFormatProvider implements IElementFormatProvider
|
||||||
|
{
|
||||||
|
private static final String ELEMENT_FORMAT_PERSISTABLE_PROPERTY = "org.eclipse.cdt.dsf.ui.elementFormatPersistable"; //$NON-NLS-1$
|
||||||
|
private static final String FILTER_PROVIDER_ID = ElementNumberFormatProvider.class.getName() + ".eventFilter"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final IVMProvider fVMProvider;
|
||||||
|
private final DsfSession fSession;
|
||||||
|
private final Dictionary<String, String> fFilterProperties = new Hashtable<>();
|
||||||
|
|
||||||
|
public ElementNumberFormatProvider(IVMProvider vmProvider, DsfSession session) {
|
||||||
|
fVMProvider = vmProvider;
|
||||||
|
fSession = session;
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initialize() {
|
||||||
|
IPresentationContext presentationCtx = getVMProvider().getPresentationContext();
|
||||||
|
|
||||||
|
IWorkbenchPart part = presentationCtx.getPart();
|
||||||
|
String provider;
|
||||||
|
if (part != null) {
|
||||||
|
// Use an id that is unique to the instance of the view
|
||||||
|
// Note that although each view, including cloned ones, has its own presentation context,
|
||||||
|
// the presentation context id returned by getPresentationContext().getId() is the
|
||||||
|
// same for cloned views even though the presentation context itself is different.
|
||||||
|
// To get a unique id for each cloned view we can use the title of the view.
|
||||||
|
provider = part.getTitle();
|
||||||
|
} else {
|
||||||
|
// In some cases, we are not dealing with a part, e.g., the hover.
|
||||||
|
// In this case, use the presentation context id directly.
|
||||||
|
// Note that the hover will probably not provide per-element formating,
|
||||||
|
// but some extenders may choose to do so.
|
||||||
|
provider = getVMProvider().getPresentationContext().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the filter properties targeted at our provider, to be used when sending events
|
||||||
|
fFilterProperties.put(FILTER_PROVIDER_ID, provider);
|
||||||
|
|
||||||
|
// Properly formatted OSGI filter string aimed at our provider
|
||||||
|
String filterStr = "(&(" + FILTER_PROVIDER_ID + "=" + provider + "))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Filter filter = DsfUIPlugin.getBundleContext().createFilter(filterStr);
|
||||||
|
fSession.getExecutor().execute(new DsfRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Only listen to events that are aimed at our provider by using a filter.
|
||||||
|
// That avoids updating ourselves for an event that was triggered by another view.
|
||||||
|
fSession.addServiceEventListener(ElementNumberFormatProvider.this, filter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (InvalidSyntaxException e) {
|
||||||
|
assert false : e.getMessage();
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
try {
|
||||||
|
fSession.getExecutor().execute(new DsfRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fSession.removeServiceEventListener(ElementNumberFormatProvider.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public final void eventDispatched(ElementFormatEvent event) {
|
||||||
|
if (getVMProvider() instanceof AbstractVMProvider) {
|
||||||
|
((AbstractVMProvider)getVMProvider()).handleEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IVMProvider getVMProvider() {
|
||||||
|
return fVMProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getActiveFormat(IPresentationContext context, IVMNode node, Object viewerInput, final TreePath elementPath,
|
||||||
|
final DataRequestMonitor<String> rm)
|
||||||
|
{
|
||||||
|
getElementKey(
|
||||||
|
viewerInput, elementPath,
|
||||||
|
new ImmediateDataRequestMonitor<String>(rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
SimpleMapPersistable<String> persistable = getPersistable();
|
||||||
|
rm.done(persistable.getValue(getData()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActiveFormat(IPresentationContext context, IVMNode[] node, Object viewerInput,
|
||||||
|
TreePath[] elementPaths, final String format)
|
||||||
|
{
|
||||||
|
final HashSet<Object> elementsToRefresh = new HashSet<>();
|
||||||
|
final CountingRequestMonitor crm = new ImmediateCountingRequestMonitor() {
|
||||||
|
@Override
|
||||||
|
protected void handleCompleted() {
|
||||||
|
if (elementsToRefresh.size() > 0) {
|
||||||
|
// Send the event to all DSF sessions as they share the same view and the
|
||||||
|
// change of format will affect them as well. This is because they key
|
||||||
|
// we use from this implementation of getElementKey() is not specific to
|
||||||
|
// a session (and should not be if we want to have proper persistence).
|
||||||
|
for (DsfSession session : DsfSession.getActiveSessions()) {
|
||||||
|
// Use the filterProperties to specify that this event only impacts the current view.
|
||||||
|
session.dispatchEvent(new ElementFormatEvent(elementsToRefresh, 1), fFilterProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (final TreePath path : elementPaths) {
|
||||||
|
getElementKey(
|
||||||
|
viewerInput, path,
|
||||||
|
new ImmediateDataRequestMonitor<String>(crm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
SimpleMapPersistable<String> persistable = getPersistable();
|
||||||
|
persistable.setValue(getData(), format);
|
||||||
|
elementsToRefresh.add(path.getLastSegment());
|
||||||
|
crm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
crm.setDoneCount(elementPaths.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportFormat(IVMContext context) {
|
||||||
|
if (context instanceof IDMVMContext) {
|
||||||
|
// The expressions view supports expression groups, which have no value,
|
||||||
|
// so we should not support formatting for expression groups.
|
||||||
|
if (((IDMVMContext)context).getDMContext() instanceof IExpressionGroupDMContext) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return context instanceof IFormattedValueVMContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We do not make the element key session-specific or else when we start a new session for the same
|
||||||
|
// program, the format we chose will not be persisted. Instead, make the format change valid for
|
||||||
|
// any session, even if other sessions run a different program. The idea is that a user usually
|
||||||
|
// names her variables similarly so the chosen format should apply properly anyway.
|
||||||
|
protected void getElementKey(Object viewerInput, TreePath elementPath, final DataRequestMonitor<String> rm) {
|
||||||
|
Object element = elementPath.getLastSegment();
|
||||||
|
if (element instanceof IDMVMContext) {
|
||||||
|
final IDMContext dmc = ((IDMVMContext)element).getDMContext();
|
||||||
|
if (dmc instanceof IExpressionDMContext) {
|
||||||
|
rm.done(((IExpressionDMContext)dmc).getExpression());
|
||||||
|
return;
|
||||||
|
} else if (dmc instanceof IRegisterDMContext) {
|
||||||
|
fSession.getExecutor().execute(new DsfRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fSession.getId());
|
||||||
|
IRegisters regService = tracker.getService(IRegisters.class);
|
||||||
|
tracker.dispose();
|
||||||
|
|
||||||
|
regService.getRegisterData((IRegisterDMContext)dmc, new ImmediateDataRequestMonitor<IRegisterDMData>(rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
rm.done(getData().getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rm.done(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Cannot calculate peristable key for element: " + element, null)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected SimpleMapPersistable<String> getPersistable() {
|
||||||
|
Object p = getVMProvider().getPresentationContext().getProperty(ELEMENT_FORMAT_PERSISTABLE_PROPERTY);
|
||||||
|
if (p instanceof SimpleMapPersistable) {
|
||||||
|
return (SimpleMapPersistable<String>)p;
|
||||||
|
} else {
|
||||||
|
SimpleMapPersistable<String> persistable = new SimpleMapPersistable<>(String.class);
|
||||||
|
getVMProvider().getPresentationContext().setProperty(ELEMENT_FORMAT_PERSISTABLE_PROPERTY, persistable);
|
||||||
|
return persistable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,22 +7,26 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Winnie Lai (Texas Instruments) - Individual Element Number Format (Bug 202556)
|
* Winnie Lai (Texas Instruments) - Individual Element Number Format (Bug 202556)
|
||||||
|
* Marc Khouzam (Ericsson) - Base available formats on each element (Bug 439624)
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat;
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.VMHandlerUtils;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.VMHandlerUtils;
|
||||||
import org.eclipse.cdt.dsf.ui.concurrent.SimpleDisplayExecutor;
|
import org.eclipse.cdt.dsf.ui.concurrent.SimpleDisplayExecutor;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.ICacheEntry;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.ICachingVMProviderExtension2;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
import org.eclipse.debug.ui.AbstractDebugView;
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.ActionContributionItem;
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
import org.eclipse.jface.action.ContributionItem;
|
import org.eclipse.jface.action.ContributionItem;
|
||||||
|
@ -30,7 +34,6 @@ import org.eclipse.jface.action.IContributionItem;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ITreeSelection;
|
import org.eclipse.jface.viewers.ITreeSelection;
|
||||||
import org.eclipse.jface.viewers.TreePath;
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
@ -99,40 +102,37 @@ public class ElementNumberFormatsContribution extends NumberFormatsContribution
|
||||||
if (selection == null || selection.isEmpty() || selection instanceof ITreeSelection == false) {
|
if (selection == null || selection.isEmpty() || selection instanceof ITreeSelection == false) {
|
||||||
return NO_ITEMS;
|
return NO_ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
IVMProvider provider = VMHandlerUtils.getVMProviderForSelection(selection);
|
IVMProvider provider = VMHandlerUtils.getVMProviderForSelection(selection);
|
||||||
if (FORMATS.size() == 0) {
|
if (provider instanceof IElementFormatProvider == false) {
|
||||||
return NO_ITEMS;
|
return NO_ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPresentationContext context = provider.getPresentationContext();
|
IPresentationContext context = provider.getPresentationContext();
|
||||||
|
Object viewerInput = VMHandlerUtils.getViewerInput(context);
|
||||||
TreePath[] elementPaths = ((ITreeSelection) selection).getPaths();
|
TreePath[] elementPaths = ((ITreeSelection) selection).getPaths();
|
||||||
|
List<String> availableFormats = getAvailableFormats(provider, viewerInput, elementPaths);
|
||||||
|
if (availableFormats.size() == 0) {
|
||||||
|
return NO_ITEMS;
|
||||||
|
}
|
||||||
|
|
||||||
IVMNode[] nodes = new IVMNode[elementPaths.length];
|
IVMNode[] nodes = new IVMNode[elementPaths.length];
|
||||||
final String[] formats = new String[elementPaths.length];
|
final List<SelectFormatAction> actions = new ArrayList<SelectFormatAction>(availableFormats.size());
|
||||||
Object viewerInput = null;
|
for (String formatId : availableFormats) {
|
||||||
if (context.getPart() instanceof AbstractDebugView) {
|
|
||||||
Viewer viewer = ((AbstractDebugView)context.getPart()).getViewer();
|
|
||||||
if (viewer != null) {
|
|
||||||
viewerInput = viewer.getInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Here we keep using hard-coded formats, which are common formats.
|
|
||||||
// We expect clients may add extra formats before and after these formats.
|
|
||||||
// For details, please refer to 371012.
|
|
||||||
// For now, we do not use vm provider's cache entry to get available formats
|
|
||||||
// because it shows something extra than what we have been expecting. See 371012 comment #2.
|
|
||||||
final List<SelectFormatAction> actions = new ArrayList<SelectFormatAction>(FORMATS.size());
|
|
||||||
for (String formatId : FORMATS) {
|
|
||||||
actions.add(new SelectFormatAction((IElementFormatProvider) provider,
|
actions.add(new SelectFormatAction((IElementFormatProvider) provider,
|
||||||
context, nodes, viewerInput, elementPaths, formatId));
|
context, nodes, viewerInput, elementPaths, formatId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String[] elementActiveFormats = new String[elementPaths.length];
|
||||||
CountingRequestMonitor crm = new CountingRequestMonitor(SimpleDisplayExecutor.getSimpleDisplayExecutor(Display.getDefault()), null) {
|
CountingRequestMonitor crm = new CountingRequestMonitor(SimpleDisplayExecutor.getSimpleDisplayExecutor(Display.getDefault()), null) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleCompleted() {
|
protected void handleCompleted() {
|
||||||
String activeFormat = null;
|
String activeFormat = null;
|
||||||
for (int i = 0; i < formats.length; i++) {
|
for (int i = 0; i < elementActiveFormats.length; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
activeFormat = formats[i];
|
activeFormat = elementActiveFormats[i];
|
||||||
} else if (activeFormat != null
|
} else if (activeFormat != null
|
||||||
&& activeFormat.equals(formats[i]) == false) {
|
&& activeFormat.equals(elementActiveFormats[i]) == false) {
|
||||||
activeFormat = null;
|
activeFormat = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class ElementNumberFormatsContribution extends NumberFormatsContribution
|
||||||
new DataRequestMonitor<String>(ImmediateExecutor.getInstance(), crm) {
|
new DataRequestMonitor<String>(ImmediateExecutor.getInstance(), crm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
formats[index] = this.getData();
|
elementActiveFormats[index] = this.getData();
|
||||||
super.handleSuccess();
|
super.handleSuccess();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -167,9 +167,48 @@ public class ElementNumberFormatsContribution extends NumberFormatsContribution
|
||||||
crm.setDoneCount(elementPaths.length);
|
crm.setDoneCount(elementPaths.length);
|
||||||
int count = actions.size();
|
int count = actions.size();
|
||||||
IContributionItem[] items = new IContributionItem[count];
|
IContributionItem[] items = new IContributionItem[count];
|
||||||
for (int i = 0; i < actions.size(); i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
items[i] = new ActionContributionItem(actions.get(i));
|
items[i] = new ActionContributionItem(actions.get(i));
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the available formats for all elements in the selection. If all elements have the same
|
||||||
|
* available formats, return that list; if not, return the default list.
|
||||||
|
*/
|
||||||
|
private List<String> getAvailableFormats(IVMProvider provider, Object viewerInput, TreePath[] paths) {
|
||||||
|
if (provider instanceof ICachingVMProviderExtension2) {
|
||||||
|
ICachingVMProviderExtension2 cachingProvider = (ICachingVMProviderExtension2)provider;
|
||||||
|
|
||||||
|
String[] formats = null;
|
||||||
|
for (TreePath path : paths) {
|
||||||
|
IVMNode node = VMHandlerUtils.getVMNode(viewerInput, path);
|
||||||
|
if (node != null) {
|
||||||
|
ICacheEntry cacheEntry = cachingProvider.getCacheEntry(node, viewerInput, path);
|
||||||
|
if (cacheEntry != null && cacheEntry.getProperties() != null) {
|
||||||
|
String[] entryFormats = (String[]) cacheEntry.getProperties().get(IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
|
||||||
|
if (entryFormats == null) {
|
||||||
|
// At least one element has no formats. Use the default ones.
|
||||||
|
return FORMATS;
|
||||||
|
}
|
||||||
|
if (formats == null) {
|
||||||
|
// First set of formats
|
||||||
|
formats = entryFormats;
|
||||||
|
} else {
|
||||||
|
// Found another set of formats. Make sure it is the same as the set we already have.
|
||||||
|
// If not, return the default set of formats.
|
||||||
|
if (!Arrays.equals(formats, entryFormats)) {
|
||||||
|
return FORMATS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (formats != null) {
|
||||||
|
return Arrays.asList(formats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FORMATS;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
* Copyright (c) 2006, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Enable per-element formatting (Bug 439624)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.register;
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel.register;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
||||||
|
@ -41,6 +43,7 @@ import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelTe
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterBitFieldCellModifier.BitFieldEditorStyle;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterBitFieldCellModifier.BitFieldEditorStyle;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.ElementFormatEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableLabelFont;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableLabelFont;
|
||||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
@ -967,6 +970,13 @@ public class RegisterBitFieldVMNode extends AbstractExpressionVMNode
|
||||||
return IModelDelta.CONTENT;
|
return IModelDelta.CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event instanceof ElementFormatEvent) {
|
||||||
|
int depth = ((ElementFormatEvent)event).getApplyDepth();
|
||||||
|
if (depth == 0) return IModelDelta.NO_CHANGE;
|
||||||
|
if (depth == 1) return IModelDelta.STATE;
|
||||||
|
return IModelDelta.CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
return IModelDelta.NO_CHANGE;
|
return IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,6 +1011,19 @@ public class RegisterBitFieldVMNode extends AbstractExpressionVMNode
|
||||||
{
|
{
|
||||||
parentDelta.addNode(element, IModelDelta.STATE);
|
parentDelta.addNode(element, IModelDelta.STATE);
|
||||||
}
|
}
|
||||||
|
else if (event instanceof ElementFormatEvent)
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)event).getApplyDepth();
|
||||||
|
if (depth != 0) {
|
||||||
|
int deltaType = IModelDelta.CONTENT;
|
||||||
|
if (depth == 1) deltaType = IModelDelta.STATE;
|
||||||
|
|
||||||
|
Set<Object> elements = ((ElementFormatEvent)event).getElements();
|
||||||
|
for (Object elem : elements) {
|
||||||
|
parentDelta.addNode(elem, deltaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
* Copyright (c) 2006, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.register;
|
package org.eclipse.cdt.dsf.debug.ui.viewmodel.register;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
||||||
|
@ -39,6 +40,7 @@ import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.AbstractExpressionVMNod
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.ElementFormatEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableLabelFont;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableLabelFont;
|
||||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
@ -688,6 +690,13 @@ public class RegisterVMNode extends AbstractExpressionVMNode
|
||||||
return IModelDelta.STATE;
|
return IModelDelta.STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e instanceof ElementFormatEvent) {
|
||||||
|
int depth = ((ElementFormatEvent)e).getApplyDepth();
|
||||||
|
if (depth == 0) return IModelDelta.NO_CHANGE;
|
||||||
|
if (depth == 1) return IModelDelta.STATE;
|
||||||
|
return IModelDelta.CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
return IModelDelta.NO_CHANGE;
|
return IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +723,19 @@ public class RegisterVMNode extends AbstractExpressionVMNode
|
||||||
if (e instanceof IRegisterChangedDMEvent) {
|
if (e instanceof IRegisterChangedDMEvent) {
|
||||||
parentDelta.addNode( createVMContext(((IRegisterChangedDMEvent)e).getDMContext()), IModelDelta.STATE );
|
parentDelta.addNode( createVMContext(((IRegisterChangedDMEvent)e).getDMContext()), IModelDelta.STATE );
|
||||||
}
|
}
|
||||||
|
else if ( e instanceof ElementFormatEvent )
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)e).getApplyDepth();
|
||||||
|
if (depth != 0) {
|
||||||
|
int deltaType = IModelDelta.CONTENT;
|
||||||
|
if (depth == 1) deltaType = IModelDelta.STATE;
|
||||||
|
|
||||||
|
Set<Object> elements = ((ElementFormatEvent)e).getElements();
|
||||||
|
for (Object elem : elements) {
|
||||||
|
parentDelta.addNode(elem, deltaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.AbstractElementVMProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
@ -35,7 +36,6 @@ import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
||||||
|
@ -49,7 +49,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
/**
|
/**
|
||||||
* Provides the VIEW MODEL for the DEBUG MODEL REGISTER view.
|
* Provides the VIEW MODEL for the DEBUG MODEL REGISTER view.
|
||||||
*/
|
*/
|
||||||
public class RegisterVMProvider extends AbstractDMVMProvider
|
public class RegisterVMProvider extends AbstractElementVMProvider
|
||||||
{
|
{
|
||||||
private IPropertyChangeListener fPreferencesListener = new IPropertyChangeListener() {
|
private IPropertyChangeListener fPreferencesListener = new IPropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2013 Wind River Systems and others.
|
* Copyright (c) 2006, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICastToArray;
|
import org.eclipse.cdt.debug.core.model.ICastToArray;
|
||||||
|
@ -59,6 +60,7 @@ import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelTe
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.ElementFormatEvent;
|
||||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
|
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
|
||||||
|
@ -1259,6 +1261,14 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
||||||
return IModelDelta.CONTENT;
|
return IModelDelta.CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( e instanceof ElementFormatEvent )
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)e).getApplyDepth();
|
||||||
|
if (depth == 0) return IModelDelta.NO_CHANGE;
|
||||||
|
if (depth == 1) return IModelDelta.STATE;
|
||||||
|
return IModelDelta.CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
return IModelDelta.NO_CHANGE;
|
return IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,6 +1286,19 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
||||||
{
|
{
|
||||||
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
|
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
|
||||||
}
|
}
|
||||||
|
else if ( e instanceof ElementFormatEvent )
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)e).getApplyDepth();
|
||||||
|
if (depth != 0) {
|
||||||
|
int deltaType = IModelDelta.CONTENT;
|
||||||
|
if (depth == 1) deltaType = IModelDelta.STATE;
|
||||||
|
|
||||||
|
Set<Object> elements = ((ElementFormatEvent)e).getElements();
|
||||||
|
for (Object elem : elements) {
|
||||||
|
parentDelta.addNode(elem, deltaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
}
|
}
|
||||||
|
@ -1296,6 +1319,14 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
||||||
return IModelDelta.CONTENT;
|
return IModelDelta.CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event instanceof ElementFormatEvent)
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)event).getApplyDepth();
|
||||||
|
if (depth == 0) return IModelDelta.NO_CHANGE;
|
||||||
|
if (depth == 1) return IModelDelta.STATE;
|
||||||
|
return IModelDelta.CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
return IModelDelta.NO_CHANGE;
|
return IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,6 +1343,19 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
||||||
((PropertyChangeEvent)event).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) {
|
((PropertyChangeEvent)event).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) {
|
||||||
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
|
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
|
||||||
}
|
}
|
||||||
|
else if (event instanceof ElementFormatEvent )
|
||||||
|
{
|
||||||
|
int depth = ((ElementFormatEvent)event).getApplyDepth();
|
||||||
|
if (depth != 0) {
|
||||||
|
int deltaType = IModelDelta.CONTENT;
|
||||||
|
if (depth == 1) deltaType = IModelDelta.STATE;
|
||||||
|
|
||||||
|
Set<Object> elements = ((ElementFormatEvent)event).getElements();
|
||||||
|
for (Object elem : elements) {
|
||||||
|
parentDelta.addNode(elem, deltaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
* Copyright (c) 2007, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions2;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.AbstractElementVMProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
@ -28,7 +29,6 @@ import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
|
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
||||||
|
@ -39,7 +39,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
|
||||||
public class VariableVMProvider extends AbstractDMVMProvider
|
public class VariableVMProvider extends AbstractElementVMProvider
|
||||||
implements IColumnPresentationFactory
|
implements IColumnPresentationFactory
|
||||||
{
|
{
|
||||||
private IPropertyChangeListener fPreferencesListener = new IPropertyChangeListener() {
|
private IPropertyChangeListener fPreferencesListener = new IPropertyChangeListener() {
|
||||||
|
|
|
@ -104,13 +104,6 @@
|
||||||
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
|
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
|
||||||
</factory>
|
</factory>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.elementFactories">
|
|
||||||
<factory
|
|
||||||
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
|
|
||||||
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
|
|
||||||
</factory>
|
|
||||||
</extension>
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||||
<breakpointEditors
|
<breakpointEditors
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
* Copyright (c) 2011 Texas Instruments and others
|
* Copyright (c) 2011, 2014 Texas Instruments and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SimpleMapPersistable;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IElementFormatProvider;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IElementFormatProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode;
|
||||||
|
@ -39,22 +40,23 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
|
||||||
super(adapter, context, session);
|
super(adapter, context, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void getActiveFormat(IPresentationContext context, IVMNode node, Object viewerInput, TreePath elementPath,
|
public void getActiveFormat(IPresentationContext context, IVMNode node, Object viewerInput, TreePath elementPath,
|
||||||
DataRequestMonitor<String> rm) {
|
DataRequestMonitor<String> rm) {
|
||||||
Object p = context.getProperty(myPersistId);
|
Object p = context.getProperty(myPersistId);
|
||||||
if (p instanceof VariablePersistable == false) {
|
if (p instanceof SimpleMapPersistable == false) {
|
||||||
rm.setData(null);
|
rm.setData(null);
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VariablePersistable persistable = (VariablePersistable) p;
|
SimpleMapPersistable<String> persistable = (SimpleMapPersistable<String>) p;
|
||||||
Object x = elementPath.getLastSegment();
|
Object x = elementPath.getLastSegment();
|
||||||
if (x instanceof VariableVMNode.VariableExpressionVMC) {
|
if (x instanceof VariableVMNode.VariableExpressionVMC) {
|
||||||
IExpressionDMContext ctx = DMContexts.getAncestorOfType(((VariableVMNode.VariableExpressionVMC) x).getDMContext(), IExpressionDMContext.class);
|
IExpressionDMContext ctx = DMContexts.getAncestorOfType(((VariableVMNode.VariableExpressionVMC) x).getDMContext(), IExpressionDMContext.class);
|
||||||
if (ctx == null) {
|
if (ctx == null) {
|
||||||
rm.setData(null);
|
rm.setData(null);
|
||||||
} else {
|
} else {
|
||||||
rm.setData(persistable.getFormat(ctx.getExpression()));
|
rm.setData(persistable.getValue(ctx.getExpression()));
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
|
@ -66,7 +68,7 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
|
||||||
if (y == null) {
|
if (y == null) {
|
||||||
rm.setData(null);
|
rm.setData(null);
|
||||||
} else {
|
} else {
|
||||||
rm.setData(persistable.getFormat(y.getExpressionText()));
|
rm.setData(persistable.getValue(y.getExpressionText()));
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
|
@ -76,13 +78,14 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setActiveFormat(IPresentationContext context, IVMNode[] node, Object viewerInput, TreePath[] elementPath, String format) {
|
public void setActiveFormat(IPresentationContext context, IVMNode[] node, Object viewerInput, TreePath[] elementPath, String format) {
|
||||||
Object p = context.getProperty(myPersistId);
|
Object p = context.getProperty(myPersistId);
|
||||||
VariablePersistable persistable = null;
|
SimpleMapPersistable<String> persistable = null;
|
||||||
if (p instanceof VariablePersistable) {
|
if (p instanceof SimpleMapPersistable) {
|
||||||
persistable = (VariablePersistable) p;
|
persistable = (SimpleMapPersistable<String>) p;
|
||||||
} else {
|
} else {
|
||||||
persistable = new VariablePersistable();
|
persistable = new SimpleMapPersistable<String>(String.class);
|
||||||
context.setProperty(myPersistId, persistable);
|
context.setProperty(myPersistId, persistable);
|
||||||
}
|
}
|
||||||
ArrayList<IDMVMContext> changed = new ArrayList<IDMVMContext>(elementPath.length);
|
ArrayList<IDMVMContext> changed = new ArrayList<IDMVMContext>(elementPath.length);
|
||||||
|
@ -92,13 +95,13 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
|
||||||
IExpressionDMContext ctx = DMContexts.getAncestorOfType(((VariableVMNode.VariableExpressionVMC) x).getDMContext(), IExpressionDMContext.class);
|
IExpressionDMContext ctx = DMContexts.getAncestorOfType(((VariableVMNode.VariableExpressionVMC) x).getDMContext(), IExpressionDMContext.class);
|
||||||
if (ctx == null)
|
if (ctx == null)
|
||||||
continue;
|
continue;
|
||||||
persistable.setFormat(ctx.getExpression(), format);
|
persistable.setValue(ctx.getExpression(), format);
|
||||||
changed.add((IDMVMContext) x);
|
changed.add((IDMVMContext) x);
|
||||||
} else if (x instanceof IDMVMContext) {
|
} else if (x instanceof IDMVMContext) {
|
||||||
IExpression y = (IExpression) ((IVMContext) x).getAdapter(IExpression.class);
|
IExpression y = (IExpression) ((IVMContext) x).getAdapter(IExpression.class);
|
||||||
if (y == null)
|
if (y == null)
|
||||||
continue;
|
continue;
|
||||||
persistable.setFormat(y.getExpressionText(), format);
|
persistable.setValue(y.getExpressionText(), format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed.size() > 0) {
|
if (changed.size() > 0) {
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
/*****************************************************************
|
|
||||||
* Copyright (c) 2011 Texas Instruments 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:
|
|
||||||
* Winnie Lai (Texas Instruments) - Individual Element Number Format example (Bug 202556)
|
|
||||||
*****************************************************************/
|
|
||||||
package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.ui.IMemento;
|
|
||||||
import org.eclipse.ui.IPersistableElement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Variable persistable for variable settings
|
|
||||||
*/
|
|
||||||
class VariablePersistable implements IPersistableElement, IAdaptable {
|
|
||||||
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public void saveState(IMemento memento) {
|
|
||||||
HashMap<String, String> clone = null;
|
|
||||||
synchronized (map) {
|
|
||||||
clone = new HashMap<String, String>(map);
|
|
||||||
}
|
|
||||||
Iterator<Entry<String, String> > it = clone.entrySet().iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Entry<String, String> entry = it.next();
|
|
||||||
IMemento value = memento.createChild("variable", entry.getKey());
|
|
||||||
value.putString("format", entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void restore(IMemento memento) {
|
|
||||||
IMemento[] list = memento.getChildren("variable");
|
|
||||||
HashMap<String, String> clone = new HashMap<String, String>();
|
|
||||||
for (int i = 0; i < list.length; i++) {
|
|
||||||
clone.put(list[i].getID(), list[i].getString("format"));
|
|
||||||
}
|
|
||||||
synchronized(map) {
|
|
||||||
map.clear();
|
|
||||||
map.putAll(clone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getFormat(String key) {
|
|
||||||
if (key == null)
|
|
||||||
return null;
|
|
||||||
synchronized (map) {
|
|
||||||
return map.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFormat(String key, String format) {
|
|
||||||
synchronized (map) {
|
|
||||||
if (format == null) {
|
|
||||||
map.remove(key);
|
|
||||||
} else {
|
|
||||||
map.put(key, format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactoryId() {
|
|
||||||
return VariablePersistableFactory.getFactoryId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
|
||||||
if (adapter.isInstance(this)) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*****************************************************************
|
|
||||||
* Copyright (c) 2011 Texas Instruments 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:
|
|
||||||
* Winnie Lai (Texas Instruments) - Individual Element Number Format example (Bug 202556)
|
|
||||||
*****************************************************************/
|
|
||||||
package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.ui.IElementFactory;
|
|
||||||
import org.eclipse.ui.IMemento;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Variable persistable factory for VariablePersistable
|
|
||||||
*/
|
|
||||||
public class VariablePersistableFactory implements IElementFactory {
|
|
||||||
|
|
||||||
public static String getFactoryId() {
|
|
||||||
return "org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory";
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAdaptable createElement(IMemento memento) {
|
|
||||||
VariablePersistable x = new VariablePersistable();
|
|
||||||
x.restore(memento);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2010 Wind River Systems and others.
|
* Copyright (c) 2008, 2014 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -44,6 +44,8 @@ import org.osgi.framework.BundleContext;
|
||||||
*/
|
*/
|
||||||
public class PDAExpressions extends AbstractDsfService implements ICachingService, IExpressions {
|
public class PDAExpressions extends AbstractDsfService implements ICachingService, IExpressions {
|
||||||
|
|
||||||
|
private static final String FORMAT_MY_FORMAT = "My format";
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
private static class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
private static class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
||||||
|
|
||||||
|
@ -107,10 +109,6 @@ public class PDAExpressions extends AbstractDsfService implements ICachingServic
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStringValue() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +336,7 @@ public class PDAExpressions extends AbstractDsfService implements ICachingServic
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(getData().getFormattedValue());
|
Integer.parseInt(getData().getFormattedValue());
|
||||||
rm.setData(new String[] { DECIMAL_FORMAT, HEX_FORMAT, DECIMAL_FORMAT, OCTAL_FORMAT, BINARY_FORMAT });
|
rm.setData(new String[] { DECIMAL_FORMAT, HEX_FORMAT, OCTAL_FORMAT, BINARY_FORMAT, FORMAT_MY_FORMAT });
|
||||||
rm.done();
|
rm.done();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
rm.setData(new String[] { STRING_FORMAT });
|
rm.setData(new String[] { STRING_FORMAT });
|
||||||
|
@ -388,7 +386,6 @@ public class PDAExpressions extends AbstractDsfService implements ICachingServic
|
||||||
rm.setData(new FormattedValueDMData(getData().fResponseText));
|
rm.setData(new FormattedValueDMData(getData().fResponseText));
|
||||||
rm.done();
|
rm.done();
|
||||||
} else {
|
} else {
|
||||||
int result;
|
|
||||||
try {
|
try {
|
||||||
int intResult = Integer.parseInt(getData().fResponseText);
|
int intResult = Integer.parseInt(getData().fResponseText);
|
||||||
String formattedResult = "";
|
String formattedResult = "";
|
||||||
|
@ -418,8 +415,10 @@ public class PDAExpressions extends AbstractDsfService implements ICachingServic
|
||||||
formattedResult = prefix.toString();
|
formattedResult = prefix.toString();
|
||||||
} else if (DECIMAL_FORMAT.equals(formatId)) {
|
} else if (DECIMAL_FORMAT.equals(formatId)) {
|
||||||
formattedResult = Integer.toString(intResult);
|
formattedResult = Integer.toString(intResult);
|
||||||
|
} else if (FORMAT_MY_FORMAT.equals(formatId)) {
|
||||||
|
formattedResult = "This value is in my format";
|
||||||
} else {
|
} else {
|
||||||
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid format");
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid format " + formatId);
|
||||||
}
|
}
|
||||||
rm.setData(new FormattedValueDMData(formattedResult));
|
rm.setData(new FormattedValueDMData(formattedResult));
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -453,7 +452,6 @@ public class PDAExpressions extends AbstractDsfService implements ICachingServic
|
||||||
{
|
{
|
||||||
String value = null;
|
String value = null;
|
||||||
try {
|
try {
|
||||||
int intValue = 0;
|
|
||||||
if (HEX_FORMAT.equals(formatId)) {
|
if (HEX_FORMAT.equals(formatId)) {
|
||||||
if (formattedExprValue.startsWith("0x")) formattedExprValue = formattedExprValue.substring(2);
|
if (formattedExprValue.startsWith("0x")) formattedExprValue = formattedExprValue.substring(2);
|
||||||
value = Integer.toString( Integer.parseInt(formattedExprValue, 16) );
|
value = Integer.toString( Integer.parseInt(formattedExprValue, 16) );
|
||||||
|
|
Loading…
Add table
Reference in a new issue