提交 21cafb2d 编写于 作者: S Serge Rider

SQLPlan adapter

上级 e925d1c9
...@@ -1528,7 +1528,7 @@ public class SQLEditor extends SQLEditorBase implements ...@@ -1528,7 +1528,7 @@ public class SQLEditor extends SQLEditorBase implements
private void explainQueryPlan(SQLQuery sqlQuery) private void explainQueryPlan(SQLQuery sqlQuery)
{ {
// 1. Determine whether planner supports plan extraction // 1. Determine whether planner supports plan extraction
DBCQueryPlanner planner = DBUtils.getAdapter(DBCQueryPlanner.class, getDataSource()); DBCQueryPlanner planner = GeneralUtils.adapt(getDataSource(), DBCQueryPlanner.class);
if (planner == null) { if (planner == null) {
DBWorkbench.getPlatformUI().showError("Execution plan", "Execution plan explain isn't supported by current datasource"); DBWorkbench.getPlatformUI().showError("Execution plan", "Execution plan explain isn't supported by current datasource");
return; return;
......
...@@ -27,6 +27,7 @@ import org.jkiss.dbeaver.model.DBUtils; ...@@ -27,6 +27,7 @@ import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlanner; import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlanner;
import org.jkiss.dbeaver.ui.ActionUtils; import org.jkiss.dbeaver.ui.ActionUtils;
import org.jkiss.dbeaver.ui.editors.text.parser.SQLIdentifierDetector; import org.jkiss.dbeaver.ui.editors.text.parser.SQLIdentifierDetector;
import org.jkiss.dbeaver.utils.GeneralUtils;
/** /**
* SQLEditorPropertyTester * SQLEditorPropertyTester
...@@ -62,7 +63,7 @@ public class SQLEditorPropertyTester extends PropertyTester ...@@ -62,7 +63,7 @@ public class SQLEditorPropertyTester extends PropertyTester
// Do not check hasActiveQuery - sometimes jface don't update action enablement after cursor change/typing // Do not check hasActiveQuery - sometimes jface don't update action enablement after cursor change/typing
return true;/* && (!"statement".equals(expectedValue) || editor.hasActiveQuery())*/ return true;/* && (!"statement".equals(expectedValue) || editor.hasActiveQuery())*/
case PROP_CAN_EXPLAIN: case PROP_CAN_EXPLAIN:
return hasConnection && DBUtils.getAdapter(DBCQueryPlanner.class, editor.getDataSource()) != null; return hasConnection && GeneralUtils.adapt(editor.getDataSource(), DBCQueryPlanner.class) != null;
case PROP_CAN_NAVIGATE: { case PROP_CAN_NAVIGATE: {
// Check whether some word is under cursor // Check whether some word is under cursor
ISelectionProvider selectionProvider = editor.getSelectionProvider(); ISelectionProvider selectionProvider = editor.getSelectionProvider();
......
...@@ -57,6 +57,7 @@ import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorActivator; ...@@ -57,6 +57,7 @@ import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorActivator;
import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages; import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages;
import org.jkiss.dbeaver.ui.editors.sql.plan.registry.SQLPlanViewDescriptor; import org.jkiss.dbeaver.ui.editors.sql.plan.registry.SQLPlanViewDescriptor;
import org.jkiss.dbeaver.ui.editors.sql.plan.registry.SQLPlanViewRegistry; import org.jkiss.dbeaver.ui.editors.sql.plan.registry.SQLPlanViewRegistry;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
...@@ -228,7 +229,7 @@ public class ExplainPlanViewer extends Viewer implements IAdaptable ...@@ -228,7 +229,7 @@ public class ExplainPlanViewer extends Viewer implements IAdaptable
DBCExecutionContext executionContext = contextProvider.getExecutionContext(); DBCExecutionContext executionContext = contextProvider.getExecutionContext();
if (executionContext != null) { if (executionContext != null) {
DBPDataSource dataSource = executionContext.getDataSource(); DBPDataSource dataSource = executionContext.getDataSource();
planner = DBUtils.getAdapter(DBCQueryPlanner.class, dataSource); planner = GeneralUtils.adapt(dataSource, DBCQueryPlanner.class);
} else { } else {
planner = null; planner = null;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册