List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.devgateway.toolkit.forms.wicket.FormsWebApplication.java
License:Open Source License
public static FormsWebApplication get() { return (FormsWebApplication) Application.get(); }
From source file:org.efaps.ui.wicket.background.JobRunnable.java
License:Apache License
/** * Instantiates a new job runnable.//from ww w .j a v a2 s .co m * * @param _job the _job * @param _bridge the _bridge */ public JobRunnable(final IJob _job, final IExecutionBridge _bridge) { this.job = _job; this.bridge = _bridge; this.application = Application.get(); this.session = Session.exists() ? EFapsSession.get() : null; }
From source file:org.efaps.ui.wicket.behaviors.dojo.AutoCompleteHeaderItem.java
License:Apache License
@Override public ResourceReference getReference() { final JavaScriptLibrarySettings ajaxSettings = Application.get().getJavaScriptLibrarySettings(); return ajaxSettings.getWicketEventReference(); }
From source file:org.efaps.ui.wicket.EFapsApplication.java
License:Apache License
/** * Get EFapsApplication for current thread. * * @return The current thread's Application */// www.j a va2s.c o m public static EFapsApplication get() { return (EFapsApplication) Application.get(); }
From source file:org.geoserver.security.web.auth.RoleSourceChoiceRenderer.java
License:Open Source License
@Override public Object getDisplayValue(RoleSource rs) { String key = "RoleSource." + rs.toString(); return Application.get().getResourceSettings().getLocalizer().getString(key, null); }
From source file:org.geoserver.web.GeoServerApplication.java
License:Open Source License
public static GeoServerApplication get() { return (GeoServerApplication) Application.get(); }
From source file:org.geoserver.web.GeoServerStringResourceLoader.java
License:Open Source License
/** * Get the string resource for the given combination of class, key, locale and style. The * information is obtained from a resource bundle associated with the provided Class (or one of * its super classes).//from ww w.j a va2 s .c om * * @param clazz * The Class to find resources to be loaded (might be null if we want a context-less search) * @param key * The key to obtain the string for * @param locale * The locale identifying the resource set to select the strings from * @param style * The (optional) style identifying the resource set to select the strings from (see * {@link org.apache.wicket.Session}) * @return The string resource value or null if resource not found */ public String loadStringResource(Class clazz, final String key, final Locale locale, final String style) { // Load the properties associated with the path IPropertiesFactory propertiesFactory = Application.get().getResourceSettings().getPropertiesFactory(); // All GeoServer releated resources are loaded into a GeoServerApplication*.properties file String path = "/GeoServerApplication"; while (true) { // Iterator over all the combinations ResourceNameIterator iter = new ResourceNameIterator(path, style, locale, ",properties,xml"); while (iter.hasNext()) { String newPath = (String) iter.next(); final Properties props = propertiesFactory.load(clazz, newPath); if (props != null) { // Lookup the qualified key String qualifiedKey = clazz != null ? clazz.getSimpleName() + "." + key : key; String value = props.getString(qualifiedKey); if (value != null) return value; } } // Didn't find the key yet, continue searching if possible if (isStopResourceSearch(clazz)) { break; } // Move to the next superclass clazz = clazz.getSuperclass(); if (clazz == null) { // nothing more to search, done break; } } // not found return null; }
From source file:org.hippoecm.frontend.diagnosis.DiagnosticsRequestCycleListener.java
License:Apache License
@Override public void onBeginRequest(RequestCycle cycle) { final DiagnosticsService diagnosticsService = HippoServiceRegistry.getService(DiagnosticsService.class); if (diagnosticsService != null) { final Main application = (Main) Application.get(); if (diagnosticsService.isEnabledFor(cycle.getRequest())) { if (HDC.isStarted()) { log.error(/*from w ww. j av a 2 s. com*/ "HDC was not cleaned up properly in previous request cycle for some reason. So clean up HDC to start new one."); HDC.cleanUp(); } Task rootTask = HDC.start(application.getPluginApplicationName()); rootTask.setAttribute("request", cycle.getRequest().getUrl().toString()); } } }
From source file:org.hippoecm.frontend.dialog.NodeInfo.java
License:Apache License
/** * @see org.apache.wicket.request.IRequestHandler#respond(org.apache.wicket.request.IRequestCycle) *///from w w w . j a v a2 s . c om public void respond(IRequestCycle requestCycle) { final Application app = Application.get(); // Determine encoding final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); // Set content type based on markup type for page final WebResponse response = (WebResponse) requestCycle.getResponse(); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.setLastModifiedTime(Time.now()); // set filename response.setAttachmentHeader(FILE_NAME); UserSession session = UserSession.get(); try { ByteArrayOutputStream fos = new ByteArrayOutputStream(); try { PrintStream ps = new PrintStream(fos); ps.println("Hippo CMS Error report"); ps.println("========================================"); ps.print("version : "); ps.print(getCMSVersion()); ps.println(); ps.print("time : "); ps.print(Time.now().toString()); ps.println(); javax.jcr.Session jcrSession = session.getJcrSession(); if (jcrSession != null) { ps.print("user : "); ps.print(session.getJcrSession().getUserID()); ps.println(); } HttpServletRequest hsr = (HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest(); ps.print("server : "); ps.print(hsr.getServerName()); ps.println(); String node = System.getProperty("org.apache.jackrabbit.core.cluster.node_id"); if (node != null) { ps.print("node : "); ps.print(hsr.getServerName()); ps.println(); } ps.print("java : "); ps.print(System.getProperty("java.version")); ps.println(); ps.println(); ps.println("error :"); ps.print(ex.getClass().getName()); ps.print(": "); ps.print(ex.getLocalizedMessage()); ps.println(); ex.printStackTrace(ps); ps.println(); if (jcrSession != null) { ps.println("session :"); Map<NodePath, NodeInfo> modificationTree = getModificationTree(jcrSession); int widths[] = new int[Column.values().length]; for (Map.Entry<NodePath, NodeInfo> entry : modificationTree.entrySet()) { NodeInfo info = entry.getValue(); for (Column col : Column.values()) { int width = col.getWidth(info); if (width > widths[col.ordinal()]) { widths[col.ordinal()] = width; } } } int row = 0; for (Map.Entry<NodePath, NodeInfo> entry : modificationTree.entrySet()) { NodeInfo info = entry.getValue(); if (row % 5 == 0 && row != 0) { ps.println(); } ps.print(" "); for (Column col : Column.values()) { String val = col.render(info); ps.print(val); int fill = widths[col.ordinal()] - val.length(); for (int i = 0; i < fill; i++) { ps.print(' '); } ps.print(" "); } ps.println(); row++; } } ps.println(); ps.println("========================================"); } finally { fos.close(); } response.write(fos.toByteArray()); } catch (FileNotFoundException e) { log.error("Tempfile missing during export", e); } catch (IOException e) { log.error("IOException during export", e); } }
From source file:org.hippoecm.frontend.editor.builder.PreviewClusterConfig.java
License:Apache License
protected String getPluginConfigEditorClass(String pluginClass) { if (pluginClass == null) { return null; }//from w ww . ja v a 2 s .c o m try { Class<?> clazz = Class.forName(pluginClass); if (AbstractFieldPlugin.class.isAssignableFrom(clazz)) { return FieldPluginEditorPlugin.class.getName(); } else if (MixinLoaderPlugin.class.isAssignableFrom(clazz)) { return MixinLoaderPluginEditorPlugin.class.getName(); } else if (ListViewPlugin.class.isAssignableFrom(clazz)) { return ListViewPluginEditorPlugin.class.getName(); } else if (RenderPlugin.class.isAssignableFrom(clazz)) { return RenderPluginEditorPlugin.class.getName(); } } catch (ClassNotFoundException ex) { IResourceSettings resourceSettings = Application.get().getResourceSettings(); IResourceStreamLocator locator = resourceSettings.getResourceStreamLocator(); IResourceStream stream = locator.locate(null, pluginClass.replace('.', '/') + ".html"); if (stream == null) { String message = ex.getClass().getName() + ": " + ex.getMessage(); log.error(message, ex); } else { return LayoutPluginEditorPlugin.class.getName(); } } return null; }