Search in sources :

Example 16 with Link

use of com.vaadin.ui.Link in project Activiti by Activiti.

the class DeploymentDetailPanel method addResourceLinks.

protected void addResourceLinks() {
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId());
    // small nr of elements, so we can do it in-memory
    Collections.sort(resourceNames);
    if (!resourceNames.isEmpty()) {
        Label resourceHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_RESOURCES));
        resourceHeader.setWidth("95%");
        resourceHeader.addStyleName(ExplorerLayout.STYLE_H3);
        resourceHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        addDetailComponent(resourceHeader);
        // resources
        VerticalLayout resourceLinksLayout = new VerticalLayout();
        resourceLinksLayout.setSpacing(true);
        resourceLinksLayout.setMargin(true, false, false, false);
        addDetailComponent(resourceLinksLayout);
        for (final String resourceName : resourceNames) {
            StreamResource.StreamSource streamSource = new StreamSource() {

                public InputStream getStream() {
                    return repositoryService.getResourceAsStream(deployment.getId(), resourceName);
                }
            };
            Link resourceLink = new Link(resourceName, new StreamResource(streamSource, resourceName, ExplorerApp.get()));
            resourceLinksLayout.addComponent(resourceLink);
        }
    }
}
Also used : StreamSource(com.vaadin.terminal.StreamResource.StreamSource) StreamResource(com.vaadin.terminal.StreamResource) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) VerticalLayout(com.vaadin.ui.VerticalLayout) Link(com.vaadin.ui.Link)

Example 17 with Link

use of com.vaadin.ui.Link in project Activiti by Activiti.

the class ImageAttachmentRenderer method getDetailComponent.

@Override
public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);
    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
    String mimeType = extractMineType(attachment.getType());
    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()), mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);
    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);
    Label fullSizeLabel = new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);
    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
        link = new Link(attachment.getName(), res);
    }
    link.setIcon(Images.RELATED_CONTENT_PICTURE);
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    LinkLayout.addComponent(link);
    return verticalLayout;
}
Also used : StreamResource(com.vaadin.terminal.StreamResource) TaskService(org.activiti.engine.TaskService) InputStream(java.io.InputStream) Label(com.vaadin.ui.Label) StreamResource(com.vaadin.terminal.StreamResource) ExternalResource(com.vaadin.terminal.ExternalResource) Resource(com.vaadin.terminal.Resource) VerticalLayout(com.vaadin.ui.VerticalLayout) Embedded(com.vaadin.ui.Embedded) ExternalResource(com.vaadin.terminal.ExternalResource) InputStreamStreamSource(org.activiti.explorer.ui.util.InputStreamStreamSource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 18 with Link

use of com.vaadin.ui.Link in project Activiti by Activiti.

the class UrlAttachmentRenderer method getOverviewComponent.

public Component getOverviewComponent(final Attachment attachment, final RelatedContentComponent parent) {
    // instead of showing popup with details.
    if (attachment.getDescription() != null && !"".equals(attachment.getDescription())) {
        Button attachmentLink = new Button(attachment.getName());
        attachmentLink.addStyleName(Reindeer.BUTTON_LINK);
        attachmentLink.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                parent.showAttachmentDetail(attachment);
            }
        });
        return attachmentLink;
    } else {
        return new Link(attachment.getName(), new ExternalResource(attachment.getUrl()));
    }
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ExternalResource(com.vaadin.terminal.ExternalResource) ClickListener(com.vaadin.ui.Button.ClickListener) Link(com.vaadin.ui.Link)

Example 19 with Link

use of com.vaadin.ui.Link in project charts by vaadin.

the class ChartsDemoUI method init.

@Override
protected void init(VaadinRequest request) {
    initGATracker();
    tabSheet = new TabSheet();
    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
        }
    });
    tabSheet.setSizeFull();
    tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    Link homepage = new Link("Home page", new ExternalResource("https://vaadin.com/add-ons/charts"));
    Link javadoc = new Link("JavaDoc", new ExternalResource("http://demo.vaadin.com/javadoc/com.vaadin/vaadin-charts/" + getVersion() + "/"));
    Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/-/part/charts/charts-overview.html"));
    Label version = new Label("Version " + getVersion());
    version.addStyleName("version");
    HorizontalLayout links = new HorizontalLayout(homepage, javadoc, manual);
    links.setSpacing(true);
    links.addStyleName("links");
    final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(tabSheet);
    horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
    horizontalSplitPanel.addStyleName("main-layout");
    ChartOptions.get().setTheme(new ValoLightTheme());
    themeSelector = new ComboBox("Charts Theme:");
    themeSelector.addStyleName("theme-selector");
    themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
    themeSelector.setTextInputAllowed(false);
    com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
    Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
    com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
    mapThemes.put(themes[0], "Valo Light");
    mapThemes.put(themes[1], "Valo Dark");
    mapThemes.put(themes[2], "Vaadin");
    mapThemes.put(themes[3], "HighCharts");
    mapThemes.put(themes[4], "Grid");
    mapThemes.put(themes[5], "Gray");
    mapThemes.put(themes[6], "Skies");
    themeSelector.setEmptySelectionAllowed(false);
    themeSelector.setItems(themes);
    themeSelector.setSelectedItem(defaultTheme);
    themeSelector.setItemCaptionGenerator(mapThemes::get);
    themeSelector.addSelectionListener(e -> {
        ChartOptions.get().setTheme(e.getValue());
    });
    final HierarchicalContainer container = getContainer();
    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(false);
    Label logo = new Label("Vaadin Charts");
    logo.setWidth("100%");
    logo.addStyleName("h3");
    logo.addStyleName("logo");
    TextField filterField = new TextField();
    filterField.setPlaceholder("Filter examples");
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.addStyleName("filter");
    filterField.setWidth("100%");
    filterField.addValueChangeListener(e -> {
        container.removeAllContainerFilters();
        String text = e.getValue();
        if (text != null && !text.isEmpty()) {
            expandForFiltering();
            container.addContainerFilter("searchName", text, true, false);
        } else {
            restoreExpandedStates();
        }
    });
    tree = new Tree();
    tree.setImmediate(true);
    tree.setContainerDataSource(container);
    tree.setItemCaptionPropertyId("displayName");
    tree.setNullSelectionAllowed(false);
    tree.setWidth("100%");
    tree.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value instanceof Class) {
                updateTabSheet((Class) value);
            } else {
                tree.expandItemsRecursively(value);
            }
        }
    });
    Button feedback = new Button("Got feedback?", FontAwesome.COMMENTING_O);
    feedback.addStyleName("feedback-button");
    feedback.addStyleName(ValoTheme.BUTTON_PRIMARY);
    feedback.addStyleName(ValoTheme.BUTTON_TINY);
    feedback.addClickListener(e -> {
        getUI().addWindow(new FeedbackForm());
    });
    content.addComponents(logo, links, feedback, filterField, tree, version);
    content.setComponentAlignment(feedback, Alignment.MIDDLE_CENTER);
    horizontalSplitPanel.setFirstComponent(content);
    selectItem();
    Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
            selectItem();
        }
    });
    setContent(new CssLayout() {

        {
            setSizeFull();
            addComponent(horizontalSplitPanel);
            addComponent(themeSelector);
        }
    });
    if (tracker != null) {
        tracker.trackPageview("/charts");
    }
}
Also used : SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) HashMap(java.util.HashMap) Label(com.vaadin.ui.Label) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) Page(com.vaadin.server.Page) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) Tree(com.vaadin.v7.ui.Tree) Property(com.vaadin.v7.data.Property) ComboBox(com.vaadin.ui.ComboBox) GridTheme(com.vaadin.addon.charts.themes.GridTheme) ExternalResource(com.vaadin.server.ExternalResource) TabSheet(com.vaadin.ui.TabSheet) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) ValoTheme(com.vaadin.ui.themes.ValoTheme) Theme(com.vaadin.annotations.Theme) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) GridTheme(com.vaadin.addon.charts.themes.GridTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HierarchicalContainer(com.vaadin.v7.data.util.HierarchicalContainer) Link(com.vaadin.ui.Link)

Example 20 with Link

use of com.vaadin.ui.Link in project opennms by OpenNMS.

the class SimpleIframeInVaadinApplication method init.

/* (non-Javadoc)
	 * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest)
	 */
@Override
public void init(VaadinRequest request) {
    if (iframePageUrl == null)
        throw new RuntimeException("iframePageUrl must not be null");
    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);
    addHeader(request);
    // add diagnostic page links
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);
        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            // adds space between links
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML);
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }
    ExternalResource iframPageResource = new ExternalResource(iframePageUrl);
    BrowserFrame browser = new BrowserFrame("", iframPageResource);
    browser.setWidth("100%");
    browser.setHeight("100%");
    m_rootLayout.addComponent(browser);
    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(browser, 1.0f);
}
Also used : BrowserFrame(com.vaadin.ui.BrowserFrame) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

Link (com.vaadin.ui.Link)36 ExternalResource (com.vaadin.server.ExternalResource)24 VerticalLayout (com.vaadin.ui.VerticalLayout)21 Label (com.vaadin.ui.Label)18 HorizontalLayout (com.vaadin.ui.HorizontalLayout)8 PostConstruct (javax.annotation.PostConstruct)7 ExternalResource (com.vaadin.terminal.ExternalResource)5 Button (com.vaadin.ui.Button)4 StreamResource (com.vaadin.terminal.StreamResource)3 TextField (com.vaadin.ui.TextField)3 ComboBox (com.vaadin.ui.ComboBox)2 Embedded (com.vaadin.ui.Embedded)2 GridLayout (com.vaadin.ui.GridLayout)2 HashMap (java.util.HashMap)2 Secured (org.springframework.security.access.annotation.Secured)2 AnnisUser (annis.libgui.AnnisUser)1 InstanceConfig (annis.libgui.InstanceConfig)1 LoginDataLostException (annis.libgui.LoginDataLostException)1 VisualizerInput (annis.libgui.visualizers.VisualizerInput)1 VisualizerPlugin (annis.libgui.visualizers.VisualizerPlugin)1