/**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public XInfoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    // We initialize our layout
    layout = new GridBagLayout();
    gbConstraints = new GridBagConstraints();
    setLayout(layout);

    // We add the components

    infoLabel =
        LabelFactory.create(
            parent.langpack.getString("InfoPanel.info"),
            parent.icons.getImageIcon("edit"),
            JLabel.TRAILING);
    parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0);
    gbConstraints.insets = new Insets(5, 5, 5, 5);
    gbConstraints.fill = GridBagConstraints.BOTH;
    gbConstraints.anchor = GridBagConstraints.SOUTHWEST;
    layout.addLayoutComponent(infoLabel, gbConstraints);
    add(infoLabel);

    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scroller = new JScrollPane(textArea);
    parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9);
    gbConstraints.anchor = GridBagConstraints.CENTER;
    layout.addLayoutComponent(scroller, gbConstraints);
    add(scroller);
  }
Exemple #2
0
 /**
  * The constructor.
  *
  * @param parent The parent window.
  * @param idata The installation data.
  */
 public InfoPanel(InstallerFrame parent, InstallData idata) {
   super(parent, idata, new IzPanelLayout());
   // We load the text.
   loadInfo();
   // The info label.
   add(
       LabelFactory.create(
           parent.langpack.getString("InfoPanel.info"),
           parent.icons.getImageIcon("edit"),
           LEADING),
       NEXT_LINE);
   // The text area which shows the info.
   JTextArea textArea = new JTextArea(info);
   textArea.setCaretPosition(0);
   textArea.setEditable(false);
   JScrollPane scroller = new JScrollPane(textArea);
   add(scroller, NEXT_LINE);
   // At end of layouting we should call the completeLayout method also they do nothing.
   getLayoutHelper().completeLayout();
 }
  /** Called when the panel becomes active. */
  public void panelActivate() {
    Housekeeper.getInstance().registerForCleanup(this.runAfterAction);
    parent.lockNextButton();
    parent.lockPrevButton();
    parent.setQuitButtonText(parent.langpack.getString("FinishPanel.done"));
    parent.setQuitButtonIcon("done");

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.HORIZONTAL;

    if (idata.installSuccess) {

      // We set the information
      JLabel successLabel =
          LabelFactory.create(
              parent.langpack.getString("FinishPanel.success"),
              parent.icons.getImageIcon("check"),
              LEADING);
      constraints.weighty = 1.0;
      constraints.gridx = 0;
      constraints.gridy = 0;
      add(successLabel, constraints);

      final JCheckBox runAfterCheckbox =
          new JCheckBox(parent.langpack.getString("SimpleFinishPanel.headline.run_after"), true);
      runAfterCheckbox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              SimpleFinishPanel.this.runAfterAction.setRunAfter(runAfterCheckbox.isSelected());
            }
          });

      constraints.gridx = 0;
      constraints.gridy = 1;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;

      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.anchor = GridBagConstraints.NORTHWEST;

      add(runAfterCheckbox, constraints);

      if (idata.uninstallOutJar != null) {
        // We prepare a message for the uninstaller feature
        String path = translatePath("$INSTALL_PATH") + File.separator + "Uninstaller";

        JLabel infoLabel =
            LabelFactory.create(
                parent.langpack.getString("FinishPanel.uninst.info"),
                parent.icons.getImageIcon("preferences"),
                LEADING);
        constraints.weighty = 0.0;
        constraints.anchor = GridBagConstraints.SOUTH;
        constraints.gridx = 0;
        constraints.gridy = 1;
        add(infoLabel, constraints);

        JLabel pathLabel = LabelFactory.create(path, parent.icons.getImageIcon("empty"), LEADING);
        constraints.anchor = GridBagConstraints.NORTH;
        constraints.weighty = 0.0;
        constraints.gridx = 0;
        constraints.gridy = 2;
        add(pathLabel, constraints);
      }
    } else {
      add(
          LabelFactory.create(
              parent.langpack.getString("FinishPanel.fail"),
              parent.icons.getImageIcon("stop"),
              LEADING),
          constraints);
    }
    getLayoutHelper().completeLayout(); // Call, or call not?
    Log.getInstance().informUser();
  }
  /**
   * Creates a new HelloPanel object with the given layout manager. Valid layout manager are the
   * IzPanelLayout and the GridBagLayout. New panels should be use the IzPanelLaout. If lm is null,
   * no layout manager will be created or initialized.
   *
   * @param parent The parent IzPack installer frame.
   * @param idata The installer internal data.
   * @param layout layout manager to be used with this IzPanel
   */
  public HelloPanel(InstallerFrame parent, InstallData idata, LayoutManager2 layout) {
    // Layout handling. This panel was changed from a mixed layout handling
    // with GridBagLayout and BoxLayout to IzPanelLayout. It can be used as an
    // example how to use the IzPanelLayout. For this there are some comments
    // which are excrescent for a "normal" panel.
    // Set a IzPanelLayout as layout for this panel.
    // This have to be the first line during layout if IzPanelLayout will be used.
    super(parent, idata, layout);
    // We create and put the labels
    String str;
    str =
        parent.langpack.getString("HelloPanel.welcome1")
            + idata.info.getAppName()
            + " "
            + idata.info.getAppVersion()
            + parent.langpack.getString("HelloPanel.welcome2");
    JLabel welcomeLabel = LabelFactory.create(str, parent.icons.getImageIcon("host"), LEADING);
    // IzPanelLayout is a constraint orientated layout manager. But if no constraint is
    // given, a default will be used. It starts in the first line.
    // NEXT_LINE have to insert also in the first line!!
    add(welcomeLabel, NEXT_LINE);
    // Yes, there exist also a strut for the IzPanelLayout.
    // But the strut will be only used for one cell. A vertical strut will be use
    // NEXT_ROW, a horizontal NEXT_COLUMN. For more information see the java doc.
    // add(IzPanelLayout.createVerticalStrut(20));
    // But for a strut you have to define a fixed height. Alternative it is possible
    // to create a paragraph gap which is configurable.
    add(IzPanelLayout.createParagraphGap());

    ArrayList authors = idata.info.getAuthors();
    int size = authors.size();
    if (size > 0) {
      str = parent.langpack.getString("HelloPanel.authors");
      JLabel appAuthorsLabel =
          LabelFactory.create(str, parent.icons.getImageIcon("information"), LEADING);
      // If nothing will be sad to the IzPanelLayout the position of an add will be
      // determined in the default constraint. For labels it is CURRENT_ROW, NEXT_COLUMN.
      // But at this point we would place the label in the next row. It is possible
      // to create an IzPanelConstraint with this options, but it is also possible to
      // use simple the NEXT_LINE object as constraint. Attention!! Do not use
      // LayoutConstants.NEXT_ROW else LayoutConstants.NEXT_LINE because NEXT_ROW is an
      // int and with it an other add method will be used without any warning (there the
      // parameter will be used as position of the component in the panel, not the
      // layout manager.
      add(appAuthorsLabel, LayoutConstants.NEXT_LINE);

      JLabel label;
      for (int i = 0; i < size; i++) {
        Info.Author a = (Info.Author) authors.get(i);
        String email =
            (a.getEmail() != null && a.getEmail().length() > 0) ? (" <" + a.getEmail() + ">") : "";
        label =
            LabelFactory.create(
                " - " + a.getName() + email, parent.icons.getImageIcon("empty"), LEADING);
        add(label, NEXT_LINE);
      }
      add(IzPanelLayout.createParagraphGap());
    }

    if (idata.info.getAppURL() != null) {
      str = parent.langpack.getString("HelloPanel.url") + idata.info.getAppURL();
      JLabel appURLLabel = LabelFactory.create(str, parent.icons.getImageIcon("bookmark"), LEADING);
      add(appURLLabel, LayoutConstants.NEXT_LINE);
    }
    // At end of layouting we should call the completeLayout method also they do nothing.
    getLayoutHelper().completeLayout();
  }
  /**
   * The constructor.
   *
   * @param idata The installation data.
   * @param parent Description of the Parameter
   */
  public HTMLLicencePanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    // We initialize our layout
    layout = new GridBagLayout();
    gbConstraints = new GridBagConstraints();
    setLayout(layout);

    // We load the licence
    loadLicence();

    // We put our components

    infoLabel =
        LabelFactory.create(
            parent.langpack.getString("LicencePanel.info"),
            parent.icons.getImageIcon("history"),
            JLabel.TRAILING);
    parent.buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0);
    gbConstraints.insets = new Insets(5, 5, 5, 5);
    gbConstraints.fill = GridBagConstraints.NONE;
    gbConstraints.anchor = GridBagConstraints.WEST;
    layout.addLayoutComponent(infoLabel, gbConstraints);
    add(infoLabel);

    try {
      textArea = new JEditorPane();
      textArea.setEditable(false);
      textArea.addHyperlinkListener(this);
      JScrollPane scroller = new JScrollPane(textArea);
      textArea.setPage(loadLicence());
      parent.buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 1.0);
      gbConstraints.anchor = GridBagConstraints.CENTER;
      gbConstraints.fill = GridBagConstraints.BOTH;
      layout.addLayoutComponent(scroller, gbConstraints);
      add(scroller);
    } catch (Exception err) {
      err.printStackTrace();
    }

    ButtonGroup group = new ButtonGroup();

    yesRadio = new JRadioButton(parent.langpack.getString("LicencePanel.agree"), false);
    group.add(yesRadio);
    parent.buildConstraints(gbConstraints, 0, 2, 1, 1, 1.0, 0.0);
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.NONE;
    layout.addLayoutComponent(yesRadio, gbConstraints);
    add(yesRadio);
    yesRadio.addActionListener(this);

    noRadio = new JRadioButton(parent.langpack.getString("LicencePanel.notagree"), true);
    group.add(noRadio);
    parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 1.0, 0.0);
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.NONE;
    gbConstraints.insets = new Insets(0, 5, 5, 5);
    layout.addLayoutComponent(noRadio, gbConstraints);
    add(noRadio);
    noRadio.addActionListener(this);
    setInitialFocus(textArea);
  }