KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > Plain


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
20 package org.netbeans.core;
21
22 import java.io.IOException JavaDoc;
23 import javax.swing.event.ChangeEvent JavaDoc;
24 import javax.swing.event.ChangeListener JavaDoc;
25 import org.netbeans.core.startup.ModuleSystem;
26 import org.openide.awt.StatusDisplayer;
27 import org.openide.filesystems.FileSystem;
28 import org.openide.filesystems.Repository;
29
30 /** Default implementation of TopManager that is used when
31 * the system is used without initialization.
32 *
33 * @author Jaroslav Tulach
34 */

35 public class Plain extends NbTopManager implements Runnable JavaDoc, ChangeListener JavaDoc {
36
37     private final StatusDisplayer status;
38
39     /** Creates new Plain. */
40     public Plain() {
41         if (Boolean.getBoolean("org.netbeans.core.Plain.CULPRIT")) Thread.dumpStack(); // NOI18N
42
status = StatusDisplayer.getDefault();
43         status.addChangeListener(this);
44     }
45   
46     private ModuleSystem moduleSystem;
47   
48
49     /** Test method to check whether some level of interactivity is enabled.
50     * @param il mask composed of the constants of IL_XXXX
51     * @return true if such level is enabled
52     */

53     public boolean isInteractive (int il) {
54         return (IL_WINDOWS & il) == IL_WINDOWS;
55     }
56
57     /** Prints the stack trace of an exception.
58     */

59     public void notifyException (Throwable JavaDoc t) {
60         t.printStackTrace();
61     }
62
63   /** */
64   public Object JavaDoc notify (org.openide.NotifyDescriptor nd) {
65     new Exception JavaDoc("TopManager.notify()").printStackTrace(); // NOI18N
66
System.out.println("MSG = " + nd.getMessage()); // NOI18N
67
Object JavaDoc[] options = nd.getOptions();
68     System.out.print("("); // NOI18N
69
for(int i = 0; i < options.length; i++) {
70       if (i != 0) System.out.print(", "); // NOI18N
71
System.out.print(options[i]);
72     }
73     System.out.println(")"); // NOI18N
74
return new Object JavaDoc();
75   }
76   
77     /** Create the module system. Subclasses may override. */
78     protected ModuleSystem createModuleSystem() throws IOException JavaDoc {
79         FileSystem fs = Repository.getDefault().getDefaultFileSystem();
80         return new ModuleSystem(fs);
81     }
82   
83     /** Initializaton of modules if user directory provided.
84      */

85     public void run() {
86         try {
87             moduleSystem = createModuleSystem();
88         } catch (IOException JavaDoc ioe) {
89             notifyException(ioe);
90             return;
91         }
92         moduleSystem.loadBootModules();
93         if (!Repository.getDefault().getDefaultFileSystem().isReadOnly()) {
94             moduleSystem.readList();
95             moduleSystem.restore();
96             LoaderPoolNode.installationFinished();
97         } else {
98             LoaderPoolNode.installationFinished();
99         }
100     }
101   
102     /** Get the module subsystem. */
103     public ModuleSystem getModuleSystem() {
104         return moduleSystem;
105     }
106   
107     public void stateChanged(ChangeEvent JavaDoc e) {
108         System.out.println(status.getStatusText());
109     }
110     
111 }
112
Popular Tags