示例#1
0
  /**
   * return the String id of the chosen server name
   *
   * @return the server name
   */
  public String getServer() {
    Object selected = serverSelector.getSelectedItem();
    if (selected == null) {
      return null;
    }
    AddeServer server;
    if (selected instanceof AddeServer) {
      server = (AddeServer) selected;
      return server.getName();
    }
    String serverName = selected.toString();
    server = getIdv().getIdvChooserManager().addAddeServer(serverName);
    addeServers = getIdv().getIdvChooserManager().getAddeServers(getGroupType());

    Object selectedGroup = groupSelector.getSelectedItem();
    AddeServer.Group group = null;
    if (selectedGroup != null) {
      group =
          getIdv()
              .getIdvChooserManager()
              .addAddeServerGroup(server, selectedGroup.toString(), getGroupType());
    }

    boolean old = ignoreStateChangedEvents;
    ignoreStateChangedEvents = true;
    GuiUtils.setListData(serverSelector, addeServers);
    serverSelector.setSelectedItem(server);
    setGroups();
    if (group != null) {
      groupSelector.setSelectedItem(group);
    }
    ignoreStateChangedEvents = old;
    return server.getName();
  }
示例#2
0
  /**
   * Get the image group from the gui.
   *
   * @return The iamge group.
   */
  protected String getGroup() {
    Object selected = groupSelector.getSelectedItem();
    if (selected == null) {
      return null;
    }
    if (selected instanceof AddeServer.Group) {
      AddeServer.Group group = (AddeServer.Group) selected;
      return group.getName();
    }

    String groupName = selected.toString().trim();
    if ((groupName.length() > 0)) {
      // Force the get in case they typed a server name
      getServer();
      AddeServer server = getAddeServer();
      if (server != null) {
        AddeServer.Group group =
            getIdv().getIdvChooserManager().addAddeServerGroup(server, groupName, getGroupType());
        if (!group.getActive()) {
          getIdv().getIdvChooserManager().activateAddeServerGroup(server, group);
        }
        // Now put the list of groups back in to the selector
        setGroups();
        groupSelector.setSelectedItem(group);
      }
    }

    return groupName;
  }
示例#3
0
 protected JComboBox createCombo(String strText, JPanel pnlDisplay) {
   JComboBox cmbMode = new JComboBox(m_aStrMode);
   if (!strText.equalsIgnoreCase(m_aStrMode[0]) && !strText.equalsIgnoreCase(m_aStrMode[1]))
     strText = m_aStrMode[0];
   cmbMode.setSelectedItem(strText);
   pnlDisplay.add(cmbMode);
   return cmbMode;
 }
示例#4
0
 /** Load any saved server state */
 private void loadServerState() {
   if (addeServers == null) {
     return;
   }
   String id = getId();
   String[] serverState = (String[]) getIdv().getStore().get(PREF_SERVERSTATE + "." + id);
   if (serverState == null) {
     return;
   }
   AddeServer server = AddeServer.findServer(addeServers, serverState[0]);
   if (server == null) {
     return;
   }
   serverSelector.setSelectedItem(server);
   setGroups();
   if (serverState[1] != null) {
     AddeServer.Group group = (AddeServer.Group) server.findGroup(serverState[1]);
     if (group != null) {
       groupSelector.setSelectedItem(group);
     }
   }
 }
示例#5
0
  /** Set the group list */
  protected void setGroups() {
    AddeServer server = getAddeServer();
    if (server != null) {
      Object selected = groupSelector.getSelectedItem();
      List groups = server.getGroupsWithType(getGroupType());
      GuiUtils.setListData(groupSelector, groups);
      if ((selected != null) && groups.contains(selected)) {
        groupSelector.setSelectedItem(selected);
      }

    } else {
      GuiUtils.setListData(groupSelector, new Vector());
    }
  }
    /**
     * Set the fields from the ProjectionClass
     *
     * @param projClass projection class to use
     */
    private void setFieldsWithClassParams(ProjectionClass projClass) {

      // set the projection in the JComboBox
      String want = projClass.toString();
      for (int i = 0; i < projClassCB.getItemCount(); i++) {
        ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i);
        if (pc.toString().equals(want)) {
          projClassCB.setSelectedItem((Object) pc);
          break;
        }
      }

      // set the parameter fields
      paramPanel.removeAll();
      paramPanel.setVisible(0 < projClass.paramList.size());

      List widgets = new ArrayList();
      for (int i = 0; i < projClass.paramList.size(); i++) {
        ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i);
        // construct the label
        String name = pp.name;
        String text = "";
        // Create a decent looking label
        for (int cIdx = 0; cIdx < name.length(); cIdx++) {
          char c = name.charAt(cIdx);
          if (cIdx == 0) {
            c = Character.toUpperCase(c);
          } else {
            if (Character.isUpperCase(c)) {
              text += " ";
              c = Character.toLowerCase(c);
            }
          }
          text += c;
        }
        widgets.add(GuiUtils.rLabel(text + ": "));
        // text input field
        JTextField tf = new JTextField();
        pp.setTextField(tf);
        tf.setColumns(12);
        widgets.add(tf);
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N);

      paramPanel.add("North", widgetPanel);
      paramPanel.add("Center", GuiUtils.filler());
    }
示例#7
0
 /** Reload the list of servers if they have changed */
 public void updateServerList() {
   boolean old = ignoreStateChangedEvents;
   ignoreStateChangedEvents = true;
   List newList = getIdv().getIdvChooserManager().getAddeServers(getGroupType());
   if (Misc.equals(newList, this.addeServers)) {
     ignoreStateChangedEvents = old;
     return;
   }
   this.addeServers = getIdv().getIdvChooserManager().getAddeServers(getGroupType());
   Object selected = serverSelector.getSelectedItem();
   GuiUtils.setListData(serverSelector, addeServers);
   if ((selected != null) && addeServers.contains(selected)) {
     serverSelector.setSelectedItem(selected);
   }
   setGroups();
   ignoreStateChangedEvents = old;
 }
示例#8
0
  public void keyReleased(KeyEvent e) {
    char ch = e.getKeyChar();
    if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return;
    int pos = m_editor.getCaretPosition();
    String str = m_editor.getText();
    if (str.length() == 0) return;

    for (int k = 0; k < m_comboBox.getItemCount(); k++) {
      String item = m_comboBox.getItemAt(k).toString();
      if (item.startsWith(str)) {
        m_editor.setText(item);
        m_editor.setCaretPosition(item.length());
        m_editor.moveCaretPosition(pos);
        m_comboBox.setSelectedItem(item);
        break;
      }
    }
  }