Bug 460405 - Fix compiler problems from generified
IAdaptable#getAdapter(..)

Change-Id: If1c75ec83be546bf271db550ab68fd3eef07e4b8
Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
diff --git a/bundles/org.eclipse.ui.views/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.views/META-INF/MANIFEST.MF
index b2657cc..25dcf09 100644
--- a/bundles/org.eclipse.ui.views/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.views/META-INF/MANIFEST.MF
@@ -13,7 +13,7 @@
  org.eclipse.ui.internal.views.properties; ui.views="split"; mandatory:="ui.views"; x-internal:=true,
  org.eclipse.ui.views.contentoutline,
  org.eclipse.ui.views.properties; ui.views="split"; mandatory:="ui.views"
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
  org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
  org.eclipse.ui;bundle-version="[3.5.0,4.0.0)"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/ViewsPlugin.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/ViewsPlugin.java
index d6da6e2..ad648af 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/ViewsPlugin.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/ViewsPlugin.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Simon Scholz <simon.scholz@vogella.com> - Bug 460405
  *******************************************************************************/
 package org.eclipse.ui.internal.views;
 
@@ -88,19 +89,19 @@
      * @return a representation of sourceObject that is assignable to the
      *         adapter type, or null if no such representation exists
      */
-    public static Object getAdapter(Object sourceObject, Class adapter, boolean activatePlugins) {
+	public static <T> T getAdapter(Object sourceObject, Class<T> adapter, boolean activatePlugins) {
     	Assert.isNotNull(adapter);
         if (sourceObject == null) {
             return null;
         }
         if (adapter.isInstance(sourceObject)) {
-            return sourceObject;
+			return adapter.cast(sourceObject);
         }
 
         if (sourceObject instanceof IAdaptable) {
             IAdaptable adaptable = (IAdaptable) sourceObject;
 
-            Object result = adaptable.getAdapter(adapter);
+			T result = adaptable.getAdapter(adapter);
             if (result != null) {
                 // Sanity-check
                 Assert.isTrue(adapter.isInstance(result));
@@ -109,9 +110,9 @@
         }
 
         if (!(sourceObject instanceof PlatformObject)) {
-        	Object result;
+			T result;
         	if (activatePlugins) {
-        		result = Platform.getAdapterManager().loadAdapter(sourceObject, adapter.getName());
+				result = adapter.cast(Platform.getAdapterManager().loadAdapter(sourceObject, adapter.getName()));
         	} else {
         		result = Platform.getAdapterManager().getAdapter(sourceObject, adapter);
         	}
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/contentoutline/ContentOutline.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/contentoutline/ContentOutline.java
index cd330e0..2710939 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/contentoutline/ContentOutline.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/contentoutline/ContentOutline.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Simon Scholz <simon.scholz@vogella.com> - Bug 460405
  *******************************************************************************/
 
 package org.eclipse.ui.views.contentoutline;
@@ -123,9 +124,8 @@
     @Override
 	protected PageRec doCreatePage(IWorkbenchPart part) {
         // Try to get an outline page.
-        Object obj = ViewsPlugin.getAdapter(part, IContentOutlinePage.class, false);
-        if (obj instanceof IContentOutlinePage) {
-            IContentOutlinePage page = (IContentOutlinePage) obj;
+		IContentOutlinePage page = ViewsPlugin.getAdapter(part, IContentOutlinePage.class, false);
+		if (page != null) {
             if (page instanceof IPageBookViewPage) {
 				initPage((IPageBookViewPage) page);
 			}
@@ -144,14 +144,14 @@
     }
 
     @Override
-	public Object getAdapter(Class key) {
+	public <T> T getAdapter(Class<T> key) {
         if (key == IContributedContentsView.class) {
-			return new IContributedContentsView() {
+			return key.cast(new IContributedContentsView() {
                 @Override
 				public IWorkbenchPart getContributingPart() {
                     return getContributingEditor();
                 }
-            };
+			});
 		}
         return super.getAdapter(key);
     }
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
index 51d6d70..a1d06a4 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -10,22 +10,18 @@
  *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
  *     Semion Chichelnitsky (semion@il.ibm.com) - bug 272564
  *     Craig Foote (Footeware.ca) - https://bugs.eclipse.org/325743
+ *     Simon Scholz <simon.scholz@vogella.com> - Bug 460405
  *******************************************************************************/
 package org.eclipse.ui.views.properties;
 
 import java.util.HashSet;
 
-import org.eclipse.osgi.util.NLS;
-
-import org.eclipse.swt.widgets.Composite;
-
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
 import org.eclipse.core.runtime.IExtensionPoint;
 import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.IRegistryEventListener;
 import org.eclipse.core.runtime.RegistryFactory;
-
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
@@ -33,7 +29,8 @@
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.ISelection;
-
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IMemento;
 import org.eclipse.ui.ISaveablePart;
 import org.eclipse.ui.ISelectionListener;
@@ -199,7 +196,7 @@
     	if(part instanceof PropertySheet) {
     		return null;
     	}
-        IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part,
+		IPropertySheetPage page = ViewsPlugin.getAdapter(part,
                 IPropertySheetPage.class, false);
         if (page != null) {
             if (page instanceof IPageBookViewPage) {
@@ -286,7 +283,7 @@
 	public void partActivated(IWorkbenchPart part) {
     	// Look for a declaratively-contributed adapter - including not yet loaded adapter factories.
     	// See bug 86362 [PropertiesView] Can not access AdapterFactory, when plugin is not loaded.
-        IContributedContentsView view = (IContributedContentsView) ViewsPlugin.getAdapter(part,
+		IContributedContentsView view = ViewsPlugin.getAdapter(part,
                 IContributedContentsView.class, true);
         IWorkbenchPart source = null;
         if (view != null) {
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java
index bf215c9..2dbe06d 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
  *     IBM Corporation - initial API and implementation
  *     Gunnar Wagenknecht - fix for bug 21756 [PropertiesView] property view sorting
  *     Kevin Milburn - [Bug 423214] [PropertiesView] add support for IColorProvider and IFontProvider
+ *     Simon Scholz <simon.scholz@vogella.com> - Bug 460405
  *******************************************************************************/
 
 package org.eclipse.ui.views.properties;
@@ -63,7 +64,7 @@
 	/**
 	 * The property sources for the values we are displaying/editing.
 	 */
-	private Map sources = new HashMap(0);
+	private Map<Object, IPropertySource> sources = new HashMap<Object, IPropertySource>(0);
 
 	/**
 	 * The value of this entry is defined as the the first object in its value
@@ -438,20 +439,20 @@
 	 */
 	protected IPropertySource getPropertySource(Object object) {
 		if (sources.containsKey(object))
-			return (IPropertySource) sources.get(object);
+			return sources.get(object);
 
 		IPropertySource result = null;
 		IPropertySourceProvider provider = propertySourceProvider;
 
 		if (provider == null && object != null) {
-			provider = (IPropertySourceProvider) ViewsPlugin.getAdapter(object,
+			provider = ViewsPlugin.getAdapter(object,
                     IPropertySourceProvider.class, false);
         }
 
 		if (provider != null) {
 			result = provider.getPropertySource(object);
 		} else {
-            result = (IPropertySource)ViewsPlugin.getAdapter(object, IPropertySource.class, false);
+			result = ViewsPlugin.getAdapter(object, IPropertySource.class, false);
         }
 
 		sources.put(object, result);
diff --git a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetPage.java b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetPage.java
index 162b6a1..8f9436d 100644
--- a/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetPage.java
+++ b/bundles/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetPage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Gunnar Wagenknecht - fix for bug 21756 [PropertiesView] property view sorting
+ *     Simon Scholz <simon.scholz@vogella.com> - Bug 460405
  *******************************************************************************/
 
 package org.eclipse.ui.views.properties;
@@ -295,9 +296,9 @@
      * @since 3.2
      */
     @Override
-	public Object getAdapter(Class adapter) {
+	public <T> T getAdapter(Class<T> adapter) {
 		if (ISaveablePart.class.equals(adapter)) {
-			return getSaveablePart();
+			return adapter.cast(getSaveablePart());
 		}
     	return null;
     }