当前位置: 首页>>代码示例>>Java>>正文


Java View类代码示例

本文整理汇总了Java中com.vaadin.navigator.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


View类属于com.vaadin.navigator包,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.vaadin.navigator.View; //导入依赖的package包/类
@Override
protected void init(VaadinRequest vaadinRequest) {
    setNavigator(new Navigator(this, (View view) -> {
        tabs.setSelectedTab((Component) view);
    }));

    registerExample(SvgInVaadin.class);
    registerExample(SimplyAsAnImageOrIcon.class);
    registerExample(FileExample.class);
    registerExample(AnimationExample.class);
    registerExample(Java2DExample.class);
    registerExample(JungExample.class);

    getNavigator().setErrorView(SvgInVaadin.class);
    tabs.addSelectedTabChangeListener(e -> {
        if (e.isUserOriginated()) {
            getNavigator().navigateTo(e.getTabSheet().getSelectedTab().getClass().getSimpleName());
        }
    });
    String state = getNavigator().getState();
    getNavigator().navigateTo(state);

    tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    setContent(tabs);
}
 
开发者ID:mstahv,项目名称:svgexamples,代码行数:26,代码来源:MyUI.java

示例2: showView

import com.vaadin.navigator.View; //导入依赖的package包/类
@Override
public void showView(View view) {
	// check display in window
	try {
		if (showInWindow != null) {
			// set window contents
			showInWindow.setContent(ViewDisplayUtils.getViewContent(view));
			// open window
			UI ui = navigator.getUI();
			if (ui == null) {
				throw new ViewNavigationException(null,
						"Failed display View " + view.getClass().getName() + " in Window: no UI available");
			}
			openWindow(ui, showInWindow);
			// clear reference
			showInWindow = null;
		} else {
			// default
			if (getDefaultViewDisplay() != null) {
				getDefaultViewDisplay().showView(view);
			}
		}
	} finally {
		showInWindow = null;
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:27,代码来源:NavigatorActuator.java

示例3: getViewContent

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Get given <code>view</code> content: if View is a {@link ViewContentProvider}, than
 * {@link ViewContentProvider#getViewContent()} is returned, else if view is a {@link Component}, view instance
 * itself is returned. Otherwise, a {@link IllegalArgumentException} is thrown.
 * @param view View for which retrieve the content
 * @return View content as {@link Component}
 * @throws IllegalArgumentException if view instance is not a {@link ViewContentProvider} nor a {@link Component}
 */
public static Component getViewContent(View view) throws IllegalArgumentException {
	if (view != null) {
		if (view instanceof ViewContentProvider) {
			try {
				// view delegates content providing to ViewContentProvider
				return ((ViewContentProvider) view).getViewContent();
			} catch (Exception e) {
				throw new ViewConfigurationException(
						"Failed to obtain View content of View [" + view.getClass().getName() + "]", e);
			}
		} else if (view instanceof Component) {
			// view is a Component itself
			return (Component) view;
		} else {
			throw new IllegalArgumentException(
					"Invalid View " + view.getClass().getName() + ": View instance must be a "
							+ Component.class.getName() + " or a " + ViewContentProvider.class.getName());
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:30,代码来源:ViewDisplayUtils.java

示例4: fireViewOnShow

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Fire {@link OnShow} view methods
 * @param view View instance (not null)
 * @param configuration View configuration (not null)
 * @param event View change event
 * @param refresh <code>true</code> if is a page refresh
 * @throws ViewConfigurationException Error invoking view methods
 */
public static <E extends ViewChangeEvent & ViewNavigatorChangeEvent> void fireViewOnShow(View view,
		ViewConfiguration configuration, E event, boolean refresh) throws ViewConfigurationException {
	if (view == null) {
		throw new ViewConfigurationException("Null view instance");
	}
	if (configuration == null) {
		throw new ViewConfigurationException("Missing view configuration");
	}

	for (Method method : configuration.getOnShowMethods()) {
		if (!refresh || configuration.isFireOnRefresh(method)) {
			try {
				if (method.getParameterCount() == 0) {
					method.invoke(view, new Object[0]);
				} else {
					method.invoke(view, new Object[] { event });
				}
			} catch (Exception e) {
				throw new ViewConfigurationException("Failed to fire OnShow method " + method.getName()
						+ " on view class " + view.getClass().getName(), e);
			}
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:33,代码来源:ViewNavigationUtils.java

示例5: fireViewOnLeave

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Fire {@link OnLeave} view methods
 * @param view View instance (not null)
 * @param configuration View configuration (not null)
 * @param event View change event
 * @throws ViewConfigurationException Error invoking view methods
 */
public static <E extends ViewChangeEvent & ViewNavigatorChangeEvent> void fireViewOnLeave(View view,
		ViewConfiguration configuration, E event) throws ViewConfigurationException {
	if (view == null) {
		throw new ViewConfigurationException("Null view instance");
	}
	if (configuration == null) {
		throw new ViewConfigurationException("Missing view configuration");
	}

	for (Method method : configuration.getOnLeaveMethods()) {
		try {
			if (method.getParameterCount() == 0) {
				method.invoke(view, new Object[0]);
			} else {
				method.invoke(view, new Object[] { event });
			}
		} catch (Exception e) {
			throw new ViewConfigurationException("Failed to fire OnLeave method " + method.getName()
					+ " on view class " + view.getClass().getName(), e);
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:30,代码来源:ViewNavigationUtils.java

示例6: clearViewParameter

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Clear view parameter on given view instance
 * @param view View instance
 * @param definition Parameter definition
 */
private static void clearViewParameter(View view, ViewParameterDefinition definition)
		throws ViewConfigurationException {
	Object value = null;
	if (TypeUtils.isPrimitiveBoolean(definition.getType())) {
		value = Boolean.FALSE;
	} else if (TypeUtils.isPrimitiveInt(definition.getType()) || short.class == definition.getType()) {
		value = 0;
	} else if (TypeUtils.isPrimitiveInt(definition.getType())) {
		value = 0;
	} else if (TypeUtils.isPrimitiveFloat(definition.getType())) {
		value = 0f;
	} else if (TypeUtils.isPrimitiveDouble(definition.getType())) {
		value = 0d;
	}

	setViewParameterValue(view, definition, value);
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:23,代码来源:ViewNavigationUtils.java

示例7: fireViewOnLeave

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Fire {@link OnLeave} view methods
 * @param <E> Actual event type
 * @param view View instance (not null)
 * @param configuration View configuration (not null)
 * @param event View change event
 * @throws ViewConfigurationException Error invoking view methods
 */
public static <E extends ViewChangeEvent & ViewNavigatorChangeEvent> void fireViewOnLeave(View view,
		ViewConfiguration configuration, E event) throws ViewConfigurationException {
	if (view == null) {
		throw new ViewConfigurationException("Null view instance");
	}
	if (configuration == null) {
		throw new ViewConfigurationException("Missing view configuration");
	}

	for (Method method : configuration.getOnLeaveMethods()) {
		try {
			if (method.getParameterCount() == 0) {
				method.invoke(view, new Object[0]);
			} else {
				method.invoke(view, new Object[] { event });
			}
		} catch (Exception e) {
			throw new ViewConfigurationException("Failed to fire OnLeave method " + method.getName()
					+ " on view class " + view.getClass().getName(), e);
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:31,代码来源:ViewNavigationUtils.java

示例8: fireViewOnShow

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Fire {@link OnShow} view methods
 * @param <E> Actual event type
 * @param view View instance (not null)
 * @param configuration View configuration (not null)
 * @param event View change event
 * @param refresh <code>true</code> if is a page refresh
 * @throws ViewConfigurationException Error invoking view methods
 */
public static <E extends ViewChangeEvent & ViewNavigatorChangeEvent> void fireViewOnShow(View view,
		ViewConfiguration configuration, E event, boolean refresh) throws ViewConfigurationException {
	if (view == null) {
		throw new ViewConfigurationException("Null view instance");
	}
	if (configuration == null) {
		throw new ViewConfigurationException("Missing view configuration");
	}

	for (Method method : configuration.getOnShowMethods()) {
		if (!refresh || configuration.isFireOnRefresh(method)) {
			try {
				if (method.getParameterCount() == 0) {
					method.invoke(view, new Object[0]);
				} else {
					method.invoke(view, new Object[] { event });
				}
			} catch (Exception e) {
				throw new ViewConfigurationException("Failed to fire OnShow method " + method.getName()
						+ " on view class " + view.getClass().getName(), e);
			}
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:34,代码来源:ViewNavigationUtils.java

示例9: canCurrentUserAccessView

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * @param viewClass
 * @return true si l'utilisateur peut accéder à la vue
 */
public boolean canCurrentUserAccessView(Class<? extends View> viewClass, Authentication auth) {
	if (auth == null) {
		return false;
	}
	MethodInvocation methodInvocation = MethodInvocationUtils.createFromClass(viewClass, "enter");
	Collection<ConfigAttribute> configAttributes = methodSecurityInterceptor.obtainSecurityMetadataSource()
			.getAttributes(methodInvocation);
	/* Renvoie true si la vue n'est pas sécurisée */
	if (configAttributes.isEmpty()) {
		return true;
	}
	/* Vérifie que l'utilisateur a les droits requis */
	try {
		methodSecurityInterceptor.getAccessDecisionManager().decide(auth, methodInvocation, configAttributes);
	} catch (InsufficientAuthenticationException | AccessDeniedException e) {
		return false;
	}
	return true;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:24,代码来源:UserController.java

示例10: postProcessBeforeInitialization

import com.vaadin.navigator.View; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
	if (bean instanceof View) {
		ViewNavigator navigator = ViewNavigator.require();
		if (navigator instanceof ViewConfigurationProvider) {
			return ViewNavigationUtils.injectContext((ViewConfigurationProvider) navigator, (View) bean);
		}
	}
	return bean;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:11,代码来源:ViewContextInjectionPostProcessor.java

示例11: checkParameterValue

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Check the given view parameter value, performing type conversions when applicable.
 * @param view View instance
 * @param definition Parameter definition
 * @param value Parameter value
 * @return Processed parameter value
 * @throws ViewConfigurationException Error processing value
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Object checkParameterValue(View view, ViewParameterDefinition definition, Object value)
		throws ViewConfigurationException {
	if (value != null) {
		// String
		if (TypeUtils.isString(definition.getType()) && !TypeUtils.isString(value.getClass())) {
			return value.toString();
		}
		if (!TypeUtils.isString(definition.getType()) && TypeUtils.isString(value.getClass())) {
			return ConversionUtils.convertStringValue((String) value, definition.getType());
		}
		// Numbers
		if (TypeUtils.isNumber(definition.getType()) && TypeUtils.isNumber(value.getClass())) {
			return ConversionUtils.convertNumberToTargetClass((Number) value, (Class<Number>) definition.getType());
		}
		// Enums
		if (TypeUtils.isEnum(definition.getType()) && !TypeUtils.isEnum(value.getClass())) {
			return ConversionUtils.convertEnumValue((Class<Enum>) definition.getType(), value);
		}
		// check type consistency
		if (!TypeUtils.isAssignable(value.getClass(), definition.getType())) {
			throw new ViewConfigurationException("Value type " + value.getClass().getName()
					+ " doesn't match view parameter type " + definition.getType().getName());
		}
	}
	return value;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:36,代码来源:ViewNavigationUtils.java

示例12: setViewParameters

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Set parameters values in View instance using any matching parameter definition
 * @param view View instance (not null)
 * @param configuration View configuration (not null)
 * @param parameters Parameters name-value map
 * @throws ViewConfigurationException Error setting parameter values
 */
public static void setViewParameters(View view, ViewConfiguration configuration, Map<String, String> parameters)
		throws ViewConfigurationException {
	if (view == null) {
		throw new ViewConfigurationException("Null view instance");
	}
	if (configuration == null) {
		throw new ViewConfigurationException("Missing view configuration");
	}

	// get definitions
	Collection<ViewParameterDefinition> definitions = configuration.getParameters();

	// check view has some parameter definition
	if (!definitions.isEmpty()) {

		// check required parameters
		checkRequiredParameters(view, definitions, parameters);

		// set parameter values
		for (ViewParameterDefinition definition : definitions) {
			String value = (parameters != null) ? parameters.get(definition.getName()) : null;
			if (!isNullOrEmpty(value)) {
				Object deserialized = deserializeParameterValue(value, definition.getType());
				setViewParameterValue(view, definition, deserialized);
			} else {
				if (definition.getDefaultValue() != null) {
					setViewParameterValue(view, definition, definition.getDefaultValue());
				} else {
					clearViewParameter(view, definition);
				}
			}
		}

	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:43,代码来源:ViewNavigationUtils.java

示例13: processViewInstance

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Process given View instance for additional operations, such as {@link ViewContext} data injection
 * @param view View instance
 * @return Processed View
 * @throws ViewConfigurationException Error processing View instance
 */
protected View processViewInstance(View view) throws ViewConfigurationException {
	if (viewProcessorProvider != null) {
		return viewProcessorProvider.processViewInstance(viewConfigurationProvider, view);
	} else {
		return view;
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:14,代码来源:DefaultViewProviderAdapter.java

示例14: getViewConfiguration

import com.vaadin.navigator.View; //导入依赖的package包/类
public ViewConfiguration getViewConfiguration(Class<? extends View> viewClass) {
	ViewConfiguration cfg = getViewConfigurationCache().getViewConfiguration(viewClass);
	if (cfg == null) {
		// build view configuration and store in cache
		cfg = getViewConfigurationCache().storeViewConfiguration(viewClass,
				ViewNavigationUtils.buildViewConfiguration(viewClass));
	}
	return cfg;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:10,代码来源:NavigatorActuator.java

示例15: checkValidViewClass

import com.vaadin.navigator.View; //导入依赖的package包/类
/**
 * Check if given view class is valid
 * @param viewClass View class to check
 * @throws ViewConfigurationException Invalid view class
 */
public static void checkValidViewClass(Class<? extends View> viewClass) throws ViewConfigurationException {
	if (viewClass.isInterface()) {
		throw new ViewConfigurationException("Interfaces are not allowed as view class");
	}
	if (Modifier.isAbstract(viewClass.getModifiers())) {
		throw new ViewConfigurationException("Abstract classes are not allowed as view class");
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:14,代码来源:ViewNavigationUtils.java


注:本文中的com.vaadin.navigator.View类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。