private static void createConnection(final String id, final Properties properties) {
    // Add then remove profile changed listener so new CP name can be set in properties
    IProfileListener listener = new PropertiesProfileChangedListener(properties);
    ProfileManager.getInstance().addProfileListener(listener);

    if (id.equalsIgnoreCase(CONNECTION_PROFILE_IDS.CATEGORY_JDBC)) {
      NewJDBCFilteredCPWizard wiz = new NewJDBCFilteredCPWizard();
      ModelerUiViewUtils.launchWizard(wiz, new StructuredSelection(), properties, true);
    } else {
      INewWizard wiz = new NewTeiidFilteredCPWizard(id);
      ModelerUiViewUtils.launchWizard(wiz, new StructuredSelection(), properties, true);
    }

    ProfileManager.getInstance().removeProfileListener(listener);
  }
 private static List<String> getConnectionProfileNameList() {
   IConnectionProfile[] profiles =
       ProfileManager.getInstance()
           .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); // $NON-NLS-1$
   List<String> names = new ArrayList<String>();
   for (IConnectionProfile connectionProfile : profiles) {
     names.add(connectionProfile.getName());
   }
   return names;
 }
    public Map<String, IStatus> validate(Object value, Object context) {
      if (!allowEmptyConnection
          && (value == null || "".equals(value.toString().trim()))) { // $NON-NLS-1$
        return createErrormessage(
            ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
            new Status(
                IStatus.ERROR,
                SeamCorePlugin.PLUGIN_ID,
                SeamCoreMessages.VALIDATOR_FACTORY_CONNECTION_PROFILE_IS_NOT_SELECTED));
      } else {
        IConnectionProfile connProfile =
            ProfileManager.getInstance().getProfileByName(value.toString());
        Properties props = connProfile.getBaseProperties();
        Object driverClass =
            props.get("org.eclipse.datatools.connectivity.db.driverClass"); // $NON-NLS-1$

        if (driverClass == null || "".equals(driverClass)) { // $NON-NLS-1$
          return createErrormessage(
              ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
              new Status(
                  IStatus.ERROR,
                  SeamCorePlugin.PLUGIN_ID,
                  NLS.bind(
                      SeamCoreMessages
                          .VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_EMPTY_FOR_SELECTED_CONNECTION_PROFILE,
                      value)));
        }
        if (props.get("org.eclipse.datatools.connectivity.driverDefinitionID") != null) {
          DriverInstance i =
              DriverManager.getInstance()
                  .getDriverInstanceByID(
                      props
                          .get("org.eclipse.datatools.connectivity.driverDefinitionID")
                          .toString()); //$NON-NLS-1$
          if (i == null) {
            return createErrormessage(
                ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
                new Status(
                    IStatus.WARNING,
                    SeamCorePlugin.PLUGIN_ID,
                    NLS.bind(
                        SeamCoreMessages
                            .VALIDATOR_FACTORY_DRIVER_CLASS_PROPERTY_IS_NOT_FOUND_FOR_SELECTED_CONNECTION_PROFILE,
                        value)));
          }
        }
      }
      return NO_ERRORS;
    }
 private String[] getConnectionNames() {
   IConnectionProfile[] profiles =
       ProfileManager.getInstance()
           .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); // $NON-NLS-1$
   String[] names = new String[profiles.length];
   for (int i = 0; i < profiles.length; i++) {
     names[i] = profiles[i].getName();
   }
   Arrays.sort(names);
   String[] resNames = new String[names.length + 2];
   resNames[0] = HibernateConsoleMessages.ConnectionProfileCtrl_JPAConfiguredConnection;
   resNames[1] = HibernateConsoleMessages.ConnectionProfileCtrl_HibernateConfiguredConnection;
   System.arraycopy(names, 0, resNames, 2, names.length);
   return resNames;
 }
  private void createDriver2(String jbossASLocation, IServerType serverType)
      throws ConnectionProfileException {
    if (ProfileManager.getInstance().getProfileByName(DEFAULT_DS) != null) {
      // Don't create the driver a few times
      return;
    }
    String driverPath;
    try {
      driverPath = getDriverPath(jbossASLocation, serverType);
    } catch (IOException e) {
      ServerRuntimesIntegrationActivator.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR,
                  ServerRuntimesIntegrationActivator.PLUGIN_ID,
                  Messages.JBossRuntimeStartup_Cannott_create_new_HSQL_DB_Driver,
                  e));
      return;
    }
    if (driverPath == null) {
      ServerRuntimesIntegrationActivator.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR,
                  ServerRuntimesIntegrationActivator.PLUGIN_ID,
                  Messages.JBossRuntimeStartup_Cannot_create_new_DB_Driver));
    }

    DriverInstance driver = getDriver(serverType);
    if (driver == null) {
      TemplateDescriptor descr = getDriverTemplateDescriptor(serverType);
      IPropertySet instance =
          new PropertySetImpl(getDriverName(serverType), getDriverDefinitionId(serverType));
      instance.setName(getDriverName(serverType));
      instance.setID(getDriverDefinitionId(serverType));
      Properties props = new Properties();

      IConfigurationElement[] template = descr.getProperties();
      for (int i = 0; i < template.length; i++) {
        IConfigurationElement prop = template[i];
        String id = prop.getAttribute("id"); // $NON-NLS-1$

        String value = prop.getAttribute("value"); // $NON-NLS-1$
        props.setProperty(id, value == null ? "" : value); // $NON-NLS-1$
      }
      props.setProperty(DTP_DB_URL_PROPERTY_ID, getDriverUrl(serverType));
      props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
      props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
      if (usesH2(serverType)) {
        props.setProperty(
            IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, "org.h2.Driver"); // $NON-NLS-1$
        props.setProperty(
            IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, "H2 driver"); // $NON-NLS-1$
        props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, "jdbc:h2:mem"); // $NON-NLS-1$
        props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, "sa"); // $NON-NLS-1$
      }

      instance.setBaseProperties(props);
      DriverManager.getInstance().removeDriverInstance(instance.getID());
      System.gc();
      DriverManager.getInstance().addDriverInstance(instance);
    }

    driver = DriverManager.getInstance().getDriverInstanceByName(getDriverName(serverType));
    if (driver != null && ProfileManager.getInstance().getProfileByName(DEFAULT_DS) == null) {
      // create profile
      Properties props = new Properties();
      props.setProperty(
          ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, getDriverDefinitionId(serverType));
      props.setProperty(
          IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID, ""); // $NON-NLS-1$
      props.setProperty(
          IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
          driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
      props.setProperty(
          IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID,
          driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
      props.setProperty(
          IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
          driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
      props.setProperty(
          IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, "Default"); // $NON-NLS-1$
      props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, ""); // $NON-NLS-1$
      props.setProperty(
          IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false"); // $NON-NLS-1$
      props.setProperty(
          IDBDriverDefinitionConstants.USERNAME_PROP_ID,
          driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
      props.setProperty(
          IDBDriverDefinitionConstants.URL_PROP_ID,
          driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));

      if (usesH2(serverType)) {
        ProfileManager.getInstance()
            .createProfile(
                DEFAULT_DS,
                Messages.JBossRuntimeStartup_The_JBoss_AS_H2_embedded_database,
                H2_PROFILE_ID,
                props,
                "",
                false); //$NON-NLS-1$
      } else {
        ProfileManager.getInstance()
            .createProfile(
                DEFAULT_DS,
                Messages.JBossRuntimeStartup_The_JBoss_AS_Hypersonic_embedded_database,
                HSQL_PROFILE_ID,
                props,
                "",
                false); //$NON-NLS-1$
      }
    }
  }
 @Override
 public void start() {
   setProfileManager(ProfileManager.getInstance());
 }