1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 473098 - Reflect tp action changes from while-stepping

The action changes were not immediately shown when changes were done
from the while-stepping action dialog

Change-Id: I36c4b366f0fd97d0a5c939b17eda5e6cd696d89d
This commit is contained in:
Marc Khouzam 2015-07-20 12:41:36 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 05a2939d54
commit bb50c58c02
5 changed files with 98 additions and 24 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 Nokia and others.
* Copyright (c) 2010, 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
@ -75,6 +75,10 @@ public class TracepointActionDialog extends Dialog {
private IBreakpointAction originalAction;
private boolean isSubAction;
// If this dialog is for a "while-stepping" action, we keep track
// of the parent global list, so that it can be updated.
private TracepointGlobalActionsList parentGlobalList;
private IExtension[] breakpointActionPageExtensions;
private static final Point MINIMUM_SIZE = new Point(440, 540);
@ -82,13 +86,15 @@ public class TracepointActionDialog extends Dialog {
/**
* Create the dialog
*/
public TracepointActionDialog(Shell parentShell, ITracepointAction action, boolean isSub) {
public TracepointActionDialog(Shell parentShell, ITracepointAction action,
TracepointGlobalActionsList parentList, boolean isSub) {
super(parentShell);
setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
originalAction = action;
tracepointAction = action;
lastSelectedActionTypeIndex = 0;
isSubAction = isSub;
parentGlobalList = parentList;
}
@Override
@ -235,6 +241,9 @@ public class TracepointActionDialog extends Dialog {
if (actionPage == null) {
actionPages[selectedTypeIndex] = getActionPage(tracepointActions.get(selectedTypeIndex));
actionPage = actionPages[selectedTypeIndex];
if (actionPage instanceof WhileSteppingActionPage) {
((WhileSteppingActionPage)actionPage).setParentGlobalList(parentGlobalList);
}
}
if (actionComposites[selectedTypeIndex] == null) {
Composite actionComposite = actionPages[selectedTypeIndex].createComposite(tracepointAction, actionArea, SWT.NONE);

View file

@ -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
@ -45,7 +45,7 @@ public class TracepointActionsPreferencePage extends PreferencePage implements I
final Label breakpointActionsAvailableLabel = new Label(container, SWT.NONE);
breakpointActionsAvailableLabel.setText(MessagesForTracepointActions.TracepointActions_Preferences_Actions_Available);
final TracepointGlobalActionsList actionsList = new TracepointGlobalActionsList(container, SWT.NONE, false, false);
final TracepointGlobalActionsList actionsList = new TracepointGlobalActionsList(container, SWT.NONE, false, null, false);
actionsList.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
actionsList.getDeleteButton().addSelectionListener(new SelectionAdapter() {

View file

@ -76,7 +76,7 @@ public class TracepointActionsPropertyPage extends PropertyPage {
allAvailableActionsLabel.setLayoutData(gridData_3);
allAvailableActionsLabel.setText(MessagesForTracepointActions.TracepointActions_Available_actions);
globalActionsList = new TracepointGlobalActionsList(container, SWT.NONE, true, false);
globalActionsList = new TracepointGlobalActionsList(container, SWT.NONE, true, null, false);
final GridData gridData_1 = new GridData(GridData.FILL_BOTH);
gridData_1.horizontalSpan = 2;
globalActionsList.setLayoutData(gridData_1);

View file

@ -41,9 +41,15 @@ public class TracepointGlobalActionsList extends Composite {
private TracepointActionsList clientList;
private boolean isSubAction;
public TracepointGlobalActionsList(Composite parent, int style, boolean useAttachButton, boolean isSub) {
// When dealing with a "while-stepping" action, we deal with a "child" global
// list, and must keep track of the parent global list, to properly update it.
// This field will be null when the this class represents the parent class itself.
private TracepointGlobalActionsList parentGlobalList;
public TracepointGlobalActionsList(Composite parent, int style, boolean useAttachButton, TracepointGlobalActionsList parentList, boolean isSub) {
super(parent, style);
isSubAction = isSub;
parentGlobalList = parentList;
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 5;
@ -153,8 +159,14 @@ public class TracepointGlobalActionsList extends Composite {
if (clientList != null) {
clientList.removeAction(action);
}
if (parentGlobalList != null) {
assert isSubAction;
// Update the parent list also
parentGlobalList.removeAction(action);
}
TracepointActionManager.getInstance().deleteAction(action);
}
// Remove all selected actions at once
table.remove(table.getSelectionIndices());
if (table.getItemCount() > 0) {
table.select(table.getItemCount() - 1);
@ -162,12 +174,26 @@ public class TracepointGlobalActionsList extends Composite {
updateButtons();
}
void removeAction(ITracepointAction action) {
TableItem[] currentItems = table.getItems();
for (int i = 0; i < currentItems.length; i++) {
if (((ITracepointAction) currentItems[i].getData()).equals(action)) {
table.remove(i);
if (clientList != null) {
clientList.removeAction(action);
}
break;
}
}
updateButtons();
}
protected void HandleEditButton() {
TableItem[] selectedItems = table.getSelection();
ITracepointAction action = (ITracepointAction) selectedItems[0].getData();
TracepointActionDialog dialog = new TracepointActionDialog(this.getShell(), action, isSubAction);
TracepointActionDialog dialog = new TracepointActionDialog(this.getShell(), action, this, isSubAction);
int result = dialog.open();
if (result == Window.OK) {
action.setName(dialog.getActionName());
@ -177,26 +203,38 @@ public class TracepointGlobalActionsList extends Composite {
if (clientList != null) {
clientList.updateAction(action);
}
if (parentGlobalList != null) {
assert isSubAction;
// Update the parent list also
parentGlobalList.updateAction(action);
}
}
}
protected void HandleNewButton() throws CoreException {
TracepointActionDialog dialog = new TracepointActionDialog(this.getShell(), null, isSubAction);
TracepointActionDialog dialog = new TracepointActionDialog(this.getShell(), null, this, isSubAction);
int result = dialog.open();
if (result == Window.OK) {
ITracepointAction action = (ITracepointAction)dialog.getTracepointAction();
action.setName(dialog.getActionName());
TracepointActionManager.getInstance().addAction(action);
addAction(action);
if (parentGlobalList != null) {
assert isSubAction;
// Update the parent list also
parentGlobalList.addAction(action);
}
}
}
void addAction(ITracepointAction action) {
final TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setText(0, action.getName());
tableItem.setText(1, action.getTypeName());
tableItem.setText(2, action.getSummary());
tableItem.setData(action);
}
}
public void updateButtons() {
@ -214,4 +252,25 @@ public class TracepointGlobalActionsList extends Composite {
void setClientList(TracepointActionsList actionsList) {
clientList = actionsList;
}
/**
* Update the appearance of given action.
* @param action
*/
void updateAction(ITracepointAction action) {
TableItem[] currentItems = table.getItems();
for (int i = 0; i < currentItems.length; i++) {
if (((ITracepointAction) currentItems[i].getData()).equals(action)) {
TableItem tableItem = currentItems[i];
tableItem.setText(0, action.getName());
tableItem.setText(1, action.getTypeName());
tableItem.setText(2, action.getSummary());
if (clientList != null) {
clientList.updateAction(action);
}
break;
}
}
updateButtons();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 Ericsson and others.
* Copyright (c) 2010, 2015 Ericsson 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
@ -33,6 +33,9 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi
private Text fStepCountText;
private TracepointActionsList actionsList;
private TracepointGlobalActionsList globalActionsList;
// When dealing with a "while-stepping" action, we deal with a "child" global
// list, and must keep track of the parent global list, to properly update it.
private TracepointGlobalActionsList parentGlobalActionsList;
/**
* Create the composite
@ -74,7 +77,7 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi
allAvailableActionsLabel.setLayoutData(gridData);
allAvailableActionsLabel.setText(MessagesForTracepointActions.TracepointActions_Available_actions);
globalActionsList = new TracepointGlobalActionsList(composite, SWT.NONE, true, true);
globalActionsList = new TracepointGlobalActionsList(composite, SWT.NONE, true, parentGlobalActionsList, true);
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
globalActionsList.setLayoutData(gridData);
@ -82,6 +85,9 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi
String actionNames = fWhileSteppingAction.getSubActionsNames();
actionsList.setNames(actionNames);
// connect attached actions list to global list
globalActionsList.setClientList(actionsList);
globalActionsList.getAttachButton().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -112,12 +118,8 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi
* @since 7.0
*/
protected void HandleDeleteButton() {
// First remove any attached action that was just deleted
ITracepointAction[] selectedActions = globalActionsList.getSelectedActions();
for (ITracepointAction action : selectedActions) {
actionsList.removeAction(action);
}
// Now cleanup the global action list
// attached actions are now handled by the GlobalActionsList
globalActionsList.HandleDeleteButton();
}
@ -148,4 +150,8 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi
fWhileSteppingAction = (WhileSteppingAction)action;
return createWhileSteppingActionComposite(composite, style);
}
void setParentGlobalList(TracepointGlobalActionsList list) {
parentGlobalActionsList = list;
}
}