Example usage for com.vaadin.ui AbstractComponent addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

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  w w .  j a v a2 s  . c  om*/

    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:com.mycollab.module.project.ui.ProjectAssetsUtil.java

License:Open Source License

public static Component buildProjectLogo(String projectShortname, Integer projectId, String projectAvatarId,
        int size) {
    AbstractComponent wrapper;
    if (!StringUtils.isBlank(projectAvatarId)) {
        wrapper = new Image(null,
                new ExternalResource(StorageFactory.getResourcePath(String.format("%s/%s_%d.png",
                        PathUtils.getProjectLogoPath(MyCollabUI.getAccountId(), projectId), projectAvatarId,
                        size))));//from w  w w .  ja  v  a 2s .c  o m
    } else {
        ELabel projectIcon = new ELabel(projectShortname).withStyleName(UIConstants.TEXT_ELLIPSIS,
                ValoTheme.LABEL_LARGE, "center");
        wrapper = new VerticalLayout();
        ((VerticalLayout) wrapper).addComponent(projectIcon);
        ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(UIConstants.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(ProjectI18nEnum.OPT_CHANGE_LOGO_HELP,
            UserUIContext.getMessage(ProjectI18nEnum.EDIT)));
    return wrapper;
}

From source file:com.mycollab.module.project.ui.ProjectAssetsUtil.java

License:Open Source License

public static Component buildClientLogo(SimpleAccount account, int size) {
    AbstractComponent wrapper;
    if (!StringUtils.isBlank(account.getAvatarid())) {
        wrapper = new Image(null, new ExternalResource(
                StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), account.getAvatarid(), 100)));
    } else {/*from w  w  w  . java2s.  c om*/
        String accountName = account.getAccountname();
        accountName = (accountName.length() > 3) ? accountName.substring(0, 3) : accountName;
        ELabel projectIcon = new ELabel(accountName).withStyleName(UIConstants.TEXT_ELLIPSIS, "center");
        wrapper = new VerticalLayout();
        ((VerticalLayout) wrapper).addComponent(projectIcon);
        ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(UIConstants.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(ClientI18nEnum.OPT_CHANGE_LOGO_HELP,
            UserUIContext.getMessage(ClientI18nEnum.EDIT)));
    return wrapper;
}

From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent.java

License:Open Source License

public void addComponentToCountLayout(CssLayout countLayout, AbstractComponent countElement) {
    countElement.setWidthUndefined();//  w  ww  .j  a va  2 s .  com
    countElement.addStyleName(CssStyles.HSPACE_RIGHT_3);
    countLayout.addComponent(countElement);
}

From source file:de.symeda.sormas.ui.SubMenu.java

License:Open Source License

/**
 * Highlights a view navigation button as the currently active view in the
 * menu. This method does not perform the actual navigation.
 *
 * @param viewName/* w w  w .  j  a v  a2s  .c  o  m*/
 *            the name of the view to show as active
 */
public void setActiveView(String viewName) {
    for (AbstractComponent button : viewMenuItemMap.values()) {
        button.removeStyleName("selected");
    }
    AbstractComponent selected = viewMenuItemMap.get(viewName);
    if (selected != null) {
        selected.addStyleName("selected");
    }
}

From source file:org.vaadin.tori.component.FloatingComponent.java

License:Apache License

public final void extend(final AbstractComponent target) {
    super.extend(target);
    target.addStyleName("floatingcomponent");
}