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: XSDAttributeDeclarationItemProvider.java,v 1.7 2007/03/22 02:06:24 davidms Exp $
 
 package org.eclipse.xsd.provider;
 
 
 import java.util.List;
 
 
This is the item provider adpater for a org.eclipse.xsd.XSDAttributeDeclaration 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);
     }
     return ;
   }
 
   protected static class DelegatingItemPropertyDescriptor extends ItemPropertyDescriptor
   {
        (AdapterFactory adapterFactory,
         String displayName,
         String description,
         EStructuralFeature feature,
         boolean isSettable,
         Object staticImage)
     {
       super(adapterFactorydisplayNamedescriptionfeatureisSettablestaticImage);
     }
 
     @Override
     public Object getPropertyValue(Object object)
     {
     }
    @Override
    public void setPropertyValue(Object objectObject value)
    {
    }
  }
  protected void createNamePropertyDescriptor(Object object)
  {
    // This is for the name feature.
    //
         ..getString("_UI_Name_label"),
         ..getString("_UI_Name_description"),
         true,
       {
         @Override
        public void setPropertyValue(Object oObject value)
         {
           XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)o;
           if (xsdAttributeDeclaration.isAttributeDeclarationReference())
           {
             XSDAttributeDeclaration newResolvedAttributeDeclaration =
               xsdAttributeDeclaration.resolveAttributeDeclaration(xsdAttributeDeclaration.getTargetNamespace(), (String)value);
             EditingDomain editingDomain = getEditingDomain(xsdAttributeDeclaration);
             if (editingDomain == null)
             {
               xsdAttributeDeclaration.setResolvedAttributeDeclaration(newResolvedAttributeDeclaration);
             }
             else
             {
               editingDomain.getCommandStack().execute
                 (SetCommand.create
                    (editingDomain,
                     xsdAttributeDeclaration,
                     .getXSDAttributeDeclaration_ResolvedAttributeDeclaration(),
                     newResolvedAttributeDeclaration));
             }
           }
           else
           {
             super.setPropertyValue(ovalue);
           }
         }
       });
  }
  {
    // This is for the targetNamespace feature.
    //
         ..getString("_UI_TargetNamespace_label"),
         ..getString("_UI_TargetNamespace_description"),
         true,
       {
         @Override
        public void setPropertyValue(Object oObject value)
         {
           XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)o;
           if (xsdAttributeDeclaration.isAttributeDeclarationReference())
           {
             String namespace = (String)value;
             if (namespace.length() == 0)
             {
               namespace = null;
             }
             XSDAttributeDeclaration newResolvedAttributeDeclaration =
               xsdAttributeDeclaration.resolveAttributeDeclaration(namespacexsdAttributeDeclaration.getName());
             EditingDomain editingDomain = getEditingDomain(xsdAttributeDeclaration);
             if (editingDomain == null)
             {
               xsdAttributeDeclaration.setResolvedAttributeDeclaration(newResolvedAttributeDeclaration);
             }
             else
             {
               editingDomain.getCommandStack().execute
                 (SetCommand.create
                    (editingDomain,
                     xsdAttributeDeclaration,
                     .getXSDAttributeDeclaration_ResolvedAttributeDeclaration(),
                     newResolvedAttributeDeclaration));
             }
           }
           else
           {
             super.setPropertyValue(ovalue);
           }
         }
       });
  }
  {
    // This is for the elementFormDefault feature.
    //
         ..getString("_UI_Form_label"),
         ..getString("_UI_FormOfAttribute_description"),
         .getXSDFeature_Form(),
         true,
       {
         @Override
        public Object getPropertyDefaultValue(Object o)
         {
           return 
             ..getString
               ("_UI_DefaultValue_label"new Object [] { ((XSDAttributeDeclaration)o).getSchema().getAttributeFormDefault().getName() });
         }
       });
  }
  protected void createLexicalValuePropertyDescriptor(Object object)
  {
    // This is for the value feature.
    //
         ..getString("_UI_LexicalValue_label"),
         ..getString("_UI_LexicalValueOfAttribute_description"),
         true,
  }
  protected void createConstraintPropertyDescriptor(Object object)
  {
    // This is for the constraint feature.
    //
         ..getString("_UI_Constraint_label"),
         ..getString("_UI_ConstraintOfAttribute_description"),
         true,
  }
  protected void createScopePropertyDescriptor(Object object)
  {
    // This is for the scope feature.
    //
         ..getString("_UI_Scope_label"),
         ..getString("_UI_ScopeOfAttribute_description"),
         .getXSDFeature_Scope(),
         false,
        null));
  }
  {
    // This is for the typeDefinition feature.
    //
         ..getString("_UI_TypeDefinition_label"),
         ..getString("_UI_TypeDefinition_description"),
         false,
         null));
  }
  protected void createAnnotationPropertyDescriptor(Object object)
  {
    // This is for the annotation feature.
    //
      (new ItemPropertyDescriptor
         ..getString("_UI_Annotation_label"),
         ..getString("_UI_AnnotationOfAttribute_description"),
         false));
  }
  {
    // This is for the resolvedAttributeDeclaration feature.
    //
      (new ItemPropertyDescriptor
         ..getString("_UI_ResolveAttributeDeclaration_label"),
         ..getString("_UI_ResolveAttributeDeclaration_description"),
         false));
  }

  
  public Collection<? extends EStructuralFeaturegetChildrenFeatures(Object object)
  {
    if ( == null)
    {
      super.getChildrenFeatures(object);
    }
    return ;
  }

  
This returns XSDAttributeDeclaration.gif.
  public Object getImage(Object object)
  {
    XSDAttributeDeclaration xsdAttributeDeclaration = ((XSDAttributeDeclaration)object);
    XSDAttributeDeclaration resolvedAttributeDeclaration = xsdAttributeDeclaration.getResolvedAttributeDeclaration();
    return 
       (resolvedAttributeDeclaration.getContainer() == null ?
          "full/obj16/XSDAttributeUnresolved" :
          xsdAttributeDeclaration.getResolvedAttributeDeclaration() == xsdAttributeDeclaration ?
            "full/obj16/XSDAttributeDeclaration" :
            "full/obj16/XSDAttributeUse");
  }
  public String getText(Object object)
  {
    XSDAttributeDeclaration xsdAttributeDeclaration = ((XSDAttributeDeclaration)object);
    XSDAttributeDeclaration resolvedAttributeDeclaration = xsdAttributeDeclaration.getResolvedAttributeDeclaration();
    String name =
      xsdAttributeDeclaration != resolvedAttributeDeclaration ?
        xsdAttributeDeclaration.getQName() :
        xsdAttributeDeclaration.getName();
    StringBuffer result = new StringBuffer();
    if (name == null)
    {
      result.append(..getString("_UI_Absent_label"));
    }
    else
    {
      result.append(name);
    }
    if (resolvedAttributeDeclaration.getAnonymousTypeDefinition() == null && resolvedAttributeDeclaration.getTypeDefinition() != null)
    {
      result.append(" : ");
      result.append(resolvedAttributeDeclaration.getTypeDefinition().getQName(xsdAttributeDeclaration));
    }
    return result.toString();
  }

  
This handles notification by calling fireNotifyChanged.
  public void notifyChanged(Notification msg
  {
    XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)msg.getNotifier();
    {
      fireNotifyChanged(msg);
      XSDConcreteComponent container = xsdAttributeDeclaration.getContainer();
      if (container instanceof XSDAttributeUse)
      {
          (new ENotificationImpl
            ((InternalEObject)container
             msg.getEventType(), 
             (EStructuralFeature)msg.getFeature(), 
             msg.getOldValue(), 
             msg.getNewValue(), 
             msg.getPosition()));
      }
      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);
    {
      // annotation
      // atomic, list, and union simple type definitions
    }
  }
New to GrepCode? Check out our FAQ X