コード例 #1
0
ファイル: PlotModelComponent.java プロジェクト: ethanrd/IDV
  /**
   * Make the gui widget for setting the station model
   *
   * @return the widget
   */
  private JComponent makeStationModelWidget() {
    JButton editButton = GuiUtils.getImageButton("/ucar/unidata/idv/images/edit.gif", getClass());
    editButton.setToolTipText("Show the plot model editor");
    editButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {}
        });

    label = new JLabel(" ");
    changeButton = GuiUtils.getImageButton("/auxdata/ui/icons/DownDown.gif", getClass());
    changeButton.setToolTipText("Click to change plot model");
    changeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            StationModelManager smm = idv.getStationModelManager();
            ObjectListener listener =
                new ObjectListener(null) {
                  public void actionPerformed(ActionEvent ae) {
                    Misc.run(
                        new Runnable() {
                          public void run() {
                            idv.showWaitCursor();
                            try {
                              plotModel = (StationModel) theObject;
                              if (plotModel != null) {
                                label.setText(plotModel.getDisplayName());
                              }
                              method.invoke(plotModelListener, new Object[] {plotModel});
                            } catch (Exception exc) {
                              idv.logException("Changing plot model", exc);
                            }
                            idv.showNormalCursor();
                          }
                        });
                  }
                };

            List items =
                StationModelCanvas.makeStationModelMenuItems(smm.getStationModels(), listener, smm);
            items.add(0, GuiUtils.MENU_SEPARATOR);
            if (addNone) {
              items.add(0, GuiUtils.makeMenuItem("None", PlotModelComponent.this, "setNone"));
            }
            items.add(0, GuiUtils.makeMenuItem("Edit", PlotModelComponent.this, "editPlotModel"));
            JPopupMenu popup = GuiUtils.makePopupMenu(items);
            popup.show(
                changeButton, changeButton.getSize().width / 2, changeButton.getSize().height);
          }
        });

    return GuiUtils.centerRight(label, GuiUtils.inset(changeButton, new Insets(0, 4, 0, 0)));
  }
コード例 #2
0
ファイル: AddeChooser.java プロジェクト: suvarchal/IDV
  /**
   * Create the 'Connect' button.
   *
   * @return The connect button.
   */
  protected JComponent getConnectButton() {
    JButton connectBtn = new JButton("Connect");
    connectBtn.setActionCommand(CMD_CONNECT);
    connectBtn.addActionListener(this);
    JComponent buttonComp = connectBtn;
    registerStatusComp("connect", buttonComp);
    if (canDoCancel()) {
      cancelButton = GuiUtils.getImageButton("/auxdata/ui/icons/Exit16.gif", getClass());
      cancelButton.setEnabled(false);
      cancelButton.setActionCommand(GuiUtils.CMD_CANCEL);
      cancelButton.addActionListener(this);
      buttonComp = GuiUtils.hbox(buttonComp, cancelButton);
    }

    return buttonComp;
    //        return connectBtn;
  }
コード例 #3
0
ファイル: XmlChooser.java プロジェクト: nbearson/IDV
  /**
   * Create and return the Gui contents.
   *
   * @return The gui contents.
   */
  protected JComponent doMakeContents() {
    //        dataSelector = new DataSelector(getIdv(), new Dimension(400, 200),
    //                                        true);

    // Get the list of catalogs but remove the old catalog.xml entry
    urlListHandler = getPreferenceList(PREF_CATALOGLIST);
    final XmlChooser xmlChooser = this;
    ActionListener catListListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (!okToDoUrlListEvents) {
              return;
            }
            xmlChooser.actionPerformed(ae);
          }
        };
    urlBox = urlListHandler.createComboBox(GuiUtils.CMD_UPDATE, catListListener, true);

    GuiUtils.setPreferredWidth(urlBox, 200);

    // top panel
    JButton browseButton = new JButton("Select File...");
    browseButton.setToolTipText("Choose a catalog from disk");
    browseButton.setActionCommand(CMD_BROWSE);
    browseButton.addActionListener(this);

    GuiUtils.setHFill();
    JPanel catListPanel =
        GuiUtils.doLayout(new Component[] {urlBox}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);

    backBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Left16.gif", getClass()));
    backBtn.setToolTipText("View previous selection");
    GuiUtils.makeMouseOverBorder(backBtn);
    backBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goBack();
          }
        });

    fwdBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Right16.gif", getClass()));
    GuiUtils.makeMouseOverBorder(fwdBtn);
    fwdBtn.setToolTipText("View next selection");
    fwdBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goForward();
          }
        });

    checkButtons();
    JComponent bottomButtons = getDefaultButtons();
    handlerHolder = new JPanel();
    handlerHolder.setLayout(new BorderLayout());
    //        JPanel tmp = new JPanel();
    //        tmp.setPreferredSize(new Dimension(200,500));
    //        handlerHolder.add(tmp, BorderLayout.CENTER);

    if (getIdv().getArgsManager().getInitCatalogs().size() > 0) {
      initialUrlPath = (String) getIdv().getArgsManager().getInitCatalogs().get(0);
      urlBox.setSelectedItem(initialUrlPath);
    } else {
      if ((initialUrlPath != null) && (initialUrlPath.length() > 0)) {
        makeUiFromPath(initialUrlPath);
      } else {
        makeBlankTree();
      }
    }
    JPanel navButtons = GuiUtils.hbox(backBtn, fwdBtn);

    GuiUtils.tmpInsets = GRID_INSETS;
    JPanel catPanel =
        GuiUtils.doLayout(
            new Component[] {new JLabel("Catalogs:"), catListPanel, browseButton},
            3,
            GuiUtils.WT_NYN,
            GuiUtils.WT_N);
    JPanel topPanel = GuiUtils.leftCenter(navButtons, catPanel);
    myContents = GuiUtils.topCenterBottom(topPanel, handlerHolder, bottomButtons);
    //        myContents = GuiUtils.topCenter(getStatusComponent(), myContents);
    return myContents;
  }