Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteItemManager.java5
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java7
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/DefaultTagCreationAdvisor.java22
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java23
4 files changed, 46 insertions, 11 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteItemManager.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteItemManager.java
index df122a76b..f81c5fa20 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteItemManager.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/palette/impl/PaletteItemManager.java
@@ -63,7 +63,6 @@ public class PaletteItemManager implements IPaletteItemManager,
private static final boolean DEBUG = false;
- private static final IContentType JSP_CONTENTTYPE = Platform.getContentTypeManager().getContentType("org.eclipse.jst.jsp.core.jspsource"); //$NON-NLS-1$
private static Map<TagRegistryIdentifier, PaletteItemManager> _managers = new HashMap<TagRegistryIdentifier, PaletteItemManager>();
private static ReentrantLock MANAGER_LOCK = new ReentrantLock();
@@ -145,7 +144,7 @@ public class PaletteItemManager implements IPaletteItemManager,
return null;
}
//to support legacy null projects. Allows HTML and JSP tag libs to be displayed.
- return new TagRegistryIdentifier(null, JSP_CONTENTTYPE);
+ return new TagRegistryIdentifier(null, org.eclipse.jst.pagedesigner.utils.JSPUtil.JSP_CONTENTTYPE);
}
@@ -164,7 +163,7 @@ public class PaletteItemManager implements IPaletteItemManager,
}
};
}
- private void addFile(IFile file) {
+ private void addFile(final IFile file) {
synchronized (_files) {
_files.add(file);
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java
index d9b6cd8c7..5669ea93b 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/CreationData.java
@@ -193,6 +193,13 @@ public final class CreationData
return false;
}
+ /**
+ * @return flag indicating that jsf view container ancestor is required
+ */
+ public boolean isJSFViewTagRequired() {
+ return JSPUtil.isJSPModel(_model);
+ }
+
/**
* @return the metadata context for the tag
*/
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/DefaultTagCreationAdvisor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/DefaultTagCreationAdvisor.java
index a6dfca0d7..a0b0d890e 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/DefaultTagCreationAdvisor.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/itemcreation/DefaultTagCreationAdvisor.java
@@ -52,27 +52,33 @@ public class DefaultTagCreationAdvisor extends AbstractTagCreationAdvisor
* @return position after creating required containers
*/
protected ContainerCreationCommand getContainerCreationCommand(final IDOMPosition position) {
- if (_creationData.isJSFComponent()) {
+ if (_creationData.isJSFComponent()) {
return getJSFContainerCommand(position);
}
- else if (_creationData.isHTMLFormRequired()){
+ else if (!(_creationData.isJSFComponent()) && _creationData.isHTMLFormRequired()){
return getHtmlFormCommand(position);
- }
+ }
return null;
}
-
- /**
+
+ /**
* @param position
* @return the default container creation command for a JSF tag
*/
protected ContainerCreationCommand getJSFContainerCommand(final IDOMPosition position)
{
- ContainerCreationCommand command =
- new SingletonContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_VIEW, _creationData.getTagId());
+ ContainerCreationCommand command = null;
+
+ if (_creationData.isJSFViewTagRequired())
+ command = new SingletonContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_VIEW, _creationData.getTagId());
if (_creationData.isHTMLFormRequired())
{
- command.chain(new TagContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_FORM, _creationData.getTagId()));
+ final ContainerCreationCommand htmlFormCommand = new TagContainerCreationCommand(position, IJSFConstants.TAG_IDENTIFIER_FORM, _creationData.getTagId());
+ if (command != null)
+ command.chain(htmlFormCommand);
+ else
+ command = htmlFormCommand;
}
return command;
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java
index 970ca46ac..0b7f58738 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java
@@ -18,6 +18,9 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.jst.jsf.common.metadata.Trait;
import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper;
import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext;
@@ -51,6 +54,11 @@ import org.w3c.dom.Node;
* @author mengbo
*/
public class JSPUtil {
+
+ /**
+ * JSP source contenttype
+ */
+ public static final IContentType JSP_CONTENTTYPE = Platform.getContentTypeManager().getContentType("org.eclipse.jst.jsp.core.jspsource"); //$NON-NLS-1$
/**
* find out whether the specified taglib has been defined in the IDOMModel.
* If found, then return the prefix. If can't find, then will try to add a
@@ -320,4 +328,19 @@ public class JSPUtil {
}
return false;
}
+
+ /**
+ * @param model
+ * @return true if model is a JSP contenttype
+ */
+ public static boolean isJSPModel(IDOMModel model) {
+ final IContentTypeManager typeManager = Platform.getContentTypeManager();
+ final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(model.getStructuredDocument(), 0);
+ final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
+ final IFile file = (IFile)resolver.getResource();
+ final IContentType contentType =
+ typeManager.findContentTypeFor(file.getName());
+
+ return contentType.isKindOf(JSP_CONTENTTYPE);
+ }
}

Back to the top