/** * Returns the application context associated with the given page. * * @param page Page instance. * @return Application context associated with the page. */ public static XmlWebApplicationContext getAppContext(Page page) { return page == null ? null : (XmlWebApplicationContext) page.getAttribute(APP_CONTEXT_ATTRIB); }
/** * Returns the active instance of the CareWeb shell. * * @return The shell instance. */ public static CareWebShell getShell() { return (CareWebShell) ExecutionContext.getPage().getAttribute(Constants.SHELL_INSTANCE); }
/** * Returns the help viewer mode for the specified page. * * @param page The page to check. If null, the global setting is returned. * @return The help viewer mode. */ public static HelpViewerMode getViewerMode(Page page) { return page == null || !page.hasAttribute(EMBEDDED_ATTRIB) ? defaultMode : (HelpViewerMode) page.getAttribute(EMBEDDED_ATTRIB); }
/** * Remove and optionally close the specified help viewer if is the active viewer for the * specified page. * * @param page The page owner the help viewer. * @param viewer The viewer to remove. * @param close If true, close the help viewer after removing it. */ protected static void removeViewer(Page page, IHelpViewer viewer, boolean close) { if (viewer != null && viewer == page.getAttribute(VIEWER_ATTRIB)) { removeViewer(page, close); } }
/** * Returns an instance of the viewer for the current page. If no instance yet exists and * forceCreate is true, one is created. * * @param forceCreate If true, a viewer instance will be created if it does not exist. * @return The help viewer (may be null). */ public static IHelpViewer getViewer(boolean forceCreate) { Page page = getPage(); IHelpViewer viewer = (IHelpViewer) page.getAttribute(VIEWER_ATTRIB); return viewer != null ? viewer : forceCreate ? createViewer(page) : null; }
/** * Returns an instance of the design context menu. This is a singleton with the page scope and * is cached once created. * * @return The design context menu for the active page. */ public static DesignContextMenu getInstance() { Page page = ExecutionContext.getPage(); DesignContextMenu contextMenu = page.getAttribute(DesignConstants.ATTR_DESIGN_MENU, DesignContextMenu.class); if (contextMenu == null) { contextMenu = create(); page.setAttribute(DesignConstants.ATTR_DESIGN_MENU, contextMenu); } return contextMenu; }
/** * Returns an instance of the layout manager. If the layout manager is open, returns that * instance. If not and autoCreate is true, creates a new one. * * @param autoCreate If true and dialog does not exist, it is created. * @return The layout manager. */ private static Window getInstance(boolean autoCreate) { Page page = ExecutionContext.getPage(); Window dlg = page.getAttribute(DIALOG, Window.class); if (autoCreate && dlg == null) { dlg = DialogUtil.popup(DIALOG, true, true, false); page.setAttribute(DIALOG, dlg); } return dlg; }
/** * Returns a reference to the registry for global or local actions. * * @param global If true, return the global registry; if false, the local registry. * @return An action registry. */ private static ActionRegistry getRegistry(boolean global) { if (global) { return instance; } Page page = ExecutionContext.getPage(); ActionRegistry registry = (ActionRegistry) page.getAttribute(ATTR_LOCAL_REGISTRY); if (registry == null) { page.setAttribute(ATTR_LOCAL_REGISTRY, registry = new ActionRegistry()); } return registry; }
@Override public void afterInitialized(BaseComponent comp) { window = (Window) comp; window.setCloseAction(CloseAction.HIDE); comp.setAttribute("controller", this); bringToFront = comp.getPage().getAttribute(ATTR_BRING_TO_FRONT, true); layoutChangedEvent = new LayoutChangedEvent(comp, null); contextMenu.setListener(comp); clipboard.addListener(comp); comp.getPage().addEventListener("register unregister", layoutListener); }
@Override public void afterInitialized(BaseComponent root) { super.afterInitialized(root); page = root.getPage(); session = page.getSession(); noAutoLock = page.getAttribute(ATTR_NO_AUTO_LOCK, false); timeoutWindow = (BaseUIComponent) root; getEventManager().subscribe(SessionControl.EVENT_ROOT, applicationControlListener); IUser user = securityService.getAuthenticatedUser(); lblLocked.setLabel(user == null ? null : Mode.BASELINE.getLabel(TIMEOUT_EXPIRATION, user.getFullName() + "@" + user.getSecurityDomain().getName())); setMode(Mode.BASELINE); session.addSessionListener(sessionListener); }