List of usage examples for com.vaadin.ui Link setEnabled
@Override public void setEnabled(boolean enabled)
From source file:com.klwork.explorer.ui.main.views.SampleMainView.java
License:Apache License
@PostConstruct public void PostConstruct() { setSizeFull();/*from w w w.j a v a 2 s . c o m*/ VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); HorizontalLayout usernameLayout = new HorizontalLayout(); usernameLayout.setSpacing(true); usernameLayout.addComponent(new Label("Username:")); usernameLayout.addComponent(usernameLabel); //HorizontalLayout userRolesLayout = new HorizontalLayout(); //userRolesLayout.setSpacing(true); //userRolesLayout.addComponent(new Label("Roles:")); //userRolesLayout.addComponent(rolesLabel); layout.addComponent(usernameLayout); //addComponent(userRolesLayout); Link roleUserView = new Link("Role \"user\" View (disabled, if user doesn't have access)", new ExternalResource("#!" + RoleUserView.NAME)); Link roleAdminView = new Link("Role \"admin\" View (disabled, if user doesn't have access)", new ExternalResource("#!" + RoleAdminView.NAME)); Link authenticatedView = new Link("@RequiresAuthentication View (disabled, if user doesn't have access)", new ExternalResource("#!" + AuthenticatedView.NAME)); Link guestView = new Link("@RequiresGuest View (disabled, if user doesn't have access)", new ExternalResource("#!" + GuestView.NAME)); Link userView = new Link("@RequiresUser View (disabled, if user doesn't have access)", new ExternalResource("#!" + UserView.NAME)); roleUserView.setEnabled(ShiroSecurityNavigator.hasAccess(RoleUserView.class)); roleAdminView.setEnabled(ShiroSecurityNavigator.hasAccess(RoleAdminView.class)); authenticatedView.setEnabled(ShiroSecurityNavigator.hasAccess(AuthenticatedView.class)); guestView.setEnabled(ShiroSecurityNavigator.hasAccess(GuestView.class)); userView.setEnabled(ShiroSecurityNavigator.hasAccess(UserView.class)); layout.addComponent(roleUserView); layout.addComponent(roleAdminView); layout.addComponent(authenticatedView); layout.addComponent(guestView); layout.addComponent(userView); layout.addComponent(new Link("Role \"admin\" View (throw exception, if user doesn't have access)", new ExternalResource("#!" + RoleAdminView.NAME))); layout.addComponent(new Link("Logout", new ExternalResource("/logout/"))); setContent(layout); }