@Override
 protected DefinitionResourceProvider getDefinitionResourceProvider() {
   final IRepositoryStore<?> defStore =
       RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class);
   return DefinitionResourceProvider.getInstance(
       defStore, ConnectorPlugin.getDefault().getBundle());
 }
  @Test
  public void testAddCategory() throws Exception {
    final String id = "testEdit4";
    final String version = "1.0.0";

    SWTBotConnectorTestUtil.activateConnectorDefinitionShell(bot);
    SWTBotConnectorTestUtil.createConnectorDefinition(bot, id, version);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    bot.tree().setFocus();
    bot.waitUntil(
        Conditions.widgetIsEnabled(
            bot.tree().expandNode("Uncategorized").select(id + " (" + version + ")")),
        10000);
    bot.tree()
        .select("Uncategorized")
        .expandNode("Uncategorized")
        .select(id + " (" + version + ")");
    bot.button(Messages.Edit).click();
    bot.treeWithLabel(Messages.categoryLabel).select(0);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    ConnectorDefRepositoryStore store =
        (ConnectorDefRepositoryStore)
            RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class);
    ConnectorDefinition connectorDef = store.getDefinition(id, version);
    assertEquals("category size should be equal to 1", 1, connectorDef.getCategory().size());
    DefinitionResourceProvider messageProvider =
        DefinitionResourceProvider.getInstance(store, ConnectorPlugin.getDefault().getBundle());
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    final Category category = connectorDef.getCategory().get(0);
    String categoryLabel = messageProvider.getCategoryLabel(category);
    if (categoryLabel == null) {
      categoryLabel = category.getId();
    }
    final String connectorLabel =
        new ConnectorDefinitionTreeLabelProvider(messageProvider).getText(connectorDef);
    assertNotNull(
        "could not find " + connectorLabel,
        bot.tree().getTreeItem(categoryLabel).expand().getNode(connectorLabel));
    bot.button(IDialogConstants.CANCEL_LABEL).click();
  }
 protected void addDefinitionPropertiesFile(
     List<IResource> resourcesToExport, final IRepositoryStore store, ConnectorDefinition def) {
   final DefinitionResourceProvider messageProvider =
       DefinitionResourceProvider.getInstance(store, getBundle());
   List<File> propertiesFile = messageProvider.getExistingLocalesResource(def);
   for (File propertyFile : propertiesFile) {
     String newFilename = propertyFile.getName();
     try {
       IFile f = store.getResource().getFile(newFilename);
       if (!f.exists()) {
         FileInputStream fis = new FileInputStream(propertyFile);
         f.create(fis, true, Repository.NULL_PROGRESS_MONITOR);
         fis.close();
         cleanAfterExport.add(f);
       }
       if (!resourcesToExport.contains(f)) {
         resourcesToExport.add(f);
       }
     } catch (Exception e) {
       BonitaStudioLog.error(e);
     }
   }
 }
 public String getDefinitionText(DefinitionMapping association) {
   ConnectorDefinition definition =
       defStore.getDefinition(association.getDefinitionId(), association.getDefinitionVersion());
   if (definition != null) {
     String connectorDefinitionLabel = resourceProvider.getConnectorDefinitionLabel(definition);
     if (connectorDefinitionLabel == null) {
       connectorDefinitionLabel = definition.getId();
     }
     return connectorDefinitionLabel + " (" + definition.getVersion() + ")";
   } else {
     return "defintion not found for "
         + association.getDefinitionId()
         + " with version"
         + association.getDefinitionVersion();
   }
 }
 public Image getDefinitionImage(DefinitionMapping association) {
   ConnectorDefinition definition =
       defStore.getDefinition(association.getDefinitionId(), association.getDefinitionVersion());
   return resourceProvider.getDefinitionIcon(definition);
 }
  protected IStatus addDependencies(ConnectorImplementation impl, IFolder classpathFolder)
      throws CoreException {
    final IDefinitionRepositoryStore store = (IDefinitionRepositoryStore) getDefinitionStore();
    final DependencyRepositoryStore depStore =
        (DependencyRepositoryStore)
            RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class);
    final DefinitionResourceProvider resourceProvider =
        DefinitionResourceProvider.getInstance(getDefinitionStore(), getBundle());

    ConnectorDefinition def =
        store.getDefinition(impl.getDefinitionId(), impl.getDefinitionVersion());
    for (String jarName : def.getJarDependency()) {
      if (ignoredLibs.contains(jarName)) {
        continue;
      }
      IRepositoryFileStore file = depStore.getChild(jarName);
      if (file != null) {
        if (file.getResource().exists()) {
          if (!classpathFolder.getFile(file.getName()).exists()) {
            try {
              file.getResource()
                  .copy(
                      classpathFolder.getFullPath().append(file.getName()),
                      true,
                      Repository.NULL_PROGRESS_MONITOR);
            } catch (CoreException e) {
              BonitaStudioLog.error(e);
            }
          }
        }
      } else { // Search in provided jars
        InputStream is = resourceProvider.getDependencyInputStream(jarName);
        if (is != null) {
          IFile jarFile = classpathFolder.getFile(jarName);
          if (!jarFile.exists()) {
            jarFile.create(is, true, Repository.NULL_PROGRESS_MONITOR);
          }
        } else {
          return ValidationStatus.error(Messages.bind(Messages.implementationDepNotFound, jarName));
        }
      }
    }
    for (String jarName : impl.getJarDependencies().getJarDependency()) {
      if (ignoredLibs.contains(jarName)) {
        continue;
      }
      IRepositoryFileStore file = depStore.getChild(jarName);
      if (file != null) {
        if (file.getResource().exists()) {
          if (!classpathFolder.getFile(file.getName()).exists()) {
            try {
              file.getResource()
                  .copy(
                      classpathFolder.getFullPath().append(file.getName()),
                      true,
                      Repository.NULL_PROGRESS_MONITOR);
            } catch (CoreException e) {
              BonitaStudioLog.error(e);
            }
          }
        }
      } else { // Search in provided jars
        InputStream is = resourceProvider.getDependencyInputStream(jarName);
        if (is != null) {
          IFile jarFile = classpathFolder.getFile(jarName);
          if (!jarFile.exists()) {
            jarFile.create(is, true, Repository.NULL_PROGRESS_MONITOR);
          }
        } else {
          return ValidationStatus.error(Messages.bind(Messages.implementationDepNotFound, jarName));
        }
      }
    }
    return Status.OK_STATUS;
  }