Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.message.util')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/.classpath7
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/.project28
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/build.properties4
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ClientMessageServiceTracker.java60
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ElementFilter.java51
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/IOteMessageClientView.java23
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageElementSelectionDialog.java149
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageSelectionDialog.java105
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/internal/Activator.java42
11 files changed, 494 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/.classpath b/plugins/org.eclipse.osee.ote.ui.message.util/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/.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.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.message.util/.project b/plugins/org.eclipse.osee.ote.ui.message.util/.project
new file mode 100644
index 00000000000..01428f98d8f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ote.ui.message.util</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.message.util/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.osee.ote.ui.message.util/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..45e6a01a396
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue May 25 10:04:40 MST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.ui.message.util/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..65998362c80
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE OTE Messaging Utils
+Bundle-SymbolicName: org.eclipse.osee.ote.ui.message.util
+Bundle-Version: 0.9.5.qualifier
+Bundle-Activator: org.eclipse.osee.ote.ui.message.util.internal.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.osee.framework.logging,
+ org.eclipse.osee.ote.client.msg,
+ org.eclipse.osee.ote.message,
+ org.eclipse.osee.ote.client
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.osee.ote.ui.message.util
+Import-Package: org.eclipse.osee.framework.jdk.core.persistence
+Bundle-Vendor: Eclipse Open System Engineering Environment
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/build.properties b/plugins/org.eclipse.osee.ote.ui.message.util/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ClientMessageServiceTracker.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ClientMessageServiceTracker.java
new file mode 100644
index 00000000000..2d6aa1d31ea
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ClientMessageServiceTracker.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util;
+
+import java.util.logging.Level;
+
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.client.msg.IOteMessageService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Ken J. Aguilar
+ *
+ */
+public class ClientMessageServiceTracker extends ServiceTracker {
+
+ private final IOteMessageClientView viewer;
+
+ /**
+ * @param context
+ * @param filter
+ * @param customizer
+ */
+ public ClientMessageServiceTracker(BundleContext context, IOteMessageClientView viewer) {
+ super(context, IOteMessageService.class.getName(), null);
+ this.viewer = viewer;
+ }
+
+ @Override
+ public synchronized Object addingService(ServiceReference reference) {
+ IOteMessageService service = (IOteMessageService)super.addingService(reference);
+ try {
+ viewer.oteMessageServiceAcquired(service);
+ } catch (RuntimeException e) {
+ OseeLog.log(ClientMessageServiceTracker.class, Level.SEVERE, "exception while notifying viewer of service", e);
+ }
+ return service;
+ }
+
+ @Override
+ public synchronized void removedService(ServiceReference reference, Object service) {
+ try {
+ viewer.oteMessageServiceReleased();
+ } catch (RuntimeException e) {
+ OseeLog.log(ClientMessageServiceTracker.class, Level.SEVERE, "exception while notifying viewer of service stop", e);
+ } finally {
+ super.removedService(reference, service);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ElementFilter.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ElementFilter.java
new file mode 100644
index 00000000000..a04fe1aa085
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/ElementFilter.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.eclipse.osee.ote.message.elements.Element;
+
+/**
+ * @author Ken J. Aguilar
+ *
+ */
+public class ElementFilter {
+ private final HashSet<Class<? extends Element>> classes = new HashSet<Class<? extends Element>>();
+ private boolean headerElementsAllowed = true;
+
+ /**
+ * @param allowHeaderElements the allowHeaderElements to set
+ */
+ public void setHeaderElementsAllowed(boolean headerElementsAllowed) {
+ this.headerElementsAllowed = headerElementsAllowed;
+ }
+
+ public void addAllowableClass(Class<? extends Element> elementClass) {
+ classes.add(elementClass);
+ }
+
+ public void addAllowableClass(Class<? extends Element>... elementClasses) {
+ classes.addAll(Arrays.asList(elementClasses));
+ }
+
+ public boolean accept(Element e) {
+ return classes.contains(e.getClass());
+ }
+
+ /**
+ * @return the headerElementsAllowed
+ */
+ public boolean isHeaderElementsAllowed() {
+ return headerElementsAllowed;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/IOteMessageClientView.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/IOteMessageClientView.java
new file mode 100644
index 00000000000..6bc0fd83407
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/IOteMessageClientView.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util;
+
+import org.eclipse.osee.ote.client.msg.IOteMessageService;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * @author Ken J. Aguilar
+ *
+ */
+public interface IOteMessageClientView extends IViewPart {
+ void oteMessageServiceAcquired(IOteMessageService service);
+ void oteMessageServiceReleased();
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageElementSelectionDialog.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageElementSelectionDialog.java
new file mode 100644
index 00000000000..dd50e672815
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageElementSelectionDialog.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.osee.ote.message.ElementPath;
+import org.eclipse.osee.ote.message.Message;
+import org.eclipse.osee.ote.message.elements.Element;
+import org.eclipse.osee.ote.message.elements.RecordElement;
+import org.eclipse.osee.ote.message.elements.RecordMap;
+import org.eclipse.osee.ote.service.IMessageDictionary;
+import org.eclipse.osee.ote.service.IOteClientService;
+import org.eclipse.osee.ote.ui.message.util.internal.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+/**
+ * @author Ken J. Aguilar
+ *
+ */
+public class MessageElementSelectionDialog extends ElementListSelectionDialog {
+
+
+ private static Message getMessage(String msg) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
+ ServiceTracker tracker = new ServiceTracker(Activator.getDefault().getBundle().getBundleContext(), IOteClientService.class.getName(), null);
+ tracker.open(true);
+ try {
+ IMessageDictionary dictionary = ((IOteClientService)tracker.waitForService(1000)).getLoadedDictionary();
+ if (dictionary == null) {
+ throw new IllegalStateException("no dictionary loaded");
+ }
+ return (Message)dictionary.lookupMessage(msg).newInstance();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("interrupted", e);
+ } finally {
+ tracker.close();
+ }
+ }
+
+
+
+ private static final class LabelProvideer implements ILabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ String text;
+ Element msgElement = (Element) element;
+ return new ElementPath(msgElement.getElementPath()).toString();
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+
+ };
+
+ public MessageElementSelectionDialog(Shell parent, String msg,
+ ElementFilter filter) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalStateException{
+ this(parent, getMessage(msg), filter);
+ }
+
+ public MessageElementSelectionDialog(Shell parent, Message msg,
+ ElementFilter filter) {
+ super(parent, new LabelProvideer());
+ LinkedList<Element> topLevelElements = new LinkedList<Element>();
+ LinkedList<Element> filterElements = new LinkedList<Element>();
+ msg.getAllElements(topLevelElements);
+
+ process(filter, topLevelElements, filterElements);
+ setElements(filterElements.toArray());
+ setMessage("Select a message element. Use * as the wild card character");
+ setTitle("Message Element Selection");
+ }
+
+ private void process(ElementFilter filter, List<Element> list, List<Element> destinationList) {
+ for (Element element : list) {
+ processElement(filter, element, destinationList);
+ }
+ }
+
+ private void processElement(ElementFilter filter, Element element, List<Element> destinationList) {
+
+ if (element instanceof RecordMap) {
+ processRecordMap(filter, (RecordMap) element, destinationList);
+ } else if (element instanceof RecordElement){
+ processRecordElement(filter, (RecordElement) element, destinationList);
+ } else {
+ if (filter == null || filter.accept(element)){
+ destinationList.add(element);
+ }
+ }
+ }
+
+ private void processRecordMap(ElementFilter filter, RecordMap map, List<Element> destinationList) {
+ for (int i = 0 ; i < map.length(); i++) {
+ processRecordElement(filter, map.get(i), destinationList);
+ }
+
+ }
+ private void processRecordElement(ElementFilter filter, RecordElement element, List<Element> destinationList) {
+
+ if (element instanceof RecordMap) {
+ processRecordMap(filter, (RecordMap) element, destinationList);
+ } else {
+ for (Element childElement : element.getElementMap().values()) {
+ processElement(filter, childElement, destinationList);
+ }
+ }
+ }
+
+ public MessageElementSelectionDialog(Shell parent, Message msg) {
+ this(parent, msg, null);
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageSelectionDialog.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageSelectionDialog.java
new file mode 100644
index 00000000000..23276b048e1
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageSelectionDialog.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util;
+
+import java.util.ArrayList;
+import java.util.logging.Level;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.service.IMessageDictionary;
+import org.eclipse.osee.ote.service.IOteClientService;
+import org.eclipse.osee.ote.service.MessageSink;
+import org.eclipse.osee.ote.ui.message.util.internal.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+/**
+ * @author Ken J. Aguilar
+ *
+ */
+public class MessageSelectionDialog extends ElementListSelectionDialog {
+
+
+ /**
+ * @param parent
+ */
+ public MessageSelectionDialog(Shell parent) {
+ super(parent, new ILabelProvider() {
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ String msgName = (String) element;
+ String packageName = msgName.substring(0, msgName
+ .lastIndexOf('.'));
+ String type = packageName.substring(packageName
+ .lastIndexOf('.') + 1);
+
+ return String.format("%s [%s]", msgName.substring(msgName
+ .lastIndexOf('.') + 1), type);
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ });
+
+ ServiceTracker tracker =new ServiceTracker(Activator.getDefault().getBundle().getBundleContext(), IOteClientService.class.getName(), null);
+ tracker.open(true);
+ try {
+ IMessageDictionary dictionary = ((IOteClientService)tracker.waitForService(1000)).getLoadedDictionary();
+ final ArrayList<String> messages = new ArrayList<String>(4096);
+ dictionary.generateMessageIndex(new MessageSink() {
+
+ @Override
+ public void absorbElement(String elementName) {
+ }
+
+ @Override
+ public void absorbMessage(String messageName) {
+ messages.add(messageName);
+ }
+
+ });
+ setElements(messages.toArray());
+ } catch (Exception e) {
+ OseeLog.log(MessageSelectionDialog.class, Level.SEVERE,
+ "failed to generate message listing", e);
+ } finally {
+ tracker.close();
+ }
+ setMessage("Select a message. Use * as the wild card character");
+ setTitle("Message Selection");
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/internal/Activator.java b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/internal/Activator.java
new file mode 100644
index 00000000000..f60880598cd
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/internal/Activator.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.message.util.internal;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ * @author Ken J. Aguilar
+ */
+public class Activator extends AbstractUIPlugin {
+ public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui.message.util";
+ private static Activator plugin;
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+} \ No newline at end of file

Back to the top