com.vaadin.server.BrowserWindowOpener Java Examples

The following examples show how to use com.vaadin.server.BrowserWindowOpener. 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: AccountModuleImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public AccountModuleImpl() {
    addStyleName("module");
    ControllerRegistry.addController(new UserAccountController(this));

    MHorizontalLayout topPanel = new MHorizontalLayout().withFullWidth().withMargin(true).withStyleName(WebThemes.BORDER_BOTTOM).withId("tab-content-header");
    AccountSettingBreadcrumb breadcrumb = ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);

    MButton helpBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_HELP))
            .withIcon(VaadinIcons.ACADEMY_CAP).withStyleName(WebThemes.BUTTON_LINK);
    ExternalResource helpRes = new ExternalResource("https://docs.mycollab.com/user-guide/account-management/");
    BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes);
    helpOpener.extend(helpBtn);

    topPanel.with(breadcrumb, helpBtn).withAlign(helpBtn, Alignment.TOP_RIGHT);

    tabSheet = new VerticalTabsheet();
    tabSheet.getContentWrapper().addStyleName("content-height");
    tabSheet.setSizeFull();
    tabSheet.addToggleNavigatorControl();
    CssLayout contentWrapper = tabSheet.getContentWrapper();
    contentWrapper.addComponentAsFirst(topPanel);

    this.buildComponents();
    this.setContent(tabSheet);
}
 
Example #2
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private void buildLanguageUpdatePanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel languageDownloadDesc = ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_LANGUAGE_DOWNLOAD)).withFullWidth();
    leftPanel.with(languageDownloadDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.DOWNLOAD);
    ServerConfiguration serverConfiguration = AppContextUtil.getSpringBean(ServerConfiguration.class);
    BrowserWindowOpener opener = new BrowserWindowOpener(serverConfiguration.getApiUrl("localization/translations"));
    opener.extend(downloadBtn);
    rightPanel.with(downloadBtn, new ELabel(UserUIContext.getMessage(ShellI18nEnum.OPT_UPDATE_LANGUAGE_INSTRUCTION))
            .withStyleName(WebThemes.META_INFO).withFullWidth());
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Languages", layout);
    this.with(formContainer);
}
 
Example #3
Source File: PrintButton.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public PrintButton(String caption) {
    setCaption(caption);
    setIcon(VaadinIcons.PRINT);
    formReportStreamSource = new FormReportStreamSource<>(new FormReportTemplateExecutor<>("", UserUIContext.getUserTimeZone(), UserUIContext.getUserLocale()));
    BrowserWindowOpener printWindowOpener = new BrowserWindowOpener(new StreamResource(formReportStreamSource, UUID.randomUUID().toString() + ".pdf"));
    printWindowOpener.extend(this);
}
 
Example #4
Source File: PolicyEditor.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	//
	// The Save button
	//
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			self.savePolicy();
		}
	});
	//
	// Attach a window opener to the View XML button
	//
	BrowserWindowOpener opener = new BrowserWindowOpener(new StreamResource(new StreamResource.StreamSource() {
		private static final long serialVersionUID = 1L;

		@Override
		public InputStream getStream() {
			try {
				if (logger.isDebugEnabled()) {
					logger.debug("Setting view xml button to: " + self.file.getAbsolutePath());
				}
				return new FileInputStream(self.file);
			} catch (Exception e) {
				logger.error("Failed to open input stream " + self.file);
			}
			return null;
		}
	}, self.file.getName()));
	opener.setWindowName("_new");
	opener.extend(this.buttonViewXML);
}
 
Example #5
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!"));
}