KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > core > multiview > SchemaSourceMultiViewDesc


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.core.multiview;
21
22 import java.io.IOException JavaDoc;
23 import java.io.ObjectInput JavaDoc;
24 import java.io.ObjectOutput JavaDoc;
25 import java.io.Serializable JavaDoc;
26 import org.netbeans.core.spi.multiview.MultiViewDescription;
27 import org.netbeans.core.spi.multiview.MultiViewFactory;
28 import org.netbeans.modules.xml.schema.core.SchemaDataObject;
29 import org.netbeans.modules.xml.schema.core.SchemaEditorSupport;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Utilities;
32 import org.openide.windows.TopComponent;
33 /**
34  *
35  * @author Jeri Lockhart
36  */

37 public class SchemaSourceMultiViewDesc
38                 implements MultiViewDescription, Serializable JavaDoc {
39     
40     
41     private static final long serialVersionUID = -4505309173196320880L;
42     public static final String JavaDoc PREFERRED_ID = "xml-schema-sourceview";
43     private SchemaDataObject schemaDataObject;
44     
45     // Constructor for reserialization
46
public SchemaSourceMultiViewDesc( ) {
47     }
48     
49     /** Creates a new instance of SchemaSourceMultiviewDesc */
50     public SchemaSourceMultiViewDesc(SchemaDataObject schemaDataObject) {
51         this.schemaDataObject = schemaDataObject;
52     }
53
54     public String JavaDoc preferredID() {
55     return PREFERRED_ID;
56     }
57
58     public int getPersistenceType() {
59             return TopComponent.PERSISTENCE_ONLY_OPENED;
60     }
61
62     public java.awt.Image JavaDoc getIcon() {
63         return Utilities.loadImage(SchemaDataObject.SCHEMA_ICON_BASE_WITH_EXT);
64     }
65
66     public org.openide.util.HelpCtx getHelpCtx() {
67             return org.openide.util.HelpCtx.DEFAULT_HELP;
68     }
69
70     public String JavaDoc getDisplayName() {
71         return NbBundle.getMessage(SchemaColumnViewMultiViewDesc.class, "LBL_sourceView_name");
72     }
73
74     public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
75             SchemaEditorSupport editorSupport =
76         schemaDataObject.getSchemaEditorSupport();
77             if (editorSupport != null) {
78                 SchemaSourceMultiViewElement editorComponent = new SchemaSourceMultiViewElement(schemaDataObject);
79                 return editorComponent;
80             }
81             return MultiViewFactory.BLANK_ELEMENT;
82     
83     }
84     
85     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
86     out.writeObject(schemaDataObject);
87     }
88
89     public void readExternal(ObjectInput JavaDoc in)
90     throws IOException JavaDoc, ClassNotFoundException JavaDoc
91     {
92     Object JavaDoc firstObject = in.readObject();
93     if (firstObject instanceof SchemaDataObject)
94         schemaDataObject = (SchemaDataObject) firstObject;
95     }
96     
97 }
98
Popular Tags