/** * Performs logout. */ @EventHandler(value = "click", target = "mnuLogout") private void onClick$mnuLogout() { shell.logout(); }
/** * Locates a loaded plugin with the specified id. * * @param id Id of plugin to locate. * @param forceInit If true the plugin will be initialized if not already so. * @return A reference to the loaded and fully initialized plugin, or null if not found. */ public ElementPlugin getLoadedPlugin(String id, boolean forceInit) { ElementPlugin plugin = getLoadedPlugin(id); if (plugin != null && forceInit) { plugin.load(); } return plugin; }
/** * Sends an informational message for display by desktop. * * @param message Text of the message. * @param caption Optional caption text. */ public static void showMessage(String message, String caption) { getShell().getMessageWindow().showMessage(message, caption); }
@Override protected void onAttach(Page page) { try { CommandUtil.associateCommand("help", this); getPage().addChild(messageWindow = new MessageWindow()); addChild(registeredStyles); desktop = new ElementDesktop(this); setLogoutConfirm(logoutConfirm); String confirmClose = getAppProperty("confirmClose", "CAREWEB.CONFIRM.CLOSE"); if (StringUtils.isEmpty(confirmClose) || BooleanUtils.toBoolean(confirmClose)) { ClientUtil.canClose(false); } String layout = defaultLayoutName != null ? defaultLayoutName : getAppProperty("layout", "CAREWEB.LAYOUT.DEFAULT"); if (!StringUtils.isEmpty(layout)) { loadLayout(layout); } } catch (Exception e) { log.error("Error initializing the shell.", e); throw MiscUtil.toUnchecked(e); } }
@Test public void test() throws Exception { CareWebShell shell = new CareWebShell(); shell.setLayout("/StatusPanelTest.xml"); shell.setPage(mockEnvironment.getDesktop().getFirstPage()); shell.afterCompose(); mockEnvironment.flushEvents(); PluginContainer plugin = shell.getActivatedPlugin("statusPanel"); Component root = plugin.getFirstChild(); StatusPanel controller = (StatusPanel) FrameworkController.getController(root); assertNotNull("Controller must not be null.", controller); assertEquals(1, root.getChildren().size()); test(root, "STATUS", 1, 1); test(root, "STATUS.TEST1", 1, 3); test(root, "STATUS.TEST1", 2, 3); test(root, "STATUS.TEST2", 1, 5); test(root, "STATUS.TEST2", 2, 5); }
@Test public void test() throws Exception { CareWebShell shell = new CareWebShell(); shell.setParent(getMockEnvironment().getSession().getPage()); shell.setLayout("/StatusPanelTest.xml"); getMockEnvironment().flushEvents(); ElementPlugin plugin = shell.getActivatedPlugin("cwfStatusPanel"); BaseComponent root = plugin.getOuterComponent().getFirstChild(); StatusPanel controller = (StatusPanel) FrameworkController.getController(root); assertNotNull("Controller must not be null.", controller); assertEquals(1, root.getChildren().size()); test(root, "STATUS", 1, 1); test(root, "STATUS.TEST1", 1, 2); test(root, "STATUS.TEST1", 2, 2); test(root, "STATUS.TEST2", 1, 3); test(root, "STATUS.TEST2", 2, 3); }
@Test public void parserTest() throws Exception { shell = new CareWebShell(); shell.setParent(getMockEnvironment().getSession().getPage()); parserTestFile("layout-v3.xml", false); parserTestFile("layout-v4.xml", true); }
ElementBase ele = def.createElement(null, null, false); assertTrue(ele instanceof ElementTreeView); ElementDesktop root = shell.getDesktop(); root.removeChildren(); layout.materialize(root); testNode(0, ElementTreePane.class); testProperty("label", "Pane 2"); ElementPlugin plugin1 = shell.getLoadedPlugin("testplugin1"); assertNotNull(plugin1); assertEquals(hasTrigger ? 1 : 0, plugin1.getTriggers().size());
/** * Event handler for lock link */ public void onClick$lock() { CareWebUtil.getShell().lock(); }
public ElementDesktop(CareWebShell shell) throws Exception { super(); this.shell = shell; desktopOuter = createFromTemplate(); setOuterComponent(desktopOuter); setInnerComponent(desktopInner); menubar = new ElementMenubar(menubar1); toolbar = new ElementToolbar(toolbar1); ActionUtil.addAction(mnuAbout, "groovy:org.carewebframework.shell.CareWebUtil.about();"); ActionUtil.addAction(mnuTOC, "groovy:org.carewebframework.shell.CareWebUtil.showHelpTOC();"); fixedHelpItems = helpMenu.getChildCount(); sortHelpMenu = false; helpMenu.addEventListener("open", (event) -> { if (sortHelpMenu) { sortHelpMenu(); } }); if (SecurityUtil.isGrantedAny(DesignConstants.DESIGN_MODE_PRIVS)) { DesignMenu.create(this, menubar0); } addChild(menubar); addChild(toolbar); setTitle(getTitle()); shell.addChild(desktopOuter); }
/** * Event handler for lock link */ @EventHandler(value = "click", target = "lock") private void onClick$lock() { CareWebUtil.getShell().lock(); }
/** * Event handler for logout link */ public void onClick$logout() { CareWebUtil.getShell().logout(); }
/** * If event data is of the format [session id]^[requester], this is an invitation * request. If event data is of the format [session id], it is a cancellation of a * previous request. */ @Override public void eventCallback(String eventName, String eventData) { String[] pcs = eventData.split("\\^", 2); String tag = EVENT_INVITE + "_" + pcs[0]; CareWebShell shell = CareWebUtil.getShell(); if (pcs.length == 2) { String message = StrUtil.formatMessage("@cwf.chat.invitation.message", pcs[1]); String caption = StrUtil.formatMessage("@cwf.chat.invitation.caption"); shell.getMessageWindow().showMessage(message, caption, null, 999999, tag, (event) -> { eventManager.fireLocalEvent(EVENT_ACCEPT, pcs[0]); }); } else { shell.getMessageWindow().clearMessages(tag); } } };
/** * Event handler for logout link */ @EventHandler(value = "click", target = "logout") private void onClick$logout() { CareWebUtil.getShell().logout(); }