Author: scabanovich
Date: 2009-07-24 09:56:47 -0400 (Fri, 24 Jul 2009)
New Revision: 16768
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
Log:
JBIDE-1826
Dependency on old kb removed.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java 2009-07-24
13:55:30 UTC (rev 16767)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java 2009-07-24
13:56:47 UTC (rev 16768)
@@ -13,8 +13,8 @@
import java.text.MessageFormat;
import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.kb.KbDinamicResource;
import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalTypeFactory;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
/**
@@ -22,6 +22,20 @@
*/
public class AttributeValueResourceFactory {
+ static String BUNDLE_NAME_TYPE = CustomProposalTypeFactory.RESOURCE_BUNDLE_NAME_TYPE;
+ static String VIEW_ACTIONS_TYPE = CustomProposalTypeFactory.ACTION_TYPE;
+ static String IMAGE_FILE_TYPE = CustomProposalTypeFactory.RESOURCE_PATH_TYPE;
+ static String ENUMERATION_TYPE = CustomProposalTypeFactory.ENUMERATION_TYPE;
+ static String FACELETS_JSFC_TYPE = CustomProposalTypeFactory.FACELETS_JSFC_TYPE;
+ static String TAGLIB_TYPE = CustomProposalTypeFactory.NAME_SPACE_TYPE;
+ static String BUNDLE_PROPERTY_TYPE = "bundleProperty"; //$NON-NLS-1$
+ static String BEAN_PROPERTY_TYPE = "beanProperty"; //$NON-NLS-1$
+ static String BEAN_METHOD_BY_SYGNATURE_TYPE = "beanMethodBySignature";
//$NON-NLS-1$
+ static String JSP_PATH_TYPE = "jspPath"; //$NON-NLS-1$
+ static String JSF_VARIABLES_TYPE = "jsfVariables"; //$NON-NLS-1$
+ static String MANAGED_BEAN_NAME_TYPE = "managedBeanName"; //$NON-NLS-1$
+ static String JSF_ID = "jsfID"; //$NON-NLS-1$
+
private static AttributeValueResourceFactory INSTANCE = new
AttributeValueResourceFactory();
private AttributeValueResourceFactory() {
@@ -36,21 +50,21 @@
}
public AttributeValueResource createResource(IEditorInput editorInput, IPageContext
pageContext, String name, ModelElement root, String type) {
- if(KbDinamicResource.BEAN_PROPERTY_TYPE.equals(type)) {
+ if(BEAN_PROPERTY_TYPE.equals(type)) {
return new ManagedBeansPropertiesResourceElement(editorInput, name, root);
- } else if(KbDinamicResource.BEAN_METHOD_BY_SYGNATURE_TYPE.equals(type)) {
+ } else if(BEAN_METHOD_BY_SYGNATURE_TYPE.equals(type)) {
return new ManagedBeanMethodResourceElement(editorInput, name, root);
- } else if(KbDinamicResource.BUNDLE_NAME_TYPE.equals(type)) {
+ } else if(BUNDLE_NAME_TYPE.equals(type)) {
return new BundlesNameResourceElement(editorInput, name, root);
- } else if(KbDinamicResource.BUNDLE_PROPERTY_TYPE.equals(type)) {
+ } else if(BUNDLE_PROPERTY_TYPE.equals(type)) {
return new BundlesPropertiesResourceElement(editorInput, pageContext, name, root);
- } else if(KbDinamicResource.VIEW_ACTIONS_TYPE.equals(type)) {
+ } else if(VIEW_ACTIONS_TYPE.equals(type)) {
return new ViewActionsResorceElement(editorInput, name, root);
- } else if(KbDinamicResource.ENUMERATION_TYPE.equals(type)) {
+ } else if(ENUMERATION_TYPE.equals(type)) {
return new EnumerationResourceElement(name, root);
- } else if(KbDinamicResource.JSF_VARIABLES_TYPE.equals(type)) {
+ } else if(JSF_VARIABLES_TYPE.equals(type)) {
return new JsfVariablesResourceElement(name, root);
- } else if(KbDinamicResource.IMAGE_FILE_TYPE.equals(type)) {
+ } else if(IMAGE_FILE_TYPE.equals(type)) {
return new ImageFileResourceElement(editorInput, root);
} else if("seamVariables".equals(type)) { //$NON-NLS-1$
return new SeamVariablesResourceElement(editorInput, "Seam Variables",
root); //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2009-07-24
13:55:30 UTC (rev 16767)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2009-07-24
13:56:47 UTC (rev 16768)
@@ -33,6 +33,7 @@
import org.eclipse.wst.html.ui.internal.contentoutline.HTMLNodeActionManager;
import org.eclipse.wst.html.ui.views.contentoutline.HTMLContentOutlineConfiguration;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
@@ -40,13 +41,20 @@
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
-import org.jboss.tools.common.kb.AttributeDescriptor;
-import org.jboss.tools.common.kb.TagDescriptor;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.IViewerDropAdapterFactory;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageProcessor;
+import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibComponent;
+import org.jboss.tools.jst.web.kb.taglib.IAttribute;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibComponent;
import org.osgi.framework.Bundle;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -166,13 +174,29 @@
} else {
List modelQueryActionList = new ArrayList();
+ JspContentAssistProcessor processor = valueHelper.createContentAssistProcessor();
+ int offset = 0;
+ if(element instanceof IndexedRegion) {
+ offset = ((IndexedRegion)element).getStartOffset() + 1;
+ }
+ IPageContext pageContext = valueHelper.createPageContext(processor, offset);
+ KbQuery kbQuery = createKbQuery(processor, element, offset);
+ IComponent[] components = PageProcessor.getInstance().getComponents(kbQuery,
pageContext, true);
+ IComponent d = null;
+ for (IComponent c: components) {
+ if(c instanceof ICustomTagLibComponent) {
+ d = c;
+ break;
+ }
+ }
+ if(d == null && components.length > 0) d = components[0];
+
+
String query = "/" + element.getNodeName(); //$NON-NLS-1$
- //TODO replace TagDescriptor with Component
- TagDescriptor d = valueHelper.getTagDescriptor(query);
+
if(d != null) {
- List as = d.getAttributesDescriptors();
- for (int i = 0; i < as.size(); i++) {
- AttributeDescriptor a = (AttributeDescriptor)as.get(i);
+ IAttribute[] as = d.getAttributes();
+ for (IAttribute a: as) {
String attribute = a.getName();
if(element.hasAttribute(attribute)) continue;
HTMLAttrDeclImpl ad = new HTMLAttrDeclImpl(attribute, new
HTMLCMDataTypeImpl(attribute), 0);
@@ -198,6 +222,36 @@
};
}
+ protected KbQuery createKbQuery(JspContentAssistProcessor processor, Node fNode, int
offset) {
+ KbQuery kbQuery = new KbQuery();
+
+ String[] parentTags = processor.getParentTags(false);
+ parentTags = add(parentTags, fNode.getNodeName());
+ String prefix = getPrefix(fNode);
+ kbQuery.setPrefix(prefix);
+ kbQuery.setUri(processor.getUri(prefix));
+ kbQuery.setParentTags(parentTags);
+ kbQuery.setParent(fNode.getNodeName());
+ kbQuery.setMask(false);
+ kbQuery.setType(Type.ATTRIBUTE_NAME);
+ kbQuery.setOffset(offset);
+ kbQuery.setValue("");
+ kbQuery.setStringQuery("");
+
+ return kbQuery;
+ }
+ private String[] add(String[] result, String v) {
+ String[] result1 = new String[result.length + 1];
+ System.arraycopy(result, 0, result1, 0, result.length);
+ result1[result.length] = v;
+ return result1;
+ }
+ private String getPrefix(Node fNode) {
+ int i = fNode.getNodeName().indexOf(':');
+ return i < 0 ? null : fNode.getNodeName().substring(0, i);
+ }
+
+
public static class OutlineTransferDropTargetListener implements
TransferDropTargetListener {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-07-24
13:55:30 UTC (rev 16767)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-07-24
13:56:47 UTC (rev 16768)
@@ -20,7 +20,6 @@
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IControlContentAdapter;
import org.eclipse.jface.fieldassist.TextContentAdapter;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
@@ -33,7 +32,6 @@
import org.jboss.tools.common.model.ui.attribute.editor.DialogCellEditorEx;
import org.jboss.tools.common.model.ui.objecteditor.AttributeWrapper;
import org.jboss.tools.common.model.ui.objecteditor.ExtendedCellEditorProvider;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogContentProposalProvider;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSStyleDialog;
@@ -107,16 +105,16 @@
String attributeName = Constants.EMPTY +
context.getProperty("attributeName"); //$NON-NLS-1$
String nodeName = Constants.EMPTY + context.getProperty("nodeName");
//$NON-NLS-1$
- String query = Constants.SLASH;
+// String query = Constants.SLASH;
ValueHelper valueHelper = new ValueHelper();
- if ((valueHelper != null) && valueHelper.isFacetets() &&
(nodeName.indexOf(Constants.COLON) < 0)) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
- }
+// if ((valueHelper != null) && valueHelper.isFacetets() &&
(nodeName.indexOf(Constants.COLON) < 0)) {
+// query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+// }
- query += (nodeName + "@" + attributeName); //$NON-NLS-1$
- context.setProperty("query", query); //$NON-NLS-1$
- context.setProperty("help", query); //$NON-NLS-1$
+// query += (nodeName + "@" + attributeName); //$NON-NLS-1$
+// context.setProperty("query", query); //$NON-NLS-1$
+// context.setProperty("help", query); //$NON-NLS-1$
context.setProperty("title",
MessageFormat.format(JstUIMessages.JSPDialogCellEditor_EditAttribute,
WizardKeys.toDisplayName(attributeName))); //$NON-NLS-1$
context.setProperty("subtitle", "<" +
context.getProperty("nodeName") + ">"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2009-07-24
13:55:30 UTC (rev 16767)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2009-07-24
13:56:47 UTC (rev 16768)
@@ -23,12 +23,10 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.common.kb.TagDescriptor;
import org.jboss.tools.common.model.project.IPromptingProvider;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.jst.jsp.contentassist.FaceletPageContectAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResourceFactory;
@@ -53,6 +51,8 @@
import org.w3c.dom.Node;
public class ValueHelper {
+ public static final String faceletUri = "http://java.sun.com/jsf/facelets";
//$NON-NLS-1$
+ public static final String JSFCAttributeName = "jsfc"; //$NON-NLS-1$
private boolean isFacelets = false;
@@ -154,12 +154,6 @@
return (root != null && root.getChildren().length > 0);
}
- @Deprecated
- public TagDescriptor getTagDescriptor(String query) {
- if(!init()) return null;
- return null;
- }
-
public IEditorInput getEditorInput() {
IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
return editor.getEditorInput();
@@ -215,7 +209,7 @@
isFacelets = false;
for(int i = 0; i < list.size(); i++) {
TaglibData data = list.get(i);
- isFacelets = isFacelets ||
data.getUri().equals(FaceletsHtmlContentAssistProcessor.faceletUri);
+ isFacelets = isFacelets || data.getUri().equals(faceletUri);
}
}
@@ -225,7 +219,7 @@
if(name.indexOf(':') >= 0) return null;
NamedNodeMap attributes = element.getAttributes();
- Node jsfC =
attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
+ Node jsfC = attributes.getNamedItem(JSFCAttributeName);
if(jsfC != null && (jsfC instanceof Attr)) {
Attr jsfCAttribute = (Attr)jsfC;
String jsfTagName = jsfCAttribute.getValue();