/** * Display a Prompting Message to enter some text in the Application. The OK button will be * enabled iff the text is not empty or blank. * * @param title * @param message * @param callback */ public static MessageBox promptMessage( String title, String message, Listener<MessageBoxEvent> callback) { final MessageBox box = MessageBox.prompt(title, message, callback); final Button okButton = box.getDialog().getButtonById(Dialog.OK); okButton.disable(); final TextField<String> textBox = box.getTextBox(); textBox.addKeyListener( new KeyListener() { @Override public void componentKeyPress(ComponentEvent event) { if (okButton.isEnabled() && event.getKeyCode() == KeyCodes.KEY_ENTER) { box.getDialog().hide(okButton); } } }); box.addListener( Events.OnKeyUp, new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent be) { String value = textBox.getValue(); if (value == null || value.trim().equals("")) { okButton.disable(); } else { okButton.enable(); } } }); return box; }
@Override public void handleEvent(final BaseEvent be) { final MessageBox box = MessageBox.prompt(UserMessages.MESSAGE_NEW_POINT, UserMessages.MESSAGE_NEW_POINT_PROMPT); box.addCallback(createNewPointListener); }
/** * Display an Error Message in the Application * * @param title * @param message */ public static void errorMessage(String title, String message) { MessageBox box = new MessageBox(); box.setIcon(MessageBox.ERROR); box.setTitleHtml(title); box.setMessage(message); box.show(); }
@Override public void handleEvent(BaseEvent be) { final MessageBox box = MessageBox.prompt( UserMessages.MESSAGE_CONNECTION_REQUEST_TITLE, UserMessages.MESSAGE_CONNECTION_REQUEST); box.addCallback(sendInviteListener()); }
@Override public void handleEvent(BaseEvent be) { final MessageBox box = MessageBox.prompt( UserMessages.MESSAGE_ADD_CATEGORY, "Add a new folder to organize your data. Folders can be shared, and " + "subscribed to by other users if you set their security level " + "to public"); box.addCallback(createNewFolderListener); }
private boolean validateFields() { if (Utils.safeString(nameTextBox.getValue()).equals("")) { MessageBox.alert(textMessages.error(), textMessages.mustEnterName(), null); return false; } if (Utils.safeString(nameTextBox.getValue()).length() > Group.LENGTH_NAME) { MessageBox.alert(textMessages.error(), textMessages.tooLongName(), null); return false; } return true; }
public void openUrl() { GWT.log("openUrl()"); openUrlBox = MessageBox.prompt( AppConstants.INSTANCE.openUrlMenuItem(), AppConstants.INSTANCE.openUrlText()); openUrlBox.addCallback( new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { new UrlLoadRequest(be.getValue()).load(); } }); }
@SuppressWarnings("unchecked") @Override protected void handleEvent(AppEvent event) { if (event.getType() == AppEvents.AuditEventEntryView) { searchCriteria = null; currentEntity = Registry.get(Constants.ENTITY_ATTRIBUTE_MODEL); initUI(); if (Registry.get(Constants.AUDIT_EVENT_TYPE_CODES) != null) { List<AuditEventTypeWeb> auditEventTypes = (List<AuditEventTypeWeb>) Registry.get(Constants.AUDIT_EVENT_TYPE_CODES); /* * for (AuditEventTypeWeb type : auditEventTypes) { Info.display("Information", "Event Types: "+ * type.getAuditEventTypeCd() + ", " + type.getAuditEventTypeName()); } */ eventTypesStore.removeAll(); eventTypesStore.add(auditEventTypes); } } else if (event.getType() == AppEvents.Logout) { Dispatcher.get().dispatch(AppEvents.Logout); } else if (event.getType() == AppEvents.AuditEventReceived) { // Info.display("Information", "EventReceived"); store.removeAll(); AuditEventEntryListWeb events = (AuditEventEntryListWeb) event.getData(); if (events.getAuditEventEntries() != null) { store.add(events.getAuditEventEntries()); } grid.getSelectionModel().select(0, true); grid.getSelectionModel().deselect(0); status.hide(); searchButton.unmask(); } else if (event.getType() == AppEvents.EntityByIdRequest) { RecordWeb record = (RecordWeb) event.getData(); if (record != null) { identifierStore.removeAll(); buildRefRecordInfoDialog(); refRecordInfoDialog.show(); displayEntityRecord(attributeFieldMap, record); displayEntityIdentifier(record); } } else if (event.getType() == AppEvents.Error) { String message = event.getData(); MessageBox.alert("Information", "Failure: " + message, null); } }
/** * Display an Alert Message in the Application * * @param title * @param message */ public static void alertMessage(String title, String message) { MessageBox.alert( title, message, new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent be) {} }); }
@Override public void onSuccess(Entity result) { try { notifyEntityModifiedListener(new GxtModel(result), Action.create); } catch (NimbitsException e) { FeedbackHelper.showError(e); } box.close(); }
@SuppressWarnings("unchecked") @Override protected void handleEvent(AppEvent event) { if (event.getType() == AppEvents.ProfileView) { initUI(); clearFormFields(false); updateUser = Registry.get(Constants.LOGIN_USER); displayRecords(updateUser); } else if (event.getType() == AppEvents.ProfileUpdateComplete) { status.hide(); submitButton.unmask(); updateUser = (UserWeb) event.getData(); Registry.register(Constants.LOGIN_USER, updateUser); MessageBox.alert("Information", "User profile was successfully updated", listenInfoMsg); } else if (event.getType() == AppEvents.ProfileVarifyPasswordSuccess) { UserWeb user = copyUserFromGUI(updateUser); controller.handleEvent(new AppEvent(AppEvents.ProfileUpdateInitiate, user)); } else if (event.getType() == AppEvents.ProfileVarifyPasswordFailure) { status.hide(); submitButton.unmask(); MessageBox.alert("Information", "Incorrect current password", listenInfoMsg); } else if (event.getType() == AppEvents.Error) { status.hide(); submitButton.unmask(); String message = event.getData(); MessageBox.alert("Information", "Failure: " + message, listenFailureMsg); } }
@Override public void handleEvent(MessageBoxEvent be) { newEntityName = be.getValue(); if (!Utils.isEmptyString(newEntityName)) { final MessageBox box = MessageBox.wait( "Progress", "Creating your data point channel into the cloud", "Creating: " + newEntityName); box.show(); EntityServiceAsync service = GWT.create(EntityService.class); try { Point p = EntityHelper.createPointWithName(newEntityName); service.addUpdateEntity(p, new NewPointEntityAsyncCallback(box)); } catch (NimbitsException caught) { FeedbackHelper.showError(caught); } } }
@Override public void componentSelected(ButtonEvent ce) { List<BeanModel> selectedModels = deviceContentTree.getSelectionModel().getSelectedItems(); for (BeanModel beanModel : selectedModels) { if (beanModel.getBean() instanceof DeviceCommand) { List<CommandRefItem> commandRefItems = device.getCommandRefItems(); for (CommandRefItem commandRefItem : commandRefItems) { if (commandRefItem.getDeviceCommand() == beanModel.getBean()) { MessageBox.alert( "Warn", "The command cann't be delete, because it was refrenced by other sensor, switch or slider.", null); return; } } device.getDeviceCommands().remove(beanModel.getBean()); } else if (beanModel.getBean() instanceof Sensor) { List<SensorRefItem> sensorRefItems = device.getSensorRefItems(); for (SensorRefItem sensorRefItem : sensorRefItems) { if (sensorRefItem.getSensor() == beanModel.getBean()) { MessageBox.alert( "Warn", "The sensor cann't be delete, because it was refrenced by other switch or slider.", null); return; } } device.getSensors().remove(beanModel.getBean()); } else if (beanModel.getBean() instanceof Slider) { device.getSliders().remove(beanModel.getBean()); } else if (beanModel.getBean() instanceof Switch) { deviceContentTree.getStore().remove(beanModel); device.getSwitchs().remove(beanModel.getBean()); } deviceContentTree.getStore().remove(beanModel); } }
private boolean validateFields() { if (!(Utils.safeString(password2TextBox.getValue())) .equals(Utils.safeString(password1TextBox.getValue()))) { MessageBox.alert(textMessages.error(), textMessages.passwordsNotMatch(), null); return false; } if (Utils.safeString(password1TextBox.getValue()).length() > UserAuthnPassword.LENGTH_PASSWORD) { MessageBox.alert(textMessages.error(), textMessages.tooLongPassword(), null); return false; } if (Utils.safeString(usernameTextBox.getValue()).equals("")) { MessageBox.alert(textMessages.error(), textMessages.mustEnterUsername(), null); return false; } if (Utils.safeString(usernameTextBox.getValue()).length() > User.LENGTH_USERNAME) { MessageBox.alert(textMessages.error(), textMessages.tooLongUsername(), null); return false; } if (Utils.safeString(fullnameTextBox.getValue()).equals("")) { MessageBox.alert(textMessages.error(), textMessages.mustEnterFullName(), null); return false; } if (Utils.safeString(fullnameTextBox.getValue()).length() > User.LENGTH_FULLNAME) { MessageBox.alert(textMessages.error(), textMessages.tooLongFullName(), null); return false; } if (Utils.safeString(emailTextBox.getValue()).equals("")) { MessageBox.alert(textMessages.error(), textMessages.mustEnterEmail(), null); return false; } if (Utils.safeString(emailTextBox.getValue()).length() > User.LENGTH_EMAIL) { MessageBox.alert(textMessages.error(), textMessages.tooLongEmail(), null); return false; } if (!Utils.isValidEmail(Utils.safeString(emailTextBox.getValue()))) { MessageBox.alert(textMessages.error(), textMessages.invalidEmail(), null); return false; } return true; }
@Override public void handleEvent(final BaseEvent be) { // final Dialog simple = new Dialog(); // simple.setHeading("); try { final MessageBox box = new MessageBox(); box.setButtons(MessageBox.YESNOCANCEL); box.setIcon(MessageBox.QUESTION); box.setTitle("Connection request approval"); box.addCallback( new ApproveConnectionMessageBoxEventListener(r, scrollMenu, m, connectionRequest)); box.setMessage( "The owner of the email address: '" + r.getRequestorEmail().getValue() + "' would like to connect with you. You will have read only access to each others data points. Is that OK?"); box.show(); } catch (NimbitsException e) { FeedbackHelper.showError(e); } }
@Override public void handleEvent(BaseEvent be) { // TODO Auto-generated method stub if (be.getType().equals(Events.Select)) { // 会员充值 if (be.getSource().equals(addfinace)) { AddFinace_acc addfinace_acc = new AddFinace_acc(); addfinace_acc.setIsnew(0); addfinace_acc.showDialog(); } if (be.getSource().equals(d.getButtonById(Dialog.NO))) { close(); } else if (be.getSource().equals(d.getButtonById(Dialog.YES))) { passwordc_t.clearInvalid(); String passwordc = (passwordc_t.getValue() == null ? "" : passwordc_t.getValue()); String password = (password_t.getValue() == null ? "" : password_t.getValue()); if ((!passwordc.equals(password))) { passwordc_t.markInvalid("两次录入密码不一致"); MessageBox.alert("提示", "两次密码录入不一致", null); return; } if (w.isValid()) { CommandSyncContainer list = new CommandSyncContainer(); CommandSyncsql commandsql = new CommandSyncsql(); // 保存 commandsql.getV().addAll(store._trySave(0)); // 更新ccode /** 不得已才如此操作,因为ccode的ccode字段是与其他操作管理的字段,和ccodepanel里的做法一直, 默认与icode同值 */ GWT.log( "update ccode set ccode =icode where s_cardno='" + cardno_t.getValue() + "' and cname='" + cname_t.getValue() + "'", null); commandsql .getV() .add( "update ccode set ccode =icode where s_cardno='" + cardno_t.getValue() + "' and cname='" + cname_t.getValue() + "'"); list.add(commandsql); final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.SendCommandSync( list, new AsyncCallback<CommandSyncReturnObject>() { public void onFailure(Throwable caught) { Window.alert("网络连接不稳定,请稍后重试!"); } public void onSuccess(CommandSyncReturnObject cyro) { System.out.println("成功:" + cyro.getMessage() + cyro.isB() + cyro.getRetrunstr()); if (cyro.isB()) { Info.display("", "保存成功", ""); addfinace.setEnabled(true); // close(); } else { MessageBox.alert("错误", "保存错误!" + cyro.getMessage(), null); } } }); // store.trySave(0); d.getButtonById(Dialog.YES).setEnabled(false); } else MessageBox.alert("禁止", "请检查录入是否正确!", null); } } else if (be.getType().equals(Events.Change)) { if (be.getSource().equals(cardno_t)) { final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.getDataSet( "select count(*) as c from ccode where s_cardno='" + cardno_t.getValue() + "'", new AsyncCallback<DataSet>() { @Override public void onFailure(Throwable caught) {} @Override public void onSuccess(DataSet result) { if (Integer.parseInt(result.getValue(0, "c")) > 0) { Validator v = new Validator() { @Override public String validate(Field<?> field, String value) { return "已经存在相同卡号的用户"; } }; cardno_t.setValidator(v); } else { cardno_t.setValidator(null); } cardno_t.validate(); } }); } else if (be.getSource().equals(cname_t)) { final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.getDataSet( "select count(*) as c from ccode where cname='" + cname_t.getValue() + "'", new AsyncCallback<DataSet>() { @Override public void onFailure(Throwable caught) {} @Override public void onSuccess(DataSet result) { if (Integer.parseInt(result.getValue(0, "c")) > 0) { Validator v = new Validator() { @Override public String validate(Field<?> field, String value) { return "已经存在相同名字的用户"; } }; cname_t.setValidator(v); } else { cname_t.setValidator(null); } cname_t.validate(); } }); } // else if (name.equals("s_cardno")) { // ccode_t.setFireChangeEventOnSetValue(true); // ccode_t.setValue(icode_t.getValue()); // ccode_t.setFireChangeEventOnSetValue(false); // } } }
@Override public void onFailure(Throwable caught) { FeedbackHelper.showError(caught); box.close(); }
private void submitJob() { mask(); final Map<String, String> jobProperties; try { jobProperties = calculateJobProperties(); } catch (JobCreationException e) { unmask(); e.printStackTrace(); Window.alert(e.getLocalizedMessage()); return; } final MessageBox box = MessageBox.progress( "Please wait", "Submitting job " + jobProperties.get(Constants.JOBNAME_KEY) + "...", "Initializing..."); final ProgressBar bar = box.getProgressBar(); final Timer t = new Timer() { float i; @Override public void run() { GrisuClientService.Util.getInstance() .getCurrentStatus( jobProperties.get(Constants.JOBNAME_KEY), new AsyncCallback<DtoActionStatus>() { public void onFailure(Throwable arg0) { box.close(); unmask(); cancel(); arg0.printStackTrace(); } public void onSuccess(DtoActionStatus arg0) { try { if (arg0 != null && arg0.getFinished()) { box.close(); unmask(); cancel(); if (!arg0.getFailed()) { UserEnvironment.getInstance() .setUserProperty( Constants.DEFAULT_VERSION + lastCalculatedExecutable, jobProperties.get(Constants.APPLICATIONVERSION_KEY)); } } if (arg0 == null) { bar.updateProgress(0, "Contacting..."); return; } double current = arg0.getCurrentElements(); double total = arg0.getTotalElements(); bar.updateProgress( current / total, arg0.getLog().get(arg0.getLog().size() - 1).getLogMessage()); } catch (Exception e) { e.printStackTrace(); } } }); } }; t.scheduleRepeating(500); UserEnvironment.getInstance().submitJob(jobProperties); }
/** * Display a Confirmation Message in the Application * * @param title * @param message * @param callback */ public static MessageBox confirmMessage( String title, String message, Listener<MessageBoxEvent> callback) { return MessageBox.confirm(title, message, callback); }
public static void show(String command, String param) { if (command.equals(AJAX)) { MessageBox.alert(title + "AJAX error", "The browser doesn't support the AJAX object!", null) .setIcon(MessageBox.ERROR); } else if (command.equals(SEMANTIC_ANNOTATION)) { MessageBox.alert( title + "Semantic Annotation warning", "The highlighted keyword doe not correspond to the chosen entity! Do you want to do the annotation anyway?", null); } else if (command.equals(EMPTY_URI)) { MessageBox.alert(title + "Empty URI warning", "The empty string is not a valid URI!", null); } else if (command.equals(INVALID_URI)) { MessageBox.alert(title + "Invalid URI warning", "The typed string is not a valid URI!", null); } else if (command.equals(ANNOTATION_SELECTION)) { MessageBox.alert( title + "Annotation warning", "You should select the text before annotating.", null); } else if (command.equals(WATSON_SELECTION)) { MessageBox.alert( title + "Watson warning", "You should highlight a term from the text, before querying Watson.", null); } else if (command.equals(TERM_ALREADY_RETRIEVED)) { MessageBox.alert( title + "Watson warning", "The keyword \"" + param + "\" is already retrieved!", null); } else if (command.equals(NO_WATSON_RESULT)) { MessageBox.info( title + "Watson info", "Watson returned no search results for this keyword!", null); } else if (command.equals(STORE_SUCCESS)) { MessageBox.info( title + "Repository info", "Successfully save to the repository. The URI is " + param, null); } else if (command.equals(STORE_FAIL)) { MessageBox.alert(title + "Repository warning", "Fail to save to the repository", null); } else if (command.equals(DIV_ELEMENT)) { MessageBox.alert( title + "Annotation warning", "Your selection will breakup the HTML code.", null); } else if (command.equals(EXISTINGID)) { MessageBox.alert( title + "Existing Id warning", "Please choose a different name! This element id already exists.", null); } else if (command.equals(DELETEMREF)) { MessageBox.alert( title + "Delete", "Please delete the entity node in order to remove the model reference.", null); } else if (command.equals(ADDMREF)) { MessageBox.alert( title + "Model reference", "You can add model reference only to input and output elements.", null); } else if (command.equals(ADDMREF1)) { MessageBox.alert( title + "Model reference", "You can add model reference only to service and operation elements.", null); } else if (command.equals(ADDLFSCHEMA)) { MessageBox.alert( title + "Schema mapping", "You can add lifting and lowering schemas only to input and output elements.", null); } }