Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2007-04-10 19:28:22 +0000
committerJohn Cortell2007-04-10 19:28:22 +0000
commit2ef0a883982ac6707a39d610ad91ee83bbec4e5c (patch)
tree95c527faaa0373d2f43a418898fb1ffa59222157 /debug/org.eclipse.cdt.debug.ui
parent5cf3a081fbf4bbce360fad5973d852fa4cc232b6 (diff)
downloadorg.eclipse.cdt-2ef0a883982ac6707a39d610ad91ee83bbec4e5c.tar.gz
org.eclipse.cdt-2ef0a883982ac6707a39d610ad91ee83bbec4e5c.tar.xz
org.eclipse.cdt-2ef0a883982ac6707a39d610ad91ee83bbec4e5c.zip
Fixed bug 181829. Debugger was not enforcing extension point schema. Also renamed 'breakpointActionPage' extension point to have an uppercase first letter, for consistency with all other CDT debugger extension points.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml38
-rw-r--r--debug/org.eclipse.cdt.debug.ui/schema/BreakpointActionPage.exsd8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java14
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java562
4 files changed, 315 insertions, 307 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index b96266e1214..ffca2f273cb 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -3,7 +3,7 @@
<plugin>
<extension-point id="CDebuggerPage" name="%CDebuggerPage" schema="schema/CDebuggerPage.exsd"/>
- <extension-point id="breakpointActionPage" name="%BreakpointActionPage" schema="schema/BreakpointActionPage.exsd"/>
+ <extension-point id="BreakpointActionPage" name="%BreakpointActionPage" schema="schema/BreakpointActionPage.exsd"/>
<!-- Extensions -->
<extension
@@ -1315,68 +1315,58 @@
<actionType
name="%SoundAction.name"
class="org.eclipse.cdt.debug.ui.breakpointactions.SoundAction"
- id="org.eclipse.cdt.debug.ui.breakpointactions.SoundAction">
- </actionType>
+ id="org.eclipse.cdt.debug.ui.breakpointactions.SoundAction"/>
</extension>
<extension
point="org.eclipse.cdt.debug.core.BreakpointActionType">
<actionType
name="%LogAction.name"
class="org.eclipse.cdt.debug.ui.breakpointactions.LogAction"
- id="org.eclipse.cdt.debug.ui.breakpointactions.LogAction">
- </actionType>
+ id="org.eclipse.cdt.debug.ui.breakpointactions.LogAction"/>
</extension>
<extension
point="org.eclipse.cdt.debug.core.BreakpointActionType">
<actionType
name="%ResumeAction.name"
class="org.eclipse.cdt.debug.ui.breakpointactions.ResumeAction"
- id="org.eclipse.cdt.debug.ui.breakpointactions.ResumeAction">
- </actionType>
+ id="org.eclipse.cdt.debug.ui.breakpointactions.ResumeAction"/>
</extension>
-<extension
+ <extension
point="org.eclipse.cdt.debug.core.BreakpointActionType">
<actionType
name="%ExternalToolAction.name"
class="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction"
- id="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction">
- </actionType>
+ id="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction"/>
</extension>
-
<extension
- point="org.eclipse.cdt.debug.ui.breakpointActionPage">
+ point="org.eclipse.cdt.debug.ui.BreakpointActionPage">
<actionPage
class="org.eclipse.cdt.debug.ui.breakpointactions.SoundActionPage"
id="org.eclipse.cdt.debug.ui.breakpointactions.SoundActionPage"
- actionType="org.eclipse.cdt.debug.ui.breakpointactions.SoundAction">
- </actionPage>
+ actionType="org.eclipse.cdt.debug.ui.breakpointactions.SoundAction"/>
</extension>
<extension
- point="org.eclipse.cdt.debug.ui.breakpointActionPage">
+ point="org.eclipse.cdt.debug.ui.BreakpointActionPage">
<actionPage
class="org.eclipse.cdt.debug.ui.breakpointactions.LogActionPage"
id="org.eclipse.cdt.debug.ui.breakpointactions.LogActionPage"
- actionType="org.eclipse.cdt.debug.ui.breakpointactions.LogAction">
- </actionPage>
+ actionType="org.eclipse.cdt.debug.ui.breakpointactions.LogAction"/>
</extension>
<extension
- point="org.eclipse.cdt.debug.ui.breakpointActionPage">
+ point="org.eclipse.cdt.debug.ui.BreakpointActionPage">
<actionPage
class="org.eclipse.cdt.debug.ui.breakpointactions.ResumeActionPage"
id="org.eclipse.cdt.debug.ui.breakpointactions.ResumeActionPage"
- actionType="org.eclipse.cdt.debug.ui.breakpointactions.ResumeAction">
- </actionPage>
+ actionType="org.eclipse.cdt.debug.ui.breakpointactions.ResumeAction"/>
</extension>
-
<extension
- point="org.eclipse.cdt.debug.ui.breakpointActionPage">
+ point="org.eclipse.cdt.debug.ui.BreakpointActionPage">
<actionPage
class="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolActionPage"
id="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolActionPage"
- actionType="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction">
- </actionPage>
+ actionType="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction"/>
</extension>
<extension
point="org.eclipse.ui.startup">
diff --git a/debug/org.eclipse.cdt.debug.ui/schema/BreakpointActionPage.exsd b/debug/org.eclipse.cdt.debug.ui/schema/BreakpointActionPage.exsd
index 684aaed6e6a..e890bdacce2 100644
--- a/debug/org.eclipse.cdt.debug.ui/schema/BreakpointActionPage.exsd
+++ b/debug/org.eclipse.cdt.debug.ui/schema/BreakpointActionPage.exsd
@@ -3,14 +3,14 @@
<schema targetNamespace="org.eclipse.cdt.debug.ui">
<annotation>
<appInfo>
- <meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointActionPage" name="Breakpoint Action UI Page"/>
+ <meta.schema plugin="org.eclipse.cdt.debug.ui" id="BreakpointActionPage" name="Breakpoint Action UI Page"/>
</appInfo>
<documentation>
This extension point provides a mechanism for contributing UI to define and edit a breakpoint action.
</documentation>
</annotation>
- <element name="extension">
+ <element name="extension">
<complexType>
<sequence>
<element ref="actionPage"/>
@@ -34,7 +34,7 @@
</documentation>
</annotation>
</attribute>
- <attribute name="class" type="string">
+ <attribute name="class" type="string">
<annotation>
<documentation>
@@ -50,7 +50,7 @@
</attribute>
</complexType>
</element>
-
+
<annotation>
<appInfo>
<meta.section type="since"/>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
index aff58cc6290..e5430d2b5b5 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
@@ -65,6 +65,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
*/
public static final String PLUGIN_ID = "org.eclipse.cdt.debug.ui"; //$NON-NLS-1$
+ public static final String CDEBUGGER_PAGE_EXTENSION_POINT_ID = "CDebuggerPage";
+ public static final String DEBUGGER_PAGE_ELEMENT = "debuggerPage";
+
//The shared instance.
private static CDebugUIPlugin plugin;
@@ -173,11 +176,16 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
protected void initializeDebuggerPageMap() {
fDebuggerPageMap = new HashMap( 10 );
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( PLUGIN_ID, "CDebuggerPage" ); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( PLUGIN_ID, CDEBUGGER_PAGE_EXTENSION_POINT_ID ); //$NON-NLS-1$
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
for( int i = 0; i < infos.length; i++ ) {
- String id = infos[i].getAttribute( "debuggerID" ); //$NON-NLS-1$
- fDebuggerPageMap.put( id, infos[i] );
+ IConfigurationElement info = infos[i];
+ if (info.getName().equals(DEBUGGER_PAGE_ELEMENT)) {
+ String id = info.getAttribute( "debuggerID" ); //$NON-NLS-1$
+ if (id != null) {
+ fDebuggerPageMap.put( id, info );
+ }
+ }
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java
index 5e78d2f2fd5..c0e7310c854 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java
@@ -1,276 +1,286 @@
-/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-public class ActionDialog extends Dialog {
-
- public static final String BREAKPOINT_ACTION_PAGE_SIMPLE_ID = "breakpointActionPage"; //$NON-NLS-1$
-
- private static final String ACTION_DIALOG_LAST_SELECTED = "ActionDialog.lastSelectedAction"; //$NON-NLS-1$
-
- private Composite actionArea;
- private Composite[] actionComposites;
- private IBreakpointAction breakpointAction;
- private IBreakpointActionPage actionPage;
- private IBreakpointAction[] breakpointActions;
- private IBreakpointActionPage[] actionPages;
- private String actionName;
- private Text actionNameTextWidget;
- private Combo combo;
- private Composite dialogArea;
- private int lastSelectedActionTypeIndex;
- private IBreakpointAction originalAction;
-
- private IExtension[] breakpointActionPageExtensions;
-
- /**
- * Create the dialog
- *
- * @param parentShell
- */
- public ActionDialog(Shell parentShell, IBreakpointAction action) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
- this.originalAction = action;
- this.breakpointAction = action;
- lastSelectedActionTypeIndex = 0;
- }
-
- protected void cancelPressed() {
- actionPage.actionDialogCanceled();
- super.cancelPressed();
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- if (originalAction == null)
- newShell.setText(Messages.getString("ActionDialog.0")); //$NON-NLS-1$
- else
- newShell.setText(originalAction.getName());
- }
-
- /**
- * Create contents of the button bar
- *
- * @param parent
- */
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- /**
- * Create contents of the dialog
- *
- * @param parent
- */
- protected Control createDialogArea(Composite parent) {
- dialogArea = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- dialogArea.setLayout(gridLayout);
-
- final Label actionNameLabel = new Label(dialogArea, SWT.NONE);
- actionNameLabel.setText(Messages.getString("ActionDialog.1")); //$NON-NLS-1$
-
- actionNameTextWidget = new Text(dialogArea, SWT.BORDER);
- actionNameTextWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final Label breakpointActionTypeLabel = new Label(dialogArea, SWT.NONE);
- breakpointActionTypeLabel.setText(Messages.getString("ActionDialog.2")); //$NON-NLS-1$
-
- combo = new Combo(dialogArea, SWT.READ_ONLY);
- combo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(final SelectionEvent e) {
- try {
- showActionComposite();
- } catch (CoreException e1) {
- }
- }
- });
- combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- //
-
- IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions();
-
- breakpointActions = new IBreakpointAction[actionExtensions.length];
- actionPages = new IBreakpointActionPage[actionExtensions.length];
- actionComposites = new Composite[actionExtensions.length];
-
- if (actionExtensions.length > 0) {
-
- String lastTypeName = CDebugUIPlugin.getDefault().getPreferenceStore().getString(ACTION_DIALOG_LAST_SELECTED);
-
- if (breakpointAction != null) {
- lastTypeName = breakpointAction.getTypeName();
- actionName = breakpointAction.getName();
- }
-
- for (int i = 0; i < actionExtensions.length; i++) {
- IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- String actionTypeName = elements[j].getAttribute("name"); //$NON-NLS-1$
- combo.add(actionTypeName);
- if (actionTypeName.equals(lastTypeName))
- lastSelectedActionTypeIndex = i;
- }
- }
-
- combo.select(lastSelectedActionTypeIndex);
- if (originalAction != null)
- combo.setEnabled(false);
-
- breakpointActions[combo.getSelectionIndex()] = breakpointAction;
-
- actionArea = new Composite(dialogArea, SWT.NONE);
- actionArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- actionArea.setLayout(new StackLayout());
- try {
- showActionComposite();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- return dialogArea;
- }
-
- public IBreakpointAction getBreakpointAction() {
- return breakpointAction;
- }
-
- public String getActionName() {
- return actionName;
- }
-
- /**
- * Return the initial size of the dialog
- */
- protected Point getInitialSize() {
- return new Point(500, 375);
- }
-
- protected void okPressed() {
- if (originalAction == null)
- CDebugUIPlugin.getDefault().getPreferenceStore().setValue(ACTION_DIALOG_LAST_SELECTED, breakpointAction.getTypeName());
- String newName = actionNameTextWidget.getText();
- if (originalAction == null || !originalAction.getName().equals(newName)) {
- actionName = CDebugCorePlugin.getDefault().getBreakpointActionManager().makeUniqueActionName(newName);
- breakpointAction.setName(actionName);
- }
- actionPage.actionDialogOK();
- super.okPressed();
- }
-
- void showActionComposite() throws CoreException {
- // Find the selected extension
- int selectedTypeIndex = combo.getSelectionIndex();
- lastSelectedActionTypeIndex = selectedTypeIndex;
- breakpointAction = breakpointActions[selectedTypeIndex];
- if (breakpointAction == null) {
- int elementCount = 0;
- IConfigurationElement selectedElement = null;
-
- IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions();
-
- for (int i = 0; i < actionExtensions.length && selectedElement == null; i++) {
- IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length && selectedElement == null; j++) {
- if (elementCount == selectedTypeIndex)
- selectedElement = elements[j];
- elementCount++;
- }
- }
-
- breakpointAction = (IBreakpointAction) selectedElement.createExecutableExtension("class"); //$NON-NLS-1$
- breakpointAction.setName(breakpointAction.getDefaultName());
- breakpointActions[selectedTypeIndex] = breakpointAction;
- }
- actionPage = actionPages[selectedTypeIndex];
- if (actionPage == null) {
- actionPages[selectedTypeIndex] = getActionPage(breakpointActions[selectedTypeIndex]);
- actionPage = actionPages[selectedTypeIndex];
- }
- if (actionComposites[selectedTypeIndex] == null) {
- Composite actionComposite = actionPages[selectedTypeIndex].createComposite(breakpointAction, actionArea, SWT.NONE);
- actionComposites[selectedTypeIndex] = actionComposite;
- }
- actionName = breakpointAction.getName();
-
- actionNameTextWidget.setText(actionName);
- StackLayout stacklayout = (StackLayout) actionArea.getLayout();
- stacklayout.topControl = actionComposites[selectedTypeIndex];
- actionArea.layout();
- }
-
- public IExtension[] getBreakpointActionPageExtensions() {
- if (breakpointActionPageExtensions == null) {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, BREAKPOINT_ACTION_PAGE_SIMPLE_ID);
- if (point == null)
- breakpointActionPageExtensions = new IExtension[0];
- else {
- breakpointActionPageExtensions = point.getExtensions();
- }
- }
-
- return breakpointActionPageExtensions;
- }
-
- private IBreakpointActionPage getActionPage(IBreakpointAction breakpointAction) {
- IExtension[] actionExtensions = getBreakpointActionPageExtensions();
-
- IBreakpointActionPage actionPageResult = null;
- try {
-
- for (int i = 0; i < actionExtensions.length && actionPageResult == null; i++) {
- IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length && actionPageResult == null; j++) {
-
- if (elements[j].getAttribute("actionType").equals(breakpointAction.getIdentifier())) { //$NON-NLS-1$
- actionPageResult = (IBreakpointActionPage) elements[j].createExecutableExtension("class"); //$NON-NLS-1$
- }
- }
- }
-
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return actionPageResult;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nokia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.ui.breakpointactions;
+
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class ActionDialog extends Dialog {
+
+ public static final String BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID = "BreakpointActionPage"; //$NON-NLS-1$
+
+ public static final String ACTION_PAGE_ELEMENT = "actionPage"; //$NON-NLS-1$
+
+ private static final String ACTION_DIALOG_LAST_SELECTED = "ActionDialog.lastSelectedAction"; //$NON-NLS-1$
+
+ private Composite actionArea;
+ private Composite[] actionComposites;
+ private IBreakpointAction breakpointAction;
+ private IBreakpointActionPage actionPage;
+ private IBreakpointAction[] breakpointActions;
+ private IBreakpointActionPage[] actionPages;
+ private String actionName;
+ private Text actionNameTextWidget;
+ private Combo combo;
+ private Composite dialogArea;
+ private int lastSelectedActionTypeIndex;
+ private IBreakpointAction originalAction;
+
+ private IExtension[] breakpointActionPageExtensions;
+
+ /**
+ * Create the dialog
+ *
+ * @param parentShell
+ */
+ public ActionDialog(Shell parentShell, IBreakpointAction action) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
+ this.originalAction = action;
+ this.breakpointAction = action;
+ lastSelectedActionTypeIndex = 0;
+ }
+
+ protected void cancelPressed() {
+ actionPage.actionDialogCanceled();
+ super.cancelPressed();
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ if (originalAction == null)
+ newShell.setText(Messages.getString("ActionDialog.0")); //$NON-NLS-1$
+ else
+ newShell.setText(originalAction.getName());
+ }
+
+ /**
+ * Create contents of the button bar
+ *
+ * @param parent
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Create contents of the dialog
+ *
+ * @param parent
+ */
+ protected Control createDialogArea(Composite parent) {
+ dialogArea = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ dialogArea.setLayout(gridLayout);
+
+ final Label actionNameLabel = new Label(dialogArea, SWT.NONE);
+ actionNameLabel.setText(Messages.getString("ActionDialog.1")); //$NON-NLS-1$
+
+ actionNameTextWidget = new Text(dialogArea, SWT.BORDER);
+ actionNameTextWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ final Label breakpointActionTypeLabel = new Label(dialogArea, SWT.NONE);
+ breakpointActionTypeLabel.setText(Messages.getString("ActionDialog.2")); //$NON-NLS-1$
+
+ combo = new Combo(dialogArea, SWT.READ_ONLY);
+ combo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(final SelectionEvent e) {
+ try {
+ showActionComposite();
+ } catch (CoreException e1) {
+ }
+ }
+ });
+ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ //
+
+ IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions();
+
+ breakpointActions = new IBreakpointAction[actionExtensions.length];
+ actionPages = new IBreakpointActionPage[actionExtensions.length];
+ actionComposites = new Composite[actionExtensions.length];
+
+ if (actionExtensions.length > 0) {
+
+ String lastTypeName = CDebugUIPlugin.getDefault().getPreferenceStore().getString(ACTION_DIALOG_LAST_SELECTED);
+
+ if (breakpointAction != null) {
+ lastTypeName = breakpointAction.getTypeName();
+ actionName = breakpointAction.getName();
+ }
+
+ for (int i = 0; i < actionExtensions.length; i++) {
+ IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(CDebugCorePlugin.ACTION_TYPE_ELEMENT)) {
+ String actionTypeName = element.getAttribute("name"); //$NON-NLS-1$
+ combo.add(actionTypeName);
+ if (actionTypeName.equals(lastTypeName))
+ lastSelectedActionTypeIndex = i;
+ }
+ }
+ }
+
+ combo.select(lastSelectedActionTypeIndex);
+ if (originalAction != null)
+ combo.setEnabled(false);
+
+ breakpointActions[combo.getSelectionIndex()] = breakpointAction;
+
+ actionArea = new Composite(dialogArea, SWT.NONE);
+ actionArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ actionArea.setLayout(new StackLayout());
+ try {
+ showActionComposite();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return dialogArea;
+ }
+
+ public IBreakpointAction getBreakpointAction() {
+ return breakpointAction;
+ }
+
+ public String getActionName() {
+ return actionName;
+ }
+
+ /**
+ * Return the initial size of the dialog
+ */
+ protected Point getInitialSize() {
+ return new Point(500, 375);
+ }
+
+ protected void okPressed() {
+ if (originalAction == null)
+ CDebugUIPlugin.getDefault().getPreferenceStore().setValue(ACTION_DIALOG_LAST_SELECTED, breakpointAction.getTypeName());
+ String newName = actionNameTextWidget.getText();
+ if (originalAction == null || !originalAction.getName().equals(newName)) {
+ actionName = CDebugCorePlugin.getDefault().getBreakpointActionManager().makeUniqueActionName(newName);
+ breakpointAction.setName(actionName);
+ }
+ actionPage.actionDialogOK();
+ super.okPressed();
+ }
+
+ void showActionComposite() throws CoreException {
+ // Find the selected extension
+ int selectedTypeIndex = combo.getSelectionIndex();
+ lastSelectedActionTypeIndex = selectedTypeIndex;
+ breakpointAction = breakpointActions[selectedTypeIndex];
+ if (breakpointAction == null) {
+ int elementCount = 0;
+ IConfigurationElement selectedElement = null;
+
+ IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions();
+
+ for (int i = 0; i < actionExtensions.length && selectedElement == null; i++) {
+ IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length && selectedElement == null; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(CDebugCorePlugin.ACTION_TYPE_ELEMENT)) {
+ if (elementCount == selectedTypeIndex)
+ selectedElement = element;
+ elementCount++;
+ }
+ }
+ }
+
+ breakpointAction = (IBreakpointAction) selectedElement.createExecutableExtension("class"); //$NON-NLS-1$
+ breakpointAction.setName(breakpointAction.getDefaultName());
+ breakpointActions[selectedTypeIndex] = breakpointAction;
+ }
+ actionPage = actionPages[selectedTypeIndex];
+ if (actionPage == null) {
+ actionPages[selectedTypeIndex] = getActionPage(breakpointActions[selectedTypeIndex]);
+ actionPage = actionPages[selectedTypeIndex];
+ }
+ if (actionComposites[selectedTypeIndex] == null) {
+ Composite actionComposite = actionPages[selectedTypeIndex].createComposite(breakpointAction, actionArea, SWT.NONE);
+ actionComposites[selectedTypeIndex] = actionComposite;
+ }
+ actionName = breakpointAction.getName();
+
+ actionNameTextWidget.setText(actionName);
+ StackLayout stacklayout = (StackLayout) actionArea.getLayout();
+ stacklayout.topControl = actionComposites[selectedTypeIndex];
+ actionArea.layout();
+ }
+
+ public IExtension[] getBreakpointActionPageExtensions() {
+ if (breakpointActionPageExtensions == null) {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID);
+ if (point == null)
+ breakpointActionPageExtensions = new IExtension[0];
+ else {
+ breakpointActionPageExtensions = point.getExtensions();
+ }
+ }
+
+ return breakpointActionPageExtensions;
+ }
+
+ private IBreakpointActionPage getActionPage(IBreakpointAction breakpointAction) {
+ IExtension[] actionExtensions = getBreakpointActionPageExtensions();
+
+ IBreakpointActionPage actionPageResult = null;
+ try {
+
+ for (int i = 0; i < actionExtensions.length && actionPageResult == null; i++) {
+ IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length && actionPageResult == null; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(ACTION_PAGE_ELEMENT)) {
+ if (element.getAttribute("actionType").equals(breakpointAction.getIdentifier())) { //$NON-NLS-1$
+ actionPageResult = (IBreakpointActionPage) element.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return actionPageResult;
+ }
+
+}

Back to the top