Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-05-28 14:23:13 -0400
committerrescobar2010-05-28 14:23:13 -0400
commitbab410288e684a4f41b879c8d67842a75baafd97 (patch)
tree214ec73b46977c9d5e4958966b07051b7e48db97 /plugins/org.eclipse.osee.ote.ui.message.util
parent46f35da186b7cda6f7794374799fac8a47374282 (diff)
downloadorg.eclipse.osee-bab410288e684a4f41b879c8d67842a75baafd97.tar.gz
org.eclipse.osee-bab410288e684a4f41b879c8d67842a75baafd97.tar.xz
org.eclipse.osee-bab410288e684a4f41b879c8d67842a75baafd97.zip
Fixed compile warnings and build issues
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.message.util')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message.util/src/org/eclipse/osee/ote/ui/message/util/MessageElementSelectionDialog.java218
1 files changed, 105 insertions, 113 deletions
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
index dd50e67281..5db1fb61b6 100644
--- 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
@@ -12,7 +12,6 @@ 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;
@@ -28,122 +27,115 @@ 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 {
+ public MessageElementSelectionDialog(Shell parent, Message<?, ?, ?> msg) {
+ this(parent, msg, null);
+ }
+
+ 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 LabelProvider());
+ 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 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 dictionary.lookupMessage(msg).newInstance();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("interrupted", e);
+ } finally {
+ tracker.close();
+ }
+ }
+
+ private static final class LabelProvider implements ILabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ 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) {
+ }
+
+ };
+
+ 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);
+ }
+ }
+ }
- 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);
- }
}

Back to the top