Example usage for com.vaadin.ui AbstractComponent setWidth

List of usage examples for com.vaadin.ui AbstractComponent setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractComponent setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.foc.vaadin.gui.components.tableAndTree.FVColGen_FocProperty.java

License:Apache License

private Object getDisplayObject_ForProperty_Editable(FocObject focObject, FProperty property,
        FVTableColumn column, Object columnId) {
    Object objReturned = null;/* w  ww.  j a  v a  2s  . c o m*/

    FField field = property != null ? property.getFocField() : null;

    if (field instanceof FImageField) {
        objReturned = (AbstractComponent) getTableTreeDelegate().newGuiComponent(focObject, column, property);
        FVImageField imageField = (FVImageField) objReturned;
        imageField.setWidth("60px");
        imageField.setHeight("50px");
    } else if (field instanceof FCloudStorageField) {
        FCloudStorageProperty csProp = (FCloudStorageProperty) property;
        if (csProp != null) {
            FVImageField imageField = new FVImageField(csProp, column.getAttributes());
            if (imageField.getBufferedImage() == null) {
                Resource resource = imageField.getResourceAndSetIcon();
                if (resource != null) {
                    Button docIcon = new Button();
                    docIcon.setStyleName(Runo.BUTTON_LINK);
                    docIcon.setWidth("-1px");
                    docIcon.setHeight("-1px");
                    docIcon.setIcon(resource);
                    objReturned = docIcon;
                }
            } else {
                Image image = imageField.getEmbedded();
                if (image != null) {
                    int maxWidth = 150;
                    int maxHeight = 150;
                    imageField.resizeImage(image, maxWidth, maxHeight);
                }
                objReturned = imageField;
            }
        }
    } else {
        objReturned = "";
        if (property != null) {
            AbstractComponent abstractComponent = (AbstractComponent) getTableTreeDelegate()
                    .newGuiComponent(focObject, column, property);

            if (abstractComponent != null) {
                objReturned = abstractComponent;
                abstractComponent.addStyleName("editableStyle");

                if (abstractComponent instanceof FVTextField) {
                    // ((FVTextField) abstractComponent).selectAll();
                    /*
                     * ((FVTextField) abstractComponent).addFocusListener(new
                     * FocusListener() { private boolean updating = false; public void
                     * focus(FocusEvent event) { if(!updating){ updating = true;
                     * ((FVTextField) abstractComponent).selectAll(); updating = false;
                     * } } });
                     */
                    // Adding the focus listener on the component to be used in the
                    // formula layout
                    if (getFormulaFocusListener() != null) {
                        ((FVTextField) abstractComponent).addFocusListener(getFormulaFocusListener());
                    }
                    if (isUseReadOnlyFlag()) {
                        ((FVTextField) abstractComponent).addFocusListener(getReadOnlyFocusListener(true));
                        ((FVTextField) abstractComponent).addBlurListener(getReadOnlyBlurListener(true));
                    }
                } else if (abstractComponent instanceof FVCheckBox) {
                    abstractComponent.setCaption("");
                } else if (abstractComponent instanceof FVComboBox) {
                    // Adding the focus listener on the component to be used in the
                    // formula layout
                    if (getFormulaFocusListener() != null) {
                        ((FVComboBox) abstractComponent).addFocusListener(getFormulaFocusListener());
                    }
                    if (isUseReadOnlyFlag()) {
                        ((FVComboBox) abstractComponent).addFocusListener(getReadOnlyFocusListener(true));
                        ((FVComboBox) abstractComponent).addBlurListener(getReadOnlyBlurListener(true));
                    }

                } else if (abstractComponent instanceof FVObjectPopupView) {
                    // Adding the focus listener on the component to be used in the
                    // formula layout
                    FVObjectPopupView popupView = ((FVObjectPopupView) abstractComponent);
                    if (popupView != null && getFormulaFocusListener() != null) {
                        popupView.addPopupVisibilityListener(new PopupVisibilityListener() {

                            @Override
                            public void popupVisibilityChange(PopupVisibilityEvent event) {
                                if (getTableTreeDelegate() != null && event != null
                                        && event.getPopupView() != null
                                        && event.getPopupView() instanceof FVObjectPopupView) {
                                    FVObjectPopupView popupView = (FVObjectPopupView) event.getPopupView();
                                    getTableTreeDelegate().adjustFormulaLayoutForComponent(popupView);
                                }
                            }
                        });
                        //                     popupView.addFocusListener(getFormulaFocusListener());
                    }
                    //                  if(isUseReadOnlyFlag()){
                    //                     popupView.addFocusListener(getReadOnlyFocusListener(true));
                    //                     popupView.addBlurListener(getReadOnlyBlurListener(true));
                    //                  }
                } else if (abstractComponent instanceof FVObjectSelector) {
                    // Adding the focus listener on the component to be used in the
                    // formula layout
                    FVObjectComboBox comboBox = ((FVObjectSelector) abstractComponent).getComboBox();
                    if (comboBox != null && getFormulaFocusListener() != null) {
                        comboBox.addFocusListener(getFormulaFocusListener());
                    }
                    if (isUseReadOnlyFlag()) {
                        comboBox.addFocusListener(getReadOnlyFocusListener(true));
                        comboBox.addBlurListener(getReadOnlyBlurListener(true));
                    }
                } else if (abstractComponent instanceof FVObjectComboBox && getFormulaFocusListener() != null) {
                    FVObjectComboBox comboBox = (FVObjectComboBox) abstractComponent;
                    if (comboBox != null) {
                        comboBox.addFocusListener(getFormulaFocusListener());
                    }
                    if (isUseReadOnlyFlag()) {
                        comboBox.addFocusListener(getReadOnlyFocusListener(true));
                        comboBox.addBlurListener(getReadOnlyBlurListener(true));
                    }
                } else if (abstractComponent instanceof FVMultipleChoiceComboBox
                        && getFormulaFocusListener() != null) {
                    FVMultipleChoiceComboBox comboBox = (FVMultipleChoiceComboBox) abstractComponent;
                    if (comboBox != null) {
                        comboBox.addFocusListener(getFormulaFocusListener());
                    }
                    if (isUseReadOnlyFlag()) {
                        comboBox.addFocusListener(getReadOnlyFocusListener(true));
                        comboBox.addBlurListener(getReadOnlyBlurListener(true));
                    }
                }
                // Setting the column and row Ids of component
                FocXMLGuiComponent focXMLGuiComponent = (FocXMLGuiComponent) abstractComponent;
                FocXMLGuiComponentDelegate focXMLGuiComponentDelegate = focXMLGuiComponent.getDelegate();
                if (focXMLGuiComponentDelegate != null) {
                    focXMLGuiComponentDelegate.setColumnId(columnId);
                    if (focObject != null && focObject.getReference() != null) {
                        focXMLGuiComponentDelegate.setRowId(focObject.getReference().getLong());
                    }
                }
                abstractComponent.setId(column.getDataPath());
                abstractComponent.setWidth("100%");// This was added to get the node
                                                   // name text field in the BKDN
                                                   // tree big enough to enter or see
                                                   // the value
                                                   // If we put 100% in the xml we get a small width extendable. but with
                                                   // this solution we have a fixed minimum width in the xml + the 100%
                                                   // allows us to change the width
                if (isUseReadOnlyFlag()) {
                    abstractComponent.setReadOnly(true);
                }
            }
        }
    }

    if (property != null && property.isInherited()) {
        FProperty inheritedProp = null;
        try {
            inheritedProp = property.getFocField().getInheritedPropertyGetter()
                    .getInheritedProperty(property.getFocObject(), property);
        } catch (Exception e) {
            Globals.logException(e);
        }
        if (inheritedProp != null) {
            objReturned = inheritedProp;
        }
    }
    return objReturned;
}

From source file:componentwrappers.CustomVisibilityComponent.java

License:Open Source License

public CustomVisibilityComponent(String caption, AbstractComponent comp, String width) {
    this(caption, comp);
    comp.setWidth(width);
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * @param form//from   ww  w  .j  a  v  a2  s .c o  m
 * @param comp
 * @param label
 * @param labelWidth
 * @param width
 * @param height
 * @param required
 */
public static synchronized void addElement(final FormLayout form, final AbstractComponent comp,
        final String label, final int labelWidth, final int width, final int height, final boolean required) {
    comp.setWidth(width + Constants.PX);
    form.addComponent(LayoutHelper.create(label, comp, labelWidth, height, required));
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * @param form//from  w  w w.j  av a  2 s  .  c o m
 * @param comp
 * @param label
 * @param labelWidth
 * @param width
 * @param height
 * @param required
 * @param buttons
 */
public static synchronized void addElement(final FormLayout form, final AbstractComponent comp,
        final String label, final int labelWidth, final int width, final int height, final boolean required,
        final Button[] buttons) {
    comp.setWidth(width + Constants.PX);
    form.addComponent(LayoutHelper.create(label, comp, labelWidth, height, required, buttons));
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * @param form//from   w  ww . j  av  a2  s  .co  m
 * @param comp
 * @param label
 * @param labelWidth
 * @param width
 * @param required
 */
public static synchronized void addElement(final FormLayout form, final AbstractComponent comp,
        final String label, final int labelWidth, final int width, final boolean required) {
    comp.setWidth(width + Constants.PX);
    form.addComponent(LayoutHelper.create(label, comp, labelWidth, required));
}

From source file:de.mhus.lib.vaadin.layouter.LayUtil.java

License:Apache License

public static void configure(AbstractComponent layout, ResourceNode config) throws MException {
    if (config.getBoolean(LayoutBuilder.FULL_SIZE, false))
        layout.setSizeFull();//from   w  ww.j  a  v a  2 s  . co  m
    else {
        String width = config.getString(LayoutBuilder.WIDTH, null);
        if (width != null)
            layout.setWidth(width);
        String height = config.getString(LayoutBuilder.HEIGHT, null);
        if (height != null)
            layout.setHeight(height);
    }

    // margin
    //TODO      if (layout instanceof Layout && config.isProperty(LayoutBuilder.MARGIN))
    //         ((Layout)layout).setMargin(config.getBoolean(LayoutBuilder.MARGIN, false));
    // spacing
    if (layout instanceof Layout.SpacingHandler && config.isProperty(LayoutBuilder.SPACING))
        ((Layout.SpacingHandler) layout).setSpacing(config.getBoolean(LayoutBuilder.SPACING, false));
    // styles
    if (config.isProperty(LayoutBuilder.STYLE)) {
        layout.setStyleName(config.getExtracted(LayoutBuilder.STYLE));
    }
    // hidden
    if (config.getBoolean(LayoutBuilder.HIDDEN, false))
        layout.setVisible(false);

    // split
    if (layout instanceof AbstractSplitPanel) {
        String a = config.getString(LayoutBuilder.SPLIT_MIN, null);
        if (a != null) {
            float[] s = parseStringSize(a);
            if (s[0] >= 0)
                ((AbstractSplitPanel) layout).setMinSplitPosition(s[0], Unit.values()[(int) s[1]]);
        }
        a = config.getString(LayoutBuilder.SPLIT_MAX, null);
        if (a != null) {
            float[] s = parseStringSize(a);
            if (s[0] >= 0)
                ((AbstractSplitPanel) layout).setMaxSplitPosition(s[0], Unit.values()[(int) s[1]]);
        }
        a = config.getString(LayoutBuilder.SPLIT_POS, null);
        if (a != null) {
            float[] s = parseStringSize(a);
            if (s[0] >= 0)
                ((AbstractSplitPanel) layout).setSplitPosition(s[0], Unit.values()[(int) s[1]]);
        }
    }

}

From source file:org.balisunrise.vaadin.components.Sizes.java

License:Open Source License

public void applyWidth(AbstractComponent component) {
    switch (this) {
    case UNDEFINED:
        component.setWidthUndefined();/* www  .ja va 2 s .  c om*/
        break;
    default:
        component.setWidth(this.toSize());
    }
}