JBoss Tools SVN: r16776 - trunk/jst/plugins/org.jboss.tools.jst.web.tiles.ui/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 11:31:34 -0400 (Fri, 24 Jul 2009)
New Revision: 16776
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.tiles.ui/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.tiles.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.tiles.ui/META-INF/MANIFEST.MF 2009-07-24 15:29:04 UTC (rev 16775)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.tiles.ui/META-INF/MANIFEST.MF 2009-07-24 15:31:34 UTC (rev 16776)
@@ -40,7 +40,6 @@
org.eclipse.jdt.ui,
org.jboss.tools.common.text.xml,
org.eclipse.debug.core,
- org.jboss.tools.common.kb,
org.eclipse.wst.xml.ui,
org.eclipse.wst.sse.ui,
org.eclipse.core.resources,
16 years, 8 months
JBoss Tools SVN: r16775 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 11:29:04 -0400 (Fri, 24 Jul 2009)
New Revision: 16775
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2009-07-24 15:13:26 UTC (rev 16774)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2009-07-24 15:29:04 UTC (rev 16775)
@@ -37,7 +37,6 @@
org.eclipse.ui.editors,
org.jboss.tools.common.model,
org.jboss.tools.common.model.ui,
- org.jboss.tools.common.kb,
org.jboss.tools.jst.web,
org.eclipse.jface,
org.eclipse.ui,
16 years, 8 months
JBoss Tools SVN: r16774 - trunk/jst/plugins/org.jboss.tools.jst.web/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 11:13:26 -0400 (Fri, 24 Jul 2009)
New Revision: 16774
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2009-07-24 15:06:59 UTC (rev 16773)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2009-07-24 15:13:26 UTC (rev 16774)
@@ -33,7 +33,6 @@
org.eclipse.core.runtime,
org.eclipse.ant.ui,
org.eclipse.ui.externaltools,
- org.jboss.tools.common.kb,
org.eclipse.wst.common.project.facet.core,
org.jboss.tools.common.el.core;bundle-version="2.0.0"
Bundle-Version: 2.0.0
16 years, 8 months
JBoss Tools SVN: r16773 - trunk/struts/plugins/org.jboss.tools.struts.ui/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 11:06:59 -0400 (Fri, 24 Jul 2009)
New Revision: 16773
Modified:
trunk/struts/plugins/org.jboss.tools.struts.ui/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/struts/plugins/org.jboss.tools.struts.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.ui/META-INF/MANIFEST.MF 2009-07-24 14:55:48 UTC (rev 16772)
+++ trunk/struts/plugins/org.jboss.tools.struts.ui/META-INF/MANIFEST.MF 2009-07-24 15:06:59 UTC (rev 16773)
@@ -56,7 +56,6 @@
org.jboss.tools.common.model.ui,
org.jboss.tools.common.text.xml,
org.eclipse.debug.core,
- org.jboss.tools.common.kb,
org.eclipse.wst.sse.ui,
org.eclipse.wst.xml.ui,
org.eclipse.core.resources,
16 years, 8 months
JBoss Tools SVN: r16772 - trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 10:55:48 -0400 (Fri, 24 Jul 2009)
New Revision: 16772
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2009-07-24 14:41:41 UTC (rev 16771)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2009-07-24 14:55:48 UTC (rev 16772)
@@ -85,7 +85,6 @@
org.jboss.tools.common.propertieseditor.bundlemodel,
org.jboss.tools.common.propertieseditor.text
Require-Bundle: org.jboss.tools.common.model;visibility:=reexport,
- org.jboss.tools.common.kb;visibility:=reexport,
org.jboss.tools.common.text.ext;visibility:=reexport,
org.jboss.tools.common.text.xml;visibility:=reexport,
org.jboss.tools.common.gef;visibility:=reexport,
16 years, 8 months
JBoss Tools SVN: r16771 - trunk/struts/plugins/org.jboss.tools.struts.validator.ui/META-INF.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 10:41:41 -0400 (Fri, 24 Jul 2009)
New Revision: 16771
Modified:
trunk/struts/plugins/org.jboss.tools.struts.validator.ui/META-INF/MANIFEST.MF
Log:
JBIDE-1826
Dependency on old kb plugin removed.
Modified: trunk/struts/plugins/org.jboss.tools.struts.validator.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.validator.ui/META-INF/MANIFEST.MF 2009-07-24 14:37:15 UTC (rev 16770)
+++ trunk/struts/plugins/org.jboss.tools.struts.validator.ui/META-INF/MANIFEST.MF 2009-07-24 14:41:41 UTC (rev 16771)
@@ -14,7 +14,6 @@
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui,
org.jboss.tools.common.model,
- org.jboss.tools.common.kb,
org.jboss.tools.common.model.ui,
org.jboss.tools.jst.web,
org.jboss.tools.struts,
@@ -29,5 +28,5 @@
org.eclipse.core.resources,
org.eclipse.core.runtime
Bundle-Version: 2.0.0
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
16 years, 8 months
JBoss Tools SVN: r16770 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/template/expression and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 10:37:15 -0400 (Fri, 24 Jul 2009)
New Revision: 16770
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
Log:
JBIDE-1826
Depemdency on old kb plugin removed.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-07-24 14:34:58 UTC (rev 16769)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-07-24 14:37:15 UTC (rev 16770)
@@ -46,7 +46,6 @@
org.jboss.tools.common.model,
org.jboss.tools.jst.jsp,
org.jboss.tools.jst.web,
- org.jboss.tools.common.kb,
org.eclipse.wst.sse.core,
org.eclipse.jst.jsp.ui,
org.eclipse.wst.sse.ui,
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-07-24 14:34:58 UTC (rev 16769)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-07-24 14:37:15 UTC (rev 16770)
@@ -277,8 +277,9 @@
String[] parentTags = processor.getParentTags(false);
parentTags = add(parentTags, fNode.getNodeName());
- kbQuery.setPrefix(getPrefix(fNode));
- kbQuery.setUri(processor.getUri(getPrefix()));
+ String prefix = getPrefix(fNode);
+ kbQuery.setPrefix(prefix);
+ kbQuery.setUri(processor.getUri(prefix));
kbQuery.setParentTags(parentTags);
kbQuery.setParent(fNode.getNodeName());
kbQuery.setMask(false);
16 years, 8 months
JBoss Tools SVN: r16769 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: editor and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 10:34:58 -0400 (Fri, 24 Jul 2009)
New Revision: 16769
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanMethodResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundlePropertyResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdManagedBeanNameResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java
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/JSPPropertySourceAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java
Log:
JBIDE-1826
Obsolete classes using old kb removed.
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,701 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
-import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
-import org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor;
-import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-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;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistUtilities;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.TagDescriptor;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.tld.TLDVersionHelper;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @author Igels
- */
-public class ExtendedJSPContentAssistProcessor extends JSPContentAssistProcessor{
-
- private JSPActiveContentAssistProcessor jspActiveCAP;
- private WtpKbConnector wtpKbConnector;
- private IDocument document;
- private boolean dontOpenTag = false;
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) {
- try {
- String text = viewer.getDocument().get(0, documentPosition);
- int lastOpenTag = text.lastIndexOf('<');
- int lastCloseTag = text.lastIndexOf('>');
- dontOpenTag = lastCloseTag<lastOpenTag;
- } catch (BadLocationException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
-
- if(this.document != viewer.getDocument()) {
- wtpKbConnector = null;
- }
- document = viewer.getDocument();
- //added by Max Areshkau JBIDE-788
- updateActiveContentAssistProcessor(document);
- ICompletionProposal[] proposals = super.computeCompletionProposals(viewer, documentPosition);
- // If proposal list from super is empty to try to get it from Red Hat dinamic jsp content assist processor.
- if(proposals.length == 0) {
- String partitionType = getPartitionType((StructuredTextViewer) viewer, documentPosition);
- IContentAssistProcessor p = (IContentAssistProcessor) fPartitionToProcessorMap.get(partitionType);
- if (!(p instanceof CSSContentAssistProcessor)) {
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, documentPosition);
- Node node = (Node) treeNode;
-
- while (node != null && node.getNodeType() == Node.TEXT_NODE && node.getParentNode() != null)
- node = node.getParentNode();
- IDOMNode xmlnode = (IDOMNode) node;
- if(xmlnode!=null) {
- fTextViewer = viewer;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
- if(completionRegion!=null) {
- String matchString = getMatchString(sdRegion, completionRegion, documentPosition);
- ContentAssistRequest contentAssistRequest = computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode);
- if(contentAssistRequest!=null) {
- proposals = contentAssistRequest.getCompletionProposals();
- }
- }
- }
- }
- }
- proposals = getUniqProposals(proposals);
- return proposals;
- }
-
- public static ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
- ArrayList uniqProposals = new ArrayList(proposals.length);
- HashSet displayStrings = new HashSet(proposals.length);
- for(int i=0; i<proposals.length; i++) {
- String str = proposals[i].getDisplayString();
- if(str==null || !displayStrings.contains(str)) {
- displayStrings.add(str);
- uniqProposals.add(proposals[i]);
- }
- }
- return (ICompletionProposal[])uniqProposals.toArray(new ICompletionProposal[uniqProposals.size()]);
- }
-
- /**
- * int map that points [partition > processor]. This takes place of
- * embedded adapters for now.
- */
- protected void initPartitionToProcessorMap() {
- super.initPartitionToProcessorMap();
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- char[] autoActivChars = null;
- char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
- if(superAutoActivChars==null) {
- return superAutoActivChars;
- }
-
- autoActivChars = superAutoActivChars;
- IPreferenceStore store = JSPUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
-// String superDefaultChars = store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
- if(redhatDefaultChars.indexOf(".")<0) { //$NON-NLS-1$
- redhatDefaultChars.append('.');
- redhatDefaultChars.append('[');
- store.setDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- store.setValue(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
- }
-
- return autoActivChars;
- }
-
- public void updateActiveContentAssistProcessor(IDocument document) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if (manager != null) {
- List list = manager.getTaglibTrackers();
- for(int i=0; i<list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
-
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "", tracker.getPrefix(), version); //$NON-NLS-1$
- getWtpKbConnector().registerResource(resource);
- addActiveContentAssistProcessorToProcessorMap(tracker.getURI(), tracker.getPrefix(), version);
- }
- }
- }
-
- private void addActiveContentAssistProcessorToProcessorMap(String uri, String prefix, String version) {
- try {
- List names = getWtpKbConnector().getAllTagNamesFromTldByUri(uri, version);
- for(Iterator iter = names.iterator(); iter.hasNext();) {
- String fullName = prefix + ":" + iter.next(); //$NON-NLS-1$
- fNameToProcessorMap.put(fullName, jspActiveCAP);
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
-
- private WtpKbConnector getWtpKbConnector() {
- if(wtpKbConnector == null && document != null) {
- try {
- wtpKbConnector = (WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR, document);
- jspActiveCAP.setKbConnector(wtpKbConnector);
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- return wtpKbConnector;
- }
-
- protected void init() {
- super.init();
- jspActiveCAP = new JSPActiveContentAssistProcessor();
- jspActiveCAP.init();
- }
-
- public XMLContentModelGenerator getContentGenerator() {
- if (fGenerator == null){
- fGenerator = new XMLContentModelGenerator(){
- public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (elementDecl == null || buffer == null) {
- return;
- }
- try {
- String tagName = getRequiredName(parent, elementDecl);
- TagDescriptor info = getWtpKbConnector().getTagInformation("/" + tagName + "/"); //$NON-NLS-1$ //$NON-NLS-2$
- if (info != null) {
- KbProposal proposal = info.generateProposal();
- String replString = proposal.getReplacementString();
- boolean hasBody = info.hasBody();
-
- if (replString != null && replString.length() > 0) {
- if(!dontOpenTag) {
- buffer.append("<"); //$NON-NLS-1$
- }
- buffer.append(replString);
- buffer.append(">"); //$NON-NLS-1$
- if (hasBody) {
- buffer.append("</"); //$NON-NLS-1$
- buffer.append(tagName);
- buffer.append(">"); //$NON-NLS-1$
- }
- return;
- }
- }
- } catch (KbException x) {
- JspEditorPlugin.getPluginLog().logError("", x); //$NON-NLS-1$
- }
- super.generateTag(parent, elementDecl, buffer);
- return;
- }
- };
- }
- return fGenerator;
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- String error = null;
-
- if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) {
- return;
- }
- // only want proposals if cursor is after doctype...
- if (!isCursorAfterDoctype(contentAssistRequest))
- return;
-
- if (parent != null && parent instanceof IDOMNode && isCommentNode((IDOMNode) parent)) {
- // loop and find non comment node?
- while (parent != null && isCommentNode((IDOMNode) parent)) {
- parent = parent.getParentNode();
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- // XSD-specific ability - no filtering
- CMDataType childType = parentDecl.getDataType();
- if (childType != null) {
- String[] childStrings = childType.getEnumeratedValues();
- if (childStrings != null) {
- // the content string is the sole valid child...so
- // replace the rest
- int begin = contentAssistRequest.getReplacementBeginPosition();
- int length = contentAssistRequest.getReplacementLength();
- if (parent instanceof IDOMNode) {
- if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode) parent).getFirstStructuredDocumentRegion()) {
- begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
- length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() - begin;
- }
- }
- String proposedInfo = getAdditionalInfo(parentDecl, childType);
- for (int i = 0; i < childStrings.length; i++) {
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM);
- CustomCompletionProposal textProposal = new AutoContentAssistantProposal(childStrings[i].indexOf("=")>-1, childStrings[i], begin, length, childStrings[i].length(), image, childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION); //$NON-NLS-1$
- contentAssistRequest.addProposal(textProposal);
- }
- }
- }
- }
- if (parentDecl != null && parentDecl.getContentType() == CMElementDeclaration.PCDATA) {
- addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
- }
- else {
- // retrieve the list of all possible children within this parent context
- cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
-
- // retrieve the list of the possible children within this parent context and at this index
- List strictCMNodeSuggestions = null;
- if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY)))
- {
- strictCMNodeSuggestions = getValidChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
- }
- Iterator nodeIterator = cmnodes.iterator();
- if (!nodeIterator.hasNext()) {
- if (getCMElementDeclaration(parent) != null)
- error = NLS.bind(XMLUIMessages._Has_no_available_child, (new Object[]{parent.getNodeName()}));
- else
- error = NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{parent.getNodeName()}));
- }
- String matchString = contentAssistRequest.getMatchString();
- // chop off any leading <'s and whitespace from the
- // matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- while (nodeIterator.hasNext()) {
- Object o = nodeIterator.next();
- if (o instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) o;
- // only add proposals for the child element's that
- // begin with the matchstring
- String tagname = getRequiredName(parent, elementDecl);
- boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;
-
- Image image = CMImageUtil.getImage(elementDecl);
-
- if (image == null) {
- if (strictCMNodeSuggestions != null) {
- image = isStrictCMNodeSuggestion ?
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED) :
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED);
- }
- else {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- }
- // Account for the < and >. If attributes were
- // added, the cursor will be placed
- // at the offset before of the first character of the
- // first attribute name.
-// int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, elementDecl);
- if (beginsWith(tagname, matchString)) {
- String proposedText = getRequiredText(parent, elementDecl);
-
- int markupAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
- int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION;
- CustomCompletionProposal proposal = new AutoContentAssistantProposal(true, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"."
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- // Can only prompt with elements if the cursor position is past
- // the XML processing
- // instruction and DOCTYPE declaration
- boolean xmlpiFound = false;
- boolean doctypeFound = false;
- int minimumOffset = -1;
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
-
- boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$
- boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
- if (xmlpi || doctype && minimumOffset < 0)
- minimumOffset = ((IDOMNode) child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode) child).getFirstStructuredDocumentRegion().getTextLength();
- xmlpiFound = xmlpiFound || xmlpi;
- doctypeFound = doctypeFound || doctype;
- }
-
- if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
- List childDecls = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childDecls.size(); i++) {
- CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
- if (ed != null) {
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedText = getRequiredText(parent, ed);
- String tagname = getRequiredName(parent, ed);
- // account for the < and >
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
- String proposedInfo = getAdditionalInfo(null, ed);
- CustomCompletionProposal proposal = new AutoContentAssistantProposal(false, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- // WTP
- private int getCursorPositionForProposedText(String proposedText) {
- int cursorAdjustment;
- cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
- // otherwise, after the first tag
- if(cursorAdjustment==0)
- cursorAdjustment = proposedText.indexOf('>') + 1;
- if(cursorAdjustment==0)
- cursorAdjustment = proposedText.length() + 1;
-
- return cursorAdjustment;
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String error = null;
- String matchString = contentAssistRequest.getMatchString();
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- // retrieve the list of children
- cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
- Iterator nodeIterator = cmnodes.iterator();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- if (!nodeIterator.hasNext())
- error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
- while (nodeIterator.hasNext()) {
- CMNode elementDecl = (CMNode) nodeIterator.next();
- if (elementDecl != null) {
- // only add proposals for the child element's that begin
- // with the matchstring
- String proposedText = null;
- int cursorAdjustment = 0;
-
- // do a check to see if partial attributes of partial tag
- // names are in list
- if ((node != null && node.getAttributes() != null && node.getAttributes().getLength() > 0 && attributeInList(node, parent, elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) {
-
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- else {
- proposedText = getRequiredName(parent, elementDecl);
-
- StringBuffer buffer = new StringBuffer();
- KbProposal proposal;
- TagDescriptor info;
- try {
- proposal = getWtpKbConnector().getProposal("/" + proposedText); //$NON-NLS-1$
- info = getWtpKbConnector().getTagInformation("/" + proposedText + "/"); //$NON-NLS-1$ //$NON-NLS-2$
- if (proposal != null && info != null) {
- String replString = proposal.getReplacementString();
- boolean hasBody = info.hasBody();
-
- if (replString != null && replString.length() > 0) {
- if(!dontOpenTag) {
- buffer.append("<"); //$NON-NLS-1$
- }
- buffer.append(replString);
- buffer.append(">"); //$NON-NLS-1$
- if (hasBody) {
- buffer.append("</"); //$NON-NLS-1$
- buffer.append(proposedText);
- buffer.append(">"); //$NON-NLS-1$
- }
- proposedText = buffer.toString();
- }
- } else {
- if(elementDecl instanceof CMElementDeclaration) {
- cursorAdjustment = proposedText.length();
- if (elementDecl instanceof CMElementDeclaration) {
- CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- if (ed.getContentType() == CMElementDeclaration.EMPTY) {
- proposedText += getContentGenerator().getStartTagClose(parent, ed);
- cursorAdjustment = proposedText.length();
- }
- else {
- cursorAdjustment = proposedText.length() + 1;
- proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- if (beginsWith(proposedText, matchString) || beginsWith(proposedText, "<" + matchString)) { //$NON-NLS-1$
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
- CustomCompletionProposal proposal = new AutoContentAssistantProposal(proposedText.indexOf('\"')>-1 && proposedText.indexOf("=")>-1, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, elementDecl), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME); //$NON-NLS-1$
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\""
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- List childElements = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childElements.size(); i++) {
- CMNode ed = (CMNode) childElements.get(i);
- if (ed == null)
- continue;
- String proposedText = null;
- int cursorAdjustment = 0;
- if(ed instanceof CMElementDeclaration) {
- // proposedText = getRequiredName(parent, ed);
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, (CMElementDeclaration)ed, sb);
- // tag starts w/ '<', but we want to compare to name
- proposedText = sb.toString().substring(1);
-
- if (!beginsWith(proposedText, matchString))
- continue;
-
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
-
- if (ed instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) ed;
- if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
- proposedText += getContentGenerator().getStartTagClose(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- }
-
- String proposedInfo = getAdditionalInfo(null, ed);
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- CustomCompletionProposal proposal = new AutoContentAssistantProposal(proposedText.indexOf('\"')>-1, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
-
- private boolean isCommentNode(IDOMNode node) {
- return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
-
- // JBIDE-1717 Workaround:
- // The WTP processes the Attribute Containers in a different way comparing to how it does for
- // the simple attributes.
- // Also the whitespace-text placed after the attribute value is the part of that attribute value.
- // These facts both are the reason of the JBIDE-1717 issue appeared.
- // This workaround tries to add the attribute name proposals in case of WTP itself doesn't adds them
- // because it faced the attribute container (In other words, some JSF-variable is used as the
- // attribute's value
- if (fViewer != null) {
- int documentPosition = contentAssistRequest.getReplacementBeginPosition();
- // check the actual partition type
- String partitionType = getPartitionType((StructuredTextViewer) fViewer, documentPosition);
-
- IStructuredDocument structuredDocument = (IStructuredDocument) fViewer.getDocument();
- IStructuredDocumentRegion fn = structuredDocument.getRegionAtCharacterOffset(documentPosition);
- // check if it's in an attribute value, if so, don't add CDATA
- // proposal
- ITextRegion attrContainer = (fn != null) ? fn.getRegionAtCharacterOffset(documentPosition) : null;
- boolean doPerformProposalsComputing = false;
-
- if (attrContainer != null && attrContainer instanceof ITextRegionContainer) {
- if (attrContainer.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- // test location of the cursor
- // return null if it's in the middle of an open/close
- // delimeter
- Iterator attrRegions = ((ITextRegionContainer) attrContainer).getRegions().iterator();
- ITextRegion testRegion = null;
- while (attrRegions.hasNext()) {
- testRegion = (ITextRegion) attrRegions.next();
- // need to check for other valid attribute regions
- if (XMLContentAssistUtilities.isJSPOpenDelimiter(testRegion.getType())) {
- if (!(((ITextRegionContainer) attrContainer).getEndOffset(testRegion) <= documentPosition))
- break;
- }
- else if (XMLContentAssistUtilities.isJSPCloseDelimiter(testRegion.getType())) {
- if (!(((ITextRegionContainer) attrContainer).getStartOffset(testRegion) >= documentPosition))
- break;
- }
- }
- if (!(testRegion.getType().equals(DOMJSPRegionContexts.JSP_CONTENT)))
- doPerformProposalsComputing = true;
- }
- }
- //
-
- if (doPerformProposalsComputing) {
- ICompletionProposal[] embeddedResults = null;
- IContentAssistProcessor p = (IContentAssistProcessor) fPartitionToProcessorMap.get(partitionType);
- if (p != null) {
- embeddedResults = p.computeCompletionProposals(fViewer, documentPosition);
- // TODO: Probably it's needed to get bean methods, objects, and constants if there are any...
- // as it's done in JSPContentAssistProcessor but...
- }
- else {
- // the partition type is probably not mapped
- }
- for (int i = 0; embeddedResults != null && i < embeddedResults.length; i++)
- contentAssistRequest.addProposal(embeddedResults[i]);
- }
- }
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // JBIDE-1704:
- // Check the position in the value:
- // The following position:
- // <nodeName attrName="attrValue"| .../>
- // is marked as attribute value, but the value itself is complete.
- // There are no proposals to be correct at this position.
-
- String text = contentAssistRequest.getText();
- String matchString = contentAssistRequest.getMatchString();
-
- if (matchString.length() > StringUtils.strip(text).length() &&
- ( (matchString.startsWith("\"") && matchString.endsWith("\"") && //$NON-NLS-1$ //$NON-NLS-2$
- (matchString.indexOf("\"") != matchString.lastIndexOf("\""))) //$NON-NLS-1$ //$NON-NLS-2$
- || (matchString.startsWith("'") && matchString.endsWith("\"") && //$NON-NLS-1$ //$NON-NLS-2$
- (matchString.indexOf("\"") != matchString.lastIndexOf("\""))))) { //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- ITextRegion region = (sdRegion == null ? null : sdRegion.getRegionAtCharacterOffset(pos));
- if (region == null) {
- return null;
- }
-
- if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
- sdRegion.getStartOffset(region) == pos) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- sdRegion = sdRegion.getPrevious();
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
- sdRegion = sdRegion.getPrevious();
- }
- }
- }
-
- return sdRegion;
- }
-
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,812 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
-import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor;
-import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELUtil;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.kb.AttributeDescriptor;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbQuery;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
-import org.jboss.tools.jst.jsp.outline.ValueHelper;
-import org.jboss.tools.jst.jsp.support.kb.FaceletsJsfCResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbJsfValuesResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanMethodResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanPropertyResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBundlePropertyResource;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.tld.TLDVersionHelper;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author Igels
- */
-public class FaceletsHtmlContentAssistProcessor extends HTMLContentAssistProcessor implements VpeTaglibListener {
-
- private JSPActiveContentAssistProcessor jspActiveCAP;
- private WtpKbConnector wtpKbConnector;
- private IDocument document;
- private IEditorInput editorInput;
- private VpeTaglibManager tldManager;
- private boolean isFacelets = false;
- public static final String faceletUri = "http://java.sun.com/jsf/facelets"; //$NON-NLS-1$
- public static final String faceletHtmlUri = "http://www.w3.org/1999/xhtml/facelets"; //$NON-NLS-1$
- public static final String faceletHtmlPrefix = "0fHP"; //$NON-NLS-1$
- public static final String JSFCAttributeName = "jsfc"; //$NON-NLS-1$
- public static final String faceletHtmlPrefixStart = faceletHtmlPrefix + ":"; //$NON-NLS-1$
- //Added by Max Areshkau JBIDE-788
- public static final KbTldResource faceletHtmlResource = new KbTldResource(faceletHtmlUri, "", faceletHtmlPrefix, null); //$NON-NLS-1$
-
- public FaceletsHtmlContentAssistProcessor() {}
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
- if(this.document != textViewer.getDocument()) {
- wtpKbConnector = null;
- }
- document = textViewer.getDocument();
- editorInput = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
- //added by Max Areshkau JBIDE-788
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition);
- IDOMNode node = (IDOMNode) treeNode;
- registerToTldManager(textViewer, node);
-
- ICompletionProposal[] proposals = super.computeCompletionProposals(textViewer, documentPosition);
- if(proposals!=null) {
- for(int i=0; i<proposals.length; i++) {
- if(proposals[i] instanceof AutoContentAssistantProposal) {
- fErrorMessage = null;
- break;
- }
- }
- }
- if(isFacelets) {
- return getUniqProposals(proposals);
- }
- proposals = getUniqProposals(proposals);
- return proposals;
- }
-
- static ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
- if(proposals==null) {
- return null;
- }
- HashMap<String, ICompletionProposal> uniqProposals = new HashMap<String, ICompletionProposal>(proposals.length);
- ArrayList<ICompletionProposal> uniqProposalList = new ArrayList<ICompletionProposal>(proposals.length);
- for(int i=0; i<proposals.length; i++) {
- String str = proposals[i].getDisplayString();
- if(str.startsWith("\"") && str.endsWith("\"") && str.length()>2) { //$NON-NLS-1$ //$NON-NLS-2$
- str = str.substring(0, str.length()-1).substring(1);
- }
- int eq = str.indexOf('=');
- if(eq>0) {
- str = str.substring(0, eq);
- }
- ICompletionProposal proposal = uniqProposals.get(str);
- if(proposal==null || proposals[i] instanceof AutoContentAssistantProposal) {
- uniqProposals.put(str, proposals[i]);
- uniqProposalList.add(proposals[i]);
- if(proposal!=null) {
- uniqProposalList.remove(proposal);
- }
- }
- }
- return (ICompletionProposal[])uniqProposalList.toArray(new ICompletionProposal[uniqProposals.size()]);
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- if(!addELFaceletsProposals(contentAssistRequest, childPosition)) {
- String request = "/" + contentAssistRequest.getMatchString(); //$NON-NLS-1$
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal) iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String kbReplacementString = kbProposal.getReplacementString();
- String replacementString = "<" + kbReplacementString + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- String displayString = kbProposal.getLabel();
- boolean autoContentAssistant = replacementString.indexOf('\"')>-1 && replacementString.indexOf("=")>-1; //$NON-NLS-1$
- int cursorAdjustment = replacementString.length();;
- if(!kbReplacementString.endsWith("/")) { //$NON-NLS-1$
- replacementString = replacementString + "</" + displayString + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(autoContentAssistant, replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- super.addTagInsertionProposals(contentAssistRequest, childPosition);
- }
- }
-
- private boolean addELFaceletsProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- if(isFacelets) {
- IDOMNode node = (IDOMNode)contentAssistRequest.getNode();
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if(i < 0) return false;
- String currentValue = contentAssistRequest.getText();
- int start = contentAssistRequest.getStartOffset();
- int offset = contentAssistRequest.getReplacementBeginPosition() - start;
- String matchString = currentValue.substring(0, offset);
- ValueHelper h = new ValueHelper();
- JspContentAssistProcessor processor = h.createContentAssistProcessor();
- IPageContext pageContext = h.createPageContext(processor, offset);
- IEditorInput input = h.getEditorInput();
- ArrayList proposals = new ArrayList();
- WTPKbdBeanPropertyResource r1 = new WTPKbdBeanPropertyResource(input);
- proposals.addAll(r1.queryProposal(matchString));
- WTPKbdBeanMethodResource r2 = new WTPKbdBeanMethodResource(input);
- proposals.addAll(r2.queryProposal(matchString));
- WTPKbdBundlePropertyResource r3 = new WTPKbdBundlePropertyResource(input, pageContext);
- proposals.addAll(r3.queryProposal(matchString));
- WTPKbJsfValuesResource r4 = new WTPKbJsfValuesResource(input);
- proposals.addAll(r4.queryProposal(matchString));
-
- int elStart = getELStartPosition(matchString);
- int elEnd = getELEndPosition(matchString, currentValue);
-
- for (Iterator iter = proposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- kbProposal.postProcess(currentValue, offset);
- int relevance = kbProposal.getRelevance();
- if(relevance==KbProposal.R_NONE) {
- relevance = KbProposal.R_XML_ATTRIBUTE_VALUE;
- }
-
- if(kbProposal.getStart() >= 0) {
- String replacementString = kbProposal.getReplacementString();
- String label = kbProposal.getLabel();
- int cursorPositionDelta = 0;
- if (elStart > -1) {
- replacementString = replacementString.substring(2);
- if (matchString.charAt(elStart) != label.charAt(0)) {
- label = matchString.charAt(elStart) + label.substring(1);
- }
- } else if (matchString.endsWith("#") || matchString.endsWith("$")) { //$NON-NLS-1$ //$NON-NLS-2$
- replacementString = replacementString.substring(1);
- cursorPositionDelta += 1;
- if (matchString.charAt(matchString.length() - 1) != label.charAt(0)) {
- label = matchString.charAt(matchString.length() - 1) + label.substring(1);
- }
- }
- if (elStart> -1 && elEnd > -1) {
- replacementString = replacementString.substring(0, replacementString.length() - 1);
- }
- int replacementBeginPosition = start + kbProposal.getStart();
- int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
-
- // JBIDE-3133: New icons for proposals in JSF/Seam Code Assist
- Image image = kbProposal.hasImage() ? kbProposal.getImage() :
- JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
-
- if (!replacementString.startsWith("#{") && !replacementString.startsWith("${")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (label.startsWith("#") || label.startsWith("$")) //$NON-NLS-1$ //$NON-NLS-2$
- label = label.substring(1);
- if (label.startsWith("{")) //$NON-NLS-1$
- label = label.substring(1);
- if (label.endsWith("}")) //$NON-NLS-1$
- label = label.substring(0, label.length() - 1);
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(), replacementString,
- replacementBeginPosition, replacementLength, cursorPosition,
- image,
- label, null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
- continue;
- } else {
- StringBuffer replacementStringBuffer = new StringBuffer(kbProposal.getReplacementString());
- int replacementBeginPosition = start;
- int replacementLength = 0;
- int cursorPositionDelta = 0;
- String replacementString = replacementStringBuffer.toString();
- String label = kbProposal.getLabel();
- if (elStart > -1) {
- replacementString = replacementString.substring(2);
- if (matchString.charAt(elStart) != label.charAt(0)) {
- label = matchString.charAt(elStart) + label.substring(1);
- }
- } else if (matchString.endsWith("#") || matchString.endsWith("$")) { //$NON-NLS-1$ //$NON-NLS-2$
- replacementString = replacementString.substring(1);
- cursorPositionDelta += 1;
- if (matchString.charAt(matchString.length() - 1) != label.charAt(0)) {
- label = matchString.charAt(matchString.length() - 1) + label.substring(1);
- }
- }
- if (elStart> -1 && elEnd > -1) {
- replacementString = replacementString.substring(0, replacementString.length() - 1);
- }
-
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
-
- // JBIDE-3133: New icons for proposals in JSF/Seam Code Assist
- Image image = kbProposal.hasImage() ? kbProposal.getImage() :
- JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
-
- if (!replacementString.startsWith("#{") && !replacementString.startsWith("${")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (label.startsWith("#") || label.startsWith("$")) //$NON-NLS-1$ //$NON-NLS-2$
- label = label.substring(1);
- if (label.startsWith("{")) //$NON-NLS-1$
- label = label.substring(1);
- if (label.endsWith("}")) //$NON-NLS-1$
- label = label.substring(0, label.length() - 1);
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(), replacementString,
- replacementBeginPosition, replacementLength, cursorPosition,
- image,
- label, null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- // No JBoss parser ?
- ELParser p = ELParserUtil.getDefaultFactory().createParser();
- ELModel model = p.parse(currentValue);
- ELInstance instance = ELUtil.findInstance(model, offset);
- if(instance != null && instance.getStartPosition() + 2 <= offset) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * Checks if the EL operand starting characters are present
- * @return
- */
- private int getELStartPosition(String matchString) {
- if (matchString == null || matchString.length() == 0)
- return -1;
-
- int offset = matchString.length();
-
- while (--offset >= 0) {
- if ('}' == matchString.charAt(offset))
- return -1;
-
- if ('"' == matchString.charAt(offset) || '\'' == matchString.charAt(offset)) {
- int backslashCount = 0;
- while ((offset - 1 - backslashCount) >= 0 && matchString.charAt(offset - 1 - backslashCount) == '\\') {
- backslashCount++;
- }
-
- if (backslashCount % 2 == 0)
- return -1;
- }
-
- if ('{' == matchString.charAt(offset) &&
- (offset - 1) >= 0 &&
- ('#' == matchString.charAt(offset - 1) ||
- '$' == matchString.charAt(offset - 1))) {
- return (offset - 1);
- }
- }
- return -1;
- }
-
- /*
- * Checks if the EL operand ending character is present
- * @return
- */
- private int getELEndPosition(String matchString, String currentValue) {
- if (matchString == null || matchString.length() == 0 ||
- currentValue == null || currentValue.length() == 0 ||
- currentValue.length() < matchString.length())
- return -1;
-
- String restOfCurrentValue = currentValue.substring(matchString.length());
- int offset = -1;
-
- char inQuotesChar = 0;
- while (++offset < restOfCurrentValue.length()) {
- if (inQuotesChar == 0) {
- if ('}' == restOfCurrentValue.charAt(offset))
- return matchString.length() + offset;
-
- if ('#' == restOfCurrentValue.charAt(offset))
- return -1;
-
- if ('"' == restOfCurrentValue.charAt(offset) ||
- '\'' == restOfCurrentValue.charAt(offset)) {
- inQuotesChar = restOfCurrentValue.charAt(offset);
- }
-
- if ('\\' == restOfCurrentValue.charAt(offset)) {
- int backslashCount = 1;
-
- while ((offset + backslashCount) < restOfCurrentValue.length() &&
- restOfCurrentValue.charAt(offset + backslashCount) == '\\') {
- backslashCount++;
- }
-
- if (offset + backslashCount >= restOfCurrentValue.length())
- return -1;
-
- if (backslashCount % 2 == 1 &&
- ('"' == restOfCurrentValue.charAt(offset + backslashCount) ||
- '\'' == restOfCurrentValue.charAt(offset + backslashCount))) {
- inQuotesChar = restOfCurrentValue.charAt(offset + backslashCount);
- offset += backslashCount;
- }
- }
- } else {
- if ('"' == restOfCurrentValue.charAt(offset) ||
- '\'' == restOfCurrentValue.charAt(offset)) {
- inQuotesChar = 0;
- }
-
- if ('\\' == restOfCurrentValue.charAt(offset)) {
- int backslashCount = 1;
-
- while ((offset + backslashCount) < restOfCurrentValue.length() &&
- restOfCurrentValue.charAt(offset + backslashCount) == '\\') {
- backslashCount++;
- }
-
- if (offset + backslashCount >= restOfCurrentValue.length())
- return -1;
-
- if (backslashCount % 2 == 1 &&
- ('"' == restOfCurrentValue.charAt(offset + backslashCount) ||
- '\'' == restOfCurrentValue.charAt(offset + backslashCount))) {
- inQuotesChar = 0;
- offset += backslashCount;
- }
- }
- }
- }
- return -1;
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- Element element = (Element)contentAssistRequest.getNode();
- NamedNodeMap attributes = element.getAttributes();
-
- String tagName = element.getNodeName();
- if(isFacelets && tagName.indexOf(':')<0) {
- tagName = faceletHtmlPrefixStart + tagName;
- }
- String request = "/" + tagName + "@" + contentAssistRequest.getMatchString(); //$NON-NLS-1$ //$NON-NLS-2$
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- if(kbProposals!=null) {
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- String proposedInfo = kbProposal.getContextInfo();
- String replacementString = kbProposal.getReplacementString() + "=\"\""; //$NON-NLS-1$
- String displayString = kbProposal.getLabel();
- AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
- if(attr!=null) {
- ITextRegion region = attr.getNameRegion();
- IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
- if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition() ||
- docRegion.getEndOffset(region)< contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) {
- continue;
- }
- }
- boolean autoContentAssistant = true;
- int cursorAdjustment = replacementString.length() - 1;
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(autoContentAssistant, replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- addJsfAttributeNameProposalsForFaceletTag(contentAssistRequest);
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- private void addJsfAttributeNameProposalsForFaceletTag(ContentAssistRequest contentAssistRequest) {
- // Ignore if jsp is not facelet jsp
- if(!isFacelets) {
- return;
- }
-
- Element element = (Element)contentAssistRequest.getNode();
-
- String tagName = element.getNodeName();
- // Only HTML tags
- if(tagName.indexOf(':')>0) {
- return;
- }
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC = attributes.getNamedItem(JSFCAttributeName);
- if(jsfC==null || (!(jsfC instanceof Attr))) {
- return;
- }
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName==null || jsfTagName.indexOf(':')<1) {
- return;
- }
-
- String request = "/" + jsfTagName + "@" + contentAssistRequest.getMatchString(); //$NON-NLS-1$ //$NON-NLS-2$
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal)iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String replacementString = kbProposal.getReplacementString() + "=\"\""; //$NON-NLS-1$
- String displayString = kbProposal.getLabel();
- AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
- if(attr!=null) {
- ITextRegion region = attr.getNameRegion();
- IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
- if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition() ||
- docRegion.getEndOffset(region)< contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) {
- continue;
- }
- }
- boolean autoContentAssistant = true;
- int cursorAdjustment = replacementString.length() - 1;
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(autoContentAssistant, replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // JBIDE-1704:
- // Check the position in the value:
- // The following position:
- // <nodeName attrName="attrValue"| .../>
- // is marked as attribute value, but the value itself is complete.
- // There are no proposals to be correct at this position.
-
- String text = contentAssistRequest.getText();
- String matchString = contentAssistRequest.getMatchString();
-
- if (matchString.length() > StringUtils.strip(text).length() &&
- ( (matchString.startsWith("\"") && matchString.endsWith("\"") && //$NON-NLS-1$ //$NON-NLS-2$
- (matchString.indexOf("\"") != matchString.lastIndexOf("\""))) //$NON-NLS-1$ //$NON-NLS-2$
- || (matchString.startsWith("'") && matchString.endsWith("\"") && //$NON-NLS-1$ //$NON-NLS-2$
- (matchString.indexOf("\"") != matchString.lastIndexOf("\""))))) { //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- if (jspActiveCAP != null) {
- jspActiveCAP.setFacelets(isFacelets);
- jspActiveCAP.addAttributeValueProposals(contentAssistRequest);
- }
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String tagName = node.getNodeName();
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0)
- return;
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- break;
- }
-
- String attributeName = open.getText(nameRegion);
-
- boolean faceletJsfTag = false;
- if(isFacelets && tagName.indexOf(':')<1 && !JSFCAttributeName.equals(attributeName)) {
- Element element = (Element)node;
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC = attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
- if(jsfC!=null && (jsfC instanceof Attr)) {
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName!=null && jsfTagName.indexOf(':')>0) {
- tagName = jsfTagName;
- faceletJsfTag = true;
- }
- }
- }
-
- if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0) {
- tagName = faceletHtmlPrefixStart + tagName;
- }
- String query = new StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).toString();
- AttributeDescriptor ad = null;
- try {
- ad = getWtpKbConnector().getAttributeInformation(query);
- } catch(KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- if(ad!=null) {
- CMAttributeDeclaration attrDecl = null;
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
- }
- }
- }
- if (attrDecl == null || attrDecl.getAttrType() == null) {
- return;
- }
- }
-
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- String request = "/" + contentAssistRequest.getMatchString(); //$NON-NLS-1$
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- if(kbProposals!=null) {
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal) iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String kbReplacementString = kbProposal.getReplacementString();
- String replacementString = kbReplacementString + ">"; //$NON-NLS-1$
- String displayString = kbProposal.getLabel();
- boolean autoContentAssistant = replacementString.indexOf('\"')>-1 && replacementString.indexOf("=")>-1; //$NON-NLS-1$
- int cursorAdjustment = replacementString.length();
- if(!kbReplacementString.endsWith("/")) { //$NON-NLS-1$
- replacementString = replacementString + "</" + displayString + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(autoContentAssistant, replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- super.addTagNameProposals(contentAssistRequest, childPosition);
- }
-
- private boolean ignoreProposal(KbProposal proposal) {
- if(isFacelets) {
- return proposal.getLabel().startsWith(faceletHtmlPrefixStart);
- }
- return false;
- }
-
- private KbProposal cleanFaceletProposal(KbProposal proposal) {
- if(isFacelets) {
- proposal.setLabel(removeFaceletsPrefix(proposal.getLabel()));
- proposal.setReplacementString(removeFaceletsPrefix(proposal.getReplacementString()));
- }
- return proposal;
- }
-
- private String removeFaceletsPrefix(String tagName) {
- if(tagName.startsWith(faceletHtmlPrefixStart)) {
- return tagName.substring(faceletHtmlPrefixStart.length());
- }
- return tagName;
- }
-
- private WtpKbConnector getWtpKbConnector() {
- if(wtpKbConnector == null && document != null) {
- try {
- wtpKbConnector = (WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR, document);
- jspActiveCAP.setKbConnector(wtpKbConnector);
- FaceletsJsfCResource fsfCResource = new FaceletsJsfCResource(wtpKbConnector);
- wtpKbConnector.registerResource(fsfCResource);
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- return wtpKbConnector;
- }
-
- private void registerToTldManager(ITextViewer viewer,IDOMNode node) {
- if((tldManager==null) && (viewer instanceof VpeTaglibManagerProvider)) {
- tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
- tldManager.setReferenceNode(node);
- if(tldManager!=null) {
- tldManager.addTaglibListener(this);
- updateActiveContentAssistProcessor(document);
- }
- } else if(tldManager!=null) {
- tldManager.setReferenceNode(node);
- updateActiveContentAssistProcessor(document);
- }
- }
-
- public void taglibPrefixChanged(String[] prefixs) {
- updateActiveContentAssistProcessor(document);
- }
-
- public void addTaglib(String uri, String prefix) {
- }
-
- public void removeTaglib(String uri, String prefix) {
- }
-
- public static void registerTld(TaglibData data, JspWtpKbConnector wtpKbConnector, IDocument document, IEditorInput input) {
- TLDRegisterHelper.registerTld(data, wtpKbConnector, document, input);
- }
-
- public void updateActiveContentAssistProcessor(IDocument document) {
- if(tldManager==null) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if (manager != null) {
- List list = manager.getTaglibTrackers();
- for(int i=0; i<list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "", tracker.getPrefix(), version); //$NON-NLS-1$
- getWtpKbConnector().registerResource(resource);
- }
- }
- } else {
- List list = tldManager.getTagLibs();
- if(list==null) {
- return;
- }
- ((JspWtpKbConnector)getWtpKbConnector()).unregisterAllResources(true);
- isFacelets = false;
- for(int i=0; i<list.size(); i++) {
- TaglibData data = (TaglibData)list.get(i);
- registerTld(data, (JspWtpKbConnector)getWtpKbConnector(), document, editorInput);
- isFacelets = isFacelets || data.getUri().equals(faceletUri);
- }
- if(isFacelets) {
- getWtpKbConnector().registerResource(faceletHtmlResource);
- ((JspWtpKbConnector)getWtpKbConnector()).unregisterJspResource();
- }
- }
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- char[] autoActivChars = null;
- char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
- if(superAutoActivChars==null) {
- return superAutoActivChars;
- }
-
- autoActivChars = superAutoActivChars;
- IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)) {
-// String superDefaultChars = store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
- if(redhatDefaultChars.indexOf(".")<0) { //$NON-NLS-1$
- redhatDefaultChars.append('.');
- redhatDefaultChars.append('[');
- store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- store.setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
- }
-
- return autoActivChars;
- }
-
- protected void init() {
- super.init();
- jspActiveCAP = new JSPActiveContentAssistProcessor();
- jspActiveCAP.init();
- }
-
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- ITextRegion region = (sdRegion == null ? null : sdRegion.getRegionAtCharacterOffset(pos));
- if (region == null) {
- return null;
- }
-
- if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
- sdRegion.getStartOffset(region) == pos) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- sdRegion = sdRegion.getPrevious();
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
- sdRegion = sdRegion.getPrevious();
- }
- }
- }
-
- return sdRegion;
- }
-
- public void release() {
- super.release();
- wtpKbConnector = null;
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELUtil;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbQuery;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.xpl.JSPBaseContentAssistProcessor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author Igels
- */
-public class JSPActiveContentAssistProcessor extends JSPBaseContentAssistProcessor {
- private WtpKbConnector wtpKbConnector;
- private boolean isFacelets = false;
-
- public JSPActiveContentAssistProcessor() {
- super();
- }
-
- public void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- if(wtpKbConnector==null) {
- return;
- }
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- public void addFaceletAttributeValueProposals(
- ContentAssistRequest contentAssistRequest,String tagName,IDOMNode node,String attributeName, String matchString,String strippedValue, int offset, String currentValue) {
- boolean faceletJsfTag = false;
-
- String htmlQuery = null;
- if(isFacelets && tagName.indexOf(':')<1 && !FaceletsHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
- Element element = (Element)node;
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC = attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
- if(jsfC!=null && (jsfC instanceof Attr)) {
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName!=null && jsfTagName.indexOf(':')>0) {
- htmlQuery = new StringBuffer(KbQuery.TAG_SEPARATOR).append(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
- tagName = jsfTagName;
- faceletJsfTag = true;
- }
- }
- }
-
- if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0) {
- tagName = FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
- }
-
- if(!currentValue.startsWith("\"") && !currentValue.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- // Do not show any value proposals if the attribute value is not started with a quote/double-quote character
- return;
- }
-
- int elStartPosition = getELStartPosition(matchString);
- int delta = 0;
- String elProposalPrefix = ""; //$NON-NLS-1$
- String elQueryString = null;
- String queryString = null;
- String elStartChar = "#"; //$NON-NLS-1$
- if (elStartPosition == -1) {
- queryString = matchString;
- elQueryString = "#{"; //$NON-NLS-1$
- delta = matchString.length();
- if(isCharSharp(matchString, offset-1) || isCharDollar(matchString, offset-1)) {
- elProposalPrefix = "{"; //$NON-NLS-1$
- queryString = null; // Do not request for ordinar attr-value proposals
- // in case of starting EL-expression
- if (isCharDollar(matchString, offset-1))
- elStartChar = "$"; //$NON-NLS-1$
- } else {
- elProposalPrefix = "#{"; //$NON-NLS-1$
- }
- delta = matchString.length() - elQueryString.length();
- if (matchString.startsWith("\"") || matchString.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- queryString = matchString.substring(1);
- }
- } else {
- // // Do not request for ordinar attr-value proposals
- // in case of EL-expression
- queryString = null;
- elQueryString = matchString.substring(elStartPosition);
- delta = matchString.length() - elQueryString.length();
- }
-
- // Correct delta if matchString starts with a quote (exclude that quote)
- if (matchString.startsWith("\"") || matchString.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- delta--;
- }
-
- Collection proposals = null;
- if (queryString != null) {
- // Query to request for ordinar proposals
- try {
- String query = new StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(queryString).toString();
- proposals = wtpKbConnector.getProposals(query);
- if(proposals.size()==0 && htmlQuery!=null) {
- proposals = wtpKbConnector.getProposals(htmlQuery);
- }
- if(proposals != null) {
- for (Iterator iter = proposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- kbProposal.postProcess(queryString, offset - delta);
- if (kbProposal.getReplacementString().startsWith("#{")) //$NON-NLS-1$
- continue; // Do not process EL-proposals here!!!
-
- int relevance = kbProposal.getRelevance();
- if(relevance==KbProposal.R_NONE) {
- relevance = KbProposal.R_XML_ATTRIBUTE_VALUE;
- }
-
- if(kbProposal.getStart() < 0) {
- StringBuffer replacementStringBuffer = new StringBuffer(kbProposal.getReplacementString());
- int replacementBeginPosition = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPositionDelta = 0;
- if(currentValue.startsWith("\"") || currentValue.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- replacementBeginPosition = replacementBeginPosition +1;
- replacementLength--;
- } else {
- cursorPositionDelta++;
- replacementStringBuffer.insert(0, "\""); //$NON-NLS-1$
- }
- if((currentValue.endsWith("\"") || currentValue.endsWith("'")) && //$NON-NLS-1$ //$NON-NLS-2$
- strippedValue.length() < currentValue.length() ) {
- replacementLength--;
- }
-
- String replacementString = replacementStringBuffer.toString();
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
-
- // JBIDE-3133: New icons for proposals in JSF/Seam Code Assist
- Image image = kbProposal.hasImage() ?
- kbProposal.getImage() :
- SharedXMLEditorPluginImageHelper
- .getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(), replacementString,
- replacementBeginPosition, replacementLength, cursorPosition, image,
- kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
-
- }
- }
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
-
- Collection elProposals = null;
- if (elQueryString != null
- // JBIDE-3290 Quick-fix - this supresses the EL-proposals suggestions
- // in case of no "#{"-prefix is typed
- && elStartPosition != -1
- ) {
- // Query to request for EL-proposals
- try {
- String query = new StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(elQueryString).toString();
- elProposals = wtpKbConnector.getProposals(query);
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- if(elProposals != null) {
- for (Iterator iter = elProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- kbProposal.postProcess("\"" + elQueryString, offset - delta); //$NON-NLS-1$
- if (!kbProposal.getReplacementString().startsWith("#{")) //$NON-NLS-1$
- continue; // Process the only EL-proposals here!!!
- int relevance = kbProposal.getRelevance();
- if(relevance==KbProposal.R_NONE) {
- relevance = KbProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
- if(kbProposal.getStart() >= 0) {
- String replacementString = kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1);
- int replacementBeginPosition = contentAssistRequest.getReplacementBeginPosition() + kbProposal.getStart() + delta;
- int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
- int cursorPositionDelta = 0;
-
- // Add an EL-starting quotation characters if needed
- if (elStartPosition == -1) {
- replacementString = elProposalPrefix + replacementString;
- cursorPositionDelta += elProposalPrefix.length();
- }
-
- if((currentValue.length() > StringUtils.strip(currentValue).length()) &&
- (currentValue.endsWith("\"") || currentValue.endsWith("'")) ) { //$NON-NLS-1$ //$NON-NLS-2$
- String restOfCurrentValue = currentValue.substring(matchString.length());
-
- if(getELEndPosition(matchString, currentValue) == -1) {
- replacementString += "}"; //$NON-NLS-1$
- }
- } else {
- if(elStartPosition == -1 && !currentValue.endsWith("}")) { //$NON-NLS-1$
- replacementString += "}"; //$NON-NLS-1$
- }
- // replacementString += ("\"");
- }
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- String displayString = elProposalPrefix == null || elProposalPrefix.length() == 0 ?
- kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1) :
- elProposalPrefix + kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1) + "}" ; //$NON-NLS-1$
-
- if ('#' == displayString.charAt(0) || '$' == displayString.charAt(0))
- displayString = elStartChar + displayString.substring(1);
-
- // JBIDE-3133: New icons for proposals in JSF/Seam Code Assist
- Image image = kbProposal.hasImage() ?
- kbProposal.getImage() :
- JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(
- kbProposal.autoActivationContentAssistantAfterApplication(),
- replacementString,
- replacementBeginPosition, replacementLength, cursorPosition,
- image,
- displayString, null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- private KbProposal cleanFaceletProposal(KbProposal proposal) {
- if(isFacelets) {
- proposal.setLabel(removeFaceletsPrefix(proposal.getLabel()));
- proposal.setReplacementString(removeFaceletsPrefix(proposal.getReplacementString()));
- }
- return proposal;
- }
-
- private String removeFaceletsPrefix(String tagName) {
- if(tagName.startsWith(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart)) {
- return tagName.substring(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart.length());
- }
- return tagName;
- }
-
- public void init() {
- super.init();
- }
-
- public void setKbConnector(WtpKbConnector connector) {
- this.wtpKbConnector = connector;
- }
-
- public void setFacelets(boolean isFacelets) {
- this.isFacelets = isFacelets;
- }
-
- /*
- * Checks if the EL operand starting characters are present
- * @return
- */
- private int getELStartPosition(String matchString) {
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(matchString);
- ELInstance is = ELUtil.findInstance(model, matchString.length());
- return is == null ? -1 : is.getStartPosition();
- }
-
- /* Checks if the preceding character is a Sharp-character
- */
- private boolean isCharSharp(String matchString, int offset) {
- if (matchString == null || offset > matchString.length() || offset < 0) {
- return false;
- }
- return ('#' == matchString.charAt(offset));
- }
-
- /* Checks if the preceding character is a Dollar-character
- */
- private boolean isCharDollar(String matchString, int offset) {
- if (matchString == null || offset > matchString.length() || offset < 0) {
- return false;
- }
- return ('$' == matchString.charAt(offset));
- }
-
- /*
- * Checks if the EL operand ending character is present
- * @return
- */
- private int getELEndPosition(String matchString, String currentValue) {
- if (matchString == null || matchString.length() == 0 ||
- currentValue == null || currentValue.length() == 0 ||
- currentValue.length() < matchString.length())
- return -1;
-
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(currentValue);
- ELInstance is = ELUtil.findInstance(model, matchString.length());
- if(is == null || is.getCloseInstanceToken() == null) return -1;
-
- return is.getEndPosition();
- }
-
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.editor;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.ui.editors.dnd.DropUtils;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.WebProject;
-import org.jboss.tools.jst.web.tld.TaglibData;
-
-public class TLDRegisterHelper {
-
- public static void registerTld(TaglibData data, JspWtpKbConnector wtpKbConnector, IDocument document, IEditorInput input) {
- XModel xm = null;
- if(input!=null && input instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)input).getFile().getProject();
- IModelNature mn = EclipseResourceUtil.getModelNature(project);
- if(mn!=null) {
- xm = mn.getModel();
- }
- }
- registerTld(data, wtpKbConnector, document, xm);
- }
-
- public static void registerTld(TaglibData data, JspWtpKbConnector wtpKbConnector, IDocument document, XModel xm) {
- String version = WebProject.getTldVersion(data.getUri(), data.getPrefix(), document, xm);
- KbTldResource resource = new KbTldResource(data.getUri(), "", data.getPrefix(), version); //$NON-NLS-1$
- if(data.isNs()) {
- resource.setJsfResource(true);
- boolean registrated = wtpKbConnector.registerResource(resource, true);
- if(!registrated || resource.isCustomTld()) {
- try {
- resource = (KbTldResource)resource.clone();
- } catch (CloneNotSupportedException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- return;
- }
-
- IEditorPart editorPart = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(editorPart!=null) {
- IEditorInput input = editorPart.getEditorInput();
- String tldContent = DropUtils.getTldContent(input, data.getUri());
- if(tldContent!=null) {
- resource.setTldContent(tldContent);
- wtpKbConnector.registerResource(resource, true);
- }
- }
- }
- } else {
- wtpKbConnector.registerResource(resource);
- }
- }
-}
\ No newline at end of file
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:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -105,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;
// }
-// 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/JSPPropertySourceAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -42,7 +42,6 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
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.editor.IVisualController;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.tools.common.reporting.ProblemReportingHelper;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbQuery;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-
-/**
- * @author igels
- */
-public class FaceletsJsfCResource implements KbDinamicResource {
-
- private WtpKbConnector kbConnector;
-
- public FaceletsJsfCResource(WtpKbConnector kbConnector) {
- super();
- this.kbConnector = kbConnector;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbDinamicResource#setConstraint(java.lang.String, java.lang.String)
- */
- public void setConstraint(String name, String value) {
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbDinamicResource#clearConstraints()
- */
- public void clearConstraints() {
- }
-
- private static final Collection<KbProposal> emptyProposalList = new ArrayList<KbProposal>(0);
-
- /**
- * @see org.jboss.tools.common.kb.KbDinamicResource#queryProposal(java.lang.String)
- */
- public Collection<KbProposal> queryProposal(String query) {
- if(query.indexOf(KbQuery.ATTRIBUTE_SEPARATOR)>-1) {
- return emptyProposalList;
- }
- // trim first spaces
- while(true) {
- if(query.startsWith(" ")) { //$NON-NLS-1$
- query = query.substring(1);
- } else {
- break;
- }
- }
- String kbQuery = KbQuery.TAG_SEPARATOR + query;
- Collection proposals = null;
- ArrayList<KbProposal> proposalsWithoutHtmlTags = null;
- try {
- proposals = kbConnector.getProposals(kbQuery);
- if(proposals==null) {
- return emptyProposalList;
- }
- proposalsWithoutHtmlTags = new ArrayList<KbProposal>(proposals.size());
- for (Iterator iter = proposals.iterator(); iter.hasNext();) {
- KbProposal proposal = (KbProposal) iter.next();
- if(!ignoreProposal(proposal)) {
- proposal.setReplacementString(proposal.getLabel());
- proposal.setPosition(proposal.getLabel().length());
- proposal.setRelevance(10000);
- proposalsWithoutHtmlTags.add(proposal);
- }
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- return proposalsWithoutHtmlTags;
- }
-
- private boolean ignoreProposal(KbProposal proposal) {
- return proposal.getLabel().startsWith(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart) || proposal.getLabel().indexOf(':')<0;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbDinamicResource#getType()
- */
- public String getType() {
- return KbDinamicResource.FACELETS_JSFC_TYPE;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbResource#getInputStream()
- */
- public InputStream getInputStream() {
- return null;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if(!(o instanceof FaceletsJsfCResource)) return false;
- FaceletsJsfCResource other = (FaceletsJsfCResource)o;
- return other.getType().equals(getType()) && other.kbConnector == kbConnector;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return getType().hashCode() + kbConnector.hashCode();
- }
-}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -17,13 +17,11 @@
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-public abstract class WTPKbAbstractModelResource implements KbDinamicResource {
+public abstract class WTPKbAbstractModelResource {
protected IEditorInput fEditorInput;
protected WebPromptingProvider fProvider;
protected XModel fXModel;
@@ -55,28 +53,4 @@
return fXModelObject;
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if(!(o instanceof WTPKbAbstractModelResource)) return false;
- WTPKbAbstractModelResource other = (WTPKbAbstractModelResource)o;
- return other.getType().equals(getType()) && other.getXModel() == getXModel();
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int hashCode = getType().hashCode();
- if(getXModel()!=null) {
- hashCode += getXModel().hashCode();
- }
-
- return hashCode;
- }
-
- protected int getKbProposalRelevance() {
- return KbProposal.R_NONE;
- }
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -10,9 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.support.kb;
-import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
@@ -27,8 +25,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -112,25 +108,6 @@
}
}
- public Collection<KbProposal> queryProposal(String query) {
- ArrayList<KbProposal> proposals = new ArrayList<KbProposal>();
- ImagePathDescriptor[] images = getImagesFilesPathes(query);
- for(int i=0; i<images.length; i++) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(images[i].getQueryPath());
- String replacementString = images[i].getQueryPath();
- if(images[i].getResource() instanceof IFolder) {
- replacementString = replacementString + "/"; //$NON-NLS-1$
- proposal.setAutoActivationContentAssistantAfterApplication(true);
- }
- proposal.setReplacementString(replacementString);
- proposal.setPosition(replacementString.length());
- proposal.setImage(JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_RESOURCES_IMAGE_PATH));
- proposals.add(proposal);
- }
- return proposals;
- }
-
public ImagePathDescriptor[] getImagesFilesPathes(String query) {
query = query.trim();
if(query.indexOf('\\')>-1) {
@@ -201,14 +178,6 @@
return filesPathes;
}
- public String getType() {
- return KbDinamicResource.IMAGE_FILE_TYPE;
- }
-
- public InputStream getInputStream() {
- return null;
- }
-
public boolean isReadyToUse() {
return (webInfResource!=null) && (webRootResource!=null) && (currentResource!=null);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -10,13 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.support.kb;
-import java.util.Set;
-import org.eclipse.ui.IEditorInput;
-
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-
-public class WTPKbJsfValuesResource extends WTPKbdBeanPropertyResource {
+public class WTPKbJsfValuesResource {
@SuppressWarnings("nls")
private static final String[] fixedJsfValues = {
"header", "headerValues", "param", "paramValues",
@@ -24,24 +18,6 @@
"sessionScope", "applicationScope",
"facesContext", "view"};
- public WTPKbJsfValuesResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- public String getType() {
- return KbDinamicResource.JSF_VARIABLES_TYPE;
- }
-
- protected void fillSortedProposalStrings(Set sorted, String beanName, boolean hasProperty) {
- for (int i = 0; i < fixedJsfValues.length; i++) {
- sorted.add(fixedJsfValues[i]);
- }
- }
-
- protected int getKbProposalRelevance() {
- return KbProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
/**
*
* @return
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Jeremy
- */
-public class WTPKbdActionResource extends WTPKbAbstractModelResource {
- private String fPath;
- public static String SUPPORTED_ID = WebPromptingProvider.JSF_VIEW_ACTIONS;
-
- public WTPKbdActionResource(IEditorInput editorInput) {
- super(editorInput);
- if(fXModelObject != null) {
- fPath = XModelObjectLoaderUtil.getResourcePath(fXModelObject);
- }
- }
-
- public boolean isReadyToUse() {
- return (fProvider != null && fXModelObject != null && fPath != null);
- }
-
- /*
- * @see org.jboss.tools.common.kb.KbDinamicResource#queryProposal(java.lang.String)
- */
- public Collection<KbProposal> queryProposal(String query) {
- Collection<KbProposal> proposals = new ArrayList<KbProposal>();
- if (!isReadyToUse()) return proposals;
- Properties view = new Properties();
- view.put(IWebPromptingProvider.VIEW_PATH, fPath);
-
- List<Object> sourceList = fProvider.getList(fXModelObject.getModel(), SUPPORTED_ID, "", view); //$NON-NLS-1$
-
- if (sourceList != null && !sourceList.isEmpty()) {
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Iterator it = sourceList.iterator();
- while(it.hasNext()) sorted.add(it.next().toString());
- Iterator i = sorted.iterator();
- while(i.hasNext()) {
- String text = (String)i.next();
- if (text.trim().length() > 0 && text.toLowerCase().startsWith(query.toLowerCase())) {
- if (proposals == null) proposals = new ArrayList<KbProposal>(1);
- KbProposal proposal = new KbProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- proposal.setImage(JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_ACTION_IMAGE_PATH));
- proposals.add(proposal);
- }
- }
- }
- return proposals;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#getType()
- */
- public String getType() { return KbDinamicResource.VIEW_ACTIONS_TYPE; }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbResource#getInputStream()
- */
- public InputStream getInputStream() { return null; }
-
- public String toString () { return "WTPKbdActionResource"; } //$NON-NLS-1$
-
- public String getSupportedID () { return SUPPORTED_ID; }
-
- public String getPath() {
- return fPath;
- }
-
-/* public boolean equals (Object obj) {
- if (obj == null || !(obj instanceof WTPKbdActionResource)) return false;
- WTPKbdActionResource resource = (WTPKbdActionResource)obj;
-
- return (resource.getSupportedID() == SUPPORTED_ID &&
- resource.getXModelObject() == fXModelObject &&
- (fPath != null && fPath.equalsIgnoreCase(resource.getPath())));
- }
-*/
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#setConstraint(java.lang.String, java.lang.String)
- */
- public void setConstraint(String name, String value) {
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#clearConstraint(java.lang.String)
- */
- public void clearConstraints() {
- }
-}
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanMethodResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanMethodResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanMethodResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.*;
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.kb.*;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Jeremy
- */
-public class WTPKbdBeanMethodResource extends WTPKbdBeanPropertyResource {
- public static String SUPPORTED_ID = WebPromptingProvider.JSF_BEAN_METHODS;
-
- public WTPKbdBeanMethodResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- public boolean isReadyToUse() {
- return (fProvider != null && fXModel != null);
- }
-
- public String getType() {
- return KbDinamicResource.BEAN_METHOD_BY_SYGNATURE_TYPE;
- }
-
- public InputStream getInputStream() {
- return null;
- }
-
- public String toString () {
- return "WTPKbdBeanMethodResource"; //$NON-NLS-1$
- }
-
- public String getSupportedID () {
- return SUPPORTED_ID;
- }
-
- public void setConstraint(String name, String value) {
- if (name == null) return;
- if (value == null || value.trim().length() == 0) return;
-
- if ("paramType".equalsIgnoreCase(name)) { //$NON-NLS-1$
- String[] types = (String[])type.get(IWebPromptingProvider.PARAMETER_TYPES);
- List<String> aTypes = new ArrayList<String>();
- for (int i = 0; types != null && i < types.length; i++) {
- aTypes.add(types[i]);
- }
- aTypes.add(value);
- types = new String[(aTypes == null ? 0 : aTypes.size())];
- for (int i = 0; aTypes != null && i < aTypes.size(); i++) {
- types[i] = (String)aTypes.get(i);
- }
-
- type.put(IWebPromptingProvider.PARAMETER_TYPES, types);
- } else if ("returnType".equalsIgnoreCase(name)) { //$NON-NLS-1$
- type.put(IWebPromptingProvider.RETURN_TYPE, value);
- }
- }
-
- public void clearConstraints() {
- if (type != null) type.clear();
- type.put(IWebPromptingProvider.PARAMETER_TYPES, new String[0]);
- type.put(IWebPromptingProvider.RETURN_TYPE, "void"); //$NON-NLS-1$
- }
-
- public Collection queryProposal(String query, String tail) {
- throw new RuntimeException("Not implemented"); //$NON-NLS-1$
- }
-
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.model.ELUtil;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbProposal.PostProcessing;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Jeremy
- */
-public class WTPKbdBeanPropertyResource extends WTPKbAbstractModelResource {
- public static String SUPPORTED_ID = WebPromptingProvider.JSF_BEAN_PROPERTIES;
- public Properties type = new Properties();
- protected String query;
-
- public WTPKbdBeanPropertyResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- public boolean isReadyToUse() {
- return (fProvider != null && fXModel != null);
- }
-
- public Collection<KbProposal> queryProposal(String query) {
- this.query = query;
- Collection<KbProposal> proposals = new ArrayList<KbProposal>();
- proposals.clear();
- try {
- if (!isReadyToUse()) return proposals;
-
- ELParser p = ELParserUtil.getDefaultFactory().createParser();
- ELModel model = p.parse(query);
-
- List<ELInstance> is = model.getInstances();
-
- ELInvocationExpression expr = null;
- ELInvocationExpression current = null;
- boolean hasProperty = false;
-
- for (ELInstance i: is) {
- if(!(i.getExpression() instanceof ELInvocationExpression)) continue;
- expr = (ELInvocationExpression)i.getExpression();
- ELInvocationExpression inv = expr;
- current = inv;
- if(inv.getLeft() != null) {
- hasProperty = true;
- current = inv.getLeft(); //bean
- }
- }
-
- String beanNameFromQuery = current == null ? null : current.getText();
-
- String restQuery = expr == null ? null : expr.getText();
- if(expr instanceof ELPropertyInvocation) {
-// restQuery = ((ELPropertyInvocation)expr).getQualifiedName();
- }
-
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- fillSortedProposalStrings(sorted, beanNameFromQuery, hasProperty);
-
- if (sorted.isEmpty()) return proposals;
-
- Iterator<String> it = sorted.iterator();
- while(it.hasNext()) {
- String text = it.next();
- process(proposals, "", "", -1, query.length() - "".length(), query.length(), text, restQuery, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH));
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError(x);
- }
- return proposals;
- }
-
- protected void fillSortedProposalStrings(Set<String> sorted, String beanName, boolean hasProperty) {
- if (beanName == null || beanName.length() == 0 || !hasProperty) {
- List beanList = fProvider.getList(fXModel, WebPromptingProvider.JSF_MANAGED_BEANS, "", null); //$NON-NLS-1$
- Iterator it = beanList.iterator();
- while(it.hasNext()) {
- sorted.add(it.next().toString());
- }
- } else {
- List properties = fProvider.getList(fXModel, getSupportedID(), beanName, type);
- for (int ii = 0; properties != null && ii < properties.size(); ii++) {
- sorted.add(beanName + "." + (String)properties.get(ii)); //$NON-NLS-1$
- }
- }
- }
-
- private static String[][] BEAN_PROPERTY_WRAPPERS = {{"#{", "}"},{"${", "}"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- protected String[][] getWrappers() {
- return BEAN_PROPERTY_WRAPPERS;
- }
-
- protected boolean process(Collection<KbProposal> proposals, String prefix, String suffix, int start, int cursor, int end, String text, String query, Image image) {
- if ((prefix + text).toLowerCase().startsWith((prefix + query).toLowerCase())) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(prefix + text + suffix);
- proposal.setReplacementString(text);
- proposals.add(proposal);
- proposal.setPosition(cursor);
- proposal.setPostProcessing(postProcessing);
- proposal.setRelevance(getKbProposalRelevance());
- proposal.setImage(image);
- return true;
- } else {
- return false;
- }
- }
-
- public String getType() {
- return KbDinamicResource.BEAN_PROPERTY_TYPE;
- }
-
- public InputStream getInputStream() {
- return null;
- }
-
- public String toString() {
- return "WTPKbdBeanPropertyResource"; //$NON-NLS-1$
- }
-
- public XModel getXModel() {
- return fXModel;
- }
-
- public String getSupportedID() {
- return SUPPORTED_ID;
- }
-
- public void setConstraint(String name, String value) {
- if (name == null) return;
- if ("type".equalsIgnoreCase(name)) { //$NON-NLS-1$
- if (value == null || value.trim().length() == 0) {
- if(type != null) type.remove(IWebPromptingProvider.PROPERTY_TYPE);
- } else {
- type.put(IWebPromptingProvider.PROPERTY_TYPE, value);
- }
- }
- }
-
- public void clearConstraints() {
- if (type != null) type.clear();
- }
-
- PostProcessingImpl postProcessing = new PostProcessingImpl();
-
- class PostProcessingImpl implements PostProcessing {
-
- public void process(KbProposal proposal, String value, int offset) {
- ELParser p = ELParserUtil.getDefaultFactory().createParser();
- ELModel model = p.parse(value);
- List<ELInstance> is = model.getInstances();
- ELExpression expr = null;
-
- // JBIDE-3189: CA remove first entered el expression
- // The following fixes the issue
- ELInstance i = ELUtil.findInstance(model, offset);
- if (i != null) {
- expr = (ELExpression)i.getExpression();
- }
- // JBIDE-3189
-
- if(expr != null) {
- proposal.setStart(expr.getStartPosition());
- } else {
- proposal.setStart(offset);
- }
-
- // JBIDE-3189: CA remove first entered el expression
- // The following fixes the issue
- proposal.setEnd(offset);
- // JBIDE-3189
-
- int pos = proposal.getReplacementString().length();
-
- // JBIDE-2437: Because of the issue add EL open/close brackets to the proposal replacement string
- // This will allow us to separate EL-proposals from all the others.
- proposal.setReplacementString("#{" + proposal.getReplacementString() + "}"); //$NON-NLS-1$ //$NON-NLS-2$
- proposal.setLabel("#{" + proposal.getLabel() + "}"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // JBIDE-2334: JSPAciveContentAssistProcessor (a class which calls this method)
- // is to process opening and closing EL charachers
-/*
- String[][] ws = getWrappers();
- if(ws.length > 0 && ws[0][0].length() > 0) {
- ELParser.Token open = ELParser.getPrecedingOpen(c, offset);
- if(open == null && !proposal.getReplacementString().startsWith(ws[0][0])) {
-// pos += ws[0][0].length();
-// proposal.setReplacementString(ws[0][0] + proposal.getReplacementString());
-// proposal.setLabel(ws[0][0] + proposal.getLabel() + ws[0][1]);
- } else if(open != null && !proposal.getReplacementString().startsWith(ws[0][0]) && open.end - open.start == 1) {
- if(ws[0][0].endsWith("{")) {
-// pos += 1;
-// proposal.setReplacementString("{" + proposal.getReplacementString());
- }
- } else if(open != null && open.end - open.start == 2 && offset < open.end && offset > open.start) {
- proposal.setStart(proposal.getStart() + 1);
- proposal.setEnd(proposal.getStart());
- proposal.setPosition(proposal.getStart());
- }
- if(!ELParser.isFollowedByClose(c, offset) && !proposal.getReplacementString().endsWith(ws[0][1])) {
-// proposal.setReplacementString(proposal.getReplacementString() + ws[0][1]);
- }
- }
-*/
- proposal.setPosition(pos);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Jeremy
- */
-public class WTPKbdBundleNameResource extends WTPKbAbstractModelResource {
- public static String SUPPORTED_ID = WebPromptingProvider.JSF_BUNDLES;
-
- public WTPKbdBundleNameResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- public boolean isReadyToUse() {
- return (fProvider != null && fXModel != null);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#queryProposal(java.lang.String)
- */
- public Collection<KbProposal> queryProposal(String query) {
- Collection<KbProposal> proposals = new ArrayList<KbProposal>();
- if (!isReadyToUse()) return proposals;
- List sourceList = fProvider.getList(fXModel, SUPPORTED_ID, "", null); //$NON-NLS-1$
-
- if (sourceList != null && !sourceList.isEmpty()) {
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Iterator it = sourceList.iterator();
- while(it.hasNext()) sorted.add(it.next().toString());
- Iterator i = sorted.iterator();
- while(i.hasNext()) {
- String text = (String)i.next();
- if (text.toLowerCase().startsWith(query.toLowerCase())) {
- if (proposals == null) proposals = new ArrayList<KbProposal>(1);
- KbProposal proposal = new KbProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- proposal.setImage(JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_MESSAGES_IMAGE_PATH));
- proposals.add(proposal);
- }
- }
- }
- return proposals;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#getType()
- */
- public String getType() { return KbDinamicResource.BUNDLE_NAME_TYPE; }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbResource#getInputStream()
- */
- public InputStream getInputStream() { return null; }
-
- public String toString () { return "WTPKbdBundleNameResource"; } //$NON-NLS-1$
-
- public XModel getXModel() { return fXModel; }
- public String getSupportedID () { return SUPPORTED_ID; }
-
-/* public boolean equals (Object obj) {
- if (obj == null || !(obj instanceof WTPKbdBundleNameResource)) return false;
- WTPKbdBundleNameResource resource = (WTPKbdBundleNameResource)obj;
-
- return (resource.getSupportedID() == SUPPORTED_ID && resource.getXModel() == fXModel);
- }
-*/
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#setConstraint(java.lang.String, java.lang.String)
- */
- public void setConstraint(String name, String value) {
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbDinamicResource#clearConstraint(java.lang.String)
- */
- public void clearConstraints() {
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundlePropertyResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundlePropertyResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundlePropertyResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IResourceBundle;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Jeremy
- */
-public class WTPKbdBundlePropertyResource extends WTPKbdBeanPropertyResource {
- public static String SUPPORTED_ID = WebPromptingProvider.JSF_BUNDLE_PROPERTIES;
- IPageContext context;
-
- public WTPKbdBundlePropertyResource(IEditorInput editorInput, IPageContext context) {
- super(editorInput);
- this.context = context;
- }
-
- public Collection<KbProposal> queryProposal(String query) {
- Collection<KbProposal> proposals = new ArrayList<KbProposal>();
- try {
- if (!isReadyToUse()) return proposals;
-
- ELParser p = ELParserUtil.getDefaultFactory().createParser();
- ELModel model = p.parse(query);
-
- List<ELInstance> is = model.getInstances();
-
- ELInvocationExpression expr = null;
- ELInvocationExpression current = null;
- boolean hasProperty = false;
-
- for (ELInstance i: is) {
- if(!(i.getExpression() instanceof ELInvocationExpression)) continue;
- expr = (ELInvocationExpression)i.getExpression();
- ELInvocationExpression inv = expr;
- current = inv;
- if(inv.getLeft() != null) {
- hasProperty = true;
- current = inv.getLeft(); //bean
- }
- }
-
- String beanNameFromQuery = current == null ? null : current.getText();
-
- String restQuery = expr == null ? "" : expr.getText(); //$NON-NLS-1$
- String argName = expr == null ? "" : expr.getMemberName(); //$NON-NLS-1$
- if(argName == null) argName = ""; //$NON-NLS-1$
- if(argName.startsWith("\"") || argName.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- argName = argName.substring(1);
- }
- if(argName.endsWith("\"") || argName.endsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
- argName = argName.substring(0, argName.length() - 1);
- }
-
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-
- IResourceBundle[] bs = context.getResourceBundles();
- Map<String,String> bundles2 = new TreeMap<String,String>();
- for (IResourceBundle b: bs) {
- String _var = b.getVar();
- bundles2.put(_var, b.getBasename());
- }
- List l = fProvider.getList(fXModel, WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
- if(l != null && l.size() > 0 && (l.get(0) instanceof Map)) {
- bundles2.putAll((Map)l.get(0));
- }
-
- if (beanNameFromQuery == null || beanNameFromQuery.length() == 0 || !hasProperty) {
- Iterator<String> itr = bundles2.keySet().iterator();
- while (itr.hasNext())
- sorted.add(itr.next());
- } else {
- String basename = (String)bundles2.get(beanNameFromQuery);
- if (basename == null) return proposals;
-
- List<String> bundleList = new ArrayList<String>(2);
- bundleList.add(basename);
- if (argName != null && argName.length() > 0){
- if (restQuery.indexOf('-') == -1) {
- bundleList.add(basename + "." + argName); //$NON-NLS-1$
- } else {
- bundleList.add(basename + "['" + argName + "']"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- for (int i = 0; bundleList != null && i < bundleList.size(); i++) {
- String bundleName = (String)bundleList.get(i);
-
- List properties = fProvider.getList(fXModel, SUPPORTED_ID, bundleName, null);
- for (int ii = 0; properties != null && ii < properties.size(); ii++) {
- String pi = (String)properties.get(ii);
- if (pi.indexOf('-') == -1 && pi.indexOf('.') == -1 ) {
- sorted.add(beanNameFromQuery + "." + pi); //$NON-NLS-1$
- sorted.add(beanNameFromQuery + "['" + pi + "']"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- sorted.add(beanNameFromQuery + "['" + pi + "']"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
-
- if (sorted.isEmpty()) return proposals;
-
- Iterator it = sorted.iterator();
- while(it.hasNext()) {
- String text = (String)it.next();
- process(proposals, "", "", -1, query.length() - "".length(), query.length(), text, restQuery, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_MESSAGES_IMAGE_PATH));
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError("Error in executing query " + query, x); //$NON-NLS-1$
- }
- return proposals;
- }
-
- private static String[][] MESSAGE_PROPERTY_WRAPPERS = {{"#{", "}"},{"${", "}"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- protected String[][] getWrappers() {
- return MESSAGE_PROPERTY_WRAPPERS;
- }
-
- public String getType() {
- return KbDinamicResource.BUNDLE_PROPERTY_TYPE;
- }
-
- public String toString () {
- return "WTPKbdBundlePropertyResource"; //$NON-NLS-1$
- }
-
- public String getSupportedID () {
- return SUPPORTED_ID;
- }
-
- String getBundle(XModelObject property) {
- String bundle = XModelObjectLoaderUtil.getResourcePath(property.getParent());
- if(bundle == null) bundle = ""; //$NON-NLS-1$
- if(bundle.endsWith(".properties")) bundle = bundle.substring(0, bundle.length() - 11); //$NON-NLS-1$
- bundle = bundle.substring(1).replace('/', '.');
- return bundle;
- }
-
- public void setConstraint(String name, String value) {
- }
-
- public void clearConstraints() {
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if(!(o instanceof WTPKbdBundlePropertyResource)) return false;
- WTPKbdBundlePropertyResource other = (WTPKbdBundlePropertyResource)o;
- return other.getType().equals(getType()) && other.getXModel() == getXModel();
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int hashCode = getType().hashCode();
- if(getXModel()!=null) {
- hashCode += getXModel().hashCode();
- }
-// if(connector!=null) {
-// hashCode += connector.hashCode();
-// }
-
- return hashCode;
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdManagedBeanNameResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdManagedBeanNameResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdManagedBeanNameResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import org.eclipse.ui.IEditorInput;
-
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-
-public class WTPKbdManagedBeanNameResource extends WTPKbdBeanPropertyResource {
-
- public WTPKbdManagedBeanNameResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- private static String[][] MANAGED_BEAN_NAME_WRAPPERS = {{"", ""}}; //$NON-NLS-1$ //$NON-NLS-2$
-
- protected String[][] getWrappers() {
- return MANAGED_BEAN_NAME_WRAPPERS;
- }
-
- public String getType() {
- return KbDinamicResource.MANAGED_BEAN_NAME_TYPE;
- }
-
- public void setConstraint(String name, String value) {
- super.setConstraint(name, value);
- if(IWebPromptingProvider.PROPERTY_BEAN_ONLY.equals(name)) {
- if(value == null) {
- type.remove(IWebPromptingProvider.PROPERTY_BEAN_ONLY);
- } else {
- type.setProperty(IWebPromptingProvider.PROPERTY_BEAN_ONLY, value);
- }
- }
- }
-}
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java 2009-07-24 13:56:47 UTC (rev 16768)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java 2009-07-24 14:34:58 UTC (rev 16769)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.support.kb;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.ui.IEditorInput;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-public class WTPKbdTaglibResource extends WTPKbAbstractModelResource {
- String SUPPORTED_ID = WebPromptingProvider.JSF_GET_TAGLIBS;
-
- public WTPKbdTaglibResource(IEditorInput editorInput) {
- super(editorInput);
- }
-
- public boolean isReadyToUse() {
- return (fProvider != null && fXModel != null);
- }
-
- public Collection<KbProposal> queryProposal(String query) {
- Collection<KbProposal> proposals = new ArrayList<KbProposal>();
- try {
- if (!isReadyToUse()) return proposals;
- String rQuery = getPassiveQueryPart(query);
-
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- List beanList = fProvider.getList(fXModel, SUPPORTED_ID, "", null); //$NON-NLS-1$
- Iterator itr = beanList.iterator();
- while (itr.hasNext()) sorted.add(itr.next().toString());
- if (sorted.isEmpty()) return proposals;
- Iterator it = sorted.iterator();
- while(it.hasNext()) {
- String text = (String)it.next();
- if(rQuery.length() == 0 || text.startsWith(rQuery)) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposals.add(proposal);
- proposal.setPosition(proposal.getReplacementString().length());
- }
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError(x);
- }
- return proposals;
- }
-
- private String getPassiveQueryPart(String query) {
- if (query == null || query.trim().length() == 0) return ""; //$NON-NLS-1$
- int startIndex = query.length();
- return query.substring(0, startIndex);
- }
-
- public String getType() {
- return KbDinamicResource.TAGLIB_TYPE;
- }
-
- public InputStream getInputStream() {
- return null;
- }
-
- public String toString() {
- return "WTPKbdTaglibResource"; //$NON-NLS-1$
- }
-
- public XModel getXModel() {
- return fXModel;
- }
-
- public void setConstraint(String name, String value) {
- }
-
- public void clearConstraints() {
- }
-}
\ No newline at end of file
16 years, 8 months
JBoss Tools SVN: r16768 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: outline and 1 other directory.
by jbosstools-commits@lists.jboss.org
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();
16 years, 8 months
JBoss Tools SVN: r16767 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-24 09:55:30 -0400 (Fri, 24 Jul 2009)
New Revision: 16767
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
Log:
JBIDE-2920
Exception array index out of bounds prevented.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2009-07-24 13:54:10 UTC (rev 16766)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2009-07-24 13:55:30 UTC (rev 16767)
@@ -324,7 +324,7 @@
boolean b = filter.startsWith("'") || filter.startsWith("\"");
boolean e = filter.endsWith("'") || filter.endsWith("\"");
if((b) && (e)) {
- filter = filter.substring(1, filter.length() - 1);
+ filter = filter.length() == 1 ? "" : filter.substring(1, filter.length() - 1);
} else if(b && !returnEqualedVariablesOnly) {
filter = filter.substring(1);
} else {
16 years, 8 months