com.vaadin.server.ClassResource Java Examples

The following examples show how to use com.vaadin.server.ClassResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextMenuUI.java    From context-menu with Apache License 2.0 6 votes vote down vote up
private void addTree(VerticalLayout layout) {
    TreeData<String> data = new TreeData<>();
    data.addItem(null, "Dad");
    data.addItem("Dad", "Daughter");
    data.addItem("Daughter", "Granddaughter");
    data.addItem("Dad", "Son");
    data.addItem("Daughter", "Grandson");

    Tree<String> tree = new Tree<>("A family", data);
    TreeContextMenu<String> treeContextMenu = new TreeContextMenu<>(tree);
    treeContextMenu.addTreeContextMenuListener(e -> {
        treeContextMenu.removeItems();
        //The path is /resources/images/kitten.jpg
        ClassResource ico = new ClassResource("/images/kitten.jpg");
        treeContextMenu.addItem("Who?",ico, menuItem -> Notification.show(e.getItem()));
    });

    layout.addComponent(tree);
}
 
Example #2
Source File: TestGenerationView.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
@Override
public void sourceGenerationExecuted(final Source source, final TestGenerationType generationType, final long testsCreated) {
    UI.getCurrent().access(() -> {
        Item item = resultsTable.getItem(source);
        if (testsCreated == 0 || item == null)
            return;

        String column = (generationType.equals(TestGenerationType.AutoGenerated) ? "Automatic" : "Manual");
        Property<Link> statusProperty = item.getItemProperty(column);
        String fileName;
        if (generationType.equals(TestGenerationType.AutoGenerated)) {
            fileName = CacheUtils.getSourceAutoTestFile(RDFUnitDemoSession.getBaseDir() + "tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new FileResource(new File(fileName))));
        } else {
            fileName = CacheUtils.getSourceManualTestFile("/org/aksw/rdfunit/tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new ClassResource(fileName)));
        }
        CommonAccessUtils.pushToClient();
    });

}
 
Example #3
Source File: ClassPathIconProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Resource getIconResource(String iconPath) {
    Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty");

    String icon = iconPath.substring(CLASSPATH_PREFIX.length());
    return new ClassResource(icon);
}
 
Example #4
Source File: ContextMenuUI.java    From context-menu with Apache License 2.0 4 votes vote down vote up
private void fillMenu(ContextMenu menu) {
    final MenuItem item = menu.addItem("Checkable \u00d6",
            e -> Notification.show("checked: " + e.isChecked())
    );
    item.setCheckable(true);
    item.setChecked(true);

    MenuItem item2 = menu.addItem("Disabled",new ClassResource("/images/tiger.jpg"),
            e -> Notification.show("disabled")
    );
    item2.setDescription("Disabled item");
    item2.setEnabled(false);

    MenuItem item3 = menu.addItem("Invisible",
            e -> Notification.show("invisible")
    );
    item3.setVisible(false);

    menu.addSeparator();

    //The path is /resources/images/kitten.jpg
    ClassResource ico = new ClassResource("/images/kitten.jpg");
    MenuItem item4 = menu.addItem("Icon + Description + <b>HTML</b>",ico,
            e -> Notification.show("icon")
    );
    item4.setDescription("Test tooltip");
    but3.addClickListener(e -> item4.setDescription(""));
    MenuItem item5 = menu.addItem("Custom stylename",
            e -> Notification.show("stylename")
    );
    //The path is /webapp/VAADIN/themes/contextmenu/images
    ThemeResource resource = new ThemeResource("images/cat.jpg");
    item5.setIcon(resource);

    item5.setStyleName("teststyle");

    MenuItem item6 = menu.addItem("Submenu");
    item6.addItem("Subitem", VaadinIcons.OPTION, e -> Notification.show("SubItem"));
    item6.addSeparator();
    item6.addItem("Subitem",new ThemeResource("images/cat2.jpg"), e -> Notification.show("SubItem"))
            .setDescription("Test");
    MenuItem openWindowNotification = item6.addItem(
            "Open Window + Notification",
            e -> Notification.show("Open Vaadin.com"));
    new BrowserWindowOpener("https://vaadin.com").extend(openWindowNotification);

    MenuItem openWindowDummy = item6.addItem("Open Google");
    new BrowserWindowOpener("https://google.com").extend(openWindowDummy);

    new BrowserWindowOpener("https://yahoo.com")
            .extend(item6.addItem("SubMenu2").addItem("Yahoo!"));
}