提交 2e25f541 编写于 作者: A Alexander Fedorov

#3255 add 3.x style contributions supported by org.eclipse.debug

上级 5486e33e
......@@ -72,10 +72,17 @@ public abstract class DBGBaseController implements DBGController {
@Override
public Object attach(DBRProgressMonitor monitor) throws DBGException {
DBPDataSource dataSource = dataSourceContainer.getDataSource();
if (!dataSourceContainer.isConnected()) {
try {
dataSourceContainer.connect(monitor, true, true);
} catch (DBException e) {
throw new DBGException(e, dataSourceContainer.getDataSource());
}
}
if (!dataSourceContainer.isConnected()) {
throw new DBGException("Not connected to database");
}
DBPDataSource dataSource = dataSourceContainer.getDataSource();
try {
this.executionContext = dataSource.openIsolatedContext(monitor, "Debug controller");
DBGSessionInfo targetInfo = getSessionDescriptor(getExecutionContext());
......@@ -127,7 +134,9 @@ public abstract class DBGBaseController implements DBGController {
@Override
public void dispose() {
executionContext.close();
if (executionContext != null) {
executionContext.close();
}
Collection<DBGBaseSession> values = sessions.values();
for (DBGBaseSession session : values) {
try {
......
......@@ -313,7 +313,7 @@ public class DebugCore {
return null;
}
final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
DBNDatabaseNode node = navigatorModel.getNodeByObject(dbsObject);
DBNDatabaseNode node = navigatorModel.getNodeByObject(new VoidProgressMonitor(), dbsObject, false);
if (node != null) {
String nodePath = node.getNodeItemPath();
DebugCore.postDebuggerSourceEvent(nodePath);
......
......@@ -97,5 +97,13 @@
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
description="Debug Procedure commands"
id="org.jkiss.dbeaver.debug.ui.commands.category.procedure"
name="Debug Procedure">
</category>
</extension>
</plugin>
......@@ -36,6 +36,7 @@ import org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint;
import org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint;
import org.jkiss.dbeaver.debug.ui.DebugUI;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.ide.core.DBeaverIDECore;
......@@ -62,7 +63,7 @@ public class ToggleProcedureBreakpointTarget implements IToggleBreakpointsTarget
if (databaseObject == null) {
return;
}
DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(databaseObject);
DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(new VoidProgressMonitor(), databaseObject, false);
if (node == null) {
return;
}
......
......@@ -22,6 +22,7 @@
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
category="org.jkiss.dbeaver.ext.postgresql.debug.ui.pgSQL"
delegate="org.jkiss.dbeaver.debug.core.DatabaseLaunchDelegate"
delegateDescription="%launchConfigurationTypes.launchConfigurationType.pgSQL.delegateDescription"
delegateName="%launchConfigurationTypes.launchConfigurationType.pgSQL.delegateName"
......
......@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
public class PostgreSqlDebugCore {
......@@ -71,7 +72,7 @@ public class PostgreSqlDebugCore {
workingCopy.setAttribute(DebugCore.ATTR_SCRIPT_EXECUTE, DebugCore.ATTR_SCRIPT_EXECUTE_DEFAULT);
workingCopy.setAttribute(DebugCore.ATTR_SCRIPT_TEXT, DebugCore.composeScriptText(procedure));
final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
DBNDatabaseNode node = navigatorModel.getNodeByObject(procedure);
DBNDatabaseNode node = navigatorModel.getNodeByObject(new VoidProgressMonitor(), procedure, false);
workingCopy.setAttribute(DebugCore.ATTR_NODE_PATH, node.getNodeItemPath());
return workingCopy;
}
......
......@@ -11,4 +11,5 @@ Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.debug.core,
org.jkiss.dbeaver.debug.ui,
org.jkiss.dbeaver.ext.postgresql,
org.jkiss.dbeaver.ext.postgresql.debug.core
org.jkiss.dbeaver.ext.postgresql.debug.core,
org.eclipse.ui
......@@ -27,3 +27,20 @@ launchShortcuts.shortcut.pgSQL.global.description=PL/pgSQL global debug for Post
launchShortcuts.shortcut.pgSQL.local.label=PL/pgSQL (Local)
launchShortcuts.shortcut.pgSQL.local.description=PL/pgSQL local debug for PostgreSQL procedures
launchGroups.launchGroup.pgSQL.label = PL/pgSQL Debug
launchGroups.launchGroup.pgSQL.title = Select or configure PL/pgSQL procedure to debug
actions.ManageBreakpointRulerAction.label = Toggle &Breakpoint
actionSets.actionSet.pgSQL.label=PL/pgSQL Debug
actionSets.actionSet.menu.debug.label=Debug
actionSets.action.pgSQLMenu.label=PL/pgSQL
actionSets.action.pgSQLToolbar.label=PL/pgSQL
actionSets.action.pgSQLToolbar.tooltip=Debug Last PL/pgSQL
actionSets.action.pgSQLConfigurations.label=PL/pgSQL ...
commands.command.pgSQLMenuDelegateToolbar.name=Debug Last Launched PL/pgSQL Procedure
commands.command.pgSQLMenuDelegateToolbar.description=Debugs the last launched PL/pgSQL procedure
commands.command.pgSQLConfigurations.name=PL/pgSQL ...
commands.command.pgSQLConfigurations.description=Open PL/pgSQL procedure launch configuration dialog
......@@ -42,6 +42,7 @@
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
category="org.jkiss.dbeaver.ext.postgresql.debug.ui.pgSQL"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlGlobalLaunchShortcut"
description="%launchShortcuts.shortcut.pgSQL.global.description"
icon="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
......@@ -76,6 +77,7 @@
</contextualLaunch>
</shortcut>
<shortcut
category="org.jkiss.dbeaver.ext.postgresql.debug.ui.pgSQL"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlLocalLaunchShortcut"
description="%launchShortcuts.shortcut.pgSQL.local.description"
icon="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
......@@ -110,6 +112,18 @@
</contextualLaunch>
</shortcut>
</extension>
<extension
point="org.eclipse.debug.ui.launchGroups">
<launchGroup
bannerImage="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
category="org.jkiss.dbeaver.ext.postgresql.debug.ui.pgSQL"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.launchGroups.launchGroup.pgSQL"
image="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
label="%launchGroups.launchGroup.pgSQL.label"
mode="debug"
title="%launchGroups.launchGroup.pgSQL.title">
</launchGroup>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
......@@ -139,10 +153,77 @@
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
icon="platform:/plugin/org.eclipse.debug.ui/$nl$/icons/full/obj16/brkp_obj.png"
id="org.jkiss.dbeaver.debug.ui.actions.ManageBreakpointRulerAction"
label="Toggle &amp;Breakpoint"
label="%actions.ManageBreakpointRulerAction.label"
style="push">
</action>
</editorContribution>
</extension>
<!-- it should be done undeprecated way if org.eclipse.debug will follow it ever
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlDebugContributionFactory"
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
</menuContribution>
</extension>
-->
<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="%actionSets.actionSet.pgSQL.label"
visible="true"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.actionSets.actionSet.pgSQL">
<menu
label="%actionSets.actionSet.menu.debug.label"
path="additions"
id="org.eclipse.ui.debug">
<separator
name="pgSQLGroup">
</separator>
</menu>
<action
label="%actionSets.action.pgSQLMenu.label"
style="pulldown"
icon="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlMenuDelegate"
menubarPath="org.eclipse.ui.debug/pgSQLGroup"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.actionSets.action.pgSQLMenu">
</action>
<action
definitionId="org.jkiss.dbeaver.ext.postgresql.debug.ui.commands.command.pgSQLMenuDelegateToolbar"
label="%actionSets.action.pgSQLToolbar.label"
style="pulldown"
icon="platform:/plugin/org.jkiss.dbeaver.ext.postgresql/$nl$/icons/postgresql_icon.png"
tooltip="%actionSets.action.pgSQLToolbar.tooltip"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlMenuDelegate"
toolbarPath="org.eclipse.debug.ui.launchActionSet/debug"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.actionSets.action.pgSQLToolbar">
</action>
<action
definitionId="org.jkiss.dbeaver.ext.postgresql.debug.ui.commands.command.pgSQLConfigurations"
label="%actionSets.action.pgSQLConfigurations.label"
class="org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PgSqlOpenLaunchDialogAction"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.actionSets.action.pgSQLConfigurations">
</action>
</actionSet>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
name="%commands.command.pgSQLMenuDelegateToolbar.name"
description="%commands.command.pgSQLMenuDelegateToolbar.description"
categoryId="org.jkiss.dbeaver.debug.ui.commands.category.procedure"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.commands.command.pgSQLMenuDelegateToolbar">
</command>
<command
name="%commands.command.pgSQLConfigurations.name"
categoryId="org.jkiss.dbeaver.debug.ui.commands.category.procedure"
description="%commands.command.pgSQLConfigurations.description"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.commands.command.pgSQLConfigurations">
</command>
</extension>
</plugin>
......@@ -21,4 +21,10 @@ public class PostgreSqlDebugUi {
public static final String BUNDLE_SYMBOLIC_NAME = "org.jkiss.dbeaver.ext.postgresql.debug.ui"; //$NON-NLS-1$
public static final String DEBUG_PGSQL_DEBUG_AS_MENU_ID = "org.jkiss.dbeaver.debug.ui.menus.menuContribution.procedure"; //$NON-NLS-1$
public static final String DEBUG_PGSQL_LAUNCH_GROUP_ID = "org.jkiss.dbeaver.ext.postgresql.debug.ui.launchGroups.launchGroup.pgSQL"; //$NON-NLS-1$
public static final String DEBUG_PGSQL_OPEN_CONFIGURATIONS_COMMAND_ID = "org.jkiss.dbeaver.ext.postgresql.debug.ui.commands.command.pgSQLConfigurations"; //$NON-NLS-1$
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017-2018 Alexander Fedorov (alexander.fedorov@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.ext.postgresql.debug.ui.internal;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.jkiss.dbeaver.debug.ui.DatabaseLaunchContributionFactory;
import org.jkiss.dbeaver.debug.ui.DatabaseLaunchContributionItem;
import org.jkiss.dbeaver.ext.postgresql.debug.ui.PostgreSqlDebugUi;
public class PgSqlDebugContributionFactory extends DatabaseLaunchContributionFactory {
public PgSqlDebugContributionFactory() {
super(PostgreSqlDebugUi.DEBUG_PGSQL_DEBUG_AS_MENU_ID);
setText("PL/pgSQL Debug");
setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_ACT_DEBUG));
}
@Override
protected DatabaseLaunchContributionItem createContributionItem() {
return new PgSqlDebugContributionItem();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017-2018 Alexander Fedorov (alexander.fedorov@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.ext.postgresql.debug.ui.internal;
import org.eclipse.debug.core.ILaunchManager;
import org.jkiss.dbeaver.debug.ui.DatabaseLaunchContributionItem;
public class PgSqlDebugContributionItem extends DatabaseLaunchContributionItem {
protected PgSqlDebugContributionItem() {
super(ILaunchManager.DEBUG_MODE);
}
}
......@@ -57,7 +57,6 @@ public class PgSqlGlobalLaunchShortcut extends DatabaseLaunchShortcut {
} catch (Exception e) {
return error;
}
// TODO Auto-generated method stub
return null;
}
});
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017-2018 Alexander Fedorov (alexander.fedorov@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.ext.postgresql.debug.ui.internal;
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
import org.eclipse.jface.action.IAction;
import org.jkiss.dbeaver.ext.postgresql.debug.ui.PostgreSqlDebugUi;
public class PgSqlMenuDelegate extends AbstractLaunchToolbarAction {
public PgSqlMenuDelegate() {
super(PostgreSqlDebugUi.DEBUG_PGSQL_LAUNCH_GROUP_ID);
}
@Override
protected IAction getOpenDialogAction() {
return new PgSqlOpenLaunchDialogAction();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
* Copyright (C) 2017-2018 Alexander Fedorov (alexander.fedorov@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.ext.postgresql.debug.ui.internal;
import org.eclipse.debug.ui.actions.OpenLaunchDialogAction;
import org.jkiss.dbeaver.ext.postgresql.debug.ui.PostgreSqlDebugUi;
public class PgSqlOpenLaunchDialogAction extends OpenLaunchDialogAction {
public PgSqlOpenLaunchDialogAction() {
super(PostgreSqlDebugUi.DEBUG_PGSQL_LAUNCH_GROUP_ID);
setActionDefinitionId(PostgreSqlDebugUi.DEBUG_PGSQL_OPEN_CONFIGURATIONS_COMMAND_ID);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册