private void refreshServerList() {
    if (FilterType.HOST.equals(serverStore.getFilter())) {
      String selectedHost = hostStore.getSelectedHost();

      List<Server> serverModel = Collections.EMPTY_LIST;
      if (selectedHost != null) {
        serverModel = serverStore.getServerForHost(hostStore.getSelectedHost());
      }

      getView().updateServerList(serverModel);
    } else if (FilterType.GROUP.equals(serverStore.getFilter())) {
      List<Server> serverModel = serverStore.getServerForGroup(serverStore.getSelectedGroup());
      getView().updateServerList(serverModel);
    }
  }
  @Override
  protected void onBind() {
    super.onBind();
    getView().setPresenter(this);

    HandlerRegistration previewReg = getEventBus().addHandler(PreviewEvent.TYPE, this);

    handlerRegistration =
        serverStore.addChangeHandler(
            new PropagatesChange.Handler() {
              @Override
              public void onChange(Action action) {

                if (!isVisible()) return; // don't process anything when not visible

                if (action instanceof SelectServer) {
                  // changing the server selection: update subsystems on server
                  if (hostStore.hasSelectedServer()) {
                    Scheduler.get()
                        .scheduleDeferred(
                            new Scheduler.ScheduledCommand() {
                              @Override
                              public void execute() {
                                loadSubsystems();
                              }
                            });
                  } else {
                    getView().setSubsystems(Collections.EMPTY_LIST);
                  }
                }

                // clear the view
                else if (action instanceof FilterType) {
                  getView().clearServerList();
                }

                // Refresh the server list when:
                // - changes to host/group filter refresh the server list
                // - group and host selection events
                // - server's are added or removed

                else if ((action instanceof FilterType)
                    || (action instanceof GroupSelection)
                    || (action instanceof HostSelection)
                    || (action instanceof RemoveServer)
                    || (action instanceof AddServer)
                    || (action instanceof CopyServer)
                    || (action instanceof RefreshServer)) {

                  refreshServerList();
                }
              }
            });
  }
 public ServerRef getSelectedServer() {
   return serverStore.getSelectServer();
 }
 public String getSelectedGroup() {
   return serverStore.getSelectedGroup();
 }
 public String getFilter() {
   return serverStore.getFilter();
 }