Ejemplo n.º 1
0
  public FormExporter() {
    bus.addHandler(
        UndoableEvent.TYPE,
        new UndoableHandler() {
          @Override
          public void onEvent(UndoableEvent event) {
            bus.fireEvent(new GetFormRepresentationEvent(EXPORT_TYPE));
          }

          @Override
          public void doAction(UndoableEvent event) {}

          @Override
          public void undoAction(UndoableEvent event) {}
        });

    bus.addHandler(
        GetFormRepresentationResponseEvent.TYPE,
        new GetFormRepresentationResponseHandler() {
          @Override
          public void onEvent(GetFormRepresentationResponseEvent event) {
            if (EXPORT_TYPE.equals(event.getSaveType())) {
              exportForm(event.getRepresentation());
            }
          }
        });
  }
Ejemplo n.º 2
0
  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));
    }
  }
Ejemplo n.º 3
0
	private void connectHandlers() {
		EventBus eventBus = playerServices.getEventBus();
		
		eventBus.addHandler(ShowErrorsEvent.TYPE, new ShowErrorsEvent.Handler() {
			public void onShowErrors(ShowErrorsEvent event) {
				setShowErrorsMode();
			}
		});
		
		eventBus.addHandler(WorkModeEvent.TYPE, new WorkModeEvent.Handler() {
			public void onWorkMode(WorkModeEvent event) {
				setWorkMode();
			}
		});
		
		eventBus.addHandler(ResetPageEvent.TYPE, new ResetPageEvent.Handler() {
			public void onResetPage(ResetPageEvent event) {
				setWorkMode();
			}
		});
		
		eventBus.addHandler(CustomEvent.TYPE, new CustomEvent.Handler() {
			@Override
			public void onCustomEventOccurred(CustomEvent event) {
				if (event.eventName.equals("ShowAnswers")) {
					if (view.isShowErrorsMode()) {
						view.setShowErrorsMode(false);
					}
				}
			}
		});
	}
Ejemplo n.º 4
0
 public FormBuilderModel(String contextPath) {
   this.contextPath = contextPath;
   // registered to save the menu items
   bus.addHandler(
       MenuItemAddedEvent.TYPE,
       new MenuItemAddedHandler() {
         public void onEvent(MenuItemAddedEvent event) {
           FBMenuItem item = event.getMenuItem();
           saveMenuItem(event.getGroupName(), item);
           if (item instanceof CustomMenuItem) {
             CustomMenuItem customItem = (CustomMenuItem) item;
             String formItemName = customItem.getOptionName();
             FormItemRepresentation formItem = customItem.getRepresentation();
             saveFormItem(formItem, formItemName);
           }
         }
       });
   // registered to delete the menu items
   bus.addHandler(
       MenuItemRemoveEvent.TYPE,
       new MenuItemRemoveHandler() {
         public void onEvent(MenuItemRemoveEvent event) {
           FBMenuItem item = event.getMenuItem();
           deleteMenuItem(event.getGroupName(), item);
           if (item instanceof CustomMenuItem) {
             CustomMenuItem customItem = (CustomMenuItem) item;
             String formItemName = customItem.getOptionName();
             FormItemRepresentation formItem = customItem.getRepresentation();
             deleteFormItem(formItemName, formItem);
           }
         }
       });
 }
Ejemplo n.º 5
0
 public TreePresenter(TreeView treeView) {
   this.view = treeView;
   bus.addHandler(
       FormItemRemovedEvent.TYPE,
       new FormItemRemovedHandler() {
         @Override
         public void onEvent(FormItemRemovedEvent event) {
           FBFormItem item = event.getFormItem();
           view.removeFormItem(item);
         }
       });
   bus.addHandler(
       FormItemAddedEvent.TYPE,
       new FormItemAddedHandler() {
         @Override
         public void onEvent(FormItemAddedEvent event) {
           FBFormItem item = event.getFormItem();
           Widget parent = event.getFormItemHolder();
           FBCompositeItem parentItem = null;
           while (parent != null && parentItem == null) {
             if (parent instanceof FBCompositeItem) {
               parentItem = (FBCompositeItem) parent;
             } else {
               parent = parent.getParent();
             }
           }
           view.addFormItem(item, parentItem);
         }
       });
 }
Ejemplo n.º 6
0
 @Override
 public void start(AcceptsOneWidget panel, EventBus eventBus) {
   view = Util.getGeolocationView();
   view.setPresenter(this);
   panel.setWidget(view);
   eventBus.fireEvent(new SourceUpdateEvent(view.getClass().getName()));
 }
Ejemplo n.º 7
0
  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));
    }
  }
Ejemplo n.º 8
0
  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);
              }
            }));
  }
Ejemplo n.º 9
0
  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;
  }
Ejemplo n.º 10
0
  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;
  }
Ejemplo n.º 11
0
  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;
  }
Ejemplo n.º 12
0
  @Override
  public void start(
      AcceptsOneWidget containerWidget, com.google.gwt.event.shared.EventBus eventBus) {
    containerWidget.setWidget(navigationView.asWidget());
    registrations.add(
        navigationView
            .getSelectionModel()
            .addSelectionChangeHandler(
                new SelectionChangeEvent.Handler() {
                  @Override
                  public void onSelectionChange(SelectionChangeEvent event) {
                    TreePlace place = navigationView.getSelectionModel().getSelectedObject();
                    if (place != null) {
                      goTo(place);
                    }
                  }
                }));
    registrations.add(
        eventBus.addHandler(
            DataEvent.getType(),
            new DataEventHandler() {

              @Override
              public void onDataChanged(DataEvent event) {
                if (event.refreshTree()) {
                  refreshTree();
                  if (pendingPlace != null) {
                    selectPlace(pendingPlace);
                  }
                }
              }
            }));
  }
Ejemplo n.º 13
0
  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);
  }
Ejemplo n.º 14
0
 @UiHandler("nextButton")
 void handleNextButton(ClickEvent event) {
   if (validateFields()) {
     eventBus.fireEvent(new PanelTransitionEvent(PanelTransitionEvent.TransitionTypes.NEXT, this));
   } else {
     Window.alert("Validation error");
   }
 }
Ejemplo n.º 15
0
 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));
   }
 }
Ejemplo n.º 16
0
 private void setupBreadCrumbs() {
   String[] crumbs = {
     appBrowserPanel.getTitle(),
     projectOptionsPanel.getTitle(),
     databaseOptionsPanel.getTitle(),
     deploymentOptionsPanel.getTitle()
   };
   eventBus.fireEvent(new BreadCrumbEvent(BreadCrumbEvent.Action.SET_CRUMBS, crumbs));
 }
Ejemplo n.º 17
0
 @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()));
 }
Ejemplo n.º 18
0
 private void registerHandlers() {
   eventBus.addHandler(
       UpdateDBOptionsEvent.TYPE,
       new UpdateDBOptionsEventHandler() {
         public void onUpdateDBOptions(UpdateDBOptionsEvent event) {
           setAllowedAuthApps(event.getDBOptionsData().getAllowedAuthApps());
         }
       });
 }
  /** Construct a "sidebar" for a vertical Template Data editor */
  public VerticalTemplateDataSidebarWidget(
      ResourcesProvider<TemplateDataColumn> resources, boolean isReadOnly, EventBus eventBus) {
    // Argument validation performed in the superclass constructor
    super(resources, isReadOnly, eventBus);

    contextMenu = new CopyPasteContextMenu(eventBus);

    // Wire-up event handlers
    eventBus.addHandler(SetInternalTemplateDataModelEvent.TYPE, this);
  }
 private void bind(EventBus eventBus) {
   eventBus.addHandler(
       TreeVisEvent.TYPE,
       new TreeVisEventHandler() {
         @Override
         public void onViewData(TreeVisEvent e) {
           addVisTab(e.getData().getDataKey(), e.getData().getModelKey(), e.getIndex());
         }
       });
   eventBus.addHandler(
       RFGenerateEvent.TYPE,
       new RFGenerateEventHandler() {
         @Override
         public void onStart(RFGenerateEvent e) {
           logger.log(Level.INFO, "Adding confusion matrix...");
           addConfusionMatrixTab(e.getData(), e.getBuilder());
         }
       });
 }
Ejemplo n.º 21
0
 private void bind() {
   eventBus.addHandler(
       UserInfoUpdatedEvent.TYPE,
       new UserInfoUpdatedEventHandler() {
         @Override
         public void onUserInfoChanged(UserInfoUpdatedEvent event) {
           // makes sure userInfo is up to date b/c class list view uses it
           userInfo = event.getUserInfo();
         }
       });
 }
Ejemplo n.º 22
0
 @Before
 public void setup() {
   eventBus.addHandler(
       SearchFieldChangedEvent.TYPE,
       new SearchFieldChangedHandler() {
         public void onSearchFieldChanged(SearchFieldChangedEvent event) {
           trace.add("search");
         }
       });
   trace.clear();
 }
Ejemplo n.º 23
0
  public SettingsCommand() {
    super();
    bus.addHandler(
        LoadSettingsResponseEvent.TYPE,
        new LoadSettingsResponseHandler() {

          public void onEvent(LoadSettingsResponseEvent event) {
            showSettingsPanel(event.getSettings());
          }
        });
  }
  /**
   * 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));
  }
Ejemplo n.º 25
0
 private void registerHandlers() {
   eventBus.addHandler(
       PanelTransitionEvent.TYPE,
       new PanelTransitionEventHandler() {
         public void onPanelTransition(PanelTransitionEvent event) {
           if (event.getTransitionType() == PanelTransitionEvent.TransitionTypes.PROJECTS) {
             setupBreadCrumbs();
           }
         }
       });
 }
  public void start(AcceptsOneWidget container, EventBus eventBus) {
    // Подписка activity-презентера на события EventBus.
    eventBus.addHandler(DeleteEvent.TYPE, this);
    eventBus.addHandler(DoDeleteEvent.TYPE, this);
    eventBus.addHandler(DoGetRecordEvent.TYPE, this);
    eventBus.addHandler(DoSearchEvent.TYPE, this);
    eventBus.addHandler(ListEvent.TYPE, this);
    eventBus.addHandler(SearchEvent.TYPE, this);
    eventBus.addHandler(SetCurrentRecordEvent.TYPE, this);
    eventBus.addHandler(SetListUIDEvent.TYPE, this);
    eventBus.addHandler(SaveEvent.TYPE, this);

    // "Привязка" элементов представления к функционалу презентера.
    bind();
    // Переведем презентер модуля в заданный режим.
    changeWorkstate(place);
  }
Ejemplo n.º 27
0
  @Override
  public void start(AcceptsOneWidget panel, EventBus eventBus) {
    this.container = panel;
    this.eventBus = eventBus;
    handlers.add(eventBus.addHandler(FlashStatusChangeEvent.TYPE, this));

    if (useFlash) {
      fsiActivity.start(panel, eventBus);
    } else {
      jsActivity.start(panel, eventBus);
    }
  }
Ejemplo n.º 28
0
  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));
    }
  }
Ejemplo n.º 29
0
  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));
    }
  }
Ejemplo n.º 30
0
	private void connectHandlers() {
		EventBus eventBus = playerServices.getEventBus();

		eventBus.addHandler(ShowErrorsEvent.TYPE, new ShowErrorsEvent.Handler() {
			@Override
			public void onShowErrors(ShowErrorsEvent event) {
				setShowErrorsMode();
			}
		});

		eventBus.addHandler(WorkModeEvent.TYPE, new WorkModeEvent.Handler() {
			@Override
			public void onWorkMode(WorkModeEvent event) {
				setWorkMode();
			}
		});

		eventBus.addHandler(ResetPageEvent.TYPE, new ResetPageEvent.Handler() {
			@Override
			public void onResetPage(ResetPageEvent event) {
				reset();
			}
		});

		eventBus.addHandler(ItemSelectedEvent.TYPE, new ItemSelectedEvent.Handler() {
			@Override
			public void onItemSelected(ItemSelectedEvent event) {
				if (event.getItem() instanceof DraggableImage) {
					if (event.getItem().getId() == null) {
						readyToDraggableItem = null;
					} else {
						readyToDraggableItem = event.getItem();
					}
				}
			}
		});

		eventBus.addHandler(ItemConsumedEvent.TYPE, new ItemConsumedEvent.Handler() {
			@Override
			public void onItemConsumed(ItemConsumedEvent event) {
				readyToDraggableItem = null;
			}
		});

		eventBus.addHandler(CustomEvent.TYPE, new CustomEvent.Handler() {
			@Override
			public void onCustomEventOccurred(CustomEvent event) {
				if (event.eventName.equals("ShowAnswers")) {
					showAnswers();
				} else if (event.eventName.equals("HideAnswers")) {
					hideAnswers();
				}
			}
		});
	}