@AfterInitialization
  public void startApp() {
    kieSecurityService
        .call(
            new RemoteCallback<String>() {
              public void callback(final String str) {
                KieWorkbenchPolicy policy = new KieWorkbenchPolicy(str);
                kieACL.activatePolicy(policy);
                loadPreferences();
                loadStyles();
                setupMenu();
                hideLoadingPopup();
                homeProducer.init();
              }
            })
        .loadPolicy();
    List<String> allActivities = activityBeansCache.getActivitiesById();
    pmas.call(
            new RemoteCallback<Void>() {

              @Override
              public void callback(Void response) {}
            })
        .initActivities(allActivities);
  }
  @Override
  public void loadChildren(PermissionNode parent, LoadOptions options, LoadCallback callback) {
    Collection<String> resourceIds = options.getResourceIds();
    int maxNodes = options.getMaxNodes();

    if (searchService != null) {
      if (resourceIds != null) {
        searchService
            .call(
                (Collection<OrganizationalUnit> orgUnits) -> {
                  List<PermissionNode> children = buildPermissionNodes(orgUnits);
                  callback.afterLoad(children);
                })
            .searchById(resourceIds);
      } else {
        String namePattern = options.getNodeNamePattern();
        searchService
            .call(
                (Collection<OrganizationalUnit> orgUnits) -> {
                  List<PermissionNode> children = buildPermissionNodes(orgUnits);
                  callback.afterLoad(children);
                })
            .searchByName(namePattern, maxNodes, false);
      }
    } else {
      callback.afterLoad(Collections.emptyList());
    }
  }
  private Caller buildServiceCaller() {
    Caller<BuildService> caller = mock(Caller.class);
    when(caller.call(any(RemoteCallback.class), any(ErrorCallback.class)))
        .thenAnswer(
            new Answer<BuildService>() {
              @Override
              public BuildService answer(InvocationOnMock invocationOnMock) throws Throwable {
                // not calling callback causes building is still set to true
                return buildService;
              }
            });

    return caller;
  }
  @Override
  public void getData(Range visibleRange) {
    ColumnSortList columnSortList = view.getListGrid().getColumnSortList();
    if (currentFilter == null) {
      currentFilter =
          new PortableQueryFilter(
              visibleRange.getStart(),
              visibleRange.getLength(),
              false,
              "",
              columnSortList.size() > 0 ? columnSortList.get(0).getColumn().getDataStoreName() : "",
              columnSortList.size() == 0 || columnSortList.get(0).isAscending());
    }
    // If we are refreshing after a search action, we need to go back to offset 0
    if (currentFilter.getParams() == null
        || currentFilter.getParams().isEmpty()
        || currentFilter.getParams().get("textSearch") == null
        || currentFilter.getParams().get("textSearch").equals("")) {
      currentFilter.setOffset(visibleRange.getStart());
      currentFilter.setCount(visibleRange.getLength());
    } else {
      currentFilter.setOffset(0);
      currentFilter.setCount(view.getListGrid().getPageSize());
    }

    currentFilter.setOrderBy(
        columnSortList.size() > 0 ? columnSortList.get(0).getColumn().getDataStoreName() : "");
    currentFilter.setIsAscending(columnSortList.size() == 0 || columnSortList.get(0).isAscending());

    processRuntimeDataService
        .call(
            new RemoteCallback<List<ProcessSummary>>() {
              @Override
              public void callback(final List<ProcessSummary> processDefsSums) {
                boolean lastPageExactCount = processDefsSums.size() < visibleRange.getLength();
                updateDataOnCallback(
                    processDefsSums,
                    visibleRange.getStart(),
                    visibleRange.getStart() + processDefsSums.size(),
                    lastPageExactCount);
              }
            },
            new ErrorCallback<Message>() {
              @Override
              public boolean error(Message message, Throwable throwable) {
                view.hideBusyIndicator();
                view.displayNotification(
                    constants.ErrorRetrievingProcessDefinitions(throwable.getMessage()));
                GWT.log(throwable.toString());
                return true;
              }
            })
        .getProcessesByFilter(
            selectedServerTemplate,
            textSearchStr,
            visibleRange.getStart() / visibleRange.getLength(),
            visibleRange.getLength(),
            currentFilter.getOrderBy(),
            currentFilter.isAscending());
  }
示例#5
0
 protected void loadContent() {
   service
       .call(
           getModelSuccessCallback(),
           new CommandDrivenErrorCallback(view, makeNoSuchFileExceptionCommand()))
       .loadContent(versionRecordManager.getCurrentPath());
 }
 @Override
 public void onShowMetadata() {
   view.showBusyIndicator(CommonConstants.INSTANCE.Loading());
   metadataService
       .call(getMetadataSuccessCallback(), new HasBusyIndicatorDefaultErrorCallback(view))
       .getMetadata(path);
 }
  @Override
  public void onSourceTabSelected() {

    context.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE);
    if (context.isParsed() && context.isEditorChanged()) {

      // If there are changes in the ui the source must be regenerated on server side.
      view.showLoading();
      modelerService
          .call(
              new RemoteCallback<GenerationResult>() {
                @Override
                public void callback(GenerationResult result) {
                  view.hideBusyIndicator();
                  setSource(result.getSource());
                  updateSource(result.getSource());
                  context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES);
                  dataModelerWBContext.setActiveContext(context);
                }
              },
              new DataModelerErrorCallback(Constants.INSTANCE.modelEditor_loading_error()))
          .updateSource(
              getSource(), versionRecordManager.getCurrentPath(), context.getDataObject());
    } else {
      if (!isOverviewTabSelected()) {
        context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES);
      }
      updateSource(javaSourceEditor.getContent());
      dataModelerWBContext.setActiveContext(context);
    }
  }
  @Override
  public void getMethodInfosForGlobalVariable(
      final String varName, final Callback<List<MethodInfo>> callback) {
    final String factType = packageGlobalTypes.get(varName);
    final List<MethodInfo> methodInformation = projectMethodInformation.get(factType);

    // Load incremental content
    if (methodInformation == null) {
      service
          .call(
              new RemoteCallback<PackageDataModelOracleIncrementalPayload>() {

                @Override
                public void callback(final PackageDataModelOracleIncrementalPayload dataModel) {
                  AsyncPackageDataModelOracleUtilities.populateDataModelOracle(
                      AsyncPackageDataModelOracleImpl.this, dataModel);
                  callback.callback(projectMethodInformation.get(factType));
                }
              })
          .getUpdates(resourcePath, imports, factType);

    } else {
      callback.callback(methodInformation);
    }
  }
  // Refresh when a Resource has been renamed, if it exists in the active package
  public void onResourceRenamed(@Observes final ResourceRenamedEvent event) {
    if (!getView().isVisible()) {
      return;
    }
    final Path sourcePath = event.getPath();
    final Path destinationPath = event.getDestinationPath();

    boolean refresh = false;
    if (Utils.isInFolderItem(activeFolderItem, sourcePath)) {
      refresh = true;
    } else if (Utils.isInFolderItem(activeFolderItem, destinationPath)) {
      refresh = true;
    }

    if (refresh) {
      explorerService
          .call(
              new RemoteCallback<FolderListing>() {
                @Override
                public void callback(final FolderListing folderListing) {
                  getView().setItems(folderListing);
                }
              },
              new DefaultErrorCallback())
          .getFolderListing(
              activeOrganizationalUnit,
              activeRepository,
              activeProject,
              activeFolderItem,
              getActiveOptions());
    }
  }
  /**
   * Get information on a Method of a Fact Type
   *
   * @param factType
   * @param methodNameWithParams
   * @return
   */
  @Override
  public void getMethodInfo(
      final String factType,
      final String methodNameWithParams,
      final Callback<MethodInfo> callback) {
    final String fqcnFactName = getFQCNByFactName(factType);
    final List<MethodInfo> methodInformation = projectMethodInformation.get(fqcnFactName);

    // Load incremental content
    if (methodInformation == null) {
      service
          .call(
              new RemoteCallback<PackageDataModelOracleIncrementalPayload>() {

                @Override
                public void callback(final PackageDataModelOracleIncrementalPayload dataModel) {
                  AsyncPackageDataModelOracleUtilities.populateDataModelOracle(
                      AsyncPackageDataModelOracleImpl.this, dataModel);
                  final List<MethodInfo> methodInformation =
                      projectMethodInformation.get(fqcnFactName);
                  callback.callback(getMethodInfo(methodInformation, methodNameWithParams));
                }
              })
          .getUpdates(resourcePath, imports, factType);

    } else {
      callback.callback(getMethodInfo(methodInformation, methodNameWithParams));
    }
  }
示例#11
0
 private void loadContent(final NavigatorItem parent, final Path path) {
   if (path != null) {
     navigatorService
         .call(
             new RemoteCallback<NavigatorContent>() {
               @Override
               public void callback(final NavigatorContent response) {
                 for (final DataContent dataContent : response.getContent()) {
                   if (dataContent.isDirectory()) {
                     if (options.showDirectories()) {
                       parent.addDirectory(dataContent.getPath());
                     }
                   } else {
                     if (options.showFiles()) {
                       if (!options.showHiddenFiles()
                           && !hiddenTypeDef.accept(dataContent.getPath())) {
                         parent.addFile(dataContent.getPath());
                       } else if (options.showHiddenFiles()) {
                         parent.addFile(dataContent.getPath());
                       }
                     }
                   }
                 }
               }
             })
         .listContent(path);
   }
 }
  /**
   * Check whether a given FactType is an Event for CEP purposes
   *
   * @param factType
   * @return
   */
  @Override
  public void isFactTypeAnEvent(final String factType, final Callback<Boolean> callback) {
    if (factType == null || factType.isEmpty()) {
      callback.callback(false);
      return;
    }
    final Boolean isFactTypeAnEvent = filteredEventTypes.get(factType);

    // Load incremental content
    if (isFactTypeAnEvent == null) {
      service
          .call(
              new RemoteCallback<PackageDataModelOracleIncrementalPayload>() {

                @Override
                public void callback(final PackageDataModelOracleIncrementalPayload dataModel) {
                  AsyncPackageDataModelOracleUtilities.populateDataModelOracle(
                      AsyncPackageDataModelOracleImpl.this, dataModel);
                  Boolean isFactTypeAnEvent = filteredEventTypes.get(factType);
                  if (isFactTypeAnEvent == null) {
                    isFactTypeAnEvent = false;
                    filteredEventTypes.put(factType, isFactTypeAnEvent);
                  }
                  callback.callback(isFactTypeAnEvent);
                }
              })
          .getUpdates(resourcePath, imports, factType);

    } else {
      callback.callback(isFactTypeAnEvent);
    }
  }
  /**
   * Get the Fields Annotations for a given FactType
   *
   * @param factType
   * @return Empty Map if no annotations exist for the type
   */
  @Override
  public void getTypeFieldsAnnotations(
      final String factType, final Callback<Map<String, Set<Annotation>>> callback) {
    final Map<String, Set<Annotation>> typeFieldsAnnotations =
        filteredTypeFieldsAnnotations.get(factType);

    // Load incremental content
    if (typeFieldsAnnotations == null) {
      service
          .call(
              new RemoteCallback<PackageDataModelOracleIncrementalPayload>() {

                @Override
                public void callback(final PackageDataModelOracleIncrementalPayload dataModel) {
                  AsyncPackageDataModelOracleUtilities.populateDataModelOracle(
                      AsyncPackageDataModelOracleImpl.this, dataModel);
                  Map<String, Set<Annotation>> typeFieldsAnnotations =
                      filteredTypeFieldsAnnotations.get(factType);
                  if (typeFieldsAnnotations == null) {
                    typeFieldsAnnotations = Collections.EMPTY_MAP;
                    filteredTypeFieldsAnnotations.put(factType, typeFieldsAnnotations);
                  }
                  callback.callback(typeFieldsAnnotations);
                }
              })
          .getUpdates(resourcePath, imports, factType);

    } else {
      callback.callback(typeFieldsAnnotations);
    }
  }
 /** @see org.artificer.ui.client.shared.services.IOntologyService#get(java.lang.String) */
 public void get(
     final String uuid,
     boolean forceRefresh,
     final IServiceInvocationHandler<OntologyBean> handler) {
   if (!forceRefresh && ontologyCache.containsKey(uuid)) {
     Scheduler.get()
         .scheduleDeferred(
             new Command() {
               public void execute() {
                 handler.onReturn(ontologyCache.get(uuid));
               }
             });
   } else {
     RemoteCallback<OntologyBean> successCallback =
         new DelegatingRemoteCallback<OntologyBean>(handler) {
           @Override
           public void callback(OntologyBean ontology) {
             ontologyCache.put(ontology.getUuid(), ontology);
             super.callback(ontology);
           }
         };
     ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
     try {
       remoteOntologyService.call(successCallback, errorCallback).get(uuid);
     } catch (ArtificerUiException e) {
       errorCallback.error(null, e);
     }
   }
 }
  protected void save() {

    final JavaTypeInfoImpl newTypeInfo = new JavaTypeInfoImpl();
    if (isDirty()) {
      if (context.isEditorChanged()) {
        newTypeInfo.setPackageName(context.getDataObject().getPackageName());
        newTypeInfo.setName(context.getDataObject().getName());
        saveFile(newTypeInfo);
      } else {
        view.showLoading();
        modelerService
            .call(
                new RemoteCallback<TypeInfoResult>() {
                  @Override
                  public void callback(TypeInfoResult typeInfoResult) {
                    view.hideBusyIndicator();
                    if (!typeInfoResult.hasErrors() && typeInfoResult.getJavaTypeInfo() != null) {
                      newTypeInfo.setPackageName(typeInfoResult.getJavaTypeInfo().getPackageName());
                      newTypeInfo.setName(typeInfoResult.getJavaTypeInfo().getName());
                    }
                    saveFile(newTypeInfo);
                  }
                })
            .loadJavaTypeInfo(getSource());
      }
    } else {
      saveFile(null);
    }
  }
 /** @see org.artificer.ui.client.shared.services.IOntologyService#list() */
 public void list(
     boolean forceRefresh, final IServiceInvocationHandler<OntologyResultSetBean> handler) {
   if (summaryCache != null && !forceRefresh) {
     Scheduler.get()
         .scheduleDeferred(
             new Command() {
               public void execute() {
                 handler.onReturn(summaryCache);
               }
             });
   } else {
     RemoteCallback<OntologyResultSetBean> successCallback =
         new DelegatingRemoteCallback<OntologyResultSetBean>(handler) {
           @Override
           public void callback(OntologyResultSetBean response) {
             summaryCache = response;
             super.callback(response);
           }
         };
     ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
     try {
       remoteOntologyService.call(successCallback, errorCallback).list();
     } catch (ArtificerUiException e) {
       errorCallback.error(null, e);
     }
   }
 }
  protected void loadContent() {
    view.showLoading();
    ddEditorService
        .call(
            new RemoteCallback<DeploymentDescriptorModel>() {

              @Override
              public void callback(final DeploymentDescriptorModel content) {
                // Path is set to null when the Editor is closed (which can happen before async
                // calls complete).
                if (versionRecordManager.getCurrentPath() == null) {
                  return;
                }

                model = content;
                resetEditorPages(content.getOverview());
                addSourcePage();

                view.setContent(content);
                onAfterViewLoaded();
                view.hideBusyIndicator();
              }
            },
            getNoSuchFileExceptionErrorCallback())
        .load(versionRecordManager.getCurrentPath());
  }
  // Refresh when a Resource has been copied, if it exists in the active package
  public void onResourceCopied(@Observes final ResourceCopiedEvent event) {
    if (!getView().isVisible()) {
      return;
    }
    final Path resource = event.getDestinationPath();
    if (resource == null) {
      return;
    }
    if (!Utils.isInFolderItem(activeFolderItem, resource)) {
      return;
    }

    explorerService
        .call(
            new RemoteCallback<FolderListing>() {
              @Override
              public void callback(final FolderListing folderListing) {
                getView().setItems(folderListing);
              }
            },
            new DefaultErrorCallback())
        .getFolderListing(
            activeOrganizationalUnit,
            activeRepository,
            activeProject,
            activeFolderItem,
            getActiveOptions());
  }
  // Save the current state of the Workbench
  private void saveState() {

    onClose();

    final PerspectiveDefinition perspective = panelManager.getPerspective();

    if (perspective == null) {
      // On startup the Workbench has not been set to contain a perspective
      loadState();

    } else if (perspective.isTransient()) {
      // Transient Perspectives are not saved
      placeManager.closeAllPlaces();
      loadState();

    } else {
      // Save first, then close all places before loading persisted state
      wbServices
          .call(
              new RemoteCallback<Void>() {
                @Override
                public void callback(Void response) {
                  placeManager.closeAllPlaces();
                  loadState();
                }
              })
          .save(perspective);
    }
  }
  // Load the persisted state of the Workbench or use the default Perspective definition if no saved
  // state found
  private void loadState() {

    // Call OnStartup before getting the Perspective definition in case any setup is required by
    // @WorkbenchPerspective's
    onStartup(place);

    final PerspectiveDefinition perspective = getPerspective();

    if (perspective.isTransient()) {
      // Transient Perspectives are not saved and hence cannot be loaded
      initialisePerspective(perspective);

    } else {

      wbServices
          .call(
              new RemoteCallback<PerspectiveDefinition>() {
                @Override
                public void callback(PerspectiveDefinition response) {
                  if (response == null) {
                    initialisePerspective(perspective);
                  } else {
                    initialisePerspective(response);
                  }
                }
              })
          .load(perspective.getName());
    }
  }
示例#21
0
 @Override
 protected void save(String commitMessage) {
   dslTextEditorService
       .call(
           getSaveSuccessCallback(view.getContent().hashCode()),
           new HasBusyIndicatorDefaultErrorCallback(view))
       .save(versionRecordManager.getCurrentPath(), view.getContent(), metadata, commitMessage);
 }
 /** @see org.artificer.ui.client.shared.services.IOntologyService#add(OntologyBean) */
 public void add(OntologyBean ontology, final IServiceInvocationHandler<Void> handler) {
   RemoteCallback<Void> successCallback = new DelegatingRemoteCallback<Void>(handler);
   ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
   try {
     remoteOntologyService.call(successCallback, errorCallback).add(ontology);
   } catch (ArtificerUiException e) {
     errorCallback.error(null, e);
   }
 }
 @OnStartup
 public void onStartup(final ObservablePath path, final PlaceRequest place) {
   ddEditorService.call().createIfNotExists(path);
   init(path, place, type);
   fillPersistenceModes();
   fillAuditModes();
   fillRuntimeStrategies(translationService);
   view.setup();
 }
 public void onFormSubmitted(@Observes FormSubmittedEvent event) {
   if (renderingSettings == null) {
     return;
   }
   if (event.isMine(renderingSettings.getContextId()) && event.getContext().getErrors() == 0) {
     if (ACTION_SAVE_TASK.equals(action)) {
       renderContextServices
           .call(getSaveTaskStateCallback(), getUnexpectedErrorCallback())
           .saveTaskStateFromRenderContext(
               renderingSettings.getContextId(), serverTemplateId, deploymentId, taskId);
     } else if (ACTION_COMPLETE_TASK.equals(action)) {
       renderContextServices
           .call(getCompleteTaskRemoteCallback(), getUnexpectedErrorCallback())
           .completeTaskFromContext(
               renderingSettings.getContextId(), serverTemplateId, deploymentId, taskId);
     }
   }
 }
  private void onSafeRename() {

    if (context.getEditorModelContent().getOriginalClassName() != null) {
      // if we are about to rename a .java file that could be parsed without errors, and we can
      // calculate the
      // className we can check for class usages prior to renaming and we can also suggest to
      // perform an automatic
      // class renaming.

      final String className = context.getEditorModelContent().getOriginalClassName();

      modelerService
          .call(
              new RemoteCallback<List<Path>>() {

                @Override
                public void callback(List<Path> paths) {

                  if (paths != null && paths.size() > 0) {
                    // If usages for this class were detected in project assets
                    // show the confirmation message to the user.

                    ShowUsagesPopup showUsagesPopup =
                        ShowUsagesPopup.newUsagesPopupForRenaming(
                            Constants.INSTANCE.modelEditor_confirm_renaming_of_used_class(
                                className),
                            paths,
                            new Command() {
                              @Override
                              public void execute() {
                                rename();
                              }
                            },
                            new Command() {
                              @Override
                              public void execute() {
                                // do nothing.
                              }
                            });

                    showUsagesPopup.setClosable(false);
                    showUsagesPopup.show();

                  } else {
                    // no usages, just proceed with the deletion.
                    rename();
                  }
                }
              })
          .findClassUsages(versionRecordManager.getPathToLatest(), className);
    } else {
      // we couldn't parse the class, so no check can be done. Just proceed with the standard
      // file renaming procedure.
      rename();
    }
  }
 private void initMain() {
   socialUserRepositoryAPI
       .call(
           new RemoteCallback<SocialUser>() {
             public void callback(SocialUser socialUser) {
               updateMainTimeline("", socialUser);
             }
           })
       .findSocialUser(loggedUser.getIdentifier());
 }
 /** @see org.artificer.ui.client.shared.services.IOntologyService#delete(OntologyBean) */
 public void delete(String uuid, final IServiceInvocationHandler<Void> handler) {
   ontologyCache.remove(uuid);
   RemoteCallback<Void> successCallback = new DelegatingRemoteCallback<Void>(handler);
   ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
   try {
     remoteOntologyService.call(successCallback, errorCallback).delete(uuid);
   } catch (ArtificerUiException e) {
     errorCallback.error(null, e);
   }
 }
 /** @see org.artificer.ui.client.shared.services.IOntologyService#update(OntologyBean) */
 public void update(OntologyBean ontology, final IServiceInvocationHandler<Void> handler) {
   ontologyCache.remove(ontology.getUuid());
   RemoteCallback<Void> successCallback = new DelegatingRemoteCallback<Void>(handler);
   ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
   try {
     remoteOntologyService.call(successCallback, errorCallback).update(ontology);
   } catch (ArtificerUiException e) {
     errorCallback.error(null, e);
   }
 }
  private void checkUsageAndDeleteDataObjectProperty(
      final ObjectProperty objectProperty, final int index) {

    final String className = dataObject.getClassName();
    final String fieldName = objectProperty.getName();

    if (getContext() != null) {

      final Path currentPath =
          getContext().getEditorModelContent() != null
              ? getContext().getEditorModelContent().getPath()
              : null;

      modelerService
          .call(
              new RemoteCallback<List<Path>>() {

                @Override
                public void callback(List<Path> paths) {

                  if (paths != null && paths.size() > 0) {
                    // If usages for this field were detected in project assets
                    // show the confirmation message to the user.

                    ShowUsagesPopup showUsagesPopup =
                        ShowUsagesPopup.newUsagesPopupForDeletion(
                            Constants.INSTANCE.modelEditor_confirm_deletion_of_used_field(
                                objectProperty.getName()),
                            paths,
                            new Command() {
                              @Override
                              public void execute() {
                                deleteDataObjectProperty(objectProperty, index);
                              }
                            },
                            new Command() {
                              @Override
                              public void execute() {
                                // do nothing.
                              }
                            });

                    showUsagesPopup.setClosable(false);
                    showUsagesPopup.show();

                  } else {
                    // no usages, just proceed with the deletion.
                    deleteDataObjectProperty(objectProperty, index);
                  }
                }
              })
          .findFieldUsages(currentPath, className, fieldName);
    }
  }
 public void suspendProcessInstance(String processDefId, long processInstanceId) {
   kieSessionServices
       .call(
           new RemoteCallback<Void>() {
             @Override
             public void callback(Void v) {
               refreshActiveProcessList();
             }
           })
       .suspendProcessInstance(processInstanceId);
 }