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;
}
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();
}
});
}
}
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;
}
Aggregations