Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/.classpath
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/.classpath	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/.classpath	(revision 1621)
@@ -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>
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/.project
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/.project	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/.project	(revision 1621)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.openmodelica.modelicaml.relations</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>
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/.settings/org.eclipse.jdt.core.prefs	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/.settings/org.eclipse.jdt.core.prefs	(revision 1621)
@@ -0,0 +1,7 @@
+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
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/META-INF/MANIFEST.MF
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/META-INF/MANIFEST.MF	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/META-INF/MANIFEST.MF	(revision 1621)
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ModelicaML Relations
+Bundle-SymbolicName: org.openmodelica.modelicaml.relations; singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.openmodelica.modelicaml.relations.Activator
+Bundle-Vendor: OpenModelica Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.openmodelica.modelicaml.common;bundle-version="1.0.1",
+ org.eclipse.uml2.uml;bundle-version="4.0.0",
+ org.eclipse.papyrus.editor;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="0.9.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300",
+ org.eclipse.ui.navigator;bundle-version="3.5.200",
+ org.eclipse.emf.transaction;bundle-version="1.4.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.openmodelica.modelicaml.relations.dialogs,
+ org.openmodelica.modelicaml.relations.handlers
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/build.properties
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/build.properties	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/build.properties	(revision 1621)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .,\
+               icons/,\
+               contexts.xml
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/contexts.xml
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/contexts.xml	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/contexts.xml	(revision 1621)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contexts>
+	<context id="viewer" title="Sample View">
+		<description>This is the context help for the sample view with a tree viewer. It was generated by a PDE template.</description>
+		<topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
+			<enablement>
+				<with variable="platform">
+	            	<test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
+	     		</with>
+			</enablement>
+		</topic>
+	</context>
+</contexts>
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/plugin.xml
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/plugin.xml	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/plugin.xml	(revision 1621)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            allowMultiple="true"
+            category="org.openmodelica.modelicaml.category"
+            class="org.openmodelica.modelicaml.relations.views.RelationsView"
+            icon="icons/relationships.gif"
+            id="org.openmodelica.modelicaml.relations.views.RelationsView"
+            name="Relations">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.help.contexts">
+      <contexts
+            file="contexts.xml">
+      </contexts>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            id="org.openmodelica.modelicaml.relations.commands.toolbar.findInvalidRelations"
+            name="Find Invalid Relations">
+      </command>
+   </extension>
+   <extension
+         point="org.eclipse.ui.handlers">
+      <handler
+            class="org.openmodelica.modelicaml.relations.handlers.FindInvalidRelationsToolbarHandler"
+            commandId="org.openmodelica.modelicaml.relations.commands.toolbar.findInvalidRelations">
+      </handler>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="toolbar:org.eclipse.ui.main.toolbar">
+         <toolbar
+               id="org.openmodelica.modelicaml.toolbar.relations"
+               label="ModelicaML Clean Up">
+            <separator
+                  name="org.openmodelica.modelicaml.relations.separator1"
+                  visible="true">
+            </separator>
+            <command
+                  commandId="org.openmodelica.modelicaml.relations.commands.toolbar.findInvalidRelations"
+                  icon="icons/clear.gif"
+                  label="Find Invalid Relations"
+                  style="push"
+                  tooltip="Find Invalid Relations">
+               <visibleWhen>
+                  <with
+                        variable="activeEditorId">
+                     <equals
+                           value="org.eclipse.papyrus.infra.core.papyrusEditor">
+                     </equals>
+                  </with>
+               </visibleWhen>
+            </command>
+         </toolbar>
+      </menuContribution>
+   </extension>
+
+</plugin>
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/Activator.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/Activator.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/Activator.java	(revision 1621)
@@ -0,0 +1,61 @@
+package org.openmodelica.modelicaml.relations;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.openmodelica.modelicaml.relations"; //$NON-NLS-1$
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	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;
+	}
+
+	/**
+	 * Returns an image descriptor for the image file at the given
+	 * plug-in relative path
+	 *
+	 * @param path the path
+	 * @return the image descriptor
+	 */
+	public static ImageDescriptor getImageDescriptor(String path) {
+		return imageDescriptorFromPlugin(PLUGIN_ID, path);
+	}
+}
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SearchDialog.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SearchDialog.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SearchDialog.java	(revision 1621)
@@ -0,0 +1,416 @@
+package org.openmodelica.modelicaml.relations.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.utls.ResourceManager;
+import org.openmodelica.modelicaml.relations.model.TreeObject;
+import org.openmodelica.modelicaml.relations.model.TreeParent;
+
+public class SearchDialog extends Dialog {
+	private Tree tree;
+	private Button btnSearch;
+	private Text txtKeyWords;
+	
+	private TreeViewer viewer;
+	private TreeParent root;
+	
+	private HashSet<String> keywords = new HashSet<String>();
+	private Button btnOr;
+	private Button btnAnd;
+	
+	private boolean searchInName = true;
+	private boolean searchInComments = false;
+	private boolean searchInTypeName = true;
+	private boolean searchInTypeComments = false;
+	private Button btnSearchInNames;
+	private Button btnSearchInComments;
+
+	public SearchDialog(Shell parentShell, TreeViewer viewer, TreeParent root) {
+		
+		super(parentShell);
+		setShellStyle(SWT.SHELL_TRIM);
+		
+		this.root = root;
+		this.viewer = viewer;
+	}
+
+	
+	private HashSet<TreeObject> getAllTreeItems(TreeParent treeParent){
+		HashSet<TreeObject> allTreeItems = new HashSet<TreeObject>();
+		allTreeItems.add(treeParent);
+		
+		TreeObject[] children = treeParent.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			allTreeItems.add(children[i]);
+			if (children[i] instanceof TreeParent) {
+				allTreeItems.addAll(getAllTreeItems((TreeParent)children[i]));
+			}
+		}
+		
+		return allTreeItems;
+	}
+	
+	@Override
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations","icons/find.png"));
+		newShell.setText("Search in " + root.getName());		
+	}
+	
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		
+		Composite area = (Composite) super.createDialogArea(parent);
+		Composite container = new Composite(area, SWT.NONE);
+		container.setLayout(new GridLayout(1, false));
+		container.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		Group grpKeywords = new Group(container, SWT.NONE);
+		grpKeywords.setText("Keywords search in names and comments");
+		grpKeywords.setLayout(new GridLayout(3, false));
+		GridData gd_grpKeywords = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
+		gd_grpKeywords.heightHint = 101;
+		grpKeywords.setLayoutData(gd_grpKeywords);
+		
+		txtKeyWords = new Text(grpKeywords, SWT.BORDER);
+		txtKeyWords.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				if (txtKeyWords.getText().trim().length() > 1) {
+					btnSearch.setEnabled(true);
+				}
+				else {
+					btnSearch.setEnabled(false);
+				}
+			}
+		});
+		txtKeyWords.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+		txtKeyWords.setFocus();
+		
+		btnSearch = new Button(grpKeywords, SWT.NONE);
+		btnSearch.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				String[] keyWordsTextSplitted = txtKeyWords.getText().trim().split(" ");
+				
+				keywords.clear();
+				for (String string : keyWordsTextSplitted) {
+					keywords.add(string);
+				}
+
+				if (keywords.size() > 0) {
+					// update the tree
+					tree.removeAll();
+					
+					List<TreeObject> foundItems = getSortedByName(getMatchedItems()); 
+					if (foundItems != null) {
+						for (TreeObject treeObject : foundItems) {
+							
+							TreeItem treeItem = new TreeItem(tree, SWT.NONE);
+							treeItem.setData(treeObject);
+							treeItem.setText(treeObject.getName());
+							
+							Element umlElement = treeObject.getUmlElement();
+							if (umlElement instanceof Model) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Model.gif"));
+							}
+							else if ( umlElement instanceof Dependency ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Dependency.gif"));
+							}
+							else if ( umlElement instanceof Generalization) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Generalization.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/requirement.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_CalculationModel) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/calculationModel.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Model) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/model.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Block) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/block.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Record) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/record.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Connector) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/connector.gif"));
+							}
+							else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Function) != null ) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/FunctionBehavior.gif"));
+							}
+							else if ( umlElement instanceof Property) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Property.gif"));
+							}
+							else  if ( umlElement instanceof Class) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Class.gif"));
+							}
+							else  if ( umlElement instanceof PrimitiveType) {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/PrimitiveType.gif"));
+							}
+							else {
+								treeItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/unknown_obj.gif"));
+							}
+						}
+					}
+				}
+			}
+		});
+		btnSearch.setText("Search");
+		
+		btnOr = new Button(grpKeywords, SWT.RADIO);
+		btnOr.setSelection(true);
+		btnOr.setText("OR");
+		
+		btnAnd = new Button(grpKeywords, SWT.RADIO);
+		btnAnd.setText("AND");
+		new Label(grpKeywords, SWT.NONE);
+		
+		btnSearchInNames = new Button(grpKeywords, SWT.CHECK);
+		btnSearchInNames.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				if (btnSearchInNames.getSelection()) {
+					searchInName = true;
+					searchInTypeName = true;
+				}
+				else {
+					searchInName = false;
+					searchInTypeName = false;
+				}
+			}
+		});
+		btnSearchInNames.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+		btnSearchInNames.setText("Search in names");
+		btnSearchInNames.setSelection(searchInName);
+		
+		
+		new Label(grpKeywords, SWT.NONE);
+		
+		btnSearchInComments = new Button(grpKeywords, SWT.CHECK);
+		btnSearchInComments.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+		btnSearchInComments.setText("Search in comments");
+		btnSearchInComments.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				if (btnSearchInComments.getSelection()) {
+					searchInComments = true;
+					searchInTypeComments = true;
+				}
+				else {
+					searchInComments = false;
+					searchInTypeComments = false;
+				}
+			}
+		});
+		btnSearchInComments.setSelection(searchInComments);
+		
+		
+		new Label(grpKeywords, SWT.NONE);
+		new Label(grpKeywords, SWT.NONE);
+		new Label(grpKeywords, SWT.NONE);
+		new Label(grpKeywords, SWT.NONE);
+		
+		Group grpFoundItems = new Group(container, SWT.NONE);
+		grpFoundItems.setText("Found items");
+		grpFoundItems.setLayout(new GridLayout(1, false));
+		grpFoundItems.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+		
+		tree = new Tree(grpFoundItems, SWT.BORDER | SWT.V_SCROLL);
+		tree.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mouseDoubleClick(MouseEvent e) {
+				TreeItem[] selectedItems = tree.getSelection();
+				for (TreeItem selectedItem : selectedItems) {
+//					HashSet<Object> objects = treeBuilder.findTreeItems( ((TreeObject) selectedItem.getData()).getDotPath(), root, new HashSet<Object>());
+					List<Object> newSelectionItems = new ArrayList<Object>();
+					newSelectionItems.add(selectedItem.getData());
+					viewer.setSelection(new StructuredSelection(newSelectionItems), true);
+				}
+			}
+		});
+		tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+		return area;
+	}
+
+	
+	
+	public static List<TreeObject> getSortedByName(HashSet<TreeObject> set){
+		if (set == null) { return null; }
+
+		List<TreeObject> listSorted = new ArrayList<TreeObject>(set);
+		Comparator<TreeObject> c = new Comparator<TreeObject>() {
+			@Override
+			public int compare(TreeObject arg0, TreeObject arg1) {
+				return arg0.getName().compareToIgnoreCase(arg1.getName());
+			}
+		};
+		Collections.sort(listSorted, c);
+		
+		return listSorted;
+	}
+	
+	
+	private HashSet<TreeObject> getMatchedItems(){
+		HashSet<TreeObject> foundItems = new HashSet<TreeObject>();
+		
+		for (TreeObject treeObject: getAllTreeItems(root)) {
+			String string = "";
+			// search in tree object name, uml element qualified name, type qualified name, all comments 
+			
+			if (isSearchInName()) {
+				string += treeObject.getName();
+			}
+			
+			if (treeObject.getUmlElement() != null ){
+				
+				if (isSearchInName()) {
+					string += ModelicaMLServices.getQualifiedName(treeObject.getUmlElement());
+				}
+				if (isSearchInComments()) {
+					string += treeObject.getUmlElement().getOwnedComments().toString();							
+				}
+
+				if (treeObject.getUmlElement() instanceof Property) {
+					Type type = ((Property)treeObject.getUmlElement()).getType();
+					if (isSearchInTypeName()) {
+						string +=  ModelicaMLServices.getQualifiedName(type);
+					}
+					if (isSearchInTypeComments()) {
+						string += type.getOwnedComments().toString();
+					}
+				}
+			}
+			
+			// OR search 
+			if (btnOr.getSelection()) {
+				for (String keyword : keywords) {
+					// collect matches
+					if (string.toLowerCase().contains(keyword.toLowerCase())) {
+						foundItems.add(treeObject);
+					}
+				}
+			}
+			// AND search
+			else if (btnAnd.getSelection()) {
+				boolean matchedAlways = true;
+//				boolean matched = false;
+				for (String keyword : keywords) {
+					// collect matches
+					if (string.toLowerCase().contains(keyword.toLowerCase())) {
+//						matched = true;
+					}
+					else {
+//						matched = false;
+						matchedAlways = false;
+					}
+				}
+				if (matchedAlways) {
+					foundItems.add(treeObject);
+				}
+			} 	
+		}
+		
+		return foundItems;
+	}
+	
+	/**
+	 * Create contents of the button bar.
+	 * 
+	 * @param parent
+	 */
+	@Override
+	protected void createButtonsForButtonBar(Composite parent) {
+//		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+//				true);
+//		createButton(parent, IDialogConstants.CANCEL_ID,
+//				IDialogConstants.CANCEL_LABEL, false);
+	}
+
+	/**
+	 * Return the initial size of the dialog.
+	 */
+	@Override
+	protected Point getInitialSize() {
+		return new Point(494, 413);
+	}
+
+
+	public boolean isSearchInComments() {
+		return searchInComments;
+	}
+
+
+	public void setSearchInComments(boolean searchInComments) {
+		this.searchInComments = searchInComments;
+	}
+
+
+	public boolean isSearchInName() {
+		return searchInName;
+	}
+
+
+	public void setSearchInName(boolean searchInName) {
+		this.searchInName = searchInName;
+	}
+
+
+	public boolean isSearchInTypeName() {
+		return searchInTypeName;
+	}
+
+
+	public void setSearchInTypeName(boolean searchInTypeName) {
+		this.searchInTypeName = searchInTypeName;
+	}
+
+
+	public boolean isSearchInTypeComments() {
+		return searchInTypeComments;
+	}
+
+
+	public void setSearchInTypeComments(boolean searchInTypeComments) {
+		this.searchInTypeComments = searchInTypeComments;
+	}
+}
+
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SelectInvalidRelationsToDeleteDialog.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SelectInvalidRelationsToDeleteDialog.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/dialogs/SelectInvalidRelationsToDeleteDialog.java	(revision 1621)
@@ -0,0 +1,318 @@
+package org.openmodelica.modelicaml.relations.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.dialogs.DialogMessage;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.services.EditorServices;
+import org.openmodelica.modelicaml.common.utls.ResourceManager;
+import org.openmodelica.modelicaml.relations.model.TreeObject;
+
+public class SelectInvalidRelationsToDeleteDialog extends Dialog {
+	private Tree tree;
+	private HashSet<Element> invalidRelations;
+	private Button btnDeleteAll;
+	private HashSet<TreeItem> allTreeItems = new HashSet<TreeItem>();
+	private final ImageDescriptor errorImageDescriptor = ResourceManager.getPluginImageDescriptor("org.openmodelica.modelicaml.common", "icons/overlay/error_ovr.gif");
+
+
+	public SelectInvalidRelationsToDeleteDialog(Shell parentShell, HashSet<Element> invalidRelations) {
+		
+		super(parentShell);
+		setShellStyle(SWT.SHELL_TRIM);
+		this.invalidRelations = invalidRelations;
+
+	}
+
+	
+	@Override
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations","icons/find.png"));
+		newShell.setText("Invalid Relations Search (" + invalidRelations.size() + " found)");			
+	}
+	
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		
+		Composite area = (Composite) super.createDialogArea(parent);
+		Composite container = new Composite(area, SWT.NONE);
+		container.setLayout(new GridLayout(1, false));
+		container.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		Group grpFoundItems = new Group(container, SWT.NONE);
+		grpFoundItems.setText("Found items");
+		grpFoundItems.setLayout(new GridLayout(1, false));
+		grpFoundItems.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+		
+		tree = new Tree(grpFoundItems, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL);
+		tree.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				btnDeleteAll.setEnabled(true);
+			}
+		});
+		tree.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mouseDoubleClick(MouseEvent e) {
+				TreeItem[] selectedItems = tree.getSelection();
+				for (TreeItem selectedItem : selectedItems) {
+					EditorServices.locateInModelExplorer(selectedItem.getData(), false);
+				}
+			}
+		});
+		tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+		createTree(tree);
+		
+		
+		Composite composite = new Composite(grpFoundItems, SWT.NONE);
+		composite.setLayout(new GridLayout(5, false));
+		composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+		
+		Button btnSelectAll = new Button(composite, SWT.NONE);
+		btnSelectAll.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				for (TreeItem treeItem : allTreeItems) {
+					treeItem.setChecked(true);
+				}
+			}
+		});
+		btnSelectAll.setText("Select all");
+		
+		final Button btnDeselectAll = new Button(composite, SWT.NONE);
+		btnDeselectAll.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				for (TreeItem treeItem : allTreeItems) {
+					treeItem.setChecked(false);
+				}
+			}
+		});
+		btnDeselectAll.setText("Deselect all");
+		
+		Button btnLocate = new Button(composite, SWT.NONE);
+		btnLocate.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				TreeItem[] selectedItems = tree.getSelection();
+				for (TreeItem selectedItem : selectedItems) {
+					EditorServices.locateInModelExplorer(selectedItem.getData(), false);
+				}
+			}
+		});
+		btnLocate.setText("Locate");
+		
+		Composite composite_1 = new Composite(composite, SWT.NONE);
+		GridData gd_composite_1 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
+		gd_composite_1.heightHint = 9;
+		composite_1.setLayoutData(gd_composite_1);
+		
+		btnDeleteAll = new Button(composite, SWT.NONE);
+		btnDeleteAll.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+		btnDeleteAll.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+//				TreeItem[] selectedItems = tree.getSelection();
+
+				HashSet<Element> deletedRelations = new HashSet<Element>();
+				for (TreeItem treeItem : allTreeItems) {
+					if (treeItem.getChecked()) {
+						Element relation = (Element) treeItem.getData();
+						
+						// do not delete in installed Libraries
+						if (relation.getModel() != null && relation.getModel().getAppliedStereotype(Constants.stereotypeQName_InstalledLibrary) != null) {
+							// skip
+						}
+						else {
+							// delete element
+							deletedRelations.add(deleteRelation(relation));
+
+							invalidRelations.remove(relation);
+						}
+					}
+				}
+
+				// update the tree
+				tree.removeAll();
+				createTree(tree);
+				
+				// disable delete button until the next selection
+				btnDeleteAll.setEnabled(false);
+				
+				String message = "";
+				for (Element deletedRelation : deletedRelations) {
+					if (deletedRelation instanceof Generalization) {
+						message += "  - Extends relation: " + deletedRelation.toString();
+					}
+					else if (deletedRelation instanceof Dependency) {
+//						message += "Dependency: " + ModelicaMLServices.getQualifiedName(deletedRelation) + " in (" + ModelicaMLServices.getQualifiedName(deletedRelation.getOwner()) + ")";
+						message += "  - Dependency: '" + ModelicaMLServices.getQualifiedName(deletedRelation) + "'";
+
+					}
+					else {
+//						message += "Element: " + ModelicaMLServices.getQualifiedName(deletedRelation)+ " in (" + ModelicaMLServices.getQualifiedName(deletedRelation.getOwner()) + ")";
+						message += "  - Element: '" + ModelicaMLServices.getQualifiedName(deletedRelation) + "'";
+					}
+				}
+				
+				DialogMessage resultsDialog = new DialogMessage(getShell(), "Delete Relations Results", "The follwoing relations were deleted:", message, false);
+				resultsDialog.open();
+				
+			}
+		});
+		btnDeleteAll.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/etool16/delete.gif"));
+		btnDeleteAll.setText("Delete selected");
+
+		return area;
+	}
+
+	
+	public Image decorateError(Image image) {
+		return new DecorationOverlayIcon(image, errorImageDescriptor, IDecoration.BOTTOM_RIGHT).createImage();
+	}
+	
+	
+	public void createTree(Tree tree){
+		
+		allTreeItems.clear();
+		
+		List<Element> relations = ModelicaMLServices.getSortedByName(invalidRelations); 
+		if (relations != null) {
+			for (Element relation : relations) {
+				
+				TreeItem treeItem = new TreeItem(tree, SWT.CHECK);
+				treeItem.setData(relation);
+				allTreeItems.add(treeItem);
+				
+				if (relation instanceof Generalization) {
+					treeItem.setText("in: " + ModelicaMLServices.getQualifiedName(relation.getOwner()));
+				}
+				else {
+					treeItem.setText(ModelicaMLServices.getName(relation) + "          (in "+ModelicaMLServices.getQualifiedName(relation.getOwner())+")");	
+				}
+				if ( relation instanceof Dependency ) {
+					treeItem.setImage(decorateError(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Dependency.gif")));
+				}
+				else if ( relation instanceof Generalization) {
+					treeItem.setImage(decorateError(ResourceManager.getPluginImage("org.openmodelica.modelicaml.relations", "icons/Generalization.gif")));
+				}
+				
+				if (relation.getModel() != null && relation.getModel().getAppliedStereotype(Constants.stereotypeQName_InstalledLibrary) != null) {
+					treeItem.setGrayed(true);
+					treeItem.setText("In Library: " + treeItem.getText());
+				}
+			}
+		}
+	}
+	
+	public static List<TreeObject> getSortedByName(HashSet<TreeObject> set){
+		if (set == null) { return null; }
+
+		List<TreeObject> listSorted = new ArrayList<TreeObject>(set);
+		Comparator<TreeObject> c = new Comparator<TreeObject>() {
+			@Override
+			public int compare(TreeObject arg0, TreeObject arg1) {
+				return arg0.getName().compareToIgnoreCase(arg1.getName());
+			}
+		};
+		Collections.sort(listSorted, c);
+		
+		return listSorted;
+	}
+	
+	
+	private Element deleteRelation(final Element relation){
+
+		TransactionalEditingDomain editingDomain = EditorServices.getPapyrusEditingDomain(); 
+
+		CompoundCommand cc = new CompoundCommand("Create a ModelicaML Proxy Class");
+		Command command = new RecordingCommand(editingDomain) {
+			
+			Element deletedElement = null;
+			
+			@Override
+			public Collection<?> getResult() {
+				List<Element> collection = new ArrayList<Element>();
+				if (deletedElement != null) {
+					collection.add(deletedElement);
+				}
+				return collection;
+			};
+			
+			@Override
+			protected void doExecute() {
+				deletedElement = relation; 
+				relation.destroy();
+			}
+		};
+		
+		cc.append(command);
+		// Execute command
+		editingDomain.getCommandStack().execute(cc);
+
+		Collection<?> result = command.getResult();
+		for (Object object : result) {
+			if (object instanceof Element) {
+				return (Element)object;
+			}
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * Create contents of the button bar.
+	 * 
+	 * @param parent
+	 */
+	@Override
+	protected void createButtonsForButtonBar(Composite parent) {
+//		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+//				true);
+//		createButton(parent, IDialogConstants.CANCEL_ID,
+//				IDialogConstants.CANCEL_LABEL, false);
+	}
+
+	/**
+	 * Return the initial size of the dialog.
+	 */
+	@Override
+	protected Point getInitialSize() {
+		return new Point(494, 413);
+	}
+}
+
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/display/ViewLabelProviderStyledCell.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/display/ViewLabelProviderStyledCell.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/display/ViewLabelProviderStyledCell.java	(revision 1621)
@@ -0,0 +1,294 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR 
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL). 
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. 
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or  
+ * http://www.openmodelica.org, and in the OpenModelica distribution. 
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ * Main author: Wladimir Schamai, EADS Innovation Works / Linköping University, 2009-now
+ *
+ * Contributors: 
+ *   Uwe Pohlmann, University of Paderborn 2009-2010, contribution to the Modelica code generation for state machine behavior, contribution to Papyrus GUI adoptations
+ *   Parham Vasaiely, EADS Innovation Works / Hamburg University of Applied Sciences 2009-2011, implementation of simulation plugins
+ */
+package org.openmodelica.modelicaml.relations.display;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Property;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.utls.ResourceManager;
+import org.openmodelica.modelicaml.common.utls.SWTResourceManager;
+import org.openmodelica.modelicaml.relations.Activator;
+import org.openmodelica.modelicaml.relations.model.TreeObject;
+import org.openmodelica.modelicaml.relations.model.TreeParent;
+
+
+public class ViewLabelProviderStyledCell extends StyledCellLabelProvider {
+	
+	private String projectName = "";
+	
+	private boolean decorateItem = true;
+	
+//	private final ImageDescriptor warningImageDescriptor = ResourceManager.getPluginImageDescriptor("org.openmodelica.modelicaml.common", "icons/overlay/warning_ovr.gif");
+	private final ImageDescriptor errorImageDescriptor = ResourceManager.getPluginImageDescriptor("org.openmodelica.modelicaml.common", "icons/overlay/error_ovr.gif");
+//	private final ImageDescriptor okStateImageDescriptor = ResourceManager.getImageDescriptor(Activator.class, "/icons/success_ovr.gif");
+//	private final ImageDescriptor questionStateImageDescriptor = ResourceManager.getImageDescriptor(Activator.class, "/icons/question_ov.gif");
+//	private final ImageDescriptor infoImageDescriptor = ResourceManager.getPluginImageDescriptor("org.openmodelica.modelicaml.common", "icons/overlay/warning_ovr.gif");
+	
+	DecorationOverlayIcon overlayIcon = null;
+	Object overlayIconImage = null;
+	
+	// styler
+	Styler stylerRed = new Styler() {
+		@Override
+		public void applyStyles(TextStyle textStyle) {
+			textStyle.foreground = new Color(null, new RGB(234, 0, 0)); // darker RED
+		}
+	};
+	Styler stylerGrey = new Styler() {
+		@Override
+		public void applyStyles(TextStyle textStyle) {
+			textStyle.foreground = new Color(null, new RGB(112, 138, 144)); // Slate Gray
+		}
+	};
+	
+	// used to decorate the tree item string 
+	private StyledString styledString;
+
+	
+	@Override
+	public void update(ViewerCell cell) {
+		String treeItemText = "";
+		Object obj = cell.getElement();
+		
+		TreeObject item = (TreeObject)obj;
+		
+		// name string 
+		String name = item.getName() + " ";
+		
+
+		Element umlelElement = item.getUmlElement();
+
+//		// special case: requirement		
+//		if (umlelElement!= null && umlelElement.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
+//			name = (String) umlelElement.getValue(umlelElement.getAppliedStereotype(Constants.stereotypeQName_Requirement), Constants.propertyName_id) + " - " + ((NamedElement) umlelElement).getName() + " ";
+//		}
+		
+		String ownerQName = "";
+		
+		if (!(item instanceof TreeParent && ((TreeParent)item).isRoot() )) {
+			Element element = umlelElement;
+			if (umlelElement == null) {
+				element = item.getDependencyElement();
+			}
+			if (element == null) {
+				element = item.getGeneralzationElement();
+			}
+			
+			if (element != null && element.getOwner() != null) {
+				ownerQName = "  (" + ModelicaMLServices.getQualifiedName(element.getOwner()) + ") ";
+			}
+		}
+		
+		// number of children string 
+		String numberOfChildren = "";
+		if (obj instanceof TreeParent) {
+			numberOfChildren = " (" + ((TreeParent)obj).getChildren().length + ")";
+		}
+		
+		//  construct the label
+		styledString = new StyledString();
+		styledString.append(name);
+		treeItemText = treeItemText + name;
+
+		// append number of children
+		styledString.append(numberOfChildren, stylerGrey);
+		treeItemText = treeItemText + numberOfChildren;
+		
+		// append owner qualified name
+		styledString.append(ownerQName, stylerGrey);
+		treeItemText = treeItemText + ownerQName;
+
+		
+		// set text and styles
+		if (decorateItem) {
+			cell.setText( styledString.toString() );
+			cell.setStyleRanges(styledString.getStyleRanges());
+		}
+		else {
+			cell.setText(treeItemText);
+		}
+		
+		// set image
+		if ( obj instanceof TreeObject  ){
+			TreeObject treeObject = (TreeObject)obj; 
+			
+			setImage(treeObject);
+			cell.setImage((Image) overlayIconImage);
+		}
+
+		super.update(cell);
+	}
+	
+	
+	// Image handling ********************************************************************
+	
+	class OverLayImageDescriptor extends ImageDescriptor{
+		private Image image;
+		public OverLayImageDescriptor(Image image){
+			this.image = image;
+		}
+		@Override
+		public ImageData getImageData() {
+			return image.getImageData();
+		}
+	}
+	
+	private void setImage(TreeObject treeObject){
+		
+		Element umlElement = treeObject.getUmlElement();
+
+		// The top-level first info nodes
+		if (treeObject instanceof TreeParent && ((TreeParent)treeObject).isDependeciesNode() && ((TreeParent)treeObject).getDependencyElement() == null) {
+			overlayIconImage = decorateImage( treeObject , "/icons/Dependency.gif", null );
+		}
+		else if (treeObject instanceof TreeParent && ((TreeParent)treeObject).isInheritanceNode() && ((TreeParent)treeObject).getGeneralzationElement() == null) {
+			overlayIconImage = decorateImage( treeObject , "/icons/Generalization.gif", null );
+		}
+		
+		// nodes with uml elements
+		else if (umlElement != null) {
+			
+			if (umlElement instanceof Model) {
+				overlayIconImage = decorateImage( treeObject , "/icons/Model.gif", null ); 
+			}
+			else if ( umlElement instanceof Dependency ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/Dependency.gif", null ); 
+			}
+			else if ( umlElement instanceof Generalization) {
+				overlayIconImage = decorateImage( treeObject , "/icons/Generalization.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/requirement.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_CalculationModel) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/calculationModel.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Model) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/modelicaModel.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Block) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/block.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Record) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/record.gif", null ); 
+			}
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Connector) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/connector.gif", null ); 
+			}
+
+			else if ( umlElement.getAppliedStereotype(Constants.stereotypeQName_Function) != null ) {
+				overlayIconImage = decorateImage( treeObject , "/icons/FunctionBehavior.gif", null ); 
+			}
+			else if ( umlElement instanceof Property) {
+				overlayIconImage = decorateImage( treeObject , "/icons/Property.gif", null ); 
+			}
+			else  if ( umlElement instanceof PrimitiveType) {
+				overlayIconImage = decorateImage( treeObject , "/icons/PrimitiveType.gif", null ); 
+			}
+			else {
+				overlayIconImage = decorateImage( treeObject , "/icons/Class.gif", null );
+			}
+		}
+		else {
+			overlayIconImage = decorateImage( treeObject , "/icons/unknown_obj.gif", null );
+		}
+	}
+	
+	private Image decorateImage(Object element, String imagePath, Image image) {
+
+		if (element instanceof TreeParent) {
+			Image imageToBeUsed = null;
+			if (image != null) {
+				imageToBeUsed = image;
+			}
+			else {
+				imageToBeUsed = SWTResourceManager.getImage(Activator.class, imagePath);	
+			}
+			
+			if ( imageToBeUsed != null) {
+
+				if (decorateItem) { 
+					
+					if ( ((TreeObject) element).isHasErrors() ) {
+						overlayIcon = new DecorationOverlayIcon(imageToBeUsed, errorImageDescriptor, IDecoration.BOTTOM_RIGHT);
+						return overlayIcon.createImage();
+					}
+				}
+			}
+		}
+		
+		if (image != null) {
+			return image;
+		}
+		
+		return SWTResourceManager.getImage(Activator.class, imagePath);
+	}
+
+
+	public void setDecorateItem(boolean decorateItem) {
+		this.decorateItem = decorateItem;
+	}
+
+
+	public boolean isDecorateItem() {
+		return decorateItem;
+	}
+
+	public void setProjectName(String projectName) {
+		this.projectName = projectName;
+	}
+
+	public String getProjectName() {
+		return projectName;
+	}
+	
+}
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/handlers/FindInvalidRelationsToolbarHandler.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/handlers/FindInvalidRelationsToolbarHandler.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/handlers/FindInvalidRelationsToolbarHandler.java	(revision 1621)
@@ -0,0 +1,143 @@
+package org.openmodelica.modelicaml.relations.handlers;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlUtils;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.services.RelationsCollector;
+import org.openmodelica.modelicaml.relations.dialogs.SelectInvalidRelationsToDeleteDialog;
+
+
+public class FindInvalidRelationsToolbarHandler extends AbstractHandler{
+	
+	private RelationsCollector collector;	
+	 
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+
+		// get UML model data
+		UmlModel umlModel = UmlUtils.getUmlModel();
+
+		if (umlModel != null) {
+			try {
+				final EObject root = umlModel.lookupRoot();
+				if (root instanceof Element) {
+					
+					ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(ModelicaMLServices.getShell());
+					
+					try {
+						progressMonitor.run(false, true, new IRunnableWithProgress() {
+							
+							@Override
+							public void run(IProgressMonitor monitor) throws InvocationTargetException,
+									InterruptedException {
+
+								monitor.beginTask("Collecting ModelicaML Relations Data ...", 100);
+								
+								// collect data
+								collector = new RelationsCollector();
+								collector.collectElementsFromModel(root);
+							}
+						});
+					} catch (InvocationTargetException e) {
+						MessageDialog.openError(ModelicaMLServices.getShell(), "ModelicaML Relations Data Collection Error", "Could not invoce the data collection for ModelicaML Relations view. ");
+					} catch (InterruptedException e) {
+						MessageDialog.openInformation(ModelicaMLServices.getShell(), "ModelicaML Relations Data Collection", "Data collection was interrupted.");		}
+
+				
+					if (collector != null) {
+						HashSet<Element> invalidRelations = analyze(collector);
+						if (invalidRelations.size() > 0) {
+							
+							// open dialog
+							SelectInvalidRelationsToDeleteDialog dialog = new SelectInvalidRelationsToDeleteDialog(ModelicaMLServices.getShell(), invalidRelations);
+							dialog.open();
+						}
+					}
+				}
+			} catch (NotFoundException e) {
+				MessageDialog.openError(ModelicaMLServices.getShell(), "ModelicaML Model Access", "Could not access the ModelicaML model. Please open it in editor.");
+			}
+		}
+		else {
+			MessageDialog.openError(ModelicaMLServices.getShell(), "ModelicaML Model Access", "Could not access the ModelicaML model. Please open it in editor.");
+		}
+		
+		return null;
+	}
+
+	
+	private HashSet<Element> analyze(RelationsCollector collector){
+		
+		HashSet<Element> invalidRelations = new HashSet<Element>();
+		for (Element relation : collector.getElements()) {
+			Element source = getSource(relation);
+			Element target = getTarget(relation);
+			
+			if (source == null || target == null) {
+				invalidRelations.add(relation);
+			}
+		}
+		
+		return invalidRelations;
+		
+	}
+	
+	
+	private Element getSource(Element relation){
+		if (relation instanceof Dependency) {
+			if (((Dependency)relation).getClients().size() > 0 ) {
+				// NOTE: we always take the first because we do not use Dependency Sets in ModelicaML
+				return ((Dependency)relation).getClients().get(0);
+			}
+		}
+		else if (relation instanceof Generalization) {
+			if (((Generalization)relation).getSources().size() > 0 ) {
+				return ((Generalization)relation).getSources().get(0);
+			}
+		}
+		return null;
+	}
+	
+	private Element getTarget(Element relation){
+		if (relation instanceof Dependency) {
+			if (((Dependency)relation).getTargets().size() > 0 ) {
+				// NOTE: we take the first
+				return ((Dependency)relation).getTargets().get(0);
+			}
+		}
+		else if (relation instanceof Generalization) {
+			if (((Generalization)relation).getTargets().size() > 0 ) {
+				// NOTE: we take the first
+				return ((Generalization)relation).getTargets().get(0);
+			}
+		}
+		return null;
+	}
+	
+//	@Override
+//	public boolean isEnabled() {
+//		return true;
+//	}
+//	
+//	@Override
+//	public boolean isHandled() {
+//		return true;
+//	}
+	
+}
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeBuilder.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeBuilder.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeBuilder.java	(revision 1621)
@@ -0,0 +1,643 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR 
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL). 
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. 
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or  
+ * http://www.openmodelica.org, and in the OpenModelica distribution. 
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ * Main author: Wladimir Schamai, EADS Innovation Works / Linköping University, 2009-now
+ *
+ * Contributors: 
+ *   Uwe Pohlmann, University of Paderborn 2009-2010, contribution to the Modelica code generation for state machine behavior, contribution to Papyrus GUI adoptations
+ *   Parham Vasaiely, EADS Innovation Works / Hamburg University of Applied Sciences 2009-2011, implementation of simulation plugins
+ */
+package org.openmodelica.modelicaml.relations.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlUtils;
+import org.eclipse.papyrus.infra.core.utils.BusinessModelResolver;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.services.RelationsCollector;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+
+
+public class TreeBuilder {
+
+	private HashSet<TreeObject> treeItems = new HashSet<TreeObject>(); // created tree clients
+
+	private Element rootPackage;
+
+//	private NamedElement selectedElement;
+//	private Element targetPackage;
+//	private Element requirementsPackage; 
+//	private Element scenariosPackage; 
+//	private Element valueMediatorsPackage;
+
+	private TreeParent useToVerifyTreeRoot;
+	private TreeParent doNotUseToVerifyTreeRoot;
+	private TreeParent requiresTreeRoot;
+	private TreeParent requiredForTreeRoot;
+	
+	private TreeParent importsTreeRoot;
+	private TreeParent extendsTreeRoot;
+	
+	private TreeParent redeclareTreeRoot;
+	private TreeParent constrainedByTreeRoot;
+	private TreeParent partialDerivativeOfFunctionTreeRoot;
+	
+	private final int DECORATION_ERROR = 0;
+//	private final int DECORATION_WARNING = 1;
+	
+	
+	private UmlModel umlModel;
+	
+	private RelationsCollector collector;
+	
+	public final String NODE_TITLE_USE_TO_VERIFY = "Use to verify relations";
+	public final String NODE_TITLE_DO_NOT_USE_TO_VERIFY = "Do not use to verify relations";
+	public final String NODE_TITLE_REQUIRES = "Additional models (requires) relations";
+	public final String NODE_TITLE_REQUIRED_FOR = "Additional models (required for) relations";
+	public final String NODE_TITLE_IMPORT = "Import relations";
+	public final String NODE_TITLE_INHERITANCE = "Extend relations";
+	public final String NODE_TITLE_REDECLARE = "Redeclare relations";
+	public final String NODE_TITLE_CONSTRAINEDBY = "Constrained by relations";
+	public final String NODE_TITLE_PARTIAL_DERIVATIVE = "Partial Derivative of functions relations";
+	
+	public final String ITEM_NAME_POSTFIX_USE_TO_VERIFY = " (can be used to verify ...)";
+	public final String ITEM_NAME_POSTFIX_DO_NOT_USE_TO_VERIFY = " (should not be used to verify ...)";
+	public final String ITEM_NAME_POSTFIX_REQUIRES = " (requires ...)";
+	public final String ITEM_NAME_POSTFIX_REQUIRED_FOR = " (is required for ...)";
+	public final String ITEM_NAME_POSTFIX_IMPORT = " (imports ...)";
+	public final String ITEM_NAME_POSTFIX_INHERITANCE = " (extends ...)";
+	public final String ITEM_NAME_POSTFIX_REDECLARE =  " (redeclares ...)";
+	public final String ITEM_NAME_POSTFIX_CONSTRAINEDBY = " ( is constrained by ...)";
+	public final String ITEM_NAME_POSTFIX_PARTIAL_DERIVATIVE = " (is partial derivative of function ...";
+
+	private TreeParent treeRoot;
+	
+	
+	public void initialize(){
+		
+		// get the uml model that is open in Papyrus.
+		umlModel = UmlUtils.getUmlModel();
+		
+		if (umlModel != null ) {
+			try {
+				
+				Element root = (Element) umlModel.lookupRoot();
+				
+				setRootPackage(root);
+				
+//				targetPackage = root;
+//				requirementsPackage = root;
+//				scenariosPackage = root;
+//				valueMediatorsPackage = root;
+				
+			} catch (NotFoundException e) {
+				e.printStackTrace();
+				MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
+						"Packages Selection", 
+						"Cannot access the root model in editor. Please open die model in editor and try it again.");
+			}
+		}
+		
+		if (getRootPackage() != null) {
+			
+			collectData();
+			
+			// create a tree root in order to show the UML::Model name
+			treeRoot = new TreeParent("Relations found in " + ModelicaMLServices.getName(rootPackage));
+			treeRoot.setUmlElement(rootPackage);
+			treeRoot.setRoot(true);
+			
+				
+			useToVerifyTreeRoot = new TreeParent(NODE_TITLE_USE_TO_VERIFY);
+			useToVerifyTreeRoot.setDependeciesNode(true);
+			treeItems.add(useToVerifyTreeRoot);
+			
+			// build tree 
+			createRelationsTree(useToVerifyTreeRoot, getCollector().getUseToVerifyDependencies(), ITEM_NAME_POSTFIX_USE_TO_VERIFY );
+
+			
+			doNotUseToVerifyTreeRoot = new TreeParent(NODE_TITLE_DO_NOT_USE_TO_VERIFY);
+			doNotUseToVerifyTreeRoot.setDependeciesNode(true);
+			treeItems.add(doNotUseToVerifyTreeRoot);
+			
+			// build tree 
+			createRelationsTree(doNotUseToVerifyTreeRoot, getCollector().getDoNotUseToVerifyDependencies(), ITEM_NAME_POSTFIX_DO_NOT_USE_TO_VERIFY );
+
+			
+			requiresTreeRoot= new TreeParent(NODE_TITLE_REQUIRES);
+			requiresTreeRoot.setDependeciesNode(true);
+			treeItems.add(requiresTreeRoot);
+			
+			// build tree 
+			createRelationsTree(requiresTreeRoot, getCollector().getRequiresDependencies(), ITEM_NAME_POSTFIX_REQUIRES );
+
+			
+			requiredForTreeRoot = new TreeParent(NODE_TITLE_REQUIRED_FOR);
+			requiredForTreeRoot.setDependeciesNode(true);
+			treeItems.add(requiredForTreeRoot);
+			
+			// build tree 
+			createRelationsTree(requiredForTreeRoot, getCollector().getRequiredForDependencies(), ITEM_NAME_POSTFIX_REQUIRED_FOR );
+			
+			
+			importsTreeRoot = new TreeParent(NODE_TITLE_IMPORT);
+			importsTreeRoot.setDependeciesNode(true);
+			treeItems.add(importsTreeRoot);
+			
+			// build tree 
+			createRelationsTree(importsTreeRoot, getCollector().getImportDependencies(), ITEM_NAME_POSTFIX_IMPORT);
+			
+
+			extendsTreeRoot = new TreeParent(NODE_TITLE_INHERITANCE);
+			extendsTreeRoot.setInheritanceNode(true);
+			treeItems.add(extendsTreeRoot);
+			
+			// build tree 
+			createRelationsTree(extendsTreeRoot, getCollector().getInheritanceRelations(), ITEM_NAME_POSTFIX_INHERITANCE);
+			
+			
+			redeclareTreeRoot = new TreeParent(NODE_TITLE_REDECLARE);
+			redeclareTreeRoot.setDependeciesNode(true);
+			treeItems.add(redeclareTreeRoot);
+			
+			// build tree 
+			createRelationsTree(redeclareTreeRoot, getCollector().getRedeclareDependencies(), ITEM_NAME_POSTFIX_REDECLARE);
+			
+		
+			constrainedByTreeRoot = new TreeParent(NODE_TITLE_CONSTRAINEDBY);
+			constrainedByTreeRoot.setDependeciesNode(true);
+			treeItems.add(constrainedByTreeRoot);
+			
+			// build tree 
+			createRelationsTree(constrainedByTreeRoot, getCollector().getConstrainedByDependencies(), ITEM_NAME_POSTFIX_CONSTRAINEDBY);
+			
+			partialDerivativeOfFunctionTreeRoot = new TreeParent(NODE_TITLE_PARTIAL_DERIVATIVE);
+			partialDerivativeOfFunctionTreeRoot.setDependeciesNode(true);
+			treeItems.add(partialDerivativeOfFunctionTreeRoot);
+			
+			// build tree 
+			createRelationsTree(partialDerivativeOfFunctionTreeRoot, getCollector().getPartialDerivativeOfFunctionDependencies(), ITEM_NAME_POSTFIX_PARTIAL_DERIVATIVE);
+		}
+	}
+
+	
+	public void showTree(TreeParent parent){
+			
+		// remove old trees
+		TreeObject[] children = parent.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject treeObject = children[i];
+			parent.removeChild(treeObject);
+		}
+
+		// show new trees
+		parent.addChild(getTreeRoot());
+		
+		if (getUseToVerifyTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getUseToVerifyTreeRoot());
+		}
+		if (getDoNotuseToVerifyTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getDoNotuseToVerifyTreeRoot());
+		}
+		if (getRequiresTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getRequiresTreeRoot());
+		}
+		if (getRequiredForTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getRequiredForTreeRoot());
+		}
+		if (getImportsTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getImportsTreeRoot());
+		}
+		if (getExtendsTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getExtendsTreeRoot());
+		}
+		if (getRedeclareTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getRedeclareTreeRoot());
+		}
+		if (getConstrainedByTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getConstrainedByTreeRoot());
+		}
+		if (getPartialDerivativeOfFunctionTreeRoot().hasChildren()) {
+			getTreeRoot().addChild(getPartialDerivativeOfFunctionTreeRoot());
+		}
+	}
+	
+	
+	private void collectData(){
+		
+		// clear all lists from previous iterations
+		clearAll();
+		
+		ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(ModelicaMLServices.getShell());
+		
+		try {
+			progressMonitor.run(false, true, new IRunnableWithProgress() {
+				
+				@Override
+				public void run(IProgressMonitor monitor) throws InvocationTargetException,
+						InterruptedException {
+
+					monitor.beginTask("Collecting ModelicaML Relations Data ...", 100);
+					
+					collector = new RelationsCollector();
+					collector.collectElementsFromModel(getRootPackage());
+				}
+			});
+		} catch (InvocationTargetException e) {
+			MessageDialog.openError(ModelicaMLServices.getShell(), "ModelicaML Relations Data Collection Error", "Could not invoce the data collection for ModelicaML Relations view. ");
+		} catch (InterruptedException e) {
+			MessageDialog.openInformation(ModelicaMLServices.getShell(), "ModelicaML Relations Data Collection", "Data collection was interrupted.");		}
+	}
+	
+
+	private Element getSource(Element relation){
+		if (relation instanceof Dependency) {
+			if (((Dependency)relation).getClients().size() > 0 ) {
+				// NOTE: we always take the first because we do not use Dependency Sets in ModelicaML
+				return ((Dependency)relation).getClients().get(0);
+			}
+		}
+		else if (relation instanceof Generalization) {
+			if (((Generalization)relation).getSources().size() > 0 ) {
+				return ((Generalization)relation).getSources().get(0);
+			}
+		}
+		return null;
+	}
+	
+	private Element getTarget(Element relation){
+		if (relation instanceof Dependency) {
+			if (((Dependency)relation).getTargets().size() > 0 ) {
+				// NOTE: we take the first
+				return ((Dependency)relation).getTargets().get(0);
+			}
+		}
+		else if (relation instanceof Generalization) {
+			if (((Generalization)relation).getTargets().size() > 0 ) {
+				// NOTE: we take the first
+				return ((Generalization)relation).getTargets().get(0);
+			}
+		}
+		return null;
+	}
+	
+	
+	
+	private void createRelationsTree(TreeParent parent, HashSet<Element> relations, String sourceItemNamePostFix){
+		for (Element relation : relations) {
+
+			Element source = getSource(relation);
+			Element target= getTarget(relation);
+			
+			// parent node to create children for
+			TreeParent parentNode = parent;
+			// in case a relation has no source or error we create an extra error node which becomes parent
+			TreeParent errorNode = null;
+			
+			boolean inValidRelation = source == null || target == null;
+			
+			if (inValidRelation) {
+				String errorPostFix = "";
+				if (source == null) {
+					errorPostFix += " (has no source)"; 
+				}
+				if (target == null) {
+					errorPostFix += " (has no target)";
+				}
+				
+				errorNode = new TreeParent(getName(relation) + errorPostFix);
+				errorNode.setHasErrors(true);
+				errorNode.setDependeciesNode(true);
+				if (relation instanceof Dependency) {
+					errorNode.setDependencyElement((Dependency) relation);	
+				}
+				else if (relation instanceof Generalization) {
+					errorNode.setGeneralzationElement((Generalization) relation);
+				}
+				
+				parentNode.addChild(errorNode);
+			}
+			
+			// set the parent to be the error node if it was created
+			if (inValidRelation) {
+				parentNode = errorNode;
+			}
+			
+			// get the source of the relation
+			String namePrefixForSubNodes = "";
+			
+			/*
+			 * In case of an invalid relation we add relation "source" or "target" to sub nodes names.
+			 */
+			if (inValidRelation) {
+				namePrefixForSubNodes = "Source-> ";
+			}
+
+			// create new item
+			TreeParent sourceItem = new TreeParent(namePrefixForSubNodes + getName(source) + sourceItemNamePostFix);
+			sourceItem.setUmlElement(source);
+			treeItems.add(sourceItem);
+			
+			// add to parent
+			parentNode.addChild(sourceItem);
+			
+			// create target of the relation
+			if (inValidRelation) {
+				namePrefixForSubNodes = "Target-> ";
+			}
+
+			// create new item
+			TreeParent targetItem = new TreeParent(namePrefixForSubNodes + getName(target));
+			targetItem.setUmlElement(target);
+			treeItems.add(targetItem);
+			
+			// set the dependency element
+			if (relation instanceof Dependency) {
+				targetItem.setDependencyElement((Dependency) relation);	
+			}
+			else if (relation instanceof Generalization) {
+				targetItem.setGeneralzationElement((Generalization) relation);
+			}
+			
+			// add to parent
+			if (inValidRelation) {
+				errorNode.addChild(targetItem);
+			}
+			else {
+				sourceItem.addChild(targetItem);
+			}
+			
+			// propagate errors
+			if (inValidRelation) {
+				propagateError(errorNode, DECORATION_ERROR);
+			}
+		}
+	}
+	
+	
+
+	
+	
+	private void propagateError(TreeObject treeObject, int decoration){
+		treeObject.setHasErrors(true);
+		
+		TreeParent parent = treeObject.getParent(); 
+		if ( parent != null) {
+			propagateError(parent, decoration);
+		}
+	}
+	
+	private String getName(Element element) {
+		if (element!= null && element.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
+			return ModelicaMLServices.getRequirementID(element) + " - " + ModelicaMLServices.getName(element);
+		}
+		return ModelicaMLServices.getName(element);
+	}
+	
+
+	// ******************************************************************************************************************************
+	
+	public void clearAll(){
+		treeItems.clear();
+	}
+	
+	public List<TreeObject> findTreeItems(Object[] viewerSelection){
+
+		List<TreeObject> foundTreeItems = new ArrayList<TreeObject>();
+		
+		// to avoid concurrent modifications
+		ArrayList<TreeObject> items = new ArrayList<TreeObject>();
+		items.addAll(getTreeItems());
+		
+		for (TreeObject treeItem: items) {
+			
+			for (Object object : viewerSelection) {
+				
+				if (object instanceof TreeObject) {
+					Element umlElement1 = treeItem.getUmlElement();
+					Element umlElement2 = ((TreeObject)object).getUmlElement();
+					if (umlElement1!= null && umlElement2!=null && umlElement1.equals(umlElement2)) {
+						foundTreeItems.add(treeItem);
+					}
+					/*
+					 * The code below only works if the equal and hashCode are overridden ...
+					 */
+//					if ( ((TreeObject)object).equals(treeItem)) {
+//						foundTreeItems.add(treeItem);
+//					}
+				}
+				// structured selection, i.e. objects from other views
+				else if (adaptSelectedElement(object) != null) {
+					EObject eObj = adaptSelectedElement(object);
+					if ( ((TreeObject)treeItem).getUmlElement() != null && ((TreeObject)treeItem).getUmlElement().equals(eObj)) {
+						foundTreeItems.add(treeItem);
+					}
+				}
+			}
+		}
+		return foundTreeItems;
+	}
+	
+	
+	
+
+	
+	protected EObject adaptSelectedElement( Object selection) {
+		EObject eObject = null;
+		if(selection != null) {
+			
+			if (selection instanceof org.openmodelica.modelicaml.common.instantiation.TreeParent) { // this is an object from components tree view plugin
+				return ((org.openmodelica.modelicaml.common.instantiation.TreeParent)selection).getProperty();
+			}
+			
+			if(selection instanceof IAdaptable) {
+				selection = ((IAdaptable)selection).getAdapter(EObject.class);
+			}
+			Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
+			if(businessObject instanceof EObject) {
+				eObject = (EObject)businessObject;
+			}
+		}
+		return eObject;
+	}
+	
+	//***********************************
+	
+	
+	public HashSet<TreeObject> getTreeItems() {
+		return treeItems;
+	}
+	
+	
+	public void setUmlModel(UmlModel umlModel) {
+		this.umlModel = umlModel;
+	}
+
+
+
+	public UmlModel getUmlModel() {
+		return umlModel;
+	}
+
+
+	public Element getRootPackage() {
+		return rootPackage;
+	}
+
+
+	public void setRootPackage(Element rootPackage) {
+		this.rootPackage = rootPackage;
+	}
+
+
+	public TreeParent getUseToVerifyTreeRoot() {
+		return useToVerifyTreeRoot;
+	}
+
+
+	public void setUseToVerifyTreeRoot(TreeParent useToVerifyTreeRoot) {
+		this.useToVerifyTreeRoot = useToVerifyTreeRoot;
+	}
+
+
+	public TreeParent getDoNotuseToVerifyTreeRoot() {
+		return doNotUseToVerifyTreeRoot;
+	}
+
+
+	public void setDoNotuseToVerifyTreeRoot(TreeParent doNotuseToVerifyTreeRoot) {
+		this.doNotUseToVerifyTreeRoot = doNotuseToVerifyTreeRoot;
+	}
+
+
+	public TreeParent getRequiresTreeRoot() {
+		return requiresTreeRoot;
+	}
+
+
+	public void setRequiresTreeRoot(TreeParent requiresTreeRoot) {
+		this.requiresTreeRoot = requiresTreeRoot;
+	}
+
+
+	public TreeParent getRequiredForTreeRoot() {
+		return requiredForTreeRoot;
+	}
+
+
+	public void setRequiredForTreeRoot(TreeParent requiredForTreeRoot) {
+		this.requiredForTreeRoot = requiredForTreeRoot;
+	}
+	
+	public RelationsCollector getCollector() {
+		return collector;
+	}
+
+
+	public void setCollector(RelationsCollector collector) {
+		this.collector = collector;
+	}
+
+
+	public TreeParent getTreeRoot() {
+		return treeRoot;
+	}
+
+
+	public void setTreeRoot(TreeParent treeRoot) {
+		this.treeRoot = treeRoot;
+	}
+
+
+	public TreeParent getImportsTreeRoot() {
+		return importsTreeRoot;
+	}
+
+
+	public void setImportsTreeRoot(TreeParent importsTreeRoot) {
+		this.importsTreeRoot = importsTreeRoot;
+	}
+
+
+	public TreeParent getExtendsTreeRoot() {
+		return extendsTreeRoot;
+	}
+
+
+	public void setExtendsTreeRoot(TreeParent extendsTreeRoot) {
+		this.extendsTreeRoot = extendsTreeRoot;
+	}
+
+
+	public TreeParent getRedeclareTreeRoot() {
+		return redeclareTreeRoot;
+	}
+
+
+	public void setRedeclareTreeRoot(TreeParent redeclareTreeRoot) {
+		this.redeclareTreeRoot = redeclareTreeRoot;
+	}
+
+
+	public TreeParent getConstrainedByTreeRoot() {
+		return constrainedByTreeRoot;
+	}
+
+
+	public void setConstrainedByTreeRoot(TreeParent constrainedByTreeRoot) {
+		this.constrainedByTreeRoot = constrainedByTreeRoot;
+	}
+
+
+	public TreeParent getPartialDerivativeOfFunctionTreeRoot() {
+		return partialDerivativeOfFunctionTreeRoot;
+	}
+
+
+	public void setPartialDerivativeOfFunctionTreeRoot(
+			TreeParent partialDerivativeOfFunctionTreeRoot) {
+		this.partialDerivativeOfFunctionTreeRoot = partialDerivativeOfFunctionTreeRoot;
+	}
+
+}
+
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeObject.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeObject.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeObject.java	(revision 1621)
@@ -0,0 +1,115 @@
+package org.openmodelica.modelicaml.relations.model;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+
+public class TreeObject implements IAdaptable {
+	private String name;
+	private TreeParent parent;
+	
+	private Element umlElement;
+	private Dependency dependencyElement;
+	private Generalization generalzationElement;
+	private boolean hasErrors = false;
+	
+	public TreeObject(String name) {
+		this.name = name;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setParent(TreeParent parent) {
+		this.parent = parent;
+	}
+	public TreeParent getParent() {
+		return parent;
+	}
+	public String toString() {
+		return getName();
+	}
+
+	public Element getUmlElement() {
+		if (this.umlElement == null && this.dependencyElement != null) {
+			return this.dependencyElement;
+		}
+		else if (this.umlElement == null && this.generalzationElement != null) {
+			return this.generalzationElement;
+		}
+		return umlElement;
+	}
+	public void setUmlElement(Element umlElement) {
+		this.umlElement = umlElement;
+	}
+	public Dependency getDependencyElement() {
+		return dependencyElement;
+	}
+	public void setDependencyElement(Dependency dependencyElement) {
+		this.dependencyElement = dependencyElement;
+	}
+	
+	
+	@SuppressWarnings("rawtypes")
+	public Object getAdapter(java.lang.Class adapter) {
+		if (adapter == TreeObject.class) {
+			return this;
+		}
+		return null;
+	}
+	
+	
+	
+//	@Override
+//	public boolean equals(Object obj) {
+//		if (obj instanceof TreeObject) {
+//			TreeObject item = (TreeObject) obj;
+//			if (item.getUmlElement() != null && item.getUmlElement().equals(this.getUmlElement()) ) {
+//				return true;
+//			}
+//		}
+//		return false;
+//	}
+//	
+//	
+//	@Override
+//	public int hashCode() {
+//		
+//		int result = 0;
+//		
+//		result = result + this.getName().hashCode();
+//		
+//		if (this.getParent() != null) {
+//			result = result + this.getParent().hashCode();
+//		}
+//		
+//		if (this.getUmlElement() != null) {
+//			result = result + this.getUmlElement().hashCode();	
+//		}
+//		if (this.getDependencyElement() != null) {
+//			result = result + this.getDependencyElement().hashCode();	
+//		}
+//		if (this.getGeneralzationElement() != null) {
+//			result = result + this.getGeneralzationElement().hashCode();	
+//		}
+//
+//		return result; 	
+//	}
+	
+	
+	
+	
+	public Generalization getGeneralzationElement() {
+		return generalzationElement;
+	}
+	public void setGeneralzationElement(Generalization generalzationElement) {
+		this.generalzationElement = generalzationElement;
+	}
+	public boolean isHasErrors() {
+		return hasErrors;
+	}
+	public void setHasErrors(boolean hasErrors) {
+		this.hasErrors = hasErrors;
+	}
+	
+}
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeParent.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeParent.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/model/TreeParent.java	(revision 1621)
@@ -0,0 +1,48 @@
+package org.openmodelica.modelicaml.relations.model;
+
+import java.util.ArrayList;
+
+public class TreeParent extends TreeObject {
+	private ArrayList<TreeObject> children;
+	
+	private boolean isRoot = false;
+	private boolean isDependeciesNode = false;
+	private boolean isInheritanceNode = false;
+	
+	public TreeParent(String name) {
+		super(name);
+		children = new ArrayList<TreeObject>();
+	}
+	public void addChild(TreeObject child) {
+		children.add(child);
+		child.setParent(this);
+	}
+	public void removeChild(TreeObject child) {
+		children.remove(child);
+		child.setParent(null);
+	}
+	public TreeObject [] getChildren() {
+		return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+	}
+	public boolean hasChildren() {
+		return children.size()>0;
+	}
+	public boolean isRoot() {
+		return isRoot;
+	}
+	public void setRoot(boolean isRoot) {
+		this.isRoot = isRoot;
+	}
+	public boolean isDependeciesNode() {
+		return isDependeciesNode;
+	}
+	public void setDependeciesNode(boolean isDependeciesNode) {
+		this.isDependeciesNode = isDependeciesNode;
+	}
+	public boolean isInheritanceNode() {
+		return isInheritanceNode;
+	}
+	public void setInheritanceNode(boolean isInheritanceNode) {
+		this.isInheritanceNode = isInheritanceNode;
+	}
+}
Index: trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/views/RelationsView.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/views/RelationsView.java	(revision 1621)
+++ trunk/modelicaml/org.openmodelica.modelicaml.relations/src/org/openmodelica/modelicaml/relations/views/RelationsView.java	(revision 1621)
@@ -0,0 +1,441 @@
+package org.openmodelica.modelicaml.relations.views;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.papyrus.infra.core.utils.BusinessModelResolver;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.DrillDownAdapter;
+import org.eclipse.ui.part.ViewPart;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.services.EditorServices;
+import org.openmodelica.modelicaml.common.utls.ResourceManager;
+import org.openmodelica.modelicaml.relations.Activator;
+import org.openmodelica.modelicaml.relations.dialogs.SearchDialog;
+import org.openmodelica.modelicaml.relations.display.ViewLabelProviderStyledCell;
+import org.openmodelica.modelicaml.relations.model.TreeBuilder;
+import org.openmodelica.modelicaml.relations.model.TreeObject;
+import org.openmodelica.modelicaml.relations.model.TreeParent;
+
+
+
+public class RelationsView extends ViewPart {
+
+	/**
+	 * The ID of the view as specified by the extension.
+	 */
+	public static final String ID = "org.openmodelica.modelicaml.relations.views.RelationsView";
+
+	private TreeViewer viewer;
+	private DrillDownAdapter drillDownAdapter;
+//	private Action doubleClickAction;
+
+	private TreeParent invisibleRoot;
+	
+	TreeBuilder treeBuilder = new TreeBuilder();
+	public final int DEFAULT_EXPAND_LEVEL = 2;
+	
+	// actions
+	private Action actionLinkWithEditor;
+	private Action actionLocateInPapyrusModelExplorer;
+	private Action actionLocateDependencyInPapyrusModelExplorer;
+	private Action actionLocateInheritanceInPapyrusModelExplorer;
+	private Action actionCollapseAll;
+	private Action actionReload;
+
+	
+	//##################### Selection handling
+		 private ISelectionListener selectionListener = new ISelectionListener() {
+			 public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
+				 if (actionLinkWithEditor.isChecked() && sourcepart != RelationsView.this && selection instanceof IStructuredSelection) {
+		        	List<Object> selectedElements = getCurrentSelections();
+					List<Object> selectedElementsAdopted = new ArrayList<Object>();
+
+		        	if (selectedElements != null && selectedElements.size() > 0 ) {
+						for (Object object : selectedElements) {
+							EObject eObj = adaptSelectedElement(object);
+							if (eObj != null) {
+								selectedElementsAdopted.add(eObj);
+							}
+						}
+					}
+		        	
+		        	List<TreeObject> list = new ArrayList<TreeObject>();
+		        	list.addAll(treeBuilder.findTreeItems(selectedElementsAdopted.toArray()));
+					
+		        	if ( selectedElementsAdopted.size() > 0 ) {
+						viewer.setSelection(new StructuredSelection(list), true);
+					}
+		        }
+		    }
+		};
+
+		private Action actionFind;
+	
+
+	class ViewContentProvider implements IStructuredContentProvider, 
+										   ITreeContentProvider {
+
+		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+		}
+		public void dispose() {
+		}
+
+		public Object[] getElements(Object parent) {
+			if (parent.equals(getViewSite())) {
+				if (invisibleRoot==null) initialize();
+				return getChildren(invisibleRoot);
+			}
+			return getChildren(parent);
+		}
+		
+		public Object getParent(Object child) {
+			if (child instanceof TreeObject) {
+				return ((TreeObject)child).getParent();
+			}
+			return null;
+		}
+		
+		public Object [] getChildren(Object parent) {
+			if (parent instanceof TreeParent) {
+				return ((TreeParent)parent).getChildren();
+			}
+			return new Object[0];
+		}
+		
+		public boolean hasChildren(Object parent) {
+			if (parent instanceof TreeParent)
+				return ((TreeParent)parent).hasChildren();
+			return false;
+		}
+
+		private void initialize() {
+			// add the selection listener
+			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
+
+			invisibleRoot = new TreeParent("");
+		}
+	}
+
+	
+	class NameSorter extends ViewerSorter {
+	}
+
+	/**
+	 * The constructor.
+	 */
+	public RelationsView() {
+	}
+
+	/**
+	 * This is a callback that will allow us
+	 * to create the viewer and initialize it.
+	 */
+	public void createPartControl(Composite parent) {
+		viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		drillDownAdapter = new DrillDownAdapter(viewer);
+		viewer.setContentProvider(new ViewContentProvider());
+		viewer.setLabelProvider(new ViewLabelProviderStyledCell());
+		viewer.setSorter(new NameSorter());
+		viewer.setInput(getViewSite());
+
+		// Create the help context id for the viewer's control
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.openmodelica.modelicaml.relations.viewer");
+		makeActions();
+		hookContextMenu();
+		hookDoubleClickAction();
+		contributeToActionBars();
+		
+		// double click for opening/closing the sub tree
+		viewer.addOpenListener(new IOpenListener() {
+			public void open(final OpenEvent event) {
+				Object firstElement = ((IStructuredSelection)
+				event.getSelection()).getFirstElement();
+				if (viewer.getExpandedState(firstElement)) {
+					viewer.collapseToLevel(firstElement, AbstractTreeViewer.ALL_LEVELS);
+				} 
+				else {
+					viewer.expandToLevel(firstElement, 1);
+				}
+			}
+		});
+	}
+
+	private void hookContextMenu() {
+		MenuManager menuMgr = new MenuManager("#PopupMenu");
+		menuMgr.setRemoveAllWhenShown(true);
+		menuMgr.addMenuListener(new IMenuListener() {
+			public void menuAboutToShow(IMenuManager manager) {
+				RelationsView.this.fillContextMenu(manager);
+			}
+		});
+		Menu menu = menuMgr.createContextMenu(viewer.getControl());
+		viewer.getControl().setMenu(menu);
+		getSite().registerContextMenu(menuMgr, viewer);
+	}
+
+	private void contributeToActionBars() {
+		IActionBars bars = getViewSite().getActionBars();
+//		fillLocalPullDown(bars.getMenuManager());
+		fillLocalToolBar(bars.getToolBarManager());
+	}
+
+//	private void fillLocalPullDown(IMenuManager manager) {
+//		manager.add(new Separator());
+//	}
+
+	@SuppressWarnings("unchecked")
+	private void fillContextMenu(IMenuManager manager) {
+		ISelection selectedElements = viewer.getSelection();
+		List<Object> selectedTreeItems = null;
+		if (selectedElements instanceof IStructuredSelection) {
+			selectedTreeItems = ((IStructuredSelection)selectedElements).toList();
+		}
+		
+		Object firstSelectedTreeItem = selectedTreeItems.get(0);
+		if (firstSelectedTreeItem instanceof TreeObject && ((TreeObject)firstSelectedTreeItem).getUmlElement() != null) {
+			manager.add(actionLocateInPapyrusModelExplorer);
+		}
+		if (firstSelectedTreeItem instanceof TreeObject && ((TreeObject)firstSelectedTreeItem).getDependencyElement() != null) {
+			manager.add(actionLocateDependencyInPapyrusModelExplorer);
+		}
+		if (firstSelectedTreeItem instanceof TreeObject && ((TreeObject)firstSelectedTreeItem).getGeneralzationElement() != null) {
+			manager.add(actionLocateInheritanceInPapyrusModelExplorer);
+		}
+		
+		manager.add(new Separator());
+//		drillDownAdapter.addNavigationActions(manager);
+		// Other plug-ins can contribute there actions here
+//		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+	}
+	
+	private void fillLocalToolBar(IToolBarManager manager) {
+		manager.add(actionFind);
+		manager.add(new Separator());
+		manager.add(actionReload);
+		manager.add(new Separator());
+		manager.add(actionCollapseAll);
+		manager.add(actionLinkWithEditor);
+		manager.add(new Separator());
+		drillDownAdapter.addNavigationActions(manager);
+	}
+
+	
+	private void makeActions() {
+
+		actionReload = new Action() {
+			public void run() {
+				
+				Object[] expandedElements = viewer.getExpandedElements();
+				TreePath[] expandedTreePaths = viewer.getExpandedTreePaths();
+				
+				treeBuilder.initialize();
+				treeBuilder.showTree(invisibleRoot);
+				viewer.refresh();
+				
+				viewer.setExpandedElements(expandedElements);
+				viewer.setExpandedTreePaths(expandedTreePaths);
+
+				viewer.expandToLevel(2);
+			}
+		};
+		actionReload.setText("Reload");
+		actionReload.setToolTipText("Reload");
+		actionReload.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/refresh.gif"));
+		
+		actionLinkWithEditor = new Action("actionLinkWithEditor", 2) { //check box 
+			public void run() {
+			}
+		};
+		actionLinkWithEditor.setText("Link with Model Explorer");
+		actionLinkWithEditor.setToolTipText("Link with Model Explorer");
+		actionLinkWithEditor.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
+		
+		
+		
+		actionLocateInPapyrusModelExplorer = new Action("actionLocateInPapyrusModelExplorer") {
+			public void run() {
+				IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(Constants.VIEW_MODELEXPLORER);
+
+				ModelExplorerPageBookView modelExplorerPageBookView = null;
+				if (view instanceof ModelExplorerPageBookView) {
+					modelExplorerPageBookView = (ModelExplorerPageBookView)view;
+				   }
+				
+				if (modelExplorerPageBookView != null) {
+					ISelection selection = viewer.getSelection();
+					Object obj = ((IStructuredSelection)selection).getFirstElement();
+
+					if (obj instanceof TreeObject ) {
+						Object object = ((TreeObject)obj).getUmlElement();
+						EditorServices.locateInModelExplorer(object, false);
+					}
+				}
+			}
+		};
+		actionLocateInPapyrusModelExplorer.setText("Locate in Model Explorer");
+		actionLocateInPapyrusModelExplorer.setToolTipText("Locate in Model Explorer");
+		actionLocateInPapyrusModelExplorer.setImageDescriptor(ImageDescriptor.createFromImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.common", "/icons/editor/ModelExplorer.png")));
+		
+		
+		actionLocateDependencyInPapyrusModelExplorer = new Action("actionLocateDependencyInPapyrusModelExplorer") {
+			public void run() {
+				IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(Constants.VIEW_MODELEXPLORER);
+
+				ModelExplorerPageBookView modelExplorerPageBookView = null;
+				if (view instanceof ModelExplorerPageBookView) {
+					modelExplorerPageBookView = (ModelExplorerPageBookView)view;
+				   }
+				
+				if (modelExplorerPageBookView != null) {
+					ISelection selection = viewer.getSelection();
+					Object obj = ((IStructuredSelection)selection).getFirstElement();
+					
+					if (obj instanceof TreeObject ) {
+						Object object = ((TreeObject)obj).getDependencyElement();
+						EditorServices.locateInModelExplorer(object, false);
+					}
+				}
+			}
+		};
+		actionLocateDependencyInPapyrusModelExplorer.setText("Locate Dependency in Model Explorer");
+		actionLocateDependencyInPapyrusModelExplorer.setToolTipText("Locate Dependency in Model Explorer");
+		actionLocateDependencyInPapyrusModelExplorer.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/Dependency.gif"));
+		
+		actionLocateInheritanceInPapyrusModelExplorer = new Action("actionLocateInheritanceInPapyrusModelExplorer") {
+			public void run() {
+				IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(Constants.VIEW_MODELEXPLORER);
+
+				ModelExplorerPageBookView modelExplorerPageBookView = null;
+				if (view instanceof ModelExplorerPageBookView) {
+					modelExplorerPageBookView = (ModelExplorerPageBookView)view;
+				   }
+				
+				if (modelExplorerPageBookView != null) {
+					ISelection selection = viewer.getSelection();
+					Object obj = ((IStructuredSelection)selection).getFirstElement();
+					
+					if (obj instanceof TreeObject ) {
+						Object object = ((TreeObject)obj).getGeneralzationElement();
+						EditorServices.locateInModelExplorer(object, false);
+					}
+				}
+			}
+		};
+		actionLocateInheritanceInPapyrusModelExplorer.setText("Locate Generalization in Model Explorer");
+		actionLocateInheritanceInPapyrusModelExplorer.setToolTipText("Locate Generalization in Model Explorer");
+		actionLocateInheritanceInPapyrusModelExplorer.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/Generalization.gif"));
+
+		
+		actionCollapseAll = new Action("actionCollapseAll") { //obviously a check box style
+			public void run() {
+				TreeObject[] children = invisibleRoot.getChildren();
+				for (int i = 0; i < children.length; i++) {
+					if (children[i] instanceof TreeParent) {
+						TreeObject[] children2Level = ((TreeParent) children[i]).getChildren();
+						for (TreeObject treeObject : children2Level) {
+							viewer.collapseToLevel(treeObject, AbstractTreeViewer.ALL_LEVELS);	
+						}
+					}
+					else {
+						viewer.collapseToLevel(children[i], AbstractTreeViewer.ALL_LEVELS);	
+					}
+				}
+			}
+		};
+		actionCollapseAll.setText("Collapse all");
+		actionCollapseAll.setToolTipText("Collapse all");
+		actionCollapseAll.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
+		
+		
+		actionFind = new Action("actionFind") {
+			public void run() {
+				SearchDialog searchDialog = new SearchDialog(ModelicaMLServices.getShell(), viewer, invisibleRoot);
+				searchDialog.open();
+			}
+		};
+		actionFind.setText("Clear");
+		actionFind.setToolTipText("Clear");
+		actionFind.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/find.png"));
+		
+	}
+
+	private void hookDoubleClickAction() {
+		viewer.addDoubleClickListener(new IDoubleClickListener() {
+			public void doubleClick(DoubleClickEvent event) {
+//				doubleClickAction.run();
+			}
+		});
+	}
+	
+
+	/**
+	 * Passing the focus request to the viewer's control.
+	 */
+	public void setFocus() {
+		viewer.getControl().setFocus();
+	}
+	
+	
+	@SuppressWarnings("unchecked")
+	private List<Object> getCurrentSelections() {
+		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+		if(selection instanceof IStructuredSelection) {
+			IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+			return structuredSelection.toList();
+		}
+		return null;
+	}
+	
+	protected EObject adaptSelectedElement( Object selection) {
+		EObject eObject = null;
+		if(selection != null) {
+			
+			if (selection instanceof org.openmodelica.modelicaml.common.instantiation.TreeParent) { // this is an object from components tree view plugin
+				return ((org.openmodelica.modelicaml.common.instantiation.TreeParent)selection).getProperty();
+			}
+			
+			if(selection instanceof IAdaptable) {
+				selection = ((IAdaptable)selection).getAdapter(EObject.class);
+			}
+			Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
+			if(businessObject instanceof EObject) {
+				eObject = (EObject)businessObject;
+			}
+		}
+		return eObject;
+	}
+}
