Changeset 14228


Ignore:
Timestamp:
2007-07-09T10:40:52+12:00 (17 years ago)
Author:
xiao
Message:

add a method to disable the menu bar items (file and edit) while the gli is openning a collection which was left open from last time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/Gatherer.java

    r14093 r14228  
    402402    // Create GUI Manager (last) or else suffer the death of a thousand NPE's
    403403    g_man = new GUIManager(size);
    404     }
    405 
    406 
    407     public void openGUI()
    408     {
    409     // Size and place the frame on the screen
    410     Rectangle bounds = Configuration.getBounds("general.bounds", true);
    411     if (bounds == null) {
    412         // Choose a sensible default value
    413         bounds = new Rectangle(0, 0, 640, 480);
    414     }
    415    
    416     // Ensure width and height are reasonable
    417     size = bounds.getSize();
    418     if (size.width < 640) {
    419         size.width = 640;
    420     }
    421     else if (size.width > Configuration.screen_size.width && Configuration.screen_size.width > 0) {
    422         size.width = Configuration.screen_size.width;
    423     }
    424     if (size.height < 480) {
    425         size.height = 480;
    426     }
    427     else if (size.height > Configuration.screen_size.height && Configuration.screen_size.height > 0) {
    428         size.height = Configuration.screen_size.height;
    429     }
    430 
    431     if (!g_man_built) {
    432 
    433         g_man.display();
    434 
    435         // Place the window in the desired location on the screen, if this is do-able (not under most linux window managers apparently. In fact you're lucky if they listen to any of your screen size requests).
    436         g_man.setLocation(bounds.x, bounds.y);
    437         g_man.setVisible(true);
    438 
    439         // After the window has been made visible, check that it is in the correct place
    440         // sometimes java places a window not in the correct place,
    441         // but with an offset. If so, we work out what the offset is
    442         // and change the desired location to take that into account
    443         Point location = g_man.getLocation();
    444         int x_offset = bounds.x - location.x;
    445         int y_offset = bounds.y - location.y;
    446         // If not, offset the window to move it into the correct location
    447         if (x_offset > 0 || y_offset > 0) {
    448         ///ystem.err.println("changing the location to "+(bounds.x + x_offset)+" "+ (bounds.y + y_offset));
    449         g_man.setLocation(bounds.x + x_offset, bounds.y + y_offset);
    450         }
    451 
    452         // The 'after-display' triggers several events which don't occur until after the visual components are actually available on screen. Examples of these would be the various html renderings, as they can't happen offscreen.
    453         g_man.afterDisplay();
    454         g_man_built = true;
    455     }
    456     else {
    457         g_man.setVisible(true);
    458     }
    459 
    460     // Get a list of the core Greenstone classifiers and plugins
    461     Classifiers.loadClassifiersList(null);
    462     Plugins.loadPluginsList(null);
    463 
    464     // If using a remote Greenstone we need to download the collection configurations now
    465     if (Gatherer.isGsdlRemote) {
    466         if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
    467         // !! Something went wrong downloading the collection configurations
    468         System.err.println("Error: Could not download collection configurations.");
    469         System.exit(0);
    470         }
    471     }
    472 
    473     // If there was a collection left open last time, reopen it
    474     c_man.openCollectionFromLastTime();
    475     }
    476 
     404
     405    }
     406
     407
     408    public void openGUI() {
     409      // Size and place the frame on the screen
     410      Rectangle bounds = Configuration.getBounds("general.bounds", true);
     411      if (bounds == null) {
     412        // Choose a sensible default value
     413        bounds = new Rectangle(0, 0, 640, 480);
     414      }
     415     
     416      // Ensure width and height are reasonable
     417      size = bounds.getSize();
     418      if (size.width < 640) {
     419        size.width = 640;
     420      } else if (size.width > Configuration.screen_size.width && Configuration.screen_size.width > 0) {
     421        size.width = Configuration.screen_size.width;
     422      }
     423      if (size.height < 480) {
     424        size.height = 480;
     425      } else if (size.height > Configuration.screen_size.height && Configuration.screen_size.height > 0) {
     426        size.height = Configuration.screen_size.height;
     427      }
     428     
     429      if (!g_man_built) {
     430       
     431        g_man.display();
     432       
     433        // Place the window in the desired location on the screen, if this is do-able (not under most linux window managers apparently. In fact you're lucky if they listen to any of your screen size requests).
     434        g_man.setLocation(bounds.x, bounds.y);
     435        g_man.setVisible(true);
     436       
     437        // After the window has been made visible, check that it is in the correct place
     438        // sometimes java places a window not in the correct place,
     439        // but with an offset. If so, we work out what the offset is
     440        // and change the desired location to take that into account
     441        Point location = g_man.getLocation();
     442        int x_offset = bounds.x - location.x;
     443        int y_offset = bounds.y - location.y;
     444        // If not, offset the window to move it into the correct location
     445        if (x_offset > 0 || y_offset > 0) {
     446          ///ystem.err.println("changing the location to "+(bounds.x + x_offset)+" "+ (bounds.y + y_offset));
     447          g_man.setLocation(bounds.x + x_offset, bounds.y + y_offset);
     448        }
     449       
     450        // The 'after-display' triggers several events which don't occur until after the visual components are actually available on screen. Examples of these would be the various html renderings, as they can't happen offscreen.
     451        g_man.afterDisplay();
     452        g_man_built = true;
     453      } else {
     454        g_man.setVisible(true);
     455      }
     456  if (open_collection_file_path != null) {
     457      //the menu bar stuff (file, edit) have to be disabled while a collection opened
     458      //from last session being opened in a different thread
     459      setMenuBarEnabled(false);
     460  }     
     461      // Get a list of the core Greenstone classifiers and plugins
     462      Classifiers.loadClassifiersList(null);
     463      Plugins.loadPluginsList(null);
     464     
     465      // If using a remote Greenstone we need to download the collection configurations now
     466      if (Gatherer.isGsdlRemote) {
     467        if (RemoteGreenstoneServer.downloadCollectionConfigurations().equals("")) {
     468          // !! Something went wrong downloading the collection configurations
     469          System.err.println("Error: Could not download collection configurations.");
     470          System.exit(0);
     471        }
     472      }
     473      // If there was a collection left open last time, reopen it
     474      c_man.openCollectionFromLastTime();
     475
     476    }
     477    public static void setMenuBarEnabled(boolean enabled) {
     478      g_man.menu_bar.file.setEnabled(enabled);
     479      g_man.menu_bar.edit.setEnabled(enabled);
     480    }
    477481
    478482    /** Exits the Gatherer after ensuring that things needing saving are saved.
     
    624628    {
    625629    if (g_man != null) {
     630
    626631        g_man.refresh(refresh_reason, c_man.ready());
    627632    }
Note: See TracChangeset for help on using the changeset viewer.