/** * Shows or hide this frame. This means it gets (un)registered at the session. * * @see org.wings.session.Session#getFrames() */ @Override public void setVisible(boolean visible) { if (visible != isVisible()) { if (visible) { List newHeaders = new ArrayList(SessionHeaders.getInstance().getHeaders()); for (Object oldHeaders : headers) { if (!newHeaders.contains(oldHeaders)) { newHeaders.add(oldHeaders); } } headers = newHeaders; getSession().addFrame(this); register(); } else { getSession().removeFrame(this); unregister(); } super.setVisible(visible); setRecursivelyVisible(visible); } }
public static SFrame getFrame(WingsSession wingsSession) { String path = wingsSession.getServletRequest().getServletPath(); int pos = path.lastIndexOf('/'); path = path.substring(pos + 1); synchronized (wingsSession.getServletRequest().getSession()) { Map frames = getFrames(wingsSession); SFrame frame = (SFrame)frames.get(path); if (frame == null) { frame = new SFrame(path); frame.setTargetResource(path); frame.show(); frames.put(path, frame); } return frame; } }
private static void fullScreenAttributes(SFrame frame) { Boolean fullScreenAttributesApplied = (Boolean)frame.getClientProperty("fullScreenAttributesApplied"); if (frame.isFullScreen() && !Boolean.TRUE.equals(fullScreenAttributesApplied)) { if (!Utils.isMSIE(frame)) { frame.getContentPane().setAttribute(CSSProperty.POSITION, "absolute"); frame.getContentPane().setAttribute(CSSProperty.HEIGHT, "100%"); frame.getContentPane().setAttribute(CSSProperty.WIDTH, "100%"); } frame.setAttribute(CSSProperty.POSITION, "absolute"); frame.setAttribute(CSSProperty.HEIGHT, "100%"); frame.setAttribute(CSSProperty.WIDTH, "100%"); frame.putClientProperty("fullScreenAttributesApplied", Boolean.TRUE); } else if (!frame.isFullScreen() && Boolean.TRUE.equals(fullScreenAttributesApplied)){ if (!Utils.isMSIE(frame)) { frame.getContentPane().setAttribute(CSSProperty.POSITION, null); frame.getContentPane().setAttribute(CSSProperty.HEIGHT, null); frame.getContentPane().setAttribute(CSSProperty.WIDTH, null); } frame.setAttribute(CSSProperty.POSITION, null); frame.setAttribute(CSSProperty.HEIGHT, null); frame.setAttribute(CSSProperty.WIDTH, null); frame.putClientProperty("fullScreenAttributesApplied", Boolean.FALSE); } }
@Override public void propertyChange(PropertyChangeEvent pe) { if ("lookAndFeel".equals(pe.getPropertyName())) { updateComponentTreeCG(getContentPane()); } if ("request.url".equals(pe.getPropertyName())) { setRequestURL((RequestURL) pe.getNewValue()); } }
public void setFullScreen(boolean fullScreen) { if (isDifferent(this.fullScreen, fullScreen)) { boolean oldFullScreen = this.fullScreen; this.fullScreen = fullScreen; if (fullScreen) getContentPane().setPreferredSize(SDimension.FULLAREA); reload(); propertyChangeSupport.firePropertyChange("fullScreen", oldFullScreen, this.fullScreen); } }
String strokes = strokes(frame.getGlobalInputMapComponents()); if (strokes != null) component.getSession().getScriptManager().addScriptListener(new JavaScriptListener(null, null, strokes)); if (!frame.isVisible()) return; frame.fireRenderEvent(SComponent.START_RENDERING); final String title = frame.getTitle(); final String encoding = session.getCharacterEncoding(); boolean isDebug = SFrame.isDebugJs(); for (Object next : frame.getHeaders()) { if (next instanceof Renderable) { try { if (frame.getFocus() != null) { String script = "wingS.util.requestFocus('" + frame.getFocus().getName() + "');"; ScriptManager.getInstance().addScriptListener(new OnPageRenderedScript(script)); if (frame.isVisible()) { Utils.createExternalizedJSHeaderFromProperty(Utils.JS_ETC_WZ_TOOLTIP).write(device); device.print("\n"); frame.getLayout().write(device); Set<SComponent> menues = frame.getSession().getMenuManager().getMenues(frame); for (SComponent menuItem : menues) { menuItem.putClientProperty("popup", Boolean.TRUE);
String strokes = strokes(frame.getGlobalInputMapComponents()); if (strokes != null) component.getSession().getScriptManager().addScriptListener(new JavaScriptListener(null, null, strokes)); if (!frame.isVisible()) return; frame.fireRenderEvent(SComponent.START_RENDERING); for (Object next : frame.getHeaders()) { if (next instanceof Renderable) { try { if (frame.getFocus() != null) { String script = "wingS.util.requestFocus('" + frame.getFocus().getName() + "');"; ScriptManager.getInstance().addScriptListener(new OnPageRenderedScript(script)); if (frame.isVisible()) { Utils.createExternalizedJSHeaderFromProperty(Utils.JS_ETC_WZ_TOOLTIP).write(device); device.print("\n"); frame.getLayout().write(device); Set menues = frame.getSession().getMenuManager().getMenues(frame); for (Object menue : menues) { SComponent menuItem = (SComponent) menue; DragAndDropManager dndManager = frame.getSession().getDragAndDropManager(); dndManager.getCG().write(device, dndManager);
private static void writeGlobalInitScript(Device out, SFrame frame) throws IOException { Map<String, Object> initConfig = new HashMap<>(); initConfig.put("eventEpoch", frame.getEventEpoch()); initConfig.put("reloadResource", frame.getDynamicResource(ReloadResource.class).getURL().toString()); initConfig.put("updateResource", frame.getDynamicResource(UpdateResource.class).getURL().toString()); initConfig.put("updateEnabled", frame.isUpdateEnabled()); initConfig.put("updateCursor", Utils.mapToJsObject(frame.getUpdateCursor())); initConfig.put("autoAdjustLayout", Utils.mapToJsObject(frame.getAutoAdjustLayout())); initConfig.put("cometEnabled", frame.getSession().getComet() != null && frame.getSession().getComet().isCometEnabled()); final String logLevel = SFrame.getLogLevel(); if (logLevel != null && !logLevel.isEmpty()) { initConfig.put("loglevel", logLevel); } out.print("wingS.global.init("); Utils.mapToJsObject(initConfig).write(out); out.print(");"); }
private void createControllerFrame() { controllerFrame = new SFrame(); String w = "95%"; String h = "768px"; if (getFrameWidth() != null) { w = getFrameWidth().intValue() + "px"; } if (getFrameHeight() != null) { h = getFrameHeight().intValue() + "px"; } controllerFrame.setPreferredSize(new SDimension(w, h)); controllerFrame.getContentPane().setPreferredSize(SDimension.FULLAREA); cardPanel = new SPanel(new SCardLayout()); cardPanel.setPreferredSize(SDimension.FULLAREA); controllerFrame.getContentPane().add(cardPanel, SBorderLayout.CENTER); statusBar = new SLabel(); statusBar.setBorder(new SLineBorder(1)); statusBar.setVisible(false); controllerFrame.getContentPane().add(statusBar, BorderLayout.SOUTH); updateFrameTitle(); controllerFrame.setVisible(true); }
final SFrame errorFrame = new SFrame(); errorFrame.getContentPane().setLayout(layout); errorFrame.getContentPane().add(errorStackTraceLabel, "EXCEPTION_STACK_TRACE"); errorFrame.getContentPane().add(errorMessageLabel, "EXCEPTION_MESSAGE"); errorFrame.getContentPane().add(versionLabel, "WINGS_VERSION"); errorFrame.setVisible(true); errorFrame.write(device); errorFrame.setVisible(false);
/** * The MIME-type for this {@link Resource}. */ private static String provideMimeType(SFrame frame) { return "text/html; charset=" + frame.getSession().getCharacterEncoding(); }
private SFrame createControllerFrame() { SFrame frame = new SFrame(); frame .setPreferredSize(new SDimension(frameWidth, frameHeight/* WingsUtil.FULL_DIM_PERCENT */)); cardPanel = new SPanel(new SCardLayout()); cardPanel.setPreferredSize(SDimension.FULLAREA); frame.getContentPane().add(createApplicationMenuBar(), SBorderLayout.NORTH); frame.getContentPane().add(cardPanel, SBorderLayout.CENTER); frame.getContentPane().setPreferredSize(SDimension.FULLAREA); return frame; }
/** * Creates a new SFrame */ public SFrame() { getSession().addPropertyChangeListener("lookAndFeel", this); getSession().addPropertyChangeListener("request.url", this); this.visible = false; // Frames are invisible originally. setUpdateEnabled(true); Map<String, Object> updateCursor = new HashMap<>(); SIcon cursorImage = new SResourceIcon("org/wings/icons/AjaxActivityCursor.gif"); updateCursor.put("enabled", true); updateCursor.put("image", cursorImage.getURL().toString()); updateCursor.put("width", cursorImage.getIconWidth()); updateCursor.put("height", cursorImage.getIconHeight()); updateCursor.put("dx", 15); updateCursor.put("dy", 0); setUpdateCursor(updateCursor); Map<String, Object> autoAdjustLayout = new HashMap<>(); autoAdjustLayout.put("enabled", true); autoAdjustLayout.put("delay", 250); setAutoAdjustLayout(autoAdjustLayout); addStyle("yui-skin-sam"); }
public InputMapRequestListener(SFrame frame) { this.frame = frame; frame.putClientProperty("InputMapRequestListener", this); frame.getSession().addRequestListener(e -> { if (e.getType() == SRequestEvent.DELIVER_START && InputMapRequestListener.this.frame.getDynamicResources().contains(e.getRequestedResource().getObject())) { boolean changeDetected = false; Set<SComponent> components = InputMapRequestListener.this.frame.getGlobalInputMapComponents(); for (SComponent component : components) { boolean visible = component.isRecursivelyVisible(); if (!Boolean.valueOf(visible).equals(component.getClientProperty("visible"))) { component.putClientProperty("visible", visible); changeDetected |= true; } } for (SComponent component : components) { if (checkForChange(component, SComponent.WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT)) { changeDetected |= true; } if (checkForChange(component, SComponent.WHEN_IN_FOCUSED_FRAME)) { changeDetected |= true; } } if (changeDetected) { String script = strokes(components); InputMapRequestListener.this.frame.getSession().getScriptManager().addScriptListener(new JavaScriptListener(null, null, script)); } } }); }
/** * Returns the base URL for a request to the WingsServlet. This URL * is used to assemble an URL that trigger events. In order to be used * for this purpose, you've to add your parameters here. */ @Override public final RequestURL getRequestURL() { // first time we are called, and we didn't get any change yet if (requestURL == null) { requestURL = (RequestURL) getSession().getProperty("request.url"); } RequestURL result = null; if (requestURL != null) { result = (RequestURL) requestURL.clone(); result.setEventEpoch(epochCache); result.setResource(getTargetResource()); } return result; }
/** * Searches the current session for the root HTML frame and returns the Resource * representing this root HTML frame (i.e. for you to retrieve the externalizer id * via <code>getId()</code>-method). * @return Resource of the root HTML frame */ private Resource retrieveCurrentRootFrameResource() throws ServletException { log.debug("delivering default frame"); if (session.getFrames().size() == 0) throw new ServletException("no frame visible"); // get the first frame from the set and walk up the hierarchy. // this should work in most cases. if there are more than one // toplevel frames, the developer has to care about the resource // ids anyway .. SFrame defaultFrame = (SFrame) session.getFrames().iterator().next(); while (defaultFrame.getParent() != null) defaultFrame = (SFrame) defaultFrame.getParent(); return defaultFrame.getDynamicResource(ReloadResource.class); }
protected static void handleScripts(Device device, SComponent component) throws IOException { final SFrame frame = (SFrame) component; final ScriptManager scriptManager = frame.getSession().getScriptManager(); final SToolTipManager tooltipManager = SToolTipManager.sharedInstance(); // hand script listeners of frame to script manager scriptManager.addScriptListeners(frame.getScriptListeners()); device.print("<script type=\"text/javascript\">\n"); // print all scripts writeGlobalInitScript(device, frame); device.print("\n"); writeTooltipInitScript(device, tooltipManager); device.print("\n"); ScriptListener[] scriptListeners = scriptManager.getScriptListeners(); for (ScriptListener scriptListener : scriptListeners) { if (scriptListener.getScript() != null) { device.print(scriptListener.getScript()).print("\n"); } } scriptManager.clearScriptListeners(); device.print("</script>\n"); }
/** * Shows this frame. This means it gets registered at the session. * * @see org.wings.session.Session#getFrames() */ public void show() { setVisible(true); }
public void addComponent(String name, SComponent component) throws ServletException { SFrame frame = getFrame(this); frame.getContentPane().add(component, name); setProperty(name, component); }
/** * Creates a new SFrame * * @param title Title of this frame, rendered in browser window title */ public SFrame(String title) { this(); setTitle(title); }