001: package abbot.editor;
002:
003: import java.awt.*;
004:
005: import javax.swing.*;
006: import javax.swing.border.*;
007:
008: import abbot.Platform;
009: import abbot.i18n.Strings;
010:
011: /** Simple splash screen for the script editor. */
012: public class Costello {
013:
014: private static final String BUNDLE = "abbot.editor.i18n.costello";
015:
016: static {
017: // Don't need robot verification
018: System.setProperty("abbot.robot.verify", "false");
019: System.setProperty(
020: "com.apple.mrj.application.apple.menu.about.name",
021: "Costello");
022: if (Platform.JAVA_VERSION < Platform.JAVA_1_4) {
023: // Mac OSX setup stuff
024: System.setProperty(
025: "com.apple.mrj.application.growbox.intrudes",
026: "true");
027: System.setProperty(
028: "com.apple.macos.use-file-dialog-packages", "true");
029: System.setProperty("com.apple.macos.useScreenMenuBar",
030: "true");
031: } else {
032: System.setProperty("apple.laf.useScreenMenuBar", "true");
033: System.setProperty("apple.awt.showGrowBox", "true");
034: }
035: Strings.addBundle(BUNDLE);
036: }
037:
038: private static class SplashScreen extends JWindow {
039: boolean disposeOK = false;
040:
041: /** @deprecated */
042: public void hide() {
043: if (disposeOK) {
044: super .hide();
045: }
046: }
047:
048: public void dispose() {
049: if (disposeOK) {
050: super .dispose();
051: }
052: }
053: }
054:
055: private static SplashScreen splash = null;
056:
057: public static Window getSplashScreen() {
058: return splash;
059: }
060:
061: /** Note that this "main" is typical of many Swing apps, in that it does
062: window showing and disposal directly from the main thread. Running
063: the editor under itself should provide a reasonable test for handling
064: that scenario.
065: */
066: public static void main(String[] args) {
067: EditorContext ec = new EditorContext(args);
068: showCostello(ec);
069: }
070:
071: /** Invoke the costello editor with an editor configuration to give more fine
072: grained control
073: */
074: public static void showCostello(EditorContext ec) {
075:
076: // In non embedded case set look and feel
077: if (!ec.isEmbedded()) {
078: try {
079: String lafClass = System.getProperty(
080: "abbot.editor.look_and_feel", "system");
081: if ("system".equals(lafClass))
082: lafClass = UIManager
083: .getSystemLookAndFeelClassName();
084: if (lafClass != null && !"".equals(lafClass)
085: && !"default".equals(lafClass))
086: UIManager.setLookAndFeel(lafClass);
087: } catch (Exception e) {
088: }
089: }
090:
091: splash = new SplashScreen();
092: JLabel label = new LogoLabel();
093: // Add a beveled border on non-Mac platforms
094: if (!Platform.isOSX()) {
095: Border b = new CompoundBorder(new SoftBevelBorder(
096: BevelBorder.RAISED), label.getBorder());
097: label.setBorder(b);
098: }
099: splash.getContentPane().add(label);
100: splash.pack();
101: Rectangle screen = splash.getGraphicsConfiguration()
102: .getBounds();
103: Dimension size = splash.getSize();
104: Point loc = new Point(screen.x + (screen.width - size.width)
105: / 2, screen.y + (screen.height - size.height) / 2);
106: splash.setLocation(loc);
107: splash.setVisible(true);
108:
109: try {
110: ScriptEditor.showEditor(ec);
111: } finally {
112: splash.disposeOK = true;
113: // NOTE: disposal in main still screws us up, because the dispose
114: // does an invokeAndWait...
115: java.awt.EventQueue.invokeLater(new Runnable() {
116: public void run() {
117: splash.dispose();
118: splash = null;
119: }
120: });
121: }
122: }
123: }
|