提交 39899db0 编写于 作者: S serge-rider

Debug dropdowns redesign

上级 d46de710
......@@ -20,7 +20,6 @@ package org.jkiss.dbeaver.ui.actions.datasource;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.ui.actions.CompoundContributionItem;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ui.actions.common.EmptyListAction;
import java.util.ArrayList;
......@@ -28,8 +27,6 @@ import java.util.List;
public abstract class DataSourceMenuContributor extends CompoundContributionItem
{
private static final Log log = Log.getLog(DataSourceMenuContributor.class);
@Override
protected IContributionItem[] getContributionItems()
{
......
......@@ -35,6 +35,8 @@ commands.command.menuDelegateToolbar.description=Debug last launched database ob
commands.command.debugConfigurations.name=Database debug ...
commands.command.debugConfigurations.description=Open database debug launch configuration dialog
toolbar.debug.label=Database Debug
actionSets.actionSet.label=Database Debug actions
actionSets.actionSet.menu.debug.label=Database Debug
actionSets.action.menu.label=Database Debug
......
......@@ -110,67 +110,48 @@
</detailFactories>
</extension>
<extension point="org.eclipse.ui.commands">
<category description="Database Debug commands" id="org.jkiss.dbeaver.debug.ui.commands.category" name="Database Debug"/>
<command
name="%commands.command.menuDelegateToolbar.name"
description="%commands.command.menuDelegateToolbar.description"
id="org.jkiss.dbeaver.debug.ui.command.debugConfigurationMenu">
</command>
</extension>
<extension point="org.eclipse.ui.commandImages">
<image commandId="org.jkiss.dbeaver.debug.ui.command.debugConfigurationMenu" icon="platform:/plugin/org.eclipse.debug.ui/$nl$/icons/full/obj16/ldebug_obj.png"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint" class="org.jkiss.dbeaver.debug.ui.actions.ToggleBreakpointHandler"/>
<handler commandId="org.jkiss.dbeaver.debug.ui.command.debugConfigurationMenu" class="org.jkiss.dbeaver.debug.ui.actions.OpenDebugConfigurationHandler"/>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution allPopups="false" locationURI="popup:#SQLRulerContext?before=additions">
<command commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint" label="%command.ToggleBreakpoint.label" style="push"/>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<category description="Database Debug commands" id="org.jkiss.dbeaver.debug.ui.commands.category" name="Database Debug"/>
<menuContribution allPopups="false" locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="dbeaver-debug" label="%toolbar.debug.label">
<command commandId="org.jkiss.dbeaver.debug.ui.command.debugConfigurationMenu" id="org.jkiss.dbeaver.debug.ui.menu.pulldown"
label="%actionSets.action.toolbar.label"
tooltip="%actionSets.action.toolbar.tooltip" style="pulldown">
<visibleWhen>
<reference definitionId="DBeaverPerspectiveActive"/>
</visibleWhen>
</command>
<separator name="additions" visible="false"/>
</toolbar>
</menuContribution>
<command
name="%commands.command.menuDelegateToolbar.name"
description="%commands.command.menuDelegateToolbar.description"
categoryId="org.jkiss.dbeaver.debug.ui.commands.category"
id="org.jkiss.dbeaver.debug.ui.commands.command.menuDelegateToolbar">
</command>
<command
name="%commands.command.debugConfigurations.name"
categoryId="org.jkiss.dbeaver.debug.ui.commands.category"
description="%commands.command.debugConfigurations.description"
id="org.jkiss.dbeaver.debug.ui.commands.command.debugConfigurations">
</command>
</extension>
<menuContribution allPopups="false" locationURI="menu:org.jkiss.dbeaver.debug.ui.menu.pulldown">
<dynamic id="org.jkiss.dbeaver.debug.ui.menu.configuration" class="org.jkiss.dbeaver.debug.ui.internal.DebugConfigurationMenuContributor"/>
</menuContribution>
<extension point="org.eclipse.ui.actionSets">
<actionSet label="%actionSets.actionSet.label" visible="true" id="org.jkiss.dbeaver.debug.actionSet">
<!-- Do we need an entry in main menu? I guess not -->
<!--
<menu label="%actionSets.actionSet.menu.debug.label" path="additions" id="org.eclipse.ui.debug">
<separator name="org.jkiss.dbeaver.debug.group"/>
</menu>
<action
label="%actionSets.action.menu.label"
style="pulldown"
icon="platform:/plugin/org.eclipse.debug.ui/$nl$/icons/full/obj16/ldebug_obj.png"
class="org.jkiss.dbeaver.debug.ui.internal.DebugMenuDelegate"
menubarPath="org.eclipse.ui.debug/org.jkiss.dbeaver.debug.group"
id="org.jkiss.dbeaver.debug.ui.actionSets.action.menuAction">
</action>
-->
<action
definitionId="org.jkiss.dbeaver.debug.ui.commands.command.menuDelegateToolbar"
label="%actionSets.action.toolbar.label"
style="pulldown"
icon="platform:/plugin/org.eclipse.debug.ui/$nl$/icons/full/obj16/ldebug_obj.png"
tooltip="%actionSets.action.toolbar.tooltip"
class="org.jkiss.dbeaver.debug.ui.internal.DebugMenuDelegate"
toolbarPath="org.eclipse.debug.ui.launchActionSet/debug"
id="org.jkiss.dbeaver.debug.ui.actionSets.action.debugToolbar">
</action>
<action
definitionId="org.jkiss.dbeaver.debug.ui.commands.command.debugConfigurations"
label="%actionSets.action.debugConfigurations.label"
class="org.jkiss.dbeaver.debug.ui.internal.DebugLaunchDialogAction"
id="org.jkiss.dbeaver.debug.ui.actionSets.action.debugConfigurations">
</action>
</actionSet>
</extension>
</plugin>
/*
* 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.debug.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
import org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Event;
import org.jkiss.dbeaver.debug.ui.DebugUI;
import org.jkiss.dbeaver.debug.ui.internal.DebugLaunchDialogAction;
public class OpenDebugConfigurationHandler extends AbstractHandler implements IHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (LaunchingResourceManager.isContextLaunchEnabled(DebugUI.DEBUG_LAUNCH_GROUP_ID)) {
ContextRunner.getDefault().launch(
DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(
DebugUI.DEBUG_LAUNCH_GROUP_ID),
false);
}
else {
ILaunchConfiguration configuration = getLastLaunch();
if (configuration == null) {
DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), DebugUI.DEBUG_LAUNCH_GROUP_ID);
} else {
DebugUITools.launch(configuration, "debug", false);
}
}
DebugLaunchDialogAction action = new DebugLaunchDialogAction();
action.run();
return null;
}
protected ILaunchConfiguration getLastLaunch() {
return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(DebugUI.DEBUG_LAUNCH_GROUP_ID);
}
}
/*
* 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.debug.ui.internal;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.actions.LaunchAction;
import org.eclipse.debug.ui.actions.LaunchShortcutsAction;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.Separator;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.debug.ui.DebugUI;
import org.jkiss.dbeaver.ui.ActionUtils;
import org.jkiss.dbeaver.ui.actions.datasource.DataSourceMenuContributor;
import java.util.List;
public class DebugConfigurationMenuContributor extends DataSourceMenuContributor
{
private static final Log log = Log.getLog(DebugConfigurationMenuContributor.class);
@Override
protected void fillContributionItems(final List<IContributionItem> menuItems)
{
// Fill recent debugs
LaunchConfigurationManager launchConfigurationManager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
LaunchHistory launchHistory = launchConfigurationManager.getLaunchHistory(DebugUI.DEBUG_LAUNCH_GROUP_ID);
ILaunchConfiguration[] filteredConfigs = LaunchConfigurationManager.filterConfigs(launchHistory.getHistory());
for (ILaunchConfiguration launch : filteredConfigs) {
LaunchAction action = new LaunchAction(launch, "debug");
menuItems.add(new ActionContributionItem(action));
}
// Fill configuration actions
if (filteredConfigs.length > 0) {
menuItems.add(new Separator());
}
menuItems.add(new ActionContributionItem(new LaunchShortcutsAction(DebugUI.DEBUG_LAUNCH_GROUP_ID)));
menuItems.add(new ActionContributionItem(new DebugLaunchDialogAction()));
}
}
\ No newline at end of file
......@@ -18,17 +18,3 @@
Bundle-Vendor = JKISS
Bundle-Name = DBeaver PostgreSQL Debug UI
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
......@@ -33,72 +33,6 @@
</panel>
</extension>
<!--
<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"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.launchShortcuts.shortcut.pgSQL.local"
label="%launchShortcuts.shortcut.pgSQL.global.label"
modes="debug">
<configurationType id="org.jkiss.dbeaver.ext.postgresql.debug.core.pgSQL"/>
<contextualLaunch>
<contextLabel label="%launchShortcuts.shortcut.pgSQL.global.label" mode="debug">
</contextLabel>
<enablement>
<with variable="selection">
<count value="1"/>
<iterate ifEmpty="false" operator="and">
<adapt type="org.jkiss.dbeaver.model.struct.DBSObject">
<instanceof value="org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure"/>
</adapt>
</iterate>
</with>
</enablement>
</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"
id="org.jkiss.dbeaver.ext.postgresql.debug.ui.launchShortcuts.shortcut.pgSQL.local"
label="%launchShortcuts.shortcut.pgSQL.local.label"
modes="debug">
<configurationType id="org.jkiss.dbeaver.ext.postgresql.debug.core.pgSQL"/>
<contextualLaunch>
<contextLabel label="%launchShortcuts.shortcut.pgSQL.local.label" mode="debug"/>
<enablement>
<with variable="selection">
<count value="1"/>
<iterate ifEmpty="false" operator="and">
<adapt type="org.jkiss.dbeaver.model.struct.DBSObject">
<instanceof value="org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure"/>
</adapt>
</iterate>
</with>
</enablement>
</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">
<factory adaptableType="org.jkiss.dbeaver.ext.postgresql.ui.editors.PostgreSourceViewEditor" class="org.jkiss.dbeaver.debug.ui.actions.DebugActionAdapterFactory">
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
......@@ -128,66 +62,4 @@
</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"/>
</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>
/*
* 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;
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);
}
}
/*
* 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.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.InputDialog;
import org.jkiss.dbeaver.debug.ui.DatabaseLaunchShortcut;
import org.jkiss.dbeaver.ext.postgresql.debug.PostgreDebugConstants;
import org.jkiss.dbeaver.ext.postgresql.debug.core.PostgreSqlDebugCore;
import org.jkiss.dbeaver.model.struct.DBSObject;
import java.util.Map;
public class PgSqlGlobalLaunchShortcut extends DatabaseLaunchShortcut {
public PgSqlGlobalLaunchShortcut() {
super(PostgreSqlDebugCore.CONFIGURATION_TYPE, PostgreDebugUIMessages.PgSqlLaunchShortcut_name);
}
@Override
protected ILaunchConfiguration createConfiguration(DBSObject launchable) throws CoreException {
ILaunchConfigurationWorkingCopy workingCopy = PostgreSqlDebugCore.createConfiguration(launchable);
workingCopy.setAttribute(PostgreDebugConstants.ATTR_ATTACH_KIND, PostgreDebugConstants.ATTACH_KIND_GLOBAL);
String pid = workingCopy.getAttribute(PostgreDebugConstants.ATTR_ATTACH_PROCESS, (String)null);
String dialogTitle = "Specify PID";
String dialogMessage = "Specify PID to attach. Use '-1' to allow any PID";
InputDialog dialog = new InputDialog(getShell(), dialogTitle, dialogMessage, pid, newText -> {
String error = "PID should be positive number or '-1' for any PID";
try {
Integer integer = Integer.parseInt(newText);
if (integer < -1) {
return error;
}
} catch (Exception e) {
return error;
}
return null;
});
dialog.create();
int open = dialog.open();
if (IDialogConstants.CANCEL_ID == open) {
return null;
}
String modified = dialog.getValue();
workingCopy.setAttribute(PostgreDebugConstants.ATTR_ATTACH_PROCESS, modified);
return workingCopy.doSave();
}
@Override
protected boolean isCandidate(ILaunchConfiguration config, DBSObject launchable, Map<String, Object> databaseContext) {
try {
String kind = config.getAttribute(PostgreDebugConstants.ATTR_ATTACH_KIND, (String)null);
if (!PostgreDebugConstants.ATTACH_KIND_LOCAL.equals(kind)) {
return false;
}
} catch (CoreException e) {
return false;
}
return super.isCandidate(config, launchable, databaseContext);
}
}
/*
* 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.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.jkiss.dbeaver.debug.ui.DatabaseLaunchShortcut;
import org.jkiss.dbeaver.debug.ui.DatabaseScriptDialog;
import org.jkiss.dbeaver.ext.postgresql.debug.PostgreDebugConstants;
import org.jkiss.dbeaver.ext.postgresql.debug.core.PostgreSqlDebugCore;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.utils.GeneralUtils;
import java.util.Map;
public class PgSqlLocalLaunchShortcut extends DatabaseLaunchShortcut {
public PgSqlLocalLaunchShortcut() {
super(PostgreSqlDebugCore.CONFIGURATION_TYPE, PostgreDebugUIMessages.PgSqlLaunchShortcut_name);
}
@Override
protected ILaunchConfiguration createConfiguration(DBSObject launchable) throws CoreException {
/*
ILaunchConfigurationWorkingCopy workingCopy = PostgreSqlDebugCore.createConfiguration(launchable);
workingCopy.setAttribute(PostgreDebugConstants.ATTR_ATTACH_KIND, PostgreDebugConstants.ATTACH_KIND_LOCAL);
IWorkbenchPartSite site = getWorkbenchPartSite();
String script = workingCopy.getAttribute(PostgreDebugConstants.ATTR_SCRIPT_TEXT, "");
String inputName = "Script";
DatabaseScriptDialog dialog = new DatabaseScriptDialog(getShell(), site, inputName, script, launchable);
dialog.create();
dialog.setTitle("Specify script to be executed");
dialog.setMessage("Specify script to be executed to start debug.");
int open = dialog.open();
if (IDialogConstants.CANCEL_ID == open) {
return null;
}
String modified = dialog.getScriptTextValue();
workingCopy.setAttribute(PostgreDebugConstants.ATTR_SCRIPT_TEXT, modified);
return workingCopy.doSave();
*/
throw new CoreException(GeneralUtils.makeErrorStatus("Not implemented"));
}
@Override
protected boolean isCandidate(ILaunchConfiguration config, DBSObject launchable, Map<String, Object> databaseContext) {
try {
String kind = config.getAttribute(PostgreDebugConstants.ATTR_ATTACH_KIND, (String)null);
if (!PostgreDebugConstants.ATTACH_KIND_LOCAL.equals(kind)) {
return false;
}
} catch (CoreException e) {
return false;
}
return super.isCandidate(config, launchable, databaseContext);
}
}
/*
* 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);
}
}
/*
* 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.osgi.util.NLS;
public class PostgreDebugUIMessages extends NLS {
private static final String BUNDLE_NAME = "org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PostgreDebugUIMessages"; //$NON-NLS-1$
public static String PgSqlLaunchShortcut_name;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, PostgreDebugUIMessages.class);
}
private PostgreDebugUIMessages() {
}
}
# 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.
PgSqlLaunchShortcut_name=PL/pgSQL
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册