Example usage for com.vaadin.ui Label getData

List of usage examples for com.vaadin.ui Label getData

Introduction

In this page you can find the example usage for com.vaadin.ui Label getData.

Prototype

public Object getData() 

Source Link

Document

Gets the application specific data.

Usage

From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig), ContentMode.HTML);
    dateLabel.addStyleName(param.leftPartLineStyle);

    cells.add(dateLabel);/*w w w  .j a  v a2 s  .  c o  m*/
    for (int j = 0; j < param.nbCol; j++) {
        int qte = param.qte[lig][j];
        boolean isExcluded = isExcluded(lig, j);

        // En lecture simple
        if (param.readOnly) {
            //
            String txt;

            if (isExcluded) {
                txt = "XXXXXX";
            } else if (qte == 0) {
                txt = "";
            } else {
                txt = "" + qte;
            }
            Label tf = new Label(txt);
            tf.addStyleName("cell-voir");
            tf.setWidth((param.largeurCol - 10) + "px");
            cells.add(tf);
        }
        // En mode normal
        else {
            // Si la cellule est exclue
            if (isExcluded) {
                TextField tf = new TextField();
                tf.setValue("XXXXXX");
                tf.setEnabled(false);
                tf.addStyleName("cell-voir");
                tf.setWidth((param.largeurCol - 10) + "px");
                cells.add(tf);
            } else {
                //
                final TextField tf = BaseUiTools.createQteField("");
                tf.setData(new GridIJData(lig, j));
                if (qte == 0) {
                    tf.setConvertedValue(null);
                } else {
                    tf.setConvertedValue(new Integer(qte));
                }
                tf.addValueChangeListener(new Property.ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        try {
                            GridIJData ij = (GridIJData) tf.getData();
                            int qte = readValueInCell(tf);
                            param.updateQte(ij.i(), ij.j(), qte);
                            displayMontantTotal();
                        } catch (ErreurSaisieException e) {
                            NotificationHelper.displayNotificationQte();
                        }
                    }
                });

                tf.addStyleName("cell-saisie");
                tf.setWidth((param.largeurCol - 10) + "px");
                shortCutManager.registerTextField(tf);
                cells.add(tf);
            }
        }
    }

    table.addItem(cells.toArray(), new Integer(lig));

}

From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java

License:Apache License

/**
 * Check all the other fields to ensure they are still valid
 * this includes any buttons that were registered because they
 * get disabled if there are errors on the relevant form or
 * if the requiredness is incomplete./*w  w  w. j a  va2  s . c  om*/
 * 
 * @param field
 */
public void updateOtherFields(AbstractField field) {
    PermissionManager permissionmanager = getPermissionManager();
    Collection<AbstractField> fields = getFields();
    Collection<Label> labels = getLabels();
    for (Label fieldx : labels) {
        com.vaadin.data.Property p = fieldx.getPropertyDataSource();
        if (p != null && p instanceof LabelProperty) {
            fieldx.requestRepaint();
        }
    }
    for (AbstractField fieldx : fields) {
        if (fieldx.equals(field))
            continue;
        if ((fieldx instanceof Button) && !(fieldx instanceof CheckBox)) {
            com.vaadin.data.Property p = fieldx.getPropertyDataSource();
            if (p != null && p instanceof ButtonProperty) {
                ((ButtonProperty) p).getPainter().paint((Button) fieldx);
                fieldx.requestRepaint();
            }
            continue;
        }
        if (fieldx instanceof MenuItemWrapper) {
            MenuItemPainter menuItemPainter = ((MenuItemWrapper) fieldx).getMenuItemPainter();
            MenuItem menuItem = (MenuItem) fieldx.getData();
            if (menuItemPainter != null) {
                menuItemPainter.paint(menuItem);
                fieldx.requestRepaint();
            }
            continue;
        }
        MaduraPropertyWrapper property = null;
        try {
            property = (MaduraPropertyWrapper) fieldx.getPropertyDataSource();
        } catch (Exception e) {
            // ignore
            property = null;
        }
        if (property != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("evaluating field: {}", property.getName());
                if (fieldx.isEnabled() != property.isEnabled()) {
                    logger.debug("Enabled: {} {}", fieldx.isEnabled(), property.isEnabled());
                }
                if (fieldx.isReadOnly() != property.isReadOnly()) {
                    logger.debug("ReadOnly: {} {}", fieldx.isReadOnly(), property.isReadOnly());
                }
                if (fieldx.isRequired() != property.isRequired()) {
                    logger.debug("Required: {} {}", fieldx.isRequired(), property.isRequired());
                }
                if (fieldx.isVisible() != property.isVisible()) {
                    logger.debug("Visible: {} {}", fieldx.isVisible(), property.isVisible());
                }
            }
            fieldx.setEnabled(property.isEnabled());
            fieldx.setReadOnly(property.isReadOnly());
            fieldx.setRequired(property.isRequired());
            fieldx.setVisible(property.isVisible());
            // Permissions trump rules
            if (!permissionmanager.hasPermission(property.getReadPermission())) {
                fieldx.setVisible(false);
            }
            if (!permissionmanager.hasPermission(property.getWritePermission())) {
                fieldx.setEnabled(false);
            }
            if (fieldx instanceof AbstractSelect) {
                AbstractSelect select = (AbstractSelect) fieldx;
                List<ChoiceBase> availableList = new ArrayList<ChoiceBase>();
                for (ChoiceBase v : property.getAvailableValues()) {
                    availableList.add(v);
                }
                logger.debug("{} availableList {}", property.getName(), availableList);
                Collection<?> itemIds = select.getItemIds();
                List<Object> killList = new ArrayList<Object>();
                for (Object itemId : itemIds) {
                    if (availableList.contains(itemId))
                        continue;
                    killList.add(itemId);
                }
                for (Object kill : killList) {
                    select.removeItem(kill);
                }
                for (ChoiceBase cb : availableList) {
                    select.addItem(cb);
                }
                logger.debug("Select {} value \"{}\", updated to {}",
                        new Object[] { property.getName(), select.getValue(), select.getItemIds() });
            }
        }
        fieldx.requestRepaint();
    }
}