Ejemplo n.º 1
0
  /**
   * @param wizard The wizard
   * @param panelName The panel name to filter events from components
   * @param titleKey The key for the title section text
   * @param backgroundIcon The icon for the content section background
   */
  public AbstractWizardPanelView(
      AbstractWizard<M> wizard, String panelName, MessageKey titleKey, AwesomeIcon backgroundIcon) {

    Preconditions.checkNotNull(wizard, "'wizard' must be present");
    Preconditions.checkNotNull(titleKey, "'title' must be present");

    this.wizardModel = wizard.getWizardModel();
    this.panelName = panelName;

    // All wizard panel views can receive UI events
    CoreServices.uiEventBus.register(this);

    // All wizard screen panels are decorated with the same theme and
    // layout at creation so just need a simple panel to begin with
    wizardScreenPanel = Panels.newRoundedPanel();

    // All wizard panels require a backing model
    newPanelModel();

    // Create a new wizard panel and apply the wizard theme
    PanelDecorator.applyWizardTheme(wizardScreenPanel);

    // Add the title to the wizard
    JLabel title = Labels.newTitleLabel(titleKey);
    wizardScreenPanel.add(
        title,
        "span 4," + MultiBitUI.WIZARD_MAX_WIDTH_MIG + ",shrink,aligny top,align center,wrap");

    // Provide a basic empty content panel (allows lazy initialisation later)
    contentPanel = Panels.newDetailBackgroundPanel(backgroundIcon);

    // Add it to the wizard panel as a placeholder
    wizardScreenPanel.add(contentPanel, "span 4,grow,push,wrap");

    // Add the buttons to the wizard
    initialiseButtons(wizard);
  }
  @Override
  public void initialiseContent(JPanel contentPanel) {

    // Postpone the creation of the executor service to the last moment
    restoreWalletExecutorService = SafeExecutors.newSingleThreadExecutor("restore-wallet");

    contentPanel.setLayout(
        new MigLayout(
            Panels.migXYLayout(),
            "[][][]", // Column constraints
            "10[24]10[24]10[24]10[24]10[24]10" // Row constraints
            ));

    // Apply the theme
    contentPanel.setBackground(Themes.currentTheme.detailPanelBackground());

    // Initialise to failure
    backupLocationStatusLabel = Labels.newBackupLocationStatus(false);
    walletCreatedStatusLabel = Labels.newWalletCreatedStatus(false);
    caCertificateStatusLabel = Labels.newCACertsInstalledStatus(false);
    synchronizationStatusLabel = Labels.newSynchronizingStatus(false);

    // Start invisible (activates after CA certs completes)
    blocksLeftLabel = Labels.newValueLabel("0");
    blocksLeftStatusLabel = Labels.newBlocksLeft();

    // Make all labels invisible initially
    backupLocationStatusLabel.setVisible(false);
    walletCreatedStatusLabel.setVisible(false);
    caCertificateStatusLabel.setVisible(false);
    synchronizationStatusLabel.setVisible(false);
    blocksLeftLabel.setVisible(false);
    blocksLeftStatusLabel.setVisible(false);

    contentPanel.add(backupLocationStatusLabel, "wrap");
    contentPanel.add(walletCreatedStatusLabel, "wrap");
    contentPanel.add(caCertificateStatusLabel, "wrap");
    contentPanel.add(synchronizationStatusLabel, "wrap");

    contentPanel.add(blocksLeftStatusLabel, "");
    contentPanel.add(blocksLeftLabel, "wrap");
  }