List of usage examples for com.google.gwt.user.client Window getClientHeight
public static int getClientHeight()
From source file:ch.unifr.pai.twice.multipointer.provider.client.MouseCursor.java
License:Apache License
/** * Reposition the mouse pointer to x and y coordinates * //w w w .j a va2 s . c o m * @param event */ void move(RemoteMouseMoveEvent event) { genericEventHandling(event); this.x = event.x; this.y = event.y; Element e = getElementFromPoint(x, y); int shrinkX = x + image.getOffsetWidth() - Window.getClientWidth() - Window.getScrollLeft(); int shrinkY = y + image.getOffsetHeight() - Window.getClientHeight() - Window.getScrollTop(); setWidth(Math.max(0, (image.getOffsetWidth() - (shrinkX > 0 ? shrinkX : 0))) + "px"); setHeight(Math.max(0, (image.getOffsetHeight() - (shrinkY > 0 ? shrinkY : 0))) + "px"); int clientX = x + Window.getScrollLeft(); int clientY = y + Window.getScrollTop(); if (!e.equals(oldElement)) { if (oldElement != null) fireMouseEvent("mouseout", uuid, color, oldElement, clientX, clientY); fireMouseEvent("mouseover", uuid, color, e, clientX, clientY); } fireMouseEvent("mousemove", uuid, color, e, clientX, clientY); oldElement = e; getElement().getStyle().setLeft(x, Unit.PX); getElement().getStyle().setTop(y, Unit.PX); if (storage != null) { storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".x", String.valueOf(x)); //old version mice storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".y", String.valueOf(y)); //old version mice } show(); }
From source file:ch.unifr.pai.twice.multipointer.provider.client.MultiCursorController.java
License:Apache License
/** * Looks up the assigned mouse pointer for a specific device (by the uuid) and returns it. If no mouse pointer is assigned to this UUID, a new cursor is * assigned to this device and returned. This method also informs the web socket server about the new assignment for passing through that information to the * according client.// ww w .j av a 2s . c o m * * @param uuid * @return */ private MouseCursor getOrCreateCursor(String uuid) { MouseCursor m = assignedMouseCursors.get(uuid); // If a cursor is already assigned to the uuid, return this one if (m != null) return m; // else create a new cursor with the next color currentCursor++; if (currentCursor >= cursorColors.size()) { currentCursor = 0; } CursorColor c = cursorColors.get(currentCursor); m = defineMouseCursor(c.cursor, c.colorCode); m.setUuid(uuid); assignedMouseCursors.put(uuid, m); if (storage != null) storage.setItem("ch.unifr.pai.mice.multicursor.assignedCursor." + m.getFileName(), uuid); //"ch.unifr.pai.mice.multicursor.assignedCursor." CommunicationManager.getBidirectionalEventBus().fireEvent(InformationUpdateEvent .changeColorAndResize(m.getColor(), Window.getClientWidth(), Window.getClientHeight(), uuid)); return m; }
From source file:ch.unifr.pai.twice.multipointer.provider.client.MultiCursorController.java
License:Apache License
/** * If the screen of the shared device is resized, the component updates the information on the server side. * //from ww w .ja v a 2s. c o m * @see com.google.gwt.event.logical.shared.ResizeHandler#onResize(com.google.gwt.event.logical.shared.ResizeEvent) */ @Override public void onResize(ResizeEvent event) { CommunicationManager.getBidirectionalEventBus() .fireEvent(InformationUpdateEvent.resize(Window.getClientWidth(), Window.getClientHeight())); }
From source file:ch.unifr.pai.twice.utils.cursorSimulator.client.RandomCursor.java
License:Apache License
/** * Move the mouse pointer randomly (the mouse pointer does not move every time but decides on if to move within this interval depending on a random boolean * choice as well.//ww w .j a va 2s. c om */ private void move() { int newX; int newY; if (Random.nextBoolean()) { newX = Random.nextInt(Window.getClientWidth() - RandomCursor.this.getOffsetWidth()); newY = Random.nextInt(Window.getClientHeight() - RandomCursor.this.getOffsetHeight()); } else { newX = RandomCursor.this.getAbsoluteLeft(); newY = RandomCursor.this.getAbsoluteTop(); } move(newX, newY, interval, moveCallback); }
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ScreenShotDistributor.java
License:Apache License
/** * Send the screenshot to the server/* ww w. j a va 2 s . c om*/ */ public void sendScreenShot() { String screen = Document.get().getDocumentElement().getInnerHTML(); if (!screen.equals(lastSent) || lastLeft != Window.getScrollLeft() || lastTop != Window.getScrollTop()) { String url = Window.Location.getHref(); URLParser p = new URLParser(url, Rewriter.getServletPath(Window.Location.getHref())); RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "manager?url=" + p.getProxyBasePath() + "&width=" + Window.getClientWidth() + "&height=" + Window.getClientHeight() + "&top=" + Window.getScrollTop() + "&left=" + Window.getScrollLeft()); lastSent = screen; lastLeft = Window.getScrollLeft(); lastTop = Window.getScrollTop(); screen = screen.replace('\n', ' '); screen = screen.replaceAll("<body", "<body><div class=\"readOnlyView\" style=\"width:" + Window.getClientWidth() + "; height:" + Window.getClientHeight() + ";\""); screen = screen.replaceAll("<\\/body>", "</div></body>"); screen = screen.replaceAll("(<script).*?(\\/script>)", ""); try { rb.sendRequest(screen, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { // TODO Auto-generated method stub } @Override public void onError(Request request, Throwable exception) { Window.alert("Screenshot sent"); } }); } catch (RequestException e) { e.printStackTrace(); } } }
From source file:cl.uai.client.MarkingInterface.java
License:Open Source License
/** * Loads marking interface according to current submission *//*from w w w. j av a2 s . c o m*/ public void loadInterface() { toolbar.loadSubmissionData(); dragController.unregisterDropControllers(); interfacePanel.clear(); markingPagesInterface = new MarkingPagesInterface(); rubricInterface = new RubricInterface(); for (BubbleButton b : bubbleButtons) { b.setLeft(Window.getClientWidth() - 40); b.updatePosition(markingPanel); if (b instanceof ShowRubricButton) { b.setVisible(!EMarkingConfiguration.isShowRubricOnLoad()); } else { b.setVisible(EMarkingConfiguration.isChatEnabled()); } b.setVisible(false); } int rubricWidth = (int) (Window.getClientWidth() - (Window.getClientWidth() / 1.61803)); rubricMinSize = (int) Math.max(rubricWidth, 300); if (EMarkingConfiguration.getMarkingType() == EMarkingConfiguration.EMARKING_TYPE_PRINT_SCAN) { rubricWidth = rubricMinSize - 10; } interfacePanel.addEast(rubricInterface, rubricWidth); interfacePanel.setWidgetMinSize(rubricInterface, 10); interfacePanel.add(markingPagesInterface); interfacePanel.setWidgetMinSize(markingPagesInterface, rubricMinSize); interfacePanel.setHeight((Window.getClientHeight() - toolbar.getOffsetHeight()) + "px"); // When we set the rubric visibility we call the loadinterface in the markinginterface object rubricInterface.setVisible(EMarkingConfiguration.isShowRubricOnLoad() && EMarkingConfiguration.getMarkingType() != EMarkingConfiguration.EMARKING_TYPE_PRINT_SCAN); }
From source file:cl.uai.client.page.EditMarkDialog.java
License:Open Source License
/** * Creates a comment dialog at a specific position * //w w w . j a v a 2 s . c o m * @param posx Top position for the dialog * @param posy Left position for the dialog * @param level An optional rubric level in case we are editing one */ public EditMarkDialog(int posx, int posy, int level, int regradeid) { super(true, false); this.regradeId = regradeid; this.levelId = level; Level lvl = MarkingInterface.submissionData.getLevelById(levelId); if (EMarkingConfiguration.getKeywords() != null && EMarkingConfiguration.getKeywords().length() > 0) { logger.fine("Keywords: " + EMarkingConfiguration.getKeywords()); } if (!EMarkingConfiguration.getKeywords().equals("") && (level > 0 || regradeid > 0)) { feedbackArray = new ArrayList<FeedbackObject>(); feedbackPanel = new FeedbackInterface(); feedbackPanel.setParent(this); } else { simplePanel = true; } superPanel = new HorizontalPanel(); superPanel.addStyleName(Resources.INSTANCE.css().feedbackdialog()); feedbackForStudent = new VerticalPanel(); feedbackForStudent.addStyleName(Resources.INSTANCE.css().feedbackforstudent()); feedbackSummary = new ScrollPanel(feedbackForStudent); feedbackSummary.addStyleName(Resources.INSTANCE.css().feedbacksummary()); mainPanel = new VerticalPanel(); mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialog()); // Adds the CSS style and other settings this.addStyleName(Resources.INSTANCE.css().commentdialog()); this.setAnimationEnabled(true); this.setGlassEnabled(true); bonusTxt = new TextBox(); bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslist()); this.levelsList = new ListBox(); this.levelsList.addStyleName(Resources.INSTANCE.css().levelslist()); this.levelsList.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { int levelid = Integer.parseInt(levelsList.getValue(levelsList.getSelectedIndex())); levelId = levelid; Level lvl = MarkingInterface.submissionData.getLevelById(levelId); setBonus(lvl.getBonus()); } }); // If there's a rubric level we should edit a Mark // otherwise we are just editing its comment if (this.levelId == 0) { this.setHTML(MarkingInterface.messages.AddEditComment()); } else { this.setHTML(MarkingInterface.messages.AddEditMark() + "<br/>" + lvl.getCriterion().getDescription()); } // Position the dialog if (simplePanel) { this.setPopupPosition(posx, posy); } else { // The Dialog is more big, so we need to fix the position this.setPopupPosition((int) (Window.getClientWidth() * 0.08), (int) (Window.getClientHeight() * 0.15)); } if (this.levelId > 0) { loadLevelsList(); HorizontalPanel hpanelLevels = new HorizontalPanel(); hpanelLevels.setWidth("100%"); Label messages = new Label(MarkingInterface.messages.Level()); hpanelLevels.add(messages); hpanelLevels.add(levelsList); hpanelLevels.setCellHorizontalAlignment(levelsList, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelLevels); mainPanel.setCellHorizontalAlignment(hpanelLevels, HasHorizontalAlignment.ALIGN_RIGHT); } // Save button Button btnSave = new Button(MarkingInterface.messages.Save()); btnSave.addStyleName(Resources.INSTANCE.css().btnsave()); btnSave.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (levelId > 0 && !bonusIsValid()) { Window.alert(MarkingInterface.messages.InvalidBonusValue()); return; } cancelled = false; hide(); } }); // Cancel button Button btnCancel = new Button(MarkingInterface.messages.Cancel()); btnSave.addStyleName(Resources.INSTANCE.css().btncancel()); btnCancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { cancelled = true; hide(); } }); // The comment text box TextArea txt = new TextArea(); txt.setVisibleLines(5); txt.getElement().getStyle().setMarginBottom(5, Unit.PT); txtComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt); txtComment.setAutoSelectEnabled(false); txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestbox()); HorizontalPanel hpanelComment = new HorizontalPanel(); hpanelComment.setWidth("100%"); hpanelComment.add(new Label(MarkingInterface.messages.Comment())); hpanelComment.add(txtComment); hpanelComment.setCellHorizontalAlignment(txtComment, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelComment); mainPanel.setCellHorizontalAlignment(hpanelComment, HasHorizontalAlignment.ALIGN_RIGHT); // If the rubric level is not null then create the bonus list and add it to the dialog if (this.levelId > 0) { setBonus(lvl.getBonus()); HorizontalPanel hpanelBonus = new HorizontalPanel(); hpanelBonus.setWidth("100%"); hpanelBonus.add(new Label(MarkingInterface.messages.SetBonus())); hpanelBonus.add(bonusTxt); hpanelBonus.setCellHorizontalAlignment(bonusTxt, HasHorizontalAlignment.ALIGN_RIGHT); if (EMarkingConfiguration.isFormativeFeedbackOnly()) { hpanelBonus.setVisible(false); } mainPanel.add(hpanelBonus); mainPanel.setCellHorizontalAlignment(hpanelBonus, HasHorizontalAlignment.ALIGN_RIGHT); } // The regrade comment text box txt = new TextArea(); txt.setVisibleLines(5); txt.getElement().getStyle().setMarginBottom(5, Unit.PT); txtRegradeComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt); if (this.regradeId > 0) { mainPanel.add(new HTML("<hr>")); mainPanel.add(new Label(MarkingInterface.messages.Regrade())); // Add the textbox HorizontalPanel hpanelRegradeComment = new HorizontalPanel(); hpanelRegradeComment.setWidth("100%"); hpanelRegradeComment.add(new Label(MarkingInterface.messages.RegradeComment())); hpanelRegradeComment.add(txtRegradeComment); hpanelRegradeComment.setCellHorizontalAlignment(txtRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanelRegradeComment); mainPanel.setCellHorizontalAlignment(hpanelRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT); } // Add buttons HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(2); hpanel.setWidth("100%"); hpanel.add(btnSave); hpanel.add(btnCancel); hpanel.setCellWidth(btnSave, "100%"); hpanel.setCellWidth(btnCancel, "0px"); hpanel.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT); hpanel.setCellHorizontalAlignment(btnSave, HasHorizontalAlignment.ALIGN_RIGHT); mainPanel.add(hpanel); mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT); if (simplePanel) { // No feedback this.setWidget(mainPanel); } else { // Remove CSS Style mainPanel.removeStyleName(Resources.INSTANCE.css().editmarkdialog()); mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialogWithFeedback()); bonusTxt.removeStyleName(Resources.INSTANCE.css().bonuslist()); bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslistWithFeedback()); this.levelsList.removeStyleName(Resources.INSTANCE.css().levelslist()); this.levelsList.addStyleName(Resources.INSTANCE.css().levelslistWithFeedback()); txtComment.removeStyleName(Resources.INSTANCE.css().editmarksuggestbox()); txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestboxWithFeedback()); // Add feedback panel mainPanel.add(new HTML("<h4>Feedback</h4>")); mainPanel.add(feedbackSummary); superPanel.add(mainPanel); superPanel.add(feedbackPanel); this.setWidget(superPanel); } }
From source file:cl.uai.client.page.MarkingPageClickHandler.java
License:Open Source License
@Override public void onClick(ClickEvent event) { // If interface is in readonly mode no popups should be allowed. if (EMarkingConfiguration.isReadonly()) { return;/*from w w w .j a v a 2s . c om*/ } // Calculate basic position and page number to add a Mark final int pageno = this.parentPage.getPageNumber(); final int newposx = event.getClientX() - this.parentPage.getAbsolutePanel().getAbsoluteLeft(); final int newposy = event.getClientY() - this.parentPage.getAbsolutePanel().getAbsoluteTop(); int dialogposy = newposy + this.parentPage.getAbsolutePanel().getAbsoluteTop(); if (dialogposy > (int) ((float) Window.getClientHeight() * 0.8)) { dialogposy -= (int) ((float) Window.getClientHeight() * 0.2); } final long unixtime = System.currentTimeMillis() / 1000L; Criterion criterion = EMarkingWeb.markingInterface.getToolbar().getMarkingButtons().getSelectedCriterion(); final int selectedCriterion = criterion == null ? 0 : criterion.getId(); // Switches over the selected button in the rubric interface, to know what mark to add switch (EMarkingWeb.markingInterface.getToolbar().getMarkingButtons().getSelectedButtonFormat()) { // A comment case BUTTON_COMMENT: final EditMarkDialog dialog = new EditMarkDialog(newposx, dialogposy, 0, // No level id for a text comment 0); // No regradeid either dialog.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (dialog.isCancelled() || dialog.getTxtComment().trim().length() <= 0) { EMarkingWeb.markingInterface.getElement().focus(); return; } CommentMark mark = new CommentMark(0, newposx, newposy, pageno, EMarkingConfiguration.getMarkerId(), unixtime, selectedCriterion, "Not set", dialog.getTxtComment()); EMarkingWeb.markingInterface.addMark(mark, parentPage); } }); dialog.center(); break; // A cross case BUTTON_CROSS: final EditMarkDialog dialogcross = new EditMarkDialog(newposx, dialogposy, 0, // No level id for a text comment 0); // No regradeid either dialogcross.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (dialogcross.isCancelled()) { EMarkingWeb.markingInterface.getElement().focus(); return; } CrossMark crmark = new CrossMark(0, newposx, newposy, pageno, EMarkingConfiguration.getMarkerId(), unixtime, selectedCriterion, MarkingInterface.submissionData.getMarkerfirstname(), dialogcross.getTxtComment()); EMarkingWeb.markingInterface.addMark(crmark, parentPage); } }); dialogcross.center(); break; // A pen case BUTTON_PEN: break; // When the rubric button is selected nothing happens, it should use DnD case BUTTON_RUBRIC: AddMarkDialog addmarkdialog = new AddMarkDialog(parentPage); addmarkdialog.setRubricLeft(newposx); addmarkdialog.setRubricTop(newposy); addmarkdialog.center(); break; // A check mark case BUTTON_TICK: final EditMarkDialog dialogtick = new EditMarkDialog(newposx, dialogposy, 0, // No level id for a text comment 0); // No regradeid either dialogtick.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (dialogtick.isCancelled()) { EMarkingWeb.markingInterface.getElement().focus(); return; } CheckMark cmark = new CheckMark(0, newposx, newposy, pageno, EMarkingConfiguration.getMarkerId(), unixtime, selectedCriterion, MarkingInterface.submissionData.getMarkerfirstname(), dialogtick.getTxtComment()); EMarkingWeb.markingInterface.addMark(cmark, parentPage); } }); dialogtick.center(); break; // A check mark case BUTTON_QUESTION: final EditMarkDialog dialogquestion = new EditMarkDialog(newposx, dialogposy, 0, // No level id for a text comment 0); // No regradeid either dialogquestion.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (dialogquestion.isCancelled()) { EMarkingWeb.markingInterface.getElement().focus(); return; } QuestionMark qmark = new QuestionMark(0, newposx, newposy, pageno, EMarkingConfiguration.getMarkerId(), unixtime, selectedCriterion, MarkingInterface.submissionData.getMarkerfirstname(), dialogquestion.getTxtComment()); EMarkingWeb.markingInterface.addMark(qmark, parentPage); } }); dialogquestion.center(); break; case BUTTON_CUSTOM: final EditMarkDialog dialogcustom = new EditMarkDialog(newposx, dialogposy, 0, // No level id for a text comment 0); // No regradeid either dialogcustom.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (dialogcustom.isCancelled()) { EMarkingWeb.markingInterface.getElement().focus(); return; } CustomMark custommark = new CustomMark(0, dialogcustom.getTxtComment(), newposx, newposy, pageno, EMarkingConfiguration.getMarkerId(), unixtime, selectedCriterion, MarkingInterface.submissionData.getMarkerfirstname(), ""); custommark.setRawtext( EMarkingWeb.markingInterface.getToolbar().getMarkingButtons().getSelectedButtonLabel() + ": " + EMarkingWeb.markingInterface.getToolbar().getMarkingButtons() .getSelectedButtonTitle()); EMarkingWeb.markingInterface.addMark(custommark, parentPage); } }); dialogcustom.center(); break; default: } EMarkingWeb.markingInterface.getElement().focus(); }
From source file:cl.uai.client.page.MarkingPagesInterface.java
License:Open Source License
@Override protected void onLoad() { super.onLoad(); this.addStyleName(Resources.INSTANCE.css().pagespanel()); int height = Window.getClientHeight() - this.getAbsoluteTop(); this.scrollContainerForPages.setHeight(height + "px"); }
From source file:cl.uai.client.rubric.RubricInterface.java
License:Open Source License
/** * Constructor//from ww w . ja v a2 s . c o m */ public RubricInterface() { mainSplitLayoutPanel = new SplitLayoutPanel(); mainSplitLayoutPanel.addStyleName(Resources.INSTANCE.css().rubricinterface()); rubricPanel = new RubricPanel(false); scrollRubric = new ScrollPanel(rubricPanel); mainSplitLayoutPanel.addNorth(scrollRubric, (int) (Window.getClientHeight() / 1.61803)); toolsPanel = new ToolsPanel(); scrollTools = new ScrollPanel(toolsPanel); mainSplitLayoutPanel.add(scrollTools); this.initWidget(mainSplitLayoutPanel); }