提交 75c1087c 编写于 作者: S Serge Rider

Explain plan view refactoring

上级 fdf60288
......@@ -65,7 +65,7 @@ import org.jkiss.dbeaver.ui.editors.StringEditorInput;
import org.jkiss.dbeaver.ui.editors.SubEditorSite;
import org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.dbeaver.ui.views.plan.PlanNodesTree;
import org.jkiss.dbeaver.ui.editors.sql.plan.PlanNodesTree;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
......
......@@ -44,7 +44,6 @@ Export-Package: org.jkiss.dbeaver.runtime.sql,
org.jkiss.dbeaver.ui.editors.sql.syntax.tokens,
org.jkiss.dbeaver.ui.editors.sql.templates,
org.jkiss.dbeaver.ui.editors.sql.util,
org.jkiss.dbeaver.ui.views,
org.jkiss.dbeaver.ui.views.plan
org.jkiss.dbeaver.ui.editors.sql.plan
Bundle-ClassPath: .
......@@ -7,6 +7,7 @@
<extension-point id="org.jkiss.dbeaver.sqlCommand" name="%extension-point.org.jkiss.dbeaver.sqlCommand.name" schema="schema/org.jkiss.dbeaver.sqlCommand.exsd"/>
<extension-point id="org.jkiss.dbeaver.sqlPresentation" name="%extension-point.org.jkiss.dbeaver.sqlCommand.name" schema="schema/org.jkiss.dbeaver.sqlPresentation.exsd"/>
<extension-point id="org.jkiss.dbeaver.sqlFormatter" name="%extension-point.org.jkiss.dbeaver.sqlFormatter.name" schema="schema/org.jkiss.dbeaver.sqlFormatter.exsd"/>
<extension-point id="org.jkiss.dbeaver.sql.plan.view" name="%extension-point.org.jkiss.dbeaver.sqlPlanView.name" schema="schema/org.jkiss.dbeaver.sqlPlanView.exsd"/>
<extension point="org.eclipse.core.runtime.preferences">
<initializer class="org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorPreferencesInitializer"/>
......@@ -24,7 +25,7 @@
<view
id="org.jkiss.dbeaver.core.sqlResults"
category="org.jkiss.dbeaver.core.category"
class="org.jkiss.dbeaver.ui.views.SQLResultsView"
class="org.jkiss.dbeaver.ui.editors.sql.SQLResultsView"
allowMultiple="true"
icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/sql/page_data_grid.png"
name="%view.sql.results.title"/>
......@@ -50,6 +51,10 @@
<command id="include" class="org.jkiss.dbeaver.runtime.sql.commands.SQLCommandInclude" label="Include" description="Include another SQL script file"/>
</extension>
<extension point="org.jkiss.dbeaver.sql.plan.view">
<command id="simple" priority="100" class="org.jkiss.dbeaver.ui.editors.sql.plan.simple.SQLPlanViewerSimple" label="Simple" description="Simple execution plan presentation"/>
</extension>
<extension point="org.jkiss.dbeaver.sql.covert">
<target id="unformatted"
label="%sql.convert.unformatted.text.name"
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.jkiss.dbeaver.core" id="org.jkiss.dbeaver.sqlPlanView" name="SQL Plan View"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="view" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="view">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="identifier"/>
</appInfo>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.jkiss.dbeaver.model.data.DBDDataFormatter"/>
</appInfo>
</annotation>
</attribute>
<attribute name="configurerClass" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.jkiss.dbeaver.model.data.DBDDataFormatter"/>
</appInfo>
</annotation>
</attribute>
<attribute name="label" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
......@@ -110,8 +110,7 @@ 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.navigator.NavigatorUtils;
import org.jkiss.dbeaver.ui.views.SQLResultsView;
import org.jkiss.dbeaver.ui.views.plan.ExplainPlanViewer;
import org.jkiss.dbeaver.ui.editors.sql.plan.ExplainPlanViewer;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.PrefUtils;
import org.jkiss.dbeaver.utils.RuntimeUtils;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.views;
package org.jkiss.dbeaver.ui.editors.sql;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.views.plan;
package org.jkiss.dbeaver.ui.editors.sql.plan;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionManager;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.views.plan;
package org.jkiss.dbeaver.ui.editors.sql.plan;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.plan.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.impl.AbstractContextDescriptor;
import org.jkiss.utils.CommonUtils;
/**
* SQLPlanViewDescriptor
*/
public class SQLPlanViewDescriptor extends AbstractContextDescriptor {
private final String id;
private final String label;
private final String description;
private final int priority;
private final ObjectType implClass;
private final DBPImage icon;
SQLPlanViewDescriptor(IConfigurationElement config) {
super(config);
this.id = config.getAttribute("id");
this.label = config.getAttribute("label");
this.description = config.getAttribute("description");
this.implClass = new ObjectType(config.getAttribute("class"));
this.icon = iconToImage(config.getAttribute("icon"));
this.priority = CommonUtils.toInt(config.getAttribute("priority"));
}
public String getId() {
return id;
}
public String getLabel() {
return label;
}
public String getDescription() {
return description;
}
public DBPImage getIcon() {
return icon;
}
public int getPriority() {
return priority;
}
public <T> T createInstance(Class<T> type) throws DBException {
return implClass.createInstance(type);
}
@Override
public String toString() {
return id;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.plan.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
* SQLPlanViewRegistry
*/
public class SQLPlanViewRegistry {
public static final String EXTENSION_ID = "org.jkiss.dbeaver.sql.plan.view"; //NON-NLS-1 //$NON-NLS-1$
private static final String TAG_VIEW = "view"; //NON-NLS-1
private static SQLPlanViewRegistry instance;
public synchronized static SQLPlanViewRegistry getInstance() {
if (instance == null) {
instance = new SQLPlanViewRegistry(Platform.getExtensionRegistry());
}
return instance;
}
private List<SQLPlanViewDescriptor> planViewDescriptors = new ArrayList<>();
private SQLPlanViewRegistry(IExtensionRegistry registry)
{
// Load target converters
IConfigurationElement[] panelElements = registry.getConfigurationElementsFor(EXTENSION_ID);
for (IConfigurationElement ext : panelElements) {
if (TAG_VIEW.equals(ext.getName())) {
SQLPlanViewDescriptor descriptor = new SQLPlanViewDescriptor(ext);
planViewDescriptors.add(descriptor);
}
}
}
@NotNull
public List<SQLPlanViewDescriptor> getPlanViewDescriptors() {
List<SQLPlanViewDescriptor> result = new ArrayList<>(planViewDescriptors);
result.sort(Comparator.comparingInt(SQLPlanViewDescriptor::getPriority));
return result;
}
@Nullable
public SQLPlanViewDescriptor getPlanViewDescriptor(String id) {
for (SQLPlanViewDescriptor converter : planViewDescriptors) {
if (converter.getId().equals(id)) {
return converter;
}
}
return null;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册