/** * 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(); }
/** * 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; }
/** 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); } } }
/** 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()); } }
/** 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; }