예제 #1
0
 public DatabaseView() {
   try {
     DatabasePlugin.getDefault().getActiveDatabaseConnection();
     availableDatabaseConnectionProperties =
         DatabasePlugin.getDefault().getAvailableDatabaseConnectionProperties();
   } catch (Exception e) {
     // exception handled at connection time
     e.printStackTrace();
   }
 }
예제 #2
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;
  }
예제 #3
0
  /** Creates a {@link DatabaseConnectionProperties} definition for an existing local database. */
  public void createExistingLocalDatabaseDefinition(DatabaseConnectionProperties props) {
    DatabasePlugin.getDefault().checkSameNameDbconnection(props);

    availableDatabaseConnectionProperties.add(props);
    relayout();

    setDatabaseSelected(props);
  }
예제 #4
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();
  }