Ignore:
Timestamp:
07/18/08 14:28:41 (16 years ago)
Author:
ra33
Message:

Added anchorRight and anchorBottom properties to items...
Fixed bugs with @i item display...
Can now inject properties into enclosed items at the same time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Browser.java

    r145 r147  
    5050
    5151        public static Browser _theBrowser = null;
    52        
     52
    5353        // A flag which is set once the application is exiting.
    5454        private boolean _isExiting = false;
     
    6060         */
    6161        public static void main(String[] args) {
    62                
     62
    6363                // Prepare all expeditee and swing data on the AWT event thread.
    6464                SwingUtilities.invokeLater(new Runnable() {
    6565                        public void run() {
    66                                 //MessageBay.supressMessages(true);
    67                                
    68                                 //MessageBay.supressMessages(false);
    69                                
     66                                // MessageBay.supressMessages(true);
     67
     68                                // MessageBay.supressMessages(false);
     69
    7070                                _theBrowser = new Browser();
    7171                                _theBrowser.requestFocus();
    72                                 FrameMouseActions.MouseX = MouseInfo.getPointerInfo().getLocation().x - _theBrowser.getOrigin().x;
    73                                 FrameMouseActions.MouseY = MouseInfo.getPointerInfo().getLocation().y - _theBrowser.getOrigin().y;
     72                                FrameMouseActions.MouseX = MouseInfo.getPointerInfo()
     73                                                .getLocation().x
     74                                                - _theBrowser.getOrigin().x;
     75                                FrameMouseActions.MouseY = MouseInfo.getPointerInfo()
     76                                                .getLocation().y
     77                                                - _theBrowser.getOrigin().y;
    7478                        }
    7579                });
    7680
    7781        }
    78        
     82
    7983        public Point getOrigin() {
    8084                return getContentPane().getLocationOnScreen();
    8185        }
    82        
    83         /**
    84          * @return 
    85          *
    86          *              True if the application is about to exit. False if not. Not that this is only set once the
    87          *              window is in its closed state (not closing) or if the application has explicity being requested
    88          *              to exit.
     86
     87        /**
     88         * @return
     89         *
     90         * True if the application is about to exit. False if not. Not that this is
     91         * only set once the window is in its closed state (not closing) or if the
     92         * application has explicity being requested to exit.
    8993         *
    9094         * @see Browser#exit()
     
    131135                        }
    132136                }
    133                
     137
    134138                FrameUtils.ParseProfile(profile);
    135                
    136                 // Now reset the size of the windows to the size specified in the users
    137                 // profile
    138                 setSizes(new Dimension(UserSettings.InitialWidth,
    139                                 UserSettings.InitialHeight));
    140139
    141140                // set the layout to absolute layout for widgets
     
    151150                addComponentListener(this);
    152151                pack();
    153                
    154 
    155                 // See java bug ID 4016934. They say that window closed events are called once the
     152
     153                // Reset windows to user specified size
     154                // Must be done after initialising the content pane above!
     155                setSizes(new Dimension(UserSettings.InitialWidth,
     156                                UserSettings.InitialHeight));
     157
     158                // See java bug ID 4016934. They say that window closed events are
     159                // called once the
    156160                // jframe is disposed.
    157                 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
    158                
     161                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     162
    159163                // Expeditee handles its own repainting of AWT/Swing components
    160164                RepaintManager.setCurrentManager(ExpediteeRepaintManager.getInstance());
    161                
     165
    162166                // Listen for save status to display during and after runtime
    163167                EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
    164                
     168
    165169                // Set the drag and drop handler
    166170                setTransferHandler(FrameDNDTransferHandler.getInstance());
    167        
     171
    168172                try {
    169173                        Collection<String> warningMessages = Actions.Init();
    170174
    171175                        DisplayIO.Init(this);
    172                         // Set visible must be just after DisplayIO.Init for the message box to
     176                        // Set visible must be just after DisplayIO.Init for the message box
     177                        // to
    173178                        // be the right size
    174179                        setVisible(true);
     
    178183                        // required to accept TAB key
    179184                        setFocusTraversalKeysEnabled(false);
    180                        
    181                         //Must be loaded after setupGraphics if images are on the frame
    182                         //Turn off XRay mode and load the first frame
     185
     186                        // Must be loaded after setupGraphics if images are on the frame
     187                        // Turn off XRay mode and load the first frame
    183188                        FrameUtils.loadFirstFrame(profile);
    184189                        FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
    185190                        DisplayIO.UpdateTitle();
    186                        
    187                         //I think this can be moved back up to the top of the Go method now...
    188                         //It used to crash the program trying to print error messages up the top
     191
     192                        // I think this can be moved back up to the top of the Go method
     193                        // now...
     194                        // It used to crash the program trying to print error messages up
     195                        // the top
    189196                        for (String message : warningMessages)
    190197                                MessageBay.warningMessage(message);
     
    193200                        this.getContentPane().addKeyListener(keyboardListner);
    194201                        this.addKeyListener(keyboardListner);
    195                        
     202
    196203                        FrameKeyboardActions.Refresh();
    197                         //setVisible(true);
     204                        // setVisible(true);
    198205                } catch (Exception e) {
    199206                        e.printStackTrace();
     
    292299
    293300        public void saveCompleted(SaveStateChangedEvent event) {
    294                 //if (isExisting()) {
    295                
    296                 //} else {
    297                         MessageBay.displayMessage("Save finished!", Color.BLUE);
    298                 //}
     301                // if (isExisting()) {
     302
     303                // } else {
     304                MessageBay.displayMessage("Save finished!", Color.BLUE);
     305                // }
    299306        }
    300307
    301308        public void saveStarted(SaveStateChangedEvent event) {
    302                 //if (isExisting()) {
    303                        
    304                 //} else {
    305                         String name = event.getEntity().getSaveName();
    306                         if (name == null) name = "data";
    307                         MessageBay.displayMessage("Saving " + name + "...", Color.BLUE);
    308                 //}
    309         }
    310        
    311         /**
    312          * Closes the browser and ends the application.
    313          * Performs saving operations - halting until saves have completed.
    314          * Feedback is given to the user while the application is exiting.
    315          * Must call on the swing thread.
     309                // if (isExisting()) {
     310
     311                // } else {
     312                String name = event.getEntity().getSaveName();
     313                if (name == null)
     314                        name = "data";
     315                MessageBay.displayMessage("Saving " + name + "...", Color.BLUE);
     316                // }
     317        }
     318
     319        /**
     320         * Closes the browser and ends the application. Performs saving operations -
     321         * halting until saves have completed. Feedback is given to the user while
     322         * the application is exiting. Must call on the swing thread.
    316323         */
    317324        public void exit() {
    318                
     325
    319326                // Set exiting flag
    320327                _isExiting = true;
    321                
     328
    322329                MessageBay.displayMessage("System exiting...");
    323                
     330
    324331                /**
    325332                 * TODO: Prompt the user etc.
    326333                 */
    327                
    328                 // TODO: Should we should a popup with a progress bar for user feedback? this would be nice and easy to do.
    329 
     334
     335                // TODO: Should we should a popup with a progress bar for user feedback?
     336                // this would be nice and easy to do.
    330337                // Exit on a dedicated thread so that feedback can be obtained
    331338                new Exiter().start(); // this will exit the application
    332339        }
    333        
    334         /**
    335          * The system must exit on a different thread other than the swing thread
    336          * so that the save threads can fire save-feedback to the swing thread and thus
     340
     341        /**
     342         * The system must exit on a different thread other than the swing thread so
     343         * that the save threads can fire save-feedback to the swing thread and thus
    337344         * provide user feedback on asynchronous save operations.
    338345         *
    339346         * @author Brook Novak
    340          *
     347         * 
    341348         */
    342349        private class Exiter extends Thread {
     
    344351                @Override
    345352                public void run() {
    346                        
     353
    347354                        // The final save point for saveable entities
    348355                        EntitySaveManager.getInstance().saveAll();
     
    353360                        }
    354361
    355                         // The final phase must save on the wing thread since dealing with the expeditee
     362                        // The final phase must save on the wing thread since dealing with
     363                        // the expeditee
    356364                        // data model
    357365                        SwingUtilities.invokeLater(new Runnable() {
    358366                                public void run() {
    359367
    360                                         //Stop any agents or simple programs
     368                                        // Stop any agents or simple programs
    361369                                        Simple.stop();
    362370                                        Actions.stopAgent();
    363                                         //Wait for them to stop
    364                                         try{
    365                                                 MessageBay.displayMessage("Stopping Simple programs..."); // TODO: Only stop if need to...
    366                                                 while(Simple.isProgramRunning()){
    367                                                         Thread.sleep(100); // Brook: What purpose does this serve?
     371                                        // Wait for them to stop
     372                                        try {
     373                                                MessageBay
     374                                                                .displayMessage("Stopping Simple programs..."); // TODO:
     375                                                                                                                                                                // Only
     376                                                                                                                                                                // stop
     377                                                                                                                                                                // if
     378                                                                                                                                                                // need
     379                                                                                                                                                                // to...
     380                                                while (Simple.isProgramRunning()) {
     381                                                        Thread.sleep(100); // Brook: What purpose does this
     382                                                                                                // serve?
    368383                                                }
    369                                                 MessageBay.displayMessage("Stopping Agents..."); // TODO: Only stop if need to...
    370                                                 while(Actions.isAgentRunning()){
    371                                                         Thread.sleep(100); // Brook: What purpose does this serve?
     384                                                MessageBay.displayMessage("Stopping Agents..."); // TODO:
     385                                                                                                                                                        // Only
     386                                                                                                                                                        // stop
     387                                                                                                                                                        // if
     388                                                                                                                                                        // need
     389                                                                                                                                                        // to...
     390                                                while (Actions.isAgentRunning()) {
     391                                                        Thread.sleep(100); // Brook: What purpose does this
     392                                                                                                // serve?
    372393                                                }
    373                                         }catch(Exception e){
    374                                                
     394                                        } catch (Exception e) {
     395
    375396                                        }
    376                                        
    377                                         MessageBay.displayMessage("Saving current frame..."); 
     397
     398                                        MessageBay.displayMessage("Saving current frame...");
    378399                                        FrameIO.SaveFrame(DisplayIO.getCurrentFrame());
    379400
    380                                         while (FrameIO.DeleteFrameset("messages"));
    381 
    382                                         MessageBay.displayMessage("Saving stats...");
     401                                        while (FrameIO.DeleteFrameset("messages"))
     402                                                ;
     403
     404                                        MessageBay.displayMessage("Saving stats...");
    383405                                        StatsLogger.WriteStatsFile();
    384                                        
    385                                         MessageBay.displayMessage("System exited"); 
     406
     407                                        MessageBay.displayMessage("System exited");
    386408                                        System.exit(0);
    387                                        
     409
    388410                                }
    389411                        });
    390                        
     412
    391413                }
    392                
    393         }
    394        
    395 
    396        
     414
     415        }
     416
    397417}
Note: See TracChangeset for help on using the changeset viewer.