/** * 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(); }
/** 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()); } }
/** * Remove the server * * @param server server to remove */ public void removeServer(AddeServer server) { if (!MARK_AS_INACTIVE && !server.getIsLocal()) { return; } getIdv().getIdvChooserManager().removeAddeServer(server, MARK_AS_INACTIVE); updateServerList(); }
/** 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); } } }