Index: trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaDetailedGraphView.java
===================================================================
--- trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaDetailedGraphView.java	(revision 1714)
+++ trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaDetailedGraphView.java	(revision 1715)
@@ -427,5 +427,6 @@
 
 	private static void refreshView() {
-		for (Button b : buttonArray)
+		if (buttonArray != null)
+			for (Button b : buttonArray)
 			b.dispose();
 		buttonArray = new ArrayList<Button>();
@@ -436,5 +437,6 @@
 			}
 
-		textPanel.setText("");
+		if (textPanel != null)
+			textPanel.setText("");
 	}
 
Index: trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphAnalyzer.java
===================================================================
--- trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphAnalyzer.java	(revision 1714)
+++ trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphAnalyzer.java	(revision 1715)
@@ -129,4 +129,5 @@
 	public static int analyzeClasses(int prevID, String className, boolean recursive) 
 			throws ConnectException, UnexpectedReplyException, InvocationError {
+		System.out.println("TESTING");
 		currentCompiler.loadFile(classPath);
 
@@ -140,6 +141,13 @@
 		}
 
+		// Find service-dependencies among imports
+		int num =  currentCompiler.getImportCount(className);
+		for (int i = 0; i < num; i++) {
+			ICompilerResult res = currentCompiler.getNthImport(className, i+1);
+			createBond(className, res.getFirstResult(), recursive, prevID, SWT.LINE_SOLID, SWT.COLOR_GREEN);
+		}
+		
 		// Find inheritance-dependencies
-		int num =  currentCompiler.getInheritanceCount(className);
+		num =  currentCompiler.getInheritanceCount(className);
 		for (int i = 0; i < num; i++) {
 			ICompilerResult res = currentCompiler.getNthInheritedClass(className, i+1);
@@ -161,5 +169,5 @@
 			checkExist(className, trimRes, recursive, prevID);
 		}
-
+		
 		// Find function-call-dependencies among equations
 		num =  currentCompiler.getEquationItemsCount(className);
Index: trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphView.java
===================================================================
--- trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphView.java	(revision 1714)
+++ trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/graph/ModelicaGraphView.java	(revision 1715)
@@ -29,7 +29,9 @@
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.internal.WorkbenchPage;
 import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.texteditor.ITextEditor;
@@ -61,6 +63,7 @@
 	private static String objName = "";
 	private String source;
+	private boolean isDetached = false;
 	public static boolean loadedModelica = false;
-	
+
 	String viewId = "org.modelica.mdt.ui.graph.ModelicaGraphView"; 
 
@@ -72,22 +75,22 @@
 	 *            the parent that the part is made in
 	 */
+	@SuppressWarnings("restriction")
 	public void createPartControl(Composite parent) {
 		System.out.println("[GraphView initial] Creating a new Graph View");
 
 		// TODO: There seems to be an issue with this
+
 		/*
-		// Always detach view
-		// In Eclipse 3.x
-
-		WorkbenchPage page = ((WorkbenchPage) getSite().getPage());
-
-		//get the reference for your viewId
-		IViewReference ref = page.findViewReference(viewId);
-
-		page.getActivePerspective().getPresentation().detachPart(ref);
-		 */
-
-		// TODO: In Eclipse 4.x the following should be done instead
-		/*
+
+		// If the parent shell doesn't have a title it has been detached from the main window
+		if(parent.getShell().getText().length() != 0) {
+			// In Eclipse 3.x
+
+			WorkbenchPage page = ((WorkbenchPage) getSite().getPage());
+			IViewReference ref = page.findViewReference("org.modelica.mdt.ui.graph.ModelicaGraphView");
+			page.getActivePerspective().getPresentation().detachPart(ref);
+
+			// TODO: In Eclipse 4.x the following should be done instead
+			
 		EModelService s = (EModelService) getSite().getService(EModelService.class);
 		MPartSashContainerElement p = (MPart) getSite().getService(MPart.class);
@@ -95,5 +98,6 @@
 			p = p.getCurSharedRef();
 		s.detach(p, 100, 100, 300, 300);
-		 */
+		 
+		*/
 
 		permaParent = parent;
@@ -377,29 +381,29 @@
 	 */
 	public static void selectionChanged(final ISelection final_selection) {
-			Job job = new Job("Dependency Graph Loading") {
-				@Override
-				protected IStatus run(IProgressMonitor monitor) {
-
-			objName = "";
-			try {
-				IStructuredSelection newSelection = (IStructuredSelection) final_selection; 
-				Object obj = newSelection.getFirstElement();
-				objName = obj.getClass().getName();
-			} catch (ClassCastException e) {}
-			catch (NullPointerException e) {}
-
-			if (objName.equals("org.modelica.mdt.internal.core.ModelicaSourceFile")) {
-				System.out.println("[Change Selection] Found a Modelica-file!");
-				updateGraph(final_selection);
+		Job job = new Job("Dependency Graph Loading") {
+			@Override
+			protected IStatus run(IProgressMonitor monitor) {
+
+				objName = "";
+				try {
+					IStructuredSelection newSelection = (IStructuredSelection) final_selection; 
+					Object obj = newSelection.getFirstElement();
+					objName = obj.getClass().getName();
+				} catch (ClassCastException e) {}
+				catch (NullPointerException e) {}
+
+				if (objName.equals("org.modelica.mdt.internal.core.ModelicaSourceFile")) {
+					System.out.println("[Change Selection] Found a Modelica-file!");
+					updateGraph(final_selection);
+				}
+				else {
+					System.out.println("[Change Selection] Not a Modelia-file");
+				}
+				return Status.OK_STATUS;
 			}
-			else {
-				System.out.println("[Change Selection] Not a Modelia-file");
-			}
-			return Status.OK_STATUS;
-			}
-			};
-			job.schedule(); 
-		}
-	
+		};
+		job.schedule(); 
+	}
+
 	/**
 	 * This will remove all visual graph objects from the graph
