Author: akazakov
Date: 2011-06-10 20:56:28 -0400 (Fri, 10 Jun 2011)
New Revision: 32035
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/StaticAttribute.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkDetector.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java
Log:
https://issues.jboss.org/browse/JBIDE-9088
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkDetector.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkDetector.java 2011-06-11
00:07:58 UTC (rev 32034)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkDetector.java 2011-06-11
00:56:28 UTC (rev 32035)
@@ -126,7 +126,7 @@
IAttribute[] attributes = PageProcessor.getInstance().getAttributes(query,
(IPageContext)context);
ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
for(IAttribute attribute : attributes){
- if(!attribute.isExtended() && validateComponent(attribute.getComponent(),
((IPageContext)context).getNameSpaces(reg.getOffset()), query.getPrefix())){
+ if(!attribute.isExtended() && validateComponent(attribute.getComponent(),
((IPageContext)context).getNameSpaces(reg.getOffset()), query.getPrefix()) &&
attribute instanceof AbstractAttribute){
TLDAttributeHyperlink link = new
TLDAttributeHyperlink((AbstractAttribute)attribute, reg);
link.setDocument(textViewer.getDocument());
hyperlinks.add(link);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java 2011-06-11
00:07:58 UTC (rev 32034)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java 2011-06-11
00:56:28 UTC (rev 32035)
@@ -124,7 +124,7 @@
protected void adopt(KbObject child) {
if(child.getKbProject() != null && child.getKbProject() != getKbProject())
return;
- ((KbObject)child).setParent(this);
+ child.setParent(this);
}
@@ -137,7 +137,7 @@
* @return list of changes
*/
public List<Change> merge(KbObject s) {
- KbObject o = (KbObject)s;
+ KbObject o = s;
source = o.source;
id = o.id;
resource = o.resource;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2011-06-11
00:07:58 UTC (rev 32034)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2011-06-11
00:56:28 UTC (rev 32035)
@@ -25,7 +25,6 @@
import org.jboss.tools.common.xml.XMLUtilities;
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.KbObject;
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
import org.jboss.tools.jst.web.kb.internal.taglib.composite.CompositeAttribute;
@@ -52,7 +51,7 @@
protected String description;
protected String name;
protected boolean hasExtendedAttributes = false;
- private Map<String, IAttribute> attributes = new HashMap<String,
IAttribute>();
+ protected Map<String, IAttribute> attributes = new HashMap<String,
IAttribute>();
private IAttribute[] attributesArray;
private Map<String, IAttribute> preferableAttributes = new HashMap<String,
IAttribute>();
private IAttribute[] preferableAttributesArray;
@@ -347,7 +346,9 @@
* @param attribute
*/
public void addAttribute(IAttribute attribute) {
- adopt((KbObject)attribute);
+ if(attribute instanceof KbObject) {
+ adopt((KbObject)attribute);
+ }
attributes.put(attribute.getName(), attribute);
if(attribute.isExtended()) {
hasExtendedAttributes = true;
@@ -417,7 +418,9 @@
copy.requiredAttributes = new HashMap<String, IAttribute>();
IAttribute[] as = getAttributes();
for (IAttribute a: as) {
- copy.addAttribute(((AbstractAttribute)a).clone());
+ if(a instanceof AbstractAttribute) {
+ copy.addAttribute(((AbstractAttribute)a).clone());
+ }
if(a.isExtended()) {
copy.hasExtendedAttributes = true;
}
@@ -478,28 +481,36 @@
*/
public void mergeAttributes(AbstractComponent c, Change children) {
Map<Object,AbstractAttribute> attributeMap = new HashMap<Object,
AbstractAttribute>();
- for (IAttribute a: getAttributes()) attributeMap.put(((KbObject)a).getId(),
(AbstractAttribute)a);
+ for (IAttribute a: getAttributes()) {
+ if(a instanceof AbstractAttribute) {
+ attributeMap.put(((KbObject)a).getId(), (AbstractAttribute)a);
+ }
+ }
for (IAttribute a: c.getAttributes()) {
- AbstractAttribute loaded = (AbstractAttribute)a;
- AbstractAttribute current = attributeMap.remove(loaded.getId());
- if(current == null) {
- addAttribute(loaded);
- Change change = new Change(this, null, null, loaded);
- children.addChildren(Change.addChange(null, change));
- } else {
- removeAttribute(current);
- List<Change> rc = current.merge(loaded);
- if(rc != null) children.addChildren(rc);
- addAttribute(current);
+ if(a instanceof AbstractAttribute) {
+ AbstractAttribute loaded = (AbstractAttribute)a;
+ AbstractAttribute current = attributeMap.remove(loaded.getId());
+ if(current == null) {
+ addAttribute(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ removeAttribute(current);
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ addAttribute(current);
+ }
}
}
for (IAttribute a: attributeMap.values()) {
- AbstractAttribute removed = (AbstractAttribute)a;
- if(attributes.get(removed.getName()) == removed) {
- attributes.remove(removed.getName());
- Change change = new Change(this, null, removed, null);
- children.addChildren(Change.addChange(null, change));
- clearAttributeArrays();
+ if(a instanceof AbstractAttribute) {
+ AbstractAttribute removed = (AbstractAttribute)a;
+ if(attributes.get(removed.getName()) == removed) {
+ attributes.remove(removed.getName());
+ Change change = new Change(this, null, removed, null);
+ children.addChildren(Change.addChange(null, change));
+ clearAttributeArrays();
+ }
}
}
}
@@ -526,7 +537,9 @@
}
for (IAttribute c: getAttributes()) {
- ((KbObject)c).toXML(element, context);
+ if(c instanceof KbObject) {
+ ((KbObject)c).toXML(element, context);
+ }
}
return element;
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/StaticAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/StaticAttribute.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/StaticAttribute.java 2011-06-11
00:56:28 UTC (rev 32035)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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;
+import org.jboss.tools.jst.web.kb.taglib.IAttribute;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class StaticAttribute implements IAttribute {
+
+ protected String description;
+ protected String name;
+ protected boolean required;
+ protected IComponent component;
+
+ public StaticAttribute(IComponent component, String name) {
+ this.component = component;
+ this.name = name;
+ }
+
+ /*
+ * (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) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isPreferable()
+ */
+ public boolean isPreferable() {
+ return isRequired();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isExtended()
+ */
+ public boolean isExtended() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getComponent()
+ */
+ public IComponent getComponent() {
+ return component;
+ }
+}
\ 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/taglib/StaticAttribute.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2011-06-11
00:07:58 UTC (rev 32034)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/composite/CompositeComponent.java 2011-06-11
00:56:28 UTC (rev 32035)
@@ -12,9 +12,20 @@
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
import org.jboss.tools.jst.web.kb.internal.taglib.AbstractComponent;
+import org.jboss.tools.jst.web.kb.internal.taglib.StaticAttribute;
+import org.jboss.tools.jst.web.kb.taglib.IAttribute;
public class CompositeComponent extends AbstractComponent {
+ public static final String[] STATIC_ATTRIBUTES = new String[] {"id",
"rendered"}; //$NON-NLS-1$ //$NON-NLS-2$
+
+ public CompositeComponent() {
+ for (String attribute : STATIC_ATTRIBUTES) {
+ IAttribute staticAttribute = new StaticAttribute(this, attribute);
+ attributes.put(attribute, staticAttribute);
+ }
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.internal.KbObject#getXMLClass()