001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.core;
043:
044: import java.io.IOException;
045: import javax.swing.event.ChangeEvent;
046: import javax.swing.event.ChangeListener;
047: import org.netbeans.core.startup.ModuleSystem;
048: import org.openide.awt.StatusDisplayer;
049: import org.openide.filesystems.FileSystem;
050: import org.openide.filesystems.Repository;
051:
052: /** Default implementation of TopManager that is used when
053: * the system is used without initialization.
054: *
055: * @author Jaroslav Tulach
056: */
057: public class Plain extends NbTopManager implements Runnable,
058: ChangeListener {
059:
060: private final StatusDisplayer status;
061:
062: /** Creates new Plain. */
063: public Plain() {
064: if (Boolean.getBoolean("org.netbeans.core.Plain.CULPRIT"))
065: Thread.dumpStack(); // NOI18N
066: status = StatusDisplayer.getDefault();
067: status.addChangeListener(this );
068: }
069:
070: private ModuleSystem moduleSystem;
071:
072: /** Test method to check whether some level of interactivity is enabled.
073: * @param il mask composed of the constants of IL_XXXX
074: * @return true if such level is enabled
075: */
076: public boolean isInteractive(int il) {
077: return (IL_WINDOWS & il) == IL_WINDOWS;
078: }
079:
080: /** Prints the stack trace of an exception.
081: */
082: public void notifyException(Throwable t) {
083: t.printStackTrace();
084: }
085:
086: /** */
087: public Object notify(org.openide.NotifyDescriptor nd) {
088: new Exception("TopManager.notify()").printStackTrace(); // NOI18N
089: System.out.println("MSG = " + nd.getMessage()); // NOI18N
090: Object[] options = nd.getOptions();
091: System.out.print("("); // NOI18N
092: for (int i = 0; i < options.length; i++) {
093: if (i != 0)
094: System.out.print(", "); // NOI18N
095: System.out.print(options[i]);
096: }
097: System.out.println(")"); // NOI18N
098: return new Object();
099: }
100:
101: /** Create the module system. Subclasses may override. */
102: protected ModuleSystem createModuleSystem() throws IOException {
103: FileSystem fs = Repository.getDefault().getDefaultFileSystem();
104: return new ModuleSystem(fs);
105: }
106:
107: /** Initializaton of modules if user directory provided.
108: */
109: public void run() {
110: try {
111: moduleSystem = createModuleSystem();
112: } catch (IOException ioe) {
113: notifyException(ioe);
114: return;
115: }
116: moduleSystem.loadBootModules();
117: if (!Repository.getDefault().getDefaultFileSystem()
118: .isReadOnly()) {
119: moduleSystem.readList();
120: moduleSystem.restore();
121: LoaderPoolNode.installationFinished();
122: } else {
123: LoaderPoolNode.installationFinished();
124: }
125: }
126:
127: /** Get the module subsystem. */
128: public ModuleSystem getModuleSystem() {
129: return moduleSystem;
130: }
131:
132: public void stateChanged(ChangeEvent e) {
133: System.out.println(status.getStatusText());
134: }
135:
136: }
|