Author: akazakov
Date: 2009-12-16 12:56:27 -0500 (Wed, 16 Dec 2009)
New Revision: 19366
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ActionProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ConverterIDProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalTypeFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EmptyProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EnumerationProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FaceletsJsfCProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FacetNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/IDProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ModelProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/NameSpaceProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourceBundleNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourcePathProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ValidatorIDProposalType.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ConverterIDProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EmptyProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ValidatorIDProposalType.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResource.java
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/EnumerationResourceElement.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ImageFileResourceElement.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfCore.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3875
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResource.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResource.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResource.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -14,7 +14,7 @@
import org.jboss.tools.jst.jsp.outline.ValueHelper;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType.Param;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType.Param;
/**
* @author Igels
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-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/AttributeValueResourceFactory.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -15,8 +15,8 @@
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalTypeFactory;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalTypeFactory;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/EnumerationResourceElement.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/EnumerationResourceElement.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/EnumerationResourceElement.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.drop.treeviewer.model;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType.Param;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType.Param;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/IDResourceElement.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -3,7 +3,7 @@
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
public class IDResourceElement extends AttributeValueResource {
IPageContext pageContext;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ImageFileResourceElement.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ImageFileResourceElement.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ImageFileResourceElement.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -16,7 +16,7 @@
import org.eclipse.ui.IEditorInput;
import org.jboss.tools.jst.jsp.support.kb.WTPKbImageFileResource;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType.Param;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType.Param;
/**
* @author Igels
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-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -45,9 +45,9 @@
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.internal.taglib.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.EmptyProposalType;
import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibAttribute;
-import org.jboss.tools.jst.web.kb.internal.taglib.EmptyProposalType;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-12-16 17:09:02
UTC (rev 19365)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-12-16 17:56:27
UTC (rev 19366)
@@ -33,6 +33,7 @@
org.jboss.tools.jst.web.kb.el,
org.jboss.tools.jst.web.kb.include,
org.jboss.tools.jst.web.kb.internal,
+ org.jboss.tools.jst.web.kb.internal.proposal,
org.jboss.tools.jst.web.kb.internal.scanner,
org.jboss.tools.jst.web.kb.internal.taglib,
org.jboss.tools.jst.web.kb.internal.taglib.composite,
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ActionProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ActionProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ActionProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ActionProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "JSFActionProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ XModelObject xModelObject =
EclipseResourceUtil.getObjectByResource(context.getResource());
+ if(xModelObject==null) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ String path = XModelObjectLoaderUtil.getResourcePath(xModelObject);
+ if(path==null) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ Properties view = new Properties();
+ view.put(IWebPromptingProvider.VIEW_PATH, path);
+ List<Object> sourceList = provider.getList(xModel,
WebPromptingProvider.JSF_VIEW_ACTIONS, "", view); //$NON-NLS-1$
+ if (sourceList != null && !sourceList.isEmpty()) {
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Iterator<Object> it = sourceList.iterator();
+ while(it.hasNext()) {
+ sorted.add(it.next().toString());
+ }
+ for (String text : sorted) {
+ if (text.trim().length() > 0 &&
text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class,
IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ActionProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+
+/**
+ * The CSS Class proposal type. Is used to collect and return the proposals on
+ * the CSS classes
+ *
+ * @author Victor Rubezhny
+ *
+ */
+@SuppressWarnings("restriction")
+public class CSSClassProposalType extends CustomProposalType {
+ private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ static String ID = "cssclass"; //$NON-NLS-1$
+ static String QUOTE_1 = "'"; //$NON-NLS-1$
+ static String QUOTE_2 = "\""; //$NON-NLS-1$
+ Set<String> idList = new TreeSet<String>();
+
+ @Override
+ protected void init(IPageContext context) {
+ idList.clear();
+ if (context instanceof ICSSContainerSupport) {
+ ICSSContainerSupport cssSource = (ICSSContainerSupport)context;
+
+ List<CSSStyleSheetDescriptor> descrs = cssSource.getCSSStyleSheetDescriptors();
+ if (descrs != null) {
+ for (CSSStyleSheetDescriptor descr : descrs) {
+ CSSRuleList rules = descr.sheet.getCssRules();
+ for (int i = 0; rules != null && i < rules.getLength(); i++) {
+ CSSRule rule = rules.item(i);
+ idList.addAll(getNamesFromCSSRule(rule));
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the style name found in the specified CSS Rule
+ *
+ * @param cssRule
+ * @param styleName
+ * @return
+ */
+ public static Set<String> getNamesFromCSSRule(CSSRule cssRule) {
+ Set<String> styleNames = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+
+ // get selector text
+ String selectorText = ((ICSSStyleRule) cssRule).getSelectorText();
+
+ if (selectorText != null) {
+ String styles[] = selectorText.trim().split(","); //$NON-NLS-1$
+ for (String styleText : styles) {
+ String[] styleWords = styleText.trim().split(" "); //$NON-NLS-1$
+ if (styleWords != null) {
+ for (String name : styleWords) {
+ if (name.startsWith(".")) //$NON-NLS-1$
+ continue;
+
+ if (name.indexOf("[") >= 0) { //$NON-NLS-1$
+ name = name.substring(0, name.indexOf("[")); //$NON-NLS-1$
+ }
+ if (name.indexOf(".") >= 0) { //$NON-NLS-1$
+ name = name.substring(0, name.indexOf(".")); //$NON-NLS-1$
+ }
+ if (name.indexOf(":") >= 0) { //$NON-NLS-1$
+ name = name.substring(0, name.indexOf(":")); //$NON-NLS-1$
+ }
+
+ // Use the first word as a style name
+ styleNames.add(name);
+ }
+ }
+ }
+ }
+ return styleNames;
+ }
+
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ String v = query.getValue();
+ int offset = v.length();
+ int b = v.lastIndexOf(',');
+ if(b < 0) b = 0; else b += 1;
+ String tail = v.substring(offset);
+ int e = tail.indexOf(',');
+ if(e < 0) e = v.length(); else e += offset;
+ String prefix = v.substring(b).trim();
+
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (String text: idList) {
+ if(text.startsWith(prefix)) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(b + text.length());
+ proposal.setStart(b);
+ proposal.setEnd(e);
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+
+ proposals.add(proposal);
+ }
+ }
+
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ConverterIDProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ConverterIDProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ConverterIDProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ConverterIDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class ConverterIDProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ public ConverterIDProposalType() {}
+
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ String v = query.getValue();
+
+ List<Object> list = provider.getList(xModel, getListID(), v, new Properties());
+ Set<String> idList = new TreeSet<String>();
+ if(list != null) {
+ for (Object o: list) idList.add(o.toString());
+ }
+
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (String text: idList) {
+ if(text.startsWith(v)) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+
+ proposals.add(proposal);
+ }
+ }
+
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ protected String getListID() {
+ return IWebPromptingProvider.JSF_CONVERTER_IDS;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ConverterIDProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IProposalProcessor;
+import org.jboss.tools.jst.web.kb.KbQuery;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class CustomProposalType implements IProposalProcessor {
+
+ protected Param[] params;
+ protected String type;
+ protected IPageContext context;
+
+ protected abstract void init(IPageContext context);
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the params
+ */
+ public Param[] getParams() {
+ if(params==null) {
+ params = new Param[0];
+ }
+ return params;
+ }
+
+ /**
+ * @param params the params to set
+ */
+ public void setParams(Param[] params) {
+ this.params = params;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ this.context = context;
+ init(context);
+ return getProposals(query);
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ public String getParamValue(String name) {
+ if(params==null) {
+ return null;
+ }
+ for (int i = 0; i < params.length; i++) {
+ if(name.equals(params[i].getName())) {
+ return params[i].getValue();
+ }
+ }
+ return null;
+ }
+
+ abstract public TextProposal[] getProposals(KbQuery query);
+
+ public static class Param {
+
+ private String name;
+ private String value;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalTypeFactory.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalTypeFactory.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalTypeFactory.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CustomProposalTypeFactory {
+
+ private static final CustomProposalTypeFactory INSTANCE = new
CustomProposalTypeFactory();
+
+ public static final String RESOURCE_BUNDLE_NAME_TYPE = "bundleName";
//$NON-NLS-1$
+ public static final String ACTION_TYPE = "viewActions"; //$NON-NLS-1$
+ public static final String RESOURCE_PATH_TYPE = "file"; //$NON-NLS-1$
+ public static final String ENUMERATION_TYPE = "enumeration"; //$NON-NLS-1$
+ public static final String FACELETS_JSFC_TYPE = "faceletsJsfCTags";
//$NON-NLS-1$
+ public static final String NAME_SPACE_TYPE = "taglib"; //$NON-NLS-1$
+ public static final String ID_TYPE = "id"; //$NON-NLS-1$
+ public static final String CONVERTER_ID_TYPE = "converterID"; //$NON-NLS-1$
+ public static final String VALIDATOR_ID_TYPE = "validatorID"; //$NON-NLS-1$
+ public static final String CSSCLASS_TYPE = "cssclass"; //$NON-NLS-1$
+ public static final String FACET_NAME_TYPE = "facetName"; //$NON-NLS-1$
+
+ private CustomProposalTypeFactory() {
+ }
+
+ /**
+ * @return an instance of this factory.
+ */
+ public static CustomProposalTypeFactory getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Creates Custom Proposal Type by name
+ * @param type
+ * @return
+ */
+ public CustomProposalType createProposalType(String type) {
+ if(RESOURCE_BUNDLE_NAME_TYPE.equals(type)) {
+ return new ResourceBundleNameProposalType();
+ }
+ if(ACTION_TYPE.equals(type)) {
+ return new ActionProposalType();
+ }
+ if(RESOURCE_PATH_TYPE.equals(type)) {
+ return new ResourcePathProposalType();
+ }
+ if(ENUMERATION_TYPE.equals(type)) {
+ return new EnumerationProposalType();
+ }
+ if(FACELETS_JSFC_TYPE.equals(type)) {
+ return new FaceletsJsfCProposalType();
+ }
+ if(NAME_SPACE_TYPE.equals(type)) {
+ return new NameSpaceProposalType();
+ }
+ if(ID_TYPE.equals(type)) {
+ return new IDProposalType();
+ }
+ if(CONVERTER_ID_TYPE.equals(type)) {
+ return new ConverterIDProposalType();
+ }
+ if(VALIDATOR_ID_TYPE.equals(type)) {
+ return new ValidatorIDProposalType();
+ }
+ if(CSSCLASS_TYPE.equals(type)) {
+ return new CSSClassProposalType();
+ }
+ if(FACET_NAME_TYPE.equals(type)) {
+ return new FacetNameProposalType();
+ }
+
+ //WebKbPlugin.getDefault().logError("Unknown proposal type: " + type);
//$NON-NLS-1$
+ //ExtendedProposalType will report if necessary
+
+ EmptyProposalType proposalType = new EmptyProposalType();
+
+ return proposalType;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CustomProposalTypeFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EmptyProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EmptyProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EmptyProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EmptyProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+
+public class EmptyProposalType extends CustomProposalType {
+
+ public EmptyProposalType() {}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EmptyProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EnumerationProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EnumerationProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EnumerationProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class EnumerationProposalType extends CustomProposalType {
+
+ private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ if(params==null) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (int i = 0; i < params.length; i++) {
+ String text = params[i].getValue();
+ if(text.startsWith(query.getValue())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/EnumerationProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FaceletsJsfCProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FaceletsJsfCProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FaceletsJsfCProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
+import org.jboss.tools.common.text.TextProposal;
+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.taglib.CustomTagLibManager;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ * @author Alexey Kazakov
+ */
+@SuppressWarnings("restriction")
+public class FaceletsJsfCProposalType extends CustomProposalType {
+
+ private static Image ICON;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ // trim first spaces
+ String value = query.getValue();
+ while(true) {
+ if(value.startsWith(" ")) { //$NON-NLS-1$
+ value = value.substring(1);
+ } else {
+ break;
+ }
+ }
+ KbQuery kbQuery = new KbQuery();
+ kbQuery.setMask(query.isMask());
+ kbQuery.setType(KbQuery.Type.TAG_NAME);
+ kbQuery.setValue(query.getValue());
+ kbQuery.setOffset(query.getOffset());
+
+ IComponent[] components = null;
+ List<TextProposal> proposals = null;
+ components = PageProcessor.getInstance().getComponents(kbQuery, context);
+ if(components.length==0) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ proposals = new ArrayList<TextProposal>();
+ Map<String, List<String>> prefixes = new HashMap<String,
List<String>>();
+ for (int i = 0; i < components.length; i++) {
+ ITagLibrary lib = components[i].getTagLib();
+ if(ignoreTagLib(lib)) {
+ continue;
+ }
+ List<String> pfx = prefixes.get(lib.getURI());
+ if(pfx==null) {
+ pfx = getPrefixes((IPageContext)context, components[i], kbQuery);
+ prefixes.put(lib.getURI(), pfx);
+ }
+ for (String prefix : pfx) {
+ TextProposal proposal = getProposal(prefix, components[i]);
+ proposals.add(proposal);
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private boolean ignoreTagLib(ITagLibrary lib) {
+ return CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(lib.getURI()) ||
CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI.equals(lib.getURI());
+ }
+
+ private TextProposal getProposal(String prefix, IComponent component) {
+ TextProposal proposal = new TextProposal();
+ proposal.setContextInfo(component.getDescription());
+ proposal.setSource(component);
+ StringBuffer label = new StringBuffer();
+ label.append(prefix + KbQuery.PREFIX_SEPARATOR);
+ label.append(component.getName());
+ proposal.setLabel(label.toString());
+ proposal.setReplacementString(proposal.getLabel());
+ int position = proposal.getReplacementString().length();
+ proposal.setPosition(position);
+ if (ICON == null) {
+ ICON =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ proposal.setImage(ICON);
+
+ return proposal;
+ }
+
+ private List<String> getPrefixes(IPageContext context, IComponent component,
KbQuery query) {
+ List<String> prefixes = new ArrayList<String>();
+ Map<String, List<INameSpace>> nameSpaces =
context.getNameSpaces(query.getOffset());
+ if(nameSpaces!=null) {
+ List<INameSpace> nameSpace = nameSpaces.get(component.getTagLib().getURI());
+ if(nameSpace!=null) {
+ for (INameSpace n : nameSpace) {
+ prefixes.add(n.getPrefix());
+ }
+ }
+ }
+ return prefixes;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FaceletsJsfCProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FacetNameProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FacetNameProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FacetNameProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+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.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.taglib.Facet;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+import org.jboss.tools.jst.web.kb.taglib.IFacesConfigTagLibrary;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+import org.jboss.tools.jst.web.kb.taglib.TagLibraryManager;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class FacetNameProposalType extends CustomProposalType {
+
+ private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ private IPageContext context;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ String[] parentTags = query.getParentTags();
+ Set<String> facetNames = new HashSet<String>();
+ if(parentTags.length>1) {
+ String parentTag = parentTags[parentTags.length-2];
+ KbQuery newQuery = new KbQuery();
+ newQuery.setMask(false);
+ newQuery.setType(KbQuery.Type.TAG_NAME);
+ newQuery.setValue(parentTag);
+ newQuery.setOffset(query.getOffset());
+ IComponent[] components = PageProcessor.getInstance().getComponents(newQuery,
context);
+ Set<String> types = new HashSet<String>();
+ for (int i = 0; i < components.length; i++) {
+ String type = components[i].getComponentType();
+ if(type!=null) {
+ types.add(type.trim());
+ }
+ }
+ if(!types.isEmpty()) {
+ ITagLibrary[] libs =
TagLibraryManager.getLibraries(context.getResource().getProject());
+ for (ITagLibrary lib : libs) {
+ if(lib instanceof IFacesConfigTagLibrary) {
+ for (String type : types) {
+ IComponent comp = lib.getComponentByType(type);
+ Facet[] facets = comp.getFacets();
+ if(facets!=null) {
+ for (int i = 0; i < facets.length; i++) {
+ facetNames.add(facets[i].getName());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (String facetName : facetNames) {
+ if(facetName.startsWith(query.getValue())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(facetName);
+ proposal.setReplacementString(facetName);
+ proposal.setPosition(facetName.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposals.add(proposal);
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ this.context = context;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/FacetNameProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/IDProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/IDProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/IDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+@SuppressWarnings("restriction")
+public class IDProposalType extends CustomProposalType {
+ private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ static String ID = "id"; //$NON-NLS-1$
+ static String QUOTE_1 = "'"; //$NON-NLS-1$
+ static String QUOTE_2 = "\""; //$NON-NLS-1$
+ Set<String> idList = new TreeSet<String>();
+
+ @Override
+ protected void init(IPageContext context) {
+ idList.clear();
+
+ IDocument document = context.getDocument();
+ IStructuredModel sModel =
StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ try {
+ if (sModel != null) {
+ Document sd = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() :
null;
+ if(sd != null) {
+ Element root = sd.getDocumentElement();
+ collectIDs(root);
+ }
+ }
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+ private void collectIDs(Element element) {
+ String id = element.getAttribute(ID);
+ if(id != null && id.length() > 0) idList.add(id);
+ NodeList cs = element.getChildNodes();
+ for (int i = 0; i < cs.getLength(); i++) {
+ Node n = cs.item(i);
+ if(n.getNodeType() == Node.ELEMENT_NODE) {
+ collectIDs((Element)n);
+ }
+ }
+ }
+
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ String v = query.getValue();
+ int offset = v.length();
+ int b = v.lastIndexOf(',');
+ if(b < 0) b = 0; else b += 1;
+ String tail = v.substring(offset);
+ int e = tail.indexOf(',');
+ if(e < 0) e = v.length(); else e += offset;
+ String prefix = v.substring(b).trim();
+
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (String text: idList) {
+ if(text.startsWith(prefix)) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(b + text.length());
+ proposal.setStart(b);
+ proposal.setEnd(e);
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+
+ proposals.add(proposal);
+ }
+ }
+
+ return proposals.toArray(new TextProposal[0]);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/IDProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ModelProposalType.java
(from rev 19273,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ModelProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ModelProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class ModelProposalType extends CustomProposalType {
+
+ protected WebPromptingProvider provider;
+ protected XModel xModel;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ provider = WebPromptingProvider.getInstance();
+ xModel = null;
+ IModelNature nature =
EclipseResourceUtil.getModelNature(context.getResource().getProject());
+ if(nature!=null) {
+ xModel = nature.getModel();
+ }
+ }
+
+ protected boolean isReadyToUse() {
+ return (provider != null && xModel != null);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ModelProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/NameSpaceProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/NameSpaceProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/NameSpaceProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class NameSpaceProposalType extends ModelProposalType {
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ String rQuery = getPassiveQueryPart(query.getValue());
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<Object> beanList = provider.getList(xModel,
WebPromptingProvider.JSF_GET_TAGLIBS, "", null); //$NON-NLS-1$
+ Iterator<Object> itr = beanList.iterator();
+ while (itr.hasNext()) {
+ sorted.add(itr.next().toString());
+ }
+ for (String text : sorted) {
+ if(rQuery.length() == 0 || text.startsWith(rQuery)) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposals.add(proposal);
+ proposal.setPosition(proposal.getReplacementString().length());
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private String getPassiveQueryPart(String query) {
+ if (query == null || query.trim().length() == 0) {
+ return ""; //$NON-NLS-1$
+ }
+ return query;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/NameSpaceProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourceBundleNameProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourceBundleNameProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourceBundleNameProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ResourceBundleNameProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "MessageBundleProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<Object> sourceList = provider.getList(xModel,
WebPromptingProvider.JSF_BUNDLES, "", null); //$NON-NLS-1$
+ if (sourceList != null && !sourceList.isEmpty()) {
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Iterator<Object> it = sourceList.iterator();
+ while(it.hasNext()) {
+ sorted.add(it.next().toString());
+ }
+ for (String text : sorted) {
+ if (text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class,
IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourceBundleNameProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourcePathProposalType.java
(from rev 19273,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourcePathProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourcePathProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,301 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ResourcePathProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "ResourcePathProposal.gif";
//$NON-NLS-1$
+ private static Image ICON;
+ private static Set<String> GRAPHIC_FILE_EXTENSIONS = new HashSet<String>();
+ private static Set<String> PAGE_FILE_EXTENSIONS = new HashSet<String>();
+ static {
+ String[] images = {"gif", "jpeg", "jpg", "png",
"wbmp", "bmp"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ for (int i = 0; i < images.length; i++) {
+ GRAPHIC_FILE_EXTENSIONS.add(images[i]);
+ }
+ String[] pages = {"jsp", "htm", "html",
"xhtml", "xml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$
+ for (int i = 0; i < pages.length; i++) {
+ PAGE_FILE_EXTENSIONS.add(pages[i]);
+ }
+ }
+ private static String PATH_ADDITION = "pathAddition"; //$NON-NLS-1$
+
+ private IContainer webRootResource;
+ private Set<String> extensions;
+ private List<String> enumeration;
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ super.init(context);
+ webRootResource = null;
+ if(xModel != null) {
+ XModelObject webInf = FileSystemsHelper.getWebInf(xModel);
+ XModelObject webRoot = FileSystemsHelper.getWebRoot(xModel);
+ if(webInf != null && webRoot != null) {
+ webRootResource = (IContainer)EclipseResourceUtil.getResource(webRoot);
+ }
+ }
+ if(extensions==null) {
+ initExtensions();
+ }
+ if(enumeration==null) {
+ enumeration = new ArrayList<String>();
+ if(params!=null) {
+ for (int i = 0; i < params.length; i++) {
+ if(PATH_ADDITION.equals(params[i].getName())) {
+ enumeration.add(params[i].getValue());
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ if(!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ ImagePathDescriptor[] images = getImagesFilesPathes(query.getValue());
+ for(int i=0; i<images.length; i++) {
+ TextProposal proposal = new TextProposal();
+ 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());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ for (String path : enumeration) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(path);
+ String replacementString = path;
+ proposal.setAutoActivationContentAssistantAfterApplication(false);
+ proposal.setReplacementString(replacementString);
+ proposal.setPosition(replacementString.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private static final String EXTENSIONS_PARAM_NAME = "extensions";
//$NON-NLS-1$
+ private static final String IMAGE_PARAM_TYPE = "%image%"; //$NON-NLS-1$
+ private static final String PAGE_PARAM_TYPE = "%page%"; //$NON-NLS-1$
+
+ private void initExtensions() {
+ String value = getParamValue(EXTENSIONS_PARAM_NAME);
+ if(value != null && !value.equals("*")) { //$NON-NLS-1$
+ if(IMAGE_PARAM_TYPE.equals(value)) {
+ this.extensions = GRAPHIC_FILE_EXTENSIONS;
+ } else if("%page%".equals(value)) { //$NON-NLS-1$
+ this.extensions = PAGE_FILE_EXTENSIONS;
+ } else {
+ StringTokenizer st = new StringTokenizer(value, ",;"); //$NON-NLS-1$
+ if(st.countTokens() > 0) {
+ extensions = new HashSet<String>();
+ while(st.hasMoreTokens()) {
+ String t = st.nextToken().trim();
+ if(t.length() == 0) {
+ continue;
+ }
+ if(IMAGE_PARAM_TYPE.equals(t)) {
+ extensions.addAll(GRAPHIC_FILE_EXTENSIONS);
+ } else if(PAGE_PARAM_TYPE.equals(t)) {
+ extensions.addAll(PAGE_FILE_EXTENSIONS);
+ } else {
+ extensions.add(t);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#isReadyToUse()
+ */
+ protected boolean isReadyToUse() {
+ return webRootResource!=null;
+ }
+
+ private ImagePathDescriptor[] getImagesFilesPathes(String query) {
+ query = query.trim();
+ if(query.indexOf('\\')>-1) {
+ return new ImagePathDescriptor[0];
+ }
+ if(query.length()==0) {
+ query = "/"; //$NON-NLS-1$
+ }
+ int lastSeparator = query.lastIndexOf('/');
+ String name = null;
+ String pathWithoutLastSegment = null;
+ if(lastSeparator>-1) {
+ pathWithoutLastSegment = query.substring(0, lastSeparator);
+ if(lastSeparator+1<query.length()) {
+ name = query.substring(lastSeparator+1, query.length());
+ } else {
+ name = ""; //$NON-NLS-1$
+ }
+ } else {
+ pathWithoutLastSegment = ""; //$NON-NLS-1$
+ name = query;
+ }
+ if(name.equals(".") || name.equals("..")) { //$NON-NLS-1$
//$NON-NLS-2$
+ if(pathWithoutLastSegment.length()>0) {
+ pathWithoutLastSegment = pathWithoutLastSegment + "/" + name;
//$NON-NLS-1$
+ } else {
+ if(query.startsWith("/")) { //$NON-NLS-1$
+ pathWithoutLastSegment = "/" + name; //$NON-NLS-1$
+ } else {
+ pathWithoutLastSegment = name;
+ }
+ }
+ name = ""; //$NON-NLS-1$
+ }
+ if(name==null) {
+ name = ""; //$NON-NLS-1$
+ }
+ IResource resource;
+ String startPath = pathWithoutLastSegment;
+ if(pathWithoutLastSegment.startsWith("/")) { //$NON-NLS-1$
+ if(pathWithoutLastSegment.length()>1) {
+ startPath = pathWithoutLastSegment.substring(1);
+ } else {
+ startPath = ""; //$NON-NLS-1$
+ }
+ }
+ if(query.startsWith("/")) { //$NON-NLS-1$
+ resource = webRootResource.findMember(startPath);
+ } else {
+ resource = context.getResource().getParent().findMember(startPath);
+ }
+
+ List<IResource> resources = new ArrayList<IResource>();
+ try {
+ if(resource != null) resource.accept(new ImagesFinder(resources, name, extensions));
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ ImagePathDescriptor[] filesPathes = new ImagePathDescriptor[resources.size()];
+ for(int i=0; i<filesPathes.length; i++) {
+ String prefix = pathWithoutLastSegment.toString();
+ if(!prefix.endsWith("/")) { //$NON-NLS-1$
+ prefix = prefix + '/';
+ }
+ IResource r = (IResource)resources.get(i);
+ filesPathes[i] = new ImagePathDescriptor(prefix + r.getName(), r);
+ }
+ return filesPathes;
+ }
+
+ private static class ImagePathDescriptor {
+ private String queryPath;
+ private IResource resource;
+
+ public ImagePathDescriptor(String queryPath, IResource resource) {
+ this.queryPath = queryPath;
+ this.resource = resource;
+ }
+
+ public String getQueryPath() {
+ return queryPath;
+ }
+
+ public IResource getResource() {
+ return resource;
+ }
+ }
+
+ private static class ImagesFinder implements IResourceVisitor {
+ private List<IResource> resources;
+ private int count = 0;
+ private String name;
+ Set<String> extensions = null;
+
+ /**
+ * @param resources
+ * @param name
+ * @param extensions
+ */
+ public ImagesFinder(List<IResource> resources, String name, Set<String>
extensions) {
+ this.resources = resources;
+ this.name = name;
+ this.extensions = extensions;
+ }
+
+ boolean acceptExtension(String ext) {
+ if(ext != null) {
+ ext = ext.toLowerCase();
+ }
+ return (extensions == null || extensions.contains(ext));
+ }
+
+ public boolean visit(IResource resource) throws CoreException {
+ if(resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ if(resource.getName().startsWith(name) &&
acceptExtension(file.getFileExtension())) {
+ resources.add(resource);
+ }
+ } else if(resource instanceof IFolder) {
+ if(count==0) {
+ count++;
+ return true;
+ } else if(resource.getName().startsWith(name) &&
(!resource.getName().equals("WEB-INF")) &&
(!resource.getName().equals("META-INF"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ resources.add(resource);
+ }
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ResourcePathProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ValidatorIDProposalType.java
(from rev 19076,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ValidatorIDProposalType.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ValidatorIDProposalType.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ValidatorIDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.proposal;
+
+import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class ValidatorIDProposalType extends ConverterIDProposalType {
+
+ public ValidatorIDProposalType() {}
+
+ @Override
+ protected String getListID() {
+ return IWebPromptingProvider.JSF_VALIDATOR_IDS;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/ValidatorIDProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -77,6 +77,20 @@
return components.get(name);
}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.taglib.ITagLibrary#getComponentByType(java.lang.String)
+ */
+ public IComponent getComponentByType(String type) {
+ IComponent[] comps = getComponents();
+ for (int i = 0; i < comps.length; i++) {
+ if(type.equals(comps[i].getComponentType())) {
+ return comps[i];
+ }
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getComponents(java.lang.String)
*/
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Alexey Kazakov
- */
-public class ActionProposalType extends ModelProposalType {
-
- private static final String IMAGE_NAME = "JSFActionProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- if (!isReadyToUse()) {
- return EMPTY_PROPOSAL_LIST;
- }
- XModelObject xModelObject =
EclipseResourceUtil.getObjectByResource(context.getResource());
- if(xModelObject==null) {
- return EMPTY_PROPOSAL_LIST;
- }
- String path = XModelObjectLoaderUtil.getResourcePath(xModelObject);
- if(path==null) {
- return EMPTY_PROPOSAL_LIST;
- }
- Properties view = new Properties();
- view.put(IWebPromptingProvider.VIEW_PATH, path);
- List<Object> sourceList = provider.getList(xModel,
WebPromptingProvider.JSF_VIEW_ACTIONS, "", view); //$NON-NLS-1$
- if (sourceList != null && !sourceList.isEmpty()) {
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Iterator<Object> it = sourceList.iterator();
- while(it.hasNext()) {
- sorted.add(it.next().toString());
- }
- for (String text : sorted) {
- if (text.trim().length() > 0 &&
text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class,
IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
- proposals.add(proposal);
- }
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
-import org.w3c.dom.css.CSSRule;
-import org.w3c.dom.css.CSSRuleList;
-
-/**
- * The CSS Class proposal type. Is used to collect and return the proposals on
- * the CSS classes
- *
- * @author Victor Rubezhny
- *
- */
-@SuppressWarnings("restriction")
-public class CSSClassProposalType extends CustomProposalType {
- private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- static String ID = "cssclass"; //$NON-NLS-1$
- static String QUOTE_1 = "'"; //$NON-NLS-1$
- static String QUOTE_2 = "\""; //$NON-NLS-1$
- Set<String> idList = new TreeSet<String>();
-
- @Override
- protected void init(IPageContext context) {
- idList.clear();
- if (context instanceof ICSSContainerSupport) {
- ICSSContainerSupport cssSource = (ICSSContainerSupport)context;
-
- List<CSSStyleSheetDescriptor> descrs = cssSource.getCSSStyleSheetDescriptors();
- if (descrs != null) {
- for (CSSStyleSheetDescriptor descr : descrs) {
- CSSRuleList rules = descr.sheet.getCssRules();
- for (int i = 0; rules != null && i < rules.getLength(); i++) {
- CSSRule rule = rules.item(i);
- idList.addAll(getNamesFromCSSRule(rule));
- }
- }
- }
- }
- }
-
- /**
- * Returns the style name found in the specified CSS Rule
- *
- * @param cssRule
- * @param styleName
- * @return
- */
- public static Set<String> getNamesFromCSSRule(CSSRule cssRule) {
- Set<String> styleNames = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-
- // get selector text
- String selectorText = ((ICSSStyleRule) cssRule).getSelectorText();
-
- if (selectorText != null) {
- String styles[] = selectorText.trim().split(","); //$NON-NLS-1$
- for (String styleText : styles) {
- String[] styleWords = styleText.trim().split(" "); //$NON-NLS-1$
- if (styleWords != null) {
- for (String name : styleWords) {
- if (name.startsWith(".")) //$NON-NLS-1$
- continue;
-
- if (name.indexOf("[") >= 0) { //$NON-NLS-1$
- name = name.substring(0, name.indexOf("[")); //$NON-NLS-1$
- }
- if (name.indexOf(".") >= 0) { //$NON-NLS-1$
- name = name.substring(0, name.indexOf(".")); //$NON-NLS-1$
- }
- if (name.indexOf(":") >= 0) { //$NON-NLS-1$
- name = name.substring(0, name.indexOf(":")); //$NON-NLS-1$
- }
-
- // Use the first word as a style name
- styleNames.add(name);
- }
- }
- }
- }
- return styleNames;
- }
-
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- String v = query.getValue();
- int offset = v.length();
- int b = v.lastIndexOf(',');
- if(b < 0) b = 0; else b += 1;
- String tail = v.substring(offset);
- int e = tail.indexOf(',');
- if(e < 0) e = v.length(); else e += offset;
- String prefix = v.substring(b).trim();
-
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (String text: idList) {
- if(text.startsWith(prefix)) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(b + text.length());
- proposal.setStart(b);
- proposal.setEnd(e);
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
-
- proposals.add(proposal);
- }
- }
-
- return proposals.toArray(new TextProposal[0]);
- }
-
-}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ConverterIDProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ConverterIDProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ConverterIDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-
-/**
- *
- * @author Viacheslav Kabanovich
- *
- */
-public class ConverterIDProposalType extends ModelProposalType {
-
- private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- public ConverterIDProposalType() {}
-
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- String v = query.getValue();
-
- List<Object> list = provider.getList(xModel, getListID(), v, new Properties());
- Set<String> idList = new TreeSet<String>();
- if(list != null) {
- for (Object o: list) idList.add(o.toString());
- }
-
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (String text: idList) {
- if(text.startsWith(v)) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
-
- proposals.add(proposal);
- }
- }
-
- return proposals.toArray(new TextProposal[0]);
- }
-
- protected String getListID() {
- return IWebPromptingProvider.JSF_CONVERTER_IDS;
- }
-
-}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IProposalProcessor;
-import org.jboss.tools.jst.web.kb.KbQuery;
-
-/**
- * @author Alexey Kazakov
- */
-public abstract class CustomProposalType implements IProposalProcessor {
-
- protected Param[] params;
- protected String type;
- protected IPageContext context;
-
- protected abstract void init(IPageContext context);
-
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * @return the params
- */
- public Param[] getParams() {
- if(params==null) {
- params = new Param[0];
- }
- return params;
- }
-
- /**
- * @param params the params to set
- */
- public void setParams(Param[] params) {
- this.params = params;
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
- */
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
- this.context = context;
- init(context);
- return getProposals(query);
- }
-
- /**
- * @param name
- * @return
- */
- public String getParamValue(String name) {
- if(params==null) {
- return null;
- }
- for (int i = 0; i < params.length; i++) {
- if(name.equals(params[i].getName())) {
- return params[i].getValue();
- }
- }
- return null;
- }
-
- abstract public TextProposal[] getProposals(KbQuery query);
-
- public static class Param {
-
- private String name;
- private String value;
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the value
- */
- public String getValue() {
- return value;
- }
-
- /**
- * @param value the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-
-/**
- * @author Alexey Kazakov
- */
-public class CustomProposalTypeFactory {
-
- private static final CustomProposalTypeFactory INSTANCE = new
CustomProposalTypeFactory();
-
- public static final String RESOURCE_BUNDLE_NAME_TYPE = "bundleName";
//$NON-NLS-1$
- public static final String ACTION_TYPE = "viewActions"; //$NON-NLS-1$
- public static final String RESOURCE_PATH_TYPE = "file"; //$NON-NLS-1$
- public static final String ENUMERATION_TYPE = "enumeration"; //$NON-NLS-1$
- public static final String FACELETS_JSFC_TYPE = "faceletsJsfCTags";
//$NON-NLS-1$
- public static final String NAME_SPACE_TYPE = "taglib"; //$NON-NLS-1$
- public static final String ID_TYPE = "id"; //$NON-NLS-1$
- public static final String CONVERTER_ID_TYPE = "converterID"; //$NON-NLS-1$
- public static final String VALIDATOR_ID_TYPE = "validatorID"; //$NON-NLS-1$
- public static final String CSSCLASS_TYPE = "cssclass"; //$NON-NLS-1$
-
- private CustomProposalTypeFactory() {
- }
-
- /**
- * @return an instance of this factory.
- */
- public static CustomProposalTypeFactory getInstance() {
- return INSTANCE;
- }
-
- /**
- * Creates Custom Proposal Type by name
- * @param type
- * @return
- */
- public CustomProposalType createProposalType(String type) {
- if(RESOURCE_BUNDLE_NAME_TYPE.equals(type)) {
- return new ResourceBundleNameProposalType();
- }
- if(ACTION_TYPE.equals(type)) {
- return new ActionProposalType();
- }
- if(RESOURCE_PATH_TYPE.equals(type)) {
- return new ResourcePathProposalType();
- }
- if(ENUMERATION_TYPE.equals(type)) {
- return new EnumerationProposalType();
- }
- if(FACELETS_JSFC_TYPE.equals(type)) {
- return new FaceletsJsfCProposalType();
- }
- if(NAME_SPACE_TYPE.equals(type)) {
- return new NameSpaceProposalType();
- }
- if(ID_TYPE.equals(type)) {
- return new IDProposalType();
- }
- if(CONVERTER_ID_TYPE.equals(type)) {
- return new ConverterIDProposalType();
- }
- if(VALIDATOR_ID_TYPE.equals(type)) {
- return new ValidatorIDProposalType();
- }
- if(CSSCLASS_TYPE.equals(type)) {
- return new CSSClassProposalType();
- }
-
- //WebKbPlugin.getDefault().logError("Unknown proposal type: " + type);
//$NON-NLS-1$
- //ExtendedProposalType will report if necessary
-
- EmptyProposalType proposalType = new EmptyProposalType();
-
- return proposalType;
- }
-}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -23,6 +23,8 @@
import javax.xml.parsers.ParserConfigurationException;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalTypeFactory;
import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibrary;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EmptyProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EmptyProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EmptyProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-
-public class EmptyProposalType extends CustomProposalType {
-
- public EmptyProposalType() {}
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- return EMPTY_PROPOSAL_LIST;
- }
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-
-/**
- * @author Alexey Kazakov
- */
-public class EnumerationProposalType extends CustomProposalType {
-
- private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- if(params==null) {
- return EMPTY_PROPOSAL_LIST;
- }
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (int i = 0; i < params.length; i++) {
- String text = params[i].getValue();
- if(text.startsWith(query.getValue())) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
- proposals.add(proposal);
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.jboss.tools.common.text.TextProposal;
-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.taglib.CustomTagLibManager;
-import org.jboss.tools.jst.web.kb.taglib.IComponent;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-
-/**
- * @author Alexey Kazakov
- */
-@SuppressWarnings("restriction")
-public class FaceletsJsfCProposalType extends CustomProposalType {
-
- private static Image ICON;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- // trim first spaces
- String value = query.getValue();
- while(true) {
- if(value.startsWith(" ")) { //$NON-NLS-1$
- value = value.substring(1);
- } else {
- break;
- }
- }
- KbQuery kbQuery = new KbQuery();
- kbQuery.setMask(query.isMask());
- kbQuery.setType(KbQuery.Type.TAG_NAME);
- kbQuery.setValue(query.getValue());
- kbQuery.setOffset(query.getOffset());
-
- IComponent[] components = null;
- List<TextProposal> proposals = null;
- components = PageProcessor.getInstance().getComponents(kbQuery, context);
- if(components.length==0) {
- return EMPTY_PROPOSAL_LIST;
- }
- proposals = new ArrayList<TextProposal>();
- Map<String, List<String>> prefixes = new HashMap<String,
List<String>>();
- for (int i = 0; i < components.length; i++) {
- ITagLibrary lib = components[i].getTagLib();
- if(ignoreTagLib(lib)) {
- continue;
- }
- List<String> pfx = prefixes.get(lib.getURI());
- if(pfx==null) {
- pfx = getPrefixes((IPageContext)context, components[i], kbQuery);
- prefixes.put(lib.getURI(), pfx);
- }
- for (String prefix : pfx) {
- TextProposal proposal = getProposal(prefix, components[i]);
- proposals.add(proposal);
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-
- private boolean ignoreTagLib(ITagLibrary lib) {
- return CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(lib.getURI()) ||
CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI.equals(lib.getURI());
- }
-
- private TextProposal getProposal(String prefix, IComponent component) {
- TextProposal proposal = new TextProposal();
- proposal.setContextInfo(component.getDescription());
- proposal.setSource(component);
- StringBuffer label = new StringBuffer();
- label.append(prefix + KbQuery.PREFIX_SEPARATOR);
- label.append(component.getName());
- proposal.setLabel(label.toString());
- proposal.setReplacementString(proposal.getLabel());
- int position = proposal.getReplacementString().length();
- proposal.setPosition(position);
- if (ICON == null) {
- ICON =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- proposal.setImage(ICON);
-
- return proposal;
- }
-
- private List<String> getPrefixes(IPageContext context, IComponent component,
KbQuery query) {
- List<String> prefixes = new ArrayList<String>();
- Map<String, List<INameSpace>> nameSpaces =
context.getNameSpaces(query.getOffset());
- if(nameSpaces!=null) {
- List<INameSpace> nameSpace = nameSpaces.get(component.getTagLib().getURI());
- if(nameSpace!=null) {
- for (INameSpace n : nameSpace) {
- prefixes.add(n.getPrefix());
- }
- }
- }
- return prefixes;
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.text.TextProposal;
-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.WebKbPlugin;
-import org.jboss.tools.jst.web.kb.taglib.IFaceletTagLibrary;
-import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-
-/**
- * @author Alexey Kazakov
- */
-public class FacetNameProposalType extends CustomProposalType {
-
- private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- private IPageContext context;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- String[] parentTags = query.getParentTags();
- if(parentTags.length>1) {
- String parentTag = parentTags[parentTags.length-2];
- if(parentTag.contains(":")) { //$NON-NLS-1$
- KbQuery newQuery = new KbQuery();
- newQuery.setMask(false);
- newQuery.setType(KbQuery.Type.TAG_NAME);
- newQuery.setValue(parentTag);
- PageProcessor.getInstance().getComponents(query, context);
- ITagLibrary[] libs = context.getLibraries();
- for (ITagLibrary l : libs) {
- if(l instanceof IFaceletTagLibrary) {
- //TODO
- }
- }
- }
- }
- List<String> facetNames = new ArrayList<String>();
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (String facetName : facetNames) {
- if(facetName.startsWith(query.getValue())) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(facetName);
- proposal.setReplacementString(facetName);
- proposal.setPosition(facetName.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposals.add(proposal);
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- this.context = context;
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-@SuppressWarnings("restriction")
-public class IDProposalType extends CustomProposalType {
- private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- static String ID = "id"; //$NON-NLS-1$
- static String QUOTE_1 = "'"; //$NON-NLS-1$
- static String QUOTE_2 = "\""; //$NON-NLS-1$
- Set<String> idList = new TreeSet<String>();
-
- @Override
- protected void init(IPageContext context) {
- idList.clear();
-
- IDocument document = context.getDocument();
- IStructuredModel sModel =
StructuredModelManager.getModelManager().getExistingModelForRead(document);
- try {
- if (sModel != null) {
- Document sd = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() :
null;
- if(sd != null) {
- Element root = sd.getDocumentElement();
- collectIDs(root);
- }
- }
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- private void collectIDs(Element element) {
- String id = element.getAttribute(ID);
- if(id != null && id.length() > 0) idList.add(id);
- NodeList cs = element.getChildNodes();
- for (int i = 0; i < cs.getLength(); i++) {
- Node n = cs.item(i);
- if(n.getNodeType() == Node.ELEMENT_NODE) {
- collectIDs((Element)n);
- }
- }
- }
-
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- String v = query.getValue();
- int offset = v.length();
- int b = v.lastIndexOf(',');
- if(b < 0) b = 0; else b += 1;
- String tail = v.substring(offset);
- int e = tail.indexOf(',');
- if(e < 0) e = v.length(); else e += offset;
- String prefix = v.substring(b).trim();
-
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (String text: idList) {
- if(text.startsWith(prefix)) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(b + text.length());
- proposal.setStart(b);
- proposal.setEnd(e);
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
-
- proposals.add(proposal);
- }
- }
-
- return proposals.toArray(new TextProposal[0]);
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Alexey Kazakov
- */
-public abstract class ModelProposalType extends CustomProposalType {
-
- protected WebPromptingProvider provider;
- protected XModel xModel;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- provider = WebPromptingProvider.getInstance();
- xModel = null;
- IModelNature nature =
EclipseResourceUtil.getModelNature(context.getResource().getProject());
- if(nature!=null) {
- xModel = nature.getModel();
- }
- }
-
- protected boolean isReadyToUse() {
- return (provider != null && xModel != null);
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Alexey Kazakov
- */
-public class NameSpaceProposalType extends ModelProposalType {
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- if (!isReadyToUse()) {
- return EMPTY_PROPOSAL_LIST;
- }
- String rQuery = getPassiveQueryPart(query.getValue());
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- List<Object> beanList = provider.getList(xModel,
WebPromptingProvider.JSF_GET_TAGLIBS, "", null); //$NON-NLS-1$
- Iterator<Object> itr = beanList.iterator();
- while (itr.hasNext()) {
- sorted.add(itr.next().toString());
- }
- for (String text : sorted) {
- if(rQuery.length() == 0 || text.startsWith(rQuery)) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposals.add(proposal);
- proposal.setPosition(proposal.getReplacementString().length());
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-
- private String getPassiveQueryPart(String query) {
- if (query == null || query.trim().length() == 0) {
- return ""; //$NON-NLS-1$
- }
- return query;
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-
-/**
- * @author Alexey Kazakov
- */
-public class ResourceBundleNameProposalType extends ModelProposalType {
-
- private static final String IMAGE_NAME = "MessageBundleProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- if (!isReadyToUse()) {
- return EMPTY_PROPOSAL_LIST;
- }
- List<Object> sourceList = provider.getList(xModel,
WebPromptingProvider.JSF_BUNDLES, "", null); //$NON-NLS-1$
- if (sourceList != null && !sourceList.isEmpty()) {
- Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- Iterator<Object> it = sourceList.iterator();
- while(it.hasNext()) {
- sorted.add(it.next().toString());
- }
- for (String text : sorted) {
- if (text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(text);
- proposal.setReplacementString(text);
- proposal.setPosition(text.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class,
IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
- proposals.add(proposal);
- }
- }
- }
- return proposals.toArray(new TextProposal[0]);
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-
-/**
- * @author Alexey Kazakov
- */
-public class ResourcePathProposalType extends ModelProposalType {
-
- private static final String IMAGE_NAME = "ResourcePathProposal.gif";
//$NON-NLS-1$
- private static Image ICON;
- private static Set<String> GRAPHIC_FILE_EXTENSIONS = new HashSet<String>();
- private static Set<String> PAGE_FILE_EXTENSIONS = new HashSet<String>();
- static {
- String[] images = {"gif", "jpeg", "jpg", "png",
"wbmp", "bmp"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- for (int i = 0; i < images.length; i++) {
- GRAPHIC_FILE_EXTENSIONS.add(images[i]);
- }
- String[] pages = {"jsp", "htm", "html",
"xhtml", "xml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$
- for (int i = 0; i < pages.length; i++) {
- PAGE_FILE_EXTENSIONS.add(pages[i]);
- }
- }
- private static String PATH_ADDITION = "pathAddition"; //$NON-NLS-1$
-
- private IContainer webRootResource;
- private Set<String> extensions;
- private List<String> enumeration;
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
- */
- @Override
- protected void init(IPageContext context) {
- super.init(context);
- webRootResource = null;
- if(xModel != null) {
- XModelObject webInf = FileSystemsHelper.getWebInf(xModel);
- XModelObject webRoot = FileSystemsHelper.getWebRoot(xModel);
- if(webInf != null && webRoot != null) {
- webRootResource = (IContainer)EclipseResourceUtil.getResource(webRoot);
- }
- }
- if(extensions==null) {
- initExtensions();
- }
- if(enumeration==null) {
- enumeration = new ArrayList<String>();
- if(params!=null) {
- for (int i = 0; i < params.length; i++) {
- if(PATH_ADDITION.equals(params[i].getName())) {
- enumeration.add(params[i].getValue());
- }
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
- */
- @Override
- public TextProposal[] getProposals(KbQuery query) {
- if(!isReadyToUse()) {
- return EMPTY_PROPOSAL_LIST;
- }
- List<TextProposal> proposals = new ArrayList<TextProposal>();
- ImagePathDescriptor[] images = getImagesFilesPathes(query.getValue());
- for(int i=0; i<images.length; i++) {
- TextProposal proposal = new TextProposal();
- 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());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
- proposals.add(proposal);
- }
- for (String path : enumeration) {
- TextProposal proposal = new TextProposal();
- proposal.setLabel(path);
- String replacementString = path;
- proposal.setAutoActivationContentAssistantAfterApplication(false);
- proposal.setReplacementString(replacementString);
- proposal.setPosition(replacementString.length());
- if(ICON==null) {
- ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
- }
- proposal.setImage(ICON);
- proposals.add(proposal);
- }
- return proposals.toArray(new TextProposal[0]);
- }
-
- private static final String EXTENSIONS_PARAM_NAME = "extensions";
//$NON-NLS-1$
- private static final String IMAGE_PARAM_TYPE = "%image%"; //$NON-NLS-1$
- private static final String PAGE_PARAM_TYPE = "%page%"; //$NON-NLS-1$
-
- private void initExtensions() {
- String value = getParamValue(EXTENSIONS_PARAM_NAME);
- if(value != null && !value.equals("*")) { //$NON-NLS-1$
- if(IMAGE_PARAM_TYPE.equals(value)) {
- this.extensions = GRAPHIC_FILE_EXTENSIONS;
- } else if("%page%".equals(value)) { //$NON-NLS-1$
- this.extensions = PAGE_FILE_EXTENSIONS;
- } else {
- StringTokenizer st = new StringTokenizer(value, ",;"); //$NON-NLS-1$
- if(st.countTokens() > 0) {
- extensions = new HashSet<String>();
- while(st.hasMoreTokens()) {
- String t = st.nextToken().trim();
- if(t.length() == 0) {
- continue;
- }
- if(IMAGE_PARAM_TYPE.equals(t)) {
- extensions.addAll(GRAPHIC_FILE_EXTENSIONS);
- } else if(PAGE_PARAM_TYPE.equals(t)) {
- extensions.addAll(PAGE_FILE_EXTENSIONS);
- } else {
- extensions.add(t);
- }
- }
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#isReadyToUse()
- */
- protected boolean isReadyToUse() {
- return webRootResource!=null;
- }
-
- private ImagePathDescriptor[] getImagesFilesPathes(String query) {
- query = query.trim();
- if(query.indexOf('\\')>-1) {
- return new ImagePathDescriptor[0];
- }
- if(query.length()==0) {
- query = "/"; //$NON-NLS-1$
- }
- int lastSeparator = query.lastIndexOf('/');
- String name = null;
- String pathWithoutLastSegment = null;
- if(lastSeparator>-1) {
- pathWithoutLastSegment = query.substring(0, lastSeparator);
- if(lastSeparator+1<query.length()) {
- name = query.substring(lastSeparator+1, query.length());
- } else {
- name = ""; //$NON-NLS-1$
- }
- } else {
- pathWithoutLastSegment = ""; //$NON-NLS-1$
- name = query;
- }
- if(name.equals(".") || name.equals("..")) { //$NON-NLS-1$
//$NON-NLS-2$
- if(pathWithoutLastSegment.length()>0) {
- pathWithoutLastSegment = pathWithoutLastSegment + "/" + name;
//$NON-NLS-1$
- } else {
- if(query.startsWith("/")) { //$NON-NLS-1$
- pathWithoutLastSegment = "/" + name; //$NON-NLS-1$
- } else {
- pathWithoutLastSegment = name;
- }
- }
- name = ""; //$NON-NLS-1$
- }
- if(name==null) {
- name = ""; //$NON-NLS-1$
- }
- IResource resource;
- String startPath = pathWithoutLastSegment;
- if(pathWithoutLastSegment.startsWith("/")) { //$NON-NLS-1$
- if(pathWithoutLastSegment.length()>1) {
- startPath = pathWithoutLastSegment.substring(1);
- } else {
- startPath = ""; //$NON-NLS-1$
- }
- }
- if(query.startsWith("/")) { //$NON-NLS-1$
- resource = webRootResource.findMember(startPath);
- } else {
- resource = context.getResource().getParent().findMember(startPath);
- }
-
- List<IResource> resources = new ArrayList<IResource>();
- try {
- if(resource != null) resource.accept(new ImagesFinder(resources, name, extensions));
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
- ImagePathDescriptor[] filesPathes = new ImagePathDescriptor[resources.size()];
- for(int i=0; i<filesPathes.length; i++) {
- String prefix = pathWithoutLastSegment.toString();
- if(!prefix.endsWith("/")) { //$NON-NLS-1$
- prefix = prefix + '/';
- }
- IResource r = (IResource)resources.get(i);
- filesPathes[i] = new ImagePathDescriptor(prefix + r.getName(), r);
- }
- return filesPathes;
- }
-
- private static class ImagePathDescriptor {
- private String queryPath;
- private IResource resource;
-
- public ImagePathDescriptor(String queryPath, IResource resource) {
- this.queryPath = queryPath;
- this.resource = resource;
- }
-
- public String getQueryPath() {
- return queryPath;
- }
-
- public IResource getResource() {
- return resource;
- }
- }
-
- private static class ImagesFinder implements IResourceVisitor {
- private List<IResource> resources;
- private int count = 0;
- private String name;
- Set<String> extensions = null;
-
- /**
- * @param resources
- * @param name
- * @param extensions
- */
- public ImagesFinder(List<IResource> resources, String name, Set<String>
extensions) {
- this.resources = resources;
- this.name = name;
- this.extensions = extensions;
- }
-
- boolean acceptExtension(String ext) {
- if(ext != null) {
- ext = ext.toLowerCase();
- }
- return (extensions == null || extensions.contains(ext));
- }
-
- public boolean visit(IResource resource) throws CoreException {
- if(resource instanceof IFile) {
- IFile file = (IFile)resource;
- if(resource.getName().startsWith(name) &&
acceptExtension(file.getFileExtension())) {
- resources.add(resource);
- }
- } else if(resource instanceof IFolder) {
- if(count==0) {
- count++;
- return true;
- } else if(resource.getName().startsWith(name) &&
(!resource.getName().equals("WEB-INF")) &&
(!resource.getName().equals("META-INF"))) { //$NON-NLS-1$ //$NON-NLS-2$
- resources.add(resource);
- }
- }
- return false;
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ValidatorIDProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ValidatorIDProposalType.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ValidatorIDProposalType.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal.taglib;
-
-import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
-
-/**
- *
- * @author Viacheslav Kabanovich
- *
- */
-public class ValidatorIDProposalType extends ConverterIDProposalType {
-
- public ValidatorIDProposalType() {}
-
- @Override
- protected String getListID() {
- return IWebPromptingProvider.JSF_VALIDATOR_IDS;
- }
-}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -10,26 +10,17 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib.composite;
-import java.util.Properties;
-
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
import org.jboss.tools.jst.web.kb.internal.taglib.AbstractComponent;
-import org.w3c.dom.Element;
public class CompositeComponent extends AbstractComponent {
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.KbObject#getXMLClass()
+ */
+ @Override
public String getXMLClass() {
return KbXMLStoreConstants.CLS_COMPOSITE_LIBRARY;
}
-
- @Override
- protected void saveAttributesInfo(Element element, Properties context) {
- super.saveAttributesInfo(element, context);
- }
-
- @Override
- protected void loadAttributesInfo(Element element, Properties context) {
- super.loadAttributesInfo(element, context);
- }
-
-}
+}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -12,9 +12,9 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
-import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IProposalProcessor;
+import org.jboss.tools.jst.web.kb.KbQuery;
/**
* Represents a tag library.
@@ -65,6 +65,12 @@
IComponent getComponent(String name);
/**
+ * @param type
+ * @return component by type
+ */
+ IComponent getComponentByType(String type);
+
+ /**
* @param query
* @param context
* @return components
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java 2009-12-16
17:09:02 UTC (rev 19365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -30,6 +30,15 @@
if(kbProject == null) {
return new ITagLibrary[0];
}
- return kbProject.getTagLibraries(uri);
+ return uri==null?kbProject.getTagLibraries():kbProject.getTagLibraries(uri);
}
+
+ /**
+ * Returns all tag libraries which are available in the project.
+ * @param project
+ * @return
+ */
+ public static ITagLibrary[] getLibraries(IProject project) {
+ return getLibraries(project, null);
+ }
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfCore.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfCore.xml 2009-12-16 17:09:02
UTC (rev 19365)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfCore.xml 2009-12-16 17:56:27
UTC (rev 19366)
@@ -2,6 +2,12 @@
<!DOCTYPE tag-lib PUBLIC "-//Red Hat, Inc//DTD Knowledge Base 2.0//EN"
"http://anonsvn.jboss.org/repos/jbosstools/trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/kbCustomTagLibSchema-1.0.dtd">
<tag-lib defaultPrefix="f">
+ <component closeTag="true" name="facet">
+ <attribute name="name">
+ <proposal type="facetName"/>
+ </attribute>
+ </component>
+
<component closeTag="true" name="loadBundle">
<attribute name="basename">
<proposal type="bundleName"/>
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-12-16
17:09:02 UTC (rev 19365)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-12-16
17:56:27 UTC (rev 19366)
@@ -13,8 +13,6 @@
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
@@ -31,16 +29,15 @@
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.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType;
+import org.jboss.tools.jst.web.kb.internal.proposal.CustomProposalType.Param;
import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibAttribute;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType.Param;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.tld.IFilePathEncoder;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
import org.jboss.tools.vpe.editor.util.ElService;
-import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.Jsf2ResourceUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.w3c.dom.Node;