コード例 #1
0
 private void determineIntegrationContext() {
   if (configurationMap.get(ToolIntegrationConstants.INTEGRATION_TYPE) != null) {
     for (ToolIntegrationContext context :
         integrationContextRegistry.getAllIntegrationContexts()) {
       if (context
           .getContextType()
           .equals(configurationMap.get(ToolIntegrationConstants.INTEGRATION_TYPE))) {
         integrationContext = context;
       }
     }
   } else {
     integrationContext =
         integrationContextRegistry.getToolIntegrationContext(
             ToolIntegrationConstants.COMMON_TOOL_INTEGRATION_CONTEXT_UID);
   }
 }
コード例 #2
0
  /** Removes old integrated component for updating the new one. */
  public void removeOldIntegration() {
    integrationService.setFileWatcherActive(false);
    String previousToolName = "";
    String toolName = (String) configurationMap.get(ToolIntegrationConstants.KEY_TOOL_NAME);
    File previousToolDir = null;
    if (previousConfiguration != null) {
      previousToolName = (String) previousConfiguration.get(ToolIntegrationConstants.KEY_TOOL_NAME);
      previousToolDir =
          new File(
              new File(
                  integrationContext.getRootPathToToolIntegrationDirectory(),
                  integrationContext.getNameOfToolIntegrationDirectory()),
              previousToolName);
    } else {
      previousToolName = toolName;
    }
    if (previousToolDir != null) {
      storeIconAndDocuInTempDir(previousToolDir);
    }
    integrationService.unregisterIntegration(previousToolName, integrationContext);
    integrationService.removeTool(previousToolName, integrationContext);
    if (!previousToolName.equals(toolName)) {

      File delete = previousToolDir;
      try {
        FileUtils.forceDelete(delete);
      } catch (IOException e) {
        LogFactory.getLog(ToolIntegrationWizard.class).error(e);
      }
    } else {
      if (configurationMap.get(ToolIntegrationConstants.KEY_DOC_FILE_PATH) == null
          || ((String) configurationMap.get(ToolIntegrationConstants.KEY_DOC_FILE_PATH))
              .isEmpty()) {
        File docDir = new File(previousToolDir, ToolIntegrationConstants.DOCS_DIR_NAME);
        if (docDir.listFiles() != null) {
          for (File f : docDir.listFiles()) {
            try {
              FileUtils.forceDelete(f);
            } catch (IOException e) {
              LOGGER.error("Could not delete file in tool docs directory: ", e);
            }
          }
        }
      }
    }
    integrationService.setFileWatcherActive(true);
  }
コード例 #3
0
 /**
  * Saves the wizards configuration to the given path.
  *
  * @param folderPath where to store the configuration.
  */
 public void performSaveAs(String folderPath) {
   determineIntegrationContext();
   File toolConfigFile =
       new File(
           folderPath,
           integrationContext.getNameOfToolIntegrationDirectory()
               + File.separator
               + integrationContext.getToolDirectoryPrefix()
               + configurationMap.get(ToolIntegrationConstants.KEY_TOOL_NAME));
   try {
     integrationService.writeToolIntegrationFileToSpecifiedFolder(
         folderPath, configurationMap, integrationContext);
     MessageBox infoDialog = new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
     if (toolConfigFile.exists()) {
       infoDialog.setText("Tool saved");
       infoDialog.setMessage(
           StringUtils.format(
               "Successfully saved tool: %s\nLocation: " + toolConfigFile.getAbsolutePath(),
               configurationMap.get(ToolIntegrationConstants.KEY_TOOL_NAME)));
     } else {
       infoDialog.setText("Saving failed");
       infoDialog.setMessage(
           StringUtils.format(
               "Could not save tool: %s\nLocation tried: " + toolConfigFile.getAbsolutePath(),
               configurationMap.get(ToolIntegrationConstants.KEY_TOOL_NAME)));
     }
     infoDialog.open();
   } catch (IOException e) {
     MessageBox errorDialog = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
     errorDialog.setText("Saving failed");
     errorDialog.setMessage(
         StringUtils.format(
             "Failed to save tool configuration to: "
                 + toolConfigFile.getAbsolutePath()
                 + "\nCause: "
                 + e.getMessage(),
             configurationMap.get(ToolIntegrationConstants.KEY_TOOL_NAME)));
     errorDialog.open();
   }
 }
コード例 #4
0
  /**
   * Setter for the configuration map to edit.
   *
   * @param newPreviousConfiguration loaded map
   * @param configJson where the config came from
   */
  public void setPreviousConfiguration(
      Map<String, Object> newPreviousConfiguration, File configJson) {
    Map<String, Object> configurationMapCopy = new HashMap<>();
    previousConfiguration = new HashMap<>(newPreviousConfiguration);
    if (newPreviousConfiguration != null) {
      configurationMapCopy.putAll(newPreviousConfiguration);
    }
    setConfigurationMap(configurationMapCopy);
    if (configJson != null) {
      if (newPreviousConfiguration != null
          && newPreviousConfiguration.get(ToolIntegrationConstants.INTEGRATION_TYPE) != null) {
        for (ToolIntegrationContext context :
            integrationContextRegistry.getAllIntegrationContexts()) {
          if (newPreviousConfiguration
              .get(ToolIntegrationConstants.INTEGRATION_TYPE)
              .equals(context.getContextType())) {
            integrationContext = context;
          }
        }
      } else {
        integrationContext =
            integrationContextRegistry.getToolIntegrationContext(
                ToolIntegrationConstants.COMMON_TOOL_INTEGRATION_CONTEXT_UID);
      }
    }

    updateAllPages();
    for (Entry<String, List<ToolIntegrationWizardPage>> addPages : additionalPages.entrySet()) {
      if (newPreviousConfiguration != null
          && !addPages
              .getKey()
              .equals(newPreviousConfiguration.get(ToolIntegrationConstants.INTEGRATION_TYPE))) {
        for (ToolIntegrationWizardPage page : addPages.getValue()) {
          page.setPageComplete(true);
        }
      }
    }
  }