Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2014-07-15 13:34:38 +0000
committerMarc Khouzam2014-10-29 17:32:35 +0000
commit126e67237d6915a17e250c0ce8596c50d42f8f91 (patch)
tree8fa230a0a3993c6b8baea810ace06fd9b247d710 /dsf/org.eclipse.cdt.examples.dsf.pda.ui
parent08fd13ed9f55297f738363484912acd806b8cbde (diff)
downloadorg.eclipse.cdt-126e67237d6915a17e250c0ce8596c50d42f8f91.tar.gz
org.eclipse.cdt-126e67237d6915a17e250c0ce8596c50d42f8f91.tar.xz
org.eclipse.cdt-126e67237d6915a17e250c0ce8596c50d42f8f91.zip
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>
Diffstat (limited to 'dsf/org.eclipse.cdt.examples.dsf.pda.ui')
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml7
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAExpressionVMProvider.java25
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistable.java81
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistableFactory.java32
4 files changed, 14 insertions, 131 deletions
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml
index 08095386ad3..5d2b5ff5cff 100644
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml
@@ -105,13 +105,6 @@
</factory>
</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
point="org.eclipse.cdt.debug.ui.breakpointContribution">
<breakpointEditors
debugModelId="org.eclipse.cdt.examples.dsf.pda.debugModel"
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAExpressionVMProvider.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAExpressionVMProvider.java
index e3a7340d3fb..91ea58f4392 100644
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAExpressionVMProvider.java
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAExpressionVMProvider.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.datamodel.DMContexts;
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.numberformat.IElementFormatProvider;
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);
}
+ @SuppressWarnings("unchecked")
public void getActiveFormat(IPresentationContext context, IVMNode node, Object viewerInput, TreePath elementPath,
DataRequestMonitor<String> rm) {
Object p = context.getProperty(myPersistId);
- if (p instanceof VariablePersistable == false) {
+ if (p instanceof SimpleMapPersistable == false) {
rm.setData(null);
rm.done();
return;
}
- VariablePersistable persistable = (VariablePersistable) p;
+ SimpleMapPersistable<String> persistable = (SimpleMapPersistable<String>) p;
Object x = elementPath.getLastSegment();
if (x instanceof VariableVMNode.VariableExpressionVMC) {
IExpressionDMContext ctx = DMContexts.getAncestorOfType(((VariableVMNode.VariableExpressionVMC) x).getDMContext(), IExpressionDMContext.class);
if (ctx == null) {
rm.setData(null);
} else {
- rm.setData(persistable.getFormat(ctx.getExpression()));
+ rm.setData(persistable.getValue(ctx.getExpression()));
}
rm.done();
return;
@@ -66,7 +68,7 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
if (y == null) {
rm.setData(null);
} else {
- rm.setData(persistable.getFormat(y.getExpressionText()));
+ rm.setData(persistable.getValue(y.getExpressionText()));
}
rm.done();
return;
@@ -76,13 +78,14 @@ public class PDAExpressionVMProvider extends ExpressionVMProvider implements IEl
return;
}
+ @SuppressWarnings("unchecked")
public void setActiveFormat(IPresentationContext context, IVMNode[] node, Object viewerInput, TreePath[] elementPath, String format) {
Object p = context.getProperty(myPersistId);
- VariablePersistable persistable = null;
- if (p instanceof VariablePersistable) {
- persistable = (VariablePersistable) p;
+ SimpleMapPersistable<String> persistable = null;
+ if (p instanceof SimpleMapPersistable) {
+ persistable = (SimpleMapPersistable<String>) p;
} else {
- persistable = new VariablePersistable();
+ persistable = new SimpleMapPersistable<String>(String.class);
context.setProperty(myPersistId, persistable);
}
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);
if (ctx == null)
continue;
- persistable.setFormat(ctx.getExpression(), format);
+ persistable.setValue(ctx.getExpression(), format);
changed.add((IDMVMContext) x);
} else if (x instanceof IDMVMContext) {
IExpression y = (IExpression) ((IVMContext) x).getAdapter(IExpression.class);
if (y == null)
continue;
- persistable.setFormat(y.getExpressionText(), format);
+ persistable.setValue(y.getExpressionText(), format);
}
}
if (changed.size() > 0) {
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistable.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistable.java
deleted file mode 100644
index e723b106548..00000000000
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistable.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistableFactory.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistableFactory.java
deleted file mode 100644
index 914fd8c6056..00000000000
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/VariablePersistableFactory.java
+++ /dev/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;
- }
-
-}

Back to the top