@DoNotRunWith({Platform.HtmlUnitBug}) public void testValueChangeEvent() { // Checks setValue(date, true); DateBox db = new DateBox(); RootPanel.get().add(db); new DateValueChangeTester(db).run(); // Check setting the text directly in the text box. final DateBox db2 = new DateBox(); RootPanel.get().add(db2); new DateValueChangeTester(db2) { @Override protected void fire(java.util.Date d) { db2.getTextBox().setText(db2.getFormat().format(db2, d)); NativeEvent e = Document.get().createBlurEvent(); db2.getTextBox().getElement().dispatchEvent(e); } }.run(); // Checks that setting the date picker's date works correctly. final DateBox db3 = new DateBox(); RootPanel.get().add(db3); new DateValueChangeTester(db3) { @Override protected void fire(java.util.Date d) { db3.getDatePicker().setValue(d, true); } }.run(); }
/** Tests submitting an alternate frame. TODO: Investigate intermittent failures with HtmlUnit. */ @DoNotRunWith(Platform.HtmlUnitUnknown) public void testSubmitFrame() { System.out.println("testSubmitFrame"); final NamedFrame frame = new NamedFrame("myFrame"); FormPanel form = new FormPanel(frame); form.setMethod(FormPanel.METHOD_POST); form.setAction(GWT.getModuleBaseURL() + "formHandler?sendHappyHtml"); RootPanel.get().add(form); RootPanel.get().add(frame); delayTestFinish(TEST_DELAY); form.submit(); Timer t = new Timer() { @Override public void run() { // Make sure the frame got the contents we expected. assertTrue(isHappyDivPresent(frame.getElement())); finishTest(); } }; // Wait 5 seconds before checking the results. t.schedule(TEST_DELAY - 2000); }
public void run(final RootPanel rp, final String nick) { if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0); cl.setPageSize(500); final Button sendMessage = new Button( "sendMessage", new ClickHandler() { public void onClick(ClickEvent event) { if (!message.getText().equals("")) { new Post().postJson(SERVERURL, nick.toString(), message.getText()); message.setText(""); } } }); rp.get("mainDiv2").setVisible(true); message.getElement().setAttribute("placeholder", "Introduce your message"); message.getElement().setAttribute("id", "message"); cl.getElement().setAttribute("id", "chatBox"); sendMessage.getElement().setAttribute("id", "sendMessage"); sendMessage.setText("Send"); vp.getElement().setAttribute("id", "verticalPanel"); hp.getElement().setAttribute("id", "horizontalPanel"); panel.getElement().setAttribute("id", "scroller"); hp.add(message); hp.add(sendMessage); panel.add(cl); vp.add(panel); vp.add(hp); rp.get("mainDiv2").add(vp); Timer t = new Timer() { @Override public void run() { getMessages(); if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) { cl.setRowCount(chatList.size() + 1, true); cl.setRowData( Integer.parseInt(Cookies.getCookie(nick)), chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size())); panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1); Cookies.setCookie(nick, "" + chatList.size()); } } }; t.scheduleRepeating(1000); }
private void finalizeFileTableInit() { files = new FileTable(); final RootPanel filePanel = RootPanel.get("fileTable"); filePanel.add(files); connectOutputLocationAndFileTable(); connectTitleAndFileTable(); }
public void onModuleLoad() { final ScrollPanel contentPanel = new ScrollPanel(); contentPanel.setStyleName("content_panel"); RoundedPanel roundedContentPanel = new RoundedPanel(contentPanel, RoundedPanel.ALL, 5); roundedContentPanel.setStyleName("rounded_content_panel"); MenuBar menuBar = createMenuBar(contentPanel); RoundedPanel roundedMenuBar = new RoundedPanel(menuBar, RoundedPanel.ALL, 5); RootPanel.get().add(roundedMenuBar); RootPanel.get().add(roundedContentPanel); }
/** This is the entry point method. */ public void onModuleLoad() { sendButton = new Button("Send"); nameField = new TextBox(); nameField.setText("GWT User"); errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); textToServerLabel = new Label(); serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox final ClickHandler buttonClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }; closeButton.addClickHandler(buttonClickHandler); // Add a handler to send the name to the server ChangeEventHandler handler = new ChangeEventHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
private void startResizingFrom(int x, int y) { isResizing = true; onSplitterResizeStarted(x, y); // Resize glassElem to take up the entire scrollable window area int height = RootPanel.getBodyElement().getScrollHeight() - 1; int width = RootPanel.getBodyElement().getScrollWidth() - 1; glassElem.getStyle().setProperty("height", height + "px"); glassElem.getStyle().setProperty("width", width + "px"); RootPanel.getBodyElement().appendChild(glassElem); }
private void finalizeSpectrumQa(final List<SpectrumQaParamFileInfo> list) { if (list == null || list.isEmpty()) { DOM.setStyleAttribute(DOM.getElementById("spectrumQaRow"), "display", "none"); } else { DOM.setStyleAttribute(DOM.getElementById("spectrumQaRow"), "display", ""); spectrumQaSetupPanel = new SpectrumQaSetupPanel(list); final RootPanel rootSpectrumQaPanel = RootPanel.get("spectrumQa"); rootSpectrumQaPanel.add(spectrumQaSetupPanel); } showPageContentsAfterLoad(); }
public void paint(Graphics g) { RootPanel rootPanel = frame.getRoot(); if (rootPanel != null) { if (isWindowResizing()) { PanelPainterLoop.doPaintJob( rootPanel.getPanel(), rootPanel.getPanel().getAbsoluteBounds(), (Graphics2D) g); } else { rootPanel.addDirtyRegion(frame.getRoot().getPanel().getAbsoluteBounds()); } } }
public EditorController(String divID, int width, int height) { VerticalPanel vp = new VerticalPanel(); HorizontalPanel hp = new HorizontalPanel(); SimplePanel topToolBoxWrapper = new SimplePanel(); ToggleButtonListener toggleButtonListener = new ToggleButtonListener(); topToolBox = new TopToolBox(this, toggleButtonListener); topToolBox.setStyleName("jsmoleditor-topToolBox"); topToolBoxWrapper.setWidget(topToolBox); topToolBoxWrapper.setStyleName("jsmoleditor-topTooBoxWrapper"); topToolBoxWrapper.setWidth(width + "px"); SimplePanel sideToolBoxWrapper = new SimplePanel(); elementToolBox = new ElementToolBox(this, toggleButtonListener); sideToolBoxWrapper.setWidget(elementToolBox); sideToolBoxWrapper.setStyleName("jsmoleditor-elementToolBoxWrapper"); sideToolBoxWrapper.setHeight((height - 24) + "px"); VerticalPanel vp2 = new VerticalPanel(); ExtendedCanvas canvas = new ExtendedCanvas(width - 24, height - 48); StatusBar statusBar = new StatusBar(width - 24, 24); statusBar.setHTML("Copyright chemhack.com"); renderer = new CanvasRenderer(this, canvas); vp2.add(canvas); vp2.add(statusBar); hp.add(sideToolBoxWrapper); hp.add(vp2); vp.add(topToolBoxWrapper); vp.add(hp); RootPanel rootPanel = RootPanel.get(divID); rootPanel.setPixelSize(width, height); rootPanel.add(vp); KeyboardShortCutEventPreview preview = new KeyboardShortCutEventPreview(this); // TODO deal with multiple editor instance? DOM.addEventPreview(preview); EditorMouseListener listener = new EditorMouseListener(this); canvas.addMouseListener(listener); canvas.addMouseWheelListener(listener); }
public void testReset() { System.out.println("testReset"); FormPanel form = new FormPanel(); RootPanel.get().add(form); TextBox textBox = new TextBox(); textBox.setText("Hello World"); form.setWidget(textBox); assertEquals("Hello World", textBox.getText()); System.out.println("reset: normal"); form.reset(); assertEquals("", textBox.getText()); RootPanel.get().remove(form); }
public void testResetNative() { System.out.println("testResetNative"); // this test makes only sense if an event is called FormPanel form = new FormPanel(); RootPanel.get().add(form); TextBox textBox = new TextBox(); textBox.setText("Hello World"); form.setWidget(textBox); assertEquals("Hello World", textBox.getText()); System.out.println("reset: native"); nativeFormReset(form.getElement()); assertEquals("", textBox.getText()); RootPanel.get().remove(form); }
private void initEditorToggle() { final RootPanel togglePanel = RootPanel.get("paramsToggleButton"); editorToggle = new ToggleButton(new Image("images/triright.png"), new Image("images/tridown.png")); editorToggle.setDown(false); editorToggle.addStyleName("toggle-button"); togglePanel.add(editorToggle); editorToggle.addClickHandler( new ClickHandler() { @Override public void onClick(final ClickEvent event) { paramsEditor.setEditorExpanded(editorToggle.isDown()); } }); }
private void initTitleEditor() { final RootPanel titlePanel = RootPanel.get("title"); title.setVisibleLength(60); titlePanel.add(title); title.addKeyUpHandler( new KeyUpHandler() { @Override public void onKeyUp(final KeyUpEvent event) { userEditedTitle = true; updateOutputLocation(); } }); titleChangeListener = new TitleChangeListener(); title.addChangeHandler(titleChangeListener); }
public void testFileUpload() { System.out.println("testFileUpload"); final FormPanel form = new FormPanel(); form.setMethod(FormPanel.METHOD_POST); form.setEncoding(FormPanel.ENCODING_MULTIPART); assertEquals(FormPanel.ENCODING_MULTIPART, form.getEncoding()); form.setAction(GWT.getModuleBaseURL() + "formHandler"); FileUpload file = new FileUpload(); file.setName("file0"); form.setWidget(file); RootPanel.get().add(form); delayTestFinish(TEST_DELAY); form.addSubmitCompleteHandler( new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // The server just echoes the contents of the request. The following // string should have been present in it. assertTrue( event.getResults().indexOf("Content-Disposition: form-data; name=\"file0\";") != -1); finishTest(); } }); form.submit(); }
private void initAddFilesButton() { // Add files button produces a dialog addFileButton = new PushButton( "", new ClickHandler() { @Override public void onClick(final ClickEvent event) { final int clientWidth = Window.getClientWidth(); final int clientHeight = Window.getClientHeight(); final int popupWidth = clientWidth * 3 / 4; final int popupHeight = clientHeight * 3 / 4; final int posX = (clientWidth - popupWidth) / 2; final int posY = (clientHeight - popupHeight) / 2; final FileTreeDialog dialog = new FileTreeDialog(popupWidth, popupHeight); dialog.setPopupPosition(posX, posY); dialog.setSelectedFilesListener( new SelectedFilesListener() { @Override public void selectedFiles(final FileInfo[] info) { files.addFiles(info); } }); dialog.show(); } }); addFileButton.setEnabled(false); RootPanel.get("addFileButton").add(addFileButton); }
/** Override show to also center the dialog. */ @Override public void show() { super.show(); super.center(); // set a body class to mark the dialog show RootPanel.get().addStyleName("gwt-ModalDialog-show"); }
private void initRunButton() { // Run Button //////////////////////////////////////////// runButton = new PushButton(); RootPanel.get("runButton").add(runButton); runButton.setEnabled(false); runButton.addClickHandler(new RunClickHandler()); }
public void setUp() throws Exception { root = new RootPanel(new MockPropFrame()); prop = new MockProp(); style = prop.getStyle(); panel = new PropPanel(prop); root.setPanel(panel); }
public static Video wrap(VideoElement e) { assert Document.get().getBody().isOrHasChild(e); Video v = new Video(e); v.maybeInitMediaEvents(); // The two lines below seems to be good practice to avoid memory leaks... v.onAttach(); RootPanel.detachOnWindowClose(v); return v; }
public Example1InnerWidget(Element anElement) { setElement(anElement); onAttach(); RootPanel.detachOnWindowClose(this); // do something visible to show that we've bound to the element getElement().getStyle().setColor("green"); getElement().getStyle().setFontStyle(FontStyle.ITALIC); }
public void testHoverOnWithoutHoverStyle() throws Exception { MouseEvent event = new MouseEvent(new JPanel(), 1, 2, 3, 4, 5, 6, false); prop.hoverStyle = null; panel.mouseEntered(event); assertEquals(Cursor.DEFAULT_CURSOR, root.getContentPane().getCursor().getType()); assertEquals(null, style.getScreen()); }
private void addStackPanel() { DecoratedStackPanel sPanel = new DecoratedStackPanel(); sPanel.setWidth("450px"); for (int i = 1; i <= 5; i++) { Widget tabContent = new TabPanelSampleContent(i); String tabLabel = "Panel " + i; sPanel.add(tabContent, tabLabel); } RootPanel.get("stack-panel").add(sPanel); }
/** This is the entry point method. */ public void onModuleLoad() { final TextButton textButton = new TextButton("gxtSimpleButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element // GXT button RootPanel.get("gxtContainer").add(textButton); }
@Override public void showCodeSQLError(String errorMsg) { RootPanel.get("error_div").add(new Label(errorMsg)); loadingBar.setVisible(false); quickCodeResult.clear(); resultStatusTextBox.setVisible(true); resultStatusTextBox.setText(errorMsg); resultStatusTextBox.removeStyleName(style.errorTextBoxQuickCard()); resultStatusTextBox.removeStyleName(style.successTextBoxQuickCard()); resultStatusTextBox.addStyleName(style.errorTextBoxQuickCard()); }
/** * Creates a FileUpload widget that wraps an existing <input type='file'> element. * * <p>This element must already be attached to the document. If the element is removed from the * document, you must call {@link RootPanel#detachNow(Widget)}. * * @param element the element to be wrapped */ public static FileUpload wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); FileUpload fileUpload = new FileUpload(element); // Mark it attached and remember it for cleanup. fileUpload.onAttach(); RootPanel.detachOnWindowClose(fileUpload); return fileUpload; }
private void addTabPanel() { DecoratedTabPanel tPanel = new DecoratedTabPanel(); tPanel.setWidth("450px"); for (int i = 1; i <= 5; i++) { Widget tabContent = new TabPanelSampleContent(i); String tabLabel = "Panel " + i; tPanel.add(tabContent, tabLabel); } tPanel.selectTab(0); tPanel.setAnimationEnabled(true); RootPanel.get("tab-panel").add(tPanel); }
private void addSuggestPanel() { HorizontalPanel langPanel = new HorizontalPanel(); langPanel.setSpacing(5); langPanel.add(new HTML("Enter language:")); MultiWordSuggestOracle langChoices = new ProgrammingLanguageOracle(); SuggestBox langBox = new SuggestBox(langChoices); langPanel.add(langBox); Button searchButton = new Button("Send to Google"); searchButton.addClickHandler(new SearchHandler(langBox)); langPanel.add(searchButton); RootPanel.get("suggest-panel").add(langPanel); }
public void setWidgetTiming(int rows, int columns) { resetTimer(); HTMLTable HTMLTable = createTable(rows, columns); RootPanel.get().add(HTMLTable); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { Label label = new Label(column + "i"); HTMLTable.setWidget(row, column, label); } } timing("setWidgetTiming(" + rows + "," + columns + ")"); }
private void initOutputLocation() { // currently, the save location is populated deterministically by the combination of // the users's input final RootPanel outputPanel = RootPanel.get("output"); output = new TextBox(); output.setVisibleLength(150); output.addChangeHandler( new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { outputPathUserSpecified = true; updateOutputLocation(); } }); outputPanel.add(output); final RootPanel outputWarning = RootPanel.get("outputWarning"); outputValidationPanel = new ValidationPanel(2); outputWarning.add(outputValidationPanel); connectOutputLocationAndFileTable(); // Fire userChanged to get the output location updated userChanged(); updateOutputLocation(); }