Exemplo n.º 1
0
 @Autowired
 public void setMangoGwtAsyncAdapterRemoteServiceLocator(
     MangoGwtAsyncAdapterRemoteServiceLocator mangoGwtAsyncAdapterRemoteServiceLocator) {
   MangoClientWeb.getInstance()
       .setMyAdminGWTRemoteServiceLocator(mangoGwtAsyncAdapterRemoteServiceLocator);
   MangoClientWeb.MESSAGES = I18NProxy.create(MangoMessages.class);
   MangoDemoClientConfiguration.registerAll();
 }
  public HierarchicalTreeModule(
      String moduleUrl,
      final AsyncCallback<IModule> moduleCallback,
      Map<String, Object> parameters) {
    super(moduleUrl, moduleCallback, parameters);

    final IHierarchicalServiceGWTAsync hierarchicalService =
        MangoClientWeb.getInstance().getRemoteServiceLocator().getHierarchicalService();

    hierarchicalService.getConfigurationById(
        getHierarchicalTreeId(),
        new AsyncCallback<HierarchicalConfigurationVO>() {

          /** {@inheritDoc} */
          @Override
          public void onFailure(Throwable caught) {
            moduleCallback.onFailure(caught);
          }

          @Override
          public void onSuccess(HierarchicalConfigurationVO result) {
            HierarchicalTreeModule.this.hierarchicalConfiguration = result;

            Set<String> allDictionaryNames = new HashSet<String>();
            for (Map.Entry<String, List<String>> entry :
                HierarchicalTreeModule.this
                    .hierarchicalConfiguration
                    .getDictionaryHierarchy()
                    .entrySet()) {
              allDictionaryNames.add(entry.getKey());

              for (String dictionaryName : entry.getValue()) {
                if (dictionaryName != null) {
                  allDictionaryNames.addAll(entry.getValue());
                }
              }
            }

            for (String dictionaryId : allDictionaryNames) {
              List<String> childDictionaryIds =
                  HierarchicalTreeModule.this.hierarchicalConfiguration.getChildDictionaryIds(
                      dictionaryId);

              List<IDictionaryModel> childDictionaries = Collections.emptyList();
              if (!childDictionaryIds.isEmpty()) {
                childDictionaries = DictionaryModelProvider.getDictionaries(childDictionaryIds);
              }

              DictionaryHookRegistry.getInstance()
                  .addEditorHook(
                      dictionaryId, new HierarchicalEditorHook<IHierarchicalVO>(childDictionaries));
            }

            getModuleCallback().onSuccess(HierarchicalTreeModule.this);
          }
        });
  }