Author: vrubezhny
Date: 2010-12-30 10:31:51 -0500 (Thu, 30 Dec 2010)
New Revision: 27827
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/KbRequire.exsd
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireDefinition.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/IKBBuilderRequiredNature.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
Log:
JBIDE-8013
Move the acquirement for KB Builder requirements out of the nature(-s)
New extension point is used to declare KB Builder requirement.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2010-12-30 15:28:53 UTC (rev
27826)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2010-12-30 15:31:51 UTC (rev
27827)
@@ -5,6 +5,7 @@
<extension-point id="KbIncludeContext" name="Kb Include Context
Buillder" schema="schema/include.exsd" />
<extension-point id="validator" name="KB Validator"
schema="schema/validator.exsd"/>
<extension-point id="elValidationDelegate" name="EL Validation
Delegate" schema="schema/elValidationDelegate.exsd"/>
+ <extension-point id="KbRequire" name="KB Builder Requirement"
schema="schema/KbRequire.exsd"/>
<extension
id="kbbuilder"
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/KbRequire.exsd
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/KbRequire.exsd
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/KbRequire.exsd 2010-12-30 15:31:51
UTC (rev 27827)
@@ -0,0 +1,125 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.jst.web.kb"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.jst.web.kb"
id="KbRequire" name="KbRequire"/>
+ </appInfo>
+ <documentation>
+ The extension point allows the application to define Natures that require JBoss
Tools Knowledge Base Builder to be present due to provide Validation and Content Assist
facilities.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="require" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="require">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="forNature" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ V.3.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <pre>
+ <extension-point id="KbRequire" name="KB Builder
Requirement" />
+
+ <extension
+ id="org.jboss.tools.jsf.KbRequire"
+ point="org.jboss.tools.jst.web.kb.KbRequire">
+ <require
+ description="%KB_REQUIRED_FOR_JSF"
+ forNature="org.jboss.tools.jsf.jsfnature">
+ </require>
+ </extension>
+
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ The baseline for API and extension point stability is RedHat Developer Studio
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ RedHat
+ </documentation>
+ </annotation>
+
+</schema>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/KbRequire.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/IKBBuilderRequiredNature.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/IKBBuilderRequiredNature.java 2010-12-30
15:28:53 UTC (rev 27826)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/IKBBuilderRequiredNature.java 2010-12-30
15:31:51 UTC (rev 27827)
@@ -1,25 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2010 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;
-
-/**
- * The interface is used by the nature which are require the KB Nature and Builder
- * to be installed due to the correct information to be provided for Content Assist
- * and/or Validation facilities
- *
- * @author Jeremy
- *
- */
-public interface IKBBuilderRequiredNature {
- boolean isKBBuilderRequired();
- String getNatureDescription();
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2010-12-30
15:28:53 UTC (rev 27826)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2010-12-30
15:31:51 UTC (rev 27827)
@@ -52,6 +52,8 @@
import org.jboss.tools.jst.web.kb.internal.taglib.composite.CompositeTagLibrary;
import org.jboss.tools.jst.web.kb.internal.taglib.myfaces.MyFacesTagLibrary;
import org.jboss.tools.jst.web.kb.internal.validation.ProjectValidationContext;
+import org.jboss.tools.jst.web.kb.require.KbRequireBuilder;
+import org.jboss.tools.jst.web.kb.require.KbRequireDefinition;
import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibrary;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.jboss.tools.jst.web.kb.validation.IProjectValidationContext;
@@ -870,18 +872,19 @@
private static String[] getKBBuilderRequiredNatureDescriptions(IProject project) {
ArrayList<String> natureDescriptions = new ArrayList<String>();
try {
- IProjectDescription projectDescription = project.getDescription();
- String[] ids = projectDescription.getNatureIds();
- if (ids == null) return (String[])natureDescriptions.toArray(new String[0]);
- for (String id : ids) {
- IProjectNature nature = project.getNature(id);
- if (nature instanceof IKBBuilderRequiredNature) {
- if (((IKBBuilderRequiredNature)nature).isKBBuilderRequired()) {
- String description = ((IKBBuilderRequiredNature)nature).getNatureDescription();
- if (description != null && description.length() > 0) {
- natureDescriptions.add(description);
- }
- }
+ List<KbRequireDefinition> definitions =
KbRequireBuilder.getInstance().getKbRequireDefinitions();
+
+ if (definitions == null) return (String[])natureDescriptions.toArray(new String[0]);
+
+ for (KbRequireDefinition def : definitions) {
+ String forNature = def.getNatureId();
+
+ if (project.getNature(forNature) != null) {
+ String description = def.getDescription();
+ if (description == null)
+ description = forNature;
+
+ natureDescriptions.add(description);
}
}
} catch (CoreException ex) {
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireBuilder.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireBuilder.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireBuilder.java 2010-12-30
15:31:51 UTC (rev 27827)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.require;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.text.ext.util.xpl.RegistryReader;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
+
+/**
+ * KB Require Builder is used to read and store the information from the
+ * KbRequire schema.
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public class KbRequireBuilder extends RegistryReader {
+
+ // extension point ID
+ public static final String PL_KB_REQUIRE = "KbRequire"; //$NON-NLS-1$
+
+ public static final String TAG_REQUIRE = "require"; //$NON-NLS-1$
+
+ public static final String ATT_ID = "id"; //$NON-NLS-1$
+ public static final String ATT_FOR_NATURE = "forNature"; //$NON-NLS-1$
+ public static final String ATT_DESCRIPTION = "description"; //$NON-NLS-1$
+
+ private static KbRequireBuilder fInstance;
+
+ protected String fTargetContributionElement;
+
+ List<KbRequireDefinition> fDefinitions = null;
+
+ /**
+ * returns singleton instance of KbRequireBuilder
+ *
+ * @return {@link IncludeContextBuilder}
+ */
+ public synchronized static KbRequireBuilder getInstance() {
+ if (fInstance == null) {
+ fInstance = new KbRequireBuilder();
+ }
+ return fInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.internal.extension.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ @Override
+ protected boolean readElement(IConfigurationElement element) {
+ String tag = element.getName();
+
+ if (tag.equals(TAG_REQUIRE)) {
+ processRequireElement(element);
+ }
+
+ return false;
+ }
+
+ /**
+ * Reads the Tag element and stores the specific data
+ *
+ * @param element
+ * @return
+ */
+ private boolean processRequireElement(IConfigurationElement element) {
+ String forNature = element.getAttribute(ATT_FOR_NATURE);
+ String description = element.getAttribute(ATT_DESCRIPTION);
+
+ if (forNature != null && forNature.trim().length() > 0) {
+ if (fDefinitions == null)
+ fDefinitions = new ArrayList<KbRequireDefinition>();
+
+ fDefinitions.add(new KbRequireDefinition(forNature, description));
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private void initCache() {
+ if (fDefinitions == null) {
+ readContributions(TAG_REQUIRE, PL_KB_REQUIRE);
+ }
+ }
+
+ /**
+ * Reads the contributions defined in the extension point
+ *
+ * @param element
+ * @param extensionPoint
+ */
+ protected void readContributions(String element, String extensionPoint) {
+ fTargetContributionElement = element;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ readRegistry(registry, WebKbPlugin.PLUGIN_ID, extensionPoint);
+ }
+
+ /**
+ * Returns all the open on definition objects
+ *
+ * @return
+ */
+ public List<KbRequireDefinition> getKbRequireDefinitions() {
+ initCache();
+ return fDefinitions;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireDefinition.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireDefinition.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireDefinition.java 2010-12-30
15:31:51 UTC (rev 27827)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.require;
+
+/**
+ * KbRequireDefinition is used to store the definitions read from the KbRequire Schema
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public class KbRequireDefinition {
+ private String fNatureId;
+ private String fDescription;
+
+ public KbRequireDefinition(String forId, String description) {
+ this.fNatureId = forId;
+ this.fDescription = description;
+ }
+
+ public String getNatureId () {
+ return fNatureId;
+ }
+
+ public String getDescription() {
+ return fDescription;
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/require/KbRequireDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain