1 19 package org.netbeans.modules.localhistory.ui.view; 20 21 import java.io.Serializable ; 22 import javax.swing.JPanel ; 23 import org.openide.util.NbBundle; 24 import org.openide.windows.TopComponent; 25 26 31 final public class LocalHistoryTopComponent extends TopComponent { 32 33 private static LocalHistoryTopComponent instance; 34 private LocalHistoryFileView masterView; 35 private static final String PREFERRED_ID = "LocalHistoryTopComponent"; 36 37 public LocalHistoryTopComponent() { 38 initComponents(); 39 setToolTipText(NbBundle.getMessage(LocalHistoryTopComponent.class, "HINT_LocalHistoryTopComponent")); 40 } 42 43 48 private void initComponents() { 50 51 splitPane = new javax.swing.JSplitPane (); 52 53 setLayout(new java.awt.BorderLayout ()); 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 } 61 62 private javax.swing.JSplitPane splitPane; 64 66 public void init(JPanel diffPanel, LocalHistoryFileView masterView) { 67 this.masterView = masterView; 69 splitPane.setTopComponent(masterView.getPanel()); 70 splitPane.setBottomComponent(diffPanel); 71 } 72 73 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 101 public Object writeReplace() { 102 return new ResolvableHelper(); 103 } 104 105 protected String preferredID() { 106 return PREFERRED_ID; 107 } 108 109 final static class ResolvableHelper implements Serializable { 110 private static final long serialVersionUID = 1L; 111 public Object readResolve() { 112 return LocalHistoryTopComponent.getDefault(); 113 } 114 } 115 116 } 117 | Popular Tags |