提交 e5c9be86 编写于 作者: S Serge Rider

Application model refactoring

上级 39f8a01d
......@@ -65,7 +65,7 @@ import java.util.List;
/**
* DBeaverCore
*/
public class DBeaverCore implements DBPApplication {
public class DBeaverCore implements DBPPlatform {
// The plug-in ID
public static final String PLUGIN_ID = "org.jkiss.dbeaver.core"; //$NON-NLS-1$
......
......@@ -17,7 +17,6 @@
*/
package org.jkiss.dbeaver.registry;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.security.storage.ISecurePreferences;
......@@ -25,7 +24,6 @@ import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.connection.DBPClientHome;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
......@@ -196,8 +194,8 @@ public class DataSourceDescriptor
@NotNull
@Override
public DBPApplication getApplication() {
return registry.getApplication();
public DBPPlatform getPlatform() {
return registry.getPlatform();
}
public void setDriver(@NotNull DriverDescriptor driver)
......@@ -639,7 +637,7 @@ public class DataSourceDescriptor
monitor.subTask("Initialize tunnel");
tunnel = tunnelConfiguration.createHandler(DBWTunnel.class);
try {
tunnelConnectionInfo = tunnel.initializeTunnel(monitor, registry.getApplication(), tunnelConfiguration, connectionInfo);
tunnelConnectionInfo = tunnel.initializeTunnel(monitor, registry.getPlatform(), tunnelConfiguration, connectionInfo);
} catch (Exception e) {
throw new DBCException("Can't initialize tunnel", e);
}
......
......@@ -79,16 +79,16 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private static PasswordEncrypter ENCRYPTOR = new SimpleStringEncrypter();
private final DBPApplication application;
private final DBPPlatform platform;
private final IProject project;
private final List<DataSourceDescriptor> dataSources = new ArrayList<>();
private final List<DBPEventListener> dataSourceListeners = new ArrayList<>();
private volatile boolean saveInProgress = false;
public DataSourceRegistry(DBPApplication application, IProject project)
public DataSourceRegistry(DBPPlatform platform, IProject project)
{
this.application = application;
this.platform = platform;
this.project = project;
loadDataSources(false);
DataSourceProviderRegistry.getInstance().fireRegistryChange(this, true);
......@@ -141,8 +141,8 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
}
@NotNull
public DBPApplication getApplication() {
return application;
public DBPPlatform getPlatform() {
return platform;
}
////////////////////////////////////////////////////
......
......@@ -329,7 +329,7 @@ class ResultSetFilterPanel extends Composite implements IContentProposalProvider
private DBPImage getActiveObjectImage() {
DBSDataContainer dataContainer = viewer.getDataContainer();
if (dataContainer instanceof DBSEntity) {
DBNDatabaseNode dcNode = viewer.getDataContainer().getDataSource().getContainer().getApplication().getNavigatorModel().findNode(dataContainer);
DBNDatabaseNode dcNode = viewer.getDataContainer().getDataSource().getContainer().getPlatform().getNavigatorModel().findNode(dataContainer);
if (dcNode != null) {
return dcNode.getNodeIcon();
}
......
......@@ -1520,7 +1520,7 @@ public class ResultSetViewer extends Viewer
"view"); //$NON-NLS-1$
List<? extends DBDAttributeTransformerDescriptor> transformers =
dataSource.getContainer().getApplication().getValueHandlerRegistry().findTransformers(
dataSource.getContainer().getPlatform().getValueHandlerRegistry().findTransformers(
dataSource, attr, null);
if (!CommonUtils.isEmpty(transformers)) {
MenuManager transformersMenu = new MenuManager("View as");
......@@ -1660,7 +1660,7 @@ public class ResultSetViewer extends Viewer
return;
}
final DBPDataSource dataSource = dataContainer.getDataSource();
final DBDRegistry registry = dataSource.getContainer().getApplication().getValueHandlerRegistry();
final DBDRegistry registry = dataSource.getContainer().getPlatform().getValueHandlerRegistry();
final DBVTransformSettings transformSettings = DBVUtils.getTransformSettings(attr, false);
DBDAttributeTransformerDescriptor customTransformer = null;
if (transformSettings != null && transformSettings.getCustomTransformer() != null) {
......@@ -1876,7 +1876,7 @@ public class ResultSetViewer extends Viewer
if (dataSource == null) {
return;
}
final DBNDatabaseNode targetNode = dataSource.getContainer().getApplication().getNavigatorModel().getNodeByObject(monitor, targetEntity, false);
final DBNDatabaseNode targetNode = dataSource.getContainer().getPlatform().getNavigatorModel().getNodeByObject(monitor, targetEntity, false);
if (targetNode == null) {
UIUtils.showMessageBox(null, "Open link", "Can't navigate to '" + DBUtils.getObjectFullName(targetEntity, DBPEvaluationContext.UI) + "' - navigator node not found", SWT.ICON_ERROR);
return;
......
......@@ -67,7 +67,7 @@ class TransformerSettingsDialog extends BaseDialog {
Collection<? extends DBPPropertyDescriptor> properties = Collections.emptyList();
final DBDAttributeTransformerDescriptor transformer;
if (dataSource != null && !CommonUtils.isEmpty(settings.getCustomTransformer())) {
transformer = dataSource.getContainer().getApplication().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
transformer = dataSource.getContainer().getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
if (transformer != null) {
properties = transformer.getProperties();
}
......
......@@ -193,7 +193,7 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
}
// Refresh navigator node (script execution can change everything inside)
for (BASE_OBJECT object : databaseObjects) {
final DBNDatabaseNode node = dataSourceContainer.getApplication().getNavigatorModel().findNode(object);
final DBNDatabaseNode node = dataSourceContainer.getPlatform().getNavigatorModel().findNode(object);
if (node != null) {
node.refreshNode(monitor, AbstractToolWizard.this);
}
......
......@@ -110,7 +110,7 @@ public class MySQLDataSource extends JDBCDataSource implements DBSObjectSelector
private void initSSL(DBRProgressMonitor monitor, Map<String, String> props, DBWHandlerConfiguration sslConfig) throws Exception {
monitor.subTask("Install SSL certificates");
final DBACertificateStorage securityManager = getContainer().getApplication().getCertificateStorage();
final DBACertificateStorage securityManager = getContainer().getPlatform().getCertificateStorage();
props.put("useSSL", "true");
props.put("verifyServerCertificate", String.valueOf(CommonUtils.toBoolean(sslConfig.getProperties().get(MySQLConstants.PROP_VERIFY_SERVER_SERT))));
......
......@@ -20,7 +20,7 @@ package org.jkiss.dbeaver.ext.oracle.data;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.data.DBDContentStorage;
import org.jkiss.dbeaver.model.data.DBDDisplayFormat;
......@@ -137,14 +137,14 @@ public class OracleContentBFILE extends JDBCContentLOB {
try {
openFile();
long contentLength = getContentLength();
DBPApplication application = dataSource.getContainer().getApplication();
if (contentLength < application.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
DBPPlatform platform = dataSource.getContainer().getPlatform();
if (contentLength < platform.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
try {
try (InputStream bs = getInputStream()) {
storage = BytesContentStorage.createFromStream(
bs,
contentLength,
application.getPreferenceStore().getString(ModelPreferences.CONTENT_HEX_ENCODING));
platform.getPreferenceStore().getString(ModelPreferences.CONTENT_HEX_ENCODING));
}
} catch (IOException e) {
throw new DBCException("IO error while reading content", e);
......@@ -153,7 +153,7 @@ public class OracleContentBFILE extends JDBCContentLOB {
// Create new local storage
File tempFile;
try {
tempFile = ContentUtils.createTempContentFile(monitor, application, "blob" + bfile.hashCode());
tempFile = ContentUtils.createTempContentFile(monitor, platform, "blob" + bfile.hashCode());
} catch (IOException e) {
throw new DBCException("Can't create temporary file", e);
}
......@@ -168,7 +168,7 @@ public class OracleContentBFILE extends JDBCContentLOB {
ContentUtils.deleteTempFile(tempFile);
throw new DBCException(e, dataSource);
}
this.storage = new TemporaryContentStorage(application, tempFile);
this.storage = new TemporaryContentStorage(platform, tempFile);
}
// Free blob - we don't need it anymore
releaseBlob();
......
......@@ -35,7 +35,7 @@ public class WMIDataSourceProvider implements DBPDataSourceProvider {
private boolean libLoaded = false;
@Override
public void init(@NotNull DBPApplication application)
public void init(@NotNull DBPPlatform platform)
{
}
......
......@@ -54,7 +54,7 @@ public interface DBPDataSourceContainer extends DBSObject, DBDPreferences, DBPNa
DBPDriver getDriver();
@NotNull
DBPApplication getApplication();
DBPPlatform getPlatform();
/**
* Connection configuration.
......
......@@ -33,9 +33,9 @@ public interface DBPDataSourceProvider extends DBPObject
/**
* Initializes data source provider
* @param application application
* @param platform application
*/
void init(@NotNull DBPApplication application);
void init(@NotNull DBPPlatform platform);
/**
* Supported features
......
......@@ -35,7 +35,7 @@ public interface DBPDataSourceRegistry {
String CONFIG_FILE_NAME = CONFIG_FILE_PREFIX + CONFIG_FILE_EXT;
@NotNull
DBPApplication getApplication();
DBPPlatform getPlatform();
/**
* Owner project.
*/
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 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.model;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.admin.DBACertificateStorage;
import org.jkiss.dbeaver.model.data.DBDRegistry;
import org.jkiss.dbeaver.model.edit.DBERegistry;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.qm.QMController;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
/**
* DBPApplication
*/
public interface DBPApplication
{
@NotNull
DBNModel getNavigatorModel();
@NotNull
IWorkspace getWorkspace();
@NotNull
DBPProjectManager getProjectManager();
@NotNull
Collection<IProject> getLiveProjects();
@NotNull
QMController getQueryManager();
@NotNull
DBDRegistry getValueHandlerRegistry();
@NotNull
DBERegistry getEditorsRegistry();
@NotNull
DBPPreferenceStore getPreferenceStore();
@NotNull
DBACertificateStorage getCertificateStorage();
@NotNull
File getTempFolder(DBRProgressMonitor monitor, String name) throws IOException;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 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.model;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.admin.DBACertificateStorage;
import org.jkiss.dbeaver.model.data.DBDRegistry;
import org.jkiss.dbeaver.model.edit.DBERegistry;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.qm.QMController;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* DBPPlatform
*/
public interface DBPPlatform
{
@NotNull
DBNModel getNavigatorModel();
@NotNull
IWorkspace getWorkspace();
@NotNull
DBPProjectManager getProjectManager();
@NotNull
List<IProject> getLiveProjects();
@NotNull
QMController getQueryManager();
@NotNull
DBDRegistry getValueHandlerRegistry();
@NotNull
DBERegistry getEditorsRegistry();
@NotNull
DBPPreferenceStore getPreferenceStore();
@NotNull
DBACertificateStorage getCertificateStorage();
@NotNull
File getTempFolder(DBRProgressMonitor monitor, String name) throws IOException;
}
......@@ -504,7 +504,7 @@ public final class DBUtils {
{
DBDValueHandler typeHandler = null;
DBDValueHandlerProvider typeProvider = dataSource.getContainer().getApplication().getValueHandlerRegistry().getDataTypeProvider(
DBDValueHandlerProvider typeProvider = dataSource.getContainer().getPlatform().getValueHandlerRegistry().getDataTypeProvider(
dataSource, column);
if (typeProvider != null) {
typeHandler = typeProvider.getHandler(dataSource, preferences, column);
......
......@@ -17,7 +17,7 @@
*/
package org.jkiss.dbeaver.model.impl;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.data.DBDContentStorage;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.utils.ContentUtils;
......@@ -29,18 +29,18 @@ import java.io.*;
*/
public class ExternalContentStorage implements DBDContentStorage {
private final DBPApplication application;
private final DBPPlatform platform;
private File file;
private String charset;
public ExternalContentStorage(DBPApplication application, File file)
public ExternalContentStorage(DBPPlatform platform, File file)
{
this(application, file, null);
this(platform, file, null);
}
public ExternalContentStorage(DBPApplication application, File file, String charset)
public ExternalContentStorage(DBPPlatform platform, File file, String charset)
{
this.application = application;
this.platform = platform;
this.file = file;
this.charset = charset;
}
......@@ -76,7 +76,7 @@ public class ExternalContentStorage implements DBDContentStorage {
throws IOException
{
// Create new local storage
File tempFile = ContentUtils.createTempContentFile(monitor, application, "copy" + this.hashCode());
File tempFile = ContentUtils.createTempContentFile(monitor, platform, "copy" + this.hashCode());
try {
try (InputStream is = new FileInputStream(file)) {
try (OutputStream os = new FileOutputStream(tempFile)) {
......@@ -87,7 +87,7 @@ public class ExternalContentStorage implements DBDContentStorage {
ContentUtils.deleteTempFile(tempFile);
throw new IOException(e);
}
return new TemporaryContentStorage(application, tempFile);
return new TemporaryContentStorage(platform, tempFile);
}
@Override
......
......@@ -17,7 +17,7 @@
*/
package org.jkiss.dbeaver.model.impl;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.data.DBDContentStorage;
import org.jkiss.dbeaver.model.data.DBDContentStorageLocal;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
......@@ -31,12 +31,12 @@ import java.io.*;
*/
public class TemporaryContentStorage implements DBDContentStorageLocal {
private final DBPApplication application;
private final DBPPlatform platform;
private File file;
public TemporaryContentStorage(DBPApplication application, File file)
public TemporaryContentStorage(DBPPlatform platform, File file)
{
this.application = application;
this.platform = platform;
this.file = file;
}
......@@ -71,7 +71,7 @@ public class TemporaryContentStorage implements DBDContentStorageLocal {
throws IOException
{
// Create new local storage
File tempFile = ContentUtils.createTempContentFile(monitor, application, "copy" + this.hashCode());
File tempFile = ContentUtils.createTempContentFile(monitor, platform, "copy" + this.hashCode());
try {
try (InputStream is = new FileInputStream(file)) {
try (OutputStream os = new FileOutputStream(tempFile)) {
......@@ -82,7 +82,7 @@ public class TemporaryContentStorage implements DBDContentStorageLocal {
ContentUtils.deleteTempFile(tempFile);
throw new IOException(e);
}
return new TemporaryContentStorage(application, tempFile);
return new TemporaryContentStorage(platform, tempFile);
}
@Override
......
......@@ -542,7 +542,7 @@ public abstract class AbstractCommandContext implements DBECommandContext {
}
}
if (queue == null) {
DBEObjectManager<?> objectManager = executionContext.getDataSource().getContainer().getApplication().getEditorsRegistry().getObjectManager(object.getClass());
DBEObjectManager<?> objectManager = executionContext.getDataSource().getContainer().getPlatform().getEditorsRegistry().getObjectManager(object.getClass());
if (objectManager == null) {
throw new IllegalStateException("Can't find object manager for '" + object.getClass().getName() + "'");
}
......
......@@ -41,7 +41,7 @@ public abstract class JDBCDataSourceProvider implements DBPDataSourceProvider {
static final protected Log log = Log.getLog(JDBCDataSourceProvider.class);
@Override
public void init(@NotNull DBPApplication application) {
public void init(@NotNull DBPPlatform platform) {
}
......
......@@ -761,7 +761,7 @@ public class JDBCUtils {
}
public static String generateTableDDL(@NotNull DBRProgressMonitor monitor, @NotNull JDBCTable table, boolean addComments) throws DBException {
final DBERegistry editorsRegistry = table.getDataSource().getContainer().getApplication().getEditorsRegistry();
final DBERegistry editorsRegistry = table.getDataSource().getContainer().getPlatform().getEditorsRegistry();
final SQLObjectEditor entityEditor = editorsRegistry.getObjectManager(table.getClass(), SQLObjectEditor.class);
if (entityEditor instanceof SQLTableManager) {
DBEPersistAction[] ddlActions = ((SQLTableManager) entityEditor).getTableDDL(monitor, table);
......
......@@ -20,7 +20,7 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.data.DBDContentStorage;
import org.jkiss.dbeaver.model.data.DBDDisplayFormat;
......@@ -81,14 +81,14 @@ public class JDBCContentBLOB extends JDBCContentLOB {
{
if (storage == null && blob != null) {
long contentLength = getContentLength();
DBPApplication application = dataSource.getContainer().getApplication();
if (contentLength < application.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
DBPPlatform platform = dataSource.getContainer().getPlatform();
if (contentLength < platform.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
try {
try (InputStream bs = blob.getBinaryStream()) {
storage = BytesContentStorage.createFromStream(
bs,
contentLength,
application.getPreferenceStore().getString(ModelPreferences.CONTENT_HEX_ENCODING));
platform.getPreferenceStore().getString(ModelPreferences.CONTENT_HEX_ENCODING));
}
}
catch (SQLException e) {
......@@ -100,7 +100,7 @@ public class JDBCContentBLOB extends JDBCContentLOB {
// Create new local storage
File tempFile;
try {
tempFile = ContentUtils.createTempContentFile(monitor, application, "blob" + blob.hashCode());
tempFile = ContentUtils.createTempContentFile(monitor, platform, "blob" + blob.hashCode());
}
catch (IOException e) {
throw new DBCException("Can't create temporary file", e);
......@@ -116,7 +116,7 @@ public class JDBCContentBLOB extends JDBCContentLOB {
ContentUtils.deleteTempFile(tempFile);
throw new DBCException(e, dataSource);
}
this.storage = new TemporaryContentStorage(application, tempFile);
this.storage = new TemporaryContentStorage(platform, tempFile);
}
// Free blob - we don't need it anymore
releaseBlob();
......
......@@ -20,7 +20,7 @@ package org.jkiss.dbeaver.model.impl.jdbc.data;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.data.DBDContent;
import org.jkiss.dbeaver.model.data.DBDContentCached;
......@@ -85,8 +85,8 @@ public class JDBCContentCLOB extends JDBCContentLOB implements DBDContent {
{
if (storage == null && clob != null) {
long contentLength = getContentLength();
DBPApplication application = dataSource.getContainer().getApplication();
if (contentLength < application.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
DBPPlatform platform = dataSource.getContainer().getPlatform();
if (contentLength < platform.getPreferenceStore().getInt(ModelPreferences.MEMORY_CONTENT_MAX_SIZE)) {
try {
storage = StringContentStorage.createFromReader(clob.getCharacterStream(), contentLength);
}
......@@ -99,7 +99,7 @@ public class JDBCContentCLOB extends JDBCContentLOB implements DBDContent {
// Create new local storage
File tempFile;
try {
tempFile = ContentUtils.createTempContentFile(monitor, application, "clob" + clob.hashCode());
tempFile = ContentUtils.createTempContentFile(monitor, platform, "clob" + clob.hashCode());
}
catch (IOException e) {
throw new DBCException("Can't create temp file", e);
......@@ -113,7 +113,7 @@ public class JDBCContentCLOB extends JDBCContentLOB implements DBDContent {
ContentUtils.deleteTempFile(tempFile);
throw new DBCException(e, dataSource);
}
this.storage = new TemporaryContentStorage(application, tempFile);
this.storage = new TemporaryContentStorage(platform, tempFile);
}
// Free lob - we don't need it anymore
releaseClob();
......
......@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.model.impl.net;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.net.DBWTunnel;
......@@ -32,7 +32,7 @@ import java.io.IOException;
public class HTTPTunnelImpl implements DBWTunnel {
@Override
public DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPApplication application, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
public DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
throws DBException, IOException
{
return connectionInfo;
......
......@@ -21,7 +21,7 @@ import com.jcraft.jsch.*;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
......@@ -47,7 +47,7 @@ public class SSHTunnelImpl implements DBWTunnel {
private transient Session session;
@Override
public DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPApplication application, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
public DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
throws DBException, IOException
{
String dbPortString = connectionInfo.getHostPort();
......@@ -114,7 +114,7 @@ public class SSHTunnelImpl implements DBWTunnel {
} catch (NumberFormatException e) {
throw new DBException("Bad database port number: " + dbPortString);
}
int localPort = findFreePort(application);
int localPort = findFreePort(platform);
try {
if (jsch == null) {
jsch = new JSch();
......@@ -162,9 +162,9 @@ public class SSHTunnelImpl implements DBWTunnel {
return connectionInfo;
}
private int findFreePort(DBPApplication application)
private int findFreePort(DBPPlatform platform)
{
DBPPreferenceStore store = application.getPreferenceStore();
DBPPreferenceStore store = platform.getPreferenceStore();
int minPort = store.getInt(ModelPreferences.NET_TUNNEL_PORT_MIN);
int maxPort = store.getInt(ModelPreferences.NET_TUNNEL_PORT_MAX);
return IOUtils.findFreePort(minPort, maxPort);
......
......@@ -78,7 +78,7 @@ public abstract class SQLStructEditor<OBJECT_TYPE extends DBSObject, CONTAINER_T
protected void createObjectReferences(DBRProgressMonitor monitor, DBECommandContext commandContext, ObjectCreateCommand createCommand) throws DBException {
OBJECT_TYPE object = createCommand.getObject();
final DBERegistry editorsRegistry = object.getDataSource().getContainer().getApplication().getEditorsRegistry();
final DBERegistry editorsRegistry = object.getDataSource().getContainer().getPlatform().getEditorsRegistry();
for (Class childType : getChildTypes()) {
Collection<? extends DBSObject> children = getChildObjects(monitor, object, childType);
if (!CommonUtils.isEmpty(children)) {
......
......@@ -141,7 +141,7 @@ public abstract class SQLTableManager<OBJECT_TYPE extends JDBCTable, CONTAINER_T
public DBEPersistAction[] getTableDDL(DBRProgressMonitor monitor, OBJECT_TYPE table) throws DBException
{
final DBERegistry editorsRegistry = table.getDataSource().getContainer().getApplication().getEditorsRegistry();
final DBERegistry editorsRegistry = table.getDataSource().getContainer().getPlatform().getEditorsRegistry();
SQLObjectEditor<DBSEntityAttribute, OBJECT_TYPE> tcm = getObjectEditor(editorsRegistry, DBSEntityAttribute.class);
SQLObjectEditor<DBSTableConstraint, OBJECT_TYPE> pkm = getObjectEditor(editorsRegistry, DBSTableConstraint.class);
SQLObjectEditor<DBSTableForeignKey, OBJECT_TYPE> fkm = getObjectEditor(editorsRegistry, DBSTableForeignKey.class);
......
......@@ -27,7 +27,7 @@ import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBIconComposite;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeFolder;
......@@ -54,18 +54,18 @@ import java.util.Map;
public class DBNModel implements IResourceChangeListener {
private static final Log log = Log.getLog(DBNModel.class);
private final DBPApplication application;
private final DBPPlatform platform;
private DBNRoot root;
private final List<INavigatorListener> listeners = new ArrayList<>();
private transient INavigatorListener[] listenersCopy = null;
private final Map<DBSObject, Object> nodeMap = new HashMap<>();
public DBNModel(DBPApplication application) {
this.application = application;
public DBNModel(DBPPlatform platform) {
this.platform = platform;
}
public DBPApplication getApplication() {
return application;
public DBPPlatform getPlatform() {
return platform;
}
public void initialize()
......@@ -76,16 +76,16 @@ public class DBNModel implements IResourceChangeListener {
this.root = new DBNRoot(this);
// Add all existing projects to root node
for (IProject project : application.getLiveProjects()) {
for (IProject project : platform.getLiveProjects()) {
root.addProject(project, false);
}
application.getWorkspace().addResourceChangeListener(this);
platform.getWorkspace().addResourceChangeListener(this);
}
public void dispose()
{
application.getWorkspace().removeResourceChangeListener(this);
platform.getWorkspace().removeResourceChangeListener(this);
this.root.dispose(false);
synchronized (nodeMap) {
this.nodeMap.clear();
......@@ -484,8 +484,8 @@ public class DBNModel implements IResourceChangeListener {
// New projectNode
getRoot().addProject(project, true);
if (application.getProjectManager().getActiveProject() == null) {
application.getProjectManager().setActiveProject(project);
if (platform.getProjectManager().getActiveProject() == null) {
platform.getProjectManager().setActiveProject(project);
}
} else {
// Project not found - report an error
......@@ -495,8 +495,8 @@ public class DBNModel implements IResourceChangeListener {
if (childDelta.getKind() == IResourceDelta.REMOVED) {
// Project deleted
getRoot().removeProject(project);
if (project == application.getProjectManager().getActiveProject()) {
application.getProjectManager().setActiveProject(null);
if (project == platform.getProjectManager().getActiveProject()) {
platform.getProjectManager().setActiveProject(null);
}
} else {
if (childDelta.getFlags() == IResourceDelta.OPEN) {
......
......@@ -42,7 +42,7 @@ public class DBNProject extends DBNResource
public DBNProject(DBNNode parentNode, IProject project, DBPResourceHandler handler)
{
super(parentNode, project, handler);
getModel().getApplication().getProjectManager().addProject(project);
getModel().getPlatform().getProjectManager().addProject(project);
}
@Override
......@@ -50,7 +50,7 @@ public class DBNProject extends DBNResource
{
IProject project = getProject();
super.dispose(reflect);
getModel().getApplication().getProjectManager().removeProject(project);
getModel().getPlatform().getProjectManager().removeProject(project);
}
public IProject getProject()
......@@ -108,7 +108,7 @@ public class DBNProject extends DBNResource
public boolean supportsRename()
{
// Do not rename active projects
return getModel().getApplication().getProjectManager().getActiveProject() != getProject();
return getModel().getPlatform().getProjectManager().getActiveProject() != getProject();
}
@Override
......@@ -135,7 +135,7 @@ public class DBNProject extends DBNResource
throw new DBException("Can't open project '" + project.getName() + "'", e);
}
}
DBPDataSourceRegistry dataSourceRegistry = getModel().getApplication().getProjectManager().getDataSourceRegistry(project);
DBPDataSourceRegistry dataSourceRegistry = getModel().getPlatform().getProjectManager().getDataSourceRegistry(project);
DBNNode[] children = super.readChildNodes(monitor);
if (dataSourceRegistry != null) {
children = ArrayUtils.insertArea(DBNNode.class, children, 0, new Object[] {new DBNProjectDatabases(this, dataSourceRegistry)});
......
......@@ -201,7 +201,7 @@ public class DBNResource extends DBNNode// implements IContributorResourceAdapte
// Sub folder
return handler.makeNavigatorNode(this, resource);
}
DBPResourceHandler resourceHandler = getModel().getApplication().getProjectManager().getResourceHandler(resource);
DBPResourceHandler resourceHandler = getModel().getPlatform().getProjectManager().getResourceHandler(resource);
if (resourceHandler == null) {
log.debug("Skip resource '" + resource.getName() + "'");
return null;
......
......@@ -38,7 +38,7 @@ public class DBNRoot extends DBNNode implements DBNContainer, DBPProjectListener
{
super();
this.model = model;
model.getApplication().getProjectManager().addProjectListener(this);
model.getPlatform().getProjectManager().addProjectListener(this);
}
@Override
......@@ -48,7 +48,7 @@ public class DBNRoot extends DBNNode implements DBNContainer, DBPProjectListener
project.dispose(reflect);
}
projects = new DBNProject[0];
model.getApplication().getProjectManager().removeProjectListener(this);
model.getPlatform().getProjectManager().removeProjectListener(this);
}
@Override
......@@ -141,7 +141,7 @@ public class DBNRoot extends DBNNode implements DBNContainer, DBPProjectListener
DBNProject projectNode = new DBNProject(
this,
project,
model.getApplication().getProjectManager().getResourceHandler(project));
model.getPlatform().getProjectManager().getResourceHandler(project));
projects = ArrayUtils.add(DBNProject.class, projects, projectNode);
Arrays.sort(projects, new Comparator<DBNProject>() {
@Override
......
......@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.model.net;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
......@@ -29,7 +29,7 @@ import java.io.IOException;
*/
public interface DBWTunnel extends DBWNetworkHandler {
DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPApplication application, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
throws DBException, IOException;
void closeTunnel(DBRProgressMonitor monitor, DBPConnectionConfiguration connectionInfo)
......
......@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.model.qm;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import java.util.Collections;
import java.util.List;
......@@ -28,10 +28,10 @@ import java.util.List;
*/
public class QMUtils {
private static DBPApplication application;
private static DBPPlatform application;
private static QMExecutionHandler defaultHandler;
public static void initApplication(DBPApplication application) {
public static void initApplication(DBPPlatform application) {
QMUtils.application = application;
}
......
......@@ -321,7 +321,7 @@ public class DBVModel extends DBVContainer {
case TAG_EXCLUDE:
String transformerId = atts.getValue(ATTR_ID);
if (curTransformSettings != null && !CommonUtils.isEmpty(transformerId)) {
final DBDAttributeTransformerDescriptor transformer = dataSourceContainer.getApplication().getValueHandlerRegistry().getTransformer(transformerId);
final DBDAttributeTransformerDescriptor transformer = dataSourceContainer.getPlatform().getValueHandlerRegistry().getTransformer(transformerId);
if (transformer == null) {
log.warn("Transformer '" + transformerId + "' not found");
} else {
......
......@@ -98,7 +98,7 @@ public abstract class DBVUtils {
DBPDataSource dataSource = binding.getDataSource();
DBPDataSourceContainer container = dataSource.getContainer();
List<? extends DBDAttributeTransformerDescriptor> tdList =
container.getApplication().getValueHandlerRegistry().findTransformers(dataSource, binding.getAttribute(), custom);
container.getPlatform().getValueHandlerRegistry().findTransformers(dataSource, binding.getAttribute(), custom);
if (tdList == null || tdList.isEmpty()) {
return null;
}
......
......@@ -24,7 +24,7 @@ import org.eclipse.core.runtime.IPath;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPlatform;
import org.jkiss.dbeaver.model.data.DBDContent;
import org.jkiss.dbeaver.model.data.DBDContentCached;
import org.jkiss.dbeaver.model.data.DBDContentStorage;
......@@ -61,13 +61,13 @@ public class ContentUtils {
}
public static File getLobFolder(DBRProgressMonitor monitor, DBPApplication application)
public static File getLobFolder(DBRProgressMonitor monitor, DBPPlatform application)
throws IOException
{
return application.getTempFolder(monitor, LOB_DIR);
}
public static File createTempContentFile(DBRProgressMonitor monitor, DBPApplication application, String fileName)
public static File createTempContentFile(DBRProgressMonitor monitor, DBPPlatform application, String fileName)
throws IOException
{
return makeTempFile(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册