use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager in project dbeaver by dbeaver.
the class ClientHomesSelector method populateHomes.
public void populateHomes(DBPDriver driver, String currentHome, boolean selectDefault) {
this.driver = driver;
this.currentHomeId = currentHome;
this.homesCombo.removeAll();
this.homeIds.clear();
Map<String, DBPNativeClientLocation> homes = new LinkedHashMap<>();
AbstractJob hlJob = new AbstractJob("Find native client homes") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
for (DBPNativeClientLocation ncl : driver.getNativeClientLocations()) {
homes.put(ncl.getName(), ncl);
}
DBPNativeClientLocationManager clientManager = driver.getNativeClientManager();
if (clientManager != null) {
for (DBPNativeClientLocation location : clientManager.findLocalClientLocations()) {
homes.putIfAbsent(location.getName(), location);
}
}
return Status.OK_STATUS;
}
};
hlJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
UIUtils.syncExec(() -> {
for (DBPNativeClientLocation location : homes.values()) {
homesCombo.add(location.getDisplayName());
homeIds.add(location.getName());
if (currentHomeId != null && location.getName().equals(currentHomeId)) {
homesCombo.select(homesCombo.getItemCount() - 1);
}
}
if (homesCombo.getItemCount() == 0) {
homesCombo.add(UIConnectionMessages.controls_client_home_selector_missing);
homeIds.add(null);
}
if (selectDefault && homesCombo.getSelectionIndex() == -1) {
homesCombo.select(0);
currentHomeId = homeIds.get(0);
}
homesCombo.add(UIConnectionMessages.controls_client_home_selector_browse);
displayClientVersion();
homesCombo.setEnabled(true);
});
super.done(event);
}
});
hlJob.schedule();
}
use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager in project dbeaver by dbeaver.
the class AbstractNativeToolHandler method validateClientHome.
private void validateClientHome(DBRProgressMonitor monitor, SETTINGS settings) throws DBCException {
DBPDataSourceContainer dataSourceContainer = settings.getDataSourceContainer();
if (isNativeClientHomeRequired()) {
String clientHomeId = dataSourceContainer.getConnectionConfiguration().getClientHomeId();
final DBPDriver driver = dataSourceContainer.getDriver();
final List<DBPNativeClientLocation> clientLocations = driver.getNativeClientLocations();
final DBPNativeClientLocationManager locationManager = driver.getNativeClientManager();
if (locationManager != null) {
clientLocations.addAll(locationManager.findLocalClientLocations());
}
if (clientHomeId == null) {
if (!clientLocations.isEmpty()) {
settings.setClientHome(clientLocations.get(0));
} else {
settings.setClientHome(null);
}
if (settings.getClientHome() == null) {
throw new DBCException("Client binaries location is not specified");
}
} else {
DBPNativeClientLocation clientHome = DBUtils.findObject(clientLocations, clientHomeId);
if (clientHome == null) {
clientHome = settings.findNativeClientHome(clientHomeId);
}
settings.setClientHome(clientHome);
}
if (settings.getClientHome() == null) {
throw new DBCException("Native client home '" + clientHomeId + "' not found");
}
}
DBPNativeClientLocation clientHome = settings.getClientHome();
if (!isNativeClientHomeRequired() || clientHome == null) {
return;
}
try {
clientHome.validateFilesPresence(monitor);
} catch (DBException e) {
throw new DBCException("Error downloading client file(s)", e);
} catch (InterruptedException e) {
// ignore
throw new DBCException("Client file download interrupted", e);
}
}
use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager in project dbeaver by serge-rider.
the class AbstractNativeToolHandler method validateClientHome.
private void validateClientHome(DBRProgressMonitor monitor, SETTINGS settings) throws DBCException {
DBPDataSourceContainer dataSourceContainer = settings.getDataSourceContainer();
if (isNativeClientHomeRequired()) {
String clientHomeId = dataSourceContainer.getConnectionConfiguration().getClientHomeId();
final DBPDriver driver = dataSourceContainer.getDriver();
final List<DBPNativeClientLocation> clientLocations = driver.getNativeClientLocations();
final DBPNativeClientLocationManager locationManager = driver.getNativeClientManager();
if (locationManager != null) {
clientLocations.addAll(locationManager.findLocalClientLocations());
}
if (clientHomeId == null) {
if (!clientLocations.isEmpty()) {
settings.setClientHome(clientLocations.get(0));
} else {
settings.setClientHome(null);
}
if (settings.getClientHome() == null) {
throw new DBCException("Client binaries location is not specified");
}
} else {
DBPNativeClientLocation clientHome = DBUtils.findObject(clientLocations, clientHomeId);
if (clientHome == null) {
clientHome = settings.findNativeClientHome(clientHomeId);
}
settings.setClientHome(clientHome);
}
if (settings.getClientHome() == null) {
throw new DBCException("Native client home '" + clientHomeId + "' not found");
}
}
DBPNativeClientLocation clientHome = settings.getClientHome();
if (!isNativeClientHomeRequired() || clientHome == null) {
return;
}
try {
clientHome.validateFilesPresence(monitor);
} catch (DBException e) {
throw new DBCException("Error downloading client file(s)", e);
} catch (InterruptedException e) {
// ignore
throw new DBCException("Client file download interrupted", e);
}
}
use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager in project dbeaver by serge-rider.
the class ClientHomesPanel method loadHomes.
public void loadHomes(DBPDriver driver) {
homesTable.removeAll();
this.driver = driver;
selectHome(null);
DBPNativeClientLocationManager clientManager = this.driver.getNativeClientManager();
if (clientManager == null) {
// $NON-NLS-1$ //$NON-NLS-2$
log.debug("Client manager is not supported by driver '" + driver.getName() + "'");
}
Set<DBPNativeClientLocation> providedHomes = new LinkedHashSet<>();
if (clientManager != null) {
providedHomes.addAll(clientManager.findLocalClientLocations());
}
Set<DBPNativeClientLocation> allHomes = new LinkedHashSet<>();
allHomes.addAll(driver.getNativeClientLocations());
allHomes.addAll(providedHomes);
for (DBPNativeClientLocation home : allHomes) {
TableItem item = createHomeItem(clientManager, home, home instanceof RemoteNativeClientLocation || providedHomes.contains(home));
if (item != null) {
HomeInfo homeInfo = (HomeInfo) item.getData();
if (homeInfo.isDefault) {
homesTable.setSelection(homesTable.indexOf(item));
selectHome(homeInfo);
}
}
}
}
use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager in project dbeaver by dbeaver.
the class ClientHomesPanel method addClientHome.
private void addClientHome() {
DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
if (lastHomeDirectory != null) {
directoryDialog.setFilterPath(lastHomeDirectory);
}
String homeId = directoryDialog.open();
if (homeId == null) {
return;
}
lastHomeDirectory = homeId;
DBPNativeClientLocationManager clientManager = driver.getNativeClientManager();
if (clientManager != null) {
createHomeItem(clientManager, new LocalNativeClientLocation(homeId, homeId), false);
}
}
Aggregations