feature[ats_AMS1527]: Added functionality on an update to display as hex
Signed-off-by: Jonathon Fidiam <Jonathon.Fidiam@boeing.com>
Change-Id: I451e213c7337cc483f4fdbe1d84874e3f3d7d02a
diff --git a/org.eclipse.ote.ui.eviewer.test/.classpath b/org.eclipse.ote.ui.eviewer.test/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.ote.ui.eviewer.test/.project b/org.eclipse.ote.ui.eviewer.test/.project
new file mode 100644
index 0000000..67d2156
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ote.ui.eviewer.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.ote.ui.eviewer.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ote.ui.eviewer.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/org.eclipse.ote.ui.eviewer.test/META-INF/MANIFEST.MF b/org.eclipse.ote.ui.eviewer.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..63a7bc9
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test
+Bundle-SymbolicName: org.eclipse.ote.ui.eviewer.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.junit,
+ org.eclipse.osee.framework.messaging,
+ org.mockito,
+ org.eclipse.osee.framework.core,
+ org.eclipse.osee.ote.messaging.dds,
+ org.eclipse.osee.framework.jdk.core
+Import-Package: com.google.inject.spi;version="1.4.0",
+ org.eclipse.osee.ote.message,
+ org.eclipse.osee.ote.message.data,
+ org.eclipse.osee.ote.message.elements,
+ org.eclipse.osee.ote.message.enums,
+ org.eclipse.osee.ote.message.interfaces,
+ org.eclipse.ote.ui.eviewer.tohex
diff --git a/org.eclipse.ote.ui.eviewer.test/build.properties b/org.eclipse.ote.ui.eviewer.test/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessage.java b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessage.java
new file mode 100644
index 0000000..80086e0
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessage.java
@@ -0,0 +1,17 @@
+package org.eclipse.ote.ui.eviewer.test;
+
+import org.eclipse.osee.ote.message.Message;
+import org.eclipse.osee.ote.message.data.MessageData;
+
+public class ElementViewerTestMessage extends Message {
+
+ public static final int _BYTE_SIZE = 16;
+ public static final int _MESSAGE_ID = 1;
+
+ public ElementViewerTestMessage() {
+ super(ElementViewerTestMessage.class.getSimpleName(), _BYTE_SIZE, 0, true, 0, 0);
+ byte[] data = "test data".getBytes();
+ MessageData messageData = new ElementViewerTestMessageData(data, data.length, 0);
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessageData.java b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessageData.java
new file mode 100644
index 0000000..840c5c2
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerTestMessageData.java
@@ -0,0 +1,24 @@
+package org.eclipse.ote.ui.eviewer.test;
+
+import org.eclipse.osee.ote.message.IMessageHeader;
+import org.eclipse.osee.ote.message.data.IMessageDataVisitor;
+import org.eclipse.osee.ote.message.data.MessageData;
+public class ElementViewerTestMessageData extends MessageData{
+
+ public ElementViewerTestMessageData(byte[] data, int dataByteSize, int offset) {
+ super(data, dataByteSize, offset);
+ }
+
+ @Override
+ public IMessageHeader getMsgHeader() {
+ return null;
+ }
+
+ @Override
+ public void visit(IMessageDataVisitor visitor) {
+ }
+
+ @Override
+ public void initializeDefaultHeaderValues() {
+ }
+}
diff --git a/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerToHexTest.java b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerToHexTest.java
new file mode 100644
index 0000000..90588fd
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer.test/src/org/eclipse/ote/ui/eviewer/test/ElementViewerToHexTest.java
@@ -0,0 +1,87 @@
+package org.eclipse.ote.ui.eviewer.test;
+import org.eclipse.osee.ote.message.elements.BiSci16Element;
+import org.eclipse.osee.ote.message.elements.CharElement;
+import org.eclipse.osee.ote.message.elements.Dec32Element;
+import org.eclipse.osee.ote.message.elements.FixedPointElement;
+import org.eclipse.osee.ote.message.elements.Float32Element;
+import org.eclipse.osee.ote.message.elements.Float64Element;
+import org.eclipse.osee.ote.message.elements.IntegerElement;
+import org.eclipse.osee.ote.message.elements.LongIntegerElement;
+import org.eclipse.osee.ote.message.elements.StringElement;
+import org.eclipse.ote.ui.eviewer.tohex.ToHexFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ElementViewerToHexTest {
+
+
+ private static ToHexFactory toHexFactory;
+ @Test
+ public void toHexTest() {
+
+ toHexFactory = new ToHexFactory();
+
+ ElementViewerTestMessage testMessage = new ElementViewerTestMessage();
+ byte[] data = "blank data".getBytes();
+ ElementViewerTestMessageData testMessageData = new ElementViewerTestMessageData(data, data.length, 0);
+
+ IntegerElement integerElement = new IntegerElement(testMessage, "element", testMessageData, 0, 32);
+ integerElement.setValue(10);
+ String intToHex = toHexFactory.getHexConverter(integerElement).toHex(integerElement).toUpperCase();
+ String intToHexPredicate = "A";
+ Assert.assertEquals(intToHexPredicate, intToHex);
+
+ LongIntegerElement longElement = new LongIntegerElement(testMessage, "element", testMessageData, 0, 64);
+ longElement.setValue((long) 98765);
+ String longToHex = toHexFactory.getHexConverter(longElement).toHex(longElement).toUpperCase();
+ String longToHexPredicate = "181CD";
+ Assert.assertEquals(longToHexPredicate, longToHex);
+
+ Float32Element float32Element = new Float32Element(testMessage, "element", testMessageData, 0, 32);
+ float32Element.setValue(10.5);
+ String float32ToHex = toHexFactory.getHexConverter(float32Element).toHex(float32Element).toUpperCase();
+ String float32ToHexPredicate = "41280000";
+ Assert.assertEquals(float32ToHexPredicate, float32ToHex);
+
+ Float64Element float64Element = new Float64Element(testMessage, "element", testMessageData, 0, 64);
+ float64Element.setValue(55.625);
+ String float64ToHex = toHexFactory.getHexConverter(float64Element).toHex(float64Element).toUpperCase();
+ String float64ToHexPredicate = "404BD00000000000";
+ Assert.assertEquals(float64ToHexPredicate, float64ToHex);
+
+ Dec32Element decElement = new Dec32Element(testMessage, "element", testMessageData, 0, 32);
+ decElement.setValue(10.5);
+ String decToHex = toHexFactory.getHexConverter(decElement).toHex(decElement);
+ String decToHexPredicate = "42280000";
+ Assert.assertEquals(decToHexPredicate, decToHex);
+
+ FixedPointElement fixedElement = new FixedPointElement(testMessage, "element", testMessageData, 1, true, 0, 0, 11);
+ fixedElement.setValue((double) -2900.0);
+ String fixedtoHex = toHexFactory.getHexConverter(fixedElement).toHex(fixedElement).toUpperCase();
+ String fixedToHexPredicate = "4AC";
+ Assert.assertEquals(fixedToHexPredicate, fixedtoHex);
+
+ BiSci16Element biSci16Element = new BiSci16Element(testMessage, "element", testMessageData, 0, 16);
+ biSci16Element.setValue((long) 65535);
+ String biSci16ToHex = toHexFactory.getHexConverter(biSci16Element).toHex(biSci16Element).toUpperCase();
+ String biSci16ToHexPredicate = "1002";
+ Assert.assertEquals(biSci16ToHexPredicate, biSci16ToHex);
+
+ StringElement stringElement = new StringElement(testMessage, "element", testMessageData, 0, 64);
+ stringElement.setValue("ABCD");
+ String stringToHex = toHexFactory.getHexConverter(stringElement).toHex(stringElement);
+ String stringToHexPredicate = "ABCD";
+ Assert.assertEquals(stringToHexPredicate, stringToHex);
+
+ CharElement charElement = new CharElement(testMessage, "element", testMessageData, 0, 8);
+ charElement.setValue('B');
+ String charToHex = toHexFactory.getHexConverter(charElement).toHex(charElement);
+ String charToHexPredicate = "42";
+ Assert.assertEquals(charToHexPredicate, charToHex);
+
+
+
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/META-INF/MANIFEST.MF b/org.eclipse.ote.ui.eviewer/META-INF/MANIFEST.MF
index 76f01ca..e64250f 100644
--- a/org.eclipse.ote.ui.eviewer/META-INF/MANIFEST.MF
+++ b/org.eclipse.ote.ui.eviewer/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@
org.eclipse.osee.ote.messaging.dds
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.ote.ui.eviewer.view
+Export-Package: org.eclipse.ote.ui.eviewer.tohex,
+ org.eclipse.ote.ui.eviewer.view
Import-Package: org.eclipse.osee.framework.jdk.core.persistence,
org.eclipse.ote.io,
org.eclipse.ote.message.lookup,
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowElementsAsHexAction.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowElementsAsHexAction.java
new file mode 100644
index 0000000..c3f796f
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowElementsAsHexAction.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+/**
+ * @author Jonathon Fidiam
+ */
+
+
+package org.eclipse.ote.ui.eviewer.action;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ote.ui.eviewer.Activator;
+import org.eclipse.ote.ui.eviewer.view.ElementContentProvider;
+
+public class ShowElementsAsHexAction extends Action{
+
+ private final ElementContentProvider elementContentProvider;
+
+ public ShowElementsAsHexAction(ElementContentProvider elementContentProvider, boolean isChecked) {
+ super("Show Elements as Hex", IAction.AS_CHECK_BOX);
+ setImageDescriptor(Activator.getImageDescriptor("icons/NumberLetter.png"));
+ setToolTipText("Show Elements as Hex");
+ this.elementContentProvider = elementContentProvider;
+ this.setChecked(isChecked);
+ if(isChecked){
+ run();
+ }
+ }
+
+ @Override
+ public void run() {
+ elementContentProvider.showNumbersAsHex(this.isChecked());
+ }
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowEnumAsNumberAction.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowEnumAsNumberAction.java
index 84174af..c163249 100644
--- a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowEnumAsNumberAction.java
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/action/ShowEnumAsNumberAction.java
@@ -16,7 +16,7 @@
import org.eclipse.ote.ui.eviewer.view.ElementContentProvider;
/**
- * @author Ken J. Aguilar
+ * @author Jonathon Fidiam
*/
public class ShowEnumAsNumberAction extends Action {
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/CharToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/CharToHex.java
new file mode 100644
index 0000000..8e2ea52
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/CharToHex.java
@@ -0,0 +1,18 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+
+
+public class CharToHex implements IToHex {
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ String hexString;
+ Character rawData = (Character) element.getValue();
+ Long charToLong = (long)rawData;
+ hexString = "0x";
+ hexString += Long.toHexString(charToLong);
+ return hexString;
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EmptyEnumToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EmptyEnumToHex.java
new file mode 100644
index 0000000..eb9cd26
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EmptyEnumToHex.java
@@ -0,0 +1,14 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+import org.eclipse.osee.ote.message.elements.EmptyEnum_Element;
+
+public class EmptyEnumToHex implements IToHex{
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ String hexString;
+ hexString = ((EmptyEnum_Element)element).getValue().toString().toUpperCase();
+ return hexString;
+ }
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EnumToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EnumToHex.java
new file mode 100644
index 0000000..8db11c1
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/EnumToHex.java
@@ -0,0 +1,16 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+import org.eclipse.osee.ote.message.elements.EnumeratedElement;
+
+public class EnumToHex implements IToHex{
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ // just returns the value as a string
+ @SuppressWarnings("rawtypes")
+ String hexString = ((EnumeratedElement)element).valueOf().toString().toUpperCase();
+ return hexString;
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/IToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/IToHex.java
new file mode 100644
index 0000000..3315e11
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/IToHex.java
@@ -0,0 +1,7 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+
+public interface IToHex {
+ public String toHex(DiscreteElement<?> element);
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/InaccessibleToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/InaccessibleToHex.java
new file mode 100644
index 0000000..b48ca44
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/InaccessibleToHex.java
@@ -0,0 +1,12 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+
+public class InaccessibleToHex implements IToHex{
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ return " ";
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/NumericToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/NumericToHex.java
new file mode 100644
index 0000000..f4bca85
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/NumericToHex.java
@@ -0,0 +1,18 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+import org.eclipse.osee.ote.message.elements.NumericElement;
+
+
+public class NumericToHex implements IToHex {
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ String hexString;
+ long rawData = ((NumericElement<?>)element).getNumericBitValue();
+ hexString = "0x";
+ hexString += Long.toHexString(rawData).toUpperCase();
+ return hexString;
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/StringToHex.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/StringToHex.java
new file mode 100644
index 0000000..33f58cf
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/StringToHex.java
@@ -0,0 +1,15 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+import org.eclipse.osee.ote.message.elements.StringElement;
+
+public class StringToHex implements IToHex{
+
+ @Override
+ public String toHex(DiscreteElement<?> element) {
+ String hexString;
+ hexString = ((StringElement)element).getValue();
+ return hexString;
+ }
+
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/ToHexFactory.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/ToHexFactory.java
new file mode 100644
index 0000000..a6e9bfe
--- /dev/null
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/tohex/ToHexFactory.java
@@ -0,0 +1,30 @@
+package org.eclipse.ote.ui.eviewer.tohex;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.message.elements.CharElement;
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+import org.eclipse.osee.ote.message.elements.EmptyEnum_Element;
+import org.eclipse.osee.ote.message.elements.EnumeratedElement;
+import org.eclipse.osee.ote.message.elements.NumericElement;
+import org.eclipse.osee.ote.message.elements.StringElement;
+
+public class ToHexFactory {
+
+ public IToHex getHexConverter(DiscreteElement<?> elementType){
+ if(elementType instanceof EnumeratedElement){
+ return new EnumToHex();
+ }
+ else if (elementType instanceof NumericElement<?>){
+ return new NumericToHex();
+ }else if (elementType instanceof EmptyEnum_Element){
+ return new EmptyEnumToHex();
+ }else if (elementType instanceof StringElement){
+ return new StringToHex();
+ }else if (elementType instanceof CharElement){
+ return new CharToHex();
+ }else{
+ OseeLog.log(ToHexFactory.class, Level.SEVERE, "ERROR: " + elementType.getDescriptiveName() + " was not handled correctly");
+ return new InaccessibleToHex();
+ }
+ }
+}
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ColumnElement.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ColumnElement.java
index 70bfb8f..f0d1eea 100644
--- a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ColumnElement.java
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ColumnElement.java
@@ -2,7 +2,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-
import org.eclipse.osee.ote.client.msg.core.IMessageSubscription;
import org.eclipse.osee.ote.client.msg.core.ISubscriptionListener;
import org.eclipse.osee.ote.message.ElementPath;
@@ -10,6 +9,9 @@
import org.eclipse.osee.ote.message.elements.Element;
import org.eclipse.osee.ote.message.elements.EnumeratedElement;
import org.eclipse.osee.ote.message.elements.IEnumValue;
+import org.eclipse.ote.ui.eviewer.tohex.EnumToHex;
+import org.eclipse.ote.ui.eviewer.tohex.IToHex;
+import org.eclipse.ote.ui.eviewer.tohex.ToHexFactory;
public class ColumnElement implements ISubscriptionListener {
private ViewerColumnElement viewerColumn;
@@ -22,18 +24,23 @@
private final AtomicReference<Object> lastValueReference = new AtomicReference<Object>(new Object());
private final AtomicBoolean valueUpdatedFlag = new AtomicBoolean(false);
private boolean unsupportedType = false;
-
+ private String hexText = "";
+ private static ToHexFactory toHexFactory;
+ private IToHex toHex;
private boolean isEnum = false;
private EnumeratedElement enumElement = null;
private String enumText = "";
-
+
+ private EnumToHex enumtoHex;
+
ColumnElement(ViewerColumnElement viewerColumn, ElementPath path) {
this.viewerColumn = viewerColumn;
this.path = path;
message = path.getMessageClass();
verbosetext = getMessageName(message) + "." + path.toString();
+ toHexFactory = new ToHexFactory();
}
public ElementPath getElementPath() {
@@ -45,6 +52,9 @@
Object current;
if(isEnum && viewerColumn.isEnumOutputNumber()){
current = enumElement.getIntValue();
+ } else if(viewerColumn.showNumbersAsHex()){
+ hexText = toHex.toHex(element);
+ current = hexText;
} else {
current = element.getValue();
}
@@ -61,7 +71,7 @@
public String getVerboseName() {
return verbosetext;
}
-
+
public String getEnumText(){
return enumText;
}
@@ -81,16 +91,16 @@
public void clearValue() {
lastValueReference.set(null);
}
-
+
public void setToolTip(){
String tip = "";
if (unsupportedType) {
- tip = "This element type cannot be displayed";
+ tip = "This element type cannot be displayed";
} else if (element == null) {
tip = "The element " + getElementPath() + " does not exist on " + getMessageClassName();
} else {
tip = String.format("%s.%s\nByte Offset: %d\nMSB: %d\nLSB: %d", getMessageName(getMessageClassName()), path.toString(), element.getByteOffset(), element.getMsb(),
- element.getLsb());
+ element.getLsb());
if(viewerColumn.isDuplicateName()){
tip = "Note: Duplicate name in view\n" + tip;
}
@@ -138,16 +148,17 @@
@Override
public void subscriptionResolved(IMessageSubscription subscription) {
- Element resolvedElement = subscription.getMessage().getElementByPath(path);
- if (!(resolvedElement instanceof DiscreteElement)) {
- unsupportedType = true;
- element = null;
- isEnum = false;
- enumElement = null;
- lastValueReference.set(UNKNOWN_VALUE);
- return;
- }
+ Element resolvedElement = subscription.getMessage().getElementByPath(path);
+ if (!(resolvedElement instanceof DiscreteElement)) {
+ unsupportedType = true;
+ element = null;
+ isEnum = false;
+ enumElement = null;
+ lastValueReference.set(UNKNOWN_VALUE);
+ return;
+ }
element = (DiscreteElement<?>) resolvedElement;
+ toHex = toHexFactory.getHexConverter(element);
if(element instanceof EnumeratedElement){
enumElement = (EnumeratedElement)element;
isEnum = true;
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementContentProvider.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementContentProvider.java
index 2b8aa5c..08d5231 100644
--- a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementContentProvider.java
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementContentProvider.java
@@ -52,8 +52,7 @@
private final int limit;
private ViewRefresher refresher;
private boolean autoReveal = true;
-
-
+ private boolean showNumbersAsHex = false;
private volatile PrintWriter streamToFileWriter = null;
private HashMap<ViewerColumn, Integer> valueMap = new HashMap<ViewerColumn, Integer>();
@@ -61,10 +60,9 @@
private RowUpdate last = null;
private ReentrantLock streamWriteLock = new ReentrantLock();
private volatile boolean acceptUpdates = true;
-
+ private boolean showEnumAsNumber = false;
private ViewerColumnLong timeColumn;
private ViewerColumnLong timeDeltaColumn;
- private boolean showEnumAsNumber = false;
public ElementContentProvider(int limit) {
this.limit = limit;
@@ -350,6 +348,13 @@
this.showEnumAsNumber = isNumber;
}
+ public void showNumbersAsHex(boolean showNumbersAsHex){
+ for(ViewerColumnElement col:elementColumns){
+ col.setShowNumbersAsHex(showNumbersAsHex);
+ }
+ this.showNumbersAsHex = showNumbersAsHex;
+ }
+
public boolean updateInternalFile() {
try {
saveColumnsToFile(OseeData.getFile(Constants.INTERNAL_FILE_NAME));
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementViewer.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementViewer.java
index 0abdd0a..7725909 100644
--- a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementViewer.java
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ElementViewer.java
@@ -12,7 +12,6 @@
import java.io.File;
import java.util.logging.Level;
-
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
@@ -38,6 +37,7 @@
import org.eclipse.ote.ui.eviewer.action.SaveLoadAction;
import org.eclipse.ote.ui.eviewer.action.SetActiveColumnAction;
import org.eclipse.ote.ui.eviewer.action.ShowEnumAsNumberAction;
+import org.eclipse.ote.ui.eviewer.action.ShowElementsAsHexAction;
import org.eclipse.ote.ui.eviewer.action.ShowTimeAction;
import org.eclipse.ote.ui.eviewer.action.ShowTimeDeltaAction;
import org.eclipse.ote.ui.eviewer.action.StreamToFileAction;
@@ -90,6 +90,8 @@
private ShowEnumAsNumberAction showEnumAsNumberAction;
+ private ShowElementsAsHexAction showNumbersAsHex;
+
/**
* The constructor.
*/
@@ -163,6 +165,7 @@
manager.add(new Separator());
manager.add(toggleAutoRevealAction);
manager.add(showEnumAsNumberAction);
+ manager.add(showNumbersAsHex);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
@@ -177,6 +180,7 @@
manager.add(saveLoadAction);
manager.add(pauseUpdatesAction);
manager.add(streamToFileAction);
+ manager.add(showNumbersAsHex);
manager.add(new OpenNewElementViewer());
}
@@ -198,6 +202,7 @@
showTimeDeltaAction = new ShowTimeDeltaAction(elementContentProvider);
showEnumAsNumberAction = new ShowEnumAsNumberAction(elementContentProvider, false);
+ showNumbersAsHex = new ShowElementsAsHexAction(elementContentProvider, false);
}
private void hookDoubleClickAction() {
diff --git a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ViewerColumnElement.java b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ViewerColumnElement.java
index 7c8103a..79cfd3f 100644
--- a/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ViewerColumnElement.java
+++ b/org.eclipse.ote.ui.eviewer/src/org/eclipse/ote/ui/eviewer/view/ViewerColumnElement.java
@@ -18,6 +18,7 @@
private ColumnElement columnElement;
private boolean duplicateName = false;
private boolean isEnumOutputNumber = false;
+ private boolean showNumbersAsHex = false;
ViewerColumnElement(TableViewer table, int index, ElementPath path) {
@@ -113,7 +114,12 @@
public void setEnumOutputNumber(boolean isNumber){
isEnumOutputNumber = isNumber;
}
-
-
+
+ public boolean showNumbersAsHex(){
+ return showNumbersAsHex;
+ }
+ public void setShowNumbersAsHex(boolean showNumbersAsHex) {
+ this.showNumbersAsHex = showNumbersAsHex;
+ }
}