1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +02:00

Simplified LaunchElement to a PODS (plain old data structure)

This commit is contained in:
John Cortell 2009-10-13 20:32:26 +00:00
parent be12c28504
commit fa78098bee
2 changed files with 27 additions and 25 deletions

View file

@ -359,10 +359,10 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
} }
public void setInitialSelection(LaunchElement el) { public void setInitialSelection(LaunchElement el) {
action = el.getAction(); action = el.action;
actionParam = el.getActionParam(); actionParam = el.actionParam;
isDefaultMode = el.getMode().equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE); isDefaultMode = el.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE);
fInitialSelection = new StructuredSelection(el.getData()); fInitialSelection = new StructuredSelection(el.data);
fSelection = fInitialSelection; fSelection = fInitialSelection;
} }
} }

View file

@ -93,13 +93,13 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
return null; return null;
if (columnIndex == 0) { if (columnIndex == 0) {
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element; MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
if (el.getData() == null) { if (el.data == null) {
Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
return errorImage; return errorImage;
} }
try { try {
String key = el.getData().getType().getIdentifier(); String key = el.data.getType().getIdentifier();
return DebugPluginImages.getImage(key); return DebugPluginImages.getImage(key);
} catch (CoreException e) { } catch (CoreException e) {
Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
@ -117,26 +117,26 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
// launch name // launch name
if (columnIndex == 0) { if (columnIndex == 0) {
try { try {
return (el.getData() != null) ? el.getData().getType().getName() + "::" + el.getName() : el.getName(); //$NON-NLS-1$ return (el.data != null) ? el.data.getType().getName() + "::" + el.name : el.name; //$NON-NLS-1$
} catch (CoreException e) { } catch (CoreException e) {
return el.getName(); return el.name;
} }
} }
// launch mode // launch mode
if (columnIndex == 1) if (columnIndex == 1)
return el.getMode(); return el.mode;
// launch post action // launch post action
if (columnIndex == 2) { if (columnIndex == 2) {
EPostLaunchAction action = el.getAction(); EPostLaunchAction action = el.action;
switch (action) { switch (action) {
case NONE: case NONE:
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
case WAIT_FOR_TERMINATION: case WAIT_FOR_TERMINATION:
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated"); //$NON-NLS-1$ return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated"); //$NON-NLS-1$
case DELAY: case DELAY:
final Object actionParam = el.getActionParam(); final Object actionParam = el.actionParam;
return LaunchMessages.getFormattedString("MultiLaunchConfigurationTabGroup.13", //$NON-NLS-1$ return LaunchMessages.getFormattedString("MultiLaunchConfigurationTabGroup.13", //$NON-NLS-1$
actionParam instanceof Integer ? Integer.toString((Integer)actionParam) : "?"); //$NON-NLS-1$ actionParam instanceof Integer ? Integer.toString((Integer)actionParam) : "?"); //$NON-NLS-1$
default: default:
@ -260,14 +260,15 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
for (ILaunchConfiguration config : configs) { for (ILaunchConfiguration config : configs) {
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement(); MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
input.add(el); input.add(el);
el.setIndex(input.size() - 1); el.index = input.size() - 1;
el.setEnabled(true); el.enabled = true;
el.setName(config.getName()); el.name = config.getName();
el.setData(config); el.data = config;
el.setMode(dialog.getMode()); el.mode = dialog.getMode();
el.setAction(dialog.getAction(), dialog.getActionParam()); el.action = dialog.getAction();
el.actionParam = dialog.getActionParam();
treeViewer.refresh(true); treeViewer.refresh(true);
treeViewer.setChecked(el, el.isEnabled()); treeViewer.setChecked(el, el.enabled);
} }
updateWidgetEnablement(); updateWidgetEnablement();
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
@ -290,17 +291,18 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index); MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog dialog =
MultiLaunchConfigurationSelectionDialog.createDialog( MultiLaunchConfigurationSelectionDialog.createDialog(
treeViewer.getControl().getShell(), el.getMode(), true); treeViewer.getControl().getShell(), el.mode, true);
dialog.setInitialSelection(el); dialog.setInitialSelection(el);
if (dialog.open() == Dialog.OK) { if (dialog.open() == Dialog.OK) {
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations(); ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
if (confs.length < 0) if (confs.length < 0)
return; return;
assert confs.length == 1 : "invocation of the dialog for editing an entry sholdn't allow OK to be hit if the user chooses multiple launch configs in the dialog"; //$NON-NLS-1$ assert confs.length == 1 : "invocation of the dialog for editing an entry sholdn't allow OK to be hit if the user chooses multiple launch configs in the dialog"; //$NON-NLS-1$
el.setName(confs[0].getName()); el.name = confs[0].getName();
el.setData(confs[0]); el.data = confs[0];
el.setMode(dialog.getMode()); el.mode = dialog.getMode();
el.setAction(dialog.getAction(), dialog.getActionParam()); el.action = dialog.getAction();
el.actionParam = dialog.getActionParam();
treeViewer.refresh(true); treeViewer.refresh(true);
updateWidgetEnablement(); updateWidgetEnablement();
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
@ -405,7 +407,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
treeViewer.addCheckStateListener(new ICheckStateListener(){ treeViewer.addCheckStateListener(new ICheckStateListener(){
public void checkStateChanged(CheckStateChangedEvent event) { public void checkStateChanged(CheckStateChangedEvent event) {
((LaunchElement)event.getElement()).setEnabled(event.getChecked()); ((LaunchElement)event.getElement()).enabled = event.getChecked();
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
@ -424,7 +426,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
if (treeViewer != null) { if (treeViewer != null) {
for (Iterator<LaunchElement> iterator = input.iterator(); iterator.hasNext();) { for (Iterator<LaunchElement> iterator = input.iterator(); iterator.hasNext();) {
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next(); MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
treeViewer.setChecked(el, el.isEnabled()); treeViewer.setChecked(el, el.enabled);
} }
treeViewer.refresh(true); treeViewer.refresh(true);
} }