Search in sources :

Example 1 with NewConnectionWizard

use of org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard in project dbeaver by serge-rider.

the class DataSourceDescriptorManager method createNewObject.

@Override
public DataSourceDescriptor createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, DBPObject parent, Object copyFrom) {
    if (copyFrom != null) {
        DataSourceDescriptor dsTpl = (DataSourceDescriptor) copyFrom;
        DBPDataSourceRegistry registry;
        DBPDataSourceFolder folder = null;
        if (parent instanceof DataSourceRegistry) {
            registry = (DBPDataSourceRegistry) parent;
        } else if (parent instanceof DBPDataSourceFolder) {
            folder = (DBPDataSourceFolder) parent;
            registry = folder.getDataSourceRegistry();
        } else {
            registry = dsTpl.getRegistry();
        }
        DataSourceDescriptor dataSource = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(dsTpl.getDriver()), dsTpl.getDriver(), new DBPConnectionConfiguration(dsTpl.getConnectionConfiguration()));
        dataSource.copyFrom(dsTpl);
        if (folder != null) {
            dataSource.setFolder(folder);
        }
        // Generate new name
        String origName = dsTpl.getName();
        String newName = origName;
        for (int i = 0; ; i++) {
            if (registry.findDataSourceByName(newName) == null) {
                break;
            }
            newName = origName + " " + (i + 1);
        }
        dataSource.setName(newName);
        registry.addDataSource(dataSource);
    } else {
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                CreateConnectionDialog dialog = new CreateConnectionDialog(DBeaverUI.getActiveWorkbenchWindow(), new NewConnectionWizard());
                dialog.open();
            }
        });
    }
    return null;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSourceFolder(org.jkiss.dbeaver.model.DBPDataSourceFolder) NewConnectionWizard(org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) CreateConnectionDialog(org.jkiss.dbeaver.ui.dialogs.connection.CreateConnectionDialog)

Example 2 with NewConnectionWizard

use of org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard in project dbeaver by serge-rider.

the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.

@Override
public void postWindowOpen() {
    log.debug("Finish initialization");
    super.postWindowOpen();
    if (DataSourceRegistry.getAllDataSources().isEmpty()) {
        // Open New Connection wizard
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                IWorkbenchWindow window = getWindowConfigurer().getWindow();
                CreateConnectionDialog dialog = new CreateConnectionDialog(window, new NewConnectionWizard());
                dialog.open();
            }
        });
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NewConnectionWizard(org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard) CreateConnectionDialog(org.jkiss.dbeaver.ui.dialogs.connection.CreateConnectionDialog)

Example 3 with NewConnectionWizard

use of org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard in project dbeaver by serge-rider.

the class NavigatorHandlerConnectionCreate method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    CreateConnectionDialog dialog = new CreateConnectionDialog(window, new NewConnectionWizard());
    dialog.open();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NewConnectionWizard(org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard) CreateConnectionDialog(org.jkiss.dbeaver.ui.dialogs.connection.CreateConnectionDialog)

Aggregations

CreateConnectionDialog (org.jkiss.dbeaver.ui.dialogs.connection.CreateConnectionDialog)3 NewConnectionWizard (org.jkiss.dbeaver.ui.dialogs.connection.NewConnectionWizard)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 DBPDataSourceFolder (org.jkiss.dbeaver.model.DBPDataSourceFolder)1 DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)1 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)1