示例#1
0
  /**
   * Load in the {@link ucar.unidata.idv.ui.ParamInfo}-s defined in the xml from the given root
   * Element. Create a new JTable and add it into the GUI.
   *
   * @param root The xml root
   * @param i Which resource is this
   */
  private void addList(Element root, int i) {
    List infos;
    boolean isWritable = resources.isWritableResource(i);
    if (root != null) {
      infos = createParamInfoList(root);
    } else {
      if (!isWritable) {
        return;
      }
      infos = new ArrayList();
    }

    if (infos.size() == 0) {
      //            infos.add(new ParamInfo("", null, null, null, null));
    }
    ParamDefaultsTable table = new ParamDefaultsTable(infos, isWritable);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    String editableStr = "";
    if (!isWritable) {
      editableStr = " (" + Msg.msg("non-editable") + ") ";
    }
    JLabel label =
        new JLabel(
            "<html>" + Msg.msg("Path: ${param1}", resources.get(i) + editableStr) + "</html>");
    JPanel tablePanel = GuiUtils.topCenter(GuiUtils.inset(label, 4), new JScrollPane(table));

    table.label = resources.getShortName(i);
    tableTabbedPane.add(resources.getShortName(i), tablePanel);
    myTables.add(table);
  }
示例#2
0
 /**
  * Show a dialog containing a message.
  *
  * @param msg Message to display.
  * @param breakLines If {@code true}, long lines are split.
  */
 public static void userMessage(String msg, boolean breakLines) {
   msg = Msg.msg(msg);
   if (LogUtil.showGui()) {
     LogUtil.consoleMessage(msg);
     JComponent msgComponent = getMessageComponent(msg, breakLines);
     GuiUtils.addModalDialogComponent(msgComponent);
     JOptionPane.showMessageDialog(LogUtil.getCurrentWindow(), msgComponent);
     GuiUtils.removeModalDialogComponent(msgComponent);
   } else {
     System.err.println(msg);
   }
 }
示例#3
0
 /**
  * _more_
  *
  * @return _more_
  */
 private boolean windowOk() {
   getContents();
   if (contents == null) {
     return false;
   }
   if (shouldMakeDialog()) {
     if (dialog == null) {
       dialog = new JDialog((Frame) null, getWindowTitle(), false);
       LogUtil.registerWindow(dialog);
       GuiUtils.packDialog(dialog, contents);
       dialog.setLocation(100, 100);
       window = dialog;
     }
   } else {
     if (frame == null) {
       frame = new JFrame(getWindowTitle());
       if (menuBar != null) {
         GuiUtils.decorateFrame(frame, menuBar);
       }
       LogUtil.registerWindow(frame);
       frame.getContentPane().add(contents);
       frame.pack();
       Msg.translateTree(frame);
       frame.setLocation(100, 100);
       window = frame;
     }
   }
   if (window != null) {
     window.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             windowIsClosing();
           }
         });
   }
   return window != null;
 }
  /**
   * Create a new ProjectionManager.
   *
   * @param parent JFrame (application) or JApplet (applet)
   * @param projections list of initial projections
   * @param makeDialog true to make this a dialog
   * @param helpId help id if dialog
   * @param maps List of MapData
   */
  public ProjectionManager(
      RootPaneContainer parent, List projections, boolean makeDialog, String helpId, List maps) {

    this.helpId = helpId;
    this.maps = maps;
    this.parent = parent;

    // manage NewProjectionListeners
    lm =
        new ListenerManager(
            "java.beans.PropertyChangeListener",
            "java.beans.PropertyChangeEvent",
            "propertyChange");

    // here's where the map will be drawn: but cant be changed/edited
    npViewControl = new NPController();
    if (maps == null) {
      maps = getDefaultMaps(); // we use the system default
    }
    for (int mapIdx = 0; mapIdx < maps.size(); mapIdx++) {
      MapData mapData = (MapData) maps.get(mapIdx);
      if (mapData.getVisible()) {
        npViewControl.addMap(mapData.getSource(), mapData.getColor());
      }
    }
    mapViewPanel = npViewControl.getNavigatedPanel();
    mapViewPanel.setPreferredSize(new Dimension(250, 250));
    mapViewPanel.setToolTipText("Shows the default zoom of the current projection");
    mapViewPanel.setChangeable(false);

    if ((projections == null) || (projections.size() == 0)) {
      projections = makeDefaultProjections();
    }

    // the actual list is a JTable subclass
    projTable = new JTableProjection(this, projections);

    JComponent listContents = new JScrollPane(projTable);

    JComponent buttons =
        GuiUtils.hbox(
            GuiUtils.makeButton("Edit", this, "doEdit"),
            GuiUtils.makeButton("New", this, "doNew"),
            GuiUtils.makeButton("Export", this, "doExport"),
            GuiUtils.makeButton("Delete", this, "doDelete"));

    mapLabel = new JLabel(" ");
    JComponent leftPanel = GuiUtils.inset(GuiUtils.topCenter(mapLabel, mapViewPanel), 5);

    JComponent rightPanel = GuiUtils.topCenter(buttons, listContents);
    rightPanel = GuiUtils.inset(rightPanel, 5);
    contents = GuiUtils.inset(GuiUtils.hbox(leftPanel, rightPanel), 5);

    // default current and working projection
    if (null != (current = projTable.getSelected())) {
      setWorkingProjection(current);
      projTable.setCurrentProjection(current);
      mapLabel.setText(current.getName());
    }

    /* listen for new working Projections from projTable */
    projTable.addNewProjectionListener(
        new NewProjectionListener() {
          public void actionPerformed(NewProjectionEvent e) {
            if (e.getProjection() != null) {
              setWorkingProjection(e.getProjection());
            }
          }
        });

    eventsOK = true;

    // put it together in the viewDialog
    if (makeDialog) {
      Container buttPanel = GuiUtils.makeApplyOkHelpCancelButtons(this);
      contents = GuiUtils.centerBottom(contents, buttPanel);
      viewDialog =
          GuiUtils.createDialog(GuiUtils.getApplicationTitle() + "Projection Manager", false);
      viewDialog.getContentPane().add(contents);
      viewDialog.pack();
      ucar.unidata.util.Msg.translateTree(viewDialog);
      viewDialog.setLocation(100, 100);
    }
  }