Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 668365c990321b74817c84836c4bce03e756a9e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*******************************************************************************
 * Copyright (c) 2001, 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 Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.adapters;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider;
import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject;
import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel;
import org.eclipse.xsd.XSDAttributeDeclaration;
import org.eclipse.xsd.XSDAttributeUse;
import org.eclipse.xsd.XSDTypeDefinition;

public class XSDAttributeUseAdapter extends XSDBaseAttributeAdapter implements IActionProvider
{
  protected XSDAttributeDeclaration getXSDAttributeDeclaration()
  {
    return getXSDAttributeUse().getAttributeDeclaration();
  }

  protected XSDAttributeDeclaration getResolvedXSDAttributeDeclaration()
  {
    return getXSDAttributeDeclaration().getResolvedAttributeDeclaration();
  }
  
  protected XSDAttributeUse getXSDAttributeUse()
  {
    return (XSDAttributeUse)target;
  }

  public XSDAttributeUseAdapter()
  {
    super();
  }

  public String getText()
  {
    return getTextForAttributeUse(getXSDAttributeUse(), true);
  }

  public String getTextForAttributeUse(XSDAttributeUse attributeUse, boolean showType)
  {
    XSDAttributeDeclaration ad = attributeUse.getAttributeDeclaration();
      
    StringBuffer result  = new StringBuffer();
    result.append(getTextForAttribute(ad, showType));
    /*
    if (xsdAttributeUse.isSetConstraint())
    {
      if (result.length() != 0)
      {
        result.append("  ");
      }
      result.append('<');
      result.append(xsdAttributeUse.getConstraint());
      result.append("=\"");
      result.append(xsdAttributeUse.getLexicalValue());
      result.append("\">");
    }
    */
    return result.toString();
  }
  
  public boolean isGlobal()
  {
    return false;
  }

  public IModel getModel()
  {
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDAttributeDeclaration().getSchema());
    return (IModel)adapter;
  }
  
  public String getTypeNameQualifier()
  {
    XSDTypeDefinition type = getResolvedXSDAttributeDeclaration().getTypeDefinition();
    if (type != null)
    {
      return type.getTargetNamespace();
    }
    return "";
  }

  public IADTObject getTopContainer()
  {
    return getGlobalXSDContainer(getXSDAttributeUse());
  }

  public boolean isReference()
  {
    return getXSDAttributeUse().getAttributeDeclaration().isAttributeDeclarationReference();
  }
}

Back to the top