提交 4502ac92 编写于 作者: S serge-rider

SQL presentation panels


Former-commit-id: fe863a86
上级 7896b142
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.registry.transfer;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.wizard.IWizardPage;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.impl.AbstractDescriptor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.tools.transfer.IDataTransferNode;
import org.jkiss.dbeaver.tools.transfer.IDataTransferSettings;
import org.jkiss.utils.ArrayUtils;
import java.util.*;
/**
* DataTransferNodeDescriptor
*/
public class DataTransferNodeDescriptor extends AbstractDescriptor
{
private static final Log log = Log.getLog(DataTransferNodeDescriptor.class);
enum NodeType {
PRODUCER,
CONSUMER
}
@NotNull
private final String id;
@NotNull
private final String name;
private final String description;
@NotNull
private final DBPImage icon;
private final NodeType nodeType;
private final ObjectType implType;
private final ObjectType settingsType;
private final List<ObjectType> sourceTypes = new ArrayList<>();
private final List<ObjectType> pageTypes = new ArrayList<>();
private final List<DataTransferProcessorDescriptor> processors = new ArrayList<>();
public DataTransferNodeDescriptor(IConfigurationElement config)
{
super(config);
this.id = config.getAttribute(RegistryConstants.ATTR_ID);
this.name = config.getAttribute(RegistryConstants.ATTR_LABEL);
this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
this.icon = iconToImage(config.getAttribute(RegistryConstants.ATTR_ICON), DBIcon.TYPE_UNKNOWN);
this.nodeType = NodeType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE).toUpperCase(Locale.ENGLISH));
this.implType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_CLASS));
this.settingsType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_SETTINGS));
loadNodeConfigurations(config);
}
void loadNodeConfigurations(IConfigurationElement config) {
for (IConfigurationElement typeCfg : ArrayUtils.safeArray(config.getChildren(RegistryConstants.ATTR_SOURCE_TYPE))) {
sourceTypes.add(new ObjectType(typeCfg.getAttribute(RegistryConstants.ATTR_TYPE)));
}
for (IConfigurationElement pageConfig : ArrayUtils.safeArray(config.getChildren(RegistryConstants.TAG_PAGE))) {
pageTypes.add(new ObjectType(pageConfig.getAttribute(RegistryConstants.ATTR_CLASS)));
}
for (IConfigurationElement processorConfig : ArrayUtils.safeArray(config.getChildren(RegistryConstants.TAG_PROCESSOR))) {
processors.add(new DataTransferProcessorDescriptor(this, processorConfig));
}
processors.sort(Comparator.comparing(DataTransferProcessorDescriptor::getName));
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
public String getDescription()
{
return description;
}
@NotNull
public DBPImage getIcon()
{
return icon;
}
public Class<? extends IDataTransferNode> getNodeClass()
{
return implType.getObjectClass(IDataTransferNode.class);
}
public IDataTransferNode createNode() throws DBException
{
implType.checkObjectClass(IDataTransferNode.class);
try {
return implType.getObjectClass(IDataTransferNode.class).newInstance();
} catch (Throwable e) {
throw new DBException("Can't create data transformer node", e);
}
}
public IDataTransferSettings createSettings() throws DBException
{
settingsType.checkObjectClass(IDataTransferSettings.class);
try {
return settingsType.getObjectClass(IDataTransferSettings.class).newInstance();
} catch (Throwable e) {
throw new DBException("Can't create node settings", e);
}
}
public IWizardPage[] createWizardPages()
{
List<IWizardPage> pages = new ArrayList<>();
for (ObjectType type : pageTypes) {
try {
type.checkObjectClass(IWizardPage.class);
pages.add(type.getObjectClass(IWizardPage.class).newInstance());
} catch (Throwable e) {
log.error("Can't create wizard page", e);
}
}
return pages.toArray(new IWizardPage[pages.size()]);
}
public NodeType getNodeType()
{
return nodeType;
}
public boolean appliesToType(Class objectType)
{
if (!sourceTypes.isEmpty()) {
for (ObjectType sourceType : sourceTypes) {
if (sourceType.matchesType(objectType)) {
return true;
}
}
}
for (DataTransferProcessorDescriptor processor : processors) {
if (processor.appliesToType(objectType)) {
return true;
}
}
return false;
}
/**
* Returns data exporter which supports ALL specified object types
* @param surceObjects object types
* @return list of editors
*/
public Collection<DataTransferProcessorDescriptor> getAvailableProcessors(Collection<DBSObject> surceObjects)
{
List<DataTransferProcessorDescriptor> editors = new ArrayList<>();
for (DataTransferProcessorDescriptor descriptor : processors) {
boolean supports = true;
for (DBSObject sourceObject : surceObjects) {
if (!descriptor.appliesToType(sourceObject.getClass())) {
boolean adapts = false;
if (sourceObject instanceof IAdaptable) {
if (descriptor.adaptsToType((IAdaptable)sourceObject)) {
adapts = true;
}
}
if (!adapts) {
supports = false;
break;
}
}
}
if (supports) {
editors.add(descriptor);
}
}
return editors;
}
public DataTransferProcessorDescriptor getProcessor(String id)
{
for (DataTransferProcessorDescriptor descriptor : processors) {
if (descriptor.getId().equals(id)) {
return descriptor;
}
}
return null;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.registry.transfer;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.app.DBPRegistryDescriptor;
import org.jkiss.dbeaver.model.impl.AbstractDescriptor;
import org.jkiss.dbeaver.model.impl.PropertyDescriptor;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
import java.util.ArrayList;
import java.util.List;
/**
* DataTransferProcessorDescriptor
*/
public class DataTransferProcessorDescriptor extends AbstractDescriptor implements DBPRegistryDescriptor<IDataTransferProcessor>
{
private final DataTransferNodeDescriptor node;
private final String id;
private final ObjectType processorType;
private final List<ObjectType> sourceTypes = new ArrayList<>();
private final String name;
private final String description;
@NotNull
private final DBPImage icon;
private final List<DBPPropertyDescriptor> properties = new ArrayList<>();
private boolean isBinary;
DataTransferProcessorDescriptor(DataTransferNodeDescriptor node, IConfigurationElement config)
{
super(config);
this.node = node;
this.id = config.getAttribute(RegistryConstants.ATTR_ID);
this.processorType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_CLASS));
this.name = config.getAttribute(RegistryConstants.ATTR_LABEL);
this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
this.icon = iconToImage(config.getAttribute(RegistryConstants.ATTR_ICON), DBIcon.TYPE_UNKNOWN);
this.isBinary = CommonUtils.getBoolean(config.getAttribute("binary"), false);
for (IConfigurationElement typeCfg : ArrayUtils.safeArray(config.getChildren(RegistryConstants.ATTR_SOURCE_TYPE))) {
sourceTypes.add(new ObjectType(typeCfg.getAttribute(RegistryConstants.ATTR_TYPE)));
}
for (IConfigurationElement prop : ArrayUtils.safeArray(config.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP))) {
properties.addAll(PropertyDescriptor.extractProperties(prop));
}
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
public String getDescription()
{
return description;
}
@NotNull
public DBPImage getIcon()
{
return icon;
}
public List<DBPPropertyDescriptor> getProperties() {
return properties;
}
boolean appliesToType(Class objectType)
{
if (sourceTypes.isEmpty()) {
return true;
}
for (ObjectType sourceType : sourceTypes) {
if (sourceType.matchesType(objectType)) {
return true;
}
}
return false;
}
public boolean adaptsToType(IAdaptable adaptable) {
if (sourceTypes.isEmpty()) {
return true;
}
for (ObjectType sourceType : sourceTypes) {
if (adaptable.getAdapter(sourceType.getObjectClass()) != null) {
return true;
}
}
return false;
}
public IDataTransferProcessor getInstance()
{
try {
processorType.checkObjectClass(IDataTransferProcessor.class);
Class<? extends IDataTransferProcessor> clazz = processorType.getObjectClass(IDataTransferProcessor.class);
return clazz.newInstance();
} catch (Exception e) {
throw new IllegalStateException("Can't instantiate data exporter", e);
}
}
public DataTransferNodeDescriptor getNode()
{
return node;
}
public boolean isBinaryFormat() {
return isBinary;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.registry.transfer;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.tools.transfer.IDataTransferNode;
import org.jkiss.utils.CommonUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
/**
* EntityEditorsRegistry
*/
public class DataTransferRegistry {
public static final String EXTENSION_ID = "org.jkiss.dbeaver.dataTransfer"; //$NON-NLS-1$
private static DataTransferRegistry instance = null;
private static final Log log = Log.getLog(DataTransferRegistry.class);
public synchronized static DataTransferRegistry getInstance()
{
if (instance == null) {
instance = new DataTransferRegistry(Platform.getExtensionRegistry());
}
return instance;
}
private List<DataTransferNodeDescriptor> nodes = new ArrayList<>();
private DataTransferRegistry(IExtensionRegistry registry)
{
// Load datasource providers from external plugins
IConfigurationElement[] extElements = registry.getConfigurationElementsFor(EXTENSION_ID);
for (IConfigurationElement ext : extElements) {
// Load main nodes
if (RegistryConstants.TAG_NODE.equals(ext.getName())) {
if (!CommonUtils.isEmpty(ext.getAttribute(RegistryConstants.ATTR_REF))) {
continue;
}
nodes.add(new DataTransferNodeDescriptor(ext));
}
}
// Load references
for (IConfigurationElement ext : extElements) {
if (RegistryConstants.TAG_NODE.equals(ext.getName())) {
String nodeReference = ext.getAttribute(RegistryConstants.ATTR_REF);
if (CommonUtils.isEmpty(nodeReference)) {
continue;
}
DataTransferNodeDescriptor refNode = getNodeById(nodeReference);
if (refNode == null) {
log.error("Referenced data transfer node '" + nodeReference + "' not found");
} else {
refNode.loadNodeConfigurations(ext);
}
}
}
nodes.sort(Comparator.comparing(DataTransferNodeDescriptor::getName));
}
public List<DataTransferNodeDescriptor> getAvailableProducers(Collection<DBSObject> sourceObjects)
{
return getAvailableNodes(DataTransferNodeDescriptor.NodeType.PRODUCER, sourceObjects);
}
public List<DataTransferNodeDescriptor> getAvailableConsumers(Collection<DBSObject> sourceObjects)
{
return getAvailableNodes(DataTransferNodeDescriptor.NodeType.CONSUMER, sourceObjects);
}
List<DataTransferNodeDescriptor> getAvailableNodes(DataTransferNodeDescriptor.NodeType nodeType, Collection<DBSObject> sourceObjects)
{
List<DataTransferNodeDescriptor> result = new ArrayList<>();
for (DataTransferNodeDescriptor node : nodes) {
if (node.getNodeType() == nodeType) {
for (DBSObject sourceObject : sourceObjects) {
if (node.appliesToType(sourceObject.getClass())) {
result.add(node);
break;
}
}
}
}
return result;
}
public DataTransferNodeDescriptor getNodeByType(Class<? extends IDataTransferNode> type)
{
for (DataTransferNodeDescriptor node : nodes) {
if (node.getNodeClass().equals(type)) {
return node;
}
}
return null;
}
public DataTransferNodeDescriptor getNodeById(String id)
{
for (DataTransferNodeDescriptor node : nodes) {
if (node.getId().equals(id)) {
return node;
}
}
return null;
}
}
......@@ -83,8 +83,6 @@ import org.jkiss.dbeaver.model.sql.*;
import org.jkiss.dbeaver.model.struct.DBSDataContainer;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSObjectSelector;
import org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationDescriptor;
import org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationRegistry;
import org.jkiss.dbeaver.runtime.sql.SQLQueryJob;
import org.jkiss.dbeaver.runtime.sql.SQLQueryListener;
import org.jkiss.dbeaver.runtime.sql.SQLResultsConsumer;
......@@ -105,6 +103,9 @@ import org.jkiss.dbeaver.ui.editors.EditorUtils;
import org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput;
import org.jkiss.dbeaver.ui.editors.StringEditorInput;
import org.jkiss.dbeaver.ui.editors.sql.log.SQLLogPanel;
import org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationDescriptor;
import org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor;
import org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationRegistry;
import org.jkiss.dbeaver.ui.editors.text.ScriptPositionColumn;
import org.jkiss.dbeaver.ui.views.SQLResultsView;
import org.jkiss.dbeaver.ui.views.plan.ExplainPlanViewer;
......@@ -139,6 +140,8 @@ public class SQLEditor extends SQLEditorBase implements
private static final int SQL_EDITOR_CONTROL_INDEX = 1;
private static final int EXTRA_CONTROL_INDEX = 0;
private static final String PANEL_ITEM_PREFIX = "SQLPanelToggle:";
private static Image IMG_DATA_GRID = DBeaverIcons.getImage(UIIcon.SQL_PAGE_DATA_GRID);
private static Image IMG_DATA_GRID_LOCKED = DBeaverIcons.getImage(UIIcon.SQL_PAGE_DATA_GRID_LOCKED);
private static Image IMG_EXPLAIN_PLAN = DBeaverIcons.getImage(UIIcon.SQL_PAGE_EXPLAIN_PLAN);
......@@ -149,6 +152,7 @@ public class SQLEditor extends SQLEditorBase implements
private static final String TOOLBAR_CONTRIBUTION_ID = "toolbar:org.jkiss.dbeaver.ui.editors.sql.toolbar.side";
private static final String TOOLBAR_GROUP_TOP = "top";
private static final String TOOLBAR_GROUP_ADDITIONS = IWorkbenchActionConstants.MB_ADDITIONS;
private static final String TOOLBAR_GROUP_PANELS = "panelToggles";
public static final String VAR_CONNECTION_NAME = "connectionName";
public static final String VAR_FILE_NAME = "fileName";
......@@ -590,6 +594,7 @@ public class SQLEditor extends SQLEditorBase implements
sideToolBar.add(new ToolbarSeparatorContribution(false));
sideToolBar.add(ActionUtils.makeCommandContribution(getSite(), CoreCommands.CMD_SQL_SHOW_OUTPUT, CommandContributionItem.STYLE_CHECK));
sideToolBar.add(ActionUtils.makeCommandContribution(getSite(), CoreCommands.CMD_SQL_SHOW_LOG, CommandContributionItem.STYLE_CHECK));
sideToolBar.add(new GroupMarker(TOOLBAR_GROUP_PANELS));
final IMenuService menuService = getSite().getService(IMenuService.class);
if (menuService != null) {
int prevSize = sideToolBar.getSize();
......@@ -753,6 +758,9 @@ public class SQLEditor extends SQLEditorBase implements
}
}
/////////////////////////////////////////////////////////////
// Panels
private void showExtraView(final String commandId, String name, String toolTip, Image image, Control view) {
ToolItem viewItem = getViewToolItem(commandId);
if (viewItem == null) {
......@@ -874,6 +882,29 @@ public class SQLEditor extends SQLEditorBase implements
presentationSash.setMaximizedControl(null);
}
}
// Show presentation panels
boolean sideBarChanged = false;
if (getExtraPresentationState() == SQLEditorPresentation.ActivationType.HIDDEN) {
// Remove all presentation panel toggles
for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
if (sideToolBar.remove(PANEL_ITEM_PREFIX + panelDescriptor.getId()) != null) {
sideBarChanged = true;
}
}
} else {
// Check and add presentation panel toggles
for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
if (sideToolBar.find(PANEL_ITEM_PREFIX + panelDescriptor.getId()) == null) {
sideBarChanged = true;
sideToolBar.insertAfter(TOOLBAR_GROUP_PANELS, new PresentationPanelToggleAction(panelDescriptor));
}
}
}
if (sideBarChanged) {
sideToolBar.update(true);
sideToolBar.getControl().getParent().layout(true);
}
}
private Control getExtraPresentationControl() {
......@@ -927,15 +958,6 @@ public class SQLEditor extends SQLEditorBase implements
}
}
@Override
public void init(IEditorSite site, IEditorInput editorInput)
throws PartInitException
{
super.init(site, editorInput);
updateResultSetOrientation();
}
private void updateResultSetOrientation() {
try {
resultSetOrientation = ResultSetOrientation.valueOf(getActivePreferenceStore().getString(SQLPreferenceConstants.RESULT_SET_ORIENTATION));
......@@ -947,6 +969,38 @@ public class SQLEditor extends SQLEditorBase implements
}
}
private class PresentationPanelToggleAction extends Action {
private SQLPresentationPanelDescriptor panel;
public PresentationPanelToggleAction(SQLPresentationPanelDescriptor panel) {
super(panel.getLabel(), Action.AS_CHECK_BOX);
setId(PANEL_ITEM_PREFIX + panel.getId());
if (panel.getIcon() != null) {
setImageDescriptor(DBeaverIcons.getImageDescriptor(panel.getIcon()));
}
if (panel.getDescription() != null) {
setToolTipText(panel.getDescription());
}
this.panel = panel;
}
@Override
public void run() {
}
}
/////////////////////////////////////////////////////////////
// Initialization
@Override
public void init(IEditorSite site, IEditorInput editorInput)
throws PartInitException
{
super.init(site, editorInput);
updateResultSetOrientation();
}
@Override
protected void doSetInput(IEditorInput editorInput)
{
......
......@@ -25,6 +25,8 @@ import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentation;
import org.jkiss.utils.CommonUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
......@@ -40,6 +42,7 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
private final ObjectType implClass;
private final DBPImage icon;
private final SQLEditorPresentation.ActivationType activationType;
private final List<SQLPresentationPanelDescriptor> panels = new ArrayList<>();
public SQLPresentationDescriptor(IConfigurationElement config)
{
......@@ -55,6 +58,11 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
} else {
this.activationType = SQLEditorPresentation.ActivationType.valueOf(activationStr.toUpperCase(Locale.ENGLISH));
}
for (IConfigurationElement panelConfig : config.getChildren("panel")) {
// Load functions
SQLPresentationPanelDescriptor presentationDescriptor = new SQLPresentationPanelDescriptor(panelConfig);
this.panels.add(presentationDescriptor);
}
}
public String getId() {
......@@ -77,6 +85,10 @@ public class SQLPresentationDescriptor extends AbstractContextDescriptor {
return activationType;
}
public List<SQLPresentationPanelDescriptor> getPanels() {
return panels;
}
public SQLEditorPresentation createPresentation()
throws DBException
{
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.editors.sql.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.registry.AbstractContextDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentation;
import org.jkiss.dbeaver.ui.editors.sql.SQLEditorPresentationPanel;
import org.jkiss.utils.CommonUtils;
import java.util.Locale;
/**
* SQLPresentationPanelDescriptor
*/
public class SQLPresentationPanelDescriptor extends AbstractContextDescriptor {
private final String id;
private final String label;
private final String description;
private final ObjectType implClass;
private final DBPImage icon;
private final boolean isSingleton;
public SQLPresentationPanelDescriptor(IConfigurationElement config)
{
super(config);
this.id = config.getAttribute(RegistryConstants.ATTR_ID);
this.label = config.getAttribute(RegistryConstants.ATTR_LABEL);
this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
this.implClass = new ObjectType(config.getAttribute(RegistryConstants.ATTR_CLASS));
this.icon = iconToImage(config.getAttribute(RegistryConstants.ATTR_ICON));
this.isSingleton = CommonUtils.getBoolean(config.getAttribute("singleton"), true);
}
public String getId() {
return id;
}
public String getLabel() {
return label;
}
public String getDescription() {
return description;
}
public DBPImage getIcon() {
return icon;
}
public boolean isSingleton() {
return isSingleton;
}
public SQLEditorPresentationPanel createPanel()
throws DBException
{
return implClass.createInstance(SQLEditorPresentationPanel.class);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册