예제 #1
0
  /** Start the local server and connect to it. */
  public void goOffline() {
    RBNBController rbnb = RBNBController.getInstance();
    LocalServer server = LocalServer.getInstance();

    rbnb.disconnect(true);

    try {
      server.startServer();
    } catch (Exception e) {
      e.printStackTrace();
      MessagePopup.getInstance().showError("Failed to start local data server for offline usage.");
      return;
    }

    rbnb.setRBNBHostName(server.getHost());
    rbnb.setRBNBPortNumber(server.getPort());
    rbnb.connect();

    setSelected(true);
  }
예제 #2
0
  public void postState(int newState, int oldState) {
    if (newState == Player.STATE_DISCONNECTED) {
      frame.setTitle("RDV");

      controlAction.setEnabled(false);
      disconnectAction.setEnabled(false);
      saveAction.setEnabled(false);
      importAction.setEnabled(false);
      exportAction.setEnabled(false);

      controlPanel.setEnabled(false);
      markerSubmitPanel.setEnabled(false);

      ActionFactory.getInstance().getOfflineAction().setSelected(false);
    } else if (oldState == Player.STATE_DISCONNECTED) {
      frame.setTitle(rbnb.getServerName() + " - RDV");

      controlAction.setEnabled(true);
      disconnectAction.setEnabled(true);

      LocalServer localServer = LocalServer.getInstance();
      boolean offline =
          rbnb.getRBNBHostName().equals(localServer.getHost())
              && rbnb.getRBNBPortNumber() == localServer.getPort();
      saveAction.setEnabled(!offline);
      importAction.setEnabled(offline);
      exportAction.setEnabled(true);

      controlPanel.setEnabled(true);
      markerSubmitPanel.setEnabled(true);
    }

    if (newState == Player.STATE_LOADING
        || newState == Player.STATE_PLAYING
        || newState == Player.STATE_MONITORING) {
      startThrobber();
    } else if (oldState == Player.STATE_LOADING
        || oldState == Player.STATE_PLAYING
        || oldState == Player.STATE_MONITORING) {
      stopThrobber();
    }

    if (newState == Player.STATE_LOADING) {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      loadingDialog = new LoadingDialog(frame);

      new Thread() {
        public void run() {
          synchronized (loadingMonitor) {
            if (loadingDialog == null) {
              return;
            }

            try {
              loadingMonitor.wait(1000);
            } catch (InterruptedException e) {
            }

            if (loadingDialog != null) {
              loadingDialog.setVisible(true);
              loadingDialog.start();
            }
          }
        }
      }.start();
    } else if (oldState == Player.STATE_LOADING) {
      setCursor(null);

      synchronized (loadingMonitor) {
        loadingMonitor.notify();

        if (loadingDialog != null) {
          loadingDialog.close();
          loadingDialog = null;
        }
      }
    }
  }