Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 08:02:08 +0000
committerrbrooks2010-07-24 08:02:08 +0000
commit4ed8bddc791fda93940f238c5135556a07041dc0 (patch)
tree64a118285c5006c3a38320dbb2d374e8ea72a061 /plugins/org.eclipse.osee.ote.ui.markers
parent542cc7344d3f129d64e47f547384297c8e1b1f43 (diff)
downloadorg.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.gz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.xz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.zip
converted all line terminators to unix style
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.markers')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/.classpath14
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/.project56
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/build.properties8
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/CheckPointHelper.java114
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerInfo.java68
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerPlugin.java212
-rw-r--r--plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/OteMarkerHelper.java272
7 files changed, 372 insertions, 372 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/.classpath b/plugins/org.eclipse.osee.ote.ui.markers/.classpath
index 8a8f1668cdc..ad32c83a788 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/.classpath
+++ b/plugins/org.eclipse.osee.ote.ui.markers/.classpath
@@ -1,7 +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.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?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.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/.project b/plugins/org.eclipse.osee.ote.ui.markers/.project
index 2cf24a360a4..91b3aab9a73 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/.project
+++ b/plugins/org.eclipse.osee.ote.ui.markers/.project
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.ote.ui.markers</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>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ote.ui.markers</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/plugins/org.eclipse.osee.ote.ui.markers/build.properties b/plugins/org.eclipse.osee.ote.ui.markers/build.properties
index 41eb6ade2b4..34d2e4d2dad 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/build.properties
+++ b/plugins/org.eclipse.osee.ote.ui.markers/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/CheckPointHelper.java b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/CheckPointHelper.java
index 6c388bf7fd9..ef3b3fa883b 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/CheckPointHelper.java
+++ b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/CheckPointHelper.java
@@ -8,60 +8,60 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.markers;
-
-import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
-import org.w3c.dom.Element;
-
-public class CheckPointHelper implements Comparable<CheckPointHelper> {
-
- @Override
- public String toString() {
- return String.format("%s[%s, %s]", testPointName, expected, actual);
- }
-
- /**
- *
- */
- public void increment() {
- count++;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof CheckPointHelper) {
- return key.equals(((CheckPointHelper) obj).key);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return key.hashCode();
- }
-
- private String testPointName;
- private String expected;
- private String actual;
- private String key;
- private int count = 1;
-
- public CheckPointHelper(Element el) {
- testPointName = Jaxp.getChildText(el, "TestPointName");
- expected = Jaxp.getChildText(el, "Expected");
- actual = Jaxp.getChildText(el, "Actual");
- key = testPointName + expected + actual;
- }
-
- public CheckPointHelper(CheckPointData data){
- testPointName = data.getName();
- expected = data.getExpected();
- actual = data.getActual();
- key = testPointName + expected + actual;
- }
-
- public int compareTo(CheckPointHelper o) {
- return o.count - this.count;
- }
-
- }
+package org.eclipse.osee.ote.ui.markers;
+
+import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
+import org.w3c.dom.Element;
+
+public class CheckPointHelper implements Comparable<CheckPointHelper> {
+
+ @Override
+ public String toString() {
+ return String.format("%s[%s, %s]", testPointName, expected, actual);
+ }
+
+ /**
+ *
+ */
+ public void increment() {
+ count++;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof CheckPointHelper) {
+ return key.equals(((CheckPointHelper) obj).key);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode();
+ }
+
+ private String testPointName;
+ private String expected;
+ private String actual;
+ private String key;
+ private int count = 1;
+
+ public CheckPointHelper(Element el) {
+ testPointName = Jaxp.getChildText(el, "TestPointName");
+ expected = Jaxp.getChildText(el, "Expected");
+ actual = Jaxp.getChildText(el, "Actual");
+ key = testPointName + expected + actual;
+ }
+
+ public CheckPointHelper(CheckPointData data){
+ testPointName = data.getName();
+ expected = data.getExpected();
+ actual = data.getActual();
+ key = testPointName + expected + actual;
+ }
+
+ public int compareTo(CheckPointHelper o) {
+ return o.count - this.count;
+ }
+
+ }
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerInfo.java b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerInfo.java
index 1e2a0f00eab..28272ab6b55 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerInfo.java
+++ b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerInfo.java
@@ -8,37 +8,37 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.markers;
-
-public class MarkerInfo {
- private String file;
- private int line;
- private String message;
-
- public MarkerInfo(String file, int line, String message) {
- this.file = file;
- this.line = line;
- this.message = message;
- }
-
- /**
- * @return the file
- */
- public String getFile() {
- return file;
- }
-
- /**
- * @return the line
- */
- public int getLine() {
- return line;
- }
-
- /**
- * @return the message
- */
- public String getMessage() {
- return message;
- }
-}
+package org.eclipse.osee.ote.ui.markers;
+
+public class MarkerInfo {
+ private String file;
+ private int line;
+ private String message;
+
+ public MarkerInfo(String file, int line, String message) {
+ this.file = file;
+ this.line = line;
+ this.message = message;
+ }
+
+ /**
+ * @return the file
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @return the line
+ */
+ public int getLine() {
+ return line;
+ }
+
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerPlugin.java b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerPlugin.java
index e351a7b3918..c282f2d40c8 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerPlugin.java
+++ b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/MarkerPlugin.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.markers;
-
+package org.eclipse.osee.ote.ui.markers;
+
import java.util.List;
import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
@@ -25,112 +25,112 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class MarkerPlugin extends OseeUiActivator {
-
- private FileWatchList filesToWatch;
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui.markers";
-
- // The shared instance
- private static MarkerPlugin plugin;
-
- /**
- * The constructor
- */
- public MarkerPlugin() {
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- filesToWatch = new FileWatchList();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
-
- public void resourceChanged(final IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- try {
- delta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IPath path = delta.getFullPath();
- String extension = path.getFileExtension();
- if (extension != null) {
- if ("tmo".equals(extension)) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- // file.refreshLocal(depth, monitor);
- if (file != null) {
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- // OseeLog.log(Activator.class, Level.INFO, String.format("ADDED %s updating
- // markers - delta kind: %d", file.getName(), delta.getKind()));
- // addMarkers(file);
- break;
- case IResourceDelta.CHANGED:
- // OseeLog.log(Activator.class, Level.INFO, String.format("CHANGED %s updating
- // markers - delta kind: %d", file.getName(), delta.getKind()));
- // updateMarkers(file);
- break;
- case IResourceDelta.REMOVED:
- // OseeLog.log(Activator.class, Level.INFO, String.format("removing %s markers -
- // delta kind: %d", file.getName(), delta.getKind()));
- removeMarkers(file);
- break;
- }
- }
- }
- }
- if (delta.getAffectedChildren().length > 0) return true;
- return false;
- }
- });
- } catch (CoreException ex) {
- OseeLog.log(MarkerPlugin.class, Level.SEVERE, ex);
- }
- }
-
- }, IResourceChangeEvent.POST_CHANGE);
- }
-
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static MarkerPlugin getDefault() {
- return plugin;
- }
-
- public void addMarkers(IFile file) {
- removeMarkers(file);
- Jobs.runInJob("OTE Marker Processing", new ProcessOutfileSax(this, file), MarkerPlugin.class, MarkerPlugin.PLUGIN_ID, false);
- }
-
- public void removeMarkers(IFile file) {
- List<IMarker> markers = filesToWatch.get(file);
- if (markers != null) {
- for (IMarker marker : markers) {
- try {
- marker.delete();
- } catch (CoreException ex) {
- }
- }
- }
- }
-
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class MarkerPlugin extends OseeUiActivator {
+
+ private FileWatchList filesToWatch;
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui.markers";
+
+ // The shared instance
+ private static MarkerPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public MarkerPlugin() {
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ filesToWatch = new FileWatchList();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
+
+ public void resourceChanged(final IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ delta.accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IPath path = delta.getFullPath();
+ String extension = path.getFileExtension();
+ if (extension != null) {
+ if ("tmo".equals(extension)) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ // file.refreshLocal(depth, monitor);
+ if (file != null) {
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ // OseeLog.log(Activator.class, Level.INFO, String.format("ADDED %s updating
+ // markers - delta kind: %d", file.getName(), delta.getKind()));
+ // addMarkers(file);
+ break;
+ case IResourceDelta.CHANGED:
+ // OseeLog.log(Activator.class, Level.INFO, String.format("CHANGED %s updating
+ // markers - delta kind: %d", file.getName(), delta.getKind()));
+ // updateMarkers(file);
+ break;
+ case IResourceDelta.REMOVED:
+ // OseeLog.log(Activator.class, Level.INFO, String.format("removing %s markers -
+ // delta kind: %d", file.getName(), delta.getKind()));
+ removeMarkers(file);
+ break;
+ }
+ }
+ }
+ }
+ if (delta.getAffectedChildren().length > 0) return true;
+ return false;
+ }
+ });
+ } catch (CoreException ex) {
+ OseeLog.log(MarkerPlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ }, IResourceChangeEvent.POST_CHANGE);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static MarkerPlugin getDefault() {
+ return plugin;
+ }
+
+ public void addMarkers(IFile file) {
+ removeMarkers(file);
+ Jobs.runInJob("OTE Marker Processing", new ProcessOutfileSax(this, file), MarkerPlugin.class, MarkerPlugin.PLUGIN_ID, false);
+ }
+
+ public void removeMarkers(IFile file) {
+ List<IMarker> markers = filesToWatch.get(file);
+ if (markers != null) {
+ for (IMarker marker : markers) {
+ try {
+ marker.delete();
+ } catch (CoreException ex) {
+ }
+ }
+ }
+ }
+
synchronized void updateMarkerInfo(IFile file, List<IMarker> markers) {
List<IMarker> oldMarkers = filesToWatch.get(file);
if(oldMarkers != null){
oldMarkers.addAll(markers);
- } else {
+ } else {
filesToWatch.put(file, markers);
- }
- }
-}
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/OteMarkerHelper.java b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/OteMarkerHelper.java
index 1d0bedb38b3..808387bd148 100644
--- a/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/OteMarkerHelper.java
+++ b/plugins/org.eclipse.osee.ote.ui.markers/src/org/eclipse/osee/ote/ui/markers/OteMarkerHelper.java
@@ -1,136 +1,136 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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
- *******************************************************************************/
-package org.eclipse.osee.ote.ui.markers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.ui.ws.AWorkspace;
-import org.eclipse.osee.ote.core.framework.saxparse.elements.StacktraceData;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class OteMarkerHelper {
-
- private final List<MarkerInfo> markerInfo;
- private final List<IMarker> markersToDelete;
- private final Map<CheckPointHelper, CheckPointHelper> count = new HashMap<CheckPointHelper, CheckPointHelper>();
- private final StringBuilder builder = new StringBuilder();
- private final List<TestPointData> testPonitDatas;
-
- /**
- * @param testPointDatas
- */
- public OteMarkerHelper(List<TestPointData> testPointDatas) {
- this.testPonitDatas = testPointDatas;
- markerInfo = new ArrayList<MarkerInfo>();
- markersToDelete = new ArrayList<IMarker>();
-
- doWork();
- }
-
- private void doWork() {
- for (TestPointData data : testPonitDatas) {
- String description = getDescription(data.getCheckPointData());
- String number = data.getNumber();
- int num = Integer.parseInt(number);
- String details = String.format("#%03d %s", num, description);
-
- for (StacktraceData stackLocation : data.getStacktraceCollection().getStackTrace()) {
- String file = stackLocation.getSource();
- String line = stackLocation.getLine();
- //pull out the java file name
- file = file.substring(file.lastIndexOf(".") + 1);
- int innerMarker = file.indexOf("$");
- if (innerMarker > 0) {
- file = file.substring(0, file.indexOf("$"));
- }
- file += ".java";
- int linenumber = Integer.parseInt(line);
-
- markerInfo.add(new MarkerInfo(file, linenumber, details));
- }
- }
- finish();
- }
-
- private String getDescription(List<CheckPointData> datas) {
- count.clear();
- for (CheckPointData data : datas) {
- CheckPointHelper check = new CheckPointHelper(data);
- if (count.containsKey(check)) {
- count.get(check).increment();
- } else {
- count.put(check, check);
- }
- }
-
- CheckPointHelper[] helper = count.values().toArray(new CheckPointHelper[count.values().size()]);
- Arrays.sort(helper);
- int maxNumber = 2;
- builder.setLength(0);
- for (int i = 0; i < helper.length && i < maxNumber; i++) {
- builder.append(helper[i].toString());
- if (i + 1 < Math.min(helper.length, maxNumber)) {
- builder.append(", ");
- }
- if (i + 1 < helper.length && i + 1 >= maxNumber) {
- builder.append("...");
- }
- }
- return builder.toString();
- }
-
- private void finish() {
-
- Set<String> fileAlreadyLookedFor = new HashSet<String>();
- Map<String, IResource> resources = new HashMap<String, IResource>();
-
- for (MarkerInfo marker : markerInfo) {
- try {
- if (!fileAlreadyLookedFor.contains(marker.getFile())) {
- fileAlreadyLookedFor.add(marker.getFile());
- IResource resource = AWorkspace.findWorkspaceFile(marker.getFile());
- if (resource != null) {
- resources.put(marker.getFile(), resource);
- }
- }
-
- IResource resourceToMark = resources.get(marker.getFile());
- if (resourceToMark != null) {
- Map<String, Object> scriptMarkerMap = new HashMap<String, Object>();
- scriptMarkerMap.put(IMarker.MESSAGE, marker.getMessage());
- scriptMarkerMap.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
- scriptMarkerMap.put(IMarker.LINE_NUMBER, marker.getLine());
- IMarker markerToDelete = resourceToMark.createMarker("org.eclipse.osee.ote.ui.output.errorMarker");
- markerToDelete.setAttributes(scriptMarkerMap);
- markersToDelete.add(markerToDelete);
- }
- } catch (Exception ex) {
- OseeLog.log(MarkerPlugin.class, Level.SEVERE, "Error adding markers from outfile", ex);
- }
- }
- }
-
- public List<IMarker> getMarkers() {
- return markersToDelete;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ *******************************************************************************/
+package org.eclipse.osee.ote.ui.markers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.ws.AWorkspace;
+import org.eclipse.osee.ote.core.framework.saxparse.elements.StacktraceData;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class OteMarkerHelper {
+
+ private final List<MarkerInfo> markerInfo;
+ private final List<IMarker> markersToDelete;
+ private final Map<CheckPointHelper, CheckPointHelper> count = new HashMap<CheckPointHelper, CheckPointHelper>();
+ private final StringBuilder builder = new StringBuilder();
+ private final List<TestPointData> testPonitDatas;
+
+ /**
+ * @param testPointDatas
+ */
+ public OteMarkerHelper(List<TestPointData> testPointDatas) {
+ this.testPonitDatas = testPointDatas;
+ markerInfo = new ArrayList<MarkerInfo>();
+ markersToDelete = new ArrayList<IMarker>();
+
+ doWork();
+ }
+
+ private void doWork() {
+ for (TestPointData data : testPonitDatas) {
+ String description = getDescription(data.getCheckPointData());
+ String number = data.getNumber();
+ int num = Integer.parseInt(number);
+ String details = String.format("#%03d %s", num, description);
+
+ for (StacktraceData stackLocation : data.getStacktraceCollection().getStackTrace()) {
+ String file = stackLocation.getSource();
+ String line = stackLocation.getLine();
+ //pull out the java file name
+ file = file.substring(file.lastIndexOf(".") + 1);
+ int innerMarker = file.indexOf("$");
+ if (innerMarker > 0) {
+ file = file.substring(0, file.indexOf("$"));
+ }
+ file += ".java";
+ int linenumber = Integer.parseInt(line);
+
+ markerInfo.add(new MarkerInfo(file, linenumber, details));
+ }
+ }
+ finish();
+ }
+
+ private String getDescription(List<CheckPointData> datas) {
+ count.clear();
+ for (CheckPointData data : datas) {
+ CheckPointHelper check = new CheckPointHelper(data);
+ if (count.containsKey(check)) {
+ count.get(check).increment();
+ } else {
+ count.put(check, check);
+ }
+ }
+
+ CheckPointHelper[] helper = count.values().toArray(new CheckPointHelper[count.values().size()]);
+ Arrays.sort(helper);
+ int maxNumber = 2;
+ builder.setLength(0);
+ for (int i = 0; i < helper.length && i < maxNumber; i++) {
+ builder.append(helper[i].toString());
+ if (i + 1 < Math.min(helper.length, maxNumber)) {
+ builder.append(", ");
+ }
+ if (i + 1 < helper.length && i + 1 >= maxNumber) {
+ builder.append("...");
+ }
+ }
+ return builder.toString();
+ }
+
+ private void finish() {
+
+ Set<String> fileAlreadyLookedFor = new HashSet<String>();
+ Map<String, IResource> resources = new HashMap<String, IResource>();
+
+ for (MarkerInfo marker : markerInfo) {
+ try {
+ if (!fileAlreadyLookedFor.contains(marker.getFile())) {
+ fileAlreadyLookedFor.add(marker.getFile());
+ IResource resource = AWorkspace.findWorkspaceFile(marker.getFile());
+ if (resource != null) {
+ resources.put(marker.getFile(), resource);
+ }
+ }
+
+ IResource resourceToMark = resources.get(marker.getFile());
+ if (resourceToMark != null) {
+ Map<String, Object> scriptMarkerMap = new HashMap<String, Object>();
+ scriptMarkerMap.put(IMarker.MESSAGE, marker.getMessage());
+ scriptMarkerMap.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
+ scriptMarkerMap.put(IMarker.LINE_NUMBER, marker.getLine());
+ IMarker markerToDelete = resourceToMark.createMarker("org.eclipse.osee.ote.ui.output.errorMarker");
+ markerToDelete.setAttributes(scriptMarkerMap);
+ markersToDelete.add(markerToDelete);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(MarkerPlugin.class, Level.SEVERE, "Error adding markers from outfile", ex);
+ }
+ }
+ }
+
+ public List<IMarker> getMarkers() {
+ return markersToDelete;
+ }
+
+}

Back to the top