示例#1
0
  /**
   * Creates a new result item for the given type.
   *
   * @param type The type of the result item to be created.
   */
  public ResultItem(String type) {
    this.type = type;

    setInsets(new Insets(0, 0, 0, 5));

    Column mainColumn = new Column();
    mainColumn.setBorder(new Border(1, Color.BLACK, Border.STYLE_SOLID));

    Row headRow = new Row();
    headRow.setCellSpacing(new Extent(5));
    headRow.setInsets(new Insets(2, 0));
    headRow.setBackground(new Color(200, 200, 200));
    SolidLabel titleLabel = new SolidLabel(type, Font.PLAIN, 9);
    titleLabel.setForeground(Color.WHITE);

    headRow.add(titleLabel);
    contentColumn = new Column();
    contentColumn.setInsets(new Insets(10, 0));

    mainColumn.add(headRow);
    mainColumn.add(contentColumn);

    add(mainColumn);
    add(new HSpace());
  }
示例#2
0
 /** @see nextapp.echo.app.ApplicationInstance#init() */
 public Window init() {
   window = new Window();
   contentPane = window.getContent();
   column = new Column();
   label = new Label("Label");
   column.add(label);
   contentPane.add(column);
   return window;
 }
示例#3
0
  private void setContent(String content) {
    this.content = content;

    contentColumn.removeAll();
    Component contentComp;
    if (isPreformated()) {
      contentComp =
          new DirectHtml("<pre style=\"font-size:11px;\">" + HtmlKit.encode(content) + "</pre>");
    } else if (isHtml()) {
      contentComp = new DirectHtml("<span style=\"font-size:11px;\">" + content + "</span>");
    } else {
      Label l = new Label(content);
      l.setFont(new Font(Font.MONOSPACE, Font.PLAIN, new Extent(11)));
      Column c = new Column();
      c.setInsets(new Insets(0, 10));
      c.add(l);
      contentComp = c;
    }
    contentColumn.add(contentComp);
  }
  public PanelAdquirirHabilidades() {

    Column col = new Column();
    col.setInsets(new Insets(10, 10, 10, 10));
    col.setCellSpacing(new Extent(10));

    Row row = new Row();
    row.setCellSpacing(new Extent(10));
    row.setAlignment(Alignment.ALIGN_CENTER);

    // ----------------------------------------
    // Carga las Habilidades Disponibles
    // ----------------------------------------

    tableDtaModel = new TestTableModel();
    try {
      tableDtaModel =
          HabilidadesAnillo.obtenerHabilidadesCompra( //
              atrib.getPersonaje(), tableDtaModel);
    } catch (Exception e) {
      e.printStackTrace();
    }

    col.add(PanelConstructor.initTopRow("Habilidades Disponibles"));
    col.add(PanelConstructor.initTable(tableDtaModel, initTableColModel(), true));

    Button btnAtras = new Button("Atrás");
    btnAtras.setStyle(Estilo.getStyleColor(app.getAtributos()));
    btnAtras.setWidth(new Extent(160));
    btnAtras.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            btnAtrasClicked();
          }
        });
    row.add(btnAtras);

    Button btnAdquirirHabilidad = new Button("Adquirir Habilidad");
    btnAdquirirHabilidad.setStyle(Estilo.getStyleColor(app.getAtributos()));
    btnAdquirirHabilidad.setWidth(new Extent(160));
    btnAdquirirHabilidad.setAlignment(Alignment.ALIGN_CENTER);
    btnAdquirirHabilidad.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            btnAdquirirHabilidadClicked();
          }
        });
    row.add(btnAdquirirHabilidad);

    col.add(row);
    add(col);
  }
示例#5
0
  @AfterClass
  public static void finish() {
    final Component content = Application.getContent().getTestArea();
    content.removeAll();
    final Column column = new Column();
    column.add(get());
    // The following rows are used to test the Z-index behaviour
    Row d1row = new Row();
    dateField2 = new DateField();
    dateField2.setDateFormat("dd.MM.yyyy");
    dateField2.setFirstDayOfWeek(1);
    dateField2.setInputWidth(new Extent(8, Extent.EM));
    dateField2.setShowWeeks(true);
    d1row.add(dateField2);
    d1row.add(new Label("The following rows are used to test the Z-index behaviour"));
    column.add(d1row);
    Row d2row = new Row();
    dateField3 = new DateField();
    dateField3.setDate(new Date());
    d2row.add(dateField3);
    d2row.add(new Label("Field initialised with date"));
    column.add(d2row);
    column.add(new SelectField());

    Row d3row = new Row();
    PushButton pButton = new PushButton("Get Date value from second date field");
    d3row.add(pButton);
    pButton.addActionListener(
        new ActionListener() {
          private static final long serialVersionUID = 1l;

          public void actionPerformed(final ActionEvent event) {
            Date myDate = dateField2.getDate();
            if (myDate != null) {
              dateLabel.setText(myDate.toLocaleString());
            } else {
              dateLabel.setText("Date value is null");
            }
          }
        });
    dateLabel = new Label();
    d3row.add(dateLabel);

    column.add(d3row);

    content.add(column);
  }
示例#6
0
  /**
   * Creates a new word editor form.
   *
   * @param parentWindow The parent window.
   * @param actionListener The action-listener.
   */
  public WordEditorForm(WindowPane parentWindow, ActionListener actionListener) {
    this.parentWindow = parentWindow;
    this.actionListener = actionListener;

    Column borderCol = new Column();
    borderCol.setBorder(new Border(1, Color.BLACK, Border.STYLE_INSET));

    Grid grid = new Grid(1);
    grid.setRowHeight(0, new Extent(parentWindow.getHeight().getValue() - 160));
    grid.setRowHeight(1, new Extent(30));

    column = new Column();
    column.setInsets(new Insets(10, 20, 0, 0));
    column.setCellSpacing(new Extent(10));
    GridLayoutData gridLayout = new GridLayoutData();
    gridLayout.setAlignment(new Alignment(Alignment.LEFT, Alignment.TOP));
    column.setLayoutData(gridLayout);
    grid.add(column);

    explanationRow = new Row();
    column.add(explanationRow);

    Row footerRow = new Row();
    footerRow.setInsets(new Insets(10, 0, 0, 0));
    String l = "* " + LocaleResources.getString("preditor_wordeditor_required");
    footerRow.add(new Label(l, Font.ITALIC, 11));
    grid.add(footerRow);

    buttonBar = new Row();
    buttonBar.setAlignment(new Alignment(Alignment.RIGHT, Alignment.CENTER));
    buttonBar.setInsets(new Insets(10, 10, 10, 10));
    buttonBar.setCellSpacing(new Extent(5));
    grid.add(buttonBar);

    addButton("general_action_ok");
    addButton("general_action_cancel");

    borderCol.add(grid);
    add(borderCol);
  }
示例#7
0
 /**
  * Adds a new row to the form.
  *
  * @param labelText The text for the label shown on the left hand side of the component.
  * @param formElement The component, i.e. a text field.
  * @param explanation An explanation text shown under the component.
  * @param required Defines whether the component should be marked as required.
  */
 public void addRow(
     String labelText, Component formElement, String explanation, boolean required) {
   Grid grid = new Grid(3);
   grid.setInsets(new Insets(0, 0, 5, 0));
   grid.setColumnWidth(0, new Extent(140));
   grid.add(new SolidLabel(labelText, Font.ITALIC));
   formElements.add(formElement);
   if (formElement instanceof TextField) {
     TextField tf = (TextField) formElement;
     tf.setWidth(new Extent(parentWindow.getWidth().getValue() - 223));
     tf.setActionCommand("OK");
     tf.addActionListener(this);
   }
   grid.add(formElement);
   if (required) {
     requiredFormElements.add(formElement);
     grid.add(new Label("*", Font.ITALIC, 11));
   } else {
     grid.add(new Label());
   }
   grid.add(new Label());
   grid.add(new Label(explanation, Font.ITALIC, 11));
   column.add(grid);
 }
示例#8
0
  /**
   * Creates and returns the GUI component of this menu block column.
   *
   * @param width The width of the column.
   * @return The GUI component.
   */
  public Column createGUI(int width) {
    Column column = new Column();
    column.setCellSpacing(new Extent(10));

    int totalUnits = 18;
    int unitsRest = totalUnits - (2 * contents.size());
    int freeUnits = unitsRest;
    int freeBlocksCount = contents.size();
    double avHeightUnits = (double) unitsRest / contents.size();
    boolean overfull = totalUnits - heightUnits < 0;

    boolean even = true;
    for (MenuBlockContent c : contents) {
      if (overfull && c.getUnfilteredItemCount() <= avHeightUnits) {
        even = false;
        break;
      } else if (!overfull && c.getUnfilteredItemCount() >= avHeightUnits) {
        even = false;
        break;
      }
    }

    if (!even && overfull) {
      List<MenuBlockContent> largeContents = new ArrayList<MenuBlockContent>(contents);
      boolean changed;
      do {
        changed = false;
        int i = 0;
        while (i < largeContents.size()) {
          MenuBlockContent c = largeContents.get(i);
          if (avHeightUnits > c.getUnfilteredItemCount()) {
            changed = true;
            freeUnits -= c.getUnfilteredItemCount();
            freeBlocksCount--;
            largeContents.remove(c);
          } else {
            i++;
          }
        }
        avHeightUnits = (double) freeUnits / freeBlocksCount;
      } while (changed);
    } else if (!even) {
      freeUnits = totalUnits - heightUnits;
    }

    for (int i = 0; i < contents.size(); i++) {
      MenuBlockContent c = contents.get(i);
      int cs = preditor.getMenuCreator().getColorShift(c.getName());
      int heightUnits;
      boolean isLast = (i == contents.size() - 1);
      if (isLast) {
        heightUnits = unitsRest;
      } else if (even) {
        heightUnits = (int) ((double) freeUnits / freeBlocksCount + 0.999);
        freeUnits -= heightUnits;
        freeBlocksCount--;
      } else if (overfull) {
        if (avHeightUnits > c.getUnfilteredItemCount()) {
          heightUnits = c.getUnfilteredItemCount();
        } else {
          heightUnits = (int) ((double) freeUnits / freeBlocksCount + 0.999);
          freeUnits -= heightUnits;
          freeBlocksCount--;
        }
      } else {
        int extraCols = (int) ((double) freeUnits / (contents.size() - i) + 0.999);
        heightUnits = c.getUnfilteredItemCount() + extraCols;
        freeUnits -= extraCols;
      }
      unitsRest -= heightUnits;
      MenuBlock mb = new MenuBlock(width, heightUnits * 15, cs, preditor);
      mb.setContent(c);
      column.add(mb);
    }

    return column;
  }