Reorganized to be easily extensible.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3444 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-03-30 02:59:03 +00:00
parent d3603cfdc4
commit 5aba5ff57b
2 changed files with 65 additions and 50 deletions
@@ -59,15 +59,35 @@ public class EditorApp implements Runnable
/**
* Construct and initialize the EditorApp object.
*/
public EditorApp (final String target)
public EditorApp (String[] args)
throws IOException
{
final String target = (args.length > 0) ? args[0] : null;
if (System.getProperty("no_log_redir") != null) {
Log.info("Logging to console only.");
} else {
String dlog = localDataDir("editor.log");
try {
PrintStream logOut = new PrintStream(
new BufferedOutputStream(new FileOutputStream(dlog)));
System.setOut(logOut);
System.setErr(logOut);
Log.info("Opened debug log '" + dlog + "'.");
} catch (IOException ioe) {
Log.warning("Failed to open debug log [path=" + dlog +
", error=" + ioe + "].");
}
}
// we need to use heavy-weight popup menus so that they can overly
// our non-lightweight Miso view
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
// create and size the main application frame
_frame = new EditorFrame();
_frame = createEditorFrame();
// create our frame manager
_framemgr = FrameManager.newInstance(_frame);
@@ -213,33 +233,18 @@ public class EditorApp implements Runnable
_framemgr.start();
}
protected EditorFrame createEditorFrame ()
{
return new EditorFrame();
}
/**
* Instantiate the application object and start it running.
*/
public static void main (String[] args)
{
String target = (args.length > 0) ? args[0] : null;
if (System.getProperty("no_log_redir") != null) {
Log.info("Logging to console only.");
} else {
String dlog = localDataDir("editor.log");
try {
PrintStream logOut = new PrintStream(
new BufferedOutputStream(new FileOutputStream(dlog)));
System.setOut(logOut);
System.setErr(logOut);
Log.info("Opened debug log '" + dlog + "'.");
} catch (IOException ioe) {
Log.warning("Failed to open debug log [path=" + dlog +
", error=" + ioe + "].");
}
}
try {
EditorApp app = new EditorApp(target);
EditorApp app = new EditorApp(args);
// start up the UI on the AWT thread to avoid deadlocks
EventQueue.invokeLater(app);
@@ -164,22 +164,7 @@ public class EditorFrame extends ManagedJFrame
// create the "File" menu
JMenu menuFile = new JMenu("File");
menuFile.setMnemonic(KeyEvent.VK_F);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "New", KeyEvent.VK_N, accel,
this, "handleNew");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Open", KeyEvent.VK_O, accel,
this, "handleOpen");
//addMenuItem(menuFile, "Close", KeyEvent.VK_C);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Save", KeyEvent.VK_S, accel,
this, "handleSave");
MenuUtil.addMenuItem(menuFile, "Save As", KeyEvent.VK_A, null,
this, "handleSaveAs");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Quit", KeyEvent.VK_Q, accel,
this, "handleQuit");
createFileMenu(menuFile);
// create the "Edit" menu
// JMenu menuEdit = new JMenu("Edit");
@@ -193,17 +178,7 @@ public class EditorFrame extends ManagedJFrame
// create the "Actions" menu
JMenu menuActions = new JMenu("Actions");
MenuUtil.addMenuItem(menuActions, "Load (reload) test tiles", this,
"handleTestTiles");
menuActions.setMnemonic(KeyEvent.VK_A);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuActions, "Make default base tile",
KeyEvent.VK_M, accel, this, "handleSetDefBase");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuActions, "Update mini view",
KeyEvent.VK_M, accel, this, "updateMiniView");
createActionsMenu(menuActions);
// create the "Settings" menu
JMenu menuSettings = new JMenu("Settings");
@@ -224,6 +199,41 @@ public class EditorFrame extends ManagedJFrame
setJMenuBar(bar);
}
protected void createFileMenu (JMenu menuFile)
{
menuFile.setMnemonic(KeyEvent.VK_F);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "New", KeyEvent.VK_N, accel,
this, "handleNew");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Open", KeyEvent.VK_O, accel,
this, "handleOpen");
//addMenuItem(menuFile, "Close", KeyEvent.VK_C);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Save", KeyEvent.VK_S, accel,
this, "handleSave");
MenuUtil.addMenuItem(menuFile, "Save As", KeyEvent.VK_A, null,
this, "handleSaveAs");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuFile, "Quit", KeyEvent.VK_Q, accel,
this, "handleQuit");
}
protected void createActionsMenu (JMenu menuActions)
{
MenuUtil.addMenuItem(menuActions, "Load (reload) test tiles", this,
"handleTestTiles");
menuActions.setMnemonic(KeyEvent.VK_A);
accel = KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuActions, "Make default base tile",
KeyEvent.VK_M, accel, this, "handleSetDefBase");
accel = KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK);
MenuUtil.addMenuItem(menuActions, "Update mini view",
KeyEvent.VK_M, accel, this, "updateMiniView");
}
protected void setScene (StageScene scene)
{
// save off the scene objects