@Override
  public void initialize(Map<String, Object> arg0, URL arg1, Resources arg2) {
    tableViewRowEditor = new TableViewRowEditor();
    asf1TVAdditionalServices.setRowEditor(tableViewRowEditor);

    // Quantity uses a TextInput
    TextInput quantityTextInput = new TextInput();
    quantityTextInput.setTextKey("quantity");
    tableViewRowEditor.getCellEditors().put("quantity", quantityTextInput);

    // Description uses a TextInput
    TextInput descriptionTextInput = new TextInput();
    descriptionTextInput.setTextKey("description");
    tableViewRowEditor.getCellEditors().put("description", descriptionTextInput);
  }
  @Override
  public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    if (button == Mouse.Button.MIDDLE) {
      if (component instanceof TextInput) {
        ((TextInput) component).paste();
      } else if (component instanceof TextArea) {
        ((TextArea) component).paste();
        return true;
      }
    }

    return false;
  }
Exemplo n.º 3
0
  protected void aplicarFiltro() {
    java.util.List<RecetaListItem> aux;
    recetas.clear();
    try {
      Integer tiempoTotal =
          minutosSpinner.getSelectedIndex() * 60 + segundosSpinner.getSelectedIndex();
      // Para que no desaparezcan recetas de la tabla al no haber indicado ningún tiempo.
      if (tiempoTotal == 0) tiempoTotal = null;
      Long idCategoria = ((CategoriaItem) categoriasListButton.getSelectedItem()).getId();
      aux =
          ServiceLocator.getRecetasService()
              .buscarRecetas(nombreText.getText(), tiempoTotal, idCategoria);
      for (RecetaListItem c : aux) {
        recetas.add(convert(c));
      }
    } catch (ServiceException e) {

    }
    // Actualizar el número de recetas
    recetApp.getPrincipalWindow().setNumRecetasText("" + recetas.getLength());
  }
Exemplo n.º 4
0
  @Override
  public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    recetas = new ArrayList<RecetaListFormatItem>();
    recetasTable.setTableData(recetas);

    initRecetasTable();
    initCategoriaListButton();

    nombreText
        .getComponentKeyListeners()
        .add(
            new ComponentKeyListener.Adapter() {
              @Override
              public boolean keyTyped(Component component, char character) {
                aplicarFiltro();
                return false;
              }
            });

    minutosSpinner
        .getSpinnerSelectionListeners()
        .add(
            new SpinnerSelectionListener.Adapter() {
              @Override
              public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
                aplicarFiltro();
              }
            });

    segundosSpinner
        .getSpinnerSelectionListeners()
        .add(
            new SpinnerSelectionListener.Adapter() {
              @Override
              public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
                aplicarFiltro();
              }
            });

    categoriasListButton
        .getListButtonSelectionListeners()
        .add(
            new ListButtonSelectionListener.Adapter() {
              @Override
              public void selectedItemChanged(ListButton listButton, Object previousSelectedItem) {
                aplicarFiltro();
              }
            });

    aniadirButton
        .getButtonPressListeners()
        .add(
            new ButtonPressListener() {
              @Override
              public void buttonPressed(Button button) {
                onAniadirButtonPressed();
              }
            });

    eliminarButton
        .getButtonPressListeners()
        .add(
            new ButtonPressListener() {
              @Override
              public void buttonPressed(Button arg0) {
                onEliminarButtonPressed();
              }
            });

    editarButton
        .getButtonPressListeners()
        .add(
            new ButtonPressListener() {
              @Override
              public void buttonPressed(Button button) {
                onEditarButtonPressed();
              }
            });
  }
  @Override
  public void beginEdit(
      TableView tableViewArgument, int rowIndexArgument, int columnIndexArgument) {
    this.tableView = tableViewArgument;
    this.rowIndex = rowIndexArgument;
    this.columnIndex = columnIndexArgument;

    Container tableViewParent = tableViewArgument.getParent();
    tableViewScrollPane =
        (tableViewParent instanceof ScrollPane) ? (ScrollPane) tableViewParent : null;

    // Add/create the editor components
    TableView.ColumnSequence tableViewColumns = tableViewArgument.getColumns();
    TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();

    for (int i = 0, n = tableViewColumns.getLength(); i < n; i++) {
      // Add a new column to the table pane to match the table view column
      TablePane.Column tablePaneColumn = new TablePane.Column();
      tablePaneColumn.setWidth(tableViewArgument.getColumnBounds(i).width);
      tablePaneColumns.add(tablePaneColumn);

      // Determine which component to use as the editor for this column
      String columnName = tableViewColumns.get(i).getName();
      Component editorComponent = null;
      if (columnName != null) {
        editorComponent = cellEditors.get(columnName);
      }

      // Default to a read-only text input editor
      if (editorComponent == null) {
        TextInput editorTextInput = new TextInput();
        editorTextInput.setTextKey(columnName);
        editorTextInput.setEnabled(false);
        editorTextInput.setTextBindType(BindType.LOAD);
        editorComponent = editorTextInput;
      }

      // Add the editor component to the table pane
      editorRow.add(editorComponent);
    }

    // Get the data being edited
    List<?> tableData = tableViewArgument.getTableData();
    Object tableRow = tableData.get(rowIndexArgument);

    // Load the row data into the editor components
    tablePane.load(tableRow);

    // Get the row bounds
    Bounds rowBounds = tableViewArgument.getRowBounds(rowIndexArgument);
    rowImage.bounds = rowBounds;

    // Scroll to make the row as visible as possible
    tableViewArgument.scrollAreaToVisible(
        rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);

    // Constrain the bounds by what is visible through viewport ancestors
    rowBounds = tableViewArgument.getVisibleArea(rowBounds);
    Point location =
        tableViewArgument.mapPointToAncestor(
            tableViewArgument.getDisplay(), rowBounds.x, rowBounds.y);

    // Set size and location and match scroll left
    setPreferredWidth(rowBounds.width);
    setLocation(location.x, location.y + (rowBounds.height - getPreferredHeight(-1)) / 2);

    if (tableViewScrollPane != null) {
      scrollPane.setScrollLeft(tableViewScrollPane.getScrollLeft());
    }

    // Open the editor
    open(tableViewArgument.getWindow());

    // Start the transition
    cardPane.setSelectedIndex(EDITOR_CARD_INDEX);
  }