Author: scabanovich
Date: 2011-03-17 13:25:23 -0400 (Thu, 17 Mar 2011)
New Revision: 29867
Added:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectToResourceAdapter.java
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
Log:
JBIDE-8602
https://issues.jboss.org/browse/JBIDE-8602
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-03-17
17:21:03 UTC (rev 29866)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-03-17
17:25:23 UTC (rev 29867)
@@ -397,4 +397,13 @@
resource="meta/options_general.xml" priority="0">
</contribution>
</extension>
+
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+
class="org.jboss.tools.common.model.impl.XModelObjectToResourceAdapter"
+ adaptableType="org.jboss.tools.common.model.XModelObject">
+ <adapter type="org.eclipse.core.resources.IResource"/>
+ </factory>
+ </extension>
+
</plugin>
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2011-03-17
17:21:03 UTC (rev 29866)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2011-03-17
17:25:23 UTC (rev 29867)
@@ -480,9 +480,8 @@
public Object getAdapter(Class adapter) {
if(XModelObject.class == adapter) return this;
else if(adapter == IResource.class) {
- XModelObject f = getResourceAncestor();
- Object o = (f == null || f == this) ? null : f.getAdapter(IResource.class);
- return (o instanceof IResource) ? o : null;
+ //implementation moved to XModelObjectToResourceAdapter
+ return null;
} else if(adapter == IProject.class) {
return EclipseResourceUtil.getProject(this);
} else if(adapter == IFile.class) {
Added:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectToResourceAdapter.java
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectToResourceAdapter.java
(rev 0)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectToResourceAdapter.java 2011-03-17
17:25:23 UTC (rev 29867)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.impl;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.jboss.tools.common.model.XModelObject;
+
+public class XModelObjectToResourceAdapter implements IAdapterFactory {
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adaptableObject instanceof XModelObject && adapterType == IResource.class)
{
+ XModelObject o = (XModelObject)adaptableObject;
+ XModelObject f = ((XModelObjectImpl)o).getResourceAncestor();
+ Object r = (f == null || f == this) ? null : f.getAdapter(IResource.class);
+ return (r instanceof IResource) ? r : null;
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectToResourceAdapter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain