예제 #1
0
  /**
   * Create me
   *
   * @param persistenceManager A reference to the persistence manager in case we need it
   * @param label The label to use in the dialog title
   */
  public LoadBundleDialog(IdvPersistenceManager persistenceManager, String label) {
    dialogTitle = label;
    label = null;
    this.persistenceManager = persistenceManager;
    msgLabel1 = new JLabel(" ");
    msgLabel1.setMinimumSize(new Dimension(250, 20));
    msgLabel1.setPreferredSize(new Dimension(250, 20));
    msgLabel2 = new JLabel(" ");
    msgLabel2.setMinimumSize(new Dimension(250, 20));
    msgLabel2.setPreferredSize(new Dimension(250, 20));

    progressBar = new RovingProgress();
    progressBar.start();
    progressBar.setBorder(BorderFactory.createLineBorder(Color.gray));
    JLabel waitLbl = new JLabel(IdvWindow.getWaitIcon());

    ActionListener buttonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            removeItems = true;
            // removeItems = ae.getActionCommand().equals(CMD_CANCELANDREMOVE);
            okToRun = false;
            setMessage("Cancelling load. Please wait...");
            Misc.runInABit(
                2000,
                new Runnable() {
                  public void run() {
                    dispose();
                  }
                });
          }
        };
    // String[] cmds = { CMD_CANCELANDREMOVE, GuiUtils.CMD_CANCEL };
    String[] cmds = {GuiUtils.CMD_CANCEL};
    //            String[] tts = { "Press to cancel and remove any loaded items",
    //                             "Press to cancel" };
    String[] tts = {"Press to cancel and remove loaded items"};
    JPanel buttonPanel = GuiUtils.makeButtons(buttonListener, cmds, cmds, tts, null);

    GuiUtils.tmpInsets = GuiUtils.INSETS_2;
    JComponent labelComp =
        GuiUtils.doLayout(
            new Component[] {
              new JLabel("Status:"),
              msgLabel1,
              waitLbl,
              GuiUtils.filler(),
              msgLabel2,
              GuiUtils.filler()
            },
            3,
            GuiUtils.WT_NYN,
            GuiUtils.WT_N);

    contents = GuiUtils.inset(labelComp, 5);
    if (label != null) {
      contents = GuiUtils.topCenter(GuiUtils.cLabel("Loading: " + label), contents);
    }
    //            contents = GuiUtils.vbox(contents,
    //                                     GuiUtils.inset(progressBar, 5),
    //                                     buttonPanel);
    contents = GuiUtils.vbox(contents, buttonPanel);
  }
예제 #2
0
 /** Overwrite dispose to stop the progress bar */
 public void dispose() {
   progressBar.stop();
   if (dialog != null) {
     dialog.dispose();
   }
 }