예제 #1
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);
  }
예제 #2
0
  @Override
  public void addPages() {
    List<String> toolNames = new LinkedList<>();

    for (String id : integrationService.getIntegratedComponentIds()) {
      toolNames.add(id.substring(id.lastIndexOf(".") + 1));
    }

    List<String> groupNames = new ArrayList<>();
    LogicalNodeId localNode =
        serviceRegistryAccess.getService(PlatformService.class).getLocalDefaultLogicalNodeId();
    Collection<ComponentInstallation> installations =
        getInitialComponentKnowledge().getAllInstallations();
    installations = ComponentUtils.eliminateComponentInterfaceDuplicates(installations, localNode);
    for (ComponentInstallation ci : installations) {
      ComponentInterface componentInterface = ci.getComponentRevision().getComponentInterface();
      String groupName = componentInterface.getGroupName();
      if (!groupName.startsWith("_") && !groupNames.contains(groupName)) {
        groupNames.add(groupName);
      }
    }

    Collections.sort(groupNames, String.CASE_INSENSITIVE_ORDER);

    editConfigurationPage =
        new ChooseConfigurationPage(
            Messages.chooseConfigPageTitle,
            integrationContextRegistry.getAllIntegrationContexts(),
            this,
            wizardType);

    characteristicsPage =
        new ToolCharacteristicsPage(
            Messages.firstToolIntegrationPageTitle, configurationMap, toolNames, groupNames);

    inOutputPage = new InOutputConfigurationPage(Messages.inOuputPage, configurationMap);
    propertyPage = new PropertyConfigurationPage(Messages.propertyPage, configurationMap);
    toolPage = new ToolConfigurationPage(Messages.toolPage, configurationMap);
    scriptPage = new ScriptConfigurationPage(Messages.scriptPage, configurationMap);

    addPage(editConfigurationPage);
    addPage(characteristicsPage);
    addPage(inOutputPage);
    addPage(propertyPage);
    addPage(toolPage);
    addPage(scriptPage);

    this.getShell().setMinimumSize(MINIMUM_WIDTH, MINIMUM_HEIGHT);

    IntegrationWizardPageContributorRegistry contributorRegistry =
        serviceRegistryAccess.getService(IntegrationWizardPageContributorRegistry.class);
    for (IntegrationWizardPageContributor contributor : contributorRegistry.getAllContributors()) {
      List<ToolIntegrationWizardPage> pages = contributor.getAdditionalPagesList(configurationMap);
      additionalPages.put(contributor.getType(), pages);
      for (ToolIntegrationWizardPage page : pages) {
        addPage(page);
      }
    }
  }
예제 #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();
   }
 }