List of usage examples for com.google.gwt.user.client Window getClientWidth
public static int getClientWidth()
From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java
License:Apache License
public static void createWindow(UIGVO ui, String windowId) { Widget w = GWTUIGenerator.createView(ui, windowId); if (ClientApplicationContext.getInstance().isMDI()) { WindowGVO windowGVO = getWindow(ui, windowId); String windowTitle = getWindowTitle(ui, windowId); if (windowGVO != null) { windowTitle = windowGVO.getTitle(); }/*w w w . j av a 2s . co m*/ if (w != null) { WindowPanel window = new QWindowPanel(windowTitle); window.getHeader().setText(windowTitle); if (w instanceof QRootPanel) { ((QWindowPanel) window).setQRootPanel((QRootPanel) w); } window.setAnimationEnabled(true); ((QWindowPanel) window).setManaged(true); // Do not pack the windows if the "width" or "height" attributes // are on boolean bPack = true; // window.updateSize(); if (windowGVO.getHeight() != null && windowGVO.getHeight().length() > 0) { try { int height = Integer.parseInt(windowGVO.getHeight()); // Test if the height is not negative if (height < 0) throw new NumberFormatException(); bPack = false; window.setHeight(height + "px"); } catch (NumberFormatException e) { ClientApplicationContext.getInstance() .log("could not set height on Window (it's not a valid integer):" + windowGVO.getHeight()); } } if (windowGVO.getWidth() != null && windowGVO.getWidth().length() > 0) { try { int width = Integer.parseInt(windowGVO.getWidth()); // Test if the width is not negative if (width < 0) throw new NumberFormatException(); bPack = false; window.setWidth(width + "px"); } catch (NumberFormatException e) { ClientApplicationContext.getInstance().log( "could not set width on Window (it's not a valid integer):" + windowGVO.getWidth()); } } if (currentWindowTitle == null) currentWindowTitle = windowGVO.getTitle(); if (!windowTitle.equalsIgnoreCase(currentWindowTitle)) { ClientApplicationContext.getInstance().updatePosition(); } currentWindowTitle = windowTitle; int left = ClientApplicationContext.getInstance().getStartXPosition(); int top = ClientApplicationContext.getInstance().getStartYPosition(); if (windowGVO.getLeft() != null) { left = windowGVO.getLeft(); } if (windowGVO.getTop() != null) { top = windowGVO.getTop(); } window.setPopupPosition(left, top); ClientApplicationContext.getInstance().addWindows(ui, window, windowId); if (Cookies.getCookie(ui.getUuid() + "-top-" + windowId) != null && Cookies.getCookie(ui.getUuid() + "-left-" + windowId) != null) { // There is a known bug that causes the parsing of the position stored as string in the cookie to be // returned as a double. double leftPos = Double.parseDouble(Cookies.getCookie(ui.getUuid() + "-left-" + windowId)); double rightPos = Double.parseDouble(Cookies.getCookie(ui.getUuid() + "-top-" + windowId)); int roundedLeftPos = (int) Math.round(leftPos); int roundedRightPos = (int) Math.round(rightPos); window.setPopupPosition(roundedLeftPos, roundedRightPos); } window.setWidget(w); // If the width or the height attributes were set then we don't // pack the window // Use the default width and height that you got in the ClientApplicationContext. if (ClientApplicationContext.getInstance().getGlobalConfigurations() .get("window.default.height") != null && windowGVO.getHeight() == null) { window.setHeight(ClientApplicationContext.getInstance().getGlobalConfigurations() .get("window.default.height")); bPack = false; } if (ClientApplicationContext.getInstance().getGlobalConfigurations() .get("window.default.width") != null && windowGVO.getWidth() == null) { window.setWidth(ClientApplicationContext.getInstance().getGlobalConfigurations() .get("window.default.width")); bPack = false; } if (bPack) { window.pack(); if (window.getContentHeight() > (int) (Window.getClientHeight() * 0.8)) { Dimension d = window.getContentSize(); Dimension newD = new Dimension(d.getWidth(), Window.getClientHeight() / 2); window.setContentSize(newD); } if (window.getContentWidth() > (int) (Window.getClientWidth() * 0.8)) { Dimension d = window.getContentSize(); Dimension newD = new Dimension(Window.getClientWidth() / 2, d.getHeight()); window.setContentSize(newD); } } window.show(); modifyWindowSize(w, window); EventFactory.createWindowSizeEvent(ui.getUuid(), windowId, window); if (windowGVO != null) { RendererHelper.addStyle(windowGVO.getRootPanel(), ((QWindowPanel) window).getQRootPanel()); if (windowGVO.getClosable() != null) { ((QWindowPanel) window).setClosable(windowGVO.getClosable().booleanValue()); } if (windowGVO.getMaximizable() != null && windowGVO.getMaximizable().booleanValue()) { ((QWindowPanel) window).addMaximizeButton();// setMaximizable(windowGVO.getMaximizable().booleanValue()); } if (windowGVO.getMinimizable() != null && windowGVO.getMinimizable().booleanValue()) { ((QWindowPanel) window).addMinimizeButton(); } if (windowGVO.getResizable() != null) { window.setResizable(windowGVO.getResizable().booleanValue()); } // The id of the ui-window is winId|winId|appId (<id>|<parent>|<context>), // while the id of ui-components within a window is componentId|winId|appId RendererHelper.addId(windowGVO, window, ui.getUuid(), windowGVO.getId(), windowGVO.getContext(), true); RendererHelper.addUUID(windowGVO, window, ui.getUuid()); // /// TODO Check the unload and window actions... EventFactory.createDefaultCloseEvent(windowGVO, window, ClientApplicationContext.getInstance().getWindowSession(), ui.getUuid()); EventFactory.createWindowStateChangeListener(window, windowTitle, ui.getUuid(), windowId); } } else { ClientApplicationContext.getInstance().log("Opening Window failed", "Window with id '" + windowId + "' could not be opened.\n This Window might not exist in this application context", true); } } else { WindowGVO windowGVO = getWindow(ui, windowId); setWidgetToMainPanel(w, windowGVO); } }
From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java
License:Apache License
public static void setWidgetToMainPanel(Widget w, WindowGVO windowGVO) { if (w != null) { clearWidgetFromMainPanel();// ww w . java 2 s.c om SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel(); if (mainPanel == null) { mainPanel = new SimplePanel(); mainPanel.setWidth(Window.getClientWidth() + "px"); mainPanel.setHeight(Window.getClientHeight() + "px"); ClientApplicationContext.getInstance().setMainPanel(mainPanel); MenuBar menuBar = ClientApplicationContext.getInstance().getApplicationsMenu(); if (menuBar != null) { menuBar.addStyleName("SDIMenu"); RootPanel.get().add((Widget) mainPanel, 0, 24); } else { RootPanel.get().add((Widget) mainPanel, 0, 0); } } w.setWidth(Window.getClientWidth() + "px"); w.setHeight(Window.getClientHeight() + "px"); mainPanel.addStyleName("SDIWrapper"); mainPanel.setWidget(w); w.addStyleName("SDIPanel"); if (windowGVO != null) { RendererHelper.addStyle(windowGVO.getRootPanel(), w); } } }
From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java
License:Apache License
protected void moveWidgets() { try {/* w w w . j a va 2s . c o m*/ DOM.setStyleAttribute(ClientApplicationContext.getInstance().getPi().getElement(), "left", "" + (Window.getClientWidth() - ClientApplicationContext.getInstance().getPi().getWidth())); if (ClientApplicationContext.getInstance().isMDI()) { if (ClientApplicationContext.getInstance().getDockMode().booleanValue()) { int dockWidth = ClientApplicationContext.getInstance().getDockPanel().getOffsetWidth(); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(), "left", Window.getClientWidth() / 2 - (dockWidth / 2) + ""); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(), "top", "" + (Window.getClientHeight() - 80)); } else { DOM.setStyleAttribute(ClientApplicationContext.getInstance().getBottomMenuBar().getElement(), "left", "" + 0); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getBottomMenuBar().getElement(), "top", "" + (Window.getClientHeight() - 25)); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getHorizontalPanel().getElement(), "left", "" + 0); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getHorizontalPanel().getElement(), "top", "" + (Window.getClientHeight() - 23)); } } else { SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel(); mainPanel.setWidth(Window.getClientWidth() + "px"); mainPanel.setHeight(Window.getClientHeight() + "px"); } } catch (Exception e) { } }
From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java
License:Apache License
protected static void setupMDI(Boolean dockMode) { Window.enableScrolling(false); ClientApplicationContext.getInstance().setMode(ClientApplicationContext.MDI); ClientApplicationContext.getInstance().setDockMode(dockMode); RootPanel.get(rootPanelValue).add(buildMenu(), 0, 0); MainFactoryActions.processUIFromApplicationContext(); ClientApplicationContext.getInstance().setLogText("MDI Mode"); if (dockMode.booleanValue()) { Panel dockPanel = new HorizontalPanel(); ClientApplicationContext.getInstance().setDockPanel(dockPanel); RootPanel.get(rootPanelValue).add(dockPanel, Window.getClientWidth() / 2, Window.getClientHeight() - 80); } else {//from w w w . j a v a 2 s .com RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getHorizontalPanel(), 0, Window.getClientHeight() - 23); ClientApplicationContext.getInstance().getBottomMenuBar().setWidth("100%"); ClientApplicationContext.getInstance().getBottomMenuBar().addItem(" ", new Command() { @Override public void execute() { } }); RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getBottomMenuBar(), 0, Window.getClientHeight() - 25); } AbsolutePanel image = new AbsolutePanel(); image.addStyleName("imglogo"); RootPanel.get(rootPanelValue).add(image); RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getPi(), Window.getClientWidth() - ClientApplicationContext.getInstance().getPi().getWidth(), 3); }
From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java
License:Apache License
protected static void setupSDI() { ClientApplicationContext.getInstance().setMode(ClientApplicationContext.SDI); // This will remove the horizontal scrollbar RootPanel.get(rootPanelValue).getElement().getStyle().setProperty("overflow-x", "hidden"); RootPanel.get(rootPanelValue).getElement().addClassName("SDIBody"); RootPanel.get(rootPanelValue).add(buildMenu(), 0, 0); MainFactoryActions.processUIFromApplicationContext(); ClientApplicationContext.getInstance().setLogText("SDI Mode"); RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getPi(), Window.getClientWidth() - ClientApplicationContext.getInstance().getPi().getWidth(), 3); }
From source file:com.qualogy.qafe.gwt.client.ui.GWTUIGenerator.java
License:Apache License
private static void addToDockPanel(final WindowGVO windowGVO, final String uuid, final String title, final String appId) { if (windowGVO != null && windowGVO.getIcon() != null && windowGVO.getIcon().length() > 0) { final String windowId = windowGVO.getId(); final Image dockImage = new Image(windowGVO.getIcon()); dockImage.setTitle(title);/*from w ww .j a va 2 s . c o m*/ //dockImage.setHeight(60 + "px"); //dockImage.setWidth(40 + "px"); dockImage.setStylePrimaryName("dockItem"); fillInMandatoryOnly(windowGVO, dockImage, uuid, windowId, appId); dockImage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { WindowPanel existingWindowPanel = ClientApplicationContext.getInstance() .windowIdExists(windowId, uuid); if (existingWindowPanel == null) { EventListenerGVO[] events = windowGVO.getEvents(); if (events != null) { String eventType = QAMLConstants.EVENT_ONCLICK; for (EventListenerGVO eventGVO : events) { if (eventGVO.getEventComponentId().equals(windowId) && eventGVO.getEventListenerType().equals(eventType)) { createCallBack4OpenWindow(dockImage, eventType, eventGVO); break; } } } // MainFactoryActions.getUIByUUID(uuid, windowId); } else { Iterator itr = ClientApplicationContext.getInstance().getHorizontalPanel().iterator(); while (itr.hasNext()) { Widget w = (Widget) itr.next(); if (w.getTitle().equals(title)) { existingWindowPanel.setWindowState(WindowState.NORMAL); existingWindowPanel.show(); ClientApplicationContext.getInstance().getHorizontalPanel().remove(w); } } existingWindowPanel.toFront(); } } }); if (ClientApplicationContext.getInstance().getDockPanel() != null) { ClientApplicationContext.getInstance().getDockPanel().add(dockImage); int dockWidth = ClientApplicationContext.getInstance().getDockPanel().getOffsetWidth(); DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(), "left", Window.getClientWidth() / 2 - (dockWidth / 2) + ""); } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.WindowRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { QRootPanel qRootPanel = null;//from www.j a va 2s . c om if (component != null) { if (component instanceof WindowGVO) { WindowGVO gvo = (WindowGVO) component; qRootPanel = new QRootPanel(); RendererHelper.addId(component, qRootPanel, uuid, parent, context, false); RendererHelper.addUUID(component, qRootPanel, uuid); RendererHelper.addEvents(component, qRootPanel, uuid); Widget rootPanel = (Widget) super.renderChildComponent(gvo.getRootPanel(), uuid, gvo.getId(), context); Widget menuAndToolbar = createMenuAndToolbar(qRootPanel, gvo.getRootPanel(), uuid, parent); Widget messageBox = new MessageBox(); ScrollPanel sp = new ScrollPanel(); if (ClientApplicationContext.getInstance().isMDI()) { sp.setHeight(gvo.getHeight()); sp.setWidth(gvo.getWidth()); } else { sp.setHeight(Window.getClientHeight() + "px"); sp.setWidth(Window.getClientWidth() + "px"); } sp.add(rootPanel); qRootPanel.setMenuAndToolBar(menuAndToolbar); qRootPanel.setRootPanel(sp); qRootPanel.setMessageBox(messageBox); qRootPanel.add(menuAndToolbar, 0, 0); int yPosition = toolbarHeight != null ? Integer.parseInt(toolbarHeight) + 20 : 0; if (qRootPanel.getMenuBar() != null) { yPosition += 22; } qRootPanel.add(sp, 0, yPosition); qRootPanel.add(messageBox, 200, 0); } } return qRootPanel; }
From source file:com.qualogy.qafe.gwt.client.vo.handlers.OpenWindowHandler.java
License:Apache License
private void calculateCenterCascade(final Map<String, String> paramMap, final boolean external) { final int width = getWidth(paramMap, 0); final int height = getHeight(paramMap, 0); final int startLeft = ((Window.getClientWidth() - width) / 2); final int startTop = ((Window.getClientHeight() - height) / 2); calculateCascadePosition(paramMap, startLeft, startTop, external); }
From source file:com.qualogy.qafe.gwt.client.vo.handlers.OpenWindowHandler.java
License:Apache License
private void calculateTiled(final Map<String, String> paramMap) { final int width = getWidth(paramMap, 0); final int height = getHeight(paramMap, 0); int top = 30; int left = 0; if (ClientApplicationContext.getInstance().internalWindowCount > 0) { int row = 1; int column = 1; boolean makeNextRow = false; for (int i = 0; i < ClientApplicationContext.getInstance().internalWindowCount; i++) { left = (width * (i + 1));// w ww. ja v a 2 s. c o m if ((left + width) > Window.getClientWidth()) { left = 0; makeNextRow = true; if (row > 1) { left = (width * column); column++; if ((left + width) > Window.getClientWidth()) { makeNextRow = true; } else { makeNextRow = false; } } if (makeNextRow) { left = 0; column = 1; top = 30 + (height * row); row++; makeNextRow = false; } } else { top = 30; } } } paramMap.put(LEFT, String.valueOf(left)); paramMap.put(TOP, String.valueOf(top)); }
From source file:com.risevision.ui.client.common.widgets.text.TextEditorWidget.java
License:Open Source License
public void resizeTextArea(int width, int height) { int outerWidth, outerHeight; int verticalScroll = 0; if (height > Window.getClientHeight() - 320) { outerHeight = Window.getClientHeight() - 320; verticalScroll = 16;/* ww w.j ava 2 s .c o m*/ } else { outerHeight = height + 10; } if (width < 465 - 10 - verticalScroll) { outerWidth = 465; } else if (width > Window.getClientWidth() - 160 - verticalScroll) { outerWidth = Window.getClientWidth() - 160; } else { outerWidth = width + 10 + verticalScroll; } textAreaScrollPanel.setSize(outerWidth + "px", outerHeight + "px"); textAreaInnerPanel.setPixelSize(width + 10, height + 10); textAreaBackgroundPanel.setPixelSize(width, height); textArea.setPixelSize(width, height); htmlEditor.setSize(Math.max(outerWidth, 500) + "px", Math.max((outerHeight + 53), 175) + "px"); }