/** * The base page is built with an empty panel in the page-header section that can be filled by * subclasses calling this method * * @param component The component to be placed at the bottom of the page-header section. The * component must have "page-header" id */ protected void setHeaderPanel(Component component) { if (!HEADER_PANEL.equals(component.getId())) throw new IllegalArgumentException( "The header panel component must have 'headerPanel' id"); remove(HEADER_PANEL); add(component); }
/** * Returns from the page by navigating to one of {@link #returnPage} or {@link #returnPageClass}, * processed in that order. * <p> * This method should be called by pages that must return after doing some task on a form submit * such as a save or a cancel. If no return page has been set via {@Link {@link #setReturnPage(Page)}} * or {@link #setReturnPageClass(Class)} then {@link GeoServerHomePage} is used. * </p> */ protected void doReturn() { doReturn(null); }
/** Returns the application instance. */ protected GeoServerApplication getGeoServerApplication() { return (GeoServerApplication) getApplication(); }
getGeoServerApplication().getBeansOfType(HeaderContribution.class); for (HeaderContribution csscontrib : cssContribs) { try { ResourceReference ref = csscontrib.getCSS(); if (ref != null) { add(HeaderContributor.forCss(ref)); add(HeaderContributor.forJavaScript(ref)); add(new ExternalLink("faviconLink", faviconUrl, null)); add(new Label("pageTitle", getPageTitle())); add(loginForm); final Authentication user = GeoServerSession.get().getAuthentication(); final boolean anonymous = user == null || user instanceof AnonymousAuthenticationToken; add(logoutForm); logoutForm.add(new Label("username", anonymous ? "Nobody" : user.getName())); .add( new Label( "label", new StringResourceModel( "home", (Component)null, null ) ) ) ); add(devToolbar); devToolbar.setVisible(Application.DEVELOPMENT.equalsIgnoreCase( getApplication().getConfigurationType())); final Map<Category,List<MenuPageInfo>> links = splitByCategory( filterByAuth(getGeoServerApplication().getBeansOfType(MenuPageInfo.class))
getGeoServerApplication().getBeansOfType(HeaderContribution.class); for (HeaderContribution csscontrib : cssContribs) { try { add(new ExternalLink("faviconLink", faviconUrl, null)); add( new Label( "pageTitle", getGeoServerApplication() .getSecurityManager() .getSecurityConfig() filterByAuth(getGeoServerApplication().getBeansOfType(LoginFormInfo.class)); add( new ListView<LoginFormInfo>("loginforms", loginforms) { public void populateItem(ListItem<LoginFormInfo> item) { loggedInAsForm.add(new Label("loggedInUsername", anonymous ? "Nobody" : user.getName())); loggedInAsForm.setVisible(!anonymous); add(loggedInAsForm); filterByAuth(getGeoServerApplication().getBeansOfType(LogoutFormInfo.class)); add( new ListView<LogoutFormInfo>("logoutforms", logoutforms) { public void populateItem(ListItem<LogoutFormInfo> item) {
@Override protected final void onSubmit(AjaxRequestTarget target, Form<?> form) { onClick(target, form); if (getPage() instanceof GeoServerBasePage) { ((GeoServerBasePage) getPage()).addFeedbackPanels(target); } }
/** * Convenience method for pages to get access to the geoserver * configuration. */ protected GeoServer getGeoServer() { return getGeoServerApplication().getGeoServer(); }
@Override public void renderHead(IHeaderResponse response) { // includes jquery, required by the placeholder plugin (wicket only include jquery if he // need it) response.render( new PriorityHeaderItem( JavaScriptHeaderItem.forReference( getApplication() .getJavaScriptLibrarySettings() .getJQueryReference()))); List<HeaderContribution> cssContribs = getGeoServerApplication().getBeansOfType(HeaderContribution.class); for (HeaderContribution csscontrib : cssContribs) { try { if (csscontrib.appliesTo(this)) { PackageResourceReference ref = csscontrib.getCSS(); if (ref != null) { response.render(CssReferenceHeaderItem.forReference(ref)); } ref = csscontrib.getJavaScript(); if (ref != null) { response.render(JavaScriptHeaderItem.forReference(ref)); } ref = csscontrib.getFavicon(); } } catch (Throwable t) { LOGGER.log(Level.WARNING, "Problem adding header contribution", t); } } }
/** Filters a set of component descriptors based on the current authenticated user. */ protected <T extends ComponentInfo> List<T> filterByAuth(List<T> list) { Authentication user = getSession().getAuthentication(); List<T> result = new ArrayList<T>(); for (T component : list) { if (component.getAuthorizer() == null) { continue; } final Class<?> clazz = component.getComponentClass(); if (!component.getAuthorizer().isAccessAllowed(clazz, user)) continue; result.add(component); } return result; }
/** * Returns from the page by navigating to one of {@link #returnPage} or {@link * #returnPageClass}, processed in that order. * * <p>This method accepts a parameter to use as a default in cases where {@link #returnPage} and * {@link #returnPageClass} are not set and a default other than {@link GeoServerHomePage} * should be used. * * <p>This method should be called by pages that must return after doing some task on a form * submit such as a save or a cancel. If no return page has been set via {@link * #setReturnPage(Page)} or {@link #setReturnPageClass(Class)} then {@link GeoServerHomePage} is * used. */ protected void doReturn(Class<? extends Page> defaultPageClass) { if (returnPage != null) { setResponsePage(returnPage); return; } if (returnPageClass != null) { setResponsePage(returnPageClass); return; } defaultPageClass = defaultPageClass != null ? defaultPageClass : GeoServerHomePage.class; setResponsePage(defaultPageClass); }
@Override protected String load() { return getPageTitle(); } }));
@Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { CachedRuleReader cacheRuleReader = GeoServerExtensions.bean(CachedRuleReader.class); cacheRuleReader.invalidateAll(); info( new StringResourceModel( GeofencePage.class.getSimpleName() + ".cacheInvalidated") .getObject()); updateStatsValues(cacheRuleReader); for (Label label : statsLabels) { target.add(label); } if (getPage() instanceof GeoServerBasePage) { ((GeoServerBasePage) getPage()).addFeedbackPanels(target); } } }.setDefaultFormProcessing(false));
/** * Convenience method for pages to get access to the catalog. */ protected Catalog getCatalog() { return getGeoServerApplication().getCatalog(); }
/** * Filters a set of component descriptors based on the current authenticated user. */ protected <T extends ComponentInfo> List<T> filterByAuth(List<T> list) { Authentication user = getSession().getAuthentication(); List<T> result = new ArrayList<T>(); for (T component : list) { if (component.getAuthorizer() == null) { continue; } final Class clazz = component.getComponentClass(); if(!component.getAuthorizer().isAccessAllowed(clazz, user)) continue; result.add(component); } return result; } @Override
/** * Returns from the page by navigating to one of {@link #returnPage} or {@link #returnPageClass}, * processed in that order. * <p> * This method accepts a parameter to use as a default in cases where {@link #returnPage} and * {@link #returnPageClass} are not set and a default other than {@link GeoServerHomePage} should * be used. * </p> * <p> * This method should be called by pages that must return after doing some task on a form submit * such as a save or a cancel. If no return page has been set via {@Link {@link #setReturnPage(Page)}} * or {@link #setReturnPageClass(Class)} then {@link GeoServerHomePage} is used. * </p> */ protected void doReturn(Class<? extends Page> defaultPageClass) { if (returnPage != null) { setResponsePage(returnPage); return; } if (returnPageClass != null) { setResponsePage(returnPageClass); return; } defaultPageClass = defaultPageClass != null ? defaultPageClass : GeoServerHomePage.class; setResponsePage(defaultPageClass); } }
@Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { CachedRuleReader cacheRuleReader = GeoServerExtensions.bean(CachedRuleReader.class); cacheRuleReader.invalidateAll(); info( new StringResourceModel( GeofencePage.class.getSimpleName() + ".cacheInvalidated") .getObject()); updateStatsValues(cacheRuleReader); for (Label label : statsLabels) { target.add(label); } if (getPage() instanceof GeoServerBasePage) { ((GeoServerBasePage) getPage()).addFeedbackPanels(target); } } }.setDefaultFormProcessing(false));
/** * The base page is built with an empty panel in the page-header section that can be filled by * subclasses calling this method * * @param component * The component to be placed at the bottom of the page-header section. The component * must have "page-header" id */ protected void setHeaderPanel(Component component) { if (!HEADER_PANEL.equals(component.getId())) throw new IllegalArgumentException( "The header panel component must have 'headerPanel' id"); remove(HEADER_PANEL); add(component); }
/** Convenience method for pages to get access to the geoserver configuration. */ protected GeoServer getGeoServer() { return getGeoServerApplication().getGeoServer(); }
/** * Returns the application instance. */ protected GeoServerApplication getGeoServerApplication() { return (GeoServerApplication) getApplication(); }
/** * Returns from the page by navigating to one of {@link #returnPage} or {@link * #returnPageClass}, processed in that order. * * <p>This method should be called by pages that must return after doing some task on a form * submit such as a save or a cancel. If no return page has been set via {@link * #setReturnPage(Page)} or {@link #setReturnPageClass(Class)} then {@link GeoServerHomePage} is * used. */ protected void doReturn() { doReturn(null); }