List of usage examples for com.vaadin.server ExternalResource ExternalResource
public ExternalResource(String sourceURL)
From source file:com.esofthead.mycollab.module.project.view.bug.UnresolvedBugsByPriorityWidget2.java
License:Open Source License
public void setSearchCriteria(final BugSearchCriteria searchCriteria) { this.bugSearchCriteria = searchCriteria; this.bodyContent.removeAllComponents(); final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final int totalCount = bugService.getTotalCount(searchCriteria); final List<GroupItem> groupItems = bugService.getPrioritySummary(searchCriteria); final BugPriorityClickListener listener = new BugPriorityClickListener(); if (!groupItems.isEmpty()) { for (final BugPriority priority : OptionI18nEnum.bug_priorities) { boolean isFound = false; for (final GroupItem item : groupItems) { if (priority.name().equals(item.getGroupid())) { isFound = true;//from w w w . jav a2 s.co m final HorizontalLayout priorityLayout = new HorizontalLayout(); priorityLayout.setSpacing(true); priorityLayout.setWidth("100%"); final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener); final Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByBugPriority(priority.name())); userLbl.setIcon(iconPriority); userLbl.setWidth("110px"); userLbl.setStyleName("link"); priorityLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount - item.getValue(), false); indicator.setWidth("100%"); priorityLayout.addComponent(indicator); priorityLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(priorityLayout); continue; } } if (!isFound) { final HorizontalLayout priorityLayout = new HorizontalLayout(); priorityLayout.setSpacing(true); priorityLayout.setWidth("100%"); final Button userLbl = new ButtonI18nComp(priority.name(), priority, listener); final Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByBugPriority(priority.name())); userLbl.setIcon(iconPriority); userLbl.setWidth("110px"); userLbl.setStyleName("link"); priorityLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false); indicator.setWidth("100%"); priorityLayout.addComponent(indicator); priorityLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(priorityLayout); } } } }
From source file:com.esofthead.mycollab.module.project.view.task.UnresolvedTaskByPriorityWidget.java
License:Open Source License
public void setSearchCriteria(final TaskSearchCriteria searchCriteria) { this.searchCriteria = searchCriteria; this.bodyContent.removeAllComponents(); final ProjectTaskService taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class); final int totalCount = taskService.getTotalCount(searchCriteria); final List<GroupItem> groupItems = taskService.getPrioritySummary(searchCriteria); final TaskPriorityClickListener listener = new TaskPriorityClickListener(); if (!groupItems.isEmpty()) { for (final TaskPriority priority : OptionI18nEnum.task_priorities) { boolean isFound = false; for (final GroupItem item : groupItems) { if (priority.name().equals(item.getGroupid())) { isFound = true;//from ww w . j a v a 2s . co m final HorizontalLayout priorityLayout = new HorizontalLayout(); priorityLayout.setSpacing(true); priorityLayout.setWidth("100%"); final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener); final Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByTaskPriority(priority.name())); userLbl.setIcon(iconPriority); userLbl.setWidth("110px"); userLbl.setStyleName("link"); priorityLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount - item.getValue(), false); indicator.setWidth("100%"); priorityLayout.addComponent(indicator); priorityLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(priorityLayout); } } if (!isFound) { final HorizontalLayout priorityLayout = new HorizontalLayout(); priorityLayout.setSpacing(true); priorityLayout.setWidth("100%"); final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener); final Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByTaskPriority(priority.name())); userLbl.setIcon(iconPriority); userLbl.setWidth("110px"); userLbl.setStyleName("link"); priorityLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false); indicator.setWidth("100%"); priorityLayout.addComponent(indicator); priorityLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(priorityLayout); } } } }
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildShortcutIconPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true)); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(AppContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); final Image favIconRes = new Image("", new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), billingAccount.getFaviconpath()))); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); final UploadField favIconUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override//from w w w . ja v a 2s. c o m protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { try { AccountFavIconService favIconService = AppContextUtil .getSpringBean(AccountFavIconService.class); BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData)); String newFavIconPath = favIconService.upload(AppContext.getUsername(), image, AppContext.getAccountId()); favIconRes.setSource(new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), newFavIconPath))); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException(e); } } else { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; favIconUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE)); favIconUploadField.addStyleName("upload-field"); favIconUploadField.setSizeUndefined(); favIconUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); favIconUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccount.setFaviconpath(null); billingAccountService.updateWithSession(billingAccount, AppContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } }); resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); resetButton.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(favIconUploadField, resetButton); rightPanel.with(favIconRes, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Favicon", layout); this.with(formContainer); }
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
private CustomLayout createFooter() { final CustomLayout footer = CustomLayoutExt.createLayout("footer"); Link companyLink = new Link("eSoftHead", new ExternalResource("http://www.esofthead.com")); companyLink.setTargetName("_blank"); footer.addComponent(companyLink, "company-url"); Calendar currentCal = Calendar.getInstance(); Label currentYear = new Label(String.valueOf(currentCal.get(Calendar.YEAR))); currentYear.setSizeUndefined();/*ww w .ja v a2s .c om*/ footer.addComponent(currentYear, "current-year"); HorizontalLayout footerRight = new HorizontalLayout(); footerRight.setSpacing(true); final Button sendFeedback = new Button("Feedback"); sendFeedback.setStyleName("link"); sendFeedback.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().addWindow(new FeedbackWindow()); } }); Link blogLink = new Link("Blog", new ExternalResource("https://www.mycollab.com/blog")); blogLink.setTargetName("_blank"); Link forumLink = new Link("Forum", new ExternalResource("http://forum.mycollab.com")); forumLink.setTargetName("_blank"); Link wikiLink = new Link("Knowledge Base", new ExternalResource("https://www.mycollab.com/help/")); wikiLink.setTargetName("_blank"); footerRight.addComponent(blogLink); footerRight.addComponent(forumLink); footerRight.addComponent(wikiLink); footerRight.addComponent(sendFeedback); footer.addComponent(footerRight, "footer-right"); return footer; }
From source file:com.esofthead.mycollab.shell.view.MainViewImpl.java
License:Open Source License
private MHorizontalLayout buildAccountMenuLayout() { accountLayout.removeAllComponents(); if (SiteConfiguration.isDemandEdition()) { // display trial box if user in trial mode SimpleBillingAccount billingAccount = AppContext.getBillingAccount(); if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) { if ("Free".equals(billingAccount.getBillingPlan().getBillingtype())) { Label informLbl = new Label( "<div class='informBlock'>FREE CHARGE<br>UPGRADE</div><div class='informBlock'>>></div>", ContentMode.HTML); informLbl.addStyleName("trialEndingNotification"); informLbl.setHeight("100%"); HorizontalLayout informBox = new HorizontalLayout(); informBox.addStyleName("trialInformBox"); informBox.setSizeFull(); informBox.addComponent(informLbl); informBox.setMargin(new MarginInfo(false, true, false, false)); informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { private static final long serialVersionUID = 1L; @Override/*from w ww. j a v a 2s. c om*/ public void layoutClick(LayoutClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT); } else { Label informLbl = new Label("", ContentMode.HTML); informLbl.addStyleName("trialEndingNotification"); informLbl.setHeight("100%"); HorizontalLayout informBox = new HorizontalLayout(); informBox.addStyleName("trialInformBox"); informBox.setSizeFull(); informBox.setMargin(new MarginInfo(false, true, false, false)); informBox.addComponent(informLbl); informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(LayoutClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT); Duration dur = new Duration(new DateTime(billingAccount.getCreatedtime()), new DateTime()); int daysLeft = dur.toStandardDays().getDays(); if (daysLeft > 30) { informLbl.setValue( "<div class='informBlock'>Trial<br></div><div class='informBlock'>>></div>"); // AppContext.getInstance().setIsValidAccount(false); } else { informLbl.setValue(String.format("<div class='informBlock'>Trial ending<br>%d days " + "left</div><div class='informBlock'>>></div>", 30 - daysLeft)); } } } } Label accountNameLabel = new Label(AppContext.getSubDomain()); accountNameLabel.addStyleName("subdomain"); accountLayout.addComponent(accountNameLabel); if (SiteConfiguration.isCommunityEdition()) { Button buyPremiumBtn = new Button("Upgrade to Pro edition", new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new AdWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { LicenseInfo licenseInfo = licenseResolver.getLicenseInfo(); if (licenseInfo != null) { if (licenseInfo.isExpired()) { Button buyPremiumBtn = new Button(AppContext.getMessage(LicenseI18nEnum.EXPIRE_NOTIFICATION), new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } else if (licenseInfo.isTrial()) { Duration dur = new Duration(new DateTime(), new DateTime(licenseInfo.getExpireDate())); int days = dur.toStandardDays().getDays(); Button buyPremiumBtn = new Button( AppContext.getMessage(LicenseI18nEnum.TRIAL_NOTIFICATION, days), new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } } } NotificationComponent notificationComponent = new NotificationComponent(); accountLayout.addComponent(notificationComponent); if (StringUtils.isBlank(AppContext.getUser().getAvatarid())) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification())); } if (!SiteConfiguration.isDemandEdition()) { ExtMailService mailService = AppContextUtil.getSpringBean(ExtMailService.class); if (!mailService.isMailSetupValid()) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new SmtpSetupNotification())); } SimpleUser user = AppContext.getUser(); GregorianCalendar tenDaysAgo = new GregorianCalendar(); tenDaysAgo.add(Calendar.DATE, -10); if (Boolean.TRUE.equals(user.getRequestad()) && user.getRegisteredtime().before(tenDaysAgo.getTime())) { UI.getCurrent().addWindow(new AdRequestWindow(user)); } } Resource userAvatarRes = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 24); final PopupButton accountMenu = new PopupButton(""); accountMenu.setIcon(userAvatarRes); accountMenu.setDescription(AppContext.getUserDisplayName()); OptionPopupContent accountPopupContent = new OptionPopupContent(); Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); } }); myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE)); accountPopupContent.addOption(myProfileBtn); Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS)); accountPopupContent.addOption(userMgtBtn); Button generalSettingBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETTING), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance().post( new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "general" })); } }); generalSettingBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.GENERAL_SETTING)); accountPopupContent.addOption(generalSettingBtn); Button themeCustomizeBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_THEME), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "theme" })); } }); themeCustomizeBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.THEME_CUSTOMIZE)); accountPopupContent.addOption(themeCustomizeBtn); if (!SiteConfiguration.isDemandEdition()) { Button setupBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETUP), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" })); } }); setupBtn.setIcon(FontAwesome.WRENCH); accountPopupContent.addOption(setupBtn); } accountPopupContent.addSeparator(); Button helpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_HELP)); helpBtn.setIcon(FontAwesome.MORTAR_BOARD); ExternalResource helpRes = new ExternalResource("https://community.mycollab.com/meet-mycollab/"); BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes); helpOpener.extend(helpBtn); accountPopupContent.addOption(helpBtn); Button supportBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUPPORT)); supportBtn.setIcon(FontAwesome.LIFE_SAVER); ExternalResource supportRes = new ExternalResource("http://support.mycollab.com/"); BrowserWindowOpener supportOpener = new BrowserWindowOpener(supportRes); supportOpener.extend(supportBtn); accountPopupContent.addOption(supportBtn); Button translateBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_TRANSLATE)); translateBtn.setIcon(FontAwesome.PENCIL); ExternalResource translateRes = new ExternalResource( "https://community.mycollab.com/docs/developing-mycollab/translating/"); BrowserWindowOpener translateOpener = new BrowserWindowOpener(translateRes); translateOpener.extend(translateBtn); accountPopupContent.addOption(translateBtn); if (!SiteConfiguration.isCommunityEdition()) { Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING)); accountPopupContent.addOption(myAccountBtn); } accountPopupContent.addSeparator(); Button aboutBtn = new Button("About MyCollab", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); Window aboutWindow = ViewManager.getCacheComponent(AbstractAboutWindow.class); UI.getCurrent().addWindow(aboutWindow); } }); aboutBtn.setIcon(FontAwesome.INFO_CIRCLE); accountPopupContent.addOption(aboutBtn); Button releaseNotesBtn = new Button("Release Notes"); ExternalResource releaseNotesRes = new ExternalResource( "https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/"); BrowserWindowOpener releaseNotesOpener = new BrowserWindowOpener(releaseNotesRes); releaseNotesOpener.extend(releaseNotesBtn); releaseNotesBtn.setIcon(FontAwesome.BULLHORN); accountPopupContent.addOption(releaseNotesBtn); Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)); } }); signoutBtn.setIcon(FontAwesome.SIGN_OUT); accountPopupContent.addSeparator(); accountPopupContent.addOption(signoutBtn); accountMenu.setContent(accountPopupContent); accountLayout.addComponent(accountMenu); return accountLayout; }
From source file:com.esofthead.mycollab.vaadin.ui.EmailLink.java
License:Open Source License
public EmailLink(String email) { super();/*from w w w . j a va 2s .c om*/ this.setResource(new ExternalResource("mailto:" + email)); this.setCaption(email); }
From source file:com.esofthead.mycollab.vaadin.ui.MyCollabResource.java
License:Open Source License
public static Resource newResource(String resourceId) { return new ExternalResource(newResourceLink(resourceId)); }
From source file:com.esofthead.mycollab.vaadin.ui.SocialNetworkLink.java
License:Open Source License
public SocialNetworkLink(String caption, String linkAccount) { super();//from w w w .ja v a 2 s. c o m this.setResource(new ExternalResource(linkAccount)); this.setCaption(caption); this.setTargetName("_blank"); }
From source file:com.esofthead.mycollab.vaadin.ui.UrlLink.java
License:Open Source License
public UrlLink(String urlLink) { super();//from w w w . j a v a 2s . c om this.setResource(new ExternalResource(urlLink)); this.setCaption(urlLink); this.setTargetName("_blank"); }
From source file:com.esofthead.mycollab.vaadin.web.ui.field.EmailViewField.java
License:Open Source License
@Override protected Component initContent() { final Link emailLink = new Link(email, new ExternalResource("mailto:" + email)); return emailLink; }