Example usage for com.vaadin.server ExternalResource ExternalResource

List of usage examples for com.vaadin.server ExternalResource ExternalResource

Introduction

In this page you can find the example usage for com.vaadin.server ExternalResource ExternalResource.

Prototype

public ExternalResource(String sourceURL) 

Source Link

Document

Creates a new download component for downloading directly from given URL.

Usage

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initContactSection() {
    Label header = createProfileHeader(i18nManager.getMessage(Messages.PROFILE_CONTACT));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    GridLayout contactLayout = createInfoSectionLayout(2, 4);
    // Email//from   w  w  w .  ja  va  2 s.c o m
    if (!editable && isDefined(user.getEmail())) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail());
    } else if (editable) {
        emailField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField,
                user.getEmail());
    }

    // Phone
    if (!editable && isDefined(phone)) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone);
    } else if (editable) {
        phoneField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone);
    }

    // Twitter
    if (!editable && isDefined(twitterName)) {
        Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName));
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink);
    } else if (editable) {
        twitterField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField,
                twitterName);
    }

    // Skype
    if (!editable && isDefined(skypeId)) {
        // The skype entry shows the name + skype icon, laid out in a small grid
        GridLayout skypeLayout = new GridLayout(2, 1);
        skypeLayout.setSpacing(true);
        skypeLayout.setSizeUndefined();

        Label skypeIdLabel = new Label(skypeId);
        skypeIdLabel.setSizeUndefined();
        skypeLayout.addComponent(skypeIdLabel);

        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout);
    } else if (editable) {
        skypeField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField,
                skypeId);
    }
}

From source file:com.klwork.explorer.web.MyNavigationUI.java

License:Apache License

/**
 * Exception on action//from w w  w . ja v  a  2 s. co m
 */
@Override
public void error(com.vaadin.server.ErrorEvent event) {
    // connector event
    if (event.getThrowable().getCause() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable().getCause();
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);

        // Cleanup view. Now Vaadin ignores errors and always shows the view.  :-(
        // since beta10
        setContent(null);
        return;
    }

    // Error on page load. Now it doesn't work. User sees standard error page.
    if (event.getThrowable() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable();

        Label label = new Label(exception.getMessage());
        label.setWidth(-1, Unit.PERCENTAGE);

        Link goToMain = new Link("Go to main", new ExternalResource("/"));

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(label);
        layout.addComponent(goToMain);
        layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.setSizeFull();
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

        setContent(mainLayout);
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);
        return;
    }

    DefaultErrorHandler.doDefault(event);
}

From source file:com.kohmiho.mpsr.MPSRUI.java

private void initMPSRTable() {

    mpsrTable.setContainerDataSource(project);
    mpsrTable.setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
    mpsrTable.setVisibleColumns(VISIBLE_COLUMNS);
    mpsrTable.setColumnHeaders(COLUMN_HEADERS);

    mpsrTable.setSelectable(true);/*from   ww w  . ja v a  2s .  c o  m*/
    mpsrTable.setImmediate(true);
    mpsrTable.setColumnReorderingAllowed(true);

    mpsrTable.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {

            if (null != mpsrTable.getValue()) {
                pdflink.setResource(new ExternalResource(
                        PDFGenerator.class.getSimpleName() + "?MPSR_ID=" + mpsrTable.getValue().toString()));
                // wordLink.setResource(new
                // ExternalResource(DocxGenerator.class.getSimpleName() +
                // "?MPSR_ID="
                // + mpsrTable.getValue().toString()));
            } else {
                pdflink.setResource(null);
                // wordLink.setResource(null);
            }

            if (null == mpsrTable.getValue() || null == tree.getValue()) {
                splitPanel2.setSecondComponent(welcomePage);
                return;
            }

            setEditPage();

            mpsrTable.refreshRowCache();

            // TODO:
            form_7_1.setFieldsVisible(false);
            form_7_2.setFieldsVisible(false);
            form_8_2_1.setFieldsVisible(false);
            form_8_2_2.setFieldsVisible(false);
            form_9_1.setFieldsVisible(false);
            form_9_2.setFieldsVisible(false);
            form_appendix.setFieldsVisible(false);
            form_attach.setFieldsVisible(false);

            form_7_1.unSelectTable();
            form_7_2.unSelectTable();
            form_8_2_1.unSelectTable();
            form_8_2_2.unSelectTable();
            form_9_1.unSelectTable();
            form_9_2.unSelectTable();
            form_appendix.unSelectTable();
            form_attach.unSelectTable();
        }
    });

}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile/*  www. ja  v a2  s . c om*/
 * @param cover
 * @return
 */
private Component createPlayImage(final AudioFile audioFile, ExternalResource cover) {

    AbsoluteLayout absoluteLayout = new AbsoluteLayout();
    absoluteLayout.setWidth("120px");
    absoluteLayout.setHeight("120px");
    absoluteLayout.addComponent(createImageCover(cover));

    final Image play = createImageCover(
            new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png"));
    play.setWidth("50px");
    play.setHeight("50px");
    play.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -5184601350921707969L;

        @Override
        public void click(ClickEvent event) {
            MusicPlayerPanel musicPanel = MusicPlayerPanel.getInstance(getPlayerLayout());

            watched.addObserver(musicPanel);

            MusicPlayerPanel.setAudio(audioFile);
            MusicPlayerPanel.runDefaultSetup();

            if (isPlay.equals(false)) {
                watched.setValue(isPlay = true);
                play.setSource(new ExternalResource(
                        "http://icons.iconarchive.com/icons/icons-land/play-stop-pause/256/Pause-Disabled-icon.png"));
            } else {
                watched.setValue(isPlay = false);
                play.setSource(
                        new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png"));
            }

        }
    });

    absoluteLayout.addComponent(play, "top: 30px; left: 30px;");

    return absoluteLayout;
}

From source file:com.mycollab.community.shell.view.components.AboutWindow.java

License:Open Source License

public AboutWindow() {

    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("",
            new ExternalResource(StorageFactory.generateAssetRelativeLink(WebResourceIds._about)));
    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion()));
    Label javaNameLbl = new Label(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version")));
    Label homeFolderLbl = new Label("Home folder: " + FileUtils.getHomeFolder().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    Label osLbl = new Label(
            String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication()));
    osLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
            .appendChild(new A("https://www.mycollab.com").appendText("MyCollab"))
            .appendChild(new Text(". Open source under GPL license"));
    Label licenseLbl = new Label(licenseDiv.write(), ContentMode.HTML);
    Label copyRightLbl = new Label(String.format("© %s - %s MyCollab Ltd. All rights reserved", "2011",
            new GregorianCalendar().get(Calendar.YEAR) + ""), ContentMode.HTML);
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl)
            .withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}

From source file:com.mycollab.mobile.module.crm.ui.RelatedReadItemField.java

License:Open Source License

@Override
protected Component initContent() {
    try {/*from w  w w. j  ava 2s  . com*/
        final String type = (String) PropertyUtils.getProperty(RelatedReadItemField.this.bean, "type");
        if (type == null || type.equals("")) {
            return new Label("");
        }

        final Integer typeid = (Integer) PropertyUtils.getProperty(bean, "typeid");
        if (typeid == null) {
            return new Label("");
        }

        Resource relatedLink = null;
        String relateItemName = null;

        if ("Account".equals(type)) {
            AccountService accountService = AppContextUtil.getSpringBean(AccountService.class);
            final SimpleAccount account = accountService.findById(typeid, MyCollabUI.getAccountId());
            if (account != null) {
                relateItemName = account.getAccountname();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/account.png"));
            }
        } else if ("Campaign".equals(type)) {
            CampaignService campaignService = AppContextUtil.getSpringBean(CampaignService.class);
            final SimpleCampaign campaign = campaignService.findById(typeid, MyCollabUI.getAccountId());
            if (campaign != null) {
                relateItemName = campaign.getCampaignname();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/campaign.png"));
            }
        } else if ("Contact".equals(type)) {
            ContactService contactService = AppContextUtil.getSpringBean(ContactService.class);
            final SimpleContact contact = contactService.findById(typeid, MyCollabUI.getAccountId());
            if (contact != null) {
                relateItemName = contact.getContactName();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/contact.png"));

            }
        } else if ("Lead".equals(type)) {
            LeadService leadService = AppContextUtil.getSpringBean(LeadService.class);
            final SimpleLead lead = leadService.findById(typeid, MyCollabUI.getAccountId());
            if (lead != null) {
                relateItemName = lead.getLeadName();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/lead.png"));
            }
        } else if ("Opportunity".equals(type)) {
            OpportunityService opportunityService = AppContextUtil.getSpringBean(OpportunityService.class);
            final SimpleOpportunity opportunity = opportunityService.findById(typeid,
                    MyCollabUI.getAccountId());
            if (opportunity != null) {
                relateItemName = opportunity.getOpportunityname();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/opportunity.png"));

            }
        } else if ("Case".equals(type)) {
            CaseService caseService = AppContextUtil.getSpringBean(CaseService.class);
            final SimpleCase cases = caseService.findById(typeid, MyCollabUI.getAccountId());
            if (cases != null) {
                relateItemName = cases.getSubject();
                relatedLink = new ExternalResource(
                        StorageFactory.generateAssetRelativeLink("icons/16/crm/case.png"));
            }
        }

        Button related = new Button(relateItemName);
        if (relatedLink != null)
            related.setIcon(relatedLink);

        if (relatedLink != null) {
            return related;
        } else {
            return new Label("");
        }

    } catch (Exception e) {
        return new Label("");
    }
}

From source file:com.mycollab.module.crm.view.activity.ActivityRootView.java

License:Open Source License

private void buildComponents() {
    activityTabs.addTab(constructCalendarView(), "calendar",
            UserUIContext.getMessage(ActivityI18nEnum.TAB_CALENDAR_TITLE),
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/22/crm/calendar.png")));

    activityTabs.addTab(constructActivityListView(), "activities",
            UserUIContext.getMessage(ActivityI18nEnum.TAB_ACTIVITY_TITLE),
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/22/crm/activitylist.png")));

    activityTabs.addSelectedTabChangeListener(selectedTabChangeEvent -> {
        Tab tab = ((VerticalTabsheet) selectedTabChangeEvent.getSource()).getSelectedTab();
        String caption = tab.getCaption();

        if (UserUIContext.getMessage(ActivityI18nEnum.TAB_CALENDAR_TITLE).equals(caption)) {
            calendarPresenter.go(ActivityRootView.this, new ActivityScreenData.GotoCalendar());
        } else if (UserUIContext.getMessage(ActivityI18nEnum.TAB_ACTIVITY_TITLE).equals(caption)) {
            ActivitySearchCriteria criteria = new ActivitySearchCriteria();
            criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
            eventPresenter.go(ActivityRootView.this, new ActivityScreenData.GotoActivityList(criteria));
        }//from  w w  w .j av  a2  s . c  o m
    });
}

From source file:com.mycollab.module.crm.view.lead.LeadTableDisplay.java

License:Open Source License

public LeadTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(AppContextUtil.getSpringBean(LeadService.class), SimpleLead.class, viewId, requiredColumn,
            displayColumns);//  w  ww  .  j  ava2 s . c  om

    this.addGeneratedColumn("selected", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        final CheckBoxDecor cb = new CheckBoxDecor("", lead.isSelected());
        cb.setImmediate(true);
        cb.addValueChangeListener(valueChangeEvent -> {
            fireSelectItemEvent(lead);
            fireTableEvent(new TableClickEvent(LeadTableDisplay.this, lead, "selected"));
        });
        lead.setExtraData(cb);
        return cb;
    });

    this.addGeneratedColumn("leadName", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);

        LabelLink b = new LabelLink(lead.getLeadName(),
                CrmLinkBuilder.generateLeadPreviewLinkFull(lead.getId()));
        if ("Dead".equals(lead.getStatus()) || "Converted".equals(lead.getStatus())) {
            b.addStyleName(WebThemes.LINK_COMPLETED);
        }
        b.setDescription(CrmTooltipGenerator.generateTooltipLead(UserUIContext.getUserLocale(), lead,
                MyCollabUI.getSiteUrl(), UserUIContext.getUserTimeZone()));
        return b;
    });

    this.addGeneratedColumn("assignUserFullName", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        return new UserLink(lead.getAssignuser(), lead.getAssignUserAvatarId(), lead.getAssignUserFullName());
    });

    this.addGeneratedColumn("email", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        Link l = new Link();
        l.setResource(new ExternalResource("mailto:" + lead.getEmail()));
        l.setCaption(lead.getEmail());
        return l;
    });

    this.addGeneratedColumn("status", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        return ELabel.i18n(lead.getStatus(), LeadStatus.class);
    });

    this.addGeneratedColumn("industry", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        return ELabel.i18n(lead.getIndustry(), AccountIndustry.class);
    });

    this.addGeneratedColumn("source", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        return ELabel.i18n(lead.getSource(), OpportunityLeadSource.class);
    });

    this.addGeneratedColumn("website", (source, itemId, columnId) -> {
        final SimpleLead lead = getBeanByIndex(itemId);
        if (lead.getWebsite() != null) {
            return new UrlLink(lead.getWebsite());
        } else {
            return new Label("");
        }
    });

    this.setWidth("100%");
}

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;/*from w w  w .ja  v  a  2  s. com*/
    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))));
    } 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;//from   www  .  j  a va2 s  .  c  om
    if (!StringUtils.isBlank(account.getAvatarid())) {
        wrapper = new Image(null, new ExternalResource(
                StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), account.getAvatarid(), 100)));
    } else {
        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;
}