Java 类com.vaadin.server.BrowserWindowOpener 实例源码

项目:cuba    文件:WebNewWindowButton.java   
public WebNewWindowButton() {
    component = new CubaButton();
    component.addStyleName(NEW_WINDOW_BUTTON_STYLENAME);
    component.setDescription(null);

    URL pageUrl;
    try {
        pageUrl = Page.getCurrent().getLocation().toURL();
    } catch (MalformedURLException ignored) {
        LoggerFactory.getLogger(WebNewWindowButton.class).warn("Couldn't get URL of current Page");
        return;
    }

    ExternalResource currentPage = new ExternalResource(pageUrl);
    final BrowserWindowOpener opener = new BrowserWindowOpener(currentPage);
    opener.setWindowName("_blank");

    opener.extend(component);
}
项目:mycollab    文件:AccountModuleImpl.java   
public AccountModuleImpl() {
    addStyleName("module");
    ControllerRegistry.addController(new UserAccountController(this));

    MHorizontalLayout topPanel = new MHorizontalLayout().withFullWidth().withMargin(true).withStyleName("border-bottom");
    AccountSettingBreadcrumb breadcrumb = ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);

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

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

    tabSheet = new VerticalTabsheet();
    tabSheet.setSizeFull();
    tabSheet.setNavigatorStyleName("sidebar-menu");
    tabSheet.addToggleNavigatorControl();
    VerticalLayout contentWrapper = tabSheet.getContentWrapper();
    contentWrapper.addStyleName("main-content");
    contentWrapper.addComponentAsFirst(topPanel);

    this.buildComponents();
    this.setContent(tabSheet);
}
项目:mycollab    文件:GeneralSettingViewImpl.java   
private void buildLanguageUpdatePanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    Label logoDesc = new Label(UserUIContext.getMessage(ShellI18nEnum.OPT_LANGUAGE_DOWNLOAD));
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.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(UIConstants.META_INFO));
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Languages", layout);
    this.with(formContainer);
}
项目:esup-ecandidat    文件:AssistanceView.java   
/**
 * @param caption
 * @param bwo
 * @param icon
 * @return un bouton pour l'assistance
 */
private OneClickButton getButton(String caption, String bwo, com.vaadin.server.Resource icon){
    BrowserWindowOpener browser = new BrowserWindowOpener(new ExternalResource(bwo));
    OneClickButton btn = new OneClickButton(caption, icon);
    btn.addStyleName(ValoTheme.BUTTON_LINK);
    browser.extend(btn);
    return btn;
}
项目:incubator-openaz    文件:PolicyEditor.java   
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);
}
项目:dhconvalidator    文件:LoginResultPanel.java   
/**
 * Setup UI.
 * @param errorMessage
 */
private void initComponents(String errorMessage) {
    logoutLink = new LogoutLink();
    logoutLink.setVisible(false);

    User user = 
        (User)VaadinSession.getCurrent().getAttribute(SessionStorageKey.USER.name());

    // if authencication has been successful we open up a new tab to show the DHConvalidator services
    btContinue = new Button(Messages.getString("LoginResultPanel.continue")); //$NON-NLS-1$
    new BrowserWindowOpener(DHConvalidatorServices.class).extend(btContinue);

    btRetry = new Button(Messages.getString("LoginResultPanel.retry")); //$NON-NLS-1$
    btRetry.setVisible(false);

    Label infoLabel = new Label("", ContentMode.HTML);
    if (errorMessage != null) {
        infoLabel.setValue(
            Messages.getString("LoginResultPanel.authenticationFailure", errorMessage)); //$NON-NLS-1$
        btContinue.setVisible(false);
        btRetry.setVisible(true);
    }
    else {
        infoLabel.setValue(
            Messages.getString(
                    "LoginResultPanel.greeting", //$NON-NLS-1$
                    user.getFirstName(), 
                    user.getLastName())); 
        logoutLink.setVisible(true);
    }

    addCenteredComponent(logoutLink, Alignment.TOP_RIGHT);
    addCenteredComponent(infoLabel);
    addCenteredComponent(btContinue);
    addCenteredComponent(btRetry);
}
项目:XACML    文件:PolicyEditor.java   
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);
}
项目:extacrm    文件:DownloadFileWindow.java   
private void initWindow(final String caption, final byte[] file, final String fileName) {

        setCaption(caption);

        final VerticalLayout contentContainer = new VerticalLayout();
        contentContainer.setMargin(true);
        contentContainer.setSpacing(true);

        final Label infoLbl = new Label(fileName);
        contentContainer.addComponent(infoLbl);

        final HorizontalLayout toolbar = new HorizontalLayout();
        toolbar.setSpacing(true);

        final Button downloadBtn = new Button("Скачать", Fontello.DOWNLOAD);
        createDownloader(file, fileName).extend(downloadBtn);
        toolbar.addComponent(downloadBtn);

        final Button viewBtn = new Button("Посмотреть", Fontello.SEARCH_1);
        final BrowserWindowOpener opener =
                new BrowserWindowOpener(new StreamResource(
                        () -> new ByteArrayInputStream(file), encodeWebFileName(fileName)));
        opener.extend(viewBtn);
        toolbar.addComponent(viewBtn);

        contentContainer.addComponent(toolbar);
        contentContainer.setComponentAlignment(toolbar, Alignment.MIDDLE_CENTER);

        setContent(contentContainer);
    }
项目:mycollab    文件:PrintButton.java   
public PrintButton() {
    setIcon(FontAwesome.PRINT);
    formReportStreamSource = new FormReportStreamSource(new FormReportTemplateExecutor(""));
    BrowserWindowOpener printWindowOpener = new BrowserWindowOpener(new StreamResource(formReportStreamSource, UUID.randomUUID().toString() + ".pdf"));
    printWindowOpener.extend(this);
}
项目:mideaas    文件:VisualDesignerConnector.java   
@Override
public void attach() {
    super.attach();
    URI myUrl = UI.getCurrent().getPage().getLocation();
    String myUrlRoot = myUrl.getScheme() + "://" + myUrl.getAuthority()
            + myUrl.getPath();

    String modelUrl = myUrlRoot + "?getmodelid=" + modelId;

    String modelUrlEnc;
    try {
        modelUrlEnc = URLEncoder.encode(modelUrl, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return;
    }

    String url = visualDesignerUrl + "?restartApplication&modelid="
            + modelId + "&modeluri=" + modelUrlEnc;

    BrowserWindowOpener opener = new BrowserWindowOpener(url);

    Button button = new Button("Open Visual Designer");
    button.setIcon(Icons.APPLICATION_ARROW);
    opener.extend(button);

    layout.addComponent(button);

    Button fetchButton = new Button("Get from Visual Designer");
    fetchButton.setIcon(Icons.ARROW_180_MEDIUM);
    fetchButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            fetch(modelId);
        }
    });

    layout.addComponent(fetchButton);

}