List of usage examples for com.google.gwt.user.client Window getClientWidth
public static int getClientWidth()
From source file:ilarkesto.gwt.client.desktop.fields.AEditableDropdownField.java
License:Open Source License
private int getTextBoxWidth() { int width = Window.getClientWidth(); if (width > 700) width = 700; return width; }
From source file:ilarkesto.gwt.client.FullScreenDockWidget.java
License:Open Source License
private void updateCenterSize() { int width = Window.getClientWidth() - westWidth - 20; int height = Window.getClientHeight() - northHeight - 20; centerWrapper.setSize(width + "px", height + "px"); dock.setCellWidth(centerWrapper, width + "px"); dock.setCellHeight(centerWrapper, height + "px"); }
From source file:info.vstour.dbdoc.client.DbDoc.java
License:Apache License
public void onModuleLoad() { Window.enableScrolling(false); Window.setMargin("0" + UNIT); final VerticalPanel bodyVPanel = new VerticalPanel(); bodyVPanel.setWidth("100%"); final HorizontalPanel bodyHPanel = new HorizontalPanel(); bodyHPanel.setSpacing(3);//from w w w. j av a 2 s . c o m final HTML doc = new HTML(); final ScrollPanel docWrapper = new ScrollPanel(doc); objectsTree = new DbObjectsPanel(docService); final MenuPanel menuPanel = new MenuPanel(docService, eventBus); menuPanel.ownerChangeHandlers().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { objectsTree.clearDbObjects(); doc.setHTML(""); objectsTree.initDbObjects(Filter.get().getDbObjects()); } }); eventBus.addHandler(MenuUpdateEvent.TYPE, new MenuUpdateEvent.Handler() { @Override public void onMenuUpdate(MenuUpdateEvent event) { if (event.isNewConn()) { objectsTree.clear(); doc.setHTML(""); } else { objectsTree.clearDbObjects(); } objectsTree.initDbObjects(Filter.get().getDbObjects()); } }); objectsTree.getTreeOpenHandler().addOpenHandler(new OpenHandler<TreeItem>() { public void onOpen(OpenEvent<TreeItem> event) { final TreeItem treeItem = event.getTarget(); if (treeItem.getChild(0).getText().isEmpty()) { doc.setHTML(new Image(Resources.INSTANCE.processing()).toString()); docService.getTreeItems(Filter.get().getConnName(), Filter.get().getOwner(), treeItem.getText(), Filter.get().getFilter(), new AsyncCallback<List<String>>() { @Override public void onSuccess(List<String> items) { doc.setHTML(""); for (String item : items) { treeItem.addItem(item); } } @Override public void onFailure(Throwable caught) { doc.setHTML(""); } }); // Remove the temporary item when we finish loading treeItem.getChild(0).remove(); } } }); // Handler that gets documentation SelectionHandler<TreeItem> sHandler = new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { final TreeItem treeItem = event.getSelectedItem(); if (treeItem.getParentItem() != null) { final String parent = treeItem.getParentItem().getText(); final String child = treeItem.getText(); doc.setHTML(new Image(Resources.INSTANCE.processing()).toString()); docService.getDoc(Filter.get().getConnName(), Filter.get().getOwner(), parent, child, new AsyncCallback<String>() { public void onFailure(Throwable caught) { doc.setHTML(caught.toString()); } public void onSuccess(String result) { objectsTree.cacheDoc(Filter.get().getOwner() + "." + child, result); doc.setHTML(result); } }); } } }; objectsTree.getTreeSelectionHandler().addSelectionHandler(sHandler); objectsTree.getCacheTreeSelectionHandler().addSelectionHandler(new SelectionHandler<TreeItem>() { @Override public void onSelection(SelectionEvent<TreeItem> event) { doc.setHTML(objectsTree.getCachedDoc(event.getSelectedItem().getText())); } }); bodyHPanel.add(objectsTree); bodyHPanel.add(docWrapper); bodyVPanel.add(menuPanel); bodyVPanel.add(bodyHPanel); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { int height = event.getHeight(); int width = event.getWidth(); bodyVPanel.setHeight(height + UNIT); docWrapper.setHeight(height - docWrapper.getAbsoluteTop() + UNIT); docWrapper.setWidth(width - docWrapper.getAbsoluteLeft() + UNIT); objectsTree.setHeight(height); } }); RootPanel.get().add(bodyVPanel); objectsTree.setHeight(Window.getClientHeight()); docWrapper.setHeight(Window.getClientHeight() - docWrapper.getAbsoluteTop() + UNIT); docWrapper.setWidth(Window.getClientWidth() - docWrapper.getAbsoluteLeft() + UNIT); }
From source file:jake2.gwt.client.GwtQuake.java
License:Open Source License
public void onModuleLoad() { // Initialize drivers. Document doc = Document.get(); doc.setTitle("GWT Quake II"); BodyElement body = doc.getBody();/*from w w w .j ava2s . c o m*/ Style style = body.getStyle(); style.setPadding(0, Unit.PX); style.setMargin(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("height", "100%"); style.setBackgroundColor("#000"); style.setColor("#888"); boolean wireframe = ("" + Window.Location.getHash()).indexOf("wireframe") != -1; canvas = (CanvasElement) doc.createElement("canvas"); video = doc.createElement("video"); w = Window.getClientWidth(); h = Window.getClientHeight(); canvas.setWidth(w); canvas.setHeight(h); style = canvas.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style = video.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style.setProperty("display", "none"); body.appendChild(canvas); body.appendChild(video); try { final refexport_t renderer = wireframe ? new GwtWireframeGLRenderer(canvas) : new GwtWebGLRenderer(canvas, video); Globals.re = renderer; ResourceLoader.impl = new GwtResourceLoaderImpl(); Compatibility.impl = new CompatibilityImpl(); S.impl = new GwtSound(); NET.socketFactory = new WebSocketFactoryImpl(); // Sys.impl = new Sys.SysImpl() { // public void exit(int status) { // Window.alert("Something's rotten in Denmark"); // Window.Location.assign("gameover.html"); // } // }; // Flags. Qcommon.Init(new String[] { "GQuake" }); // Enable stdout. Globals.nostdout = Cvar.Get("nostdout", "0", 0); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (Window.getClientWidth() == w && Window.getClientHeight() == h) { return; } w = Window.getClientWidth(); h = Window.getClientHeight(); renderer.GLimp_SetMode(new Dimension(w, h), 0, false); } }); // QuakeServer.main(new String[0], new DummySNetImpl(), false); timer = new Timer() { double startTime = Duration.currentTimeMillis(); @Override public void run() { try { double curTime = Duration.currentTimeMillis(); boolean pumping = ResourceLoader.Pump(); if (pumping) { SCR.UpdateScreen2(); } else { int dt = (int) (curTime - startTime); GwtKBD.Frame(dt); Qcommon.Frame(dt); } startTime = curTime; timer.schedule(ResourceLoader.Pump() ? LOADING_DELAY : INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); } } }; timer.schedule(INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); body.setInnerHTML(NO_WEBGL_MESSAGE); } }
From source file:jake2.gwt.client.WebGLAdapter.java
License:Open Source License
public DisplayMode[] getAvailableDisplayModes() { return new DisplayMode[] { getDisplayMode(), new DisplayMode(Window.getClientWidth(), Window.getClientHeight(), 32, 60) }; }
From source file:javawars.client.pages.RobotPage.java
License:Open Source License
RobotPage(final Robot robot, final Workshop workshop) { super(robot.getName()); this.robot = robot; this.workshop = workshop; /**/* ww w . j a v a2s .c o m*/ * The robot label - displayed in a side menu. */ robotLabel = new Composite() { private VerticalPanel mainPanel = new VerticalPanel(); { FlexTable table = new FlexTable(); table.setWidget(0, 0, SpacerFactory.getHTMLSpacer(100, 0)); table.setWidget(0, 1, SpacerFactory.getHTMLSpacer(100, 0)); Label robotName = new Label(robot.getName()); robotName.setStyleName("RobotName"); table.setWidget(1, 0, robotName); table.setText(1, 1, "" + robot.getScore()); table.setText(2, 0, "" + DateFormatter.extractDate(robot.getCreationDate())); table.setText(2, 1, "" + DateFormatter.extractDate(robot.getModificationDate())); mainPanel.add(table); table.setStyleName("Table"); mainPanel.setStyleName("RobotLabel"); initWidget(mainPanel); } }; /** * Content of the statistics subpage */ statisticsContent = new Composite() { private VerticalPanel mainPanel = new VerticalPanel(); { mainPanel.add(new HTML("<h2>" + robot.getName() + "</h2>")); final FlexTable table = new FlexTable(); SpacerFactory.adjustFlexTable(table, 120, 50, 50, 120, 50, 50); table.setText(1, 0, "Data utworzenia:"); table.setText(1, 1, "" + DateFormatter.extractDateAndHour(robot.getCreationDate())); table.setText(1, 3, "Ostatnia modyfikacja: "); table.setText(1, 4, "" + DateFormatter.extractDateAndHour(robot.getModificationDate())); table.setText(2, 0, "Punkty: "); table.setText(2, 1, "" + robot.getScore()); // temporary commenting out - the 'choose' button doesn't get back // when another robot is chosen as a representant //if (robot.isRepresentant() == false) { table.setWidget(3, 0, SpacerFactory.getHTMLSpacer(1, 15)); table.setText(4, 0, "Ustaw jako reprezentanta:"); final Button representButton = new Button("reprezentant"); table.setWidget(4, 1, representButton); final AsyncCallback representCallback = new AsyncCallback() { public void onFailure(Throwable arg0) { representButton.setEnabled(true); } public void onSuccess(Object arg0) { representButton.setEnabled(true); } }; representButton.addClickListener(new ClickListener() { public void onClick(Widget arg0) { representButton.setEnabled(false); DataProvider.getInstance().getService().selectAsRepresentant(robot.getName(), representCallback); } }); // } table.setWidget(5, 0, SpacerFactory.getHTMLSpacer(1, 15)); table.setText(6, 0, "Usu robota: "); final Button deleteButton = new Button("usu"); table.setWidget(6, 1, deleteButton); final AsyncCallback deleteCallback = new AsyncCallback() { public void onFailure(Throwable arg0) { Window.alert("Wystpi nieznany bd."); deleteButton.setEnabled(true); } public void onSuccess(Object arg0) { History.newItem("Workshop"); workshop.removeChildPage(getUrl()); deleteButton.setEnabled(true); } }; deleteButton.addClickListener(new ClickListener() { public void onClick(Widget arg0) { deleteButton.setEnabled(false); DataProvider.getInstance().getService().deleteRobot(robot.getName(), deleteCallback); } }); mainPanel.add(table); initWidget(mainPanel); } }; /** * The composite which will be used as a content in the Edit subpage */ editContent = new Composite() { private final HTML codeTextArea; private VerticalPanel mainPanel = new VerticalPanel(); { codeTextArea = new HTML("<textarea id='codeTextArea' " + "class='codepress java' " + "style='width: " + Math.max(300, Window.getClientWidth() - 250) + "px; " + "height: " + Math.max(300, Window.getClientHeight() - 300) + "px; '" + ">" + robot.getCode() + "</textarea>"); mainPanel.add(codeTextArea); final FlowPanel editors = new FlowPanel(); CheckBox useVi = new CheckBox("Edytor VI ", false); useVi.addClickListener(new ClickListener() { private boolean enabled = false; public void onClick(Widget arg0) { if (enabled == false) { enabled = true; DOM.getElementById("codeTextArea").setAttribute("onfocus", "editor(this);"); } else { enabled = false; DOM.getElementById("codeTextArea").setAttribute("onfocus", ";"); } } }); editors.add(useVi); // editors.add(SpacerFactory.getHTMLSpacer(20, 20)); final Button launchCodepress = new Button("Edytor CodePress"); launchCodepress.addClickListener(new ClickListener() { public void onClick(Widget arg0) { editors.setVisible(false); initializeCodePress(); } }); editors.add(launchCodepress); mainPanel.add(editors); final Button save = new Button("Zapisz"); final HTML compilerOutput = new HTML(); final AsyncCallback<String> processOutput = new AsyncCallback<String>() { String startingCode; { startingCode = robot.getCode(); } public void onFailure(Throwable arg0) { compilerOutput.setText("Bd poczenia z serwerem!"); save.setEnabled(true); } public void onSuccess(String output) { compilerOutput.setHTML("<pre>" + output + "</pre>"); robot.setCode(startingCode); save.setEnabled(true); } }; save.addClickListener(new ClickListener() { public native String getRobotCode() /*-{ return $wnd.codeTextArea.getCode(); }-*/; public native String storeRobotCode() /*-{ return $doc.getElementById("codeTextArea_cp").value = $wnd.codeTextArea.getCode() }-*/; public void onClick(Widget arg0) { save.setEnabled(false); if (editors.isVisible()) { DataProvider.getInstance().getService().updateRobotCode(robot.getName(), DOM.getElementById("codeTextArea").getPropertyString("value"), processOutput); } else { storeRobotCode(); DataProvider.getInstance().getService().updateRobotCode(robot.getName(), getRobotCode(), processOutput); } } }); mainPanel.add(save); mainPanel.add(compilerOutput); initWidget(mainPanel); } boolean initialized = false; @Override protected void onLoad() { ; } public native void initializeCodePress() /*-{ $wnd.CodePress.run(); }-*/; }; // content of the test subpage... testContent = new Composite() { private final ListBox robotList = new ListBox(true); private final VerticalPanel mainPanel = new VerticalPanel(); private final VerticalPanel matchViewerPanel = new VerticalPanel(); private final ListBox leaguesList = new ListBox(); { HTML testHeadline = new HTML("<h2>Testuj:</h2>"); Label testDescription = new Label("Wybierz z listy roboty, ktre " + "chcesz przetestowa na jednej planszy; Ctrl+klik - zaznaczenie wicej ni jednego robota. " + "Po dokonaniu wyboru nacini przycisk."); mainPanel.add(testHeadline); mainPanel.add(testDescription); mainPanel.add(SpacerFactory.getHTMLSpacer(10, 10)); mainPanel.add(robotList); mainPanel.add(SpacerFactory.getHTMLSpacer(10, 10)); HTML leagueHeadline = new HTML("<h3>Liga:</h3>"); Label leagueDescription = new Label("Wybierz w jakiej lidze chcesz dokona testu:"); mainPanel.add(leagueHeadline); mainPanel.add(leagueDescription); mainPanel.add(leaguesList); mainPanel.add(SpacerFactory.getHTMLSpacer(10, 10)); final Button testButton = new Button("Testuj"); final AsyncCallback<MatchReport> testCallback = new AsyncCallback<MatchReport>() { public void onFailure(Throwable arg0) { Window.alert(("Wystpi nieznany bd.")); testButton.setEnabled(true); } public void onSuccess(MatchReport matchReport) { try { matchViewerPanel.clear(); MatchViewer matchViewer = new MatchViewerFast(); matchViewerPanel.add(matchViewer); matchViewer.show(matchReport.getXmlDescription()); testButton.setEnabled(true); } catch (Exception exception) { Window.alert("Wystpi nieznany bd podczas wywietlania przebiegu pojedynku!"); } } }; testButton.addClickListener(new ClickListener() { public void onClick(Widget arg0) { if (robotList.getSelectedIndex() == -1) { Window.alert("Prosz wybra przynajmniej jednego robota"); return; } testButton.setEnabled(false); // adding all the selected items of the listbox to one list List<String> robotNames = new LinkedList<String>(); int counter = 0; while (counter < robotList.getItemCount()) { if (robotList.isItemSelected(counter) == true) { robotNames.add(robotList.getItemText(counter)); } counter++; } // invoking the method on server DataProvider.getInstance().getService().testRobots(leaguesList.getSelectedIndex(), robotNames, testCallback); } }); mainPanel.add(SpacerFactory.getHTMLSpacer(10, 10)); mainPanel.add(testButton); mainPanel.add(matchViewerPanel); initWidget(mainPanel); } // a boolean that provides us a lock for the listbox boolean robotListLocked = false; boolean leaguesListLocked = false; /** * Refreshes the content of the listBox; */ private void populateRobotListBox(List<Robot> list) { // if the list is locked, it means there already is an update // in progress; we don't need to update it after such a short // time, so we quit updating completely. if (robotListLocked == false) { robotListLocked = true; robotList.clear(); for (Robot r : list) { robotList.addItem(r.getName()); } robotListLocked = false; } } /** * Refreshes the content of the leaguesListBox; */ private void populateLeaguesListBox(List<League> list) { // if the list is locked, it means there already is an update // in progress; we don't need to update it after such a short // time, so we quit updating completely. if (leaguesListLocked == false) { leaguesListLocked = true; leaguesList.clear(); for (League l : list) { leaguesList.addItem(l.getName()); } leaguesListLocked = false; } } private final AsyncCallback<List<League>> processLeagueCallback = new AsyncCallback<List<League>>() { public void onFailure(Throwable exception) { Window.alert("Error, couldn't update leagues list."); } public void onSuccess(List<League> list) { populateLeaguesListBox(list); } }; @Override protected void onLoad() { populateRobotListBox(workshop.getRobotList()); DataProvider.getInstance().getService().getLeagues(processLeagueCallback); } }; // matchesContent matchesContent = new Composite() { private final List<MatchReport> matches = new ArrayList<MatchReport>(); private VerticalPanel mainPanel = new VerticalPanel(); { AsyncCallback<List<MatchReport>> processMatches = new AsyncCallback<List<MatchReport>>() { public void onFailure(Throwable arg0) { Window.alert("Wystpi bd."); } public void onSuccess(final List<MatchReport> matchReports) { mainPanel.clear(); mainPanel.add(new HTML("<h3>Ostatnie dziesi pojedynkw: </h3>")); mainPanel.add(SpacerFactory.getHTMLSpacer(20, 20)); final ListBox matchesListBox = new ListBox(); matchesListBox.setVisibleItemCount(5); for (MatchReport m : matchReports) { matchesListBox.addItem(DateFormatter.extractDateAndHour(m.getDate())); } mainPanel.add(matchesListBox); mainPanel.add(SpacerFactory.getHTMLSpacer(20, 20)); final VerticalPanel viewerPanel = new VerticalPanel(); mainPanel.add(viewerPanel); matchesListBox.addClickListener(new ClickListener() { public void onClick(Widget arg0) { matchesListBox.setEnabled(false); viewerPanel.clear(); viewerPanel.add(new Label("Prosz czeka")); MatchViewer mv = new MatchViewerFast(); viewerPanel.add(mv); mv.show(matchReports.get(matchesListBox.getSelectedIndex()).getXmlDescription()); viewerPanel.getWidget(0).removeFromParent(); matchesListBox.setEnabled(true); } }); } }; mainPanel.add(new Label("prosz czeka...")); DataProvider.getInstance().getService().fetchRobotMatchReports(robot.getName(), processMatches); initWidget(mainPanel); } }; // adding the subpages... addChild(new Statistics()); addChild(new Edit()); addChild(new Test()); addChild(new MatchReports()); }
From source file:jetbrains.jetpad.cell.toDom.PopupPositioner.java
License:Apache License
private Rectangle getVisiblePart() { if (DomUtil.hasScrollers(myContext.rootElement)) { return DomUtil.visiblePart(myContext.rootElement); } else {/* w w w .j av a 2 s . co m*/ return new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); } }
From source file:jetbrains.jetpad.projectional.domUtil.DomUtil.java
License:Apache License
public static Rectangle visiblePart(Element ctx, Rectangle rect) { while (true) { if (ctx.getOffsetParent() == null) { Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); return visibleArea.intersect(rect); } else {/*from ww w .j a v a2 s.c om*/ Rectangle visible; if (hasScroller(ctx)) { visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight()); Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop()); rect = rect.sub(scroll); } else { visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight()); } Rectangle newRect = visible.intersect(rect); Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop()); ctx = ctx.getOffsetParent(); rect = newRect.add(offset); } } }
From source file:jetbrains.jetpad.projectional.view.toGwt.ViewContainerToElementMapper.java
License:Apache License
private void update() { Rectangle newRect = new Rectangle(Window.getScrollLeft() - myRootDiv.getAbsoluteLeft(), Window.getScrollTop() - myRootDiv.getAbsoluteTop(), Window.getClientWidth(), Window.getClientHeight()); if (myVisibleArea.get() != null && myVisibleArea.get().contains(newRect)) return;// w w w . ja va 2s .c om myVisibleArea.set(expand(newRect)); }
From source file:lh.api.showcase.client.BasicAbstractFormResultView.java
License:Apache License
public BasicAbstractFormResultView(String title, final Grid<T> grid, boolean fullWidth) { super();//from w ww.jav a 2 s. c om this.grid = grid; Panel main = new VerticalPanel(); main.setWidth("100%"); if (title != null) { main.add(new HTML("<h1>" + title + "</h1>")); } ((HasHorizontalAlignment) main).setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); backLink.setStyleDependentName("page", true); busyIndicatorPanel.getElement().getStyle().setPadding(10.0, Unit.PX); busyIndicatorPanel.add(new Image("images/busy.gif")); busyIndicatorPanel.setVisible(false); main.add(formPanel); main.add(messagePanel); main.add(busyIndicatorPanel); main.add(resultPanel); main.add(bottomNavigationPanel); initWidget(main); if (grid != null) { if (fullWidth) { grid.setWidth("100%"); setResizeHandler(); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (grid.getOffsetWidth() > Window.getClientWidth()) { grid.setWidth("100%"); setResizeHandler(); } } }); } }