/** * 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; }
/** 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(); }
/** Deletes the current selected {@link DatabaseConnectionProperties} from the viewer. */ public void removeCurrentSelectedDatabaseDefinition() { if (currentSelectedConnectionPropertiesList.size() > 0) { for (DatabaseConnectionProperties conn : currentSelectedConnectionPropertiesList) { if (conn.isActive()) { Display.getDefault() .asyncExec( new Runnable() { public void run() { MessageDialog.openWarning( connectionsViewer.getTable().getShell(), Messages.DatabaseConnectionPropertiesWidget__warning, Messages.DatabaseView__db_not_removed_warning); } }); continue; } availableDatabaseConnectionProperties.remove(conn); widgetMap.remove(conn); } } relayout(); putUnselected(); }