dw_fluffos_v1/
dw_fluffos_v1/fluffos-1.22c11/
dw_fluffos_v1/fluffos-1.22c11/ChangeLog.old/
dw_fluffos_v1/fluffos-1.22c11/Win32/
dw_fluffos_v1/fluffos-1.22c11/compat/
dw_fluffos_v1/fluffos-1.22c11/compat/simuls/
dw_fluffos_v1/fluffos-1.22c11/include/
dw_fluffos_v1/fluffos-1.22c11/mudlib/
dw_fluffos_v1/fluffos-1.22c11/testsuite/
dw_fluffos_v1/fluffos-1.22c11/testsuite/clone/
dw_fluffos_v1/fluffos-1.22c11/testsuite/command/
dw_fluffos_v1/fluffos-1.22c11/testsuite/data/
dw_fluffos_v1/fluffos-1.22c11/testsuite/etc/
dw_fluffos_v1/fluffos-1.22c11/testsuite/include/
dw_fluffos_v1/fluffos-1.22c11/testsuite/inherit/
dw_fluffos_v1/fluffos-1.22c11/testsuite/inherit/master/
dw_fluffos_v1/fluffos-1.22c11/testsuite/log/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/compiler/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/efuns/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/operators/
dw_fluffos_v1/fluffos-1.22c11/testsuite/u/
dw_fluffos_v1/fluffos-1.22c11/tmp/
dw_fluffos_v1/lib/
dw_fluffos_v1/lib/binaries/cmds/
dw_fluffos_v1/lib/binaries/cmds/creator/
dw_fluffos_v1/lib/binaries/cmds/living/
dw_fluffos_v1/lib/binaries/cmds/player/
dw_fluffos_v1/lib/binaries/d/admin/obj/
dw_fluffos_v1/lib/binaries/d/liaison/
dw_fluffos_v1/lib/binaries/global/virtual/
dw_fluffos_v1/lib/binaries/global/virtual/setup_compiler/
dw_fluffos_v1/lib/binaries/obj/handlers/autodoc/
dw_fluffos_v1/lib/binaries/obj/handlers/terrain_things/
dw_fluffos_v1/lib/binaries/obj/misc/
dw_fluffos_v1/lib/binaries/obj/misc/buckets/
dw_fluffos_v1/lib/binaries/obj/monster/
dw_fluffos_v1/lib/binaries/obj/reactions/
dw_fluffos_v1/lib/binaries/obj/reagents/
dw_fluffos_v1/lib/binaries/secure/cmds/creator/
dw_fluffos_v1/lib/binaries/secure/master/
dw_fluffos_v1/lib/binaries/std/
dw_fluffos_v1/lib/binaries/std/dom/
dw_fluffos_v1/lib/binaries/std/effects/object/
dw_fluffos_v1/lib/binaries/std/guilds/
dw_fluffos_v1/lib/binaries/std/languages/
dw_fluffos_v1/lib/binaries/std/races/
dw_fluffos_v1/lib/binaries/std/room/
dw_fluffos_v1/lib/binaries/std/room/basic/
dw_fluffos_v1/lib/binaries/std/shops/
dw_fluffos_v1/lib/binaries/std/shops/inherit/
dw_fluffos_v1/lib/binaries/www/
dw_fluffos_v1/lib/cmds/guild-race/
dw_fluffos_v1/lib/cmds/guild-race/crafts/
dw_fluffos_v1/lib/cmds/guild-race/other/
dw_fluffos_v1/lib/cmds/playtester/
dw_fluffos_v1/lib/cmds/playtester/senior/
dw_fluffos_v1/lib/d/admin/
dw_fluffos_v1/lib/d/admin/log/
dw_fluffos_v1/lib/d/admin/mapper/31-10-01/mapmaker/event/
dw_fluffos_v1/lib/d/admin/meetings/
dw_fluffos_v1/lib/d/admin/obj/
dw_fluffos_v1/lib/d/admin/room/we_care/
dw_fluffos_v1/lib/d/admin/save/
dw_fluffos_v1/lib/d/dist/
dw_fluffos_v1/lib/d/dist/mtf/
dw_fluffos_v1/lib/d/dist/pumpkin/
dw_fluffos_v1/lib/d/dist/pumpkin/chars/
dw_fluffos_v1/lib/d/dist/pumpkin/desert/
dw_fluffos_v1/lib/d/dist/pumpkin/gumboot/
dw_fluffos_v1/lib/d/dist/pumpkin/hospital/
dw_fluffos_v1/lib/d/dist/pumpkin/inherit/
dw_fluffos_v1/lib/d/dist/pumpkin/map/
dw_fluffos_v1/lib/d/dist/pumpkin/plain/
dw_fluffos_v1/lib/d/dist/pumpkin/pumpkin/
dw_fluffos_v1/lib/d/dist/pumpkin/save/
dw_fluffos_v1/lib/d/dist/pumpkin/squash/
dw_fluffos_v1/lib/d/dist/pumpkin/terrain/
dw_fluffos_v1/lib/d/dist/pumpkin/woods/
dw_fluffos_v1/lib/d/dist/start/
dw_fluffos_v1/lib/d/learning/TinyTown/buildings/
dw_fluffos_v1/lib/d/learning/TinyTown/map/
dw_fluffos_v1/lib/d/learning/TinyTown/roads/
dw_fluffos_v1/lib/d/learning/add_command/
dw_fluffos_v1/lib/d/learning/arms_and_weps/
dw_fluffos_v1/lib/d/learning/chars/
dw_fluffos_v1/lib/d/learning/cutnpaste/
dw_fluffos_v1/lib/d/learning/examples/npcs/
dw_fluffos_v1/lib/d/learning/examples/player_houses/npcs/
dw_fluffos_v1/lib/d/learning/examples/terrain_map/basic/
dw_fluffos_v1/lib/d/learning/functions/
dw_fluffos_v1/lib/d/learning/handlers/
dw_fluffos_v1/lib/d/learning/help_topics/npcs/
dw_fluffos_v1/lib/d/learning/help_topics/objects/
dw_fluffos_v1/lib/d/learning/help_topics/rcs_demo/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/crowd/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/situations/
dw_fluffos_v1/lib/d/learning/items/
dw_fluffos_v1/lib/d/learning/save/
dw_fluffos_v1/lib/d/liaison/
dw_fluffos_v1/lib/d/liaison/NEWBIE/doc/
dw_fluffos_v1/lib/d/liaison/NEWBIE/save/oldlog/
dw_fluffos_v1/lib/db/
dw_fluffos_v1/lib/doc/
dw_fluffos_v1/lib/doc/creator/
dw_fluffos_v1/lib/doc/creator/autodoc/include/reaction/
dw_fluffos_v1/lib/doc/creator/autodoc/include/ritual_system/
dw_fluffos_v1/lib/doc/creator/autodoc/include/talker/
dw_fluffos_v1/lib/doc/creator/autodoc/include/terrain_map/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/baggage/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/clock/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/clothing/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/cont_save/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/corpse/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/money/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/monster/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/scabbard/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/service_provider/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/state_changer/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/wand/
dw_fluffos_v1/lib/doc/creator/autodoc/std/book_dir/
dw_fluffos_v1/lib/doc/creator/autodoc/std/key/
dw_fluffos_v1/lib/doc/creator/autodoc/std/learning/
dw_fluffos_v1/lib/doc/creator/autodoc/std/map/
dw_fluffos_v1/lib/doc/creator/autodoc/std/race/
dw_fluffos_v1/lib/doc/creator/autodoc/std/weapon_logic/
dw_fluffos_v1/lib/doc/creator/files/
dw_fluffos_v1/lib/doc/creator/policy/
dw_fluffos_v1/lib/doc/creator/room/
dw_fluffos_v1/lib/doc/effects/
dw_fluffos_v1/lib/doc/ideas/
dw_fluffos_v1/lib/doc/known_command/
dw_fluffos_v1/lib/doc/lpc/basic_manual/
dw_fluffos_v1/lib/doc/lpc/intermediate/
dw_fluffos_v1/lib/doc/new/add_command/
dw_fluffos_v1/lib/doc/new/handlers/
dw_fluffos_v1/lib/doc/new/living/
dw_fluffos_v1/lib/doc/new/living/race/
dw_fluffos_v1/lib/doc/new/living/spells/
dw_fluffos_v1/lib/doc/new/player/
dw_fluffos_v1/lib/doc/new/room/guild/
dw_fluffos_v1/lib/doc/new/room/outside/
dw_fluffos_v1/lib/doc/new/room/storeroom/
dw_fluffos_v1/lib/doc/object/
dw_fluffos_v1/lib/doc/playtesters/
dw_fluffos_v1/lib/doc/policy/
dw_fluffos_v1/lib/doc/weapons/
dw_fluffos_v1/lib/global/handlers/
dw_fluffos_v1/lib/global/virtual/setup_compiler/
dw_fluffos_v1/lib/include/
dw_fluffos_v1/lib/include/cmds/
dw_fluffos_v1/lib/include/effects/
dw_fluffos_v1/lib/include/npc/
dw_fluffos_v1/lib/include/shops/
dw_fluffos_v1/lib/net/daemon/chars/
dw_fluffos_v1/lib/net/inherit/
dw_fluffos_v1/lib/net/intermud3/
dw_fluffos_v1/lib/net/intermud3/services/
dw_fluffos_v1/lib/net/obj/
dw_fluffos_v1/lib/net/save/
dw_fluffos_v1/lib/net/smnmp/
dw_fluffos_v1/lib/net/snmp/
dw_fluffos_v1/lib/obj/amulets/
dw_fluffos_v1/lib/obj/b_day/
dw_fluffos_v1/lib/obj/examples/
dw_fluffos_v1/lib/obj/food/alcohol/
dw_fluffos_v1/lib/obj/food/chocolates/
dw_fluffos_v1/lib/obj/food/fruits/
dw_fluffos_v1/lib/obj/food/meat/
dw_fluffos_v1/lib/obj/food/nuts/
dw_fluffos_v1/lib/obj/food/seafood/
dw_fluffos_v1/lib/obj/food/vegetables/
dw_fluffos_v1/lib/obj/fungi/
dw_fluffos_v1/lib/obj/furnitures/artwork/
dw_fluffos_v1/lib/obj/furnitures/bathroom/
dw_fluffos_v1/lib/obj/furnitures/beds/
dw_fluffos_v1/lib/obj/furnitures/cabinets/
dw_fluffos_v1/lib/obj/furnitures/chairs/
dw_fluffos_v1/lib/obj/furnitures/chests/
dw_fluffos_v1/lib/obj/furnitures/clocks/
dw_fluffos_v1/lib/obj/furnitures/crockery/
dw_fluffos_v1/lib/obj/furnitures/cupboards/
dw_fluffos_v1/lib/obj/furnitures/cushions/
dw_fluffos_v1/lib/obj/furnitures/fake_plants/
dw_fluffos_v1/lib/obj/furnitures/lamps/
dw_fluffos_v1/lib/obj/furnitures/mirrors/
dw_fluffos_v1/lib/obj/furnitures/outdoor/
dw_fluffos_v1/lib/obj/furnitures/safes/
dw_fluffos_v1/lib/obj/furnitures/shelves/
dw_fluffos_v1/lib/obj/furnitures/sideboards/
dw_fluffos_v1/lib/obj/furnitures/sofas/
dw_fluffos_v1/lib/obj/furnitures/stoves/
dw_fluffos_v1/lib/obj/furnitures/tables/
dw_fluffos_v1/lib/obj/furnitures/wardrobes/
dw_fluffos_v1/lib/obj/handlers/
dw_fluffos_v1/lib/obj/handlers/autodoc/
dw_fluffos_v1/lib/obj/jewellery/anklets/
dw_fluffos_v1/lib/obj/jewellery/bracelets/
dw_fluffos_v1/lib/obj/jewellery/earrings/
dw_fluffos_v1/lib/obj/jewellery/misc/
dw_fluffos_v1/lib/obj/jewellery/necklaces/
dw_fluffos_v1/lib/obj/jewellery/rings/
dw_fluffos_v1/lib/obj/media/
dw_fluffos_v1/lib/obj/misc/buckets/
dw_fluffos_v1/lib/obj/misc/jars/
dw_fluffos_v1/lib/obj/misc/papers/
dw_fluffos_v1/lib/obj/misc/player_shop/
dw_fluffos_v1/lib/obj/misc/shops/
dw_fluffos_v1/lib/obj/misc/traps/
dw_fluffos_v1/lib/obj/monster/
dw_fluffos_v1/lib/obj/monster/godmother/
dw_fluffos_v1/lib/obj/monster/transport/
dw_fluffos_v1/lib/obj/plants/inherit/
dw_fluffos_v1/lib/obj/potions/
dw_fluffos_v1/lib/open/boards/
dw_fluffos_v1/lib/save/autodoc/
dw_fluffos_v1/lib/save/bank_accounts/
dw_fluffos_v1/lib/save/boards/frog/
dw_fluffos_v1/lib/save/books/bed_catalog/
dw_fluffos_v1/lib/save/creators/
dw_fluffos_v1/lib/save/mail/
dw_fluffos_v1/lib/save/mail/p/
dw_fluffos_v1/lib/save/newsrc/b/
dw_fluffos_v1/lib/save/newsrc/c/
dw_fluffos_v1/lib/save/newsrc/d/
dw_fluffos_v1/lib/save/newsrc/f/
dw_fluffos_v1/lib/save/newsrc/p/
dw_fluffos_v1/lib/save/newsrc/s/
dw_fluffos_v1/lib/save/newsrc/w/
dw_fluffos_v1/lib/save/players/c/
dw_fluffos_v1/lib/save/players/d/
dw_fluffos_v1/lib/save/players/g/
dw_fluffos_v1/lib/save/players/p/
dw_fluffos_v1/lib/save/players/s/
dw_fluffos_v1/lib/save/soul/data/
dw_fluffos_v1/lib/save/tasks/
dw_fluffos_v1/lib/save/vaults/
dw_fluffos_v1/lib/secure/cmds/lord/
dw_fluffos_v1/lib/secure/config/
dw_fluffos_v1/lib/secure/items/
dw_fluffos_v1/lib/secure/player/
dw_fluffos_v1/lib/soul/
dw_fluffos_v1/lib/soul/i/
dw_fluffos_v1/lib/soul/j/
dw_fluffos_v1/lib/soul/k/
dw_fluffos_v1/lib/soul/o/
dw_fluffos_v1/lib/soul/q/
dw_fluffos_v1/lib/soul/to_approve/
dw_fluffos_v1/lib/soul/u/
dw_fluffos_v1/lib/soul/v/
dw_fluffos_v1/lib/soul/wish_list/
dw_fluffos_v1/lib/soul/y/
dw_fluffos_v1/lib/soul/z/
dw_fluffos_v1/lib/std/creator/
dw_fluffos_v1/lib/std/effects/
dw_fluffos_v1/lib/std/effects/attached/
dw_fluffos_v1/lib/std/effects/external/
dw_fluffos_v1/lib/std/effects/fighting/
dw_fluffos_v1/lib/std/effects/other/
dw_fluffos_v1/lib/std/environ/
dw_fluffos_v1/lib/std/guilds/
dw_fluffos_v1/lib/std/hospital/
dw_fluffos_v1/lib/std/house/
dw_fluffos_v1/lib/std/house/onebedhouse/
dw_fluffos_v1/lib/std/house/onebedhut/
dw_fluffos_v1/lib/std/house/tworoomflat/
dw_fluffos_v1/lib/std/languages/
dw_fluffos_v1/lib/std/liquids/
dw_fluffos_v1/lib/std/nationality/
dw_fluffos_v1/lib/std/nationality/accents/
dw_fluffos_v1/lib/std/nationality/accents/national/
dw_fluffos_v1/lib/std/nationality/accents/regional/
dw_fluffos_v1/lib/std/npc/goals/
dw_fluffos_v1/lib/std/npc/goals/basic/
dw_fluffos_v1/lib/std/npc/goals/misc/
dw_fluffos_v1/lib/std/npc/inherit/
dw_fluffos_v1/lib/std/npc/plans/
dw_fluffos_v1/lib/std/npc/plans/basic/
dw_fluffos_v1/lib/std/outsides/
dw_fluffos_v1/lib/std/races/shadows/
dw_fluffos_v1/lib/std/room/basic/topography/
dw_fluffos_v1/lib/std/room/controller/
dw_fluffos_v1/lib/std/room/controller/topography/
dw_fluffos_v1/lib/std/room/furniture/games/
dw_fluffos_v1/lib/std/room/furniture/inherit/
dw_fluffos_v1/lib/std/room/inherit/carriage/
dw_fluffos_v1/lib/std/room/inherit/topography/
dw_fluffos_v1/lib/std/room/punishments/
dw_fluffos_v1/lib/std/room/topography/area/
dw_fluffos_v1/lib/std/room/topography/iroom/
dw_fluffos_v1/lib/std/room/topography/milestone/
dw_fluffos_v1/lib/std/shadows/
dw_fluffos_v1/lib/std/shadows/attached/
dw_fluffos_v1/lib/std/shadows/curses/
dw_fluffos_v1/lib/std/shadows/disease/
dw_fluffos_v1/lib/std/shadows/fighting/
dw_fluffos_v1/lib/std/shadows/room/
dw_fluffos_v1/lib/std/shops/controllers/
dw_fluffos_v1/lib/std/shops/objs/
dw_fluffos_v1/lib/std/shops/player_shop/
dw_fluffos_v1/lib/std/shops/player_shop/office_code/
dw_fluffos_v1/lib/std/socket/
dw_fluffos_v1/lib/www/
dw_fluffos_v1/lib/www/external/autodoc/
dw_fluffos_v1/lib/www/external/java/telnet/Documentation/
dw_fluffos_v1/lib/www/external/java/telnet/Documentation/images/
dw_fluffos_v1/lib/www/external/java/telnet/examples/
dw_fluffos_v1/lib/www/external/java/telnet/tools/
dw_fluffos_v1/lib/www/pics/
dw_fluffos_v1/lib/www/secure/creator/
dw_fluffos_v1/lib/www/secure/editors/
dw_fluffos_v1/lib/www/secure/survey_results/
package mapmaker;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.text.*;
import java.util.*;

import mapmaker.event.*;

public class MainFrame extends JFrame
{
    public final static int TOOL_PALETTE_HEIGHT = 180;
    public final static int TOOL_PALETTE_WIDTH = 160;

    static String PROJECT_COMMENT = "// Project: {0}";
    static String AUTHOR_COMMENT = "// Author: {0}";
    static String DATE_COMMENT = "// Date: {0}\n";
    static String SETUP_HEADER = "void setup()";
    static String SET_LIGHT = "set_light({0});\n";
    static String SET_ROOM_SIZE = "set_room_size({0});\n";
    static String SET_DETERMINATE = "add_property(\"determinate\", \"{0} \");\n";
    static String SET_SHORT = "set_short(\"{0}\");\n";
    static String SET_LONG = "set_long(\"{0}\");\n";
    static String SET_DAY_LONG = "set_day_long(\"{0}\");\n";
    static String SET_NIGHT_LONG = "set_night_long(\"{0}\");\n";
    static String ADD_ITEM = "add_item({0}, \"{1}\");";
    static String ADD_DAY_ITEM = "add_day_item({0}, \"{1}\");";
    static String ADD_NIGHT_ITEM = "add_night_item({0}, \"{1}\");";
    static String ADD_EXIT = "add_exit(\"{0}\", PATH + \"{1}\", \"{2}\");";

    EventListenerList mListenerList = new EventListenerList();

    JDesktopPane mDesktop;
    JToolBar mToolBar;
    JLabel mStatusBar;
    MainFrame mFrame;

    MapWindow mActiveMapWindow;

    InheritBean mInheritBean;
    ExitBean mExitBean;
    BriefRoomBean mBriefRoomBean;
    ZoneBean mZoneBean;

    JFileChooser mFileChooser;

    NewAction mNewAction;
    OpenAction mOpenAction;
    CloseAction mCloseAction;
    SaveAction mSaveAction;
    SaveAsAction mSaveAsAction;
    SaveAllAction mSaveAllAction;
    UndoAction mUndoAction;
    RedoAction mRedoAction;
    CutAction mCutAction;
    CopyAction mCopyAction;
    PasteAction mPasteAction;
    ExitAction mExitAction;
    ResizeAction mResizeAction;
    ExportAction mExportAction;
    ExportOptionsAction mExportOptionsAction;

    public MainFrame()
    {
        super("Discworld Mapper");

        mFrame = this;

        mFileChooser = new JFileChooser();

        // Set window dimensions.
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(screenSize.width / 6, screenSize.height / 6,
            (screenSize.width / 6) * 4, (screenSize.height / 6) * 4);

        // Add save dialog HERE.
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });

        JPanel mainPanel = new JPanel();
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(mainPanel, BorderLayout.CENTER);

        createActions();

        getContentPane().add(createToolBar(), BorderLayout.NORTH);

        mainPanel.setLayout(new BorderLayout());

        mStatusBar = new JLabel(" ");
        mainPanel.add(mStatusBar, BorderLayout.SOUTH);

        mDesktop = new JDesktopPane();
        mainPanel.add(new JScrollPane(mDesktop), BorderLayout.CENTER);

        setJMenuBar(createMenuBar());

        addKeyListener(new KeyAdapter()
        {
            public void keyPressed(KeyEvent e)
            {
                MapView mapView = getActiveMapView();

                if (mapView != null)
                {
                    switch (e.getKeyChar())
                    {
                        case 'c' :
                            mapView.cycleLinkUpGroup();
                            break;
                        case KeyEvent.VK_DELETE :
                            mapView.deleteSelectedLocations();
                            break;
                    }
                }
            }
        });

        mCloseAction.setEnabled(false);
        mSaveAction.setEnabled(false);
        mSaveAsAction.setEnabled(false);
        mSaveAllAction.setEnabled(false);
        mCutAction.setEnabled(false);
        mCopyAction.setEnabled(false);
        mPasteAction.setEnabled(false);
        mResizeAction.setEnabled(false);
        mUndoAction.setEnabled(false);
        mRedoAction.setEnabled(false);
        mExportAction.setEnabled(false);
        mExportOptionsAction.setEnabled(false);

        createToolPalette();
    }

    public void setStatus(String aStatus)
    {
        mStatusBar.setText(aStatus);
    }

    protected void createActions()
    {
        mNewAction = new NewAction();
        mOpenAction = new OpenAction();
        mCloseAction = new CloseAction();
        mSaveAction = new SaveAction();
        mSaveAsAction = new SaveAsAction();
        mSaveAllAction = new SaveAllAction();
        mUndoAction = new UndoAction();
        mRedoAction = new RedoAction();
        mCutAction = new CutAction();
        mCopyAction = new CopyAction();
        mPasteAction = new PasteAction();
        mExitAction = new ExitAction();
        mResizeAction = new ResizeAction();
        mExportAction = new ExportAction();
        mExportOptionsAction = new ExportOptionsAction();
    }

    protected JToolBar createToolBar()
    {
        JToolBar toolBar = new JToolBar();

        toolBar.add(new ToolBarButton(mNewAction));
        toolBar.add(new ToolBarButton(mOpenAction));
        toolBar.add(new ToolBarButton(mSaveAction));

        toolBar.add(new ToolBarButton(mExportAction));

        toolBar.addSeparator();
        toolBar.add(new ToolBarButton(mUndoAction));
        toolBar.add(new ToolBarButton(mRedoAction));
        //toolBar.addSeparator();
        //toolBar.add(new ToolBarButton(mCutAction));
        //toolBar.add(new ToolBarButton(mCopyAction));
        //toolBar.add(new ToolBarButton(mPasteAction));

        return toolBar;
    }

    protected JMenuBar createMenuBar()
    {
        JMenuBar menuBar = new JMenuBar();

        JMenu fileMenu = new JMenu("File");
        fileMenu.setMnemonic(KeyEvent.VK_F);
        fileMenu.add(new JMenuItem(mNewAction));
        fileMenu.add(new JMenuItem(mOpenAction));
        fileMenu.add(new JMenuItem(mCloseAction));
        fileMenu.addSeparator();
        fileMenu.add(new JMenuItem(mSaveAction));
        fileMenu.add(new JMenuItem(mSaveAsAction));
        //fileMenu.add(new JMenuItem(mSaveAllAction));
        fileMenu.addSeparator();
        fileMenu.add(new JMenuItem(mExitAction));

        JMenu editMenu = new JMenu("Edit");
        editMenu.setMnemonic(KeyEvent.VK_E);
        editMenu.add(new JMenuItem(mUndoAction));
        editMenu.add(new JMenuItem(mRedoAction));
        //editMenu.addSeparator();
        //editMenu.add(new JMenuItem(mCutAction));
        //editMenu.add(new JMenuItem(mCopyAction));
        //editMenu.add(new JMenuItem(mPasteAction));
        editMenu.addSeparator();
        editMenu.add(new JMenuItem(mResizeAction));

        JMenu mapMenu = new JMenu("Map");
        mapMenu.setMnemonic(KeyEvent.VK_M);
        mapMenu.add(new JMenuItem(mExportAction));
        mapMenu.add(new JMenuItem(mExportOptionsAction));

        menuBar.add(fileMenu);
        menuBar.add(editMenu);
        menuBar.add(mapMenu);

        return menuBar;
    }

    public void createToolPalette()
    {
        JInternalFrame toolPalette = new ToolPalette(this);
        toolPalette.setVisible(true);
        mDesktop.add(toolPalette);
    }

    public MapWindow createMapWindow(MapModel aMapModel, String aTitle)
    {
        MapWindow mapWindow = new MapWindow(this, aTitle);
        mapWindow.setMapView(new MapView(aMapModel, this, mInheritBean, mExitBean));
        mapWindow.setVisible(true);
        mDesktop.add(mapWindow);

        return mapWindow;
    }

    public MapWindow createMapWindow(MapModel aMapModel)
    {
        return createMapWindow(aMapModel, null);
    }

    public void setActiveWindow(MapWindow aMapWindow)
    {
        mActiveMapWindow = aMapWindow;

        if (mActiveMapWindow == null)
        {
            mCloseAction.setEnabled(false);
            mSaveAction.setEnabled(false);
            mExportAction.setEnabled(false);
            mExportOptionsAction.setEnabled(false);
            mSaveAsAction.setEnabled(false);
            mSaveAllAction.setEnabled(false);
            mCutAction.setEnabled(false);
            mCopyAction.setEnabled(false);
            mPasteAction.setEnabled(false);
            mResizeAction.setEnabled(false);
        }
        else
        {
            mCloseAction.setEnabled(true);
            mSaveAction.setEnabled(true);
            mExportAction.setEnabled(true);
            mExportOptionsAction.setEnabled(true);
            mSaveAsAction.setEnabled(true);
            mSaveAllAction.setEnabled(true);
            mCutAction.setEnabled(true);
            mCopyAction.setEnabled(true);
            mPasteAction.setEnabled(true);
            mResizeAction.setEnabled(true);
        }

        fireActiveMapChanged();
    }

    public void addActiveMapListener(ActiveMapListener listener)
    {
        mListenerList.add(ActiveMapListener.class, listener);
    }

    public void removeActiveMapListener(ActiveMapListener listener)
    {
        mListenerList.remove(ActiveMapListener.class, listener);
    }

    protected void fireActiveMapChanged()
    {
        Object[] listeners = mListenerList.getListenerList();

        ActiveMapEvent activeMapEvent = new ActiveMapEvent(this,
            getActiveMapWindow());

        for (int i = listeners.length - 2; i >= 0; i -= 2)
        {
            if (listeners[i] == ActiveMapListener.class)
            {
                ((ActiveMapListener)listeners[i + 1]).activeMapChanged(activeMapEvent);
            }
        }
    }

    public MapWindow getActiveMapWindow()
    {
        return mActiveMapWindow;
    }

    public MapView getActiveMapView()
    {
        MapWindow mapWindow = getActiveMapWindow();

        if (mapWindow == null)
        {
            return null;
        }

        return mapWindow.getMapView();
    }

    public void refreshUndoRedo()
    {
        MapView mapView = getActiveMapView();

        if (mapView != null)
        {
            mUndoAction.setEnabled(mapView.mUndoManager.canUndo());
            mUndoAction.putValue(Action.LONG_DESCRIPTION,
                mapView.mUndoManager.getUndoPresentationName());

            mRedoAction.setEnabled(mapView.mUndoManager.canRedo());
            mRedoAction.putValue(Action.LONG_DESCRIPTION,
                mapView.mUndoManager.getRedoPresentationName());
        }
    }

    static int mPaletteNo = 0;

    class ToolPalette extends JInternalFrame
    {
        public ToolPalette(JFrame aFrame)
        {
            super("Tool Frame", false, false, false, false);

            setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

            setSize(MainFrame.TOOL_PALETTE_WIDTH, MainFrame.TOOL_PALETTE_HEIGHT);

            setLayer(JDesktopPane.PALETTE_LAYER);

            if (getUI() instanceof javax.swing.plaf.metal.MetalInternalFrameUI)
            {
                ((javax.swing.plaf.metal.MetalInternalFrameUI)getUI()).setPalette(true);
            }

            setLocation(aFrame.getWidth() - MainFrame.TOOL_PALETTE_WIDTH - 30,
                30 + (mPaletteNo++ * MainFrame.TOOL_PALETTE_HEIGHT));

            JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP);

            // Inherit Bean
            mInheritBean = new InheritBean(mFrame);
            addActiveMapListener(mInheritBean);
            mInheritBean.setEnabled(false);
            pane.add(mInheritBean, "Inherit");

            // Exit Bean
            mExitBean = new ExitBean();
            addActiveMapListener(mExitBean);
            mExitBean.setEnabled(false);

            // Brief Room Bean
            mBriefRoomBean = new BriefRoomBean();
            addActiveMapListener(mBriefRoomBean);
            mBriefRoomBean.setEnabled(false);
            JPanel roomPanel = new JPanel(new BorderLayout());
            roomPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 5, 5));
            JPanel exitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
            exitPanel.add(mExitBean);
            roomPanel.add(exitPanel, BorderLayout.CENTER);
            roomPanel.add(mBriefRoomBean, BorderLayout.SOUTH);
            pane.add(roomPanel, "Room");

            // Zone Bean
            mZoneBean = new ZoneBean(mFrame);
            addActiveMapListener(mZoneBean);
            mZoneBean.setEnabled(false);
            JPanel zonePanel = new JPanel(new BorderLayout());
            zonePanel.add(mZoneBean, BorderLayout.CENTER);
            zonePanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 5, 5));
            pane.add(zonePanel, "Area");

            pane.setFont(new Font("Arial", Font.BOLD, 9));
            pane.setOpaque(true);
            setContentPane(pane);
        }

        public void setSelected(boolean aSelection)
        {
            // This stops the internal frame competing with active windows
            // for focus.
        }
    }

    class ToolBarButton extends JButton
    {
        Border mEmptyBorder = BorderFactory.createEmptyBorder(3, 3, 3, 3);
        Border mEtchedBorder = BorderFactory.createCompoundBorder(
            BorderFactory.createEtchedBorder(),
            BorderFactory.createEmptyBorder(1, 1, 1, 1));

        public ToolBarButton(Action aAction)
        {
            super(aAction);

            setText("");

            //setIcon((Icon)aAction.getValue("largeIcon"));

            //setBorder(mEmptyBorder);

            final Action action = aAction;

            addMouseListener(new MouseAdapter()
            {
                public void mouseEntered(MouseEvent e)
                {
                    //setBorder(mEtchedBorder);
                    setStatus((String)action.getValue(Action.LONG_DESCRIPTION));
                }

                public void mouseExited(MouseEvent e)
                {
                    //setBorder(mEmptyBorder);
                    setStatus(" ");
                }
            });
        }
    }

    class NewAction extends AbstractAction
    {
        private static final String NAME = "New";
        private static final String SMALL_ICON = "New16.gif";
        private static final String LARGE_ICON = "New24.gif";
        private static final String SHORT_DESCRIPTION = "New";
        private static final String LONG_DESCRIPTION = "Create a new map";
        private static final int MNEMONIC_KEY = 'N';

        public NewAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            Dimension mapSize = MapSizeDialog.showNewRoomDialog(mFrame, new Dimension(500, 500));

            if (mapSize == null)
            {
                return;
            }

            MapWindow mapWindow = createMapWindow(new MapModel(mapSize));

            try
            {
                mapWindow.setSelected(true);
            }
            catch (java.beans.PropertyVetoException ex)
            {
                ex.printStackTrace();
            }
        }
    }

    class OpenAction extends AbstractAction
    {
        private static final String NAME = "Open";
        private static final String SMALL_ICON = "Open16.gif";
        private static final String LARGE_ICON = "Open24.gif";
        private static final String SHORT_DESCRIPTION = "Open";
        private static final String LONG_DESCRIPTION = "Open a map";
        private static final int MNEMONIC_KEY = 'O';

        public OpenAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            MapModel mapModel = null;

            int returnVal = mFileChooser.showOpenDialog(mFrame);

            if (returnVal != JFileChooser.APPROVE_OPTION)
            {
                return;
            }

            File file = mFileChooser.getSelectedFile();
            String filename = file.getAbsolutePath();

            try
            {
                FileInputStream in = new FileInputStream(filename);
                ObjectInputStream s = new ObjectInputStream(in);
                mapModel = (MapModel)s.readObject();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }

            MapWindow mapWindow = createMapWindow(mapModel, filename);

            try
            {
                mapWindow.setSelected(true);
            }
            catch (java.beans.PropertyVetoException ex)
            {
                ex.printStackTrace();
            }
        }
    }

    class CloseAction extends AbstractAction
    {
        private static final String NAME = "Close";
        private static final String SMALL_ICON = "Blank16.gif";
        private static final String LARGE_ICON = "Blank24.gif";
        private static final String SHORT_DESCRIPTION = "Close";
        private static final String LONG_DESCRIPTION = "Close the current map";
        private static final int MNEMONIC_KEY = 'C';

        public CloseAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class SaveAction extends AbstractAction
    {
        private static final String NAME = "Save";
        private static final String SMALL_ICON = "Save16.gif";
        private static final String LARGE_ICON = "Save24.gif";
        private static final String SHORT_DESCRIPTION = "Save";
        private static final String LONG_DESCRIPTION = "Save the current map";
        private static final int MNEMONIC_KEY = 'S';

        public SaveAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            MapWindow mapWindow = getActiveMapWindow();
            MapModel mapModel = getActiveMapView().getMapModel();

            String filename = mapModel.getFilename();

            if (mapModel.getFilename() == null)
            {
                int returnVal = mFileChooser.showSaveDialog(mFrame);

                if (returnVal == JFileChooser.APPROVE_OPTION)
                {
                    File file = mFileChooser.getSelectedFile();
                    filename = file.getAbsolutePath();
                    mapModel.setFilename(filename);
                    mapWindow.setTitle(filename);
                }
                else
                {
                    return;
                }
            }

            try
            {
                FileOutputStream out = new FileOutputStream(filename);
                ObjectOutputStream s = new ObjectOutputStream(out);
                s.writeObject(getActiveMapView().getMapModel());
                s.flush();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        }
    }

    class ExportOptionsAction extends AbstractAction
    {
        private static final String NAME = "Export Options...";
        private static final String SMALL_ICON = "Blank16.gif";
        private static final String LARGE_ICON = "Blank24.gif";
        private static final String SHORT_DESCRIPTION = "Export Options";
        private static final String LONG_DESCRIPTION = "Change the map's export options";
        private static final int MNEMONIC_KEY = 'P';

        public ExportOptionsAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            MapWindow mapWindow = getActiveMapWindow();
            MapModel mapModel = getActiveMapView().getMapModel();

            ExportOptions exportOptions = mapModel.getExportOptions();
            exportOptions = ExportOptionsDialog.showExportOptionsDialog(mFrame,
                exportOptions);
            if (exportOptions != null)
            {
                mapModel.setExportOptions(exportOptions);
            }
        }
    }

    class ExportAction extends AbstractAction
    {
        private static final String NAME = "Export";
        private static final String SMALL_ICON = "Export16.gif";
        private static final String LARGE_ICON = "Export24.gif";
        private static final String SHORT_DESCRIPTION = "Export";
        private static final String LONG_DESCRIPTION = "Export the current map as LPC";
        private static final int MNEMONIC_KEY = 'X';

        Hashtable mFormatHashtable = new Hashtable();

        String mIndent = "";

/*
        public String columnFormat(String aString, int aLeading, int aCols,
            int aIndent)
        {
            int firstLineMax = aCols - aLeading;
            String str;
            int lastSpace;
            int nextLastSpace;

            str = aString.substring(0, firstLineMax);
            lastSpace = str.lastIndexOf(' ');
            str = str.substring(0, lastSpace + 1);

            System.out.println("    set_long(\"" + str + "\"");

            str = aString.substring(lastSpace + 1, lastSpace + aCols);
            nextLastSpace = lastSpace + str.lastIndexOf(' ') + 2;
            lastSpace = str.lastIndexOf(' ');
            str = str.substring(0, lastSpace + 1);

            System.out.println("        \"" + str + "\"");

            str = aString.substring(nextLastSpace, nextLastSpace + aCols);
            nextLastSpace = nextLastSpace + str.lastIndexOf(' ') + 2;
            lastSpace = str.lastIndexOf(' ');
            str = str.substring(0, lastSpace + 1);

            System.out.println("        \"" + str + "\"");

            try
            {
                str = aString.substring(nextLastSpace, nextLastSpace + aCols);
            }
            catch (StringIndexOutOfBoundsException ex)
            {
                str = aString.substring(nextLastSpace, aString.length());
            }

            nextLastSpace = nextLastSpace + str.lastIndexOf(' ') + 2;
            lastSpace = str.lastIndexOf(' ');

            try
            {
                str = str.substring(0, lastSpace + 1);
            }
            catch (StringIndexOutOfBoundsException ex)
            {
                lastSpace = str.length();
                str = str.substring(0, lastSpace);
            }

            System.out.println("        \"" + str + "\"");

            return "";
        }
*/

        public ExportAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);

            mFormatHashtable.put("light", SET_LIGHT);
            mFormatHashtable.put("size", SET_ROOM_SIZE);
            mFormatHashtable.put("determinate", SET_DETERMINATE);
            mFormatHashtable.put("short", SET_SHORT);
            mFormatHashtable.put("long", SET_LONG);
            mFormatHashtable.put("dayLong", SET_DAY_LONG);
            mFormatHashtable.put("nightLong", SET_NIGHT_LONG);
        }

        public String getFormat(String aProperty)
        {
            return (String)mFormatHashtable.get(aProperty);
        }

        public void setIndent(int aIndentWidth)
        {
            String indent = "";

            for (int i = 0; i < aIndentWidth; i++)
            {
                indent += " ";
            }

            mIndent = indent;
        }

        public void writeLine(FileWriter aWriter, String aLine)
            throws IOException
        {
            aWriter.write(mIndent);
            aWriter.write(aLine);
        }

        public void writeProperty(FileWriter aWriter, MapLocation aLocation,
            String aProperty) throws IOException, NoSuchRoomPropertyException
        {
            if (aLocation.isPropertyInherited(aProperty))
            {
                return;
            }

            String property = (String)aLocation.getProperty(aProperty,
                RoomProperties.INHERIT_DO_CHECK);

            if (property == null)
            {
                return;
            }

            property = MessageFormat.format(getFormat(aProperty),
                new Object[] { property });

            writeLine(aWriter, property);
        }

        public void writeExit(FileWriter aWriter, Exit aExit)
            throws IOException
        {
            String toFilename;
            MapLocation to = aExit.getTo();

            if (to.isUseAutoName())
            {
                toFilename = to.getAutoName();
            }
            else
            {
                toFilename = to.getFileName();
            }

            // Need to add support for up/down and non-standard exits.
            String direction = Direction.getDirectionName(aExit.getDirection());
            String type = aExit.getType();
            Object[] params = new Object[] { direction, toFilename, type };
            String exitString = MessageFormat.format(ADD_EXIT, params);

            writeLine(aWriter, exitString);
        }

        public void writeRoom(File aFile, MapLocation aLocation)
        {
            FileWriter writer = null;

            try
            {
                writer = new FileWriter(aFile);

                writeProperty(writer, aLocation, "size");
                writeProperty(writer, aLocation, "light");

                // check for "None", allow empty
                writeProperty(writer, aLocation, "determinate");

                writeProperty(writer, aLocation, "short");
                writeProperty(writer, aLocation, "long");
                writeProperty(writer, aLocation, "dayLong");
                writeProperty(writer, aLocation, "nightLong");

                // Need to sort these.
                Vector exitsVector = aLocation.getExits();
                Exit[] exits = new Exit[exitsVector.size()];
                exitsVector.toArray(exits);
                Arrays.sort(exits);

                for (int i = 0; i < exits.length; i++)
                {
                    writeExit(writer, exits[i]);
                }

                writer.close();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        }

        public void actionPerformed(ActionEvent aActionEvent)
        {
/*
            columnFormat("This is a path through Lancre Forest.  There are "
                + "lots of trees here.  It's really very, very nice.  Lovely "
                + "in fact.  Really very, very lovely.  I could go on all day "
                + "about how nice and lovely it is.  It really is.  Nice.  "
                + "Lovely.\n", 13, 80, 4);
*/

            ExportDialog exportDialog = ExportDialog.showExportDialog(mFrame);

            if (!exportDialog.isOkay())
            {
                return;
            }

            int exportType = exportDialog.getExportType();
            String directory = exportDialog.getDirectory();

            switch (exportType)
            {
                case ExportDialog.EXPORT_LPC :
                    SliderDialog sliderDialog = new SliderDialog(mFrame,
                        "Exporting LPC", "Exporting file: ", "Progress: ");

                    sliderDialog.setVisible(true);

                    // Maybe need a thread in here.

                    MapWindow mapWindow = getActiveMapWindow();
                    MapModel mapModel = getActiveMapView().getMapModel();
                    Vector inherits = mapModel.getInheritables();
                    Vector mapLocations = mapModel.getMapLocations();

                    int total = inherits.size() + mapLocations.size();

                    for (Enumeration e = mapLocations.elements(); e.hasMoreElements();)
                    {
                        MapLocation location = (MapLocation)e.nextElement();

                        String filename = location.getFileName();

                        File file = new File(directory, filename + ".c");

                        writeRoom(file, location);
                    }

                    for (Enumeration e = mapLocations.elements(); e.hasMoreElements();)
                    {
                        MapLocation location = (MapLocation)e.nextElement();

                        String filename;

                        if (location.isUseAutoName())
                        {
                            filename = location.getAutoName();
                        }
                        else
                        {
                            filename = location.getFileName();
                        }

                        File file = new File(directory, filename + ".c");

                        writeRoom(file, location);
                    }

                    //sliderDialog.setVisible(false);
                    break;
                }
            }

/*



                String light = location.getLight();
                String roomShort = location.getShort();
                String determinate = location.getDeterminate();
                int roomSize = location.getRoomSize();
                String roomLong = location.getLong();
                String dayLong = location.getDayLong();
                String nightLong = location.getNightLong();

                String str;

                if (!location.isLightInherited())
                {
                    if (light != null && light.compareTo("") != 0)
                    {
                        str = getLine(SET_LIGHT, light);
                        System.out.println(str);
                    }
                }

                if (!location.isShortInherited())
                {
                    if (roomShort != null && roomShort.compareTo("") != 0)
                    {
                        str = getLine(SET_SHORT, roomShort);
                        System.out.println(str);
                    }
                }

                if (!location.isDeterminateInherited())
                {
                    if (determinate != null
                        && determinate.toLowerCase().compareTo("none") != 0)
                    {
                        str = getLine(SET_DETERMINATE, determinate);
                        System.out.println(str);
                    }
                }


            }
*/

        public String getLine(String aFormat, String aParam)
        {
            String str = MessageFormat.format(aFormat, new Object[] { aParam });

            return str;
        }

    }


    class SaveAsAction extends AbstractAction
    {
        private static final String NAME = "Save As";
        private static final String SMALL_ICON = "SaveAs16.gif";
        private static final String LARGE_ICON = "SaveAs24.gif";
        private static final String SHORT_DESCRIPTION = "Save As";
        private static final String LONG_DESCRIPTION = "Save the current map as a specified filename";
        private static final int MNEMONIC_KEY = 'V';

        public SaveAsAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            MapWindow mapWindow = getActiveMapWindow();
            MapModel mapModel = getActiveMapView().getMapModel();

            String filename;

                int returnVal = mFileChooser.showSaveDialog(mFrame);

            if (returnVal == JFileChooser.APPROVE_OPTION)
            {
                File file = mFileChooser.getSelectedFile();
                filename = file.getAbsolutePath();
                mapModel.setFilename(filename);
                mapWindow.setTitle(filename);
            }
            else
            {
                return;
            }

            try
            {
                FileOutputStream out = new FileOutputStream(filename);
                ObjectOutputStream s = new ObjectOutputStream(out);
                s.writeObject(getActiveMapView().getMapModel());
                s.flush();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        }
    }

    class SaveAllAction extends AbstractAction
    {
        private static final String NAME = "Save All";
        private static final String SMALL_ICON = "SaveAll16.gif";
        private static final String LARGE_ICON = "SaveAll24.gif";
        private static final String SHORT_DESCRIPTION = "Save All";
        private static final String LONG_DESCRIPTION = "Save all open maps";
        private static final int MNEMONIC_KEY = 'A';

        public SaveAllAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class UndoAction extends AbstractAction
    {
        private static final String NAME = "Undo";
        private static final String SMALL_ICON = "Undo16.gif";
        private static final String LARGE_ICON = "Undo24.gif";
        private static final String SHORT_DESCRIPTION = "Undo";
        private static final String LONG_DESCRIPTION = "Undo";
        private static final int MNEMONIC_KEY = 'U';

        public UndoAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            getActiveMapView().mUndoManager.undo();
            getActiveMapView().repaint();
            refreshUndoRedo();
            setStatus((String)getValue(Action.LONG_DESCRIPTION));
        }
    }

    class RedoAction extends AbstractAction
    {
        private static final String NAME = "Redo";
        private static final String SMALL_ICON = "Redo16.gif";
        private static final String LARGE_ICON = "Redo24.gif";
        private static final String SHORT_DESCRIPTION = "Redo";
        private static final String LONG_DESCRIPTION = "Redo";
        private static final int MNEMONIC_KEY = 'R';

        public RedoAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            getActiveMapView().mUndoManager.redo();
            getActiveMapView().repaint();
            refreshUndoRedo();
            setStatus((String)getValue(Action.LONG_DESCRIPTION));
        }
    }

    class CutAction extends AbstractAction
    {
        private static final String NAME = "Cut";
        private static final String SMALL_ICON = "Cut16.gif";
        private static final String LARGE_ICON = "Cut24.gif";
        private static final String SHORT_DESCRIPTION = "Cut";
        private static final String LONG_DESCRIPTION = "Cut selection to clip board";
        private static final int MNEMONIC_KEY = 'T';

        public CutAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class CopyAction extends AbstractAction
    {
        private static final String NAME = "Copy";
        private static final String SMALL_ICON = "Copy16.gif";
        private static final String LARGE_ICON = "Copy24.gif";
        private static final String SHORT_DESCRIPTION = "Copy";
        private static final String LONG_DESCRIPTION = "Copy selection to clip board";
        private static final int MNEMONIC_KEY = 'C';

        public CopyAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class PasteAction extends AbstractAction
    {
        private static final String NAME = "Paste";
        private static final String SMALL_ICON = "Paste16.gif";
        private static final String LARGE_ICON = "Paste24.gif";
        private static final String SHORT_DESCRIPTION = "Paste";
        private static final String LONG_DESCRIPTION = "Paste from clip board";
        private static final int MNEMONIC_KEY = 'P';

        public PasteAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class ExitAction extends AbstractAction
    {
        private static final String NAME = "Exit";
        private static final String SMALL_ICON = "Blank16.gif";
        private static final String LARGE_ICON = "Blank24.gif";
        private static final String SHORT_DESCRIPTION = "Exit";
        private static final String LONG_DESCRIPTION = "Exit this application";
        private static final int MNEMONIC_KEY = 'X';

        public ExitAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {

        }
    }

    class ResizeAction extends AbstractAction
    {
        private static final String NAME = "Resize";
        private static final String SMALL_ICON = "Blank16.gif";
        private static final String LARGE_ICON = "Blank24.gif";
        private static final String SHORT_DESCRIPTION = "Resize";
        private static final String LONG_DESCRIPTION = "Resize the current map";
        private static final int MNEMONIC_KEY = 'X';

        public ResizeAction()
        {
            putValue(Action.NAME, NAME);
            putValue(Action.SMALL_ICON, Utils.getIcon(SMALL_ICON));
            putValue("largeIcon", Utils.getIcon(LARGE_ICON));
            putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION);
            putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION);
            putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY));
            putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY);
        }

        public void actionPerformed(ActionEvent e)
        {
            MapWindow mapWindow = getActiveMapWindow();
            MapView mapView = getActiveMapView();
            Dimension mapSize = MapSizeDialog.showNewRoomDialog(mFrame, mapView.getSize());

            if (mapSize != null)
            {
                mapView.setMapSize(mapSize);
            }

            mapWindow.repaint();
            mapWindow.revalidate();
        }
    }
}

class MapFileFilter implements FileFilter
{
    public boolean accept(File aFile)
    {
        String name = aFile.getName();

        int i = name.lastIndexOf('.');

        if (i > 0 &&  i < name.length() - 1)
        {
            String extension = name.substring(i + 1).toLowerCase();

            if (extension.equals("map"))
            {
                return true;
            }
        }
        return false;
    }
}