private void initializeComponents() {
    backButton = new JButton(lang.translationForKey(GUIConstants.BUTTON_BACK));
    backButton.setActionCommand(GUIConstants.BUTTON_BACK);
    backButton.setVisible(false);

    nextButton = new JButton(lang.translationForKey(GUIConstants.BUTTON_NEXT));
    nextButton.setActionCommand(GUIConstants.BUTTON_NEXT);
    // if there is only one step set next button to finished
    if (numSteps == 1) {
      nextButton.setText(lang.translationForKey(GUIConstants.BUTTON_FINISH));
    }

    cancelButton = new JButton(lang.translationForKey(GUIConstants.BUTTON_CANCEL));
    cancelButton.setActionCommand(GUIConstants.BUTTON_CANCEL);
  }
  /**
   * Updates the buttons according to the position of the user consent.
   *
   * @param nextIdx Index of the step that is to be displayed.
   */
  public void selectIdx(int nextIdx) {
    // Don't show the back button on the first step
    if (nextIdx == 0) {
      backButton.setVisible(false);
    } else {
      backButton.setVisible(true);
    }

    // Change the forward button on the last step to "finished"
    if (nextIdx == (numSteps - 1)) {
      nextButton.setText(lang.translationForKey(GUIConstants.BUTTON_FINISH));
    } else {
      nextButton.setText(lang.translationForKey(GUIConstants.BUTTON_NEXT));
    }
  }
Exemple #3
0
  public void setup() {
    GUIDefaults.initialize();

    MessageDialog dialog = new MessageDialog();
    dialog.setHeadline(lang.translationForKey("client.startup.failed.headline"));

    try {
      tray = new AppTray(this);
      tray.beginSetup();

      // Set up client environment
      env = new ClientEnv();

      // Set up Management
      TinyManagement management = new TinyManagement(env);
      env.setManagement(management);

      // Set up the IFD
      ifd = new IFD();
      ifd.addProtocol(ECardConstants.Protocol.PACE, new PACEProtocolFactory());
      env.setIFD(ifd);

      // Set up the Dispatcher
      MessageDispatcher dispatcher = new MessageDispatcher(env);
      env.setDispatcher(dispatcher);
      ifd.setDispatcher(dispatcher);

      // Perform an EstablishContext to get a ContextHandle
      EstablishContext establishContext = new EstablishContext();
      EstablishContextResponse establishContextResponse = ifd.establishContext(establishContext);
      WSHelper.checkResult(establishContextResponse);
      contextHandle = ifd.establishContext(establishContext).getContextHandle();

      // Set up CardRecognition
      recognition = new CardRecognition(ifd, contextHandle);

      // Set up EventManager
      em = new EventManager(recognition, env, contextHandle);
      env.setEventManager(em);

      // Set up SALStateCallback
      cardStates = new CardStateMap();
      SALStateCallback salCallback = new SALStateCallback(recognition, cardStates);
      em.registerAllEvents(salCallback);

      // Set up SAL
      sal = new TinySAL(env, cardStates);
      env.setSAL(sal);

      // Set up GUI
      SwingUserConsent gui = new SwingUserConsent(new SwingDialogWrapper());
      sal.setGUI(gui);
      ifd.setGUI(gui);
      recognition.setGUI(gui);

      // Start up control interface
      try {
        binding = new HTTPBinding(HTTPBinding.DEFAULT_PORT);
        manager = new AddonManager(dispatcher, gui, cardStates, recognition, em);
        sal.setAddonManager(manager);
        binding.setAddonManager(manager);
        binding.start();
      } catch (BindException e) {
        dialog.setMessage(lang.translationForKey("client.startup.failed.portinuse"));
        throw e;
      }

      tray.endSetup(recognition, manager);

      // Initialize the EventManager
      em.registerAllEvents(tray.status());
      em.initialize();

    } catch (Exception e) {
      _logger.error(e.getMessage(), e);

      if (dialog.getMessage() == null || dialog.getMessage().isEmpty()) {
        // Add exception message if no custom message is set
        dialog.setMessage(e.getMessage());
      }

      // Show dialog to the user and shut down the client
      JOptionPane.showMessageDialog(null, dialog, "Open eCard App", JOptionPane.PLAIN_MESSAGE);
      teardown();
    }
  }