KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > localhistory > ui > view > LocalHistoryTopComponent


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.localhistory.ui.view;
20
21 import java.io.Serializable JavaDoc;
22 import javax.swing.JPanel JavaDoc;
23 import org.openide.util.NbBundle;
24 import org.openide.windows.TopComponent;
25
26 /**
27  * Top component which displays something.
28  *
29  * @author Tomas Stupka
30  */

31 final public class LocalHistoryTopComponent extends TopComponent {
32
33     private static LocalHistoryTopComponent instance;
34     private LocalHistoryFileView masterView;
35     private static final String JavaDoc PREFERRED_ID = "LocalHistoryTopComponent";
36
37     public LocalHistoryTopComponent() {
38         initComponents();
39         setToolTipText(NbBundle.getMessage(LocalHistoryTopComponent.class, "HINT_LocalHistoryTopComponent"));
40 // setIcon(Utilities.loadImage(ICON_PATH, true));
41
}
42
43     /** This method is called from within the constructor to
44      * initialize the form.
45      * WARNING: Do NOT modify this code. The content of this method is
46      * always regenerated by the Form Editor.
47      */

48     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
49
private void initComponents() {
50
51         splitPane = new javax.swing.JSplitPane JavaDoc();
52
53         setLayout(new java.awt.BorderLayout JavaDoc());
54
55         splitPane.setDividerLocation(150);
56         splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
57         splitPane.setOneTouchExpandable(true);
58         add(splitPane, java.awt.BorderLayout.CENTER);
59     }// </editor-fold>//GEN-END:initComponents
60

61
62     // Variables declaration - do not modify//GEN-BEGIN:variables
63
private javax.swing.JSplitPane JavaDoc splitPane;
64     // End of variables declaration//GEN-END:variables
65

66     public void init(JPanel JavaDoc diffPanel, LocalHistoryFileView masterView) {
67         // XXX should be solved in a more genarel way - not ony for LocalHistoryFileView
68
this.masterView = masterView;
69         splitPane.setTopComponent(masterView.getPanel());
70         splitPane.setBottomComponent(diffPanel);
71     }
72     
73     /**
74      * Gets default instance. Do not use directly: reserved for *.settings files only,
75      * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
76      * To obtain the singleton instance, use {@link findInstance}.
77      */

78     public static synchronized LocalHistoryTopComponent getDefault() {
79         if (instance == null) {
80             instance = new LocalHistoryTopComponent();
81         }
82         return instance;
83     }
84
85     public int getPersistenceType() {
86         return TopComponent.PERSISTENCE_NEVER;
87     }
88
89     public void componentOpened() {
90         super.componentOpened();
91     }
92
93     public void componentClosed() {
94         if(masterView != null) {
95             masterView.close();
96         }
97         super.componentClosed();
98     }
99
100     /** replaces this in object stream */
101     public Object JavaDoc writeReplace() {
102         return new ResolvableHelper();
103     }
104
105     protected String JavaDoc preferredID() {
106         return PREFERRED_ID;
107     }
108
109     final static class ResolvableHelper implements Serializable JavaDoc {
110         private static final long serialVersionUID = 1L;
111         public Object JavaDoc readResolve() {
112             return LocalHistoryTopComponent.getDefault();
113         }
114     }
115
116 }
117
Popular Tags