Example usage for com.vaadin.ui Embedded Embedded

List of usage examples for com.vaadin.ui Embedded Embedded

Introduction

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

Prototype

public Embedded(String caption, Resource source) 

Source Link

Document

Creates a new Embedded object whose contents is loaded from given resource.

Usage

From source file:com.expressui.core.util.UrlUtil.java

License:Open Source License

/**
 * Only used by sample application to track usage statistics
 *
 * @param container container for adding the embedded iframe to
 *//*ww  w  .  j ava2s  . co m*/
public static void addTrackingUrl(AbstractComponentContainer container, String tag) {
    try {
        URL url = new URL(EXPRESSUI_TEST_PAGE + tag);
        Embedded browser = new Embedded(null, new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setWidth(0, Sizeable.UNITS_PIXELS);
        browser.setHeight(0, Sizeable.UNITS_PIXELS);
        container.addComponent(browser);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.expressui.core.view.util.CodePopup.java

License:Open Source License

private Embedded getEmbeddedDoc(String u) {
    try {/*ww  w .  j a va  2 s  . c  om*/
        URL url = new URL(u);
        Embedded browser = new Embedded("", new ExternalResource(url));
        browser.setHeight(15000, Sizeable.UNITS_PIXELS);
        browser.setType(Embedded.TYPE_BROWSER);
        return browser;
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.expressui.sample.view.HomePage.java

License:Open Source License

@Override
public void onDisplay() {
    try {/*w w w.  j  a v  a 2s .c o m*/
        URL url = new URL("http://www.expressui.com/");
        Embedded browser = new Embedded("", new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setWidth(100, Sizeable.UNITS_PERCENTAGE);
        browser.setHeight(15000, Sizeable.UNITS_PIXELS);
        setCompositionRoot(browser);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }

    getMainApplication().showTrayMessage("<h3>Feature Tip:</h3>" + "<ul>"
            + "<li>This illustrates how to embed any external page into ExpressUI" + "</ul>");
}

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

License:Apache License

private Object getDisplayObject_ForProperty_NonEditable(FocObject focObject, FProperty property,
        FVTableColumn column, Object columnId) {
    Object objReturned = null;//from  w  ww  .  j a v a  2  s  .c  o  m
    FField field = property != null ? property.getFocField() : null;
    if (property != null) {
        // Remove the editable component in case the editing status has changed
        // --------------------------------------------------------------------
        String objRef = focObject != null && focObject.getReference() != null
                ? focObject.getReference().toString()
                : null;
        String compName = TableTreeDelegate.newComponentName(getTableName(), objRef, (String) column.getName());
        FocXMLLayout focXMLLayout = getFocXMLLayout();
        if (focXMLLayout != null) {
            FocXMLGuiComponent comp = focXMLLayout.removeComponentByName(compName);
            if (comp != null) {
                comp.dispose();
            }
        }
        // --------------------------------------------------------------------
        objReturned = property.vaadin_TableDisplayObject(column.getFormat(), column.getCaptionProp());

        if (objReturned instanceof Boolean) {
            if (((Boolean) objReturned).booleanValue()) {
                objReturned = new Embedded("", new ThemeResource("../runo/icons/16/ok.png"));
            } else {
                // objReturned = new Embedded("", new
                // ThemeResource("../runo/icons/16/cancel.png"));
                objReturned = FVIconFactory.getInstance().getFVIcon_Embedded(FVIconFactory.ICON_EMPTY,
                        FVIconFactory.SIZE_SMALL);
            }
        } 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 if (property instanceof FObject || property instanceof FDate || property instanceof FString
                || property instanceof FDouble || property instanceof FInt
                || property instanceof FMultipleChoice) {
            if (property instanceof FMultipleChoice) {
                objReturned = property.getString();
            }
            FVLabel lbl = null;
            String styleAttrib = column.getAttributes() != null
                    ? column.getAttributes().getValue(FXML.ATT_STYLE)
                    : null;
            int maxCharacters = column.getMaxCharacters();
            String ttt = null;

            if (styleAttrib != null && !styleAttrib.isEmpty()) {
                lbl = new FVLabel((String) objReturned);
                lbl.parseStyleAttributeValue(styleAttrib);
                objReturned = lbl;
            } else if (property instanceof FDouble
                    || (property instanceof FInt && !(property instanceof FMultipleChoice))) {
                lbl = new FVLabelInTable(property, focObject, column);
                lbl.copyMemoryToGui();
                lbl.addStyleName("foc-text-right");
                objReturned = lbl;
            }

            if (property instanceof FMultipleChoice) {
                Object itemObj = ((FMultipleChoice) property).getValue();
                if (itemObj != null && itemObj instanceof FMultipleChoiceItem) {
                    FMultipleChoiceItem item = (FMultipleChoiceItem) itemObj;
                    if (lbl == null) {
                        String iconNameInFontAwesome = item != null ? item.getIconFontAwesomeName() : null;
                        if (iconNameInFontAwesome == null) {
                            lbl = new FVLabel(item.getTitle());
                            //                        lbl.setIcon(FVIconFactory.getInstance().getFVIcon_Small(path));
                        } else {
                            FontAwesome icon = FontAwesome.valueOf(iconNameInFontAwesome);
                            lbl = new FVLabel("");
                            lbl.setCaption(null);
                            lbl.setContentMode(ContentMode.HTML);
                            lbl.setValue(item.getTitle() + " " + icon.getHtml());
                        }

                        objReturned = lbl;
                    }
                }
            }

            //If RTL I have t put the String in a label to align right
            if (lbl == null && getFocXMLLayout().isRTL()) {
                lbl = new FVLabelInTable(property, focObject, column);
                lbl.copyMemoryToGui();
                lbl.addStyleName("foc-text-right");
                objReturned = lbl;
            }

            //Setting the TTT is necessary
            //We have 2 conditions: either the objReturned is String or Label.
            //----------------------------
            if (lbl != null) {
                String originalValue = lbl.getValue();
                if (maxCharacters > 0 && originalValue != null && originalValue.length() > maxCharacters) {
                    ttt = originalValue;

                    //                  lbl.setLocale();
                    if (getFocXMLLayout().isRTL()) {
                        lbl.addStyleName("foc-cellComment-left");
                        //                     lbl.setLocale(new Locale("ar"));
                        StringBuffer buff = new StringBuffer(ttt.substring(0, maxCharacters));
                        //                     buff.append("...");
                        buff.append("...");
                        lbl.setValue(buff.toString());
                    } else {
                        lbl.addStyleName("foc-cellComment-right");
                        lbl.setValue(ttt.substring(0, maxCharacters) + "...");
                    }
                }
            } else if (objReturned instanceof String) {
                String originalValue = (String) objReturned;
                if (maxCharacters > 0 && originalValue != null && originalValue.length() > maxCharacters) {
                    ttt = originalValue;
                    if (getFocXMLLayout().isRTL()) {
                        objReturned = ttt.substring(0, maxCharacters) + "...";
                    } else {
                        objReturned = ttt.substring(0, maxCharacters) + "...";
                    }
                }
            }
            if (ttt != null && getTableTreeDelegate() != null) {
                getTableTreeDelegate().addCellTooltipText(focObject.getReference(), columnId, ttt);
            }
            //----------------------------

            if (lbl != null) {
                if (getFocXMLLayout().isRTL())
                    lbl.addStyleName("foc-text-right");
                FocXMLGuiComponent focXMLGuiComponent = lbl;
                FocXMLGuiComponentDelegate componentDelegate = focXMLGuiComponent.getDelegate();
                if (componentDelegate != null) {
                    componentDelegate.setColumnId(columnId);
                    if (focObject != null && focObject.getReference() != null) {
                        componentDelegate.setRowId(focObject.getReference().getLong());
                    }
                }
            }
            if (lbl != null && getFocXMLLayout() != null)
                getFocXMLLayout().putComponent(compName, lbl);
            FocXMLAttributes attributes = column.getAttributes();
            if (attributes != null && attributes.getValue(FXML.ATT_LINK) != null
                    && attributes.getValue(FXML.ATT_LINK).equals("true")) {
                HyperLinkButton button = new HyperLinkButton(focObject, objReturned, compName);
                button.addClickListener(hyperLinkButtonListener);
                button.addStyleName("focLinkInTable");
                objReturned = button;

                //               if(getTableTreeDelegate().getViewContainer_ForOpen() == ITableTree.VIEW_CONTAINER_NEW_BROWSER_TAB){
                //                 BrowserWindowOpener opener = null; 
                //                 opener = new BrowserWindowOpener(UI.getCurrent().getClass());
                //                opener.extend(button);
                //               }
            }
        } else {
            objReturned = property;
            //            if((property instanceof FMultipleChoice)){
            //               FocXMLAttributes attributes = column.getAttributes();
            //               if(attributes != null && attributes.getValue(FXML.ATT_LINK) != null && attributes.getValue(FXML.ATT_LINK).equals("true")){
            //                  HyperLinkButton button = new HyperLinkButton(focObject, property.getString());
            //                  button.addClickListener(hyperLinkButtonListener);
            //                  button.addStyleName("focLinkInTable");
            //                  objReturned = button;
            //               }
            //            }
        }
    }
    //      if(objReturned instanceof String){
    //         objReturned = new Label(objReturned.toString());
    //      }
    return objReturned;
}

From source file:com.foc.vaadin.gui.components.TableTreeDelegate.java

License:Apache License

private Object getDisplayObject_ForProperty_NonEditable(FProperty property, FVTableColumn column) {
    Object objReturned = null;//from  w w  w  .j  av a  2s.  co  m
    if (property != null) {
        objReturned = property.vaadin_TableDisplayObject(null, column.getCaptionProp());
        if (objReturned instanceof Boolean) {
            if (((Boolean) objReturned).booleanValue()) {
                objReturned = new Embedded("", new ThemeResource("../runo/icons/16/ok.png"));
            } else {
                objReturned = new Embedded("", new ThemeResource("../runo/icons/16/cancel.png"));
            }
        } else if (property instanceof FObject || property instanceof FDate || property instanceof FString
                || property instanceof FDouble) {

            FVLabel lbl = null;
            String styleAttrib = column.getAttributes().getValue(FXML.ATT_STYLE);
            if (styleAttrib != null && !styleAttrib.isEmpty()) {
                lbl = new FVLabel((String) objReturned);
                lbl.parseStyleAttributeValue(styleAttrib);
                objReturned = lbl;
            } else if (property instanceof FDouble) {
                lbl = new FVLabel((String) objReturned);
                lbl.addStyleName("foc-text-right");
                objReturned = lbl;
            }

        } else {
            objReturned = property;
        }
    }

    return objReturned;
}

From source file:com.foc.vaadin.gui.FVIconFactory.java

License:Apache License

public Embedded getFVIcon(String iconName, boolean dispLayCaption) {
    Resource iconResourse = new ThemeResource("../" + THEME_DIR + "/icons/" + iconName);

    Embedded embedded = new Embedded(null, iconResourse);

    if (!iconName.equals(ICON_TRASH_SMALL)) {
        embedded.setWidth("32px");
        embedded.setHeight("32px");
    }/*w  w w  . j a v  a 2s  .c om*/

    if (dispLayCaption) {
        embedded.setCaption(iconName);
    }

    return embedded;
}

From source file:com.foc.vaadin.gui.FVIconFactory.java

License:Apache License

public Embedded getFVIcon_Embedded(String iconName, int size) {
    Embedded embedded = null;//from   w ww  .  j av  a2  s.  c  om
    Resource resource = getFVIcon_Internal(iconName, size);
    if (resource != null) {
        embedded = new Embedded("", resource);
        if (size == SIZE_NONE) {

        } else if (size == SIZE_SMALL) {
            embedded.setWidth("16px");
            embedded.setHeight("16px");
        } else if (size == SIZE_24) {
            embedded.setWidth("24px");
            embedded.setHeight("24px");
        } else if (size == SIZE_BIG) {
            embedded.setWidth("32px");
            embedded.setHeight("32px");
        } else if (size == SIZE_48) {
            embedded.setWidth("48px");
            embedded.setHeight("48px");
        }
    }
    return embedded;
}

From source file:com.foc.vaadin.gui.layouts.FVTableWrapperLayout.java

License:Apache License

public Embedded valo_GetReloadEmbedded() {
    if (valo_ReloadEmbedded == null) {
        valo_ReloadEmbedded = new Embedded("",
                FVIconFactory.getInstance().getFVIcon_Small(FVIconFactory.ICON_REFRESH));
        valo_ReloadEmbedded.setStyleName(BaseTheme.BUTTON_LINK);
        valo_ReloadEmbedded.setDescription("Refresh");
        valo_ReloadEmbedded.addStyleName(FocXMLGuiComponentStatic.STYLE_NO_PRINT);
        FocXMLGuiComponentStatic.setCaptionMargin_Zero(valo_ReloadEmbedded);

        valo_ReloadEmbedded.addClickListener(new MouseEvents.ClickListener() {

            @Override/* w  ww  . j a  v  a2s.c om*/
            public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                reloadClickListener();
            }
        });
    }
    return valo_ReloadEmbedded;
}

From source file:com.foc.vaadin.gui.layouts.FVTableWrapperLayout.java

License:Apache License

private Embedded valo_GetDuplicateEmbedded() {
    if (valo_DuplicateEmbedded == null && getTableTreeDelegate().isDuplicateEnabled()) {
        valo_DuplicateEmbedded = new Embedded("",
                FVIconFactory.getInstance().getFVIcon_Small(FVIconFactory.ICON_DUPLICATE_16));
        valo_DuplicateEmbedded.setStyleName(BaseTheme.BUTTON_LINK);
        valo_DuplicateEmbedded.addStyleName(FocXMLGuiComponentStatic.STYLE_NO_PRINT);
        valo_DuplicateEmbedded.addStyleName(FocXMLGuiComponentStatic.STYLE_HAND_POINTER_ON_HOVER);
        valo_DuplicateEmbedded.setDescription("Duplicate");

        valo_DuplicateEmbedded.addClickListener(new MouseEvents.ClickListener() {

            @Override/*from  w w w  .ja  v  a 2  s.  c  om*/
            public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                duplicateClickListenerContent();
            }
        });
    }
    return valo_DuplicateEmbedded;
}

From source file:com.foc.vaadin.gui.layouts.FVTableWrapperLayout.java

License:Apache License

private Embedded valo_GetOpenEmbedded(boolean isEditable) {
    if (valo_OpenEmbedded == null && getTableTreeDelegate().isAddEnabled(isEditable) && !isPrintingUI()) {
        valo_OpenEmbedded = new Embedded("",
                FVIconFactory.getInstance().getFVIcon_Small(FVIconFactory.ICON_EDIT));
        valo_OpenEmbedded.setStyleName(BaseTheme.BUTTON_LINK);
        valo_OpenEmbedded.addStyleName(FocXMLGuiComponentStatic.STYLE_NO_PRINT);
        valo_OpenEmbedded.addStyleName(FocXMLGuiComponentStatic.STYLE_HAND_POINTER_ON_HOVER);
        valo_OpenEmbedded.setDescription("Open");
        FocXMLGuiComponentStatic.setCaptionMargin_Zero(valo_OpenEmbedded);

        valo_OpenEmbedded.addClickListener(new MouseEvents.ClickListener() {

            @Override//  ww w.java2  s  . c  om
            public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                openClickListenerContent();
            }
        });
    }
    return valo_OpenEmbedded;
}