Author: scabanovich
Date: 2008-11-14 08:53:08 -0500 (Fri, 14 Nov 2008)
New Revision: 11786
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/schema/attributeContentProposalProviders.exsd
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java
Log:
JBIDE-2575
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2008-11-14 13:46:34
UTC (rev 11785)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2008-11-14 13:53:08
UTC (rev 11786)
@@ -9,6 +9,7 @@
<extension-point id="metaTemplates" name="Meta Templates"
schema="schema/metaTemplates.exsd"/>
<extension-point id="InsertTagWizard" name="InsertTagWizard"
schema="schema/InsertTagWizard.exsd"/>
<extension-point id="labelDecorator" name="Model Object Label
Decorator" schema="schema/labelDecorator.exsd"/>
+ <extension-point id="attributeContentProposalProviders"
name="Attribute Content Proposal Providers"
schema="schema/attributeContentProposalProviders.exsd"/>
<extension point="org.eclipse.ui.elementFactories">
<factory
class="org.jboss.tools.common.core.resources.XModelObjectEditorInputFactory"
id="org.jboss.tools.common.core.resources.XModelObjectEditorInputFactory">
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/schema/attributeContentProposalProviders.exsd
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/schema/attributeContentProposalProviders.exsd
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/schema/attributeContentProposalProviders.exsd 2008-11-14
13:53:08 UTC (rev 11786)
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.model.ui"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.common.model.ui"
id="attributeContentProposalProviders" name="Attribute Content Proposal
Providers"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="provider" minOccurs="0"
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="provider">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-14
13:46:34 UTC (rev 11785)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-14
13:53:08 UTC (rev 11786)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.common.model.ui.attribute;
import java.util.ArrayList;
@@ -3,4 +13,9 @@
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
@@ -21,6 +36,9 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
+/**
+ * @author Viacheslav Kabanovich
+ */
public class AttributeContentProposalProviderFactory {
private static List<IAttributeContentProposalProvider> EMPTY = new
ArrayList<IAttributeContentProposalProvider>();
@@ -79,23 +97,54 @@
}
}
+ static String POINT_ID = ModelUIPlugin.PLUGIN_ID +
".attributeContentProposalProviders";
+
public List<IAttributeContentProposalProvider>
getContentProposalProviders(XModelObject object, XAttribute attribute) {
- //TODO
- if(true) {
- List<IAttributeContentProposalProvider> list = new
ArrayList<IAttributeContentProposalProvider>();
- list.add(new TestAttributeContentProposalProvider());
- return list;
+ List<IAttributeContentProposalProvider> result = EMPTY;
+
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(POINT_ID);
+
+ IExtension[] es = point.getExtensions();
+ for (int i = 0; i < es.length; i++) {
+ IConfigurationElement[] cs = es[i].getConfigurationElements();
+ for (int j = 0; j < cs.length; j++) {
+ IAttributeContentProposalProvider provider = null;
+ try {
+ Object o = cs[j].createExecutableExtension("class");
+ provider = (IAttributeContentProposalProvider)o;
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ if(provider.isRelevant(object, attribute)) {
+ if(result == EMPTY) result = new
ArrayList<IAttributeContentProposalProvider>();
+ result.add(provider);
+ }
+ }
}
+
+ if(false) {
+ //Test
+ result.add(new TestAttributeContentProposalProvider());
+ }
- return EMPTY;
+ return result;
}
}
+/**
+ * Example
+ * @author glory
+ *
+ */
class TestAttributeContentProposalProvider implements IAttributeContentProposalProvider
{
- public void dispose() {
+ public boolean isRelevant(XModelObject object, XAttribute attribute) {
+ return true;
}
+ public void init(XModelObject object, XAttribute attribute) {
+ }
+
public IContentProposalProvider getContentProposalProvider() {
IContentProposalProvider cpp = new IContentProposalProvider() {
@@ -103,8 +152,9 @@
int position) {
ArrayList<IContentProposal> ps = new ArrayList<IContentProposal>();
- if(position <= contents.length() && position > 0 && 'b'
== contents.charAt(position - 1))
- ps.add(makeContentProposal("aaa", ".aaa"));
+ if(position <= contents.length() && position > 3 &&
"test".equals(contents.substring(position - 4, position))) {
+ ps.add(makeContentProposal("aaa", ".aaa"));
+ }
return ps.toArray(new IContentProposal[0]);
}
@@ -117,7 +167,7 @@
return ContentProposalAdapter.PROPOSAL_INSERT;
}
- public void init(XModelObject object, XAttribute attribute) {
+ public void dispose() {
}
private IContentProposal makeContentProposal(final String proposal, final String label)
{
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java 2008-11-14
13:46:34 UTC (rev 11785)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java 2008-11-14
13:53:08 UTC (rev 11786)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.common.model.ui.attribute;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
@@ -4,8 +14,13 @@
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
+/**
+ * @author Viacheslav Kabanovich
+ */
public interface IAttributeContentProposalProvider {
+ public boolean isRelevant(XModelObject object, XAttribute attribute);
+
public void init(XModelObject object, XAttribute attribute);
public IContentProposalProvider getContentProposalProvider();