Exemplo n.º 1
0
 /** Special start method for IzPanelLayout. Called from <code>startLayout</code>. */
 private void startIzPanelLayout() {
   IzPanelLayout.setAnchor(getAnchor());
   IzPanelLayout.setXStretchType(getXStretchType());
   IzPanelLayout.setYStretchType(getYStretchType());
   IzPanelLayout.setFullLineStretch(getFullLineStretch());
   IzPanelLayout.setFullColumnStretch(getFullColumnStretch());
   getXGap(LABEL_GAP); // This call triggers resolving external setting if not already done.
   getYGap(LABEL_GAP); // This call triggers resolving external setting if not already done.
   parent.setLayout(izPanelLayout);
   // parent.add(IzPanelLayout.createGap(TOP_GAP, VERTICAL));
 }
Exemplo n.º 2
0
 /**
  * Returns the gap which should be used between the given gui objects for the y direction. The
  * value will be configurable by guiprefs modifiers. Valid values are all entries in the static
  * String array Y_GAP_NAME_LOOK_UP of this class. There are constant ints for the indexes of this
  * array.
  *
  * @param gapId index in array GAP_NAME_LOOK_UP for the needed gap
  * @return the gap depend on the xml-configurable guiprefs modifier
  */
 public int getYGap(int gapId) {
   gapId = IzPanelLayout.verifyGapId(gapId);
   if (IzPanelLayout.getDefaultYGap(GAP_LOAD_MARKER) >= 0) {
     return (IzPanelLayout.getDefaultYGap(gapId));
   }
   if (!(installData instanceof GUIInstallData)) {
     return (IzPanelLayout.getDefaultYGap(gapId));
   }
   String var;
   GUIInstallData id = (GUIInstallData) installData;
   int commonDefault = -1;
   if (id.guiPrefs.modifier.containsKey(ALL_Y_GAP)) {
     try {
       commonDefault = Integer.parseInt(id.guiPrefs.modifier.get(ALL_Y_GAP));
     } catch (NumberFormatException nfe) {
       // Do nothing else use the default value.
       // Need to set it again at this position??
     }
   }
   for (int i = 0; i < Y_GAP_NAME_LOOK_UP.length; ++i) {
     int currentDefault = 0;
     if (commonDefault >= 0) {
       currentDefault = commonDefault;
     } else {
       var = id.guiPrefs.modifier.get(Y_GAP_NAME_LOOK_UP[i]);
       if (var != null) {
         try {
           currentDefault = Integer.parseInt(var);
         } catch (NumberFormatException nfe) {
           // Do nothing else use the default value.
           // Need to set it again at this position??
         }
       }
     }
     IzPanelLayout.setDefaultYGap(currentDefault, i);
   }
   IzPanelLayout.setDefaultYGap(0, GAP_LOAD_MARKER); // Mark external settings allready
   // loaded.
   return (IzPanelLayout.getDefaultYGap(gapId));
 }
  /**
   * 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();
  }