Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
<copyright> Copyright (c) 2002-2007 IBM Corporation and others. All rights reserved. This program and the accompanying materials are 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: IBM - Initial API and implementation </copyright> $Id: XSDComplexTypeDefinitionItemProvider.java,v 1.8 2007/03/22 02:06:23 davidms Exp $
 
 package org.eclipse.xsd.provider;
 
 
 import java.util.List;
 
 
This is the item provider adpater for a org.eclipse.xsd.XSDComplexTypeDefinition object.
 
   implements 
 {
  
This constructs an instance from a factory and a notifier.
 
   {
     super(adapterFactory);
   }

  
This returns the property descriptors for the adapted class.
 
   @Override
   {
     if ( == null)
     {
       super.getPropertyDescriptors(object);
 
       // This is for the derivationMethod feature.
       //
         (new ItemPropertyDescriptor
            ..getString("_UI_DerivationMethod_label"),
            ..getString("_UI_DerivationMethod_description"),
            true,
            .));
 
 /*
       // This is for the ffinal feature.
       //
       itemPropertyDescriptors.add
         (new ItemPropertyDescriptor
           (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
            XSDEditPlugin.INSTANCE.getString("_UI_Final_label"),
            XSDEditPlugin.INSTANCE.getString("_UI_FinalOfType_description"),
            xsdPackage.getXSDComplexTypeDefinition_Final(),
            true,
            ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
 */
 
       // This is for the fabstract feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_Abstract_label"),
           ..getString("_UI_AbstractOfType_description"),
           true,
      // This is for the mixed feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_Mixed_label"),
           ..getString("_UI_Mixed_description"),
           true,
      // This is for the contentTypeCategory feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_ContentTypeCategory_label"),
           ..getString("_UI_ContentTypeCategory_description"),
           true,
      // This is for the contentType feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_ContentType_label"),
           ..getString("_UI_ContentType_description"),
           false));
      // This is for the prohibitedSubstitutions feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_ProhibitedSubstitutions_label"),
           ..getString("_UI_ProhibitedSubstitutions_description"),
           false,
         {
           @Override
          public Object getPropertyValue(Object o)
           {
             return ((XSDComplexTypeDefinition)o).getStringProhibitedSubstitutions();
           }
         });
      // This is for the attributeWildcardContent feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_AttributeWildcard_label"),
           ..getString("_UI_AttributeWildcardOfType_description"),
           false));
      // This is for the annotation feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_Annotation_label"),
           ..getString("_UI_AnnotationOfType_description"),
           false));
      // This is for the baseTypeDefinition feature.
      //
        (new ItemPropertyDescriptor
           ..getString("_UI_BaseTypeDefinition_label"),
           ..getString("_UI_BaseTypeDefinition_description"),
           false));
    }
  }
  protected void createLexicalFinalPropertyDescriptor(Object object)
  {
    // This is for the final feature.
    //
         ..getString("_UI_LexicalFinal_label"),
         ..getString("_UI_LexicalFinal_description"),
         true,
       {
         @Override
        public Object getPropertyValue(Object o)
         {
           return ((XSDComplexTypeDefinition)o).getStringLexicalFinal();
         }
         @Override
        public void setPropertyValue(Object oObject value)
         {
           ((XSDComplexTypeDefinition)o).setStringLexicalFinal((String)value);
         }
         @Override
        public Collection<?> getChoiceOfValues(Object o)
         {
           Collection<Objectresult = new ArrayList<Object>();
           result.add("");
           result.add("#all");
           result.add("extension");
           result.add("restriction");
           result.add("extension restriction");
           return result;
         }
       });
  }
  protected void createFinalPropertyDescriptor(Object object)
  {
    // This is for the final feature.
    //
         ..getString("_UI_Final_label"),
         ..getString("_UI_Final_description"),
         false,
       {
         @Override
        public Object getPropertyValue(Object o)
         {
           return ((XSDComplexTypeDefinition)o).getStringFinal();
         }
       });
  }
  protected void createBlockPropertyDescriptor(Object object)
  {
    // This is for the final feature.
    //
         ..getString("_UI_Block_label"),
         ..getString("_UI_BlockOfType_description"),
         true,
       {
         @Override
        public Object getPropertyValue(Object o)
         {
           return ((XSDComplexTypeDefinition)o).getStringBlock();
         }
         @Override
        public void setPropertyValue(Object oObject value)
         {
           ((XSDComplexTypeDefinition)o).setStringBlock((String)value);
         }
         @Override
        public Collection<?> getChoiceOfValues(Object o)
         {
           Collection<Objectresult = new ArrayList<Object>();
           result.add("");
           result.add("#all");
           result.add("extension");
           result.add("restriction");
           result.add("substitution");
           result.add("extension restriction");
           result.add("extension substitution");
           result.add("extension restriction substitution");
           result.add("restriction substitution");
           return result;
         }
       });
  }

  
  public Collection<? extends EStructuralFeaturegetChildrenFeatures(Object object)
  {
    if ( == null)
    {
      super.getChildrenFeatures(object);
    }
    return ;
  }
  protected EStructuralFeature getChildFeature(Object objectObject child)
  {
    EObject refObject = (EObject)child;
    if (refObject instanceof XSDAttributeDeclaration)
    {
      // TODO: check that this is what you want.
    }
    return super.getChildFeature(objectchild);
  }

  
This returns XSDComplexTypeDefinition.gif.
  public Object getImage(Object object)
  {
    XSDComplexTypeDefinition xsdComplexTypeDefinition = ((XSDComplexTypeDefinition)object);
    return 
        (xsdComplexTypeDefinition.getContainer() == null ?
          "full/obj16/XSDComplexTypeDefinitionUnresolved" :
          "full/obj16/XSDComplexTypeDefinition");
  }
  public String getText(Object object)
  {
    return getText(objecttrue);
  }
  public String getText(Object objectboolean showType)
  {
    XSDComplexTypeDefinition xsdComplexTypeDefinition = ((XSDComplexTypeDefinition)object);
    StringBuffer result = new StringBuffer();
    result.append
     (xsdComplexTypeDefinition.getName() == null ? 
        xsdComplexTypeDefinition.getAliasName() : 
        xsdComplexTypeDefinition.getName());
    if (showType)
    {
      XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition();
      if (baseTypeDefinition != null && 
            baseTypeDefinition != xsdComplexTypeDefinition.getContent() &&
            baseTypeDefinition.getName() != null &&
            !XSDConstants.isURType(baseTypeDefinition))
      {
        result.append(" : ");
        result.append(baseTypeDefinition.getQName(xsdComplexTypeDefinition));
      }
    }
    return result.toString();
  }

  
This handles notification by calling fireNotifyChanged.
  public void notifyChanged(Notification msg
  {
          msg.getFeature() == .getXSDComplexTypeDefinition_Final() || 
          msg.getFeature() == .getXSDComplexTypeDefinition_Abstract() || 
          msg.getFeature() == .getXSDComplexTypeDefinition_Content() || 
          msg.getFeature() == .getXSDTypeDefinition_Annotations() || 
          msg.getFeature() == .getXSDTypeDefinition_Annotation())
    {
      fireNotifyChanged(msg);
      return;
    }
    super.notifyChanged(msg);
  }

  
This adds org.eclipse.emf.edit.command.CommandParameters describing the children that can be created under this object.
  protected void collectNewChildDescriptors(Collection<ObjectnewChildDescriptorsObject object)
  {
    super.collectNewChildDescriptors(newChildDescriptorsobject);
    // type annotation
    XSDContentTypeCategory contentType = ctd.getContentTypeCategory();
    // content annotation on simple type definition content (simple type
    // definition already contains its own derivation annotation)...
    if (contentType == .)
    {
      // content annotation
    }
    // content and derivation annotations on complex content, if not
    // restriction of anyTypeDefinition (for which short form is used)...
    else if ((contentType == . ||
              contentType == .) &&
             !(ctd.getBaseTypeDefinition() == anyTypeDefinition &&
               ctd.getDerivationMethod() == .))
    {
      // content annotation
      // derivation annotation
    }
    // atomic simple type definition content
    addSimpleTypeDefinitionChildParameters(newChildDescriptorsctd.getXSDComplexTypeDefinition_Content(), truefalsefalse);
    // all, choice, and sequence model groups particle content
    // model group definition reference particle content
    // attribute declaration under attribute use
    // attribute declaration reference under attribute use
    // attribute group definition reference
    // attribute wildcard
  }
New to GrepCode? Check out our FAQ X