KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer;
21
22 import java.io.IOException JavaDoc;
23 import java.util.Map JavaDoc;
24 import org.netbeans.modules.xml.schema.model.Redefine;
25 import org.netbeans.modules.xml.schema.model.Schema;
26 import org.netbeans.modules.xml.schema.model.SchemaModel;
27 import org.netbeans.modules.xml.xam.Model;
28 import org.netbeans.modules.xml.xam.ui.customizer.ExternalReferenceCustomizer;
29 import org.netbeans.modules.xml.xam.ui.customizer.ExternalReferenceDecorator;
30 import org.openide.util.HelpCtx;
31
32 /**
33  * A redefine customizer.
34  *
35  * @author Administrator
36  * @author Nathan Fiedler
37  */

38 public class RedefineCustomizer extends ExternalReferenceCustomizer<Redefine> {
39     private static final long serialVersionUID = 1L;
40     private ExternalReferenceDecorator decorator;
41
42     /**
43      * Creates a new instance of RedefineCustomizer.
44      *
45      * @param redefine the component to customize.
46      */

47     public RedefineCustomizer(Redefine redefine) {
48         super(redefine, null);
49     }
50
51     @Override JavaDoc
52     public void applyChanges() throws IOException JavaDoc {
53         super.applyChanges();
54         if (isLocationChanged()) {
55             Redefine redefine = getModelComponent();
56             redefine.setSchemaLocation(getEditedLocation());
57         }
58     }
59
60     public boolean mustNamespaceDiffer() {
61         return false;
62     }
63
64     protected String JavaDoc getReferenceLocation() {
65         Redefine redefine = getModelComponent();
66         return redefine.getSchemaLocation();
67     }
68
69     protected String JavaDoc getNamespace() {
70         return null;
71     }
72
73     protected String JavaDoc getPrefix() {
74         return null;
75     }
76
77     public HelpCtx getHelpCtx() {
78         return new HelpCtx(RedefineCustomizer.class);
79     }
80
81     protected String JavaDoc getTargetNamespace(Model model) {
82         if (model instanceof SchemaModel) {
83             SchemaModel sm = (SchemaModel) model;
84             Schema schema = sm.getSchema();
85             if (schema != null) {
86                 return schema.getTargetNamespace();
87             }
88         }
89         return null;
90     }
91
92     protected Map JavaDoc<String JavaDoc, String JavaDoc> getPrefixes(Model model) {
93         if (model instanceof SchemaModel) {
94             SchemaModel sm = (SchemaModel) model;
95             Schema schema = sm.getSchema();
96             if (schema != null) {
97                 return schema.getPrefixes();
98             }
99         }
100         return null;
101     }
102
103     protected ExternalReferenceDecorator getNodeDecorator() {
104         if (decorator == null) {
105             decorator = new SchemaReferenceDecorator(this);
106         }
107         return decorator;
108     }
109
110     protected String JavaDoc generatePrefix() {
111         return "";
112     }
113 }
114
Popular Tags