com.vaadin.server.Page Java Examples

The following examples show how to use com.vaadin.server.Page. 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: Parameter.java    From chipster with MIT License 6 votes vote down vote up
private Name[] getEnumList() {
	if (typeTable == null || typeTable.getItemIds().isEmpty())
		return null;
	Name[] names = typeTable.getItemIds().toArray(new Name[0]);
	ArrayList<Name> list = new ArrayList<Name>();
	for (Name name : names) {
		if (!name.getID().isEmpty()) {
			if ("".equals(name.getDisplayName())) {
				name.setDisplayName(null);
			}

			list.add(name);
		} else {
			new Notification(
					"Not all ENUM types were generated to text, because id was empty",
					Type.WARNING_MESSAGE).show(Page.getCurrent());
		}
	}
	return list.toArray(new Name[0]);
}
 
Example #2
Source File: CSCTextToToolClickListener.java    From chipster with MIT License 6 votes vote down vote up
@Override
public void buttonClick(ClickEvent event) {
	
	ChipsterSADLParser parser = new ChipsterSADLParser();
	try {
		SADLDescription description = parser.parse(root.getTextEditor().getHeader());
		root.getToolEditor().removeItems();
		root.getTreeToolEditor().removeAllChildren();
		root.getToolEditor().addTool(description);
		List<Input> inputs = description.getInputs();
		for(int i = 0 ; i < inputs.size(); i++) {
			root.getToolEditor().addInput(inputs.get(i));
		}
		List<Output> outputs = description.getOutputs();
		for(int i = 0 ; i < outputs.size(); i++) {
			root.getToolEditor().addOutput(outputs.get(i));
		}
		List<Parameter> parameters = description.getParameters();
		for(int i = 0 ; i < parameters.size(); i++) {
			root.getToolEditor().addParameter(parameters.get(i));
		}
		
	} catch (Exception e) {
		new Notification("Something wrong with the header\n\n" + e.getMessage(), Type.WARNING_MESSAGE).show(Page.getCurrent());
	}
}
 
Example #3
Source File: QueryParamHandler.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public static <S extends SearchCriteria> ApplicationEventListener<ShellEvent.AddQueryParam> queryParamHandler() {
    return new ApplicationEventListener<ShellEvent.AddQueryParam>() {
        @Subscribe
        @Override
        public void handle(ShellEvent.AddQueryParam event) {
            List<SearchFieldInfo<S>> searchFieldInfos = (List<SearchFieldInfo<S>>) event.getData();
            String query = QueryAnalyzer.toQueryParams(searchFieldInfos);
            String fragment = Page.getCurrent().getUriFragment();
            int index = fragment.indexOf("?");
            if (index > 0) {
                fragment = fragment.substring(0, index);
            }

            if (StringUtils.isNotBlank(query)) {
                fragment += "?" + UrlEncodeDecoder.encode(query);
                Page.getCurrent().setUriFragment(fragment, false);
            }
        }
    };
}
 
Example #4
Source File: UrlChangeHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void handleUrlChange(Page.PopStateEvent event) {
    if (notSuitableMode()) {
        log.debug("UrlChangeHandler is disabled for '{}' URL handling mode", webConfig.getUrlHandlingMode());
        return;
    }

    int hashIdx = event.getUri().indexOf("#");
    NavigationState requestedState = hashIdx < 0
            ? NavigationState.EMPTY
            : urlTools.parseState(event.getUri().substring(hashIdx + 1));

    if (requestedState == null) {
        log.debug("Unable to handle requested state: '{}'", Page.getCurrent().getUriFragment());
        reloadApp();
        return;
    }

    __handleUrlChange(requestedState);
}
 
Example #5
Source File: UrlTools.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void pushState(String navigationState, UI ui) {
    checkNotNullArgument(navigationState, "Navigation state cannot be null");

    if (headless()) {
        log.debug("Unable to push navigation state in headless mode");
        return;
    }

    String state = !navigationState.isEmpty()
            ? "#" + navigationState
            : "";

    Page page = ui.getPage();
    if (!state.isEmpty()) {
        page.pushState(state);
    } else {
        page.pushState(getEmptyFragmentUri(page));
    }
}
 
Example #6
Source File: UrlTools.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void replaceState(String navigationState, UI ui) {
    checkNotNullArgument(navigationState, "Navigation state cannot be null");

    if (headless()) {
        log.debug("Unable to replace navigation state in headless mode");
        return;
    }

    String state = !navigationState.isEmpty()
            ? "#" + navigationState
            : "";

    Page page = ui.getPage();
    if (!state.isEmpty()) {
        page.replaceState(state);
    } else {
        page.replaceState(getEmptyFragmentUri(page));
    }
}
 
Example #7
Source File: CubaTable.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
    if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) {
        focus();
    }

    super.changeVariables(source, variables);

    if (shortcutActionManager != null) {
        shortcutActionManager.handleActions(variables, this);
    }

    if (variables.containsKey("updateAggregationRow")) {
        Boolean updateAggregationRow = (Boolean) variables.get("updateAggregationRow");
        if (updateAggregationRow) {
            markAsDirty();
        }
    }
}
 
Example #8
Source File: AboutWindow.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public AboutWindow() {
    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("", new ExternalResource(StorageUtils.generateAssetRelativeLink(WebResourceIds._about)));

    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion())).withFullWidth();
    ELabel javaNameLbl = new ELabel(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version"))).withFullWidth();
    Label homeFolderLbl = new Label("Home folder: " + AppContextUtil.getSpringBean(ServerConfiguration.class).getHomeDir().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    ELabel osLbl = new ELabel(String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication())).withFullWidth();
    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"));
    ELabel licenseLbl = ELabel.html(licenseDiv.write()).withFullWidth();
    Label copyRightLbl = ELabel.html(String.format("&copy; %s - %s MyCollab Ltd. All rights reserved", "2011",
            LocalDate.now().getYear() + "")).withFullWidth();
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl).withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}
 
Example #9
Source File: HawkbitUIErrorHandler.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void error(final ErrorEvent event) {

    // filter upload exceptions
    if (event.getThrowable() instanceof UploadException) {
        return;
    }

    final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
    if (event instanceof ConnectorErrorEvent) {
        final Connector connector = ((ConnectorErrorEvent) event).getConnector();
        if (connector instanceof UI) {
            final UI uiInstance = (UI) connector;
            uiInstance.access(() -> message.show(uiInstance.getPage()));
            return;
        }
    }

    final Optional<Page> originError = getPageOriginError(event);
    if (originError.isPresent()) {
        message.show(originError.get());
        return;
    }

    HawkbitErrorNotificationMessage.show(message.getCaption(), message.getDescription(), Type.HUMANIZED_MESSAGE);
}
 
Example #10
Source File: ClearableTextField.java    From viritin with Apache License 2.0 6 votes vote down vote up
@Override
public void attach() {
    super.attach();
    Page.getCurrent().getStyles().add(
            ".clearable-textfield .v-widget {\n"
            + "	border-radius: 4px 4px 4px 4px;\n"
            + "}\n"
            + ".clearable-textfield .v-slot:last-child>.v-widget {\n"
            + "	border-top-left-radius: 0;\n"
            + "	border-bottom-left-radius: 0; margin-left:-1px\n"
            + "}\n"
            + "\n"
            + ".clearable-textfield .v-slot:first-child>.v-widget {\n"
            + "	border-top-right-radius: 0;\n"
            + "	border-bottom-right-radius: 0;\n"
            + "}\n");
}
 
Example #11
Source File: ClearableTextField.java    From viritin with Apache License 2.0 6 votes vote down vote up
@Override
public void attach() {
    super.attach();
    // TODO optimize this so that it is added only once
    Page.getCurrent().getStyles().add(
            ".clearable-textfield .v-widget {\n"
            + "	border-radius: 4px 4px 4px 4px;\n"
            + "}\n"
            + ".clearable-textfield .v-slot:last-child>.v-widget {\n"
            + "	border-top-left-radius: 0;\n"
            + "	border-bottom-left-radius: 0; margin-left:-1px\n"
            + "}\n"
            + "\n"
            + ".clearable-textfield .v-slot:first-child>.v-widget {\n"
            + "	border-top-right-radius: 0;\n"
            + "	border-bottom-right-radius: 0;\n"
            + "}\n");
}
 
Example #12
Source File: WebAbstractDataGrid.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void updateFooterVisibility(String style) {
    Page page = Page.getCurrent();
    if (page == null) {
        return;
    }
    WebBrowser webBrowser = page.getWebBrowser();
    boolean isPredefinedStyle = style.equals(BORDERLESS_STYLE)
            || style.equals(NO_HORIZONTAL_LINES_STYLE)
            || style.equals(NO_VERTICAL_LINES_STYLE);

    if (webBrowser.isSafari()
            && isPredefinedStyle
            && grid.getFooterRowCount() > 0
            && grid.isFooterVisible()) {
        ((CubaEnhancedGrid) grid).updateFooterVisibility();
    }
}
 
Example #13
Source File: DashboardMenu.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Component buildUserMenu(final UiProperties uiProperties) {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.setHtmlContentAllowed(true);

    final MenuItem settingsItem = settings.addItem("", getImage(uiProperties.isGravatar()), null);

    final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
    if (!StringUtils.isEmpty(formattedTenant)) {
        settingsItem.setText(formattedTenant);
        UserDetailsFormatter.getCurrentTenant().ifPresent(tenant -> settingsItem.setDescription(i18n
                .getMessage("menu.user.description", tenant, UserDetailsFormatter.getCurrentUser().getUsername())));
    } else {
        settingsItem.setText("...");
    }

    settingsItem.setStyleName("user-menuitem");

    final String logoutUrl = generateLogoutUrl();

    settingsItem.addItem(i18n.getMessage("label.sign.out"),
            selectedItem -> Page.getCurrent().setLocation(logoutUrl));
    return settings;
}
 
Example #14
Source File: VaadinUI.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
protected void workaroundForFirefoxIssue(boolean initial) {
    if (initial && Page.getCurrent().getWebBrowser().getBrowserApplication().
            contains("Firefox")) {
        // Responsive, FF, cross site is currently broken :-(
        Extension r = null;
        for (Extension ext : getExtensions()) {
            if (ext instanceof Responsive) {
                r = ext;
            }
        }
        removeExtension(r);
    }
}
 
Example #15
Source File: BulkUploadHandler.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void uploadStarted(final StartedEvent event) {
    if (!event.getFilename().endsWith(".csv")) {

        new HawkbitErrorNotificationMessage(SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, null,
                i18n.getMessage("bulk.targets.upload"), true).show(Page.getCurrent());
        LOG.error("Wrong file format for file {}", event.getFilename());
        upload.interruptUpload();
    } else {
        eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED));
    }
}
 
Example #16
Source File: DistributionsView.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
void init() {
    buildLayout();
    restoreState();
    checkNoDataAvaialble();
    Page.getCurrent().addBrowserWindowResizeListener(this);
    showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth());
}
 
Example #17
Source File: SwModuleTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void styleTableOnDistSelection() {
    Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getScriptSMHighlightReset());
    setCellStyleGenerator(new Table.CellStyleGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getStyle(final Table source, final Object itemId, final Object propertyId) {
            return createTableStyle(itemId, propertyId);
        }
    });
}
 
Example #18
Source File: DeploymentView.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
void init() {
    buildLayout();
    restoreState();
    checkNoDataAvaialble();
    Page.getCurrent().addBrowserWindowResizeListener(this);
    showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth());
    getEventBus().publish(this, ManagementUIEvent.SHOW_COUNT_MESSAGE);
}
 
Example #19
Source File: MainUI.java    From anx with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
	Page.getCurrent().setTitle("Advanced Netconf Explorer");
    addStyleName(ValoTheme.UI_WITH_MENU);
    
    setContent(new RetrieverView(this, vaadinRequest));
    addStyleName("loginview");
}
 
Example #20
Source File: LoginWindow.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
private OAuthService createService() {
    ServiceBuilder sb = new ServiceBuilder();
    sb.provider(Google2Api.class);
    sb.apiKey(gpluskey);
    sb.apiSecret(gplussecret);
    sb.scope("email");
    String callBackUrl = Page.getCurrent().getLocation().toString();
    if(callBackUrl.contains("#")) {
        callBackUrl = callBackUrl.substring(0, callBackUrl.indexOf("#"));
    }
    sb.callback(callBackUrl);
    return sb.build();
}
 
Example #21
Source File: AbstractChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the chart window height.
 *
 * @param fullPage the full page
 * @return the chart window height
 */
private static int getChartWindowHeight(final boolean fullPage) {
	if (fullPage) {
		return Math.max((int) (Page.getCurrent().getBrowserWindowHeight() * HEIGHT_PERCENTAGE_FULL_PAGE) ,MINIMUM_CHART_HEIGHT_FULL_PAGE);
	} else {
		return Math.max((int) (Page.getCurrent().getBrowserWindowHeight() * HEIGHT_PERCETAGE_HALF_PAGE),NINIMUM_CHART_HEIGHT_HALF_PAGE);
	}
}
 
Example #22
Source File: CitizenIntelligenceAgencyUI.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(final VaadinRequest request) {
	VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this));
	setSizeFull();
	springNavigator.addView(CRLF_REPLACEMENT, mainView);
	setNavigator(springNavigator);


	final Page currentPage = Page.getCurrent();
	final String requestUrl = currentPage.getLocation().toString();
	final String language = request.getLocale().getLanguage();
	final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language);

	currentPage.setTitle(userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName());

	if (getSession().getUIs().isEmpty()) {
		final WebBrowser webBrowser = currentPage.getWebBrowser();

		final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
		serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());

		final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser);
		serviceRequest.setIpInformation(ipInformation);
		serviceRequest.setTimeZone(webBrowser.getTimeZoneId());
		serviceRequest.setScreenSize(webBrowser.getScreenWidth() + "x" + webBrowser.getScreenHeight());
		serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication());
		serviceRequest.setLocale(webBrowser.getLocale().toString());
		serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser));
		serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);

		final ServiceResponse serviceResponse = applicationManager.service(serviceRequest);
		LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT,requestUrl.replaceAll(CRLF,CRLF_REPLACEMENT),language.replaceAll(CRLF,CRLF_REPLACEMENT),ipInformation.replaceAll(CRLF,CRLF_REPLACEMENT),webBrowser.getBrowserApplication().replaceAll(CRLF,CRLF_REPLACEMENT),serviceRequest.getSessionId().replaceAll(CRLF,CRLF_REPLACEMENT),serviceResponse.getResult().toString().replaceAll(CRLF,CRLF_REPLACEMENT));
	}
}
 
Example #23
Source File: UserContextUtil.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the request url.
 *
 * @param current
 *            the current
 * @return the request url
 */
public static String getRequestUrl(final Page current) {
	if (current != null) {
		return current.getLocation().toString();

	} else {
		final HttpServletRequest httpRequest=((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
		return httpRequest.getRequestURL().toString();
	}
}
 
Example #24
Source File: SecuredNavigator.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
private String extractViewToken() {
	String uriFragment = Page.getCurrent().getUriFragment();
	if (uriFragment != null && !uriFragment.isEmpty() && uriFragment.length() > 1) {
		return uriFragment.substring(1);
	} else {
		return "";
	}
	
}
 
Example #25
Source File: DesktopApplication.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
    broadcastReceiverService = AppContextUtil.getSpringBean(BroadcastReceiverService.class);

    ServerConfiguration serverConfiguration = AppContextUtil.getSpringBean(ServerConfiguration.class);
    if (serverConfiguration.isPush()) {
        getPushConfiguration().setPushMode(PushMode.MANUAL);
    }

    UI.getCurrent().setErrorHandler(new DefaultErrorHandler() {
        private static final long serialVersionUID = 1L;

        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            Throwable e = event.getThrowable();
            handleException(request, e);
        }
    });

    setCurrentFragmentUrl(this.getPage().getUriFragment());
    setCurrentContext(new UserUIContext());
    postSetupApp(request);

    EventBusFactory.getInstance().register(new ShellErrorHandler());

    mainWindowContainer = new MainWindowContainer();
    this.setContent(mainWindowContainer);

    getPage().addPopStateListener((Page.PopStateListener) event -> enter(event.getPage().getUriFragment()));

    String userAgent = request.getHeader("user-agent");
    if (isInNotSupportedBrowserList(userAgent.toLowerCase())) {
        NotificationUtil.showWarningNotification(UserUIContext.getMessage(ErrorI18nEnum.BROWSER_OUT_UP_DATE));
    }
}
 
Example #26
Source File: VaadinUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Exit application
 */
public static void exit() {
	VaadinSession.getCurrent().getSession().removeAttribute(
			HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
	UI.getCurrent().close();
	VaadinSession.getCurrent().close();
	Page page = Page.getCurrent();
	page.setLocation(VaadinService.getCurrentRequest().getContextPath() + "/logout"); 
}
 
Example #27
Source File: WebUrlRouting.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public NavigationState getState() {
    if (UrlHandlingMode.URL_ROUTES != webConfig.getUrlHandlingMode()) {
        log.debug("UrlRouting is disabled for '{}' URL handling mode", webConfig.getUrlHandlingMode());
        return NavigationState.EMPTY;
    }

    if (UrlTools.headless()) {
        log.debug("Unable to resolve navigation state in headless mode");
        return NavigationState.EMPTY;
    }

    return urlTools.parseState(Page.getCurrent().getLocation().getRawFragment());
}
 
Example #28
Source File: UploadArtifactView.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
void init() {
    buildLayout();
    restoreState();
    checkNoDataAvaialble();
    eventBus.subscribe(this);
    Page.getCurrent().addBrowserWindowResizeListener(this);
    showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth());
}
 
Example #29
Source File: ShortCutModifierUtils.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the ctrl or meta modifier depending on the platform.
 * 
 * @return on mac return
 *         {@link com.vaadin.event.ShortcutAction.ModifierKey#META} other
 *         platform return
 *         {@link com.vaadin.event.ShortcutAction.ModifierKey#CTRL}
 */
public static int getCtrlOrMetaModifier() {
    final WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
    if (webBrowser.isMacOSX()) {
        return ShortcutAction.ModifierKey.META;
    }

    return ShortcutAction.ModifierKey.CTRL;
}
 
Example #30
Source File: CubaTreeTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void changeVariables(Object source, Map<String, Object> variables) {

    if (Page.getCurrent().getWebBrowser().isIE()
            && variables.containsKey("clickEvent")) {
        focus();
    }

    super.changeVariables(source, variables);

    if (shortcutActionManager != null) {
        shortcutActionManager.handleActions(variables, this);
    }
}