public void generateForm(FormRepresentation form, String language, Map<String, Object> inputs) { RequestBuilder request = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + this.contextPath + "/formPreview/lang/" + language); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { String html = response.getText(); bus.fireEvent(new PreviewFormResponseEvent(html)); } public void onError(Request request, Throwable exception) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't preview form", exception)); } }); try { request.setRequestData(helper.asXml(form, inputs)); request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't send form to server", e)); } catch (FormEncodingException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't decode form", e)); } }
public List<TaskRef> getExistingTasks(final String filter) { final List<TaskRef> retval = new ArrayList<TaskRef>(); String url = GWT.getModuleBaseURL() + this.contextPath + "/tasks/package/defaultPackage/"; if (filter != null && !"".equals(filter)) { url = url + "q=" + URL.encodeQueryString(filter); } RequestBuilder request = new RequestBuilder(RequestBuilder.GET, url); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { retval.addAll(helper.readTasks(response.getText())); bus.fireEvent(new ExistingTasksResponseEvent(retval, filter)); } public void onError(Request request, Throwable exception) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't read tasks", exception)); } }); try { request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't read tasks", e)); } return retval; }
public VerticalDecisionTableWidget( GuidedDecisionTable52 model, DataModelOracle oracle, Identity identity, boolean isReadOnly, EventBus eventBus) { super(model, oracle, identity, isReadOnly, eventBus); VerticalPanel vp = new VerticalPanel(); ctrls = new DecisionTableControlsWidget(this, model, identity, isReadOnly); vp.add(ctrls); // Construct the widget from which we're composed widget = new VerticalDecoratedDecisionTableGridWidget( resources, cellFactory, cellValueFactory, dropDownManager, isReadOnly, eventBus); vp.add(widget); initWidget(vp); // Fire event for UI components to set themselves up SetGuidedDecisionTableModelEvent sme = new SetGuidedDecisionTableModelEvent(model); eventBus.fireEvent(sme); }
private void addRuleViewInToSimplePanel( final MultiViewRow row, final SimplePanel content, final Asset asset) { eventBus.fireEvent( new RefreshModuleDataModelEvent( asset.getMetaData().getModuleName(), new Command() { public void execute() { RuleViewerSettings ruleViewerSettings = new RuleViewerSettings(); ruleViewerSettings.setDocoVisible(false); ruleViewerSettings.setMetaVisible(false); ruleViewerSettings.setStandalone(true); Command closeCommand = new Command() { public void execute() { // TODO: No handle for this -Rikkola- ruleViews.remove(row.getUuid()); rows.remove(row); doViews(); } }; final RuleViewer ruleViewer = new RuleViewer(asset, clientFactory, eventBus, ruleViewerSettings); // ruleViewer.setDocoVisible( showDescription ); // ruleViewer.setMetaVisible( showMetadata ); content.add(ruleViewer); ruleViewer.setWidth("100%"); ruleViewer.setHeight("100%"); ruleViews.put(row.getUuid(), ruleViewer); } })); }
public List<MainMenuOption> getMenuOptions() { final List<MainMenuOption> currentOptions = new ArrayList<MainMenuOption>(); RequestBuilder request = new RequestBuilder( RequestBuilder.GET, GWT.getModuleBaseURL() + this.contextPath + "/menuOptions/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { currentOptions.addAll(helper.readMenuOptions(response.getText())); for (MainMenuOption option : currentOptions) { bus.fireEvent(new MenuOptionAddedEvent(option)); } } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent(Level.ERROR, "Couldn't find menu options", exception)); } }); try { request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't read menuOptions", e)); } return currentOptions; }
public Map<String, List<FBMenuItem>> getMenuItems() { final Map<String, List<FBMenuItem>> menuItems = new HashMap<String, List<FBMenuItem>>(); RequestBuilder request = new RequestBuilder( RequestBuilder.GET, GWT.getModuleBaseURL() + this.contextPath + "/menuItems/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { menuItems.putAll(helper.readMenuMap(response.getText())); for (String groupName : menuItems.keySet()) { for (FBMenuItem menuItem : menuItems.get(groupName)) { bus.fireEvent(new MenuItemFromServerEvent(menuItem, groupName)); } } } else { bus.fireEvent( new NotificationEvent( Level.ERROR, "Couldn't find menu items: response status 404")); } } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent(Level.ERROR, "Couldn't find menu items", exception)); } }); try { request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't read menuItems", e)); } return menuItems; }
public void deleteMenuItem(String groupName, FBMenuItem item) { RequestBuilder request = new RequestBuilder( RequestBuilder.DELETE, GWT.getModuleBaseURL() + this.contextPath + "/menuItems/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { int code = response.getStatusCode(); if (code != Response.SC_ACCEPTED && code != Response.SC_NO_CONTENT && code != Response.SC_OK) { bus.fireEvent( new NotificationEvent( Level.WARN, "Error deleting menu item on server (code = " + code + ")")); } else { bus.fireEvent(new NotificationEvent(Level.INFO, "menu item deleted successfully")); } } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent( Level.ERROR, "Error deleting menu item on server", exception)); } }); try { request.setRequestData(helper.asXml(groupName, item)); request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Error deleting menu item on server", e)); } }
@Override public void start(AcceptsOneWidget panel, EventBus eventBus) { view = Util.getGeolocationView(); view.setPresenter(this); panel.setWidget(view); eventBus.fireEvent(new SourceUpdateEvent(view.getClass().getName())); }
@UiHandler("nextButton") void handleNextButton(ClickEvent event) { if (validateFields()) { eventBus.fireEvent(new PanelTransitionEvent(PanelTransitionEvent.TransitionTypes.NEXT, this)); } else { Window.alert("Validation error"); } }
@Override public void start(AcceptsOneWidget panel, EventBus eventBus) { PopViewImpl view = Util.getPopView(); view.setPresenter(this); Pop pop = new Pop(); ViewPort.get().setAnimation(pop); panel.setWidget(view); eventBus.fireEvent(new SourceUpdateEvent(view.getClass().getName())); }
private void setupBreadCrumbs() { String[] crumbs = { appBrowserPanel.getTitle(), projectOptionsPanel.getTitle(), databaseOptionsPanel.getTitle(), deploymentOptionsPanel.getTitle() }; eventBus.fireEvent(new BreadCrumbEvent(BreadCrumbEvent.Action.SET_CRUMBS, crumbs)); }
protected void exportForm(FormRepresentation form) { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); try { String formAsJson = encoder.encode(form); setClientExportForm(formAsJson); } catch (FormEncodingException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.CouldntExportAsJson(), e)); } }
/** * Start splitting the given geometry. * * @param geometry to be split */ public void start(Geometry geometry) { this.geometry = geometry; splitLine = new Geometry(Geometry.LINE_STRING, 0, 0); service.start(splitLine); service.setInsertIndex(service.getIndexService().create(GeometryIndexType.TYPE_VERTEX, 0)); service.setEditingState(GeometryEditState.INSERTING); started = true; eventBus.fireEvent(new GeometrySplitStartEvent(geometry)); }
public void loadFormTemplate(final FormRepresentation form, final String language) { RequestBuilder request = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + this.contextPath + "/formTemplate/lang/" + language); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { String fileName = helper.getFileName(response.getText()); FormPanel auxiliarForm = new FormPanel(); auxiliarForm.setMethod("get"); auxiliarForm.setAction( GWT.getModuleBaseURL() + contextPath + "/formTemplate/lang/" + language); Hidden hidden1 = new Hidden("fileName"); hidden1.setValue(fileName); Hidden hidden2 = new Hidden("formName"); hidden2.setValue( form.getName() == null || "".equals(form.getName()) ? "template" : form.getName()); VerticalPanel vPanel = new VerticalPanel(); vPanel.add(hidden1); vPanel.add(hidden2); auxiliarForm.add(vPanel); RootPanel.get().add(auxiliarForm); auxiliarForm.submit(); } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent(Level.ERROR, "Couldn't export template", exception)); } }); try { request.setRequestData(helper.asXml(form, null)); request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't send form to server", e)); } catch (FormEncodingException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't decode form", e)); } }
public void saveFormItem(final FormItemRepresentation formItem, String formItemName) { RequestBuilder request = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + this.contextPath + "/formItems/package/defaultPackage/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_CONFLICT) { bus.fireEvent( new NotificationEvent( Level.WARN, "formItem already updated in server. Try refreshing your view")); } else if (response.getStatusCode() != Response.SC_CREATED) { bus.fireEvent( new NotificationEvent( Level.WARN, "Unkown status for saveFormItem: HTTP " + response.getStatusCode())); } else { String name = helper.getFormItemId(response.getText()); bus.fireEvent( new NotificationEvent(Level.INFO, "Form item " + name + " saved successfully")); } } public void onError(Request request, Throwable exception) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't save form item", exception)); } }); try { request.setRequestData(helper.asXml(formItemName, formItem)); request.send(); } catch (RequestException e) { bus.fireEvent( new NotificationEvent( Level.ERROR, "Couldn't send form item " + formItemName + " to server", e)); } catch (FormEncodingException e) { bus.fireEvent( new NotificationEvent(Level.ERROR, "Couldn't decode form item " + formItemName, e)); } }
/** * Fired when an option is selected on the <tt>FormVersionOpenDialogListener.</tt> * * @param option the selected option. * @param tree <tt>Tree View</tt> we checking items from. * @param item <tt>Tree Item</tt> we checking. * @param eventBus <tt>ItemSelectionListener</tt> for the data check operation. * @param popup <tt>Popup</tt> for the <tt>Tree View.</tt> */ public static void onOptionSelected( int option, Tree tree, TreeItem item, EventBus eventBus, PopupPanel popup) { if (option == 0) { // Create new form verson if (item.getUserObject() instanceof FormDefVersion) { FormDefVersion copyVersion = (FormDefVersion) item.getUserObject(); String xForm = copyVersion.getXform(); addNewItem(xForm, tree, Context.getStudies(), popup); } } else if (option == 1) { // Open the dialog as read only final Object userObject = tree.getSelectedItem().getUserObject(); // ((StudyView)eventBus).designItem(true, tree.getSelectedItem().getUserObject()); if (userObject instanceof FormDefVersion) eventBus.fireEvent(new DesignFormEvent((FormDefVersion) userObject)); } else if (option == 2) { // Cancel option return; } else { // ((StudyView)eventBus).designItem(false, tree.getSelectedItem().getUserObject()); final Object userObject = tree.getSelectedItem().getUserObject(); if (userObject instanceof FormDefVersion) eventBus.fireEvent(new DesignFormEvent((FormDefVersion) userObject, true)); } }
public void doCheckin(Widget editor, Asset asset, String comment, boolean closeAfter) { if (editor instanceof SaveEventListener) { ((SaveEventListener) editor).onSave(); } performCheckIn(comment, closeAfter, asset); if (editor instanceof SaveEventListener) { ((SaveEventListener) editor).onAfterSave(); } eventBus.fireEvent(new RefreshModuleEditorEvent(asset.getMetaData().getModuleUUID())); // lastSaved = System.currentTimeMillis(); // resetDirty(); }
public void saveForm(final FormRepresentation form) { RequestBuilder request = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + this.contextPath + "/formDefinitions/package/defaultPackage/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_CONFLICT) { bus.fireEvent( new NotificationEvent( Level.WARN, "Form already updated in server. Try refreshing your form")); } else if (response.getStatusCode() != Response.SC_CREATED) { bus.fireEvent( new NotificationEvent( Level.WARN, "Unkown status for saveForm: HTTP " + response.getStatusCode())); } else { String name = helper.getFormId(response.getText()); form.setLastModified(System.currentTimeMillis()); form.setSaved(true); form.setName(name); bus.fireEvent(new FormSavedEvent(form)); } } public void onError(Request request, Throwable exception) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't save form", exception)); } }); try { String json = FormEncodingFactory.getEncoder().encode(form); request.setRequestData(json); request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't send form to server", e)); } catch (FormEncodingException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't decode form", e)); } }
@Override public void start(final AcceptsOneWidget panel, EventBus eventBus) { final String msg = "Failed to load book selection data. [" + category.toString() + "]"; panel.setWidget(view); LoadingPanel.INSTANCE.show(); view.setPresenter(this); eventBus.fireEvent(new SidebarItemSelectedEvent(getLabel(category))); view.setHeaderText(getHeader(category)); service.loadBookSelectionData( WebsiteConfig.INSTANCE.collection(), category, LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback<BookSelectList>() { @Override public void onFailure(Throwable caught) { logger.log(Level.SEVERE, msg, caught); view.addErrorMessage(msg); if (caught instanceof RosaConfigurationException) { view.addErrorMessage(caught.getMessage()); } LoadingPanel.INSTANCE.hide(); } @Override public void onSuccess(BookSelectList result) { LoadingPanel.INSTANCE.hide(); if (result == null) { logger.severe(msg); view.addErrorMessage(msg); return; } result.setCategory(category); view.setData(result); } }); Scheduler.get() .scheduleDeferred( new ScheduledCommand() { @Override public void execute() { view.onResize(); } }); }
/** * In some cases we will want to flush the package dependency stuff for suggestion completions. * The user will still need to reload the asset editor though. */ public void flushSuggestionCompletionCache(final String packageName, Asset asset) { if (AssetFormats.isPackageDependency(asset.getFormat())) { LoadingPopup.showMessage(constants.RefreshingContentAssistance()); eventBus.fireEvent( new RefreshModuleDataModelEvent( packageName, new Command() { public void execute() { // Some assets depend on the SuggestionCompletionEngine. This event is to notify // them that the // SuggestionCompletionEngine has been changed, they need to refresh their UI to // represent the changes. eventBus.fireEvent(new RefreshSuggestionCompletionEngineEvent(packageName)); LoadingPopup.close(); } })); } }
/** * Stop splitting the geometry. * * @param callback the {@link GeometryArrayFunction} to be executed after the splitting has * stopped */ public void stop(final GeometryArrayFunction callback) { started = false; service.stop(); if (callback != null) { calculate( new GeometryArrayFunction() { public void execute(Geometry[] geometries) { callback.execute(geometries); splitLine = null; eventBus.fireEvent(new GeometrySplitStopEvent(geometry)); } }); } else { eventBus.fireEvent(new GeometrySplitStopEvent(geometry)); splitLine = null; } }
public ProjectDeployerController(ClientFactory clientFactory) { initWidget(uiBinder.createAndBindUi(this)); this.createdProjectName = ""; this.currentPanelIndex = 0; this.eventBus = clientFactory.getEventBus(); this.clientFactory = clientFactory; this.jsVarHandler = clientFactory.getJSVariableHandler(); this.loadingPopup = new PopupPanel(false, true); this.appBrowserPanel = new AppBrowserPanel(clientFactory); this.projectOptionsPanel = new ProjectOptionsPanel(clientFactory); this.databaseOptionsPanel = new DatabaseOptionsPanel(clientFactory); this.deploymentOptionsPanel = new DeploymentOptionsPanel(clientFactory); setupLoadingPopup(); setupDeployerDeckPanel(); registerHandlers(); setupBreadCrumbs(); String token = jsVarHandler.getProjectToken(); if (token != null) { eventBus.fireEvent(new AsyncRequestEvent("handleImportAppList", token)); } }
public void exceptionError(Exception e) { GWT.log("[exceptionError()]", e); /* unhandled exception. get stack trace. */ if (eventBus == null) return; StringBuilder sb = new StringBuilder(); for (StackTraceElement element : e.getStackTrace()) { sb.append(element + "<br/>"); } eventBus.fireEvent( new ErrorDisplayEvent( constants.exceptionError() + " " + constants.exceptionErrorText(), "<b>" + constants.exceptionErrorContent() + "</b>:<br/>" + e.toString() + "<br/>" + sb.toString() + "<br/>")); }
public void saveMenuItem(final String groupName, final FBMenuItem item) { RequestBuilder request = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + this.contextPath + "/defaultPackage/menuItems/" + groupName + "/"); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { int code = response.getStatusCode(); NotificationEvent event; if (code == Response.SC_CREATED) { event = new NotificationEvent( Level.INFO, "Menu item " + item.getItemId() + " saved successfully."); } else { event = new NotificationEvent( Level.WARN, "Invalid status for saveMenuItem: HTTP " + code); } bus.fireEvent(event); } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent(Level.ERROR, "Couldn't generate menu item", exception)); } }); try { request.setRequestData(helper.asXml(groupName, item)); request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't save menu item", e)); } }
public void deleteFormItem(String formItemName, FormItemRepresentation formItem) { RequestBuilder request = new RequestBuilder( RequestBuilder.DELETE, GWT.getModuleBaseURL() + this.contextPath + "/formItems/package/defaultPackage/formItemName/" + formItemName); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { int code = response.getStatusCode(); if (code != Response.SC_ACCEPTED && code != Response.SC_NO_CONTENT && code != Response.SC_OK) { bus.fireEvent( new NotificationEvent( Level.WARN, "Error deleting form item on server (code = " + code + ")")); } else { bus.fireEvent(new NotificationEvent(Level.INFO, "form item deleted successfully")); } } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent( Level.ERROR, "Error deleting form item on server", exception)); } }); try { request.send(); } catch (RequestException e) { bus.fireEvent( new NotificationEvent( Level.ERROR, "Couldn't send form item " + formItemName + " deletion to server", e)); } }
public void populateRepresentationFactory() throws FormBuilderException { String url = GWT.getModuleBaseURL() + this.contextPath + "/representationMappings/"; RequestBuilder request = new RequestBuilder(RequestBuilder.GET, url); request.setCallback( new RequestCallback() { public void onResponseReceived(Request request, Response response) { Map<String, String> repMap = helper.readPropertyMap(response.getText()); for (Map.Entry<String, String> entry : repMap.entrySet()) { RepresentationFactory.registerItemClassName(entry.getKey(), entry.getValue()); } } public void onError(Request request, Throwable exception) { bus.fireEvent( new NotificationEvent( Level.ERROR, "Couldn't read representation mappings", exception)); } }); try { request.send(); } catch (RequestException e) { bus.fireEvent(new NotificationEvent(Level.ERROR, "Couldn't read representation mappings", e)); } }
@Override public void fireEvent(GwtEvent<?> event) { eventBus.fireEvent(event); }
public void close() { eventBus.fireEvent(new ClosePlaceEvent(new MultiAssetPlace(rows))); if (closeCommand != null) { closeCommand.execute(); } }
@Override public void onAddButtonClicked() { eventBus.fireEvent(new AddContactEvent()); }
@Override public void onItemClicked(ContactDetails contactDetails) { eventBus.fireEvent(new EditContactEvent(contactDetails.getId())); }