Example #1
0
  /**
   * Make the IdvWindow. Add event handlers for adding new data sources and closing the window.
   *
   * @return The window to put the gui in
   */
  public IdvWindow doMakeFrame() {
    if (frame == null) {
      JButton newBtn = new JButton("Add New Data Source");
      newBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              idv.showChooser();
            }
          });
      JButton closeBtn = new JButton("Close");
      closeBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doClose();
            }
          });

      JComponent extra = getButtons();
      JComponent buttons;
      if (extra != null) {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        extra, closeBtn),
                    4,
                    4));
      } else {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        closeBtn),
                    4,
                    4));
      }

      JPanel contents = GuiUtils.centerBottom(getContents(), buttons);
      frame = new IdvWindow(getName(), idv, false);
      frame.getContentPane().add(contents);
      frame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              doClose();
            }
          });
      frame.pack();
      frame.show();
    }
    return frame;
  }
Example #2
0
 /**
  * Remove all references to anything we may have. We do this because (stupid) Swing seems to keep
  * around lots of different references to thei component and/or it's frame. So when we do a
  * window.dispose () this DataSourceHolder does not get gc'ed.
  */
 public void dispose() {
   if (frame != null) {
     frame.dispose();
   }
   formulaDataSource = null;
   frame = null;
   dataSources = null;
 }
Example #3
0
 /** Show the window if it is non-null */
 public void show() {
   if (frame != null) {
     frame.show();
   }
   Component contents = getContents();
   if (contents != null) {
     GuiUtils.showComponentInTabs(contents, true);
   }
 }
Example #4
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);
  }