Java 类com.vaadin.server.Resource 实例源码

项目:vaadin-fluent-api    文件:FluentMediaTest.java   
@Test
public void testAudio() {
    final Resource audioResource = new ExternalResource(
            "http://mirrors.creativecommons.org/ccmixter/contrib/Wired/The%20Rapture%20-%20Sister%20Saviour%20(Blackstrobe%20Remix).mp3");
    FAudio audio = new FAudio().withAltText("alt")
                               .withAutoplay(true)
                               .withCaption("My audio")
                               .withHtmlContentAllowed(true)
                               .withMuted(true)
                               .withLoop(true)
                               .withPreload(PreloadMode.METADATA)
                               .withSource(audioResource)
                               .withShowControls(true);

    assertEquals("alt", audio.getAltText());
    assertEquals("My audio", audio.getCaption());
    assertTrue(audio.isAutoplay());
    assertTrue(audio.isHtmlContentAllowed());
    assertTrue(audio.isShowControls());
    assertTrue(audio.isLoop());
    assertTrue(audio.isMuted());
    assertEquals(PreloadMode.METADATA, audio.getPreload());
    assertEquals(audioResource, audio.getSources().get(0));

}
项目:vaadin-combobox-multiselect    文件:ComboBoxMultiselect.java   
/**
 * Initialize the ComboBoxMultiselect with default settings and register client to server RPC implementation.
 */
private void init() {
    registerRpc(this.rpc);
    registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));

    addDataGenerator((final T data, final JsonObject jsonObject) -> {
        String caption = getItemCaptionGenerator().apply(data);
        if (caption == null) {
            caption = "";
        }
        jsonObject.put(DataCommunicatorConstants.NAME, caption);
        final String style = this.itemStyleGenerator.apply(data);
        if (style != null) {
            jsonObject.put(ComboBoxMultiselectConstants.STYLE, style);
        }
        final Resource icon = getItemIconGenerator().apply(data);
        if (icon != null) {
            final String iconUrl = ResourceReference.create(icon, ComboBoxMultiselect.this, null)
                    .getURL();
            jsonObject.put(ComboBoxMultiselectConstants.ICON, iconUrl);
        }
    });
}
项目:sidemenu-addon    文件:DemoUI.java   
private void setUser(String name, Resource icon) {
    sideMenu.setUserName(name);
    sideMenu.setUserIcon(icon);

    sideMenu.clearUserMenu();
       sideMenu.addUserMenuItem("Settings", VaadinIcons.WRENCH, () -> Notification.show("Showing settings", Type.TRAY_NOTIFICATION));
       sideMenu.addUserMenuItem("Sign out", () -> Notification.show("Logging out..", Type.TRAY_NOTIFICATION));

    sideMenu.addUserMenuItem("Hide logo", () -> {
        if (!logoVisible) {
            sideMenu.setMenuCaption(menuCaption, logo);
        } else {
            sideMenu.setMenuCaption(menuCaption);
        }
        logoVisible = !logoVisible;
    });
}
项目:metasfresh-procurement-webui    文件:LoginView.java   
private Resource getLogoResource()
{
    if (logoFilename == null)
    {
        return Constants.RESOURCE_Logo;
    }
    if (logoFilename.trim().isEmpty())
    {
        return Constants.RESOURCE_Logo;
    }

    final File logoFile = new File(logoFilename.trim());
    if (!logoFile.isFile() || !logoFile.canRead())
    {
        logger.warn("Using default log because {} does not exist or it's not readable", logoFile);
        return Constants.RESOURCE_Logo;
    }

    return new FileResource(logoFile);
}
项目:cuba    文件:CubaSideMenu.java   
protected void markMenuStructureAsDirty() {
    markAsDirty();
    this.structureChanged = true;

    for (String menuIconsKey : menuIconResourceKeys) {
        Resource resource = getResource(menuIconsKey);
        menuIconsKeyMapper.remove(resource);
        setResource(menuIconsKey, null);
    }

    menuItemIdMapper.removeAll();
    menuIconsKeyMapper.removeAll();

    // all badges will be sent to client with items
    badgeUpdates.clear();
}
项目:cuba    文件:WebComponentsHelper.java   
/**
 * @deprecated use the {@link Icons#get(com.haulmont.cuba.gui.icons.Icons.Icon)} bean
 * and {@link com.haulmont.cuba.gui.icons.CubaIcon} icon set instead
 */
@Deprecated
@Nullable
public static Resource getFontIconResource(String fontIcon)
        throws NoSuchFieldException, IllegalAccessException {
    if (StringUtils.isNotEmpty(fontIcon)) {
        String fontIconName = "font-awesome-icon";
        String fontIconField;
        if (fontIcon.contains(":")) {
            fontIconName = StringUtils.substring(fontIcon, 0, fontIcon.indexOf(":"));
            fontIconField = StringUtils.substring(fontIcon, fontIcon.indexOf(":") + 1);
        } else {
            fontIconField = fontIcon;
        }
        return getFontIconResource(fontIconName, fontIconField);
    }
    return null;
}
项目:cuba    文件:WebGroupTable.java   
protected CubaGroupTable createGroupTableComponent() {
    return new CubaGroupTable() {
        @Override
        @SuppressWarnings({"unchecked"})
        public Resource getItemIcon(Object itemId) {
            return WebGroupTable.this.getItemIcon(itemId);
        }

        @Override
        protected boolean changeVariables(Map<String, Object> variables) {
            boolean b = super.changeVariables(variables);
            b = handleSpecificVariables(variables) || b;
            return b;
        }

        @Override
        public void groupBy(Object[] properties) {
            groupBy(properties, rerender);
        }
    };
}
项目:cuba    文件:WebAbstractTable.java   
@SuppressWarnings("unchecked")
protected Resource getItemIcon(Object itemId) {
    if (iconProvider == null) {
        return null;
    }
    E item = (E) datasource.getItem(itemId);
    if (item == null) {
        return null;
    }
    String resourceUrl = iconProvider.getItemIcon(item);
    if (StringUtils.isBlank(resourceUrl)) {
        return null;
    }
    // noinspection ConstantConditions
    if (!resourceUrl.contains(":")) {
        resourceUrl = "theme:" + resourceUrl;
    }
    return WebComponentsHelper.getResource(resourceUrl);
}
项目:cuba    文件:WebTable.java   
public WebTable() {
    component = new CubaTable() {
        @Override
        public Resource getItemIcon(Object itemId) {
            return WebTable.this.getItemIcon(itemId);
        }

        @Override
        protected boolean changeVariables(Map<String, Object> variables) {
            boolean b = super.changeVariables(variables);
            b = handleSpecificVariables(variables) || b;
            return b;
        }
    };
    initComponent(component);
}
项目:incubator-openaz    文件:PDPContainer.java   
@Override
public Class<?> getType(Object propertyId) {
       if (propertyId.equals(PROPERTY_ID)) {
           return String.class;
       }
       if (propertyId.equals(PROPERTY_NAME)) {
           return String.class;
       }
       if (propertyId.equals(PROPERTY_DESCRIPTION)) {
           return String.class;
       }
       if (propertyId.equals(PROPERTY_ICON)) {
           return Resource.class;
       }
       if (propertyId.equals(PROPERTY_STATUS)) {
           return String.class;
       }
       if (propertyId.equals(PROPERTY_POLICIES)) {
           return Set.class;
       }
       if (propertyId.equals(PROPERTY_PIPCONFIG)) {
           return Set.class;
       }
    return null;
}
项目:vaadin-combobox-multiselect    文件:ComboBoxMultiselect.java   
/**
 * Initialize the ComboBoxMultiselect with default settings and register client to server RPC implementation.
 */
private void init() {
    registerRpc(this.rpc);
    registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));

    addDataGenerator((final T data, final JsonObject jsonObject) -> {
        String caption = getItemCaptionGenerator().apply(data);
        if (caption == null) {
            caption = "";
        }
        jsonObject.put(DataCommunicatorConstants.NAME, caption);
        final String style = this.itemStyleGenerator.apply(data);
        if (style != null) {
            jsonObject.put(ComboBoxMultiselectConstants.STYLE, style);
        }
        final Resource icon = getItemIconGenerator().apply(data);
        if (icon != null) {
            final String iconUrl = ResourceReference.create(icon, ComboBoxMultiselect.this, null)
                    .getURL();
            jsonObject.put(ComboBoxMultiselectConstants.ICON, iconUrl);
        }
    });
}
项目:hawkbit    文件:SPUIButtonStyleSmallNoBorder.java   
/**
 * Decorate Button and return.
 * 
 * @param button
 *            as Button
 * @param style
 *            as String
 * @param setStyle
 *            as String
 * @param icon
 *            as resource
 * @return Button
 */
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    // Set Style
    if (null != style && setStyle) {
        button.addStyleName(style);
    }
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.addStyleName("button-no-border");
        button.setIcon(icon);
    }

    return button;
}
项目:hawkbit    文件:SPUITagButtonStyle.java   
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {

    button.setImmediate(true);
    button.addStyleName("generatedColumnPadding button-no-border" + " " + ValoTheme.BUTTON_BORDERLESS + " "
            + "button-tag-no-border");

    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.setIcon(icon);
    }
    return button;
}
项目:hawkbit    文件:SPUIButtonStyleTiny.java   
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_TINY);
    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}
项目:hawkbit    文件:SPUIButtonStyleSmall.java   
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}
项目:context-menu    文件:AbstractMenu.java   
@Override
public MenuItem addItemBefore(String caption, Resource icon,
        Command command, MenuItem itemToAddBefore) {
    if (caption == null) {
        throw new IllegalArgumentException("caption cannot be null");
    }

    MenuItem newItem = new MenuItemImpl(caption, icon, command);
    if (menuItems.contains(itemToAddBefore)) {
        int index = menuItems.indexOf(itemToAddBefore);
        menuItems.add(index, newItem);

    } else {
        menuItems.add(newItem);
    }

    markAsDirty();

    return newItem;
}
项目:context-menu    文件:MenuItemImpl.java   
private MenuItem addItemBefore(boolean separator, String caption,
        Resource icon, Command command, MenuItem itemToAddBefore)
        throws IllegalStateException {
    if (isCheckable()) {
        throw new IllegalStateException(
                "A checkable item cannot have children");
    }
    MenuItem newItem = null;

    if (hasChildren() && itsChildren.contains(itemToAddBefore)) {
        int index = itsChildren.indexOf(itemToAddBefore);
        newItem = new MenuItemImpl(this, caption, icon, command);
        itsChildren.add(index, newItem);
    } else {
        newItem = addItem(caption, icon, command);
    }

    markAsDirty();

    return newItem;
}
项目:sqlexplorer-vaadin    文件:QueryPanel.java   
public void addResultsTab(Component resultComponent, String title, Resource icon, int position) {
    Tab tab = resultsTabs.addTab(resultComponent, title, icon, position);

    tab.setClosable(true);

    resultsTabs.setSelectedTab(tab.getComponent());

    if (errorTab != null) {
        resultsTabs.removeTab(errorTab);
        errorTab = null;
    }

    if (maxNumberOfResultTabs > 0 && resultsTabs.getComponentCount() > maxNumberOfResultTabs) {
        resultsTabs.removeTab(resultsTabs.getTab(resultsTabs.getComponentCount() - 1));
    }

    if (icon == FontAwesome.STOP) {
        errorTab = tab;
    }
}
项目:mycollab    文件:MassUpdateWindow.java   
public MassUpdateWindow(String title, Resource iconResource, B initialValue, MassUpdateCommand<B> massUpdatePresenter) {
    super(title);
    this.withWidth("1000px").withResizable(false).withModal(true).withIcon(iconResource).withCenter();
    this.massUpdateCommand = massUpdatePresenter;
    this.beanItem = initialValue;

    this.contentLayout = new MassUpdateLayout();
    this.updateForm = new AdvancedEditBeanForm<>();

    this.contentLayout.addBody(this.updateForm);

    this.setContent(this.contentLayout);

    updateForm.setFormLayoutFactory(buildFormLayoutFactory());
    updateForm.setBeanFormFieldFactory(buildBeanFormFieldFactory());
    updateForm.setBean(beanItem);
}
项目:ilves    文件:Site.java   
/**
 * Gets getIcon corresponding to given localization key.
 * @param key The localization key.
 * @return The localized getIcon.
 */
public Resource getIcon(final String key) {
    if (PropertiesUtil.hasProperty("icon", key)) {
        final String value = PropertiesUtil.getProperty("icon", key).trim();
        if (value.startsWith("FontAwesome.")) {
            final String iconName = value.substring(value.indexOf('.') + 1);
            for (final FontAwesome icon : FontAwesome.values()) {
                if (icon.name().equals(iconName)) {
                    return icon;
                }
            }
            throw new IllegalArgumentException("No such icon in FontAwesome: " + iconName);
        } else {
            return new ThemeResource("icons/" + value + ".png");
        }

    }
    return new ThemeResource("icons/" + key + ".png");
}
项目:mycollab    文件:MilestoneComboBox.java   
public MilestoneComboBox() {
    super();
    this.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

    MilestoneSearchCriteria criteria = new MilestoneSearchCriteria();
    SimpleProject project = CurrentProjectVariables.getProject();
    if (project != null) {
        criteria.setProjectIds(new SetSearchField<>(project.getId()));
        MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
        List<SimpleMilestone> milestoneList = (List<SimpleMilestone>) milestoneService.findPageableListByCriteria(new BasicSearchRequest<>(criteria));
        Collections.sort(milestoneList, new MilestoneComparator());

        for (SimpleMilestone milestone : milestoneList) {
            this.addItem(milestone.getId());
            this.setItemCaption(milestone.getId(), StringUtils.trim(milestone.getName(), 25, true));
            Resource iconRes = ProjectAssetsUtil.getPhaseIcon(milestone.getStatus());
            this.setItemIcon(milestone.getId(), iconRes);
        }
    }
}
项目:holon-vaadin7    文件:AbstractSelectField.java   
/**
 * Set an explicit icon for given item.
 * @param item Item to set the caption for
 * @param icon Icon to set (not null)
 */
public void setItemIcon(ITEM item, Resource icon) {
    ObjectUtils.argumentNotNull(item, "Item must be not null");
    if (icon != null) {
        explicitItemIcons.put(item, icon);
    } else {
        explicitItemIcons.remove(item);
    }
}
项目:holon-vaadin7    文件:AbstractSelectField.java   
/**
 * Generate the select item icon for given <code>item</code>.
 * @param item Item to generate the icon for
 * @return Item icon (may be null)
 */
protected Resource generateItemIcon(ITEM item) {
    if (item != null) {
        return getItemIconGenerator().map(g -> g.getItemIcon(item)).orElse(getDefaultItemIcon(item));
    }
    return null;
}
项目:holon-vaadin7    文件:AbstractSelectField.java   
/**
 * Get the default select item icon for given <code>item</code>.
 * @param item Item
 * @return Default item icon
 */
protected Resource getDefaultItemIcon(ITEM item) {
    if (item != null) {
        return explicitItemIcons.get(item);
    }
    return null;
}
项目:material-theme-fw8    文件:NavigationItem.java   
public NavigationItem(Resource icon, String caption, Integer count) {
    String primaryStyleName = "md-naviitem";
    setPrimaryStyleName(primaryStyleName);

    this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
    this.caption.setPrimaryStyleName(primaryStyleName + "-caption");
    this.count.setPrimaryStyleName(primaryStyleName + "-count");

    setIcon(icon);
    setCaption(caption);
    setCount(count);

    addComponents(this.icon, this.caption, this.count);
}
项目:material-theme-fw8    文件:NavigationItem.java   
public void setIcon(Resource source) {
    if (source == null) {
        this.icon.setVisible(false);
    } else {
        this.icon.setVisible(true);
        this.icon.removeAllComponents();
        if (source instanceof FontIcon) {
            this.icon.addComponent(new Label(((FontIcon) source).getHtml(), ContentMode.HTML));
        } else {
            this.icon.addComponent(new Image(null, source));
        }
    }
}
项目:material-theme-fw8    文件:MDTextField.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:ToggleButtonGroup.java   
public Button addToggleButton(Resource icon) {
    Button button = new Button(icon);
    button.setPrimaryStyleName(Styles.Buttons.Toggle.BUTTON);
    button.addClickListener(event -> selectToggleButton(button));
    buttons.add(button);
    addComponent(button);
    return button;
}
项目:material-theme-fw8    文件:MDDateTimeField.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:MDTextFieldBox.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:MDDateField.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:MDTextAreaBox.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:MDComboBox.java   
public MDComboBox(String label, boolean light) {
    String primaryStyleName = light ? Styles.ComboBoxes.LIGHT : Styles.ComboBoxes.DARK;
    setPrimaryStyleName(primaryStyleName);

    this.label.setValue(label);
    this.label.setPrimaryStyleName(primaryStyleName + "-label");
    this.label.addStyleName(RESTING);
    this.label.setWidthUndefined();

    this.icon.setPrimaryStyleName(primaryStyleName + "-icon");

    this.field.setPrimaryStyleName(primaryStyleName + "-input");
    this.field.addFocusListener(event -> {
        addStyleName("focus");
        updateFloatingLabelPosition(this.field.getValue());
    });
    this.field.addBlurListener(event -> {
        removeStyleName("focus");
        updateFloatingLabelPosition(this.field.getValue());
    });
    this.field.addValueChangeListener(event -> {
        if (generator != null) {
            Resource itemIcon = generator.apply(event.getValue());
            if (itemIcon instanceof MaterialIcons) setIcon((MaterialIcons) itemIcon);
            else setIcon(itemIcon);
        }
        updateFloatingLabelPosition(event.getValue());
    });

    this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
    this.helper.setWidthUndefined();

    addComponents(this.label, icon, field, this.helper);

    setFloatingLabelEnabled(true);
}
项目:material-theme-fw8    文件:MDComboBox.java   
public void setDefaultIcon(Resource icon) {
    this.defaultIcon = icon;
    if (icon instanceof MaterialIcons) {
        setIcon((MaterialIcons) icon);
    } else {
        setIcon(icon);
    }
}
项目:material-theme-fw8    文件:MDComboBox.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:MDPasswordField.java   
public void setIcon(Resource source) {
    if (source == null) {
        hideIcon();
    } else {
        showImg(source);
    }
}
项目:material-theme-fw8    文件:DemoUI.java   
private void addNavItem(Resource icon, String caption, Component view) {
    NavigationItem item = new NavigationItem(icon, caption, view);
    item.addLayoutClickListener(event -> {
        navigationDrawer.selectNavigationItem(item);
        content.removeAllComponents();
        content.addComponent(item.getComponent());
    });
    navigationDrawer.addNavigationItem(item);
}
项目:md-stepper    文件:StepLabel.java   
@Override
public void setIcon(Resource icon) {
  if (icon != null && !(icon instanceof FontIcon)) {
    throw new IllegalArgumentException("Only FontIcons are allowed");
  }

  this.icon = (FontIcon) icon;
  markAsDirty();
}
项目:holon-vaadin    文件:AbstractSelectField.java   
/**
 * Set an explicit icon for given item.
 * @param item Item to set the caption for
 * @param icon Icon to set (not null)
 */
public void setItemIcon(ITEM item, Resource icon) {
    ObjectUtils.argumentNotNull(item, "Item must be not null");
    if (icon != null) {
        explicitItemIcons.put(item, icon);
    } else {
        explicitItemIcons.remove(item);
    }
}
项目:holon-vaadin    文件:AbstractSelectField.java   
/**
 * Generate the select item icon for given <code>item</code>.
 * @param item Item to generate the icon for
 * @return Item icon (may be null)
 */
protected Resource generateItemIcon(ITEM item) {
    if (item != null) {
        return getItemIconGenerator().map(g -> g.getItemIcon(item)).orElse(getDefaultItemIcon(item));
    }
    return null;
}