/** * Displays this menu at a specific xy position. * * @param x the x coordinate * @param y the y coordinate */ public void showAt(int x, int y) { MenuEvent me = new MenuEvent(this); if (fireEvent(Events.BeforeShow, me)) { lastWindowSize = new Size(Window.getClientWidth(), Window.getClientHeight()); RootPanel.get().add(this); el().makePositionable(true); onShow(); el().updateZIndex(0); showing = true; doAutoSize(); if (constrainViewport) { Point p = el().adjustForConstraints(new Point(x, y)); x = p.x; y = p.y; } setPagePosition(x + XDOM.getBodyScrollLeft(), y + XDOM.getBodyScrollTop()); if (enableScrolling) { constrainScroll(y); } el().show(); eventPreview.add(); if (focusOnShow) { focus(); } fireEvent(Events.Show, me); } }
public GoogleCalendarPanel(CalendarTaskManager calendarManager) { // style this element as absolute position DOM.setStyleAttribute(this.getElement(), "position", "absolute"); calendarTaskManager = calendarManager; configureCalendar(); createDatePickerDialog(); setHeaderVisible(false); setBodyBorder(false); setBorders(false); setTopComponent(createCalendarToolbar()); add(calendar); // window events to handle resizing Window.enableScrolling(false); Window.addResizeHandler( new ResizeHandler() { public void onResize(ResizeEvent event) { resizeTimer.schedule(500); int h = event.getHeight(); } }); DeferredCommand.addCommand( new Command() { public void execute() { LayoutContainer center = (LayoutContainer) Registry.get(AppView.CENTER_PANEL); calendar.setHeight(center.getHeight() - calendarHeightSize + "px"); } }); }
/** Popup the view source dialog, showing the given content. */ public static void showSource(final String content, String name) { Constants constants = GWT.create(Constants.class); int windowWidth = Window.getClientWidth() / 2; int windowHeight = Window.getClientHeight() / 2; final FormStylePopup pop = new FormStylePopup(images.viewSource(), constants.ViewingSourceFor0(name), windowWidth); String[] rows = content.split("\n"); FlexTable table = new FlexTable(); for (int i = 0; i < rows.length; i++) { table.setHTML(i, 0, "<span style='color:grey;'>" + (i + 1) + ".</span>"); table.setHTML(i, 1, "<span style='color:green;' >|</span>"); table.setHTML(i, 2, addSyntaxHilights(rows[i])); } ScrollPanel scrollPanel = new ScrollPanel(table); scrollPanel.setHeight(windowHeight + "px"); scrollPanel.setWidth(windowWidth + "px"); pop.addRow(scrollPanel); LoadingPopup.close(); pop.show(); }
@Override public void onClick(ClickEvent event) { if (event.getSource() == editButton) { webApp.setMain(new GroupEditForm(webApp, group)); } else if (event.getSource() == removeButton) { boolean removeContacts = Window.confirm( "Do you want to remove the contacts in the group " + group.getName() + "?"); String message = removeContacts ? Message.CONFIRM_REMOVE_GROUP_AND_CONTACTS : Message.CONFIRM_REMOVE_GROUP; if (Window.confirm(message)) { webApp .getBusinessService() .removeGroup( group, removeContacts, new AsyncCallback<Boolean>() { public void onSuccess(Boolean result) { webApp.showInfo(Message.GROUP, Message.REMOVE_GROUP_SUCCESS); webApp.setMain(new HTML("")); } public void onFailure(Throwable caught) { webApp.showError(Message.ERROR, Message.REMOVE_GROUP_FAILURE); } }); } } }
public ConsoleDialog(ConsoleDialogListener listener) { super(false, true); this.listener = listener; VerticalPanel dialogContents = new VerticalPanel(); dialogContents.setSpacing(4); setWidget(dialogContents); console = new TextArea(); console.setReadOnly(true); int width = Window.getClientWidth(); int height = Window.getClientHeight(); console.setSize(width * 2 / 3 + "px", height * 2 / 3 + "px"); console.addStyleName(Utils.sandboxStyle.consoleArea()); okButton = new Button("Ok"); addButton(okButton); dialogContents.add(console); okButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); if (ConsoleDialog.this.listener != null) { ConsoleDialog.this.listener.onOk(success); } } }); okButton.setEnabled(false); }
/** * This method constructs the application user interface by instantiating controls and hooking up * event handler. */ public void init() { // Inject global styles. GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected(); // Create the UI defined in Mail.ui.xml. DockLayoutPanel outer = binder.createAndBindUi(this); // Get rid of scrollbars, and clear out the window's built-in margin, // because we want to take advantage of the entire client area. Window.enableScrolling(false); Window.setMargin("0px"); // Special-case stuff to make topPanel overhang a bit. Element topElem = outer.getWidgetContainerElement(topPanel); topElem.getStyle().setZIndex(2); topElem.getStyle().setOverflow(Overflow.VISIBLE); // Listen for item selection, displaying the currently-selected item in // the detail area. // mailList.setListener(new MailList.Listener() { // public void onItemSelected(MailItem item) { // mailDetail.setItem(item); // } // }); // Add the outer panel to the RootLayoutPanel, so that it will be // displayed. // MenuMain PRINCIPAL RootLayoutPanel.get().add(outer); }
@UiHandler({"deleteButton"}) void onDeleteButtonClick(ClickEvent event) { if ((this.candidatesModel.getSelectedObject() == null) || (((Reference) this.candidatesModel.getSelectedObject()).getId().isEmpty())) { Window.alert("Выберите кандидата!"); return; } if (!Window.confirm("Удалить запись?")) { return; } SecureService.Util.getInstance() .deleteCand( ((Reference) this.candidatesModel.getSelectedObject()).getId(), new AsyncCallback<Integer>() { public void onSuccess(Integer result) { CandidateSearchForm.this.candidateEditPanel.setWidget(null); CandidateSearchForm.this.startSearch(); Window.alert("Кандидат успешно удален!"); } public void onFailure(Throwable caught) { Window.alert("Ошибка при удалении кандидата!"); } }); }
/* (non-Javadoc) * @see org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.IsCollectionSummaryTeacherView#setViewResponseData(java.util.ArrayList, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public void setViewResponseData( ArrayList<OetextDataDO> result, String resourceGooruId, String collectionId, String classpageId, String pathwayId, String questionType, String session) { popupPanel = new ViewResponsesPopup( result, resourceGooruId, collectionId, classpageId, pathwayId, questionType, true, session, new ClasspageItemDo()); popupPanel.setStyleName(res.css().setOETextPopupCenter()); if (popupPanel.isShowing()) { popupPanel.hide(); Window.enableScrolling(true); } else { Window.enableScrolling(false); popupPanel.setGlassEnabled(true); popupPanel.setAutoHideEnabled(true); popupPanel.show(); popupPanel.center(); } }
@Override public void onClick(ClickEvent event) { if (event.getSource() == delPortalImage) { if (Window.confirm(messages.portal_confirm_delete_image())) { deleteImage(); } } else if (event.getSource() == delFacebook) { if (Window.confirm(messages.portal_confirm_delete_facebook())) { delField("facebook"); } } else if (event.getSource() == delHomepage) { if (Window.confirm(messages.portal_confirm_delete_hompeage())) { delField("homepage"); } } else if (event.getSource() == delLinkedin) { if (Window.confirm(messages.portal_confirm_delete_linkedin())) { delField("linkedin"); } } else if (event.getSource() == delTwitter) { if (Window.confirm(messages.portal_confirm_delete_twitter())) { delField("twitter"); } } else if (event.getSource() == blockAccessButton) { setBlocked(true); } else if (event.getSource() == grantAccessButton) { setBlocked(false); } }
@Override void doSave() { int order; try { order = Integer.parseInt(listOrderEd.getText().trim()); } catch (NumberFormatException e) { Window.alert( "Enter an integer to indicate the order that this season will appear in a drop down selection box"); listOrderEd.setFocus(true); return; } if (seasonEd.getText().trim().length() == 0) { Window.alert("Enter a Season"); return; } TSe season = new TSe(); if (editRb.getValue()) { season.setId(getLookupId()); } season.setListOrder(order); season.setSeason(seasonEd.getText()); saveBtn.setEnabled(false); service.saveSeason(season); }
private void applyChanges( final GenericColumnCommand refreshGrid, final ActionRetractFactCol52 col, final boolean isNew) { if (null == editingCol.getHeader() || "".equals(editingCol.getHeader())) { Window.alert( GuidedDecisionTableConstants.INSTANCE.YouMustEnterAColumnHeaderValueDescription()); return; } if (isNew) { if (!unique(editingCol.getHeader())) { Window.alert( GuidedDecisionTableConstants.INSTANCE.ThatColumnNameIsAlreadyInUsePleasePickAnother()); return; } } else { if (!col.getHeader().equals(editingCol.getHeader())) { if (!unique(editingCol.getHeader())) { Window.alert( GuidedDecisionTableConstants.INSTANCE .ThatColumnNameIsAlreadyInUsePleasePickAnother()); return; } } } // Pass new\modified column back for handling refreshGrid.execute(editingCol); hide(); }
private void setValueByEvent(Event event, boolean updateToServer) { double v = min; // Fallback to min final int coord = getEventPosition(event); final int handleSize, baseSize, baseOffset; if (vertical) { handleSize = handle.getOffsetHeight(); baseSize = base.getOffsetHeight(); baseOffset = base.getAbsoluteTop() - Window.getScrollTop() - handleSize / 2; } else { handleSize = handle.getOffsetWidth(); baseSize = base.getOffsetWidth(); baseOffset = base.getAbsoluteLeft() - Window.getScrollLeft() + handleSize / 2; } if (vertical) { v = ((baseSize - (coord - baseOffset)) / (double) (baseSize - handleSize)) * (max - min) + min; } else { v = ((coord - baseOffset) / (double) (baseSize - handleSize)) * (max - min) + min; } if (v < min) { v = min; } else if (v > max) { v = max; } setValue(v, updateToServer); }
private void delete() { final ClientParamSet setToDelete = getSelectedParamSet(); if (selectionController.getClientParamSets().size() <= 1) { Window.alert("Cannot delete all parameter sets - at least one must remain."); } else { if (Window.confirm( "Do you really want to delete parameter set " + setToDelete.getName() + "?")) { serviceAsync.delete( new Service.Token(true), selector.getSelectedParamSet(), new AsyncCallback<Void>() { public void onFailure(Throwable throwable) { handleGlobalError(throwable); } public void onSuccess(Void aVoid) { selectionController.refresh( new ParamSetSelectionController.Callback() { public void refreshed() { final List<ClientParamSet> paramSets = selectionController.getClientParamSets(); selectionController.select(paramSets.get(0)); } }); } }); } } }
/** * Displays this menu relative to another element. * * @param elem the element to align to * @param pos the {@link El#alignTo} anchor position to use in aligning to the element (defaults * to defaultAlign) * @param offsets the menu align offsets */ public void show(Element elem, String pos, int[] offsets) { MenuEvent me = new MenuEvent(this); if (fireEvent(Events.BeforeShow, me)) { lastWindowSize = new Size(Window.getClientWidth(), Window.getClientHeight()); RootPanel.get().add(this); el().makePositionable(true); onShow(); el().updateZIndex(0); showing = true; doAutoSize(); el().alignTo(elem, pos, offsets); if (enableScrolling) { constrainScroll(el().getY()); } el().show(); eventPreview.add(); if (focusOnShow) { focus(); } fireEvent(Events.Show, me); } }
/** * Exported the selected item. * * @param item Item to export. * @param eventListener <tt>Event Listener</tt> for the export operation. */ public static void exportSelectedItem( TreeItem item, GetFileNameDialogEventListener eventListener) { if (item == null) { // TODO add message for internationalization purposes Window.alert("Please select the item to export."); return; } if (((Editable) item.getUserObject()).isNew()) { // TODO add message for internationalization purposes Window.alert("Please first save this item."); return; } String name = ""; Object studyItem = item.getUserObject(); if (studyItem instanceof StudyDef) name = ((StudyDef) studyItem).getName(); else if (studyItem instanceof FormDef) name = ((StudyDef) item.getParentItem().getUserObject()).getName() + "-" + ((FormDef) studyItem).getName(); else if (studyItem instanceof FormDefVersion) name = ((StudyDef) item.getParentItem().getParentItem().getUserObject()).getName() + "-" + ((FormDef) item.getParentItem().getUserObject()).getName() + "-" + ((FormDefVersion) studyItem).getName(); name = name.replace(" ", ""); new GetFileNameDialog( eventListener, constants.label_export_as(), constants.label_export(), name) .center(); }
/** This is the entry point method. */ @Override public void onModuleLoad() { FormUtil.setupUncaughtExceptionHandler(); FormUtil.retrieveUserDivParameters(); Context.startup(); // FormDesignerWidget designer = new FormDesignerWidget(true,true,true); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(this); // Get rid of scrollbars, and clear out the window's built-in margin, // because we want to take advantage of the entire client area. Window.enableScrolling(false); Window.setMargin("0px"); // Different themes use different background colors for the body // element, but IE only changes the background of the visible content // on the page instead of changing the background color of the entire // page. By changing the display style on the body element, we force // IE to redraw the background correctly. RootPanel.getBodyElement().getStyle().setProperty("display", "none"); RootPanel.getBodyElement().getStyle().setProperty("display", ""); // Finally, add the designer widget to the RootPanel, so that it will be // displayed. RootPanel.get().add(loginView); FormUtil.dlg .hide(); // Temporary fix This comes from the form designer where it loads and never closes }
private static boolean needToUpgrade(int srcYaVersion) { // Compare the source file's YoungAndroid version with the system's YoungAndroid version. final int sysYaVersion = YaVersion.YOUNG_ANDROID_VERSION; if (srcYaVersion > sysYaVersion) { // The source file's version is newer than the system's version. // This can happen if the user is using (or in the past has used) a non-production version of // App Inventor. // This can also happen if the user is connected to a new version of App Inventor and then // later is connected to an old version of App Inventor. // We'll try to load the project but there may be compatibility issues if the project uses // future components or other features that the current system doesn't understand. Window.alert(MESSAGES.newerVersionProject()); return false; } if (srcYaVersion == 0) { // The source file doesn't have a YoungAndroid version number. // There are two situations that cause this: // 1. The project may have been downloaded from alpha (androidblocks.googlelabs.com) and // uploaded to beta (appinventor.googlelabs.com), which is illegal. // 2. The project may have been created with beta (appinventor.googlelabs.com) before we // started putting version numbers into the source file, which is legal, and nothing // really changed between version 0 and version 1. // // For a limited time, we assume #2, show a warning, and proceed. // TODO(lizlooney) - after the limited time is up (when we think that all appinventor // projects have been upgraded), we may decide to refuse to load the project. Window.alert(MESSAGES.veryOldProject()); } return (srcYaVersion < sysYaVersion); }
private void resizeScrollPanel() { int width = Window.getClientWidth() - 20; String height = (Window.getClientHeight() - 60) + "px"; treeScrollPanel.setWidth(Math.round(width * 0.2) + "px"); treeScrollPanel.setHeight(height); explorerScrollPanel.setWidth(Math.round(width * 0.8) + "px"); explorerScrollPanel.setHeight(height); }
private void resize() { setHeight((int) (Window.getClientHeight() * heightPercentage)); setWidth((int) (Window.getClientWidth() * widthPercentage)); if (isRendered()) { center(); layout(true); } }
private String askNewConfigName() { String newName = Window.prompt("Please specify the configuration name.", "My Config"); while (containsConfig(newName)) { Window.alert("'" + newName + "' already exists, please choose a different name."); newName = askNewConfigName(); } return newName; }
public PlayerWidget(String url) { SimplePanel panel = new SimplePanel(); // create panel to hold the player player = null; try { // create the player, specifing URL of media player = new WinMediaPlayer(url, true, "450px", "550px"); player.showLogger(true); panel.setWidget(player); // add player to panel. } catch (LoadException e) { try { player = new QuickTimePlayer(url, true, "450px", "550px"); panel.setWidget(player); // add player to panel. // catch loading exception and alert user Window.alert("An error occured while loading"); } catch (LoadException ep) { try { player = new FlashMP3Player(url, true, "450px", "550px"); panel.setWidget(player); // add player to panel. // catch loading exception and alert user Window.alert("An error occured while loading"); } catch (LoadException exp) { // catch loading exception and alert user Window.alert("An error occured while loading"); } catch (PluginVersionException exp) { // required plugin version is not available, alert user possibly providing a link // to the plugin download page. panel.setWidget( new HTML(".. some nice message telling the user to download plugin first ..")); } catch (PluginNotFoundException exp) { // catch PluginNotFoundException and tell user to download plugin, possibly providing // a link to the plugin download page. panel.setWidget( new HTML(".. another nice message telling the user to download plugin..")); } } catch (PluginVersionException ep) { // required plugin version is not available, alert user possibly providing a link // to the plugin download page. panel.setWidget( new HTML(".. some nice message telling the user to download plugin first ..")); } catch (PluginNotFoundException ep) { // catch PluginNotFoundException and tell user to download plugin, possibly providing // a link to the plugin download page. panel.setWidget(new HTML(".. another nice message telling the user to download plugin..")); } } catch (PluginVersionException e) { // required plugin version is not available, alert user possibly providing a link // to the plugin download page. panel.setWidget( new HTML(".. some nice message telling the user to download plugin first ..")); } catch (PluginNotFoundException e) { // catch PluginNotFoundException and tell user to download plugin, possibly providing // a link to the plugin download page. panel.setWidget(new HTML(".. another nice message telling the user to download plugin..")); } initWidget(panel); }
@Override public void onSuccess(String result) { if (result == null) { Window.alert("添加失败!!!"); } if ("existedExecuteOrder".equals(result)) { Window.alert("部分路由工单已经创建过!!!"); } }
private void bindWebGL() { // Adds the Surface3D to the document. Surface3D surface = new Surface3D(500, 500); RootPanel.get().add(surface); final GL2 gl = surface.getGL(); if (gl == null) { Window.alert("No WebGL context found. Exiting."); return; } // Sets up the GL context. gl.clearColor(0.0f, 0f, 0f, 1f); gl.clearDepth(1); gl.viewport(0, 0, surface.getWidth(), surface.getHeight()); gl.enable(EnableCap.DEPTH_TEST); gl.depthFunc(DepthFunction.LEQUAL); gl.clear(ClearBufferMask.COLOR_BUFFER_BIT, ClearBufferMask.DEPTH_BUFFER_BIT); // Creates a lambertian shader. LambertianShader shader = new LambertianShader(); try { shader.init(gl); } catch (ShaderException e) { Window.alert("Error loading the shader."); return; } // Binds the shader. shader.bind(); // Creates a sphere. StaticMesh mesh = new StaticMesh(gl, PrimitiveFactory.makeSphere(30, 30)); mesh.setPositionIndex(shader.getAttributePosition()); mesh.setNormalIndex(shader.getAttributeNormal()); shader.setLightPosition(0, 5, 5); shader.setDiffuseColor(1, 0, 0, 1); // Sets up the model view matrix. MatrixStack.MODELVIEW.push(); MatrixStack.MODELVIEW.translate(0, 0, -5); shader.setModelViewMatrix(MatrixStack.MODELVIEW.get()); MatrixStack.MODELVIEW.pop(); // Sets up a basic camera for projection. MatrixStack.PROJECTION.pushIdentity(); MatrixStack.PROJECTION.perspective(45, 1, .1f, 100); shader.setProjectionMatrix(MatrixStack.PROJECTION.get()); MatrixStack.PROJECTION.pop(); // Draws the mesh. mesh.draw(); mesh.dispose(); shader.dispose(); }
/** * Constructor. * * @param eventBus the {@link EventBus}. * @param view the {@link MyView}. * @param proxy the {@link MyProxy}. * @param i18n the {@link I18nMessages}. */ @Inject public MainPagePresenter( final EventBus eventBus, final MyView view, final MyProxy proxy, final I18nMessages i18n) { super(eventBus, view, proxy); // prevent the application from directly reloading when the user press 'F5' or click on // 'refresh' Window.addWindowClosingHandler(new WindowClosingHandler(i18n)); Window.addCloseHandler(new WindowCloseHandler()); }
private void checkEvent(ClickEvent eventObject) { boolean keyMaskPassed = this.clickHandler.checkModifiers(eventObject); if (keyMaskPassed) { Window.alert("Selected keys are pressed."); } else { Window.alert("Selected keys don't match!"); } }
protected void center(int offsetWidth, int offsetHeight) { int width = Window.getClientWidth(); int height = Window.getClientHeight(); int scrollLeft = Window.getScrollLeft(); int scrollRight = Window.getScrollTop(); int left = scrollLeft + (width - offsetWidth) / 2; int top = scrollRight + (height - offsetHeight) / 2; child.setPopupPosition(left, top); }
private void redraw(boolean autoScroll) { if (autoScroll) { String historyToken = History.getToken(); if (!Strings.isNullOrEmpty(historyToken)) { int top = this.affixMenu.getPinnedOffset(); Window.scrollTo(Window.getScrollLeft(), top); } else { Window.scrollTo(Window.getScrollLeft(), 0); } } }
@Override public void onActionFailure(Throwable caught, String message) { if (message != null) { Window.alert(message); } else { Window.alert(caught.getMessage() != null ? caught.getMessage() : caught.toString()); } if (box != null) { box.hide(); box = null; } }
@Override public void run() { int newHeight = Window.getClientHeight(); int newWidth = Window.getClientWidth(); if (newHeight != height) { height = newHeight; LayoutContainer center = (LayoutContainer) Registry.get(AppView.CENTER_PANEL); calendar.setHeight(center.getHeight() - calendarHeightSize + "px"); calendar.doSizing(); calendar.doLayout(); } }
@Test public void title() { // Arrange Document.get().setTitle("arranged title"); // Act Window.setTitle("my title"); // Assert assertEquals("my title", Window.getTitle()); assertEquals("my title", Document.get().getTitle()); }