diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java index 2309b34c0d7..5c5ce25f4ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Nokia and others. + * Copyright (c) 2007, 2015 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 @@ -200,4 +200,22 @@ public class ActionsList extends Composite { removeButton.setEnabled(selectedItems.length > 0); } + /** + * Update the appearance of given action. + * @param action + */ + void updateAction(IBreakpointAction action) { + TableItem[] currentItems = table.getItems(); + for (int i = 0; i < currentItems.length; i++) { + if (((IBreakpointAction) currentItems[i].getData()).equals(action)) { + TableItem tableItem = currentItems[i]; + tableItem.setText(0, action.getName()); + tableItem.setText(1, action.getTypeName()); + tableItem.setText(2, action.getSummary()); + break; + } + } + updateButtons(); + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java index 7fccf6987b5..1fd10e07b2c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Nokia and others. + * Copyright (c) 2007, 2015 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 @@ -80,6 +80,9 @@ public class ActionsPropertyPage extends PropertyPage { String actionNames = breakpointMarker.getAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ actionsList.setNames(actionNames); + // connect attached actions list to global list + globalActionsList.setClientList(actionsList); + globalActionsList.getAttachButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -98,7 +101,6 @@ public class ActionsPropertyPage extends PropertyPage { } protected void HandleAttachButton() { - IBreakpointAction[] selectedActions = globalActionsList.getSelectedActions(); for (int i = 0; i < selectedActions.length; i++) { actionsList.addAction(selectedActions[i]); @@ -111,13 +113,7 @@ public class ActionsPropertyPage extends PropertyPage { * @since 7.0 */ protected void HandleDeleteButton() { - - // First remove any attached action that was just deleted - IBreakpointAction[] selectedActions = globalActionsList.getSelectedActions(); - for (int i = 0; i < selectedActions.length; i++) { - actionsList.removeAction(selectedActions[i]); - } - // Now cleanup the global action list + // attached actions are now handled by the GlobalActionsList globalActionsList.HandleDeleteButton(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java index 71fa80c8387..93c706473ef 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Nokia and others. + * Copyright (c) 2007, 2015 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 @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.ui.breakpointactions; -import java.util.ArrayList; -import java.util.Iterator; - import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; import org.eclipse.core.runtime.CoreException; @@ -35,6 +32,7 @@ public class GlobalActionsList extends Composite { private Button editButton = null; private Button newButton = null; private Table table = null; + private ActionsList clientList; public GlobalActionsList(Composite parent, int style, boolean useAttachButton) { super(parent, style); @@ -74,10 +72,7 @@ public class GlobalActionsList extends Composite { summaryTableColumn.setWidth(120); summaryTableColumn.setText(Messages.getString("GlobalActionsList.2")); //$NON-NLS-1$ - ArrayList actions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions(); - - for (Iterator iter = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions().iterator(); iter.hasNext();) { - IBreakpointAction element = (IBreakpointAction) iter.next(); + for (IBreakpointAction element : CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions()) { final TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(0, element.getName()); tableItem.setText(1, element.getTypeName()); @@ -111,7 +106,6 @@ public class GlobalActionsList extends Composite { editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HandleEditButton(); } }); @@ -150,6 +144,8 @@ public class GlobalActionsList extends Composite { TableItem[] selectedItems = table.getSelection(); for (int i = 0; i < selectedItems.length; i++) { IBreakpointAction action = (IBreakpointAction) selectedItems[i].getData(); + if (clientList != null) + clientList.removeAction(action); CDebugCorePlugin.getDefault().getBreakpointActionManager().deleteAction(action); } table.remove(table.getSelectionIndices()); @@ -160,7 +156,6 @@ public class GlobalActionsList extends Composite { } protected void HandleEditButton() { - TableItem[] selectedItems = table.getSelection(); IBreakpointAction action = (IBreakpointAction) selectedItems[0].getData(); @@ -171,12 +166,12 @@ public class GlobalActionsList extends Composite { selectedItems[0].setText(0, action.getName()); selectedItems[0].setText(1, action.getTypeName()); selectedItems[0].setText(2, action.getSummary()); + if (clientList != null) + clientList.updateAction(action); } - } protected void HandleNewButton() throws CoreException { - ActionDialog dialog = new ActionDialog(this.getShell(), null); int result = dialog.open(); if (result == Window.OK) { @@ -188,9 +183,7 @@ public class GlobalActionsList extends Composite { tableItem.setText(1, action.getTypeName()); tableItem.setText(2, action.getSummary()); tableItem.setData(action); - } - } public void updateButtons() { @@ -201,4 +194,12 @@ public class GlobalActionsList extends Composite { editButton.setEnabled(selectedItems.length > 0); } + /** + * Register client list to be notified of changes to actions. + * @param actionsList + */ + void setClientList(ActionsList actionsList) { + clientList = actionsList; + } + }