Esempio n. 1
0
  /**
   * Creates a new default local {@link DatabaseConnectionProperties} and adds it to the list.
   *
   * @param databaseFolder the folder into which to create the database or <code>null</code>.
   * @param databaseName the name for the new database or <code>null</code>.
   * @return the properties for the new created database definition.
   */
  public DatabaseConnectionProperties createNewLocalDatabaseDefinition(
      String databaseFolder, String databaseName) {
    DatabaseConnectionProperties defaultProperties =
        new H2ConnectionFactory().createDefaultProperties();

    String projectName = databaseName;
    if (projectName == null) {
      IProject activeProject = ApplicationGIS.getActiveProject();
      if (activeProject != null) {
        projectName = activeProject.getName();
      }
    }
    if (projectName == null) {
      projectName = Messages.H2ConnectionFactory__default_db;
    }
    if (projectName != null && projectName.length() != 0) {
      defaultProperties.put(DatabaseConnectionProperties.TITLE, projectName);
      defaultProperties.put(DatabaseConnectionProperties.DESCRIPTION, projectName);
    }
    if (databaseFolder != null) {
      defaultProperties.put(DatabaseConnectionProperties.PATH, databaseFolder);
    }
    DatabasePlugin.getDefault().checkSameNameDbconnection(defaultProperties);

    availableDatabaseConnectionProperties.add(defaultProperties);
    relayout();

    setDatabaseSelected(defaultProperties);
    return defaultProperties;
  }
Esempio n. 2
0
 public boolean select(Viewer arg0, Object arg1, Object arg2) {
   String name = ((DatabaseConnectionProperties) arg2).getTitle();
   String projectName = ApplicationGIS.getActiveProject().getName();
   if (name.matches("(?i).*" + projectName + ".*")) { // $NON-NLS-1$ //$NON-NLS-2$
     return true;
   }
   return false;
 }
Esempio n. 3
0
  /** Creates a new default remote {@link DatabaseConnectionProperties} and adds it to the list. */
  public void createNewRemoteDatabaseDefinition() {
    DatabaseConnectionProperties defaultProperties =
        new PostgresConnectionFactory().createDefaultProperties();
    String projectName = ApplicationGIS.getActiveProject().getName();
    if (projectName != null && projectName.length() != 0) {
      defaultProperties.put(DatabaseConnectionProperties.TITLE, projectName);
      defaultProperties.put(DatabaseConnectionProperties.DESCRIPTION, projectName);
    }

    DatabasePlugin.getDefault().checkSameNameDbconnection(defaultProperties);

    availableDatabaseConnectionProperties.add(defaultProperties);
    relayout();
  }