提交 6422df6a 编写于 作者: J jurgen

Driver files download wizard

上级 4d3cbdc6
......@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.registry;
import org.jkiss.dbeaver.model.DBPDriverFileType;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.utils.CommonUtils;
import java.io.File;
......@@ -43,8 +43,8 @@ public class DriverClassLoader extends URLClassLoader
protected String findLibrary(String libname)
{
String nativeName = System.mapLibraryName(libname);
for (DriverFileDescriptor driverFile : driver.getFiles()) {
if (driverFile.getType() == DBPDriverFileType.lib && driverFile.matchesCurrentPlatform()) {
for (DriverFileDescriptor driverFile : driver.getDriverFiles()) {
if (driverFile.getType() == DBPDriverFile.FileType.lib && driverFile.matchesCurrentPlatform()) {
final File localFile = driverFile.getLocalFile();
if (localFile != null && localFile.exists()) {
final String fileName = localFile.getName();
......
......@@ -25,6 +25,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.Log;
......@@ -43,6 +44,7 @@ import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.AcceptLicenseDialog;
import org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverDownloadDialog;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverEditDialog;
import org.jkiss.dbeaver.utils.ContentUtils;
import org.jkiss.dbeaver.utils.GeneralUtils;
......@@ -639,13 +641,14 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
clientHomeIds.add(homeId);
}
@NotNull
@Override
public Collection<DriverFileDescriptor> getFiles()
public Collection<DriverFileDescriptor> getDriverFiles()
{
return files;
}
public DriverFileDescriptor getLibrary(String path)
public DriverFileDescriptor getDriverFile(String path)
{
for (DriverFileDescriptor lib : files) {
if (lib.getPath().equals(path)) {
......@@ -655,7 +658,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return null;
}
public DriverFileDescriptor addLibrary(String path, DBPDriverFileType fileType)
public DriverFileDescriptor addDriverFile(String path, DBPDriverFile.FileType fileType)
{
for (DriverFileDescriptor lib : files) {
if (lib.getPath().equals(path)) {
......@@ -663,11 +666,11 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
}
}
DriverFileDescriptor lib = new DriverFileDescriptor(this, fileType, path);
addLibrary(lib);
addDriverFile(lib);
return lib;
}
public boolean addLibrary(DriverFileDescriptor descriptor)
public boolean addDriverFile(DriverFileDescriptor descriptor)
{
if (!files.contains(descriptor)) {
this.files.add(descriptor);
......@@ -677,7 +680,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return false;
}
public boolean removeLibrary(DriverFileDescriptor lib)
public boolean removeDriverFile(DriverFileDescriptor lib)
{
if (!lib.isCustom()) {
lib.setDisabled(true);
......@@ -702,6 +705,11 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return result;
}
@NotNull
public List<DriverFileSource> getDriverFileSources() {
return fileSources;
}
@Override
public Collection<DriverPathDescriptor> getPathList()
{
......@@ -799,7 +807,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
public String getLicense()
{
for (DriverFileDescriptor file : files) {
if (file.getType() == DBPDriverFileType.license) {
if (file.getType() == DBPDriverFile.FileType.license) {
final File licenseFile = file.getLocalFile();
if (licenseFile != null && licenseFile.exists()) {
try {
......@@ -874,7 +882,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
List<URL> libraryURLs = new ArrayList<URL>();
// Load libraries
for (DriverFileDescriptor file : files) {
if (file.isDisabled() || file.getType() != DBPDriverFileType.jar) {
if (file.isDisabled() || file.getType() != DBPDriverFile.FileType.jar) {
continue;
}
File localFile = file.getLocalFile();
......@@ -984,8 +992,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
private boolean acceptDriverLicenses(DBRRunnableContext runnableContext)
{
// User must accept all licenses before actual drivers download
for (final DriverFileDescriptor file : getFiles()) {
if (file.getType() == DBPDriverFileType.license) {
for (final DriverFileDescriptor file : getDriverFiles()) {
if (file.getType() == DBPDriverFile.FileType.license) {
final File libraryFile = file.getLocalFile();
if (libraryFile == null || !libraryFile.exists()) {
try {
......@@ -1050,7 +1058,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
// User just canceled download
return IDialogConstants.CANCEL_ID;
} catch (InvocationTargetException e) {
if (file.getType() == DBPDriverFileType.license) {
if (file.getType() == DBPDriverFile.FileType.license) {
return IDialogConstants.OK_ID;
}
DownloadRetry retryConfirm = new DownloadRetry(file, e.getTargetException());
......@@ -1124,7 +1132,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
}
// Libraries
for (DriverFileDescriptor lib : this.getFiles()) {
for (DriverFileDescriptor lib : this.getDriverFiles()) {
if ((export && !lib.isDisabled()) || lib.isCustom() || lib.isDisabled()) {
xml.startElement(RegistryConstants.TAG_LIBRARY);
xml.addAttribute(RegistryConstants.ATTR_TYPE, lib.getType().name());
......@@ -1296,25 +1304,25 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
log.warn("File outside of driver");
return;
}
DBPDriverFileType type;
DBPDriverFile.FileType type;
String typeStr = atts.getValue(RegistryConstants.ATTR_TYPE);
if (CommonUtils.isEmpty(typeStr)) {
type = DBPDriverFileType.jar;
type = DBPDriverFile.FileType.jar;
} else {
try {
type = DBPDriverFileType.valueOf(typeStr);
type = DBPDriverFile.FileType.valueOf(typeStr);
} catch (IllegalArgumentException e) {
log.warn(e);
type = DBPDriverFileType.jar;
type = DBPDriverFile.FileType.jar;
}
}
String path = atts.getValue(RegistryConstants.ATTR_PATH);
DriverFileDescriptor lib = curDriver.getLibrary(path);
DriverFileDescriptor lib = curDriver.getDriverFile(path);
String disabledAttr = atts.getValue(RegistryConstants.ATTR_DISABLED);
if (lib != null && CommonUtils.getBoolean(disabledAttr)) {
lib.setDisabled(true);
} else if (lib == null) {
curDriver.addLibrary(path, type);
curDriver.addDriverFile(path, type);
}
} else if (localName.equals(RegistryConstants.TAG_CLIENT_HOME)) {
curDriver.addClientHomeId(atts.getValue(RegistryConstants.ATTR_ID));
......@@ -1519,6 +1527,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
@Override
public void run()
{
DriverDownloadDialog downloadDialog = new DriverDownloadDialog(DBeaverUI.getActiveWorkbenchWindow(), DriverDescriptor.this);
downloadDialog.open();
proceed = ConfirmationDialog.showConfirmDialog(
null,
DBeaverPreferences.CONFIRM_DRIVER_DOWNLOAD,
......
......@@ -21,12 +21,9 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.model.DBPDriverFileType;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import org.jkiss.dbeaver.registry.maven.MavenArtifact;
......@@ -35,7 +32,6 @@ import org.jkiss.dbeaver.registry.maven.MavenLocalVersion;
import org.jkiss.dbeaver.registry.maven.MavenRegistry;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.utils.ContentUtils;
import org.jkiss.utils.CommonUtils;
import java.io.*;
import java.net.*;
......@@ -53,7 +49,7 @@ public class DriverFileDescriptor implements DBPDriverFile
public static final String FILE_SOURCE_PLATFORM = "platform:/";
private final DriverDescriptor driver;
private final DBPDriverFileType type;
private final FileType type;
private final OSDescriptor system;
private String path;
private String fileExtension;
......@@ -61,7 +57,7 @@ public class DriverFileDescriptor implements DBPDriverFile
private boolean custom;
private boolean disabled;
public DriverFileDescriptor(DriverDescriptor driver, DBPDriverFileType type, String path)
public DriverFileDescriptor(DriverDescriptor driver, FileType type, String path)
{
this.driver = driver;
this.type = type;
......@@ -73,7 +69,7 @@ public class DriverFileDescriptor implements DBPDriverFile
DriverFileDescriptor(DriverDescriptor driver, IConfigurationElement config)
{
this.driver = driver;
this.type = DBPDriverFileType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE));
this.type = FileType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE));
String osName = config.getAttribute(RegistryConstants.ATTR_OS);
this.system = osName == null ? null : new OSDescriptor(
......@@ -91,7 +87,7 @@ public class DriverFileDescriptor implements DBPDriverFile
}
@Override
public DBPDriverFileType getType()
public FileType getType()
{
return type;
}
......
......@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDriverFile;
import java.util.ArrayList;
import java.util.List;
......@@ -26,7 +27,7 @@ import java.util.List;
/**
* DriverFileSource
*/
public class DriverFileSource
public class DriverFileSource implements DBPDriverFile.FileSource
{
static final Log log = Log.getLog(DriverFileSource.class);
......
......@@ -182,7 +182,7 @@ public class ProjectExportWizard extends Wizard implements IExportWizard {
Set<File> libFiles = new HashSet<File>();
Map<String, File> libPathMap = new HashMap<String, File>();
for (DriverDescriptor driver : exportData.usedDrivers) {
for (DriverFileDescriptor fileDescriptor : driver.getFiles()) {
for (DriverFileDescriptor fileDescriptor : driver.getDriverFiles()) {
final File libraryFile = fileDescriptor.getLocalFile();
if (libraryFile != null && !fileDescriptor.isDisabled() && libraryFile.exists()) {
libFiles.add(libraryFile);
......
......@@ -29,7 +29,7 @@ import org.eclipse.ui.IWorkbench;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPDriverFileType;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.registry.*;
......@@ -270,7 +270,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
}
// Add libraries (only for managable drivers with empty library list)
if (CommonUtils.isEmpty(driver.getFiles())) {
if (CommonUtils.isEmpty(driver.getDriverFiles())) {
List<String> libraryList = new ArrayList<String>();
for (Element libElement : XMLUtils.getChildElementList(driverElement, RegistryConstants.TAG_FILE)) {
libraryList.add(libElement.getAttribute(RegistryConstants.ATTR_PATH));
......@@ -280,7 +280,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
File libFile = new File(libPath);
if (libFile.exists()) {
// Just use path as-is (may be it is local re-import or local environments equal to export environment)
driver.addLibrary(libPath, DBPDriverFileType.jar);
driver.addDriverFile(libPath, DBPDriverFile.FileType.jar);
} else {
// Get driver library from archive
String archiveLibEntry = libMap.get(libPath);
......@@ -312,7 +312,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
while (relativePath.charAt(0) == '/' || relativePath.charAt(0) == '\\') {
relativePath = relativePath.substring(1);
}
driver.addLibrary(relativePath, DBPDriverFileType.jar);
driver.addDriverFile(relativePath, DBPDriverFile.FileType.jar);
}
}
}
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.ui.dialogs.driver;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.registry.DriverFileDescriptor;
import org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
class DriverDownloadAutoPage extends WizardPage {
static final Log log = Log.getLog(DriverDownloadAutoPage.class);
DriverDownloadAutoPage() {
super("Automatic download", "Download driver files", null);
setPageComplete(false);
}
@Override
public void createControl(Composite parent) {
DriverDownloadWizard wizard = (DriverDownloadWizard) getWizard();
StringBuilder message = new StringBuilder();
message.append("Download ").append(wizard.getDriver().getFullName()).append(" driver files:\n");
for (DriverFileDescriptor file : wizard.getDriver().getDriverFiles()) {
message.append("\t-").append(file.getPath()).append("\n");
}
initializeDialogUnits(parent);
Composite composite = UIUtils.createPlaceholder(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Text infoText = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
infoText.setText(message.toString());
infoText.setLayoutData(new GridData(GridData.FILL_BOTH));
setControl(composite);
setMessage("Download " + wizard.getDriver().getFullName() + " driver files");
}
}
\ No newline at end of file
......@@ -15,15 +15,43 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.model;
package org.jkiss.dbeaver.ui.dialogs.driver;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.utils.CommonUtils;
/**
* Driver file type
* DriverDownloadDialog
*/
public enum DBPDriverFileType
public class DriverDownloadDialog extends WizardDialog
{
jar,
lib,
executable,
license
public static final int EDIT_DRIVER_BUTTON_ID = 2000;
private final DriverDescriptor driver;
public DriverDownloadDialog(IWorkbenchWindow window, DriverDescriptor driver)
{
super(window.getShell(), new DriverDownloadWizard(driver));
this.driver = driver;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, EDIT_DRIVER_BUTTON_ID, "Edit Driver", false);
super.createButtonsForButtonBar(parent);
Button finishButton = getButton(IDialogConstants.FINISH_ID);
if (CommonUtils.isEmpty(driver.getDriverFileSources())) {
finishButton.setText("Download");
} else {
finishButton.setText("Open Download Page");
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.ui.dialogs.driver;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
public class DriverDownloadWizard extends Wizard implements IExportWizard {
private static final String DRIVER_DOWNLOAD_DIALOG_SETTINGS = "DriverDownload";//$NON-NLS-1$
private DriverDescriptor driver;
public DriverDownloadWizard(@NotNull DriverDescriptor driver) {
this.driver = driver;
setWindowTitle("Setup driver files");
loadSettings();
}
public DriverDescriptor getDriver() {
return driver;
}
private void loadSettings()
{
IDialogSettings section = UIUtils.getDialogSettings(DRIVER_DOWNLOAD_DIALOG_SETTINGS);
setDialogSettings(section);
}
@Override
public void addPages() {
super.addPages();
addPage(new DriverDownloadAutoPage());
}
@Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
setWindowTitle("Driver settings");
setNeedsProgressMonitor(true);
setHelpAvailable(true);
}
@Override
public boolean canFinish()
{
return true;
}
@Override
public boolean performFinish() {
return true;
}
}
\ No newline at end of file
......@@ -37,12 +37,10 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDriverFileType;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.registry.DataSourceProviderDescriptor;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor;
......@@ -396,7 +394,7 @@ public class DriverEditDialog extends HelpEnabledDialog
libList.add(
new DriverFileDescriptor(
driver,
fileName.endsWith(".jar") || fileName.endsWith(".zip") ? DBPDriverFileType.jar : DBPDriverFileType.lib,
fileName.endsWith(".jar") || fileName.endsWith(".zip") ? DBPDriverFile.FileType.jar : DBPDriverFile.FileType.lib,
new File(folderFile, fileName).getAbsolutePath()));
}
changeLibContent();
......@@ -417,7 +415,7 @@ public class DriverEditDialog extends HelpEnabledDialog
curFolder = fd.getFilterPath();
libList.add(new DriverFileDescriptor(
driver,
DBPDriverFileType.jar,
DBPDriverFile.FileType.jar,
selected));
changeLibContent();
}
......@@ -646,8 +644,8 @@ public class DriverEditDialog extends HelpEnabledDialog
if (libTable != null) {
libList = new ArrayList<DriverFileDescriptor>();
for (DriverFileDescriptor lib : driver.getFiles()) {
if (lib.isDisabled() || (lib.getType() != DBPDriverFileType.jar && lib.getType() != DBPDriverFileType.lib) || !lib.matchesCurrentPlatform()) {
for (DriverFileDescriptor lib : driver.getDriverFiles()) {
if (lib.isDisabled() || (lib.getType() != DBPDriverFile.FileType.jar && lib.getType() != DBPDriverFile.FileType.lib) || !lib.matchesCurrentPlatform()) {
continue;
}
libList.add(lib);
......@@ -690,11 +688,11 @@ public class DriverEditDialog extends HelpEnabledDialog
// Set libraries
for (DriverFileDescriptor lib : CommonUtils.safeCollection(libList)) {
driver.addLibrary(lib);
driver.addDriverFile(lib);
}
for (DriverFileDescriptor lib : CommonUtils.copyList(driver.getFiles())) {
for (DriverFileDescriptor lib : CommonUtils.copyList(driver.getDriverFiles())) {
if (!libList.contains(lib)) {
driver.removeLibrary(lib);
driver.removeDriverFile(lib);
}
}
......@@ -762,7 +760,7 @@ public class DriverEditDialog extends HelpEnabledDialog
java.util.List<URL> libURLs = new ArrayList<URL>();
for (DriverFileDescriptor lib : libList) {
File libFile = lib.getLocalFile();
if (libFile != null && libFile.exists() && !libFile.isDirectory() && lib.getType() == DBPDriverFileType.jar) {
if (libFile != null && libFile.exists() && !libFile.isDirectory() && lib.getType() == DBPDriverFile.FileType.jar) {
libFiles.add(libFile);
try {
libURLs.add(libFile.toURI().toURL());
......
......@@ -25,7 +25,7 @@ import org.eclipse.ui.IWorkbench;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.DBPDriverFileType;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.registry.*;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.SelectObjectDialog;
......@@ -122,7 +122,7 @@ public abstract class ConfigImportWizard extends Wizard implements IImportWizard
driver.setDescription(driverInfo.getDescription());
driver.setDriverDefaultPort(driverInfo.getDefaultPort());
for (String path : driverInfo.getLibraries()) {
driver.addLibrary(path, DBPDriverFileType.jar);
driver.addDriverFile(path, DBPDriverFile.FileType.jar);
}
driver.setModified(true);
genericProvider.addDriver(driver);
......
......@@ -79,8 +79,8 @@ public class WMIDataSourceProvider implements DBPDataSourceProvider {
private void loadNativeLib(DBPDriver driver) throws DBException
{
for (DBPDriverFile libFile : driver.getFiles()) {
if (libFile.matchesCurrentPlatform() && libFile.getType() == DBPDriverFileType.lib) {
for (DBPDriverFile libFile : driver.getDriverFiles()) {
if (libFile.matchesCurrentPlatform() && libFile.getType() == DBPDriverFile.FileType.lib) {
File localFile = libFile.getLocalFile();
if (localFile != null) {
try {
......
......@@ -18,6 +18,7 @@
package org.jkiss.dbeaver.model;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
......@@ -86,7 +87,11 @@ public interface DBPDriver extends DBPObject
ClassLoader getClassLoader();
Collection<? extends DBPDriverFile> getFiles();
@NotNull
Collection<? extends DBPDriverFile> getDriverFiles();
@NotNull
Collection<? extends DBPDriverFile.FileSource> getDriverFileSources();
Object getDriverInstance(DBRRunnableContext runnableContext) throws DBException;
......
......@@ -28,7 +28,22 @@ import java.io.File;
*/
public interface DBPDriverFile
{
DBPDriverFileType getType();
/**
* Driver file type
*/
enum FileType
{
jar,
lib,
executable,
license
}
interface FileSource {
}
FileType getType();
OSDescriptor getSystem();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册