Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2010-04-28 18:45:39 -0400
committercbateman2010-04-28 18:45:39 -0400
commit152fe41e2a1bd583199a49fb23150f4853086e29 (patch)
tree62760df263ac19a4aed62389bbe34165e3403f9d
parentf62e319705ae9f84949ee00d89cc34e53116f6f2 (diff)
downloadwebtools.jsf-152fe41e2a1bd583199a49fb23150f4853086e29.tar.gz
webtools.jsf-152fe41e2a1bd583199a49fb23150f4853086e29.tar.xz
webtools.jsf-152fe41e2a1bd583199a49fb23150f4853086e29.zip
Add support for detecting composite component library adds and remove by adding and removing folders. Refactored JSFResource's to support fragments.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java187
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java8
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/AbstractJSFResourceLocator.java6
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResource.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceContainer.java11
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceFragment.java48
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceLocator.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IWorkspaceJSFResourceFragment.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResource.java25
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceChangeListener.java12
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceContainer.java25
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceFragment.java41
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResource.java29
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResourceLocator.java8
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/LibraryResourceFragmentIdentifier.java36
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceFragmentIdentifier.java132
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifier.java67
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifierFactory.java10
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResource.java11
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceContainer.java42
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceLocator.java6
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceResourceManager.java59
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/CompositeComponentTaglibLocator.java120
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/JSFResourceBasedTagRecord.java130
24 files changed, 732 insertions, 319 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java
index 1667b239d..b883eff96 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java
@@ -246,85 +246,75 @@ public class LifecycleListener extends ImmutableLifecycleListener implements
switch (event.getType())
{
- case IResourceChangeEvent.PRE_CLOSE:
- {
- final IProject proj = (IProject) event.getResource();
-
- // must use iterator to ensure copy on write behaviour
- for (final IResource res : _resources)
+ case IResourceChangeEvent.PRE_CLOSE:
{
- if (proj == res || proj == res.getProject())
+ final IProject proj = (IProject) event.getResource();
+
+ // must use iterator to ensure copy on write behaviour
+ for (final IResource res : _resources)
{
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_INACCESSIBLE,
- ReasonType.RESOURCE_PROJECT_CLOSED));
+ if (proj == res || proj == res.getProject())
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_INACCESSIBLE,
+ ReasonType.RESOURCE_PROJECT_CLOSED));
+ }
}
}
- }
break;
- case IResourceChangeEvent.PRE_DELETE:
- {
- final IProject proj = (IProject) event.getResource();
-
- // must use iterator to ensure copy on write behaviour
- for (final IResource res : _resources)
+ case IResourceChangeEvent.PRE_DELETE:
{
- // if the resource being tracked is the resource being
- // deleted,
- // then fire a resource delete event
- if (proj == res)
+ final IProject proj = (IProject) event.getResource();
+
+ // must use iterator to ensure copy on write behaviour
+ for (final IResource res : _resources)
{
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_INACCESSIBLE,
- ReasonType.RESOURCE_DELETED));
- }
- // if the resource being tracked is a resource in the
- // project being
- // deleted, then fire a project deleted event
- else if (proj == res.getProject())
- {
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_INACCESSIBLE,
- ReasonType.RESOURCE_PROJECT_DELETED));
+ // if the resource being tracked is the resource being
+ // deleted,
+ // then fire a resource delete event
+ if (proj == res)
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_INACCESSIBLE,
+ ReasonType.RESOURCE_DELETED));
+ }
+ // if the resource being tracked is a resource in the
+ // project being
+ // deleted, then fire a project deleted event
+ else if (proj == res.getProject())
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_INACCESSIBLE,
+ ReasonType.RESOURCE_PROJECT_DELETED));
+ }
}
}
- }
break;
- case IResourceChangeEvent.POST_CHANGE:
- {
- for (final IResource res : _resources)
+ case IResourceChangeEvent.POST_CHANGE:
{
- IResourceDelta delta = event.getDelta();
-
- // long seqId2 = _seqId++;
- // if (ENABLE_TEST_TRACKING && _testTracker != null)
- // {
- // _testTracker.fireEvent(Event.START_TRACKING, seqId2,
- // "testFindMember");
- // }
- // only care about post change events to resources
- // that we are tracking
- delta = delta.findMember(res.getFullPath());
-
- if (delta != null)
+ for (final IResource res : _resources)
{
- visit(delta);
+ IResourceDelta delta = event.getDelta();
+
+ // only care about post change events to resources
+ // that we are tracking
+ if (delta != null)
+ {
+ delta = delta.findMember(res.getFullPath());
+ if (delta != null)
+ {
+ visit(delta);
+ }
+ }
}
-
- // if (ENABLE_TEST_TRACKING && _testTracker != null)
- // {
- // _testTracker.fireEvent(Event.STOP_TRACKING, seqId2,
- // "testFindMember");
- // }
}
- }
break;
- default:
- // do nothing
- // we only handle these three
+ default:
+ // do nothing
+ // we only handle these three
}
if (ENABLE_TEST_TRACKING && _testTracker != null)
@@ -366,23 +356,21 @@ public class LifecycleListener extends ImmutableLifecycleListener implements
handleWorkspaceRoot(delta);
} else if (res instanceof IContainer)
{
- handleContainer(delta, (IContainer) res);
+ handleContainer(delta);
} else
{
handleFile(delta, res);
}
}
- private void handleContainer(final IResourceDelta delta, final IContainer res)
+ private void handleContainer(final IResourceDelta delta)
{
for (final IResourceDelta childDelta : delta.getAffectedChildren())
{
- if ((childDelta.getResource().getType() == IResource.FILE
+ if (childDelta.getResource().getType() == IResource.FILE
|| childDelta.getResource().getType() == IResource.FOLDER)
- && childDelta.getKind() == IResourceDelta.ADDED)
{
- fireLifecycleEvent(new ResourceLifecycleEvent(childDelta.getResource(),
- EventType.RESOURCE_ADDED, ReasonType.RESOURCE_ADDED));
+ handleChange(childDelta, childDelta.getResource());
}
}
}
@@ -391,29 +379,58 @@ public class LifecycleListener extends ImmutableLifecycleListener implements
{
switch (delta.getKind())
{
- case IResourceDelta.ADDED:
- {
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_ADDED, ReasonType.RESOURCE_ADDED));
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED:
+ {
+ handleChange(delta, res);
+ }
+ break;
+ case IResourceDelta.CHANGED:
+ {
+ // the contents of the file have changed
+ if ((delta.getFlags() & IResourceDelta.CONTENT) != 0)
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_CHANGED,
+ ReasonType.RESOURCE_CHANGED_CONTENTS));
+ }
+ }
+ break;
}
- break;
- case IResourceDelta.CHANGED:
+ }
+
+ private void handleChange(final IResourceDelta delta, final IResource res)
+ {
+ switch (delta.getKind())
{
- // the contents of the file have changed
- if ((delta.getFlags() & IResourceDelta.CONTENT) != 0)
+ case IResourceDelta.ADDED:
{
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_CHANGED,
- ReasonType.RESOURCE_CHANGED_CONTENTS));
+ if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0)
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_ADDED, ReasonType.RESOURCE_MOVED));
+ } else
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_ADDED, ReasonType.RESOURCE_ADDED));
+ }
}
- }
break;
- case IResourceDelta.REMOVED:
- {
- fireLifecycleEvent(new ResourceLifecycleEvent(res,
- EventType.RESOURCE_INACCESSIBLE,
- ReasonType.RESOURCE_DELETED));
- }
+
+ case IResourceDelta.REMOVED:
+ {
+ if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0)
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_INACCESSIBLE,
+ ReasonType.RESOURCE_MOVED));
+ } else
+ {
+ fireLifecycleEvent(new ResourceLifecycleEvent(res,
+ EventType.RESOURCE_INACCESSIBLE,
+ ReasonType.RESOURCE_DELETED));
+ }
+ }
break;
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java
index 1484382a7..6b469a0ee 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java
@@ -78,7 +78,13 @@ public class ResourceLifecycleEvent
/**
* Occurs when a non-project resource is added.
*/
- RESOURCE_ADDED
+ RESOURCE_ADDED,
+ /**
+ * Occurs when a resource was has been moved. This results
+ * in a remove and add for the moved resource, plus a similar
+ * pair for all its children if it is a container.
+ */
+ RESOURCE_MOVED
}
private final IResource _affectedResource;
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/AbstractJSFResourceLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/AbstractJSFResourceLocator.java
index 7c06a3844..b0d5df80e 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/AbstractJSFResourceLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/AbstractJSFResourceLocator.java
@@ -15,7 +15,7 @@ import org.eclipse.jst.jsf.designtime.internal.resources.JSFResourceChangeListen
*
*/
public abstract class AbstractJSFResourceLocator extends
- AbstractLocator<List<JSFResource>, IProject, String> implements
+ AbstractLocator<List<IJSFResourceFragment>, IProject, String> implements
IJSFResourceLocator
{
@@ -26,13 +26,13 @@ public abstract class AbstractJSFResourceLocator extends
* @param mutableListenerList
*/
protected AbstractJSFResourceLocator(String id, String displayName,
- List<JSFResource> noResultValue,
+ List<IJSFResourceFragment> noResultValue,
CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList)
{
super(id, displayName, noResultValue, mutableListenerList);
}
- protected abstract List<JSFResource> doLocate(IProject context);
+ protected abstract List<IJSFResourceFragment> doLocate(IProject context);
/**
* TODO: would be better to have a private interface to call fire.
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResource.java
new file mode 100644
index 000000000..7ece953b8
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResource.java
@@ -0,0 +1,18 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+/**
+ * Represents a JSF loadable resource (spec 2.6).
+ *
+ * @author cbateman
+ *
+ */
+public interface IJSFResource extends IJSFResourceFragment
+{
+ /**
+ * @param contentTypeName
+ * @return true if the resources matches the content type indicated by the
+ * contentTypeName.
+ */
+ public abstract boolean isContentType(final String contentTypeName);
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceContainer.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceContainer.java
new file mode 100644
index 000000000..e65ff0194
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceContainer.java
@@ -0,0 +1,11 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+/**
+ * A JSF Resource fragment that is a container for other fragments.
+ * @author cbateman
+ *
+ */
+public interface IJSFResourceContainer extends IJSFResourceFragment
+{
+ // do nothing. Tagging for now.
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceFragment.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceFragment.java
new file mode 100644
index 000000000..71d474c7b
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceFragment.java
@@ -0,0 +1,48 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+/**
+ * An object that backs a fragment of a JSF resource. A fragment may be a full
+ * fledged JSF resource or a may be another interesting related object such as
+ * the library folder that holds a resource.
+ *
+ * @author cbateman
+ *
+ */
+public interface IJSFResourceFragment
+{
+
+ /**
+ * @return true if the fragment is accessible
+ */
+ public abstract boolean isAccessible();
+
+ /**
+ * @return the type of this fragment.
+ */
+ public abstract Type getType();
+
+ /**
+ * @return the id of the fragment
+ */
+ public ResourceFragmentIdentifier getId();
+
+ /**
+ * The type of a fragment
+ *
+ */
+ public enum Type
+ {
+ /**
+ * A fragment of this type is a full-fledged JSF Resource. A fragment of
+ * this type can always be cast to IJSFResource.
+ */
+ RESOURCE,
+ /**
+ * A fragment of this type is a container for actual RESOURCE's or other
+ * fragments (or both). A fragment of this type can always be cast to
+ * IJSFResourceContainer.
+ */
+ CONTAINER;
+ }
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceLocator.java
index 57faaea51..c44673cfe 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IJSFResourceLocator.java
@@ -11,7 +11,7 @@ import org.eclipse.jst.jsf.common.internal.locator.ILocator;
* @author cbateman
*
*/
-public interface IJSFResourceLocator extends ILocator<List<JSFResource>, IProject, String>
+public interface IJSFResourceLocator extends ILocator<List<IJSFResourceFragment>, IProject, String>
{
/**
* @param listener
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IWorkspaceJSFResourceFragment.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IWorkspaceJSFResourceFragment.java
new file mode 100644
index 000000000..d0d4a8a4b
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/IWorkspaceJSFResourceFragment.java
@@ -0,0 +1,18 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * A JSF fragment whose design time object(s) of interest are in the workspace
+ * @author cbateman
+ *
+ */
+public interface IWorkspaceJSFResourceFragment extends IJSFResourceFragment
+{
+
+ /**
+ * @return the corresponding design time workspace resource.
+ */
+ public IResource getResource();
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResource.java
index e81c6bb62..ccd37fe52 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResource.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResource.java
@@ -8,9 +8,8 @@ import org.eclipse.jst.jsf.common.internal.resource.ContentTypeResolver;
* @author cbateman
*
*/
-public abstract class JSFResource
+public abstract class JSFResource extends JSFResourceFragment implements IJSFResource
{
- private final ResourceIdentifier _id;
private final ContentTypeResolver _contentTypeResolver;
/**
@@ -20,7 +19,7 @@ public abstract class JSFResource
public JSFResource(final ResourceIdentifier id,
final ContentTypeResolver contentTypeResolver)
{
- _id = id;
+ super(id, Type.RESOURCE);
_contentTypeResolver = contentTypeResolver;
}
@@ -29,36 +28,24 @@ public abstract class JSFResource
*/
public final ResourceIdentifier getId()
{
- return _id;
+ return (ResourceIdentifier) super.getId();
}
/**
* @return true if this jsf resource is currently accessible.
*/
+ @Override
public abstract boolean isAccessible();
- /**
- * @param contentTypeName
- * @return true if the resources matches the content type indicated by the
- * contentTypeName.
- */
public boolean isContentType(final String contentTypeName)
{
- return _contentTypeResolver.matchesType(contentTypeName, _id
+ return _contentTypeResolver.matchesType(contentTypeName, getId()
.getResourceName());
}
- /**
- * @return a resource fragment is something which does not represent
- * a JSF resource but which is a concrete object in the underlying design time system
- * that maps to part or a "fragment" of a JSF resource. The most common instance
- * is a workspace folder or jar entry that represents the library part of a resource id.
- */
- public abstract boolean isFragment();
-
@Override
public String toString()
{
- return _id.toString();
+ return getId().toString();
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceChangeListener.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceChangeListener.java
index 70e048415..f7004c550 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceChangeListener.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceChangeListener.java
@@ -46,8 +46,8 @@ public abstract class JSFResourceChangeListener implements ILocatorChangeListene
}
private final CHANGE_TYPE _changeType;
- private final JSFResource _oldValue;
- private final JSFResource _newValue;
+ private final IJSFResourceFragment _oldValue;
+ private final IJSFResourceFragment _newValue;
/**
* @param source
@@ -57,8 +57,8 @@ public abstract class JSFResourceChangeListener implements ILocatorChangeListene
*/
public JSFResourceChangedEvent(
final AbstractJSFResourceLocator source,
- final JSFResource oldValue,
- final JSFResource newValue,
+ final IJSFResourceFragment oldValue,
+ final IJSFResourceFragment newValue,
final CHANGE_TYPE changeType)
{
super(source);
@@ -84,7 +84,7 @@ public abstract class JSFResourceChangeListener implements ILocatorChangeListene
/**
* @return the old value. This is null if the event is ADDED
*/
- public final JSFResource getOldValue()
+ public final IJSFResourceFragment getOldValue()
{
return _oldValue;
}
@@ -92,7 +92,7 @@ public abstract class JSFResourceChangeListener implements ILocatorChangeListene
/**
* @return the new value. This is null if the event is REMOVED
*/
- public final JSFResource getNewValue()
+ public final IJSFResourceFragment getNewValue()
{
return _newValue;
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceContainer.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceContainer.java
new file mode 100644
index 000000000..3ffaf5885
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceContainer.java
@@ -0,0 +1,25 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+/**
+ * A container for JSFResource's. This is a fragment in that it's identifier
+ * may not point to a valid JSFResource but rather a portion of that nonetheless
+ * maps to some interesting underlying contain object such as an IFolder.
+ *
+ * @author cbateman
+ *
+ */
+public abstract class JSFResourceContainer extends JSFResourceFragment implements IJSFResourceContainer
+{
+
+ /**
+ * @param id
+ */
+ public JSFResourceContainer(ResourceFragmentIdentifier id)
+ {
+ super(id, Type.CONTAINER);
+ }
+
+ @Override
+ public abstract boolean isAccessible();
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceFragment.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceFragment.java
new file mode 100644
index 000000000..4de62aef6
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JSFResourceFragment.java
@@ -0,0 +1,41 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+/**
+ *
+ * @author cbateman
+ *
+ */
+public abstract class JSFResourceFragment implements IJSFResourceFragment
+{
+ private final ResourceFragmentIdentifier _id;
+ private final Type _type;
+
+ /**
+ * @param id
+ * @param type
+ */
+ public JSFResourceFragment(final ResourceFragmentIdentifier id,
+ final Type type)
+ {
+ _id = id;
+ _type = type;
+ }
+
+ public ResourceFragmentIdentifier getId()
+ {
+ return _id;
+ }
+
+ public final Type getType()
+ {
+ return _type;
+ }
+
+ public abstract boolean isAccessible();
+
+ public String toString()
+ {
+ String toString = _id != null ? _id.toString() : "?"; //$NON-NLS-1$
+ return String.format("%s[%s]", toString, _type.toString()); //$NON-NLS-1$
+ }
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResource.java
index 5dc72ca79..7864da0c7 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResource.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResource.java
@@ -104,33 +104,4 @@ public class JarBasedJSFResource extends JSFResource
}
return null;
}
-
- @Override
- public boolean isFragment()
- {
- JarFile jarFile = null;
- try
- {
- jarFile = getJarFile();
- if (jarFile != null)
- {
- final ZipEntry entry = getZipEntry(jarFile);
- return entry.isDirectory();
- }
- } finally
- {
- if (jarFile != null)
- {
- // TODO:
-// try
-// {
-// jarFile.close();
-// } catch (IOException e)
-// {
-// // fall-through.
-// }
- }
- }
- return false;
- }
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResourceLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResourceLocator.java
index 7804a65d4..a4d1b8262 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResourceLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/JarBasedJSFResourceLocator.java
@@ -48,7 +48,7 @@ public class JarBasedJSFResourceLocator extends AbstractJSFResourceLocator
public JarBasedJSFResourceLocator(
final String id,
final String displayName,
- final List<JSFResource> noResultValue,
+ final List<IJSFResourceFragment> noResultValue,
final CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList,
final IJarProvider provider,
final ContentTypeResolver contentTypeResolver)
@@ -65,7 +65,7 @@ public class JarBasedJSFResourceLocator extends AbstractJSFResourceLocator
* @param contentTypeResolver
*/
public JarBasedJSFResourceLocator(
- final List<JSFResource> noResultValue,
+ final List<IJSFResourceFragment> noResultValue,
final CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList,
final IJarProvider provider,
final ContentTypeResolver contentTypeResolver)
@@ -75,9 +75,9 @@ public class JarBasedJSFResourceLocator extends AbstractJSFResourceLocator
}
@Override
- protected List<JSFResource> doLocate(final IProject project)
+ protected List<IJSFResourceFragment> doLocate(final IProject project)
{
- final List<JSFResource> resourcesFound = new ArrayList<JSFResource>();
+ final List<IJSFResourceFragment> resourcesFound = new ArrayList<IJSFResourceFragment>();
final Collection<? extends JarFile> jars = _provider.getJars(project);
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/LibraryResourceFragmentIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/LibraryResourceFragmentIdentifier.java
new file mode 100644
index 000000000..744f0b1b6
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/LibraryResourceFragmentIdentifier.java
@@ -0,0 +1,36 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A fragment identifier for a library folder.
+ *
+ * @author cbateman
+ *
+ */
+public class LibraryResourceFragmentIdentifier extends
+ ResourceFragmentIdentifier
+{
+ private final String _libraryName;
+
+ /**
+ * @param libraryName
+ */
+ public LibraryResourceFragmentIdentifier(final String libraryName)
+ {
+ super();
+ _libraryName = libraryName;
+ }
+
+ @Override
+ public String getLibraryName()
+ {
+ return _libraryName;
+ }
+ @Override
+ public IStatus validate()
+ {
+ return Status.OK_STATUS;
+ }
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceFragmentIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceFragmentIdentifier.java
new file mode 100644
index 000000000..db87d34d5
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceFragmentIdentifier.java
@@ -0,0 +1,132 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Represents a piece of a resource identifier.
+ *
+ * [localePrefix/][libraryName/][libraryVersion/][resourceName][/resourceVersion]
+ *
+ * @author cbateman
+ *
+ */
+public abstract class ResourceFragmentIdentifier
+{
+
+ /**
+ * @return true if validate().isOk
+ */
+ public boolean isValid()
+ {
+ return validate().isOK();
+ }
+
+ /**
+ * @return a validation status for the current value of this identifier
+ */
+ public abstract IStatus validate();
+
+ /**
+ * @return the resource name or null if none.
+ */
+ public String getResourceName()
+ {
+ return null;
+ }
+
+ /**
+ * @return the locale prefix or null if none.
+ */
+ public String getLocalePrefix()
+ {
+ return null;
+ }
+
+ /**
+ * @return the library name or null if none.
+ */
+ public String getLibraryName()
+ {
+ return null;
+ }
+
+ /**
+ * @return the library version or null if none.
+ */
+ public String getLibraryVersion()
+ {
+ return null;
+ }
+
+ /**
+ * @return the resource version or null if none.
+ */
+ public String getResourceVersion()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (super.equals(obj))
+ {
+ return true;
+ }
+
+ if (obj instanceof ResourceIdentifier)
+ {
+ String meToString = toString();
+ String otherToString = obj.toString();
+ return meToString != null && meToString.equals(otherToString);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ String toString = toString();
+ return toString != null ? toString.hashCode() : 0;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ String toString = ""; //$NON-NLS-1$
+
+ toString = append(toString, getLocalePrefix());
+ toString = append(toString, getLibraryName());
+ toString = append(toString, getLibraryVersion());
+ toString = append(toString, getResourceName());
+ toString = append(toString, getResourceVersion());
+ return toString;
+ }
+
+ /**
+ * @param appendStr
+ * @param toAppend
+ * @return a string with to toAppend appended to appendStr if it is not null.
+ * If appendStr is not append, a '/' is added between the two concatenated strings.
+ */
+ protected String append(String appendStr, final String toAppend)
+ {
+ if (toAppend != null)
+ {
+ if (appendStr.length() > 0)
+ {
+ appendStr += "/"; //$NON-NLS-1$
+ }
+ appendStr += toAppend;
+ }
+ return appendStr;
+ }
+ /**
+ * @return true if this identifier represents only a fragment of an identifier.
+ */
+ public boolean isFragment()
+ {
+ return true;
+ }
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifier.java
index 986f1dc49..19f86efa9 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifier.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifier.java
@@ -14,7 +14,7 @@ import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
* @author cbateman
*
*/
-public class ResourceIdentifier
+public class ResourceIdentifier extends ResourceFragmentIdentifier
{
/**
* Resource name is not optional on identifiers.
@@ -37,49 +37,27 @@ public class ResourceIdentifier
}
/**
- * @return the locale prefix or null if none.
+ * Allow fragments to be
*/
- public String getLocalePrefix()
+ protected ResourceIdentifier()
{
- return null;
- }
-
- /**
- * @return the library name or null if none.
- */
- public String getLibraryName()
- {
- return null;
- }
-
- /**
- * @return the library version or null if none.
- */
- public String getLibraryVersion()
- {
- return null;
+ super();
+ _resName = null;
}
-
/**
* @return the resource name or null if none.
*/
+ @Override
public String getResourceName()
{
return _resName;
}
/**
- * @return the resource version or null if none.
- */
- public String getResourceVersion()
- {
- return null;
- }
-
- /**
* @return a status object multi-value that contains the results of
* validating this resoure identifier.
*/
+ @Override
public IStatus validate()
{
final String id = ResourceIdentifierValidationNamespace;
@@ -96,14 +74,6 @@ public class ResourceIdentifier
return status;
}
- /**
- * @return true if validate().isOK is true.
- */
- public boolean isValid()
- {
- return validate().isOK();
- }
-
@Override
public String toString()
{
@@ -120,12 +90,12 @@ public class ResourceIdentifier
{
idString = String.format("%s/%s", getLibraryName(), idString); //$NON-NLS-1$
}
-
+
if (getLocalePrefix() != null)
{
idString = String.format("%s/%s", getLocalePrefix(), idString); //$NON-NLS-1$
}
-
+
if (getResourceVersion() != null)
{
idString += "/" + getResourceVersion(); //$NON-NLS-1$
@@ -134,26 +104,9 @@ public class ResourceIdentifier
}
@Override
- public boolean equals(Object obj)
+ public final boolean isFragment()
{
- if (super.equals(obj))
- {
- return true;
- }
-
- if (obj instanceof ResourceIdentifier)
- {
- String meToString = toString();
- String otherToString = obj.toString();
- return meToString.equals(otherToString);
- }
return false;
}
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifierFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifierFactory.java
index c2f872d2f..004083b2c 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifierFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/ResourceIdentifierFactory.java
@@ -92,6 +92,15 @@ public class ResourceIdentifierFactory
}
/**
+ * @param libraryName
+ * @return a new resource fragment identifier for a library folder.
+ */
+ public ResourceFragmentIdentifier createLibraryFragment(final String libraryName)
+ {
+ return new LibraryResourceFragmentIdentifier(libraryName);
+ }
+
+ /**
* Indicates an invalid id.
*
* @author cbateman
@@ -154,6 +163,5 @@ public class ResourceIdentifierFactory
*
*/
private static final long serialVersionUID = -8926293207447823901L;
-
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResource.java
index 20a12e76a..c0d48e838 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResource.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResource.java
@@ -8,7 +8,7 @@ import org.eclipse.jst.jsf.common.internal.resource.ContentTypeResolver;
* @author cbateman
*
*/
-public class WorkspaceJSFResource extends JSFResource
+public class WorkspaceJSFResource extends JSFResource implements IWorkspaceJSFResourceFragment
{
private final IResource _res;
@@ -23,9 +23,6 @@ public class WorkspaceJSFResource extends JSFResource
_res = res;
}
- /**
- * @return the corresponding design time workspace resource.
- */
public final IResource getResource()
{
return _res;
@@ -36,10 +33,4 @@ public class WorkspaceJSFResource extends JSFResource
{
return _res.isAccessible();
}
-
- @Override
- public boolean isFragment()
- {
- return _res.getType() != IResource.FILE;
- }
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceContainer.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceContainer.java
new file mode 100644
index 000000000..aa9be8422
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceContainer.java
@@ -0,0 +1,42 @@
+package org.eclipse.jst.jsf.designtime.internal.resources;
+
+import org.eclipse.core.resources.IContainer;
+
+/**
+ * A concrete JSFResourceContainer that maps to a container object in the
+ * workspace.
+ *
+ * @author cbateman
+ *
+ */
+public class WorkspaceJSFResourceContainer extends JSFResourceContainer implements IWorkspaceJSFResourceFragment
+{
+
+ private final IContainer _container;
+
+ /**
+ * @param id
+ * @param container
+ */
+ public WorkspaceJSFResourceContainer(final ResourceFragmentIdentifier id,
+ final IContainer container)
+ {
+ super(id);
+ _container = container;
+ }
+
+ @Override
+ public boolean isAccessible()
+ {
+ return _container.isAccessible();
+ }
+
+ /**
+ * @return the container resource
+ */
+ public IContainer getResource()
+ {
+ return _container;
+ }
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceLocator.java
index 17f7a1cec..425e9e92a 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceJSFResourceLocator.java
@@ -31,7 +31,7 @@ public class WorkspaceJSFResourceLocator extends AbstractJSFResourceLocator
public WorkspaceJSFResourceLocator(
final String id,
final String displayName,
- final List<JSFResource> noResultValue,
+ final List<IJSFResourceFragment> noResultValue,
final CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList,
final AbstractVirtualComponentQuery vcQuery,
final ContentTypeResolver contentTypeResolver,
@@ -50,7 +50,7 @@ public class WorkspaceJSFResourceLocator extends AbstractJSFResourceLocator
* @param workspace
*/
public WorkspaceJSFResourceLocator(
- final List<JSFResource> noResultValue,
+ final List<IJSFResourceFragment> noResultValue,
final CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList,
final AbstractVirtualComponentQuery vcQuery,
final ContentTypeResolver contentTypeResolver,
@@ -70,7 +70,7 @@ public class WorkspaceJSFResourceLocator extends AbstractJSFResourceLocator
}
@Override
- protected List<JSFResource> doLocate(final IProject project)
+ protected List<IJSFResourceFragment> doLocate(final IProject project)
{
return _workspaceResourceManager.getJSFResources();
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceResourceManager.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceResourceManager.java
index 709a38339..5127e4dfd 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceResourceManager.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resources/WorkspaceResourceManager.java
@@ -83,7 +83,8 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
"While trying to locate JSF resources in the workspace"); //$NON-NLS-1$
}
- final VisitorMatcher<IContainer, IResource, String> matcher = new VisitorMatcher<IContainer, IResource, String>(
+ final VisitorMatcher<IContainer, IResource, String> matcher =
+ new VisitorMatcher<IContainer, IResource, String>(
"", "", //$NON-NLS-1$ //$NON-NLS-2$
new FileMatchingAcceptor(), Collections
.singletonList(new AlwaysMatcher()));
@@ -104,18 +105,32 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
}
}
- private WorkspaceJSFResource track(final IContainer containerFolder,
- final IResource res) throws ManagedObjectException,
- InvalidIdentifierException
+ private IWorkspaceJSFResourceFragment trackRootRelative(final IResource res)
+ throws ManagedObjectException, InvalidIdentifierException
+ {
+ return track(getRootResourceFolder(), res);
+ }
+
+ private IWorkspaceJSFResourceFragment track(
+ final IContainer containerFolder, final IResource res)
+ throws ManagedObjectException, InvalidIdentifierException
{
final IPath containerPath = containerFolder.getFullPath();
final IPath fullPath = res.getFullPath().makeRelativeTo(containerPath);
// cause the resource to get tracked
final JSFResourceTracker tracker = (JSFResourceTracker) getInstance(res);
- final WorkspaceJSFResource jsfRes = new WorkspaceJSFResource(_factory
- .createLibraryResource(fullPath.toString()), res,
- _contentTypeResolver);
+ IWorkspaceJSFResourceFragment jsfRes = null;
+ if (res.getType() == IResource.FILE)
+ {
+ jsfRes = new WorkspaceJSFResource(_factory
+ .createLibraryResource(fullPath.toString()), res,
+ _contentTypeResolver);
+ } else
+ {
+ jsfRes = new WorkspaceJSFResourceContainer(_factory
+ .createLibraryFragment(res.getName()), (IContainer) res);
+ }
tracker.setJsfResource(jsfRes);
addLifecycleEventListener(tracker);
return jsfRes;
@@ -147,9 +162,9 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
* @return the jsf resource currently known. List is a copy but the
* contained JSFResource references are not.
*/
- public List<JSFResource> getJSFResources()
+ public List<IJSFResourceFragment> getJSFResources()
{
- final List<JSFResource> jsfResources = new ArrayList<JSFResource>();
+ final List<IJSFResourceFragment> jsfResources = new ArrayList<IJSFResourceFragment>();
final Map<IResource, ManagedResourceObject<ResourceTracker<IResource>>> jsfResourceTrackers = getPerResourceObjects();
for (final Map.Entry<IResource, ManagedResourceObject<ResourceTracker<IResource>>> entry : jsfResourceTrackers
@@ -163,7 +178,7 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
private class JSFResourceTracker extends ResourceTracker<IResource>
{
- private WorkspaceJSFResource _jsfResource;
+ private IWorkspaceJSFResourceFragment _jsfResource;
public JSFResourceTracker(final IResource resource)
{
@@ -189,13 +204,12 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
protected void fireResourceAdded(final IResource affectedResource,
final ReasonType reasonType)
{
- final IFolder root = getRootResourceFolder();
- if (root != null && root.isAccessible())
+ final IContainer parent = affectedResource.getParent();
+ if (parent != null && parent.isAccessible())
{
try
{
- final WorkspaceJSFResource newJsfRes = track(root,
- affectedResource);
+ final IWorkspaceJSFResourceFragment newJsfRes = trackRootRelative(affectedResource);
final JSFResourceChangedEvent event = new JSFResourceChangedEvent(
_locator, null, newJsfRes, CHANGE_TYPE.ADDED);
_locator.fireChangeEvent(event);
@@ -216,21 +230,22 @@ public class WorkspaceResourceManager extends ResourceManager<IResource>
{
switch (event.getEventType())
{
- case RESOURCE_ADDED:
- return getResource() instanceof IContainer
- && event.getAffectedResource().getParent().equals(
- getResource());
- default:
- return super.isInteresting(event);
+ case RESOURCE_ADDED:
+ return getResource() instanceof IContainer
+ && event.getAffectedResource().getParent().equals(
+ getResource());
+ default:
+ return super.isInteresting(event);
}
}
- public final WorkspaceJSFResource getJsfResource()
+ public final IWorkspaceJSFResourceFragment getJsfResource()
{
return _jsfResource;
}
- public final void setJsfResource(final WorkspaceJSFResource jsfResource)
+ public final void setJsfResource(
+ final IWorkspaceJSFResourceFragment jsfResource)
{
_jsfResource = jsfResource;
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/CompositeComponentTaglibLocator.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/CompositeComponentTaglibLocator.java
index ddc72b84a..8cf8ced65 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/CompositeComponentTaglibLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/CompositeComponentTaglibLocator.java
@@ -6,9 +6,13 @@ import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.common.internal.locator.ILocatorProvider;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResource;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResourceContainer;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResourceFragment;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResourceFragment.Type;
import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResourceLocator;
-import org.eclipse.jst.jsf.designtime.internal.resources.JSFResource;
import org.eclipse.jst.jsf.designtime.internal.resources.JSFResourceChangeListener;
+import org.eclipse.jst.jsf.designtime.internal.resources.JSFResourceContainer;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.JSFResourceBasedTagRecord.Builder;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.Listener.TaglibChangedEvent;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.Listener.TaglibChangedEvent.CHANGE_TYPE;
@@ -32,55 +36,103 @@ public class CompositeComponentTaglibLocator extends
final Builder builder = new Builder();
switch (event.getChangeType())
{
- case ADDED:
- case CHANGED:
- {
- List<TaglibChangedEvent> events = Collections.EMPTY_LIST;
-
- if (event.getNewValue().isFragment())
+ case ADDED:
+ case CHANGED:
{
- // if it's a fragment handle as a possible library add
- events = handleFolderAddChange(event, builder);
- } else
- {
- // otherwise, handle as a file add.
- events = handleFileAddChange(event, builder);
+ handleAddAndChange(event, builder);
}
- _records = builder.merge(events, _records);
- for (final TaglibChangedEvent fireEvent : events)
+ break;
+ case REMOVED:
{
- fireChangeEvent(fireEvent);
+ handleRemove(event, builder);
}
- }
break;
- case REMOVED:
+ }
+ }
+
+ private void handleRemove(final JSFResourceChangedEvent event,
+ final Builder builder)
+ {
+ List<TaglibChangedEvent> events = Collections.EMPTY_LIST;
+ switch (event.getOldValue().getType())
{
- final JSFResource oldValue = event.getOldValue();
- builder.addTag(oldValue, CHANGE_TYPE.REMOVED);
- final List<TaglibChangedEvent> events = builder.createRemove(
- CompositeComponentTaglibLocator.this, _records);
- _records = builder.merge(events, _records);
- for (final TaglibChangedEvent fireEvent : events)
+ case RESOURCE:
{
- fireChangeEvent(fireEvent);
+ events = handleRemoveResource(event, builder);
}
+ break;
+ case CONTAINER:
+ {
+ events = handleRemoveContainer(event, builder);
+ }
+ break;
+ }
+
+ _records = builder.merge(events, _records);
+ for (final TaglibChangedEvent fireEvent : events)
+ {
+ fireChangeEvent(fireEvent);
}
+ }
+
+ private List<TaglibChangedEvent> handleRemoveContainer(
+ final JSFResourceChangedEvent event, final Builder builder)
+ {
+ final IJSFResourceFragment oldValue = event.getOldValue();
+ builder.addLibrary((IJSFResourceContainer) oldValue,
+ CHANGE_TYPE.REMOVED);
+ return builder.createRemove(CompositeComponentTaglibLocator.this,
+ _records);
+ }
+
+ private List<TaglibChangedEvent> handleRemoveResource(
+ final JSFResourceChangedEvent event, final Builder builder)
+ {
+ final IJSFResourceFragment oldValue = event.getOldValue();
+ builder.addTag((IJSFResource) oldValue, CHANGE_TYPE.REMOVED);
+ return builder.createRemove(CompositeComponentTaglibLocator.this,
+ _records);
+ }
+
+ private void handleAddAndChange(final JSFResourceChangedEvent event,
+ final Builder builder)
+ {
+ List<TaglibChangedEvent> events = Collections.EMPTY_LIST;
+
+ switch (event.getNewValue().getType())
+ {
+ case CONTAINER:
+ // if it's a fragment handle as a possible library add
+ events = handleFolderAddChange(event, builder);
break;
+ case RESOURCE:
+ // otherwise, handle as a file add.
+ events = handleFileAddChange(event, builder);
+ break;
+ }
+
+ _records = builder.merge(events, _records);
+
+ for (final TaglibChangedEvent fireEvent : events)
+ {
+ fireChangeEvent(fireEvent);
}
}
private List<TaglibChangedEvent> handleFolderAddChange(
- JSFResourceChangedEvent event, Builder builder)
+ final JSFResourceChangedEvent event, final Builder builder)
{
- final JSFResource newValue = event.getNewValue();
+ final JSFResourceContainer newValue = (JSFResourceContainer) event
+ .getNewValue();
builder.addLibrary(newValue, CHANGE_TYPE.ADDED);
- return builder.createMerge(CompositeComponentTaglibLocator.this, _records);
+ return builder.createMerge(CompositeComponentTaglibLocator.this,
+ _records);
}
private List<TaglibChangedEvent> handleFileAddChange(
final JSFResourceChangedEvent event, final Builder builder)
{
- final JSFResource newValue = event.getNewValue();
+ final IJSFResource newValue = (IJSFResource) event.getNewValue();
builder.addTag(newValue, CHANGE_TYPE.ADDED);
return builder.createMerge(CompositeComponentTaglibLocator.this,
_records);
@@ -121,10 +173,14 @@ public class CompositeComponentTaglibLocator extends
final Builder builder = new Builder();
for (final IJSFResourceLocator locator : _locatorProvider.getLocators())
{
- final List<JSFResource> resources = locator.locate(initialContext);
- for (final JSFResource resource : resources)
+ final List<IJSFResourceFragment> resources = locator
+ .locate(initialContext);
+ for (final IJSFResourceFragment resource : resources)
{
- builder.addTag(resource, CHANGE_TYPE.ADDED);
+ if (resource.getType() == Type.RESOURCE)
+ {
+ builder.addTag((IJSFResource) resource, CHANGE_TYPE.ADDED);
+ }
}
}
_records = builder.build();
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/JSFResourceBasedTagRecord.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/JSFResourceBasedTagRecord.java
index 1b23add35..02f6fe857 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/JSFResourceBasedTagRecord.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/taglib/JSFResourceBasedTagRecord.java
@@ -9,7 +9,8 @@ import java.util.Map;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.jsf.designtime.internal.resources.JSFResource;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResource;
+import org.eclipse.jst.jsf.designtime.internal.resources.IJSFResourceContainer;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.Listener.TaglibChangedEvent;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.Listener.TaglibChangedEvent.CHANGE_TYPE;
import org.eclipse.jst.jsf.facelet.core.internal.registry.taglib.faceletTaglib.FaceletTaglibFactory;
@@ -119,24 +120,25 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
*/
public static class Builder
{
+ private static final List<FaceletTaglibTag> WHOLE_LIBRARY = new ArrayList<FaceletTaglibTag>(
+ 0);
private final Map<String, List<FaceletTaglibTag>> _tags = new HashMap<String, List<FaceletTaglibTag>>();
private static final String FACELET_FILE_CONTENT_TYPE = "org.eclipse.wst.html.core.htmlsource"; //$NON-NLS-1$
/**
* @param jsfResource
- * @param changeType
+ * @param changeType
*/
- public void addTag(final JSFResource jsfResource,
+ public void addTag(final IJSFResource jsfResource,
final CHANGE_TYPE changeType)
{
- String libraryName = jsfResource.getId().getLibraryName();
+ final String libraryName = jsfResource.getId().getLibraryName();
if (libraryName == null)
{
return;
}
- final String uri = String
- .format(
- "http://java.sun.com/jsf/composite/%s", libraryName); //$NON-NLS-1$
+ final String uri = String.format(
+ "http://java.sun.com/jsf/composite/%s", libraryName); //$NON-NLS-1$
List<FaceletTaglibTag> tags = _tags.get(uri);
if (tags == null)
{
@@ -152,42 +154,53 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
switch (changeType)
{
- case ADDED:
- case CHANGED:
- // only add to the list on a add/change if the resource exists
- // and is the right type
- if (jsfResource.isAccessible()
- && jsfResource.isContentType(FACELET_FILE_CONTENT_TYPE))
- {
+ case ADDED:
+ case CHANGED:
+ // only add to the list on a add/change if the resource
+ // exists
+ // and is the right type
+ if (jsfResource.isAccessible()
+ && jsfResource
+ .isContentType(FACELET_FILE_CONTENT_TYPE))
+ {
+ tags.add(tag);
+ }
+ break;
+ case REMOVED:
+ // add all comers to the remove list. There will only be
+ // removal
+ // on merge if ADDED/CHANGED path decided they should be
+ // there.
tags.add(tag);
- }
break;
- case REMOVED:
- // add all comers to the remove list. They will only be removal
- // on merge if ADDED/CHANGED path decided they should be there.
- tags.add(tag);
}
}
/**
* @param jsfResource
- * @param added
+ * @param changeType
*/
- public void addLibrary(JSFResource jsfResource, CHANGE_TYPE added)
+ public void addLibrary(final IJSFResourceContainer jsfResource,
+ final CHANGE_TYPE changeType)
{
- String libraryName = jsfResource.getId().getLibraryName();
+ final String libraryName = jsfResource.getId().getLibraryName();
if (libraryName == null)
{
return;
}
- final String uri = String
- .format(
- "http://java.sun.com/jsf/composite/%s", libraryName); //$NON-NLS-1$
- List<FaceletTaglibTag> tags = _tags.get(uri);
- if (tags == null)
+ final String uri = String.format(
+ "http://java.sun.com/jsf/composite/%s", libraryName); //$NON-NLS-1$
+ if (changeType == CHANGE_TYPE.REMOVED)
{
- tags = new ArrayList<FaceletTaglibTag>();
- _tags.put(uri, tags);
+ _tags.put(uri, WHOLE_LIBRARY);
+ } else
+ {
+ List<FaceletTaglibTag> tags = _tags.get(uri);
+ if (tags == null)
+ {
+ tags = new ArrayList<FaceletTaglibTag>();
+ _tags.put(uri, tags);
+ }
}
}
@@ -230,9 +243,9 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
.getValue(), CHANGE_TYPE.ADDED);
} else
{
- JSFResourceBasedTagRecord oldRecord = records.get(entry
- .getKey());
- JSFResourceBasedTagRecord newRecord = oldRecord
+ final JSFResourceBasedTagRecord oldRecord = records
+ .get(entry.getKey());
+ final JSFResourceBasedTagRecord newRecord = oldRecord
.mergeTags(entry.getValue()._tags);
event = new TaglibChangedEvent(locator, oldRecord,
newRecord, CHANGE_TYPE.CHANGED);
@@ -249,8 +262,8 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
* _tags from records.
*/
public List<TaglibChangedEvent> createRemove(
- AbstractFaceletTaglibLocator locator,
- Map<String, JSFResourceBasedTagRecord> records)
+ final AbstractFaceletTaglibLocator locator,
+ final Map<String, JSFResourceBasedTagRecord> records)
{
final Map<String, JSFResourceBasedTagRecord> newRecords = build();
final List<TaglibChangedEvent> mergeEvents = new ArrayList<TaglibChangedEvent>();
@@ -258,21 +271,29 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
.entrySet())
{
TaglibChangedEvent event = null;
+ final JSFResourceBasedTagRecord oldRecord = records
+ .get(entry.getKey());
+ if (oldRecord != null)
{
- JSFResourceBasedTagRecord oldRecord = records.get(entry
- .getKey());
- if (oldRecord != null)
+ final List<FaceletTaglibTag> tags = entry.getValue()._tags;
+ if (tags == WHOLE_LIBRARY)
+ {
+ event = new TaglibChangedEvent(locator, oldRecord,
+ null, CHANGE_TYPE.REMOVED);
+ } else
{
- JSFResourceBasedTagRecord newRecord = oldRecord
+ final JSFResourceBasedTagRecord newRecord = oldRecord
.removeTags(entry.getValue()._tags);
event = new TaglibChangedEvent(locator, oldRecord,
newRecord, CHANGE_TYPE.CHANGED);
}
}
- mergeEvents.add(event);
+ if (event != null)
+ {
+ mergeEvents.add(event);
+ }
}
return mergeEvents;
-
}
/**
@@ -282,19 +303,36 @@ public class JSFResourceBasedTagRecord extends FaceletTagRecord
* here.
*/
public Map<String, JSFResourceBasedTagRecord> merge(
- List<TaglibChangedEvent> events,
+ final List<TaglibChangedEvent> events,
final Map<String, JSFResourceBasedTagRecord> withThese)
{
final Map<String, JSFResourceBasedTagRecord> newMap = new HashMap<String, JSFResourceBasedTagRecord>(
withThese);
for (final TaglibChangedEvent event : events)
{
- IFaceletTagRecord newRecord = event.getNewValue();
- // doubles as null check
- if (newRecord instanceof JSFResourceBasedTagRecord)
+ switch (event.getChangeType())
{
- newMap.put(newRecord.getURI(),
- (JSFResourceBasedTagRecord) newRecord);
+ case ADDED:
+ case CHANGED:
+ {
+ final IFaceletTagRecord newRecord = event.getNewValue();
+ // doubles as null check
+ if (newRecord instanceof JSFResourceBasedTagRecord)
+ {
+ newMap.put(newRecord.getURI(),
+ (JSFResourceBasedTagRecord) newRecord);
+ }
+ }
+ break;
+ case REMOVED:
+ {
+ final IFaceletTagRecord oldRecord = event.getOldValue();
+ if (oldRecord != null)
+ {
+ newMap.remove(oldRecord.getURI());
+ }
+ }
+ break;
}
}
return newMap;

Back to the top