KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > wizard > localized > LocalizedTemplateGroup


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  * LocalizedTemplateGroup.java
22  *
23  * Created on September 1, 2006, 12:15 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.wsdl.ui.view.wizard.localized;
30
31 import java.util.List JavaDoc;
32 import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementTemplateProvider;
33 import org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateGroup;
34 import org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateType;
35
36 /**
37  *
38  * @author radval
39  */

40 public class LocalizedTemplateGroup implements Comparable JavaDoc<LocalizedTemplateGroup> {
41     
42     public static final String JavaDoc TEMPLATE_GROUP="TEMPLATEGROUP";//NOI18N
43

44     private TemplateGroup mTGroup;
45     
46     private ExtensibilityElementTemplateProvider mProvider;
47     
48     private LocalizedTemplate[] mLtts = null;
49     
50     /** Creates a new instance of LocalizedTemplateGroup */
51     public LocalizedTemplateGroup(TemplateGroup tGroup, ExtensibilityElementTemplateProvider provider) {
52         this.mTGroup = tGroup;
53         this.mProvider = provider;
54     }
55     
56     public String JavaDoc getName() {
57         String JavaDoc lName = null;
58         String JavaDoc name = TEMPLATE_GROUP + "_name"; //NOI18N
59
try {
60             lName = this.mProvider.getLocalizedMessage(name, null);
61         } catch (Exception JavaDoc ex) {
62             lName = "UNKNOWN_NAME";
63         }
64         
65         return lName;
66     }
67     
68     public String JavaDoc getPrefix() {
69         String JavaDoc lPrefix = null;
70         String JavaDoc name = TEMPLATE_GROUP + "_prefix_" + this.mTGroup.getPrefix(); //NOI18N
71
try {
72             lPrefix = this.mProvider.getLocalizedMessage(name, null);
73         } catch (Exception JavaDoc ex) {
74             lPrefix = "UNKNOWN_PREFIX";
75         }
76         
77         return lPrefix;
78     }
79   
80     public String JavaDoc getNamespace() {
81         return this.mTGroup.getNamespace();
82     }
83     
84     public TemplateGroup getDelegate() {
85         return this.mTGroup;
86     }
87     
88     public LocalizedTemplate[] getTemplate() {
89         if(mLtts != null) {
90             return mLtts;
91         }
92         
93         TemplateType[] tts = this.mTGroup.getTemplate();
94         if(tts != null) {
95             mLtts = new LocalizedTemplate[tts.length];
96             for(int i =0; i < tts.length; i++) {
97                 TemplateType tt = tts[i];
98                 LocalizedTemplate ltt = new LocalizedTemplate(this, tt, this.mProvider);
99                 mLtts[i] = ltt;
100             }
101         }
102         
103         return mLtts;
104     }
105     
106     @Override JavaDoc
107     public String JavaDoc toString() {
108         return getName();
109     }
110
111     public int compareTo(LocalizedTemplateGroup o) {
112         return toString().compareTo(o.toString());
113     }
114 }
115
Popular Tags