KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > categorized > customizer > AdvancedGlobalElementCustomizer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * AdvancedGlobalElementCustomizer.java
22  *
23  * Created on January 17, 2006, 10:26 PM
24  */

25
26 package org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer;
27
28 import org.netbeans.modules.xml.schema.model.SchemaComponent;
29 import org.openide.util.HelpCtx;
30 //local imports
31
import org.netbeans.modules.xml.schema.model.GlobalElement;
32 import org.netbeans.modules.xml.schema.model.GlobalType;
33 import org.netbeans.modules.xml.schema.model.LocalType;
34 import org.netbeans.modules.xml.schema.model.SchemaComponentFactory;
35 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
36 import org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer.ElementCustomizer.ElementTypeStyle;
37
38 /**
39  * Global Element customizer
40  *
41  * @author Ajit Bhate
42  */

43 public class AdvancedGlobalElementCustomizer extends ElementCustomizer<GlobalElement>
44 {
45     
46     static final long serialVersionUID = 1L;
47     
48     /**
49      * Creates new form AdvancedGlobalElementCustomizer
50      */

51     /**
52      * Creates new form AdvancedLocalElementCustomizer
53      */

54     public AdvancedGlobalElementCustomizer(
55             SchemaComponentReference<GlobalElement> reference)
56     {
57         this(reference, null);
58     }
59     
60     public AdvancedGlobalElementCustomizer(
61             SchemaComponentReference<GlobalElement> reference,
62             SchemaComponent parent)
63     {
64         super(reference, parent);
65     }
66     
67     /**
68      * initializes non ui elements
69      */

70     protected void initializeModel()
71     {
72         GlobalElement element = getReference().get();
73         if (element.getType() != null)
74         {
75             _setType(element.getType().get());
76         }
77         else
78         {
79             _setType(element.getInlineType());
80         }
81     }
82     
83     /**
84      * Changes the type of element
85      *
86      */

87     protected void setModelType()
88     {
89         GlobalElement element = getReference().get();
90         SchemaComponentFactory factory = element.getModel().getFactory();
91         
92         ElementTypeStyle newStyle = getUIStyle();
93         GlobalType newType = getUIType();
94         _setType(newType);
95         if(newStyle == ElementTypeStyle.EXISTING)
96         {
97             if(element.getInlineType()!=null)
98             {
99                 element.setInlineType(null);
100             }
101             element.setType(factory.createGlobalReference(
102                     newType, GlobalType.class, element));
103         }
104         else
105         {
106             if(element.getType()!=null)
107             {
108                 element.setType(null);
109             }
110             LocalType lt = createLocalType(factory, newStyle, newType);
111             element.setInlineType(lt);
112         }
113     }
114
115     public HelpCtx getHelpCtx()
116     {
117         return new HelpCtx(AdvancedGlobalElementCustomizer.class);
118     }
119 }
120
Popular Tags