JBoss Tools SVN: r6675 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-03-04 05:12:41 -0500 (Tue, 04 Mar 2008)
New Revision: 6675
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1839
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2008-03-03 20:39:41 UTC (rev 6674)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2008-03-04 10:12:41 UTC (rev 6675)
@@ -52,6 +52,8 @@
import org.hibernate.eclipse.console.actions.OpenMappingAction;
import org.hibernate.eclipse.console.viewers.xpl.MTreeViewer;
import org.hibernate.eclipse.console.workbench.xpl.AnyAdaptableLabelProvider;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
import org.hibernate.util.StringHelper;
@@ -160,12 +162,15 @@
}
} else if (selection instanceof TreeSelection){
TreePath path = ((TreeSelection)selection).getPaths()[0];
+ Object first = path.getFirstSegment();
ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(path.getSegment(0));
- try {
- OpenMappingAction.run(path, consoleConfiguration);
- } catch (Exception e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
- }
+ if (first instanceof PersistentClass || first.getClass() == Property.class){
+ try {
+ OpenMappingAction.run(path, consoleConfiguration);
+ } catch (Exception e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
+ }
+ }
}
}
};
16 years, 8 months
JBoss Tools SVN: r6674 - in trunk/core: plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-03 15:39:41 -0500 (Mon, 03 Mar 2008)
New Revision: 6674
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/StrictXercesXSMarshaller.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/util/FileIOUtil.java
Log:
Created a modified XercesXSMarshaller to throw an exception if a required attribute (such as name) is missing.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-03-03 16:46:56 UTC (rev 6673)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -37,7 +37,6 @@
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeDeltaImpl.NodeDelta;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNodeWithProperties;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
/**
* Abstract superclass implementation for archive node types
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/StrictXercesXSMarshaller.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/StrictXercesXSMarshaller.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/StrictXercesXSMarshaller.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -0,0 +1,1471 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xerces.xs.StringList;
+import org.apache.xerces.xs.XSAttributeDeclaration;
+import org.apache.xerces.xs.XSAttributeUse;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSModelGroup;
+import org.apache.xerces.xs.XSNamedMap;
+import org.apache.xerces.xs.XSObject;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSParticle;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTerm;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.apache.xerces.xs.XSWildcard;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.AttributesImpl;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Content;
+import org.jboss.xb.binding.ContentWriter;
+import org.jboss.xb.binding.DelegatingObjectModelProvider;
+import org.jboss.xb.binding.GenericObjectModelProvider;
+import org.jboss.xb.binding.JBossXBRuntimeException;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.MarshallingContext;
+import org.jboss.xb.binding.NamespaceRegistry;
+import org.jboss.xb.binding.ObjectLocalMarshaller;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.Util;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 1958 $</tt>
+ */
+public class StrictXercesXSMarshaller
+ extends AbstractMarshaller
+{
+ private Stack stack = new StackImpl();
+
+ /**
+ * ObjectModelProvider for this marshaller
+ */
+ private GenericObjectModelProvider provider;
+
+ private Object root;
+
+ /**
+ * Whether NULL values should be ignored or marshalled as xsi:nil='1'
+ */
+ private boolean supportNil = true;
+
+ private QName rootTypeQName;
+
+ private SchemaBindingResolver schemaResolver;
+
+ private XSModel model;
+
+ private boolean ignoreUnresolvedWildcard;
+
+ private XSAttributeUse currentAttribute;
+ private XSTypeDefinition currentElementType;
+
+ private String simpleContentProperty = "value";
+
+ private MarshallingContext ctx = new MarshallingContext()
+ {
+ private ContentHandler ch;
+
+ public boolean isAttributeRequired()
+ {
+ if(currentAttribute == null)
+ {
+ throw new JBossXBRuntimeException("There is no current attribute!");
+ }
+ return currentAttribute.getRequired();
+ }
+
+ public boolean isTypeComplex()
+ {
+ if(currentElementType == null)
+ {
+ throw new JBossXBRuntimeException("There is no current element!");
+ }
+ return currentElementType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE;
+ }
+
+ public String getSimpleContentProperty()
+ {
+ return simpleContentProperty;
+ }
+
+ public ContentHandler getContentHandler()
+ {
+ if(ch == null)
+ {
+ ch = new ContentHandlerAdaptor();
+ }
+ return ch;
+ }
+
+ public NamespaceRegistry getNamespaceContext()
+ {
+ return nsRegistry;
+ }
+ };
+
+ public String getSimpleContentProperty()
+ {
+ return simpleContentProperty;
+ }
+
+ public void setSimpleContentProperty(String simpleContentProperty)
+ {
+ this.simpleContentProperty = simpleContentProperty;
+ }
+
+ public boolean isIgnoreUnresolvedWildcard()
+ {
+ return ignoreUnresolvedWildcard;
+ }
+
+ public void setIgnoreUnresolvedWildcard(boolean ignoreUnresolvedWildcard)
+ {
+ this.ignoreUnresolvedWildcard = ignoreUnresolvedWildcard;
+ }
+
+ public SchemaBindingResolver getSchemaResolver()
+ {
+ return schemaResolver;
+ }
+
+ public void setSchemaResolver(SchemaBindingResolver schemaResolver)
+ {
+ this.schemaResolver = schemaResolver;
+ }
+
+ public QName getRootTypeQName()
+ {
+ return rootTypeQName;
+ }
+
+ public void setRootTypeQName(QName rootTypeQName)
+ {
+ this.rootTypeQName = rootTypeQName;
+ }
+
+ public boolean isSupportNil()
+ {
+ return supportNil;
+ }
+
+ public void setSupportNil(boolean supportNil)
+ {
+ this.supportNil = supportNil;
+ }
+
+ /**
+ * Adds an attribute to the top most elements.
+ * First, we check whether there is a namespace associated with the passed in prefix.
+ * If the prefix was not declared, an exception is thrown.
+ *
+ * @param prefix the prefix of the attribute to be declared
+ * @param localName local name of the attribute
+ * @param type the type of the attribute
+ * @param value the value of the attribute
+ */
+ public void addAttribute(String prefix, String localName, String type, String value)
+ {
+ // todo addAttribute(String prefix, String localName, String type, String value)
+ }
+
+ // AbstractMarshaller implementation
+
+ public void marshal(Reader xsdReader, ObjectModelProvider provider, Object root, Writer writer)
+ throws IOException, SAXException, ParserConfigurationException
+ {
+ XSModel model = Util.loadSchema(xsdReader, null, schemaResolver);
+ marshallInternal(provider, root, model, writer);
+ }
+
+ public void marshal(String xsdURL, ObjectModelProvider provider, Object root, Writer writer) throws IOException,
+ SAXException
+ {
+ XSModel model = Util.loadSchema(xsdURL, schemaResolver);
+ marshallInternal(provider, root, model, writer);
+ }
+
+ public void marshal(XSModel model, ObjectModelProvider provider, Object root, Writer writer) throws IOException,
+ SAXException
+ {
+ marshallInternal(provider, root, model, writer);
+ }
+
+ private void marshallInternal(ObjectModelProvider provider, Object root, XSModel model, Writer writer)
+ throws IOException, SAXException
+ {
+ if(model == null)
+ {
+ throw new JBossXBRuntimeException("XSModel is not available!");
+ }
+
+ this.model = model;
+ this.provider = provider instanceof GenericObjectModelProvider ?
+ (GenericObjectModelProvider)provider : new DelegatingObjectModelProvider(provider);
+
+ this.root = root;
+
+ content.startDocument();
+
+ if(rootTypeQName != null)
+ {
+ if(rootQNames.isEmpty())
+ {
+ throw new JBossXBRuntimeException("If type name (" +
+ rootTypeQName +
+ ") for the root element is specified then the name for the root element is required!"
+ );
+ }
+ QName rootQName = (QName)rootQNames.get(0);
+
+ XSTypeDefinition type = model.getTypeDefinition(rootTypeQName.getLocalPart(),
+ rootTypeQName.getNamespaceURI()
+ );
+ if(type == null)
+ {
+ throw new JBossXBRuntimeException("Global type definition is not found: " + rootTypeQName);
+ }
+
+ if(isArrayWrapper(type))
+ {
+ Object o = provider.getRoot(root, null, rootQName.getNamespaceURI(), rootQName.getLocalPart());
+ stack.push(o);
+ marshalComplexType(rootQName.getNamespaceURI(),
+ rootQName.getLocalPart(),
+ (XSComplexTypeDefinition)type,
+ true,
+ false
+ );
+ stack.pop();
+ }
+ else
+ {
+ Object o = provider.getRoot(root, null, rootQName.getNamespaceURI(), rootQName.getLocalPart());
+ marshalElementOccurence(rootQName.getNamespaceURI(),
+ rootQName.getLocalPart(),
+ type,
+ o,
+ false,
+ false,
+ true
+ );
+ }
+ }
+ else if(rootQNames.isEmpty())
+ {
+ XSNamedMap components = model.getComponents(XSConstants.ELEMENT_DECLARATION);
+ if(components.getLength() == 0)
+ {
+ throw new JBossXBRuntimeException("The schema doesn't contain global element declarations.");
+ }
+
+ for(int i = 0; i < components.getLength(); ++i)
+ {
+ XSElementDeclaration element = (XSElementDeclaration)components.item(i);
+ Object o = provider.getRoot(root, null, element.getNamespace(), element.getName());
+ marshalElementOccurence(element.getNamespace(),
+ element.getName(),
+ element.getTypeDefinition(),
+ o,
+ element.getNillable(),
+ false,
+ true
+ );
+ }
+ }
+ else
+ {
+ for(int i = 0; i < rootQNames.size(); ++i)
+ {
+ QName qName = (QName)rootQNames.get(i);
+ XSElementDeclaration element = model.getElementDeclaration(qName.getLocalPart(), qName.getNamespaceURI());
+ if(element == null)
+ {
+ XSNamedMap components = model.getComponents(XSConstants.ELEMENT_DECLARATION);
+ String roots = "";
+ for(int j = 0; j < components.getLength(); ++j)
+ {
+ XSObject xsObject = components.item(j);
+ if(j > 0)
+ {
+ roots += ", ";
+ }
+ roots += "{" + xsObject.getNamespace() + "}" + xsObject.getName();
+ }
+ throw new IllegalStateException("Root element not found: " + qName + " among " + roots);
+ }
+
+ Object o = provider.getRoot(root, null, element.getNamespace(), element.getName());
+ marshalElementOccurence(element.getNamespace(),
+ element.getName(),
+ element.getTypeDefinition(),
+ o,
+ element.getNillable(),
+ false,
+ true
+ );
+ }
+ }
+
+ content.endDocument();
+
+ // version & encoding
+ writeXmlVersion(writer);
+
+ ContentWriter contentWriter = new ContentWriter(writer,
+ propertyIsTrueOrNotSet(Marshaller.PROP_OUTPUT_INDENTATION)
+ );
+ content.handleContent(contentWriter);
+
+ if(log.isTraceEnabled())
+ {
+ java.io.StringWriter traceWriter = new java.io.StringWriter();
+ contentWriter = new ContentWriter(traceWriter,
+ propertyIsTrueOrNotSet(Marshaller.PROP_OUTPUT_INDENTATION)
+ );
+ content.handleContent(contentWriter);
+ log.trace("marshalled:\n" + traceWriter.getBuffer().toString());
+ }
+ }
+
+ private boolean marshalElement(String elementNs, String elementLocal,
+ XSTypeDefinition type,
+ boolean optional,
+ boolean nillable,
+ boolean declareNs,
+ boolean declareXsiType)
+ {
+ Object value = stack.peek();
+ boolean result = value != null || value == null && (optional || nillable);
+ boolean trace = log.isTraceEnabled() && result;
+ if(trace)
+ {
+ String prefix = getPrefix(elementNs);
+ log.trace("started element ns=" + elementNs + ", local=" + elementLocal + ", prefix=" + prefix);
+ }
+
+ if(value != null)
+ {
+ marshalElementType(elementNs, elementLocal, type, declareNs, nillable, declareXsiType);
+ }
+ else if(nillable)
+ {
+ writeNillable(elementNs, elementLocal, nillable);
+ }
+
+ if(trace)
+ {
+ log.trace("finished element ns=" + elementNs + ", local=" + elementLocal);
+ }
+
+ return result;
+ }
+
+ private void marshalElementType(String elementNs,
+ String elementLocal,
+ XSTypeDefinition type,
+ boolean declareNs,
+ boolean nillable,
+ boolean declareXsiType)
+ {
+ switch(type.getTypeCategory())
+ {
+ case XSTypeDefinition.SIMPLE_TYPE:
+ marshalSimpleType(elementNs,
+ elementLocal,
+ (XSSimpleTypeDefinition)type,
+ declareNs,
+ nillable,
+ declareXsiType
+ );
+ break;
+ case XSTypeDefinition.COMPLEX_TYPE:
+ marshalComplexType(elementNs, elementLocal, (XSComplexTypeDefinition)type, declareNs, declareXsiType);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected type category: " + type.getTypeCategory());
+ }
+ }
+
+ private void marshalSimpleType(String elementUri,
+ String elementLocal,
+ XSSimpleTypeDefinition type,
+ boolean declareNs,
+ boolean nillable,
+ boolean declareXsiType)
+ {
+ Object value = stack.peek();
+ if(value != null)
+ {
+ String prefix = getPrefix(elementUri);
+ boolean genPrefix = prefix == null && elementUri != null && elementUri.length() > 0;
+ if(genPrefix)
+ {
+ prefix = "ns_" + elementLocal;
+ }
+
+ AttributesImpl attrs = null;
+ String typeName = type.getName();
+ if(SimpleTypeBindings.XS_QNAME_NAME.equals(typeName) ||
+ SimpleTypeBindings.XS_NOTATION_NAME.equals(typeName) ||
+ type.getItemType() != null &&
+ (SimpleTypeBindings.XS_QNAME_NAME.equals(type.getItemType().getName()) ||
+ SimpleTypeBindings.XS_NOTATION_NAME.equals(type.getItemType().getName())
+ )
+ )
+ {
+ attrs = new AttributesImpl(5);
+ }
+
+ String marshalled = marshalCharacters(elementUri, prefix, type, value, attrs);
+
+ if((declareNs || declareXsiType) && nsRegistry.size() > 0)
+ {
+ if(attrs == null)
+ {
+ attrs = new AttributesImpl(nsRegistry.size() + 1);
+ }
+ declareNs(attrs);
+ }
+
+ if(declareXsiType)
+ {
+ declareXsiType(type, attrs);
+ }
+
+ if(genPrefix)
+ {
+ if(attrs == null)
+ {
+ attrs = new AttributesImpl(1);
+ }
+ attrs.add(null, prefix, "xmlns:" + prefix, null, (String)elementUri);
+ }
+
+ String qName = prefixLocalName(prefix, elementLocal);
+
+ content.startElement(elementUri, elementLocal, qName, attrs);
+ content.characters(marshalled.toCharArray(), 0, marshalled.length());
+ content.endElement(elementUri, elementLocal, qName);
+ }
+ else
+ {
+ writeNillable(elementUri, elementLocal, nillable);
+ }
+ }
+
+ private void marshalComplexType(String elementNsUri,
+ String elementLocalName,
+ XSComplexTypeDefinition type,
+ boolean declareNs,
+ boolean declareXsiType)
+ {
+ Object o = stack.peek();
+ XSParticle particle = type.getParticle();
+
+ XSObjectList attributeUses = type.getAttributeUses();
+ int attrsTotal = declareNs || declareXsiType ?
+ nsRegistry.size() + attributeUses.getLength() + 1 :
+ attributeUses.getLength();
+ AttributesImpl attrs = attrsTotal > 0 ? new AttributesImpl(attrsTotal) : null;
+
+ if(declareNs && nsRegistry.size() > 0)
+ {
+ declareNs(attrs);
+ }
+
+ String generatedPrefix = null;
+ if(declareXsiType)
+ {
+ generatedPrefix = declareXsiType(type, attrs);
+ if(generatedPrefix != null)
+ {
+ String typeNsWithGeneratedPrefix = type.getNamespace();
+ declareNs(attrs, generatedPrefix, typeNsWithGeneratedPrefix);
+ declareNamespace(generatedPrefix, typeNsWithGeneratedPrefix);
+ }
+ }
+
+ String prefix = getPrefix(elementNsUri);
+ boolean genPrefix = prefix == null && elementNsUri != null && elementNsUri.length() > 0;
+ if(genPrefix)
+ {
+ // todo: it's possible that the generated prefix already mapped. this should be fixed
+ prefix = "ns_" + elementLocalName;
+ declareNamespace(prefix, elementNsUri);
+ if(attrs == null)
+ {
+ attrs = new AttributesImpl(1);
+ }
+ attrs.add(null, prefix, "xmlns:" + prefix, null, elementNsUri);
+ }
+
+ for(int i = 0; i < attributeUses.getLength(); ++i)
+ {
+ currentAttribute = (XSAttributeUse)attributeUses.item(i);
+ XSAttributeDeclaration attrDec = currentAttribute.getAttrDeclaration();
+ String attrNs = attrDec.getNamespace();
+ String attrLocal = attrDec.getName();
+ Object attrValue = provider.getAttributeValue(o, ctx, attrNs, attrLocal);
+
+ if(attrValue != null)
+ {
+ if(attrs == null)
+ {
+ attrs = new AttributesImpl(5);
+ }
+
+ String attrPrefix = null;
+ if(attrNs != null)
+ {
+ attrPrefix = getPrefix(attrNs);
+ if(attrPrefix == null && attrNs != null && attrNs.length() > 0)
+ {
+ attrPrefix = "ns_" + attrLocal;
+ attrs.add(null, attrPrefix, "xmlns:" + attrPrefix, null, attrNs);
+ }
+ }
+
+ String qName = attrPrefix == null || attrPrefix.length() == 0 ? attrLocal : attrPrefix + ":" + attrLocal;
+
+ // todo: this is a quick fix for boolean pattern (0|1 or true|false) should be refactored
+ XSSimpleTypeDefinition attrType = attrDec.getTypeDefinition();
+ if(attrType.getItemType() != null)
+ {
+ XSSimpleTypeDefinition itemType = attrType.getItemType();
+ if(Constants.NS_XML_SCHEMA.equals(itemType.getNamespace()))
+ {
+ List list;
+ if(attrValue instanceof List)
+ {
+ list = (List)attrValue;
+ }
+ else if(attrValue.getClass().isArray())
+ {
+ list = Arrays.asList((Object[])attrValue);
+ }
+ else
+ {
+ throw new JBossXBRuntimeException("Expected value for list type is an array or " +
+ List.class.getName() +
+ " but got: " +
+ attrValue
+ );
+ }
+
+ if(Constants.QNAME_QNAME.getLocalPart().equals(itemType.getName()))
+ {
+ for(int listInd = 0; listInd < list.size(); ++listInd)
+ {
+ QName item = (QName)list.get(listInd);
+ String itemNs = item.getNamespaceURI();
+ if(itemNs != null && itemNs.length() > 0)
+ {
+ String itemPrefix;
+ if(itemNs.equals(elementNsUri))
+ {
+ itemPrefix = prefix;
+ }
+ else
+ {
+ itemPrefix = getPrefix(itemNs);
+ if(itemPrefix == null)
+ {
+ itemPrefix = attrLocal + listInd;
+ declareNs(attrs, itemPrefix, itemNs);
+ }
+ }
+ item = new QName(item.getNamespaceURI(), item.getLocalPart(), itemPrefix);
+ list.set(listInd, item);
+ }
+ }
+ }
+
+ attrValue = SimpleTypeBindings.marshalList(itemType.getName(), list, null);
+ }
+ else
+ {
+ throw new JBossXBRuntimeException("Marshalling of list types with item types not from " +
+ Constants.NS_XML_SCHEMA + " is not supported."
+ );
+ }
+ }
+ else if(attrType.getLexicalPattern().item(0) != null
+ &&
+ attrType.derivedFrom(Constants.NS_XML_SCHEMA,
+ Constants.QNAME_BOOLEAN.getLocalPart(),
+ XSConstants.DERIVATION_RESTRICTION
+ ))
+ {
+ String item = attrType.getLexicalPattern().item(0);
+ if(item.indexOf('0') != -1 && item.indexOf('1') != -1)
+ {
+ attrValue = ((Boolean)attrValue).booleanValue() ? "1" : "0";
+ }
+ else
+ {
+ attrValue = ((Boolean)attrValue).booleanValue() ? "true" : "false";
+ }
+ }
+ else if(Constants.QNAME_QNAME.getNamespaceURI().equals(attrType.getNamespace()) &&
+ Constants.QNAME_QNAME.getLocalPart().equals(attrType.getName()))
+ {
+ QName qNameValue = (QName)attrValue;
+
+ String qNamePrefix = null;
+ boolean declarePrefix = false;
+ String ns = qNameValue.getNamespaceURI();
+ if(ns != null && ns.length() > 0)
+ {
+ qNamePrefix = getPrefix(ns);
+ if(qNamePrefix == null)
+ {
+ qNamePrefix = qNameValue.getPrefix();
+ if(qNamePrefix == null || qNamePrefix.length() == 0)
+ {
+ qNamePrefix = "ns_" + qNameValue.getLocalPart();
+ }
+ declareNs(attrs, qNamePrefix, ns);
+ nsRegistry.addPrefixMapping(qNamePrefix, ns);
+ declarePrefix = true;
+ }
+ }
+
+ attrValue = SimpleTypeBindings.marshalQName(qNameValue, nsRegistry);
+
+ if(declarePrefix)
+ {
+ nsRegistry.removePrefixMapping(qNamePrefix);
+ }
+ }
+ else
+ {
+ attrValue = attrValue.toString();
+ }
+
+ attrs.add(attrNs,
+ attrLocal,
+ qName,
+ attrDec.getTypeDefinition().getName(),
+ attrValue.toString()
+ );
+ } // end if attrValue != null
+ else if( currentAttribute.getRequired()){
+ // its required and is not present. Must throw exception
+ String name = currentAttribute.getAttrDeclaration().getName();
+ throw new JBossXBRuntimeException("Required Attribute " + name + " is not present");
+ }
+ }
+ currentAttribute = null;
+
+ String characters = null;
+ if(type.getSimpleType() != null)
+ {
+ Object value = getSimpleContentValue(elementNsUri, elementLocalName, type);
+ if(value != null)
+ {
+ XSSimpleTypeDefinition simpleType = type.getSimpleType();
+ String typeName = simpleType.getName();
+ if(attrs == null && (SimpleTypeBindings.XS_QNAME_NAME.equals(typeName) ||
+ SimpleTypeBindings.XS_NOTATION_NAME.equals(typeName) ||
+ simpleType.getItemType() != null &&
+ (SimpleTypeBindings.XS_QNAME_NAME.equals(simpleType.getItemType().getName()) ||
+ SimpleTypeBindings.XS_NOTATION_NAME.equals(simpleType.getItemType().getName())
+ )
+ )
+ )
+ {
+ attrs = new AttributesImpl(5);
+ }
+
+ characters = marshalCharacters(elementNsUri, prefix, simpleType, value, attrs);
+ }
+ }
+
+ String qName = prefixLocalName(prefix, elementLocalName);
+ content.startElement(elementNsUri, elementLocalName, qName, attrs);
+
+ if(particle != null)
+ {
+ marshalParticle(particle, false);
+ }
+
+ if(characters != null)
+ {
+ content.characters(characters.toCharArray(), 0, characters.length());
+ }
+ content.endElement(elementNsUri, elementLocalName, qName);
+
+ if(genPrefix)
+ {
+ removePrefixMapping(prefix);
+ }
+
+ if(generatedPrefix != null)
+ {
+ removePrefixMapping(generatedPrefix);
+ }
+ }
+
+ private boolean marshalParticle(XSParticle particle, boolean declareNs)
+ {
+ boolean marshalled;
+ XSTerm term = particle.getTerm();
+ Object o;
+ Iterator i;
+ switch(term.getType())
+ {
+ case XSConstants.MODEL_GROUP:
+ o = stack.peek();
+ i = o != null && isRepeatable(particle) ? getIterator(o) : null;
+ if(i != null)
+ {
+ marshalled = true;
+ while(i.hasNext() && marshalled)
+ {
+ Object value = i.next();
+ stack.push(value);
+ marshalled = marshalModelGroup(particle, declareNs);
+ stack.pop();
+ }
+ }
+ else
+ {
+ marshalled = marshalModelGroup(particle, declareNs);
+ }
+ break;
+ case XSConstants.WILDCARD:
+ o = stack.peek();
+
+ boolean popWildcardValue = false;
+ ObjectLocalMarshaller marshaller = null;
+ FieldToWildcardMapping mapping = (FieldToWildcardMapping)field2WildcardMap.get(o.getClass());
+ if(mapping != null)
+ {
+ marshaller = mapping.marshaller;
+ o = mapping.fieldInfo.getValue(o);
+ stack.push(o);
+ popWildcardValue = true;
+ }
+
+ i = o != null && isRepeatable(particle) ? getIterator(o) : null;
+ if(i != null)
+ {
+ marshalled = true;
+ while(i.hasNext() && marshalled)
+ {
+ Object value = i.next();
+ marshalled = marshalWildcardOccurence(particle, marshaller, value, declareNs);
+ }
+ }
+ else
+ {
+ marshalled = marshalWildcardOccurence(particle, marshaller, o, declareNs);
+ }
+
+ if(popWildcardValue)
+ {
+ stack.pop();
+ }
+
+ break;
+ case XSConstants.ELEMENT_DECLARATION:
+ XSElementDeclaration element = (XSElementDeclaration)term;
+ XSTypeDefinition type = element.getTypeDefinition();
+ o = getElementValue(element.getNamespace(), element.getName(), type);
+
+ i = o != null && isRepeatable(particle) ? getIterator(o) : null;
+ if(i != null)
+ {
+ marshalled = true;
+ while(i.hasNext() && marshalled)
+ {
+ Object value = i.next();
+ marshalled =
+ marshalElementOccurence(element.getNamespace(),
+ element.getName(),
+ type,
+ value,
+ element.getNillable(),
+ particle.getMinOccurs() == 0,
+ declareNs
+ );
+ }
+ }
+ else
+ {
+ marshalled =
+ marshalElementOccurence(element.getNamespace(),
+ element.getName(),
+ type,
+ o,
+ element.getNillable(),
+ particle.getMinOccurs() == 0,
+ declareNs
+ );
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unexpected term type: " + term.getType());
+ }
+ return marshalled;
+ }
+
+ private boolean marshalElementOccurence(String elementNs,
+ String elementLocal,
+ XSTypeDefinition type,
+ Object value,
+ boolean nillable,
+ boolean optional,
+ boolean declareNs)
+ {
+ boolean declareXsiType = false;
+ QName xsiTypeQName = null;
+ if(value != null)
+ {
+ xsiTypeQName = (QName)cls2TypeMap.get(value.getClass());
+ if(xsiTypeQName != null &&
+ !(type.getName().equals(xsiTypeQName.getLocalPart()) &&
+ type.getNamespace().equals(xsiTypeQName.getNamespaceURI())
+ ))
+ {
+ declareXsiType = true;
+ if(log.isTraceEnabled())
+ {
+ log.trace(value.getClass() + " is mapped to xsi:type " + xsiTypeQName);
+ }
+
+ XSTypeDefinition xsiType = model.getTypeDefinition(xsiTypeQName.getLocalPart(),
+ xsiTypeQName.getNamespaceURI()
+ );
+
+ if(xsiType == null)
+ {
+ log.warn("Class " +
+ value.getClass() +
+ " is mapped to type " +
+ xsiTypeQName +
+ " but the type is not found in schema."
+ );
+ }
+ // todo should check derivation also, i.e. if(xsiType.derivedFrom())
+ else
+ {
+ type = xsiType;
+ }
+ }
+ }
+
+ stack.push(value);
+ boolean marshalled = marshalElement(elementNs,
+ elementLocal,
+ type,
+ optional,
+ nillable,
+ declareNs,
+ declareXsiType
+ );
+ stack.pop();
+
+ return marshalled;
+ }
+
+ private boolean marshalWildcardOccurence(XSParticle particle,
+ ObjectLocalMarshaller marshaller,
+ Object value,
+ boolean declareNs)
+ {
+ boolean marshalled = true;
+ if(marshaller != null)
+ {
+ marshaller.marshal(ctx, value);
+ }
+ else
+ {
+ stack.push(value);
+ marshalled = marshalWildcard(particle, declareNs);
+ stack.pop();
+ }
+ return marshalled;
+ }
+
+ private boolean marshalWildcard(XSParticle particle, boolean declareNs)
+ {
+ XSWildcard wildcard = (XSWildcard)particle.getTerm();
+ Object o = stack.peek();
+ ClassMapping mapping = getClassMapping(o.getClass());
+ if(mapping == null)
+ {
+ // todo: YAH (yet another hack)
+ QName autoType = SimpleTypeBindings.typeQName(o.getClass());
+ if(autoType != null)
+ {
+ String marshalled = SimpleTypeBindings.marshal(autoType.getLocalPart(), o, null);
+ content.characters(marshalled.toCharArray(), 0, marshalled.length());
+ return true;
+ }
+ else
+ {
+ if(ignoreUnresolvedWildcard)
+ {
+ log.warn("Failed to marshal wildcard. Class mapping not found for " +
+ o.getClass() +
+ "@" +
+ o.hashCode() +
+ ": " + o
+ );
+ return true;
+ }
+ else
+ {
+ throw new IllegalStateException("Failed to marshal wildcard. Class mapping not found for " +
+ o.getClass() +
+ "@" +
+ o.hashCode() +
+ ": " + o
+ );
+ }
+ }
+ }
+
+ GenericObjectModelProvider parentProvider = this.provider;
+ Object parentRoot = this.root;
+ Stack parentStack = this.stack;
+ XSModel parentModel = this.model;
+
+ this.root = o;
+ this.stack = new StackImpl();
+ this.model = mapping.schemaUrl == null ? this.model : Util.loadSchema(mapping.schemaUrl, schemaResolver);
+ if(mapping.provider != null)
+ {
+ this.provider = mapping.provider;
+ }
+
+ boolean marshalled;
+ if(mapping.elementName != null)
+ {
+ XSElementDeclaration elDec = model.getElementDeclaration(mapping.elementName.getLocalPart(),
+ mapping.elementName.getNamespaceURI()
+ );
+
+ if(elDec == null)
+ {
+ throw new JBossXBRuntimeException("Element " + mapping.elementName + " is not declared in the schema.");
+ }
+
+ Object elementValue = provider.getRoot(root, null, elDec.getNamespace(), elDec.getName());
+ marshalled = marshalElementOccurence(elDec.getNamespace(),
+ elDec.getName(),
+ elDec.getTypeDefinition(),
+ elementValue,
+ elDec.getNillable(),
+ particle.getMinOccurs() == 0,
+ declareNs
+ );
+ }
+ else if(mapping.typeName != null)
+ {
+ XSTypeDefinition typeDef = model.getTypeDefinition(mapping.typeName.getLocalPart(),
+ mapping.typeName.getNamespaceURI()
+ );
+
+ if(typeDef == null)
+ {
+ List typeNames = new ArrayList();
+ XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION);
+ for(int i = 0; i < types.getLength(); ++i)
+ {
+ XSObject type = types.item(i);
+ if(!Constants.NS_XML_SCHEMA.equals(type.getNamespace()))
+ {
+ typeNames.add(new QName(type.getNamespace(), type.getName()));
+ }
+ }
+ throw new JBossXBRuntimeException("Type " +
+ mapping.typeName +
+ " is not defined in the schema." +
+ " Defined types are: " + typeNames
+ );
+ }
+
+ Object elementValue = provider.getRoot(root, null, wildcard.getNamespace(), wildcard.getName());
+ marshalled =
+ marshalElementOccurence(wildcard.getNamespace(),
+ wildcard.getName(),
+ typeDef,
+ elementValue,
+ true,
+ particle.getMinOccurs() == 0,
+ declareNs
+ );
+ }
+ else
+ {
+ throw new JBossXBRuntimeException("Class mapping for " +
+ mapping.cls +
+ " is associated with neither global element name nor global type name."
+ );
+ }
+
+ this.root = parentRoot;
+ this.provider = parentProvider;
+ this.stack = parentStack;
+ this.model = parentModel;
+
+ return marshalled;
+ }
+
+ private boolean marshalModelGroup(XSParticle particle, boolean declareNs)
+ {
+ XSModelGroup modelGroup = (XSModelGroup)particle.getTerm();
+ boolean marshalled;
+ switch(modelGroup.getCompositor())
+ {
+ case XSModelGroup.COMPOSITOR_ALL:
+ marshalled = marshalModelGroupAll(modelGroup.getParticles(), declareNs);
+ break;
+ case XSModelGroup.COMPOSITOR_CHOICE:
+ marshalled = marshalModelGroupChoice(modelGroup.getParticles(), declareNs);
+ break;
+ case XSModelGroup.COMPOSITOR_SEQUENCE:
+ marshalled = marshalModelGroupSequence(modelGroup.getParticles(), declareNs);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected compsitor: " + modelGroup.getCompositor());
+ }
+ return marshalled;
+ }
+
+ private boolean marshalModelGroupAll(XSObjectList particles, boolean declareNs)
+ {
+ boolean marshalled = false;
+ for(int i = 0; i < particles.getLength(); ++i)
+ {
+ XSParticle particle = (XSParticle)particles.item(i);
+ marshalled |= marshalParticle(particle, declareNs);
+ }
+ return marshalled;
+ }
+
+ private boolean marshalModelGroupChoice(XSObjectList particles, boolean declareNs)
+ {
+ boolean marshalled = false;
+ Content mainContent = this.content;
+ for(int i = 0; i < particles.getLength() && !marshalled; ++i)
+ {
+ XSParticle particle = (XSParticle)particles.item(i);
+ this.content = new Content();
+ marshalled = marshalParticle(particle, declareNs);
+ }
+
+ if(marshalled)
+ {
+ mainContent.append(this.content);
+ }
+ this.content = mainContent;
+
+ return marshalled;
+ }
+
+ private boolean marshalModelGroupSequence(XSObjectList particles, boolean declareNs)
+ {
+ boolean marshalled = true;
+ for(int i = 0; i < particles.getLength(); ++i)
+ {
+ XSParticle particle = (XSParticle)particles.item(i);
+ marshalled &= marshalParticle(particle, declareNs);
+ }
+ return marshalled;
+ }
+
+ private String marshalCharacters(String elementUri,
+ String elementPrefix,
+ XSSimpleTypeDefinition type,
+ Object value,
+ AttributesImpl attrs)
+ {
+ String marshalled;
+ if(type.getItemType() != null)
+ {
+ XSSimpleTypeDefinition itemType = type.getItemType();
+ if(Constants.NS_XML_SCHEMA.equals(itemType.getNamespace()))
+ {
+ List list;
+ if(value instanceof List)
+ {
+ list = (List)value;
+ }
+ else if(value.getClass().isArray())
+ {
+ list = asList(value);
+ }
+ else
+ {
+ // todo: qname are also not yet supported
+ throw new JBossXBRuntimeException(
+ "Expected value for list type is an array or " + List.class.getName() + " but got: " + value
+ );
+ }
+
+ marshalled = SimpleTypeBindings.marshalList(itemType.getName(), list, null);
+ }
+ else
+ {
+ throw new JBossXBRuntimeException("Marshalling of list types with item types not from " +
+ Constants.NS_XML_SCHEMA + " is not supported."
+ );
+ }
+ }
+ else if(Constants.NS_XML_SCHEMA.equals(type.getNamespace()))
+ {
+ String typeName = type.getName();
+
+ String prefix = null;
+ boolean removePrefix = false;
+ if(SimpleTypeBindings.XS_QNAME_NAME.equals(typeName) ||
+ SimpleTypeBindings.XS_NOTATION_NAME.equals(typeName))
+ {
+ QName qName = (QName)value;
+ if(qName.getNamespaceURI() != null && qName.getNamespaceURI().length() > 0)
+ {
+ prefix = nsRegistry.getPrefix(qName.getNamespaceURI());
+ if(prefix == null)
+ {
+ prefix = qName.getPrefix();
+ if(prefix == null || prefix.length() == 0)
+ {
+ prefix = qName.getLocalPart() + "_ns";
+ }
+ nsRegistry.addPrefixMapping(prefix, qName.getNamespaceURI());
+ declareNs(attrs, prefix, qName.getNamespaceURI());
+
+ removePrefix = true;
+ }
+ }
+ }
+ marshalled = SimpleTypeBindings.marshal(typeName, value, nsRegistry);
+
+ if(removePrefix)
+ {
+ nsRegistry.removePrefixMapping(prefix);
+ }
+ }
+ // todo: this is a quick fix for boolean pattern (0|1 or true|false) should be refactored
+ else if(type.getLexicalPattern().item(0) != null
+ &&
+ type.derivedFrom(Constants.NS_XML_SCHEMA,
+ Constants.QNAME_BOOLEAN.getLocalPart(),
+ XSConstants.DERIVATION_RESTRICTION
+ ))
+ {
+ String item = type.getLexicalPattern().item(0);
+ if(item.indexOf('0') != -1 && item.indexOf('1') != -1)
+ {
+ marshalled = ((Boolean)value).booleanValue() ? "1" : "0";
+ }
+ else
+ {
+ marshalled = ((Boolean)value).booleanValue() ? "true" : "false";
+ }
+ }
+ else
+ {
+ StringList lexicalEnumeration = type.getLexicalEnumeration();
+ if(lexicalEnumeration != null && lexicalEnumeration.getLength() > 0)
+ {
+ Method getValue;
+ try
+ {
+ getValue = value.getClass().getMethod("value", null);
+ }
+ catch(NoSuchMethodException e)
+ {
+ try
+ {
+ getValue = value.getClass().getMethod("getValue", null);
+ }
+ catch(NoSuchMethodException e1)
+ {
+ List values = new ArrayList(lexicalEnumeration.getLength());
+ for(int i = 0; i < lexicalEnumeration.getLength(); ++i)
+ {
+ values.add(lexicalEnumeration.item(i));
+ }
+
+ throw new JBossXBRuntimeException("Failed to find neither value() nor getValue() in " +
+ value.getClass() +
+ " which is bound to enumeration type (" +
+ type.getNamespace() +
+ ", " +
+ type.getName() + "): " + values
+ );
+ }
+ }
+
+ try
+ {
+ value = getValue.invoke(value, null);
+ }
+ catch(Exception e)
+ {
+ throw new JBossXBRuntimeException(
+ "Failed to invoke getValue() on " + value + " to get the enumeration value", e
+ );
+ }
+ }
+
+ marshalled = marshalCharacters(elementUri,
+ elementPrefix,
+ (XSSimpleTypeDefinition)type.getBaseType(),
+ value, attrs
+ );
+ }
+ return marshalled;
+ }
+
+ /**
+ * Adds xsi:type attribute and optionally declares namespaces for xsi and type's namespace.
+ * @param type the type to declare xsi:type attribute for
+ * @param attrs the attributes to add xsi:type attribute to
+ * @return prefix for the type's ns if it was generated
+ */
+ private String declareXsiType(XSTypeDefinition type, AttributesImpl attrs)
+ {
+ String result = null;
+ String xsiPrefix = nsRegistry.getPrefix(Constants.NS_XML_SCHEMA_INSTANCE);
+ if(xsiPrefix == null)
+ {
+ attrs.add(Constants.NS_XML_SCHEMA, "xmlns", "xmlns:xsi", null, Constants.NS_XML_SCHEMA_INSTANCE);
+ xsiPrefix = "xsi";
+ }
+
+ String pref = getPrefix(type.getNamespace());
+ if(pref == null)
+ {
+ // the ns is not declared
+ result = pref = type.getName() + "_ns";
+ }
+
+ String typeQName = pref == null ? type.getName() : pref + ':' + type.getName();
+ attrs.add(Constants.NS_XML_SCHEMA_INSTANCE, "type", xsiPrefix + ":type", null, typeQName);
+ return result;
+ }
+
+ private Object getElementValue(String elementNs, String elementLocal, XSTypeDefinition type)
+ {
+ Object value;
+ Object peeked = stack.isEmpty() ? root : stack.peek();
+ if(peeked == null)
+ {
+ value = null;
+ }
+ else if(peeked instanceof Collection || peeked.getClass().isArray())
+ {
+ // collection is the provider
+ value = peeked;
+ }
+ else
+ {
+ XSTypeDefinition parentType = currentElementType;
+ currentElementType = type;
+
+ value = provider.getChildren(peeked, ctx, elementNs, elementLocal);
+ if(value == null)
+ {
+ value = provider.getElementValue(peeked, ctx, elementNs, elementLocal);
+ }
+
+ currentElementType = parentType;
+ }
+ return value;
+ }
+
+ private Object getSimpleContentValue(String elementNs, String elementLocal, XSTypeDefinition type)
+ {
+ Object value;
+ Object peeked = stack.isEmpty() ? root : stack.peek();
+ if(peeked == null)
+ {
+ value = null;
+ }
+ else
+ {
+ XSTypeDefinition parentType = currentElementType;
+ currentElementType = type;
+ value = provider.getElementValue(peeked, ctx, elementNs, elementLocal);
+ currentElementType = parentType;
+ }
+ return value;
+ }
+
+ private void writeNillable(String elementNs, String elementLocal, boolean nillable)
+ {
+ if(!supportNil)
+ {
+ return;
+ }
+
+ if(!nillable)
+ {
+ throw new JBossXBRuntimeException("Failed to marshal " +
+ new QName(elementNs, elementLocal) +
+ ": Java value is null but the element is not nillable."
+ );
+ }
+
+ AttributesImpl attrs;
+ String prefix = getPrefix(elementNs);
+ if(prefix == null && elementNs != null && elementNs.length() > 0)
+ {
+ prefix = "ns_" + elementLocal;
+ attrs = new AttributesImpl(2);
+ attrs.add(null, prefix, "xmlns:" + prefix, null, elementNs);
+ }
+ else
+ {
+ attrs = new AttributesImpl(1);
+ }
+
+ String xsiPrefix = getPrefix(Constants.NS_XML_SCHEMA_INSTANCE);
+ if(xsiPrefix == null)
+ {
+ xsiPrefix = "xsi";
+ attrs.add(null,
+ xsiPrefix,
+ "xmlns:xsi",
+ null,
+ Constants.NS_XML_SCHEMA_INSTANCE
+ );
+ }
+
+ String nilQName = xsiPrefix + ":nil";
+ attrs.add(Constants.NS_XML_SCHEMA_INSTANCE, "nil", nilQName, null, "1");
+
+ String qName = prefixLocalName(prefix, elementLocal);
+ content.startElement(elementNs, elementLocal, qName, attrs);
+ content.endElement(elementNs, elementLocal, qName);
+ }
+
+ private static boolean isArrayWrapper(XSTypeDefinition type)
+ {
+ boolean is = false;
+ if(XSTypeDefinition.COMPLEX_TYPE == type.getTypeCategory())
+ {
+ XSComplexTypeDefinition cType = (XSComplexTypeDefinition)type;
+ XSParticle particle = cType.getParticle();
+ if(particle != null)
+ {
+ is = particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1;
+ }
+ }
+ return is;
+ }
+
+ private Iterator getIterator(Object value)
+ {
+ Iterator i = null;
+ if(value instanceof Collection)
+ {
+ i = ((Collection)value).iterator();
+ }
+ else if(value.getClass().isArray())
+ {
+ final Object arr = value;
+ i = new Iterator()
+ {
+ private int curInd = 0;
+ private int length = Array.getLength(arr);
+
+ public boolean hasNext()
+ {
+ return curInd < length;
+ }
+
+ public Object next()
+ {
+ return Array.get(arr, curInd++);
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("remove is not implemented.");
+ }
+ };
+ }
+ else if(value instanceof Iterator)
+ {
+ i = (Iterator)value;
+ }
+ else
+ {
+ //throw new JBossXBRuntimeException("Unexpected type for children: " + value.getClass());
+ }
+ return i;
+ }
+
+ private static boolean isRepeatable(XSParticle particle)
+ {
+ return particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1 || particle.getMinOccurs() > 1;
+ }
+
+ private static final List asList(final Object arr)
+ {
+ return new AbstractList()
+ {
+ private final Object array = arr;
+
+ public Object get(int index)
+ {
+ return Array.get(array, index);
+ }
+
+ public int size()
+ {
+ return Array.getLength(array);
+ }
+ };
+ }
+}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2008-03-03 16:46:56 UTC (rev 6673)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -22,7 +22,6 @@
package org.jboss.ide.eclipse.archives.core.model.internal.xb;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -41,7 +40,9 @@
import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.JBossXBRuntimeException;
import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
import org.xml.sax.SAXException;
@@ -166,7 +167,7 @@
stream = schema.openStream();
monitor.worked(1);
- XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ StrictXercesXSMarshaller marshaller = new StrictXercesXSMarshaller();
marshaller.marshal(new InputStreamReader(stream), new XbPackagesObjectProvider(), element, writer);
monitor.worked(1);
} catch (IOException e) {
@@ -175,7 +176,7 @@
f = e;
} catch (ParserConfigurationException e) {
f = e;
- } catch (Exception e ) {
+ } catch (JBossXBRuntimeException e ) {
f = e;
} finally {
if( stream != null ) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd 2008-03-03 16:46:56 UTC (rev 6673)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd 2008-03-03 20:39:41 UTC (rev 6674)
@@ -60,7 +60,7 @@
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
- <xsd:attribute name="type" type="xsd:string" use="optional">
+ <xsd:attribute name="type" type="xsd:string" use="optional" >
<xsd:annotation>
<xsd:appinfo>
<jbxb:property name="packageType" />
@@ -88,7 +88,7 @@
</xsd:annotation>
<xsd:sequence>
- <xsd:element maxOccurs="unbounded" minOccurs="1" name="property" type="property-type"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="property" type="property-type"/>
</xsd:sequence>
</xsd:complexType>
Added: trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml (rev 0)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml 2008-03-03 20:39:41 UTC (rev 6674)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<packages>
+ <properties></properties>
+</packages>
\ No newline at end of file
Modified: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-03 16:46:56 UTC (rev 6673)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -5,6 +5,7 @@
import org.jboss.ide.eclipse.archives.test.core.ArchivesCoreTest;
import org.jboss.ide.eclipse.archives.test.util.TruezipUtilTest;
+import org.jboss.ide.eclipse.archives.test.xb.MarshallTest;
import org.jboss.ide.eclipse.archives.test.xb.MarshallUnmarshallTest;
import org.jboss.ide.eclipse.archives.test.xb.ValidationTest;
@@ -12,6 +13,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Archives Tests");
suite.addTestSuite(ArchivesCoreTest.class);
+ suite.addTestSuite(MarshallTest.class);
suite.addTestSuite(MarshallUnmarshallTest.class);
suite.addTestSuite(ValidationTest.class);
suite.addTestSuite(TruezipUtilTest.class);
Modified: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/util/FileIOUtil.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/util/FileIOUtil.java 2008-03-03 16:46:56 UTC (rev 6673)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/util/FileIOUtil.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -1,15 +1,34 @@
package org.jboss.ide.eclipse.archives.test.util;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
public class FileIOUtil {
public static void clearFolder(File[] children) {
- for( int i = 0; i < children.length; i++ ) {
+ for (int i = 0; i < children.length; i++) {
File[] second = children[i].listFiles();
- if( second != null && second.length > 0 )
+ if (second != null && second.length > 0)
clearFolder(second);
children[i].delete();
}
}
+
+ public static String getFileContents(File f) {
+ try {
+ BufferedReader r = new BufferedReader(new FileReader(f));
+ StringBuffer contents = new StringBuffer();
+ int c = r.read();
+ while (c != -1) {
+ contents.append((char)c);
+ c=r.read();
+ }
+ r.close();
+ return contents.toString();
+ } catch (IOException ioe) {
+ return null;
+ }
+ }
}
Added: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java (rev 0)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java 2008-03-03 20:39:41 UTC (rev 6674)
@@ -0,0 +1,118 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.test.xb;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding.XbException;
+import org.jboss.ide.eclipse.archives.test.ArchivesTest;
+import org.jboss.ide.eclipse.archives.test.util.FileIOUtil;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public class MarshallTest extends TestCase {
+ private Bundle bundle;
+ private IPath bundlePath;
+ private IPath expectedOutputs;
+ private IPath outputs;
+ protected void setUp() {
+ if( bundlePath == null ) {
+ try {
+ bundle = ArchivesTest.getDefault().getBundle();
+ URL bundleURL = FileLocator.toFileURL(bundle.getEntry(""));
+ bundlePath = new Path(bundleURL.getFile());
+ expectedOutputs = bundlePath.append("expectedOutputs");
+ outputs = bundlePath.append("output");
+ } catch( IOException ioe) {
+ fail("Failed to set up " + getClass().getName());
+ }
+ }
+ }
+
+ public void tearDown() {
+ FileIOUtil.clearFolder(outputs.toFile().listFiles());
+ }
+
+ public void testStringWriter() {
+ XbPackages packs = new XbPackages();
+ try {
+ File expected = expectedOutputs.append("emptyPackages.xml").toFile();
+ String expectedContents = FileIOUtil.getFileContents(expected);
+ String asString = XMLBinding.serializePackages(packs, new NullProgressMonitor());
+ assertEquals(asString, expectedContents);
+ } catch( XbException xbe ) {
+ fail(xbe.getMessage());
+ }
+ }
+
+ public void testFileWriter() {
+ XbPackages packs = new XbPackages();
+ IPath out = outputs.append("test.xml");
+ try {
+ File expected = expectedOutputs.append("emptyPackages.xml").toFile();
+ String expectedContents = FileIOUtil.getFileContents(expected);
+
+ XMLBinding.marshallToFile(packs, out, new NullProgressMonitor());
+ String actualContents = FileIOUtil.getFileContents(out.toFile());
+
+ assertEquals(expectedContents, actualContents);
+ } catch( XbException xbe ) {
+ xbe.printStackTrace();
+ fail(xbe.getMessage());
+ } catch( IOException ioe ) {
+ fail(ioe.getMessage());
+ }
+ }
+
+ public void testWriteFailingPackage() {
+ XbException e = null;
+ XbPackages packs = new XbPackages();
+ XbPackage pack = new XbPackage();
+ packs.addChild(pack);
+ try {
+ IPath out = outputs.append("test.xml");
+ XMLBinding.marshallToFile(packs, out, new NullProgressMonitor());
+ } catch( IOException ioe ) {
+ fail("IOException during testWritePackage operation");
+ }catch( XbException xbe ) {
+ e = xbe;
+ } finally {
+ if( e == null ) {
+ fail("Incomplete Model saved when it should not have been.");
+ }
+ }
+ }
+}
16 years, 8 months
JBoss Tools SVN: r6673 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-03 11:46:56 -0500 (Mon, 03 Mar 2008)
New Revision: 6673
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java
Log:
JBIDE-1433 Decorators sorted.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java 2008-03-03 16:38:11 UTC (rev 6672)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java 2008-03-03 16:46:56 UTC (rev 6673)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.preferences;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -109,7 +111,12 @@
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof String) {
Set<XModelObjectDecorator> set = DecoratorManager.getInstance().getDecoratorsByPartition(parentElement.toString());
- return set != null ? set.toArray(new XModelObjectDecorator[0]) : new Object[0];
+ if(set != null) {
+ XModelObjectDecorator[] ds = set.toArray(new XModelObjectDecorator[0]);
+ Arrays.sort(ds, comparator);
+ return ds;
+ }
+ return new Object[0];
}
return new Object[0];
}
@@ -385,5 +392,14 @@
formatField.setSelection(cn);
examples.refresh(true);
}
+
+ static DComparator comparator = new DComparator();
+ static class DComparator implements Comparator<XModelObjectDecorator> {
+ public int compare(XModelObjectDecorator o1, XModelObjectDecorator o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ }
+
}
16 years, 8 months
JBoss Tools SVN: r6672 - in trunk/common/plugins/org.jboss.tools.common.model.ui: src/org/jboss/tools/common/model/ui/editors/dnd/context and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-03 11:38:11 -0500 (Mon, 03 Mar 2008)
New Revision: 6672
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/ICustomVariable.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/schema/labelDecorator.exsd
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/AttributeDecoratorPart.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/DecoratorConstants.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/NameDecoratorPart.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/Variable.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/XModelObjectDecorator.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorPreferencesPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java
Log:
JBIDE-1433 More decorators added.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/schema/labelDecorator.exsd
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/schema/labelDecorator.exsd 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/schema/labelDecorator.exsd 2008-03-03 16:38:11 UTC (rev 6672)
@@ -88,6 +88,13 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -14,6 +14,8 @@
import java.net.MalformedURLException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.eclipse.swt.dnd.DropTargetEvent;
@@ -73,6 +75,7 @@
}
TransferHolder[] TRANSFERS = {
+ new TransferHolder(LocalSelectionTransfer.getTransfer(), new LocalTransferProcessor()),
new TransferHolder(ModelTransfer.getInstance(), new ModelTransferProcessor()),
new TransferHolder(HTMLTransfer.getInstance(), new HTMLTransferProcessor()),
new TransferHolder(FileTransfer.getInstance(), new FileTransferProcessor()),
@@ -136,6 +139,7 @@
}
private boolean dropAsFileObject(XModelObject o) {
+ if(o == null) return false;
if(o.getFileType() != XModelObject.FILE || isOverAttributeValue) return false;
if(TLDUtil.isTaglib(o)) return false;
String extension = o.getAttributeValue("extension");
@@ -186,6 +190,18 @@
}
}
+ class LocalTransferProcessor extends TransferProcessor {
+ public void process(TransferData data) {
+ flavor = "application/x-moz-file";
+ Object ooo = LocalSelectionTransfer.getTransfer().getSelection();
+ if(ooo instanceof StructuredSelection) {
+ ooo = ((StructuredSelection)ooo).getFirstElement();
+ InnerDragBuffer.object = ooo;
+ }
+ mimeData = ooo == null ? null : ooo.toString();
+ }
+ }
+
class FileTransferProcessor extends TransferProcessor {
public void process(TransferData data) {
flavor = "application/x-moz-file";
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/AttributeDecoratorPart.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/AttributeDecoratorPart.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/AttributeDecoratorPart.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -17,12 +17,20 @@
*/
public class AttributeDecoratorPart implements IDecoratorPart {
Variable variable;
+ String parameters = "";
public AttributeDecoratorPart(Variable variable) {
this.variable = variable;
}
+
+ public void setParameters(String params) {
+ parameters = params;
+ }
public String getLabelPart(XModelObject object) {
+ if(variable.custom != null) {
+ return variable.custom.getLabelPart(object, parameters);
+ }
String v = object.getAttributeValue(variable.getName());
return v == null ? "{" + variable.getName() + "}" : v;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/DecoratorConstants.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/DecoratorConstants.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/DecoratorConstants.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -29,6 +29,8 @@
public String ATTR_VALUE = "value";
+ public String ATTR_CLASS = "class";
+
public String NODE_VARIABLE = "variable";
public String NODE_EXAMPLE = "example";
Added: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/ICustomVariable.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/ICustomVariable.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/ICustomVariable.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.navigator.decorator;
+
+import org.jboss.tools.common.model.XModelObject;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ICustomVariable {
+
+ public String getLabelPart(XModelObject object, String parameters);
+
+}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/NameDecoratorPart.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/NameDecoratorPart.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/NameDecoratorPart.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -16,6 +16,7 @@
* @author Viacheslav Kabanovich
*/
public class NameDecoratorPart implements IDecoratorPart {
+ static NameDecoratorPart INSTANCE = new NameDecoratorPart();
public NameDecoratorPart() {
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/Variable.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/Variable.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/Variable.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.navigator.decorator;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
/**
* @author Viacheslav Kabanovich
@@ -19,7 +21,9 @@
public static Variable NAME = new Variable("name", "default label");
String name;
+ String parameters = "";
String description;
+ ICustomVariable custom;
public Variable() {}
@@ -37,19 +41,34 @@
}
public String getRuleText() {
- return RULE_OPENING + name + RULE_CLOSING;
+ return RULE_OPENING + name + parameters + RULE_CLOSING;
}
public String toString() {
if(description == null || description.length() == 0) {
return name;
}
- return name + " - " + description;
+ return name + parameters + " - " + description;
}
public void load(IConfigurationElement element) {
name = element.getAttribute(ATTR_NAME);
+ int i = name.indexOf('(');
+ if(i >= 0) {
+ parameters = name.substring(i);
+ name = name.substring(0, i);
+ }
description = element.getAttribute(ATTR_DESCRIPTION);
+ String cls = element.getAttribute(ATTR_CLASS);
+ if(cls != null && cls.length() > 0) {
+ try {
+ custom = (ICustomVariable)element.createExecutableExtension(ATTR_CLASS);
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ } catch (ClassCastException e1) {
+ ModelUIPlugin.getPluginLog().logError("Attribute " + ATTR_CLASS + " must be instanceof ICustomVariable", e1);
+ }
+ }
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/XModelObjectDecorator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/XModelObjectDecorator.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/decorator/XModelObjectDecorator.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -133,11 +133,21 @@
} else if(t.equals(RULE_CLOSING)) {
inVariable = false;
} else if(inVariable) {
- Variable variable = getVariableByName(t);
+ String n = t;
+ String p = "";
+ int i = t.indexOf('(');
+ int j = t.indexOf(')');
+ if(i >= 0 && j > i) {
+ n = t.substring(0, i);
+ p = t.substring(i + 1, j);
+ }
+ Variable variable = getVariableByName(n);
if(variable == Variable.NAME) {
- parts.add(new NameDecoratorPart());
+ parts.add(NameDecoratorPart.INSTANCE);
} else if(variable != null){
- parts.add(new AttributeDecoratorPart(variable));
+ AttributeDecoratorPart part = new AttributeDecoratorPart(variable);
+ part.setParameters(p);
+ parts.add(part);
} else {
parts.add(new DecoratorPart(RULE_OPENING + t + RULE_CLOSING));
}
@@ -145,6 +155,15 @@
parts.add(new DecoratorPart(t));
}
}
+ boolean hasSignificantPart = false;
+ for (IDecoratorPart p: parts) {
+ if(p != NameDecoratorPart.INSTANCE && !(p instanceof AttributeDecoratorPart)) continue;
+ hasSignificantPart = true;
+ break;
+ }
+ if(!hasSignificantPart) {
+ parts.add(NameDecoratorPart.INSTANCE);
+ }
return this.parts = parts;
}
@@ -154,7 +173,9 @@
for (IDecoratorPart d: parts) {
sb.append(d.getLabelPart(object));
}
- return sb.toString();
+ String s = sb.toString().trim();
+ if(s.length() == 0) s = object.getPresentationString();
+ return s;
}
/**
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorPreferencesPage.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorPreferencesPage.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorPreferencesPage.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -33,11 +33,14 @@
this.noDefaultAndApplyButton();
TabFolder tabbedComposite = new TabFolder(parent,SWT.NULL);
tabbedComposite.setBackground(parent.getBackground());
- TabItem newTab = new TabItem(tabbedComposite,SWT.NULL);
+
+ TabItem newTab = null;
- general.createControl(tabbedComposite);
- newTab.setControl(general.getControl());
- newTab.setText(general.getTitle());
+//TODO remove comments when we find some preferences to put here
+// newTab = new TabItem(tabbedComposite,SWT.NULL);
+// general.createControl(tabbedComposite);
+// newTab.setControl(general.getControl());
+// newTab.setText(general.getTitle());
newTab = new TabItem(tabbedComposite,SWT.NULL);
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java 2008-03-03 16:37:48 UTC (rev 6671)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/DecoratorTextPreferencesPage.java 2008-03-03 16:38:11 UTC (rev 6672)
@@ -383,6 +383,7 @@
currentValues.put(selection, text);
setText(text);
formatField.setSelection(cn);
+ examples.refresh(true);
}
}
16 years, 8 months
JBoss Tools SVN: r6671 - in trunk/jst/plugins/org.jboss.tools.jst.web.ui: META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-03 11:37:48 -0500 (Mon, 03 Mar 2008)
New Revision: 6671
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/decorator/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/decorator/TLDAttributeDecorator.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java
Log:
JBIDE-1433 More decorators added.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2008-03-03 16:03:38 UTC (rev 6670)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2008-03-03 16:37:48 UTC (rev 6671)
@@ -15,6 +15,7 @@
org.jboss.tools.jst.web.ui.editors,
org.jboss.tools.jst.web.ui.editors.forms,
org.jboss.tools.jst.web.ui.navigator,
+ org.jboss.tools.jst.web.ui.navigator.decorator,
org.jboss.tools.jst.web.ui.operation,
org.jboss.tools.jst.web.ui.wizards.appregister,
org.jboss.tools.jst.web.ui.wizards.links,
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2008-03-03 16:03:38 UTC (rev 6670)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2008-03-03 16:37:48 UTC (rev 6671)
@@ -585,6 +585,95 @@
<put name="display-name" value="JSTL Core"/>
</example>
</labelDecorator>
+
+ <labelDecorator
+ entities="TLDTag12,TLDTag20,TLDTag21"
+ name="Tag"
+ partition="Tag Libraries"
+ defaultValue="{display-name}">
+ <variable name="display-name" description="attribute of tag node"/>
+ <example entity="TLDTag12">
+ <put name="name" value="tag1"/>
+ </example>
+ <example entity="TLDTag12">
+ <put name="name" value="tag2"/>
+ <put name="display-name" value="Second Tag"/>
+ </example>
+ </labelDecorator>
+
+ <labelDecorator
+ entities="TLDTagFile"
+ name="Tag File"
+ partition="Tag Libraries"
+ defaultValue="{display-name}">
+ <variable name="display-name" description="attribute of tag-file node"/>
+ <variable name="path" description="attribute of tag-file node"/>
+ <example entity="TLDTagFile">
+ <put name="name" value="f"/>
+ <put name="display-name" value="File"/>
+ <put name="path" value="/a/b/c.tag"/>
+ </example>
+ </labelDecorator>
+
+ <labelDecorator
+ entities="TLDAttribute,TLDAttribute12,TLDAttribute20,TLDAttribute21,TLDAttribute2F"
+ name="Attribute"
+ partition="Tag Libraries"
+ defaultValue="{name}{required( REQUIRED)}">
+ <variable name="required(value)"
+ class="org.jboss.tools.jst.web.ui.navigator.decorator.TLDAttributeDecorator"
+ description="inserts 'value' if attribute 'required' is set to 'true'"/>
+ <example entity="TLDAttribute12">
+ <put name="name" value="attr1"/>
+ <put name="required" value="true"/>
+ </example>
+ <example entity="TLDAttribute12">
+ <put name="name" value="attr2"/>
+ <put name="required" value="false"/>
+ </example>
+ </labelDecorator>
+
+ <labelDecorator
+ entities="TLDFunction"
+ name="Function"
+ partition="Tag Libraries"
+ defaultValue="{display-name}">
+ <variable name="function-class" description="attribute of function node"/>
+ <variable name="display-name" description="attribute of function node"/>
+ <example entity="TLDFunction">
+ <put name="name" value="func"/>
+ <put name="display-name" value="Custom Function"/>
+ <put name="function-class" value="a.b.C"/>
+ </example>
+ </labelDecorator>
+
+ <labelDecorator
+ entities="TLDVariable"
+ name="Variable"
+ partition="Tag Libraries"
+ defaultValue="{name}">
+ <variable name="scope" description="attribute of variable node"/>
+ <example entity="TLDVariable">
+ <put name="name-given" value="var1"/>
+ <put name="scope" value="NESTED"/>
+ </example>
+ <example entity="TLDVariable">
+ <put name="name-from-attribute" value="var2"/>
+ <put name="scope" value="AT_BEGIN"/>
+ </example>
+ </labelDecorator>
+
+ <labelDecorator
+ entities="TLDValidator"
+ name="Validator"
+ partition="Tag Libraries"
+ defaultValue="{name}">
+ <variable name="validator-class" description="attribute of validator node"/>
+ <example entity="TLDValidator">
+ <put name="validator-class" value="a.b.C"/>
+ </example>
+ </labelDecorator>
+
</extension>
</plugin>
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java 2008-03-03 16:03:38 UTC (rev 6670)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java 2008-03-03 16:37:48 UTC (rev 6671)
@@ -25,15 +25,16 @@
public String getText(Object element) {
if(!(element instanceof XModelObject)) return "";
XModelObject o = (XModelObject)element;
- if(o.getFileType() != XModelObject.FILE) return super.getText(element);
String entity = o.getModelEntity().getName();
-
+
XModelObjectDecorator d = DecoratorManager.getInstance().getDecoratorByEntity(entity);
if(d != null) {
String label = d.getLabel(o);
return applyModification(o, label);
}
+ if(o.getFileType() != XModelObject.FILE) return super.getText(element);
+
if("FilePROPERTIES".equals(entity)) {
XModelObject fs = o;
while(fs != null && fs.getFileType() != XModelObject.SYSTEM) fs = fs.getParent();
Added: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/decorator/TLDAttributeDecorator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/decorator/TLDAttributeDecorator.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/decorator/TLDAttributeDecorator.java 2008-03-03 16:37:48 UTC (rev 6671)
@@ -0,0 +1,18 @@
+package org.jboss.tools.jst.web.ui.navigator.decorator;
+
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.navigator.decorator.ICustomVariable;
+
+public class TLDAttributeDecorator implements ICustomVariable {
+
+ public String getLabelPart(XModelObject object, String parameters) {
+ if(object == null) return "";
+ String required = object.getAttributeValue("required");
+ if(required == null || parameters == null) return "";
+ if("true".equals(required) || "yes".equals(required)) {
+ return "" + parameters;
+ }
+ return "";
+ }
+
+}
16 years, 8 months
JBoss Tools SVN: r6670 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-03 11:03:38 -0500 (Mon, 03 Mar 2008)
New Revision: 6670
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
Log:
JBIDE-509
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2008-03-03 13:42:48 UTC (rev 6669)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2008-03-03 16:03:38 UTC (rev 6670)
@@ -13,6 +13,8 @@
import java.util.List;
import java.util.Properties;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.FindObjectHelper;
import org.jboss.tools.seam.core.ISeamElement;
import org.jboss.tools.seam.core.ISeamXmlFactory;
import org.jboss.tools.seam.core.IValueInfo;
@@ -102,5 +104,12 @@
setValue(attributes.get(VALUE));
}
}
+
+ public void open() {
+ if(id instanceof XModelObject) {
+ XModelObject o = (XModelObject)id;
+ FindObjectHelper.findModelObject(o, FindObjectHelper.IN_EDITOR_ONLY);
+ }
+ }
}
16 years, 8 months
JBoss Tools SVN: r6669 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713 and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-03-03 08:42:48 -0500 (Mon, 03 Mar 2008)
New Revision: 6669
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713/JBIDE-1713.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pictures/pic1.jpg
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/JBIDE1713Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesAllTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
Log:
Add JUnit test for http://jira.jboss.com/jira/browse/JBIDE-1713
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713/JBIDE-1713.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713/JBIDE-1713.xhtml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1713/JBIDE-1713.xhtml 2008-03-03 13:42:48 UTC (rev 6669)
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j">
+<head>
+<style type="text/css">
+.myContentStyle {
+ background-color: aqua;
+}
+
+.myContentStyle1 {
+ background-color: lime;
+}
+
+.myHeaderStyle {
+ color: red;
+}
+
+.myHeaderStyle1 {
+ background: purple;
+}
+
+.myHeaderStyleActive {
+ background: aqua;
+}
+
+.myHeaderStyleActive1 {
+ background: olive;
+}
+
+.rich-panelbar {
+ background-color: silver;
+}
+
+.myClass {
+ font-style: italic;
+ font-stretch: narrower;
+}
+</style>
+</head>
+<body>
+ <rich:panelBar width="453" height="207" contentClass="myContentStyle1"
+ contentStyle="color: brown;" headerClass="myHeaderStyle1"
+ headerStyle="color: green" headerClassActive="myHeaderStyleActive1"
+ headerStyleActive="color: white;" style="font-weight: bold;"
+ styleClass="myClass">
+ <rich:panelBarItem label="nice" contentClass="myContentStyle"
+ contentStyle="color: green;" headerClass="myHeaderStyle"
+ headerStyle="background: yellow;"
+ headerClassActive="myHeaderStyleActive"
+ headerStyleActive="color: blue; background: red;">
+ An automated testing facility is in our roadmap for the near future. This facility will generate test cases for your component as soon as you develop it. The testing framework will not just test the components, but also any other server-side or client-side functionality including JavaScript code. What is more, it will do all of this without deploying the test application into the Servlet container.
+ <h:graphicImage value="/pictures/pic1.jpg" />
+ </rich:panelBarItem>
+ <rich:panelBarItem label="good">
+ <f:facet name="label">
+ <h:graphicImage value="/pictures/pic1.jpg" />
+ </f:facet>
+ <f:verbatim>Ajax4jsf is fully integrated into the JSF lifecycle. While other frameworks only give you access to the managed bean facility, Ajax4jsf advantages the action and value change listeners as well as invokes server-side validators and converters during the AJAX request-response cycle.</f:verbatim>
+ </rich:panelBarItem>
+ <rich:panelBarItem label="good"
+ headerClassActive="myHeaderStyleActive"
+ headerStyleActive="color: blue;">
+ <f:facet name="label">
+ <h:outputText value="Guess who?" />
+ </f:facet>
+ <f:verbatim>Ajax4jsf is fully integrated into the JSF lifecycle. While other frameworks only give you access to the managed bean facility, Ajax4jsf advantages the action and value change listeners as well as invokes server-side validators and converters during the AJAX request-response cycle.</f:verbatim>
+ </rich:panelBarItem>
+ </rich:panelBar>
+</body>
+</html>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pictures/pic1.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pictures/pic1.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesAllTests.java 2008-03-03 13:05:49 UTC (rev 6668)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesAllTests.java 2008-03-03 13:42:48 UTC (rev 6669)
@@ -18,6 +18,7 @@
import org.jboss.tools.jsf.vpe.richfaces.test.jbide.JBIDE1579Test;
import org.jboss.tools.jsf.vpe.richfaces.test.jbide.JBIDE1613Test;
+import org.jboss.tools.jsf.vpe.richfaces.test.jbide.JBIDE1713Test;
import org.jboss.tools.jsf.vpe.richfaces.test.jbide.Jbide1548Test;
import org.jboss.tools.jsf.vpe.richfaces.test.jbide.Jbide1580Test;
import org.jboss.tools.jsf.vpe.richfaces.test.jbide.Jbide1614Test;
@@ -47,7 +48,7 @@
suite.addTestSuite(Jbide1639Test.class);
suite.addTestSuite(Jbide1682Test.class);
suite.addTestSuite(Jbide1548Test.class);
-
+ suite.addTestSuite(JBIDE1713Test.class);
// $JUnit-END$
List<ImportBean> projectToImport = new ArrayList<ImportBean>();
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/JBIDE1713Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/JBIDE1713Test.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/JBIDE1713Test.java 2008-03-03 13:42:48 UTC (rev 6669)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.jsf.vpe.richfaces.test.jbide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * Test JBIDE-1713
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ *
+ */
+public class JBIDE1713Test extends VpeTest {
+
+ public static final String IMPORT_PROJECT_NAME = "richFacesTest";
+
+ private static final String TEST_PAGE_NAME = "JBIDE/1713/JBIDE-1713.xhtml";
+
+ public JBIDE1713Test(String name) {
+ super(name);
+ }
+
+ // test method for JBIDE 1713 component
+ public void testJBIDE_1713() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(TEST_PAGE_NAME,
+ IMPORT_PROJECT_NAME);
+
+ assertNotNull("Could not open specified file " + file.getFullPath(),
+ file);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input);
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ nsIDOMElement element = document.getDocumentElement();
+
+ // check that element is not null
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
+
+ // find "table" elements
+ TestUtil.findElementsByName(node, elements, HTML.TAG_TABLE);
+
+ assertEquals(1, elements.size());
+
+ nsIDOMElement table = (nsIDOMElement) elements.get(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ assertNotNull(table);
+
+ // Check applying styleClass
+ String styleClass = table.getAttribute(HTML.ATTR_CLASS);
+ assertNotNull("styleClass attribute not apply", styleClass);
+ assertEquals("dr-pnlbar rich-panelbar dr-pnlbar-b myClass", styleClass);
+
+ // Check applying style
+ String stylePanel = table.getAttribute(HTML.ATTR_STYLE);
+ assertNotNull("style attribute not apply", stylePanel);
+ assertEquals(
+ "padding: 0px; height: 207px; width: 453px; font-weight: bold;",
+ stylePanel);
+
+ elements.clear();
+
+ TestUtil.findAllElementsByName(node, elements, HTML.TAG_DIV);
+
+ assertEquals(9, elements.size());
+
+ nsIDOMElement activeToggle = (nsIDOMElement) elements.get(4)
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ assertNotNull(activeToggle);
+ String activeToggleClass = activeToggle.getAttribute(HTML.ATTR_CLASS);
+ assertNotNull(activeToggleClass);
+ assertEquals(
+ "dr-pnlbar-h rich-panelbar-header myHeaderStyleActive myHeaderStyleActive",
+ activeToggleClass);
+
+ String activeToggleStyle = activeToggle.getAttribute(HTML.ATTR_STYLE);
+ assertNotNull(activeToggleStyle);
+ assertEquals(
+ "background: red none repeat scroll 0%; color: blue; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;",
+ activeToggleStyle);
+
+ // check active content
+ List<nsIDOMNode> contentElements = new ArrayList<nsIDOMNode>();
+ TestUtil.findAllElementsByName(node, contentElements, HTML.TAG_TD);
+
+ assertEquals(2, contentElements.size());
+
+ nsIDOMElement contentElement = (nsIDOMElement) contentElements.get(1)
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ assertNotNull(contentElement);
+
+ String activeContentStyle = contentElement
+ .getAttribute(HTML.ATTR_STYLE);
+ assertNotNull(activeContentStyle);
+ assertEquals("color: green;", activeContentStyle);
+
+ String activeContentClass = contentElement
+ .getAttribute(HTML.ATTR_CLASS);
+ assertNotNull(activeContentClass);
+ assertEquals(
+ "dr-pnlbar-c rich-panelbar-content myContentStyle myContentStyle",
+ activeContentClass);
+
+ // check facet
+ nsIDOMElement disabledToggle = (nsIDOMElement) elements.get(6)
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ assertNotNull(contentElement);
+
+ String disabledContentStyle = disabledToggle
+ .getAttribute(HTML.ATTR_STYLE);
+ assertNotNull(disabledContentStyle);
+ assertEquals("color: green;", disabledContentStyle);
+
+ String disabledContentClass = disabledToggle
+ .getAttribute(HTML.ATTR_CLASS);
+ assertNotNull(disabledContentClass);
+ assertEquals("dr-pnlbar-h rich-panelbar-header myHeaderStyle1",
+ disabledContentClass);
+
+ contentElements.clear();
+ TestUtil.findElementsByName((nsIDOMNode) disabledToggle,
+ contentElements, HTML.TAG_IMG);
+ assertEquals(1, contentElements.size());
+
+ disabledToggle = (nsIDOMElement) elements.get(8).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ assertNotNull(contentElement);
+
+ disabledContentStyle = disabledToggle.getAttribute(HTML.ATTR_STYLE);
+ assertNotNull(disabledContentStyle);
+ assertEquals("color: green;", disabledContentStyle);
+
+ disabledContentClass = disabledToggle.getAttribute(HTML.ATTR_CLASS);
+ assertNotNull(disabledContentClass);
+ assertEquals("dr-pnlbar-h rich-panelbar-header myHeaderStyle1",
+ disabledContentClass);
+
+ if (getException() != null) {
+ throw getException();
+ }
+ }
+
+}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-03-03 13:05:49 UTC (rev 6668)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-03-03 13:42:48 UTC (rev 6669)
@@ -28,6 +28,7 @@
import org.jboss.tools.vpe.ui.test.beans.ImportBean;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.xpcom.XPCOMException;
/**
* Class for importing project from jar file
@@ -37,176 +38,203 @@
*/
public class TestUtil {
- private static final String COMPONENTS_PATH = "WebContent/pages"; //$NON-NLS-1$
+ private static final String COMPONENTS_PATH = "WebContent/pages"; //$NON-NLS-1$
- private static final String WEBCONTENT_PATH = "WebContent"; //$NON-NLS-1$
+ private static final String WEBCONTENT_PATH = "WebContent"; //$NON-NLS-1$
- @SuppressWarnings("restriction")
- static void importProjectIntoWorkspace(String path, String projectName) {
+ @SuppressWarnings("restriction")
+ static void importProjectIntoWorkspace(String path, String projectName) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- projectName);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ projectName);
- try {
+ try {
- IOverwriteQuery overwrite = new IOverwriteQuery() {
- public String queryOverwrite(String pathString) {
- return ALL;
- }
- };
+ IOverwriteQuery overwrite = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return ALL;
+ }
+ };
- ImportProvider importProvider = new ImportProvider();
+ ImportProvider importProvider = new ImportProvider();
- // need to remove from imported project "svn" files
- List<String> unimportedFiles = new ArrayList<String>();
- unimportedFiles.add(".svn"); //$NON-NLS-1$
+ // need to remove from imported project "svn" files
+ List<String> unimportedFiles = new ArrayList<String>();
+ unimportedFiles.add(".svn"); //$NON-NLS-1$
- importProvider.setUnimportedFiles(unimportedFiles);
+ importProvider.setUnimportedFiles(unimportedFiles);
- // create import operation
- ImportOperation importOp = new ImportOperation(project
- .getFullPath(), new File(path), importProvider, overwrite);
+ // create import operation
+ ImportOperation importOp = new ImportOperation(project
+ .getFullPath(), new File(path), importProvider, overwrite);
- // import files just to project folder ( without old structure )
- importOp.setCreateContainerStructure(false);
+ // import files just to project folder ( without old structure )
+ importOp.setCreateContainerStructure(false);
- importOp.setContext(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell());
+ importOp.setContext(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
- // run import
- importOp.run(new NullProgressMonitor());
+ // run import
+ importOp.run(new NullProgressMonitor());
- } catch (InvocationTargetException ite) {
- VPETestPlugin.getDefault().logError(ite.getCause());
- } catch (InterruptedException ie) {
- VPETestPlugin.getDefault().logError(ie);
+ } catch (InvocationTargetException ite) {
+ VPETestPlugin.getDefault().logError(ite.getCause());
+ } catch (InterruptedException ie) {
+ VPETestPlugin.getDefault().logError(ie);
+ }
}
- }
- /**
- *
- * @return
- * @throws CoreException
- */
- public static IResource getComponentPath(String componentPage,
- String projectName) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- projectName);
- if (project != null) {
- return project.getFolder(COMPONENTS_PATH).findMember(componentPage);
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ public static IResource getComponentPath(String componentPage,
+ String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ projectName);
+ if (project != null) {
+ return project.getFolder(COMPONENTS_PATH).findMember(componentPage);
+ }
+
+ return null;
}
- return null;
- }
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ public static IResource getWebContentPath(String componentPage,
+ String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ projectName);
+ if (project != null) {
+ return project.getFolder(WEBCONTENT_PATH).findMember(componentPage);
+ }
- /**
- *
- * @return
- * @throws CoreException
- */
- public static IResource getWebContentPath(String componentPage,
- String projectName) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- projectName);
- if (project != null) {
- return project.getFolder(WEBCONTENT_PATH).findMember(componentPage);
+ return null;
}
- return null;
- }
+ /**
+ *
+ * @throws CoreException
+ */
+ static void removeProject(String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ projectName);
+ if (project != null) {
+ project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
+ }
+ }
- /**
- *
- * @throws CoreException
- */
- static void removeProject(String projectName) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- projectName);
- if (project != null) {
- project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
- new NullProgressMonitor());
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ public static void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
}
- }
- /**
- * Process UI input but do not return for the specified time interval.
- *
- * @param waitTimeMillis
- * the number of milliseconds
- */
- public static void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while (System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.update();
+ /**
+ * Wait until all background tasks are complete.
+ */
+ public static void waitForJobs() {
+ while (Job.getJobManager().currentJob() != null)
+ delay(100);
}
- // Otherwise, perform a simple sleep.
- else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored.
- }
- }
- }
- /**
- * Wait until all background tasks are complete.
- */
- public static void waitForJobs() {
- while (Job.getJobManager().currentJob() != null)
- delay(100);
- }
+ /**
+ * find elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findElementsByName(nsIDOMNode node,
+ List<nsIDOMNode> elements, String name) {
- /**
- * find elements by name
- *
- * @param node -
- * current node
- * @param elements -
- * list of found elements
- * @param name -
- * name element
- */
- static public void findElementsByName(nsIDOMNode node,
- List<nsIDOMNode> elements, String name) {
+ // get children
+ nsIDOMNodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ nsIDOMNode child = children.item(i);
- // get children
- nsIDOMNodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- nsIDOMNode child = children.item(i);
+ // if current child is required then add his to list
+ if (name.equalsIgnoreCase((child.getNodeName()))) {
- // if current child is required then add his to list
- if (name.equalsIgnoreCase((child.getNodeName()))) {
+ elements.add(child);
- elements.add(child);
+ } else {
- } else {
+ findElementsByName(child, elements, name);
- findElementsByName(child, elements, name);
+ }
+ }
- }
}
- }
+ /**
+ * find all elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findAllElementsByName(nsIDOMNode node,
+ List<nsIDOMNode> elements, String name) {
- static public List<ImportBean> createImportBeanList(String projectName,
- String resourcePath) {
- List<ImportBean> projectToImport = new ArrayList<ImportBean>();
- projectToImport.add(createImportBean(projectName, resourcePath));
- return projectToImport;
- }
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(name)) {
+ elements.add(node);
+ }
+ for (int i = 0; i < list.getLength(); i++) {
+ findAllElementsByName(list.item(i), elements, name);
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
+ }
- static public ImportBean createImportBean(String projectName,
- String resourcePath) {
- ImportBean importBean = new ImportBean();
- importBean.setImportProjectName(projectName);
- importBean.setImportProjectPath(resourcePath);
- return importBean;
- }
+ static public List<ImportBean> createImportBeanList(String projectName,
+ String resourcePath) {
+ List<ImportBean> projectToImport = new ArrayList<ImportBean>();
+ projectToImport.add(createImportBean(projectName, resourcePath));
+ return projectToImport;
+ }
+
+ static public ImportBean createImportBean(String projectName,
+ String resourcePath) {
+ ImportBean importBean = new ImportBean();
+ importBean.setImportProjectName(projectName);
+ importBean.setImportProjectPath(resourcePath);
+ return importBean;
+ }
}
16 years, 8 months
JBoss Tools SVN: r6668 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-03-03 08:05:49 -0500 (Mon, 03 Mar 2008)
New Revision: 6668
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1468
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-03-03 10:52:13 UTC (rev 6667)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-03-03 13:05:49 UTC (rev 6668)
@@ -1158,10 +1158,20 @@
nsISelection selection = visualSelectionController.getSelection(nsISelectionController.SELECTION_NORMAL);
nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null && visualNode.getNodeType() == Node.ELEMENT_NODE &&
- (HTML.TAG_INPUT.equalsIgnoreCase(visualNode.getNodeName()) || HTML.TAG_BUTTON.equalsIgnoreCase(visualNode.getNodeName()) || HTML.TAG_SELECT.equalsIgnoreCase(visualNode.getNodeName())) &&
- !selection.containsNode(visualNode, false) && visualBuilder.canInnerDrag((nsIDOMElement)visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))) {
- return (nsIDOMElement)visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ //FIX FOR JBIDE-1468 added by Sergey Dzmitrovich
+ if (visualNode != null
+ && visualNode.getNodeType() == Node.ELEMENT_NODE
+ && (HTML.TAG_INPUT.equalsIgnoreCase(visualNode.getNodeName())
+ || HTML.TAG_OPTION.equalsIgnoreCase(visualNode
+ .getNodeName())
+ || HTML.TAG_BUTTON.equalsIgnoreCase(visualNode
+ .getNodeName()) || HTML.TAG_SELECT
+ .equalsIgnoreCase(visualNode.getNodeName()))
+ /*&& !selection.containsNode(visualNode, false)*/
+ && visualBuilder.canInnerDrag((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))) {
+ return (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
}
return null;
}
16 years, 8 months
JBoss Tools SVN: r6667 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-03-03 05:52:13 -0500 (Mon, 03 Mar 2008)
New Revision: 6667
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-675, cashing of templates was removed, because it's unstable for now.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-03-03 10:09:14 UTC (rev 6666)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-03-03 10:52:13 UTC (rev 6667)
@@ -385,18 +385,18 @@
VpeCreationData creationData = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if(getPageContext().isCreationDataExistInCash(sourceNode)) {
+// if(getPageContext().isCreationDataExistInCash(sourceNode)) {
- creationData = getPageContext().getVpeCreationDataFromCash(sourceNode).createHashCopy();
- } else {
+// creationData = getPageContext().getVpeCreationDataFromCash(sourceNode).createHashCopy();
+// } else {
creationData = template.create(getPageContext(), sourceNode,
getVisualDocument());
- if(creationData.getNode()!=null) {
-
- getPageContext().addCreationDataToCash(sourceNode, creationData.createHashCopy());
-
- }
- }
+// if(creationData.getNode()!=null) {
+//
+// getPageContext().addCreationDataToCash(sourceNode, creationData.createHashCopy());
+//
+// }
+// }
} catch (XPCOMException ex) {
VpePlugin.getPluginLog().logError(ex);
VpeTemplate defTemplate = templateManager.getDefTemplate();
16 years, 8 months
JBoss Tools SVN: r6666 - trunk/as/docs/reference/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2008-03-03 05:09:14 -0500 (Mon, 03 Mar 2008)
New Revision: 6666
Modified:
trunk/as/docs/reference/en/modules/perspective.xml
trunk/as/docs/reference/en/modules/runtimes_servers.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-199 - adding info about command line arguments
Modified: trunk/as/docs/reference/en/modules/perspective.xml
===================================================================
--- trunk/as/docs/reference/en/modules/perspective.xml 2008-03-03 10:08:44 UTC (rev 6665)
+++ trunk/as/docs/reference/en/modules/perspective.xml 2008-03-03 10:09:14 UTC (rev 6666)
@@ -133,15 +133,11 @@
</table>
<para>By double-clicking on any server, an editor window will appear allowing you to
- edit parts of that server. The editor will also link you to modify that server's
- launch configuration, set command line arguments, and other things that are relevant
- to launching the server.</para>
+ edit parts of that server. On the figure you can see that a username/password is
+ available in the UI when configuring the server. If you get an SecurityException
+ when trying to launch the server, it is most likely because your server is protected
+ and hence you need to fill the username/password fields with appropriate values.</para>
- <para>On the figure you can see that a username/password is available in the UI when
- configuring the server. If you get an SecurityException when trying to launch the
- server, it is most likely because your server is protected and hence you need to
- fill the username/password fields with appropriate values.</para>
-
<figure>
<title>Preferences Page for the Chosen Server</title>
<mediaobject>
@@ -151,9 +147,30 @@
</mediaobject>
</figure>
- <para>As the JBoss servers have few properties to edit here, a shortcut to the launch
- configuration has been provided in the context menu when right-clicking on a server.</para>
+ <para>The editor will also allow you to modify that server's launch
+ configuration. It's just after clicking <emphasis>
+ <property>Open launch configuration</property>
+ </emphasis> link. In the open window there are the tabs for setting command line
+ arguments and other things that are relevant to launching the server.</para>
+ <figure id="com_line_arg">
+ <title>Launch Configuration Properties</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/perspective/perspective_20_b.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para>Look up <ulink
+ url="http://docs.jboss.org/jbossas/guides/installguide/r1/en/html/start-stop.html"
+ >here</ulink> to find parameters which can be specified for <property>JBoss
+ Server</property>.</para>
+
+ <para>As the JBoss Servers have few properties to modify in this editor, a shortcut to
+ the launch configuration has been provided in the context menu when right-clicking
+ on a server.</para>
+
<figure>
<title>Launch Configuration</title>
<mediaobject>
@@ -401,12 +418,14 @@
what its current value is.</para>
<para> By right-clicking on <emphasis>
- <property>XML Configuration</property>,
- </emphasis> you can create a new category. Besides, context menu for <emphasis>
- <property>XML Configuration</property>
- </emphasis> category makes possible to disable it. You can disable any category in the bottom part of the <emphasis>
- <property>JBoss Server View</property>.</emphasis> Look for them in the <emphasis>
- <property>Inactive Categories</property></emphasis> afterwards to re-enable.</para>
+ <property>XML Configuration</property>, </emphasis> you can create a new
+ category. Besides, context menu for <emphasis>
+ <property>XML Configuration</property>
+ </emphasis> category makes possible to disable it. You can disable any category in
+ the bottom part of the <emphasis>
+ <property>JBoss Server View</property>.</emphasis> Look for them in the <emphasis>
+ <property>Inactive Categories</property>
+ </emphasis> afterwards to re-enable.</para>
<figure>
<title>Adding New Category</title>
@@ -480,7 +499,8 @@
<note>
<title>Tip:</title>
<para>Notice, when you type the fields autocomplete to help you locate exactly what
- xpath you're looking for.</para></note>
+ xpath you're looking for.</para>
+ </note>
<para>Then, on the other hand, if your desired field is the text of an element
<emphasis><description></emphasis>, your <emphasis>
@@ -516,11 +536,11 @@
<section>
<title>Relevant Resources Links</title>
<para>Find more about XPath in the <ulink url="http://www.w3.org/TR/xpath20/">XPath
- Documentation</ulink>.</para>
+ Documentation</ulink>.</para>
</section>
</section>
<para/>
-
+
</section>
<section id="Project_archivesView">
@@ -593,8 +613,8 @@
<property>WAR</property> archive, the archive will be created with a few
filesets relevant to the known structure of the project.</para>
- <para>Here is the first page of all New archive wizards. It is the same for any archive type and the
- only page in the <property>New Jar Wizard</property>.</para>
+ <para>Here is the first page of all New archive wizards. It is the same for any archive
+ type and the only page in the <property>New Jar Wizard</property>.</para>
<figure>
<title>New JAR Wizard</title>
<mediaobject>
@@ -613,8 +633,8 @@
respective buttons. To select a destination inside some other archive, you'll need
to press the <emphasis>
<property>Workspace...</property>
- </emphasis> button. At the bottom of the list, you'll see archives that have been
- declared in the workspace.</para>
+ </emphasis> button. At the bottom of the list, you'll see archives that
+ have been declared in the workspace.</para>
<section id="CreatingaFolder">
<title>Creating a Folder</title>
<para>Creating a folder is much easier. You simply right-click on an archive or
@@ -630,7 +650,7 @@
<para>The <property>New Fileset Wizard</property> requires a destination (where the
files will go), and a root directory (or where the files are coming from). The
source can be anywhere in the workspace or from the filesystem at large.</para>
-
+
<figure>
<title>Adding a New FileSet</title>
<mediaobject>
@@ -639,7 +659,7 @@
</imageobject>
</mediaobject>
</figure>
-
+
<para>Below that, the fileset requires only an includes pattern and an excludes
pattern. As you type in either of these fields, the preview viewer should update
itself with which files are matched.</para>
@@ -759,10 +779,13 @@
</section>
<section>
<title>Relevant Resources Links</title>
- <para>Refer to <ulink url="http://ant.apache.org/manual/index.html">Ant manual</ulink> to find more on how to build your applications with help of Ant.</para>
- </section>
+ <para>Refer to <ulink url="http://ant.apache.org/manual/index.html">Ant manual</ulink>
+ to find more on how to build your applications with help of Ant.</para>
+ </section>
</section>
<literallayout> </literallayout>
- <para>At this point, you are guessed to be familiar with <property>JBoss AS Perspective</property> and your next step now is to explore how to work with different kinds of projects.</para>
+ <para>At this point, you are guessed to be familiar with <property>JBoss AS
+ Perspective</property> and your next step now is to explore how to work with different kinds
+ of projects.</para>
</chapter>
Modified: trunk/as/docs/reference/en/modules/runtimes_servers.xml
===================================================================
--- trunk/as/docs/reference/en/modules/runtimes_servers.xml 2008-03-03 10:08:44 UTC (rev 6665)
+++ trunk/as/docs/reference/en/modules/runtimes_servers.xml 2008-03-03 10:09:14 UTC (rev 6666)
@@ -171,7 +171,7 @@
start or stop servers, deploy to servers, or debug code that will run on the server. They keep
track of the modules (jars, wars, etc) you deploy to the server and also allow you to undeploy
those modules (see <link linkend="run_on_server_wizard">Deploying with Run On Server Wizard</link> section). </para>
- <para>Servers can be started or stopped with different command-line arguments. They are often
+ <para>Servers can be started or stopped with different <link linkend="com_line_arg">command-line arguments</link>. They are often
backed by a runtime object representing that server's location.</para>
<section>
<title>Creating a New Server</title>
16 years, 8 months