private void createDialogBox() { dialogBox = new DialogBox(); dialogBox.setText("RESTful 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(HasHorizontalAlignment.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); closeButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); } }); }
private void showLogonDialog() { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Login"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setSpacing(4); dialogBox.setWidget(verticalPanel); final TextBox username = new TextBox(); verticalPanel.add(new HTML("Username:"******"Logon", new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); login(username.getValue()); } }); verticalPanel.add(closeButton); dialogBox.center(); dialogBox.show(); }
@Override public DialogBox getDialogBox() throws PopUpException { dialogBox.setWidget(getPanel()); dialogBox.setGlassEnabled(true); dialogBox.center(); return dialogBox; }
@Override public void onUncaughtException(Throwable exception) { Throwable e = unwrapUmbrellaException(exception); Log.fatal("uncaught exception", e); String stackTrace = buildStackTraceMessages(e); /* disable server side logging for now to avoid email bombing RemoteLoggingAction action = new RemoteLoggingAction(stackTrace); action.addContextInfo("selected Doc", appPresenter.getSelectedDocumentInfoOrNull()); action.addContextInfo("selected TransUnitId", targetContentsPresenter.getCurrentTransUnitIdOrNull()); action.addContextInfo("editor contents", targetContentsPresenter.getNewTargets()); dispatcher.execute(action, new NoOpAsyncCallback<NoOpResult>()); */ if (!configHolder.getState().isShowError()) { return; } globalPopup .getCaption() .setHTML("<div class=\"globalPopupCaption\">ERROR: " + e.getMessage() + "</div>"); VerticalPanel popupContent = new VerticalPanel(); // description text SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); // @formatter:off htmlBuilder .appendHtmlConstant("<h3>You may close this window and continue with your work</h3>") .appendHtmlConstant( "<div>If you want to let us know the error, Please recall your actions and take one of the following steps:</div>") .appendHtmlConstant("<ul>") .appendHtmlConstant("<li>Email administration; Or</li>") .appendHtmlConstant( "<li>Check if it's a <a href=\"https://bugzilla.redhat.com/buglist.cgi?product=Zanata&bug_status=__open__\" target=\"_blank\">known issue</a>; Or</li>") .appendHtmlConstant( "<li><a href=\"https://bugzilla.redhat.com/enter_bug.cgi?format=guided&product=Zanata\" target=\"_blank\">Report a problem</a>; Or</li>") .appendHtmlConstant( "<li>Email <a href=\"mailto:[email protected]\">Zanata users mailing list</a></li>") .appendHtmlConstant("</ul>") // @formatter:on ; // stack trace DisclosurePanel disclosurePanel = buildStackTraceDisclosurePanel(stackTrace); // send stack trace log to server popupContent.add(new HTMLPanel(htmlBuilder.toSafeHtml())); popupContent.add(disclosurePanel); popupContent.add(closeButton); globalPopup.setWidget(popupContent); globalPopup.center(); }
/** 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 popupDbCurator() { ClientSequenceDatabase csd = (ClientSequenceDatabase) dlb.getSelected(); Integer selected = csd.getId(); Map<String, String> emailInitialPairs = new TreeMap<String, String>(); for (Map.Entry<String, ClientUser> me : userInfo.entrySet()) { emailInitialPairs.put(me.getKey(), me.getValue().getInitials()); } final DialogBox dialogBox = new DialogBox(false); CurationEditor ce = new CurationEditor( selected, user.getEmail(), emailInitialPairs, new EditorCloseCallback() { public void editorClosed(final Integer openCurationID) { validationController.getAllowedValues( dlb, new Callback() { public void done() { if (openCurationID != null) { dlb.select(openCurationID, validationController); } dialogBox.hide(); } }); } }); DOM.setElementAttribute(dialogBox.getElement(), "id", "db-curator"); dialogBox.setStyleName("dbCuratorEmbed"); dialogBox.setWidget(ce); dialogBox.setSize(Window.getClientWidth() * .8 + "px", Window.getClientHeight() * .8 + "px"); ce.setPixelSize( Math.max((int) (Window.getClientWidth() * .8), 770), (int) (Window.getClientHeight() * .8)); // LightBox lb = new LightBox(dialogBox); // try { // lb.show(); // } catch (Exception ignore) { dialogBox.show(); // } dialogBox.center(); }
/** This is the entry point method. */ public void onModuleLoad() { // Create the popup dialog box dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); dialogBox.setModal(true); closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); errorLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(errorLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); authService.isLoggedIn( new AsyncCallback<Boolean>() { public void onFailure(Throwable arg0) { showError("Error", Message.SERVER_ERROR); } public void onSuccess(Boolean res) { if (res) { displayMainUI(); } else { displayLoginForm(); } } }); }
@Override public void execute() { final DialogBox db = new DialogBox(false, true); db.setText("About MIT App Inventor"); db.setStyleName("ode-DialogBox"); db.setHeight("200px"); db.setWidth("400px"); db.setGlassEnabled(true); db.setAnimationEnabled(true); db.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML message = new HTML( MESSAGES.gitBuildId(GitBuildId.getDate(), GitBuildId.getVersion()) + "<BR/>Use Companion: " + BlocklyPanel.getCompVersion() + "<BR/><BR/>Please see " + RELEASE_NOTES_LINK_AND_TEXT + "<BR/><BR/>" + termsOfServiceText); SimplePanel holder = new SimplePanel(); // holder.setStyleName("DialogBox-footer"); Button ok = new Button("Close"); ok.addClickListener( new ClickListener() { public void onClick(Widget sender) { db.hide(); } }); holder.add(ok); DialogBoxContents.add(message); DialogBoxContents.add(holder); db.setWidget(DialogBoxContents); db.show(); }
/** This is the entry point method. */ public void onModuleLoad() { final Button sendButton = new Button("Send"); final TextBox nameField = new TextBox(); nameField.setText("Deepanjali"); final Label 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 final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML 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 closeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendNameToServer(); } /** Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer( textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
public void Configure_start_time() { final DialogBox dialogBox = new DialogBox(); dialogBox.addStyleName("g-DialogBox"); DOM.setStyleAttribute(dialogBox.getElement(), "border", "0px"); dialogBox.setText("Set Time"); dialogBox.setSize("294", "207"); final AbsolutePanel absolutePanel = new AbsolutePanel(); dialogBox.setWidget(absolutePanel); absolutePanel.setSize("294px", "187px"); // 自定义datebox的输出格式,在这里采用了简洁的输出格式"M/d/yy H:mm" final DateBox dateBox = new DateBox(); DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( "M/d/yy H:mm"); // DateTimeFormat只能通过函数getFormat来生成满足特定pattern的对象,因为其构造函数为protected DateBox.DefaultFormat defaultFormat = new DateBox.DefaultFormat(dateTimeFormat); dateBox.setFormat(defaultFormat); absolutePanel.add(dateBox, 109, 35); dateBox.setWidth("150px"); final Label dateLabel = new Label("Date:"); absolutePanel.add(dateLabel, 36, 35); dateLabel.setSize("38px", "18px"); final Label dateLabel_1 = new Label("Time:"); absolutePanel.add(dateLabel_1, 36, 80); dateLabel_1.setSize("38px", "18px"); final ListBox listBox = new ListBox(); absolutePanel.add(listBox, 109, 77); listBox.setSize("150px", "21px"); String[] minutes = {"00", "15", "30", "45"}; String[] hours = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }; String[] times = new String[96]; // System.out.println(minutes.length+" "+hours.length+" "+times.length); for (int i = 0; i < 24; i++) { for (int j = 0; j < 4; j++) { times[4 * i + j] = hours[i] + ":" + minutes[j]; } } for (int i = 0; i < 96; i++) { listBox.addItem(times[i]); } final Button okButton = new Button(); DOM.setStyleAttribute(okButton.getElement(), "fontSize", "10pt"); okButton.removeStyleName("gwt-Button"); okButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { // TODO Auto-generated method stub TextBox inner_textBox = dateBox.getTextBox(); if (inner_textBox.getText() == null || inner_textBox.getText().equals("")) { dateBox.addStyleName("dateBoxFormatError"); // 如果用户没编辑日期,则datebox框变红,等待用户更正 } else { String dateString = inner_textBox.getText(); int index = listBox.getSelectedIndex(); String timeString = listBox.getValue(index); if (timeString != null) { String[] date_and_time = dateString.split(" "); date_and_time[1] = timeString; dateString = date_and_time[0] + " " + date_and_time[1]; start_time = dateString; } dialogBox.hide(); } System.out.println(start_time); } }); absolutePanel.add(okButton, 93, 129); okButton.setSize("105px", "21px"); okButton.setText("OK"); dialogBox.center(); }
// Popup pour les messages public DialogBox createDialogBoxConfirmationFormulaire( String msg, final JSONObject formAsJSONObjectAjoutDupliquer, final JSONObject formAsJSONObjectAjoutEcraser) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Confirmation"); dialogBox.setAnimationEnabled(true); Button ouiButton = new Button("Oui"); ouiButton.getElement().setId("ouiButton"); Button nonButton = new Button("Non"); nonButton.getElement().setId("nonButton"); VerticalPanel dialogVPanel = new VerticalPanel(); HorizontalPanel dialogHPanel = new HorizontalPanel(); dialogHPanel.setWidth("80px"); dialogVPanel.setWidth("300px"); dialogVPanel.add(new HTML("<b>" + msg + "</b>")); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogHPanel.add(ouiButton); dialogHPanel.add(nonButton); dialogVPanel.add(dialogHPanel); dialogBox.setWidget(dialogVPanel); dialogBox.setPopupPosition(450, 450); /** * Action de clique sur le button de valisation ** */ ouiButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { formAsJSONObjectBis = formAsJSONObjectAjoutEcraser; ajoutFormulaireDirect(); // Supprimer le formulaire RequestBuilder builder = new RequestBuilder( RequestBuilder.PUT, FORMULAIRE_URL + "supprimer/" + formulaire_id); builder.setHeader("Content-Type", "application/json"); try { builder.sendRequest( null, new RequestCallback() { public void onError(Request request, Throwable exception) {} public void onResponseReceived(Request request, Response response) {} }); } catch (RequestException e) { System.out.println("RequestException"); } dialogBox.hide(); } }); /** * Action de clique sur le button de valisation ** */ nonButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { formAsJSONObjectBis = formAsJSONObjectAjoutDupliquer; ajoutFormulaireDirect(); dialogBox.hide(); } }); return dialogBox; }
public DialogBox createDialogBoxConfirmationAllocationFormulaire( String msg, final JSONObject formAsJSONObjectAjoutDupliquer, final JSONObject formAsJSONObjectAjoutEcraser) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Confirmation"); dialogBox.setAnimationEnabled(true); Button ouiButton = new Button("Enregister sous une nouvelle version"); ouiButton.getElement().setId("ouiButton"); Button nonButton = new Button("Changer l'allocation de cette version"); nonButton.getElement().setId("nonButton"); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth("350px"); HTML h = new HTML("<b>" + msg + "</b>"); dialogVPanel.add(h); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.setCellHeight(h, "44px"); dialogVPanel.add(ouiButton); dialogVPanel.setCellHeight(ouiButton, "35px"); nonButton.setWidth("225px"); dialogVPanel.add(nonButton); dialogBox.setWidget(dialogVPanel); dialogBox.setPopupPosition(450, 550); nonButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { MouseListBox mlb = dualListBox.getRight(); ArrayList<Widget> widgets = mlb.widgetList(); String comptes = ""; for (int i = 0; i < widgets.size(); i++) { if (i == 0) comptes = widgets.get(i).getTitle(); else comptes = comptes + "-" + widgets.get(i).getTitle(); } RequestBuilder builder = new RequestBuilder( RequestBuilder.PUT, FORMULAIRE_URL + "changeAllocation/formulaire/" + formulaire_id); builder.setHeader("Content-Type", "application/json"); try { builder.sendRequest( comptes, new RequestCallback() { public void onError(Request request, Throwable exception) {} public void onResponseReceived(Request request, Response response) { Window.alert("Formulaire: Enregistrement avec succès"); Window.Location.reload(); } }); } catch (RequestException e) { System.out.println("RequestException"); } dialogBox.hide(); } }); ouiButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { formAsJSONObjectBis = formAsJSONObjectAjoutDupliquer; ajoutFormulaireDirect(); dialogBox.hide(); } }); return dialogBox; }
private DialogBox createDialogBox(final BeanObject bean) { // Create a dialog box and set the caption text final DialogBox dialogBox = new DialogBox(); dialogBox.ensureDebugId("cwDialogBox"); dialogBox.setText("插入邮件队列"); // Create a panel to layout the content ColumnPanel contentPanel = new ColumnPanel(); final ListBox list = new ListBox(); list.addItem("普通"); list.addItem("高"); contentPanel.createPanel(IEmailSendList.PRIORITY, "选择优先级", list); // add a button to commit com.google.gwt.user.client.ui.Button commitButton = new com.google.gwt.user.client.ui.Button( "确定", new ClickListener() { public void onClick(Widget sender) { // update the mail template final Map<String, Object> emails = bean.getProperties(); emails.remove(IMailTemplate.LASTSEND); Date currentTime = new Date(); final Timestamp nowTime = new Timestamp(currentTime.getTime()); emails.put(IMailTemplate.LASTSEND, nowTime); BeanObject emailBean = new BeanObject(ModelNames.MAILTEMPLATE, emails); new UpdateService() .updateBean( (Long) emails.get(IMailTemplate.ID), emailBean, new UpdateService.Listener() { @Override public void onSuccess(Boolean success) {} }); new EmailSettings() .getSettingsInfo( new EmailSettings.Listener() { public void onSuccess(HashMap<String, String> result) { // create new mail send list int index = list.getSelectedIndex(); Map<String, Object> sendlist = new HashMap<String, Object>(); sendlist.put(IEmailSendList.EMAIL, result.get("account")); sendlist.put(IEmailSendList.TEMPLATEID, emails.get(IMailTemplate.ID)); sendlist.put( IEmailSendList.EMAILCONTENT, emails.get(IMailTemplate.CONTENT)); sendlist.put(IEmailSendList.ERROR, 0); sendlist.put(IEmailSendList.LASTSEND, nowTime); sendlist.put(IEmailSendList.PRIORITY, index); // new bean object of send list BeanObject listBean = new BeanObject(ModelNames.EMAILSENDLIST, sendlist); new CreateService() .createBean( listBean, new CreateService.Listener() { public void onSuccess(String id) {} }); dialogBox.hide(); toolBar.refresh(); // 采用BFS算法的原理,处理邮件队列中的邮件。 new ListService() .listBeans( ModelNames.EMAILLIST, new ListService.Listener() { @Override public void onSuccess(List<BeanObject> beans) { // 取出所有订阅者的订阅地址,构造发送列表 StringBuffer sendTo = new StringBuffer(); for (BeanObject bean : beans) { Boolean isConfirm = bean.get(IEmailList.CONFIRM); if (isConfirm.booleanValue()) { sendTo.append(";" + bean.getString(IEmailList.EMAIL)); } } HashMap<String, String> subscribe = new HashMap<String, String>(); subscribe.put("sendTo", sendTo.substring(1)); subscribe.put( "subject", (String) emails.get(IMailTemplate.SUBJECT)); subscribe.put( "content", (String) emails.get(IMailTemplate.CONTENT)); new EmailSettings() .sendEmailAndGetState( subscribe, new EmailSettings.Listener() { public void onSuccess(Boolean result) {} public void onFailure(Throwable caught) {} }); } }); } }); } }); // Add a close button at the bottom of the dialog com.google.gwt.user.client.ui.Button closeButton = new com.google.gwt.user.client.ui.Button( "Close", new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); contentPanel.add(closeButton); contentPanel.add(commitButton); dialogBox.setWidget(contentPanel); return dialogBox; }
/** This is the entry point method. */ public void onModuleLoad() { final Button sendButton = new Button("Send"); final TextBox nameField = new TextBox(); nameField.setText("Patent ID"); final Label 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 final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); final HTML paramsLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending Patent ID to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Patent profile:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.add(new HTML("<br><b>Patent parameters:</b>")); dialogVPanel.add(paramsLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendPatentIdToServer(); } /** Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendPatentIdToServer(); } } /** Send the name from the nameField to the server and wait for a response. */ private void sendPatentIdToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); /*if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; }*/ // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); /* greetingService.greetServer(textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox .setText("Remote Procedure Call - Failure"); serverResponseLabel .addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel .removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } });*/ dialogBox.setText("Reading Database..."); serverResponseLabel.addStyleName("loadingLabel"); serverResponseLabel.setHTML("Loading..."); dialogBox.center(); patentService.getInfo( textToServer, new AsyncCallback<HashMap<String, String>>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure - Patent"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(HashMap<String, String> resultMap) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.removeStyleName("loadingLabel"); String id = resultMap.get("id"); String abs = resultMap.get("abstract"); String year = resultMap.get("year"); String displayHTML = "ID: " + id + "<br>Issued Year: " + year + "<br>Abstract: " + abs; serverResponseLabel.setHTML(displayHTML); dialogBox.center(); closeButton.setFocus(true); } }); paramsLabel.addStyleName("loadingLabel"); paramsLabel.setHTML("Loading..."); patentService.getParams( textToServer, new AsyncCallback<HashMap<String, String>>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure - Patent"); paramsLabel.addStyleName("serverResponseLabelError"); paramsLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(HashMap<String, String> resultMap) { dialogBox.setText("Remote Procedure Call"); paramsLabel.removeStyleName("serverResponseLabelError"); paramsLabel.removeStyleName("loadingLabel"); String inventors = resultMap.get("inventors"); String nobwdcite = resultMap.get("num_of_bwd_citations"); String originality_USPC = resultMap.get("originality_USPC"); String num_of_assignee_transfer = resultMap.get("num_of_assignee_transfer"); String displayHTML = "Inventors: " + inventors + "<br># of backward citations: " + nobwdcite + "<br>originality_USPC: " + originality_USPC + "<br>num_of_assignee_transfer: " + num_of_assignee_transfer; paramsLabel.setHTML(displayHTML); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
/** This is the entry point method. */ @Override public void onModuleLoad() { // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("CIS 550 HW5 - Query Results"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final HTML schemaLabel = new HTML(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<br><b>Relation schema:</b>")); dialogVPanel.add(schemaLabel); dialogVPanel.add(new HTML("<br><b>Returned data:</b>")); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogBox.setWidget(dialogVPanel); final ScrollPanel scroller = new ScrollPanel(); scroller.setHeight("400px"); dialogVPanel.add(scroller); dialogVPanel.add(closeButton); // Here we are creating a dialog box to return the query results queryService.getRelation( new AsyncCallback<Relation>() { @Override public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.show(); dialogBox.center(); closeButton.setFocus(true); } @Override public void onSuccess(Relation result) { // Add the relational schema to the output schemaLabel.setText(result.getSchema().toString()); // Add the relation outputs to the output in a scrollable table scroller.add(result.getTableWidget()); dialogBox.show(); dialogBox.center(); } }); closeButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); } }); }