diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/ui')
40 files changed, 555 insertions, 632 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java index fe10bfdd5..bd8ffbe65 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java @@ -435,10 +435,9 @@ public abstract class AbstractDebugView extends PageBookView implements IDebugVi protected void saveAllCheckedActionStates() { IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager(); IContributionItem[] items= tbm.getItems(); - for (int i = 0; i < items.length; i++) { - IContributionItem iContributionItem = items[i]; - if (iContributionItem instanceof ActionContributionItem) { - ActionContributionItem item= (ActionContributionItem)iContributionItem; + for (IContributionItem contitem : items) { + if (contitem instanceof ActionContributionItem) { + ActionContributionItem item= (ActionContributionItem)contitem; IAction action= item.getAction(); if (action.getStyle() == IAction.AS_CHECK_BOX && action.isEnabled()) { saveCheckedActionState(action); @@ -627,9 +626,9 @@ public abstract class AbstractDebugView extends PageBookView implements IDebugVi } IContributionItem[] items = tbm.getItems(); if (items != null) { - for (int i = 0; i < items.length; i++) { - if (items[i] instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem) items[i]).getAction(); + for (IContributionItem item : items) { + if (item instanceof ActionContributionItem) { + IAction action = ((ActionContributionItem) item).getAction(); if (!SkipAllBreakpointsAction.ACTION_ID.equals(action.getId())) { if (action.getStyle() == IAction.AS_CHECK_BOX) { initActionState(action); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTabGroup.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTabGroup.java index f66cffd1f..c3472b7b0 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTabGroup.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTabGroup.java @@ -49,7 +49,7 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf * * @param tabs the tabs in this group */ - protected void setTabs(ILaunchConfigurationTab[] tabs) { + protected void setTabs(ILaunchConfigurationTab... tabs) { fTabs = tabs; } @@ -62,8 +62,8 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf public void dispose() { ILaunchConfigurationTab[] tabs = getTabs(); if (tabs != null) { - for (int i = 0; i < tabs.length; i++) { - tabs[i].dispose(); + for (ILaunchConfigurationTab tab : tabs) { + tab.dispose(); } } } @@ -76,8 +76,8 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { ILaunchConfigurationTab[] tabs = getTabs(); - for (int i = 0; i < tabs.length; i++) { - tabs[i].setDefaults(configuration); + for (ILaunchConfigurationTab tab : tabs) { + tab.setDefaults(configuration); } } @@ -89,8 +89,8 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf @Override public void initializeFrom(ILaunchConfiguration configuration) { ILaunchConfigurationTab[] tabs = getTabs(); - for (int i = 0; i < tabs.length; i++) { - tabs[i].initializeFrom(configuration); + for (ILaunchConfigurationTab tab : tabs) { + tab.initializeFrom(configuration); } } @@ -102,8 +102,8 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { ILaunchConfigurationTab[] tabs = getTabs(); - for (int i = 0; i < tabs.length; i++) { - tabs[i].performApply(configuration); + for (ILaunchConfigurationTab tab : tabs) { + tab.performApply(configuration); } } @@ -120,8 +120,8 @@ public abstract class AbstractLaunchConfigurationTabGroup implements ILaunchConf @Override public void launched(ILaunch launch) { ILaunchConfigurationTab[] tabs = getTabs(); - for (int i = 0; i < tabs.length; i++) { - tabs[i].launched(launch); + for (ILaunchConfigurationTab tab : tabs) { + tab.launched(launch); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java index 9ac350da1..405867a5e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,9 +15,12 @@ *******************************************************************************/ package org.eclipse.debug.ui; +import static org.eclipse.swt.accessibility.AccessibleListener.getNameAdapter; +import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -51,22 +54,14 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; @@ -81,13 +76,11 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.ide.IDEEncoding; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; - -import com.ibm.icu.text.MessageFormat; +import org.osgi.framework.FrameworkUtil; /** * Launch configuration tab used to specify the location a launch configuration @@ -111,8 +104,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * * @since 3.6 */ - private final String SHARED_LAUNCH_CONFIGURATON_DIALOG = IDebugUIConstants.PLUGIN_ID + ".SHARED_LAUNCH_CONFIGURATON_DIALOG"; //$NON-NLS-1$ - private final String WORKSPACE_SELECTION_DIALOG = IDebugUIConstants.PLUGIN_ID + ".WORKSPACE_SELECTION_DIALOG"; //$NON-NLS-1$ + private static final String SHARED_LAUNCH_CONFIGURATON_DIALOG = IDebugUIConstants.PLUGIN_ID + + ".SHARED_LAUNCH_CONFIGURATON_DIALOG"; //$NON-NLS-1$ + private static final String WORKSPACE_SELECTION_DIALOG = IDebugUIConstants.PLUGIN_ID + + ".WORKSPACE_SELECTION_DIALOG"; //$NON-NLS-1$ /** * This attribute exists solely for the purpose of making sure that invalid shared locations @@ -123,11 +118,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { private static final String BAD_CONTAINER = "bad_container_name"; //$NON-NLS-1$ // Local/shared UI widgets + private Composite fIoComposit; private Button fLocalRadioButton; private Button fSharedRadioButton; private Text fSharedLocationText; private Button fSharedLocationButton; private Button fLaunchInBackgroundButton; + private Button fTerminateDescendantsButton; private Button fDefaultEncodingButton; private Button fAltEncodingButton; private Combo fEncodingCombo; @@ -137,6 +134,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { private Text fFileText; private Button fVariables; private Button fAppend; + private Button fMergeOutput; private Button fWorkspaceBrowse; private Button fInputFileCheckButton; @@ -153,12 +151,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { /** * Modify listener that simply updates the owning launch configuration dialog. */ - private ModifyListener fBasicModifyListener = new ModifyListener() { - @Override - public void modifyText(ModifyEvent evt) { - scheduleUpdateJob(); - } - }; + private ModifyListener fBasicModifyListener = evt -> scheduleUpdateJob(); /** * Constructs a new tab with default context help. @@ -181,6 +174,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { createEncodingComponent(comp); createOutputCaptureComponent(comp); createLaunchInBackgroundComponent(comp); + createTerminateDescendantsButtonComponent(comp); } /** @@ -191,7 +185,8 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * @since 3.6 */ IDialogSettings getDialogBoundsSettings(String id) { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings settings = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(CommonTab.class)) + .getDialogSettings(); IDialogSettings section = settings.getSection(id); if (section == null) { section = settings.addNewSection(id); @@ -213,12 +208,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { table.setFont(parent.getFont()); fFavoritesTable.setContentProvider(new FavoritesContentProvider()); fFavoritesTable.setLabelProvider(new FavoritesLabelProvider()); - fFavoritesTable.addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - updateLaunchConfigurationDialog(); - } - }); + fFavoritesTable.addCheckStateListener(event -> updateLaunchConfigurationDialog()); } /** @@ -234,27 +224,15 @@ public class CommonTab extends AbstractLaunchConfigurationTab { gd.horizontalSpan = 3; fLocalRadioButton.setLayoutData(gd); fSharedRadioButton = createRadioButton(comp, LaunchConfigurationsMessages.CommonTab_S_hared_4); - fSharedRadioButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - handleSharedRadioButtonSelected(); - } - }); + fSharedRadioButton.addSelectionListener(widgetSelectedAdapter(e -> handleSharedRadioButtonSelected())); + fSharedLocationText = SWTFactory.createSingleText(comp, 1); - fSharedLocationText.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchConfigurationsMessages.CommonTab_S_hared_4; - } - }); + fSharedLocationText.getAccessible().addAccessibleListener( + getNameAdapter(e -> e.result = LaunchConfigurationsMessages.CommonTab_S_hared_4)); + fSharedLocationText.addModifyListener(fBasicModifyListener); fSharedLocationButton = createPushButton(comp, LaunchConfigurationsMessages.CommonTab__Browse_6, null); - fSharedLocationButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - handleSharedLocationButtonSelected(); - } - }); + fSharedLocationButton.addSelectionListener(widgetSelectedAdapter(e -> handleSharedLocationButtonSelected())); fLocalRadioButton.setSelection(true); setSharedEnabled(false); @@ -268,22 +246,16 @@ public class CommonTab extends AbstractLaunchConfigurationTab { Group group = SWTFactory.createGroup(parent, LaunchConfigurationsMessages.CommonTab_4, 5, 2, GridData.FILL_HORIZONTAL); createInputCaptureComponent(group); Composite comp = SWTFactory.createComposite(group, group.getFont(), 5, 5, GridData.FILL_BOTH, 0, 0); + fIoComposit = comp; fFileOutput = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_6); fFileOutput.setLayoutData(new GridData(SWT.BEGINNING, SWT.NORMAL, false, false)); - fFileOutput.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - enableOuputCaptureWidgets(fFileOutput.getSelection()); - updateLaunchConfigurationDialog(); - } - }); + fFileOutput.addSelectionListener(widgetSelectedAdapter(e -> { + enableOuputCaptureWidgets(fFileOutput.getSelection()); + updateLaunchConfigurationDialog(); + })); fFileText = SWTFactory.createSingleText(comp, 4); - fFileText.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchConfigurationsMessages.CommonTab_6; - } - }); + fFileText.getAccessible() + .addAccessibleListener(getNameAdapter(e -> e.result = LaunchConfigurationsMessages.CommonTab_6)); fFileText.addModifyListener(fBasicModifyListener); Composite bcomp = SWTFactory.createComposite(comp, 3, 5, GridData.HORIZONTAL_ALIGN_END); @@ -291,73 +263,55 @@ public class CommonTab extends AbstractLaunchConfigurationTab { ld.marginHeight = 1; ld.marginWidth = 0; fWorkspaceBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_12, null); - fWorkspaceBrowse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); - dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), Dialog.DIALOG_PERSISTSIZE); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - if(resource != null) { - String arg = resource.getFullPath().toString(); - String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ - fFileText.setText(fileLoc); - } + fWorkspaceBrowse.addSelectionListener(widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); + dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), + Dialog.DIALOG_PERSISTSIZE); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + if (resource != null) { + String arg = resource.getFullPath().toString(); + String fileLoc = VariablesPlugin.getDefault().getStringVariableManager() + .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ + fFileText.setText(fileLoc); } } - }); + })); fFileBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_7, null); - fFileBrowse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = fFileText.getText(); - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE | SWT.SHEET); - filePath = dialog.open(); - if (filePath != null) { - fFileText.setText(filePath); - } + fFileBrowse.addSelectionListener(widgetSelectedAdapter(e -> { + String filePath = fFileText.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE | SWT.SHEET); + filePath = dialog.open(); + if (filePath != null) { + fFileText.setText(filePath); } - }); + })); fVariables = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_9, null); - fVariables.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); - dialog.open(); - String variable = dialog.getVariableExpression(); - if (variable != null) { - fFileText.insert(variable); - } + fVariables.addSelectionListener(widgetSelectedAdapter(e -> { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + dialog.open(); + String variable = dialog.getVariableExpression(); + if (variable != null) { + fFileText.insert(variable); } - @Override - public void widgetDefaultSelected(SelectionEvent e) {} - }); + })); fAppend = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_11); GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, false); - gd.horizontalSpan = 4; + gd.horizontalSpan = 5; fAppend.setLayoutData(gd); - fAppend.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }); + fAppend.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); } private void createInputCaptureComponent(Composite parent){ Composite comp1 = SWTFactory.createComposite(parent, parent.getFont(), 5, 5, GridData.FILL_BOTH, 0, 0); fConsoleOutput = createCheckButton(comp1, LaunchConfigurationsMessages.CommonTab_5); - fConsoleOutput.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }); + fConsoleOutput.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); Composite comp = SWTFactory.createComposite(comp1, comp1.getFont(), 5, 5, GridData.FILL_BOTH, 0, 0); fInputFileCheckButton = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_17); @@ -365,89 +319,71 @@ public class CommonTab extends AbstractLaunchConfigurationTab { gd.horizontalSpan = 3; fInputFileCheckButton.setLayoutData(gd); - fInputFileCheckButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - handleInputFileButtonSelected(); - updateLaunchConfigurationDialog(); - } - }); + fInputFileCheckButton.addSelectionListener(widgetSelectedAdapter(e -> { + handleInputFileButtonSelected(); + updateLaunchConfigurationDialog(); + })); fInputFileLocationText = SWTFactory.createSingleText(comp, 2); - fInputFileLocationText.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchConfigurationsMessages.CommonTab_17; - } - }); + fInputFileLocationText.getAccessible() + .addAccessibleListener(getNameAdapter(e -> e.result = LaunchConfigurationsMessages.CommonTab_17)); fInputFileLocationText.addModifyListener(fBasicModifyListener); Composite bcomp = SWTFactory.createComposite(comp, 3, 5, GridData.HORIZONTAL_ALIGN_END); GridLayout ld = (GridLayout) bcomp.getLayout(); ld.marginHeight = 1; ld.marginWidth = 0; fInputWorkspaceBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_16, null); - fInputWorkspaceBrowse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); - dialog.setValidator(new ISelectionStatusValidator() { - - @Override - public IStatus validate(Object[] selection) { - if (selection.length == 0) { - return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - for (int i = 0; i < selection.length; i++) { - if (!(selection[i] instanceof IFile)) { - return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - } - return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - }); - dialog.setMessage(LaunchConfigurationsMessages.CommonTab_18); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), Dialog.DIALOG_PERSISTSIZE); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - if (resource != null) { - String arg = resource.getFullPath().toString(); - String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ - fInputFileLocationText.setText(fileLoc); + fInputWorkspaceBrowse.addSelectionListener(widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); + dialog.setValidator(selection -> { + if (selection.length == 0) { + return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, + IInternalDebugCoreConstants.EMPTY_STRING, null); + } + for (Object f : selection) { + if (!(f instanceof IFile)) { + return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, + IInternalDebugCoreConstants.EMPTY_STRING, null); } } + return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, + IInternalDebugCoreConstants.EMPTY_STRING, null); + }); + dialog.setMessage(LaunchConfigurationsMessages.CommonTab_18); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), + Dialog.DIALOG_PERSISTSIZE); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + if (resource != null) { + String arg = resource.getFullPath().toString(); + String fileLoc = VariablesPlugin.getDefault().getStringVariableManager() + .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ + fInputFileLocationText.setText(fileLoc); + } } - }); + })); fInputFileBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_19, null); - fInputFileBrowse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = fInputFileLocationText.getText(); - FileDialog dialog = new FileDialog(getShell(), SWT.OK | SWT.SHEET); - filePath = dialog.open(); - if (filePath != null) { - fInputFileLocationText.setText(filePath); - } + fInputFileBrowse.addSelectionListener(widgetSelectedAdapter(e -> { + String filePath = fInputFileLocationText.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.OK | SWT.SHEET); + filePath = dialog.open(); + if (filePath != null) { + fInputFileLocationText.setText(filePath); } - }); + })); fInputVariables = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_20, null); - fInputVariables.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); - dialog.open(); - String variable = dialog.getVariableExpression(); - if (variable != null) { - fInputFileLocationText.insert(variable); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { + fInputVariables.addSelectionListener(widgetSelectedAdapter(e -> { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + dialog.open(); + String variable = dialog.getVariableExpression(); + if (variable != null) { + fInputFileLocationText.insert(variable); } - }); + })); setInputFileEnabled(false); } @@ -514,36 +450,24 @@ public class CommonTab extends AbstractLaunchConfigurationTab { if (encodingArray.length > 0) { fEncodingCombo.select(0); } - fEncodingCombo.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchConfigurationsMessages.CommonTab_3; - } - }); - SelectionListener listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if(e.getSource() instanceof Button) { - Button button = (Button)e.getSource(); - if(button.getSelection()) { - updateLaunchConfigurationDialog(); - fEncodingCombo.setEnabled(fAltEncodingButton.getSelection() == true); - } - } - else { + fEncodingCombo.getAccessible() + .addAccessibleListener(getNameAdapter(e -> e.result = LaunchConfigurationsMessages.CommonTab_3)); + + SelectionListener listener = widgetSelectedAdapter(e -> { + if (e.getSource() instanceof Button) { + Button button = (Button) e.getSource(); + if (button.getSelection()) { updateLaunchConfigurationDialog(); + fEncodingCombo.setEnabled(fAltEncodingButton.getSelection()); } + } else { + updateLaunchConfigurationDialog(); } - }; + }); fAltEncodingButton.addSelectionListener(listener); fDefaultEncodingButton.addSelectionListener(listener); fEncodingCombo.addSelectionListener(listener); - fEncodingCombo.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - scheduleUpdateJob(); - } - }); + fEncodingCombo.addKeyListener(KeyListener.keyReleasedAdapter(e -> scheduleUpdateJob())); } /** @@ -575,12 +499,23 @@ public class CommonTab extends AbstractLaunchConfigurationTab { data.horizontalSpan = 2; fLaunchInBackgroundButton.setLayoutData(data); fLaunchInBackgroundButton.setFont(parent.getFont()); - fLaunchInBackgroundButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }); + fLaunchInBackgroundButton.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); + } + + /** + * Creates the controls needed to edit the terminate descendants attribute of an + * external tool + * + * @param parent the composite to create the controls in + */ + private void createTerminateDescendantsButtonComponent(Composite parent) { + fTerminateDescendantsButton = createCheckButton(parent, + LaunchConfigurationsMessages.CommonTab_AttributeLabel_TerminateDescendants); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + data.horizontalSpan = 2; + fTerminateDescendantsButton.setLayoutData(data); + fTerminateDescendantsButton.setFont(parent.getFont()); + fTerminateDescendantsButton.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); } /** @@ -618,11 +553,11 @@ public class CommonTab extends AbstractLaunchConfigurationTab { private String getDefaultSharedConfigLocation(ILaunchConfiguration config) { String path = IInternalDebugCoreConstants.EMPTY_STRING; try { - IResource[] res = config.getMappedResources(); - if(res != null) { + IResource[] mappedResources = config.getMappedResources(); + if(mappedResources != null) { IProject proj; - for (int i = 0; i < res.length; i++) { - proj = res[i].getProject(); + for (IResource resource : mappedResources) { + proj = resource.getProject(); if(proj != null && proj.isAccessible()) { return proj.getFullPath().toOSString(); } @@ -658,9 +593,9 @@ public class CommonTab extends AbstractLaunchConfigurationTab { String currentContainerString = fSharedLocationText.getText(); IContainer currentContainer = getContainer(currentContainerString); ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), - currentContainer, - false, - LaunchConfigurationsMessages.CommonTab_Select_a_location_for_the_launch_configuration_13); + currentContainer, + false, + LaunchConfigurationsMessages.CommonTab_Select_a_location_for_the_launch_configuration_13); dialog.showClosedProjects(false); dialog.setDialogBoundsSettings(getDialogBoundsSettings(SHARED_LAUNCH_CONFIGURATON_DIALOG), Dialog.DIALOG_PERSISTSIZE); dialog.open(); @@ -704,6 +639,9 @@ public class CommonTab extends AbstractLaunchConfigurationTab { updateLaunchInBackground(configuration); updateEncoding(configuration); updateConsoleOutput(configuration); + + boolean terminateDescendants = getAttribute(configuration, DebugPlugin.ATTR_TERMINATE_DESCENDANTS, true); + fTerminateDescendantsButton.setSelection(terminateDescendants); } /** @@ -711,22 +649,31 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * @param configuration the local configuration */ private void updateConsoleOutput(ILaunchConfiguration configuration) { - boolean outputToConsole = true; - String stdinFromFile = null; - String outputFile = null; - boolean append = false; - + boolean outputToConsole = getAttribute(configuration, IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); + String stdinFromFile = getAttribute(configuration, IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, (String) null); + String outputFile = getAttribute(configuration, IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String) null); + boolean append = getAttribute(configuration, IDebugUIConstants.ATTR_APPEND_TO_FILE, false); + boolean mergeOutput = getAttribute(configuration, DebugPlugin.ATTR_MERGE_OUTPUT, false); + boolean supportsMergeOutput = false; try { - outputToConsole = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); - stdinFromFile = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, (String) null); - - outputFile = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String)null); - append = configuration.getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); + supportsMergeOutput = configuration.getType().supportsOutputMerging(); } catch (CoreException e) { } fConsoleOutput.setSelection(outputToConsole); fAppend.setSelection(append); + if (supportsMergeOutput) { + fMergeOutput = createCheckButton(fIoComposit, LaunchConfigurationsMessages.CommonTab_21); + GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, false); + gd.horizontalSpan = 5; + fMergeOutput.setLayoutData(gd); + fMergeOutput.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); + fMergeOutput.setSelection(mergeOutput); + } + else if (fMergeOutput != null) { + fMergeOutput.dispose(); + fMergeOutput = null; + } boolean haveOutputFile= outputFile != null; if (haveOutputFile) { fFileText.setText(outputFile); @@ -755,13 +702,9 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * @param configuration the local configuration */ private void updateEncoding(ILaunchConfiguration configuration) { - String encoding = null; - try { - encoding = configuration.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, (String)null); - } catch (CoreException e) { - } + String encoding = getAttribute(configuration, DebugPlugin.ATTR_CONSOLE_ENCODING, (String) null); String defaultEncoding = getDefaultEncoding(configuration); - fDefaultEncodingButton.setText(MessageFormat.format(LaunchConfigurationsMessages.CommonTab_2, new Object[] { defaultEncoding })); + fDefaultEncodingButton.setText(MessageFormat.format(LaunchConfigurationsMessages.CommonTab_2, defaultEncoding)); fDefaultEncodingButton.pack(); if (encoding != null) { fAltEncodingButton.setSelection(true); @@ -782,13 +725,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * @return whether the configuration is configured to launch in the background */ public static boolean isLaunchInBackground(ILaunchConfiguration configuration) { - boolean launchInBackground= true; - try { - launchInBackground= configuration.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); - } catch (CoreException ce) { - DebugUIPlugin.log(ce); - } - return launchInBackground; + return getAttribute(configuration, IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); } /** @@ -799,29 +736,26 @@ public class CommonTab extends AbstractLaunchConfigurationTab { private void updateFavoritesFromConfig(ILaunchConfiguration config) { fFavoritesTable.setInput(config); fFavoritesTable.setCheckedElements(new Object[]{}); - try { - List<String> groups = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, new ArrayList<String>()); - if (groups.isEmpty()) { - // check old attributes for backwards compatible - if (config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false)) { - groups.add(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); - } - if (config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false)) { - groups.add(IDebugUIConstants.ID_RUN_LAUNCH_GROUP); - } + List<String> groups = getAttribute(config, IDebugUIConstants.ATTR_FAVORITE_GROUPS, new ArrayList<>()); + + if (groups.isEmpty()) { + // check old attributes for backwards compatible + if (getAttribute(config, IDebugUIConstants.ATTR_DEBUG_FAVORITE, false)) { + groups.add(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); } - if (!groups.isEmpty()) { - List<LaunchGroupExtension> list = new ArrayList<>(); - for (String id : groups) { - LaunchGroupExtension extension = getLaunchConfigurationManager().getLaunchGroup(id); - if (extension != null) { - list.add(extension); - } + if (getAttribute(config, IDebugUIConstants.ATTR_RUN_FAVORITE, false)) { + groups.add(IDebugUIConstants.ID_RUN_LAUNCH_GROUP); + } + } + if (!groups.isEmpty()) { + List<LaunchGroupExtension> list = new ArrayList<>(); + for (String id : groups) { + LaunchGroupExtension extension = getLaunchConfigurationManager().getLaunchGroup(id); + if (extension != null) { + list.add(extension); } - fFavoritesTable.setCheckedElements(list.toArray()); } - } catch (CoreException e) { - DebugUIPlugin.log(e); + fFavoritesTable.setCheckedElements(list.toArray()); } } @@ -863,49 +797,72 @@ public class CommonTab extends AbstractLaunchConfigurationTab { */ @SuppressWarnings("deprecation") private void updateConfigFromFavorites(ILaunchConfigurationWorkingCopy config) { - try { - Object[] checked = fFavoritesTable.getCheckedElements(); - boolean debug = config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false); - boolean run = config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false); - if (debug || run) { - // old attributes - List<LaunchGroupExtension> groups = new ArrayList<>(); - int num = 0; - if (debug) { - groups.add(getLaunchConfigurationManager().getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP)); - num++; - } - if (run) { - num++; - groups.add(getLaunchConfigurationManager().getLaunchGroup(IDebugUIConstants.ID_RUN_LAUNCH_GROUP)); - } - // see if there are any changes - if (num == checked.length) { - boolean different = false; - for (int i = 0; i < checked.length; i++) { - if (!groups.contains(checked[i])) { - different = true; - break; - } - } - if (!different) { - return; + Object[] checked = fFavoritesTable.getCheckedElements(); + boolean debug = getAttribute(config, IDebugUIConstants.ATTR_DEBUG_FAVORITE, false); + boolean run = getAttribute(config, IDebugUIConstants.ATTR_RUN_FAVORITE, false); + if (debug || run) { + // old attributes + List<LaunchGroupExtension> groups = new ArrayList<>(); + int num = 0; + if (debug) { + groups.add(getLaunchConfigurationManager().getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP)); + num++; + } + if (run) { + num++; + groups.add(getLaunchConfigurationManager().getLaunchGroup(IDebugUIConstants.ID_RUN_LAUNCH_GROUP)); + } + // see if there are any changes + if (num == checked.length) { + boolean different = false; + for (Object checked1 : checked) { + if (!groups.contains(checked1)) { + different = true; + break; } } - } - config.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String)null); - config.setAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, (String)null); - List<String> groups = null; - for (int i = 0; i < checked.length; i++) { - LaunchGroupExtension group = (LaunchGroupExtension)checked[i]; - if (groups == null) { - groups = new ArrayList<>(); + if (!different) { + return; } - groups.add(group.getIdentifier()); } - config.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groups); - } catch (CoreException e) { - DebugUIPlugin.log(e); + } + config.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String) null); + config.setAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, (String) null); + List<String> groups = null; + for (Object c : checked) { + LaunchGroupExtension group = (LaunchGroupExtension) c; + if (groups == null) { + groups = new ArrayList<>(); + } + groups.add(group.getIdentifier()); + } + config.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groups); + } + + private static boolean getAttribute(ILaunchConfiguration config, String attribute, boolean defaultValue) { + try { + return config.getAttribute(attribute, defaultValue); + } catch (CoreException ce) { + DebugUIPlugin.log(ce); + return defaultValue; + } + } + + private static String getAttribute(ILaunchConfiguration config, String attribute, String defaultValue) { + try { + return config.getAttribute(attribute, defaultValue); + } catch (CoreException ce) { + DebugUIPlugin.log(ce); + return defaultValue; + } + } + + private static List<String> getAttribute(ILaunchConfiguration config, String attribute, List<String> defaultValue) { + try { + return config.getAttribute(attribute, defaultValue); + } catch (CoreException ce) { + DebugUIPlugin.log(ce); + return defaultValue; } } @@ -930,13 +887,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * @return true if the validate encoding is allowable, false otherwise */ private boolean validateEncoding() { - if (fAltEncodingButton.getSelection()) { - if (fEncodingCombo.getSelectionIndex() == -1) { - if (!isValidEncoding(fEncodingCombo.getText().trim())) { - setErrorMessage(LaunchConfigurationsMessages.CommonTab_15); - return false; - } - } + if (fAltEncodingButton.getSelection() && fEncodingCombo.getSelectionIndex() == -1 + && !isValidEncoding(fEncodingCombo.getText().trim())) { + setErrorMessage(LaunchConfigurationsMessages.CommonTab_15); + return false; } return true; } @@ -1001,7 +955,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { public void performApply(ILaunchConfigurationWorkingCopy configuration) { updateConfigFromLocalShared(configuration); updateConfigFromFavorites(configuration); - setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, configuration, fLaunchInBackgroundButton.getSelection(), true); + + boolean launchInBackground = fLaunchInBackgroundButton.getSelection(); + setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, configuration, launchInBackground, true); + + boolean terminateDescendants = fTerminateDescendantsButton.getSelection(); + setAttribute(DebugPlugin.ATTR_TERMINATE_DESCENDANTS, configuration, terminateDescendants, true); + String encoding = null; if(fAltEncodingButton.getSelection()) { encoding = fEncodingCombo.getText().trim(); @@ -1031,6 +991,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } else { configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String)null); } + if (fMergeOutput != null) { + if (fMergeOutput.getSelection()) { + configuration.setAttribute(DebugPlugin.ATTR_MERGE_OUTPUT, true); + } else { + configuration.setAttribute(DebugPlugin.ATTR_MERGE_OUTPUT, (String) null); + } + } if (!captureOutput) { configuration.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, false); @@ -1082,6 +1049,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_APPEND_TO_FILE, LaunchConfigurationsMessages.CommonTab_AttributeLabel_AppendToFile); getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, LaunchConfigurationsMessages.CommonTab_AttributeLabel_LaunchInBackground); getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_FAVORITE_GROUPS, LaunchConfigurationsMessages.CommonTab_AttributeLabel_FavoriteGroups); + getAttributesLabelsForPrototype().put(DebugPlugin.ATTR_TERMINATE_DESCENDANTS, LaunchConfigurationsMessages.CommonTab_AttributeLabel_TerminateDescendants); } /** @@ -1094,8 +1062,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List<ILaunchGroup> possibleGroups = new ArrayList<>(); ILaunchConfiguration configuration = (ILaunchConfiguration)inputElement; - for (int i = 0; i < groups.length; i++) { - ILaunchGroup extension = groups[i]; + for (ILaunchGroup extension : groups) { LaunchHistory history = getLaunchConfigurationManager().getLaunchHistory(extension.getIdentifier()); if (history != null && history.accepts(configuration)) { possibleGroups.add(extension); @@ -1122,15 +1089,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { @Override public Image getColumnImage(Object element, int columnIndex) { - Image image = fImages.get(element); - if (image == null) { - ImageDescriptor descriptor = ((LaunchGroupExtension)element).getImageDescriptor(); - if (descriptor != null) { - image = descriptor.createImage(); - fImages.put(element, image); - } - } - return image; + return fImages.computeIfAbsent(element, e -> { + ImageDescriptor descriptor = ((LaunchGroupExtension) e).getImageDescriptor(); + return descriptor != null ? descriptor.createImage() : null; + }); } @Override diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java index d939d751d..d8afa766d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java @@ -13,11 +13,12 @@ *******************************************************************************/ package org.eclipse.debug.ui; +import java.text.MessageFormat; + 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.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.PopupDialog; @@ -31,8 +32,7 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.IHandlerActivation; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.keys.IBindingService; - -import com.ibm.icu.text.MessageFormat; +import org.osgi.framework.FrameworkUtil; /** * A <code>PopupDialog</code> that is automatically positioned relative @@ -171,8 +171,7 @@ public abstract class DebugPopup extends PopupDialog { @Override protected IDialogSettings getDialogSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); - return settings; + return PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(DebugPopup.class)).getDialogSettings(); } @Override diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java index 886f32ef6..f5e1e6f17 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,7 +16,6 @@ package org.eclipse.debug.ui; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -29,6 +28,7 @@ import org.eclipse.core.commands.operations.IUndoableOperation; import org.eclipse.core.commands.operations.ObjectUndoContext; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IConfigurationElement; @@ -73,6 +73,7 @@ import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager; import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility; import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils; import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager; +import org.eclipse.debug.internal.ui.views.breakpoints.DeleteBreakpointMarkersOperation; import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager; import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.debug.ui.contexts.IDebugContextManager; @@ -102,7 +103,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.ide.undo.DeleteMarkersOperation; import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; @@ -220,11 +220,9 @@ public class DebugUITools { IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.ID_DEBUG_MODEL_PRESENTATION); if (point != null) { IExtension[] extensions= point.getExtensions(); - for (int i= 0; i < extensions.length; i++) { - IExtension extension= extensions[i]; + for (IExtension extension : extensions) { IConfigurationElement[] configElements= extension.getConfigurationElements(); - for (int j= 0; j < configElements.length; j++) { - IConfigurationElement elt= configElements[j]; + for (IConfigurationElement elt : configElements) { String id= elt.getAttribute("id"); //$NON-NLS-1$ if (id != null && id.equals(identifier)) { return new LazyModelPresentation(elt); @@ -304,6 +302,13 @@ public class DebugUITools { * @since 3.7 */ public static void deleteBreakpoints(IBreakpoint[] breakpoints, final Shell shell, IProgressMonitor progressMonitor) throws CoreException { + if (breakpoints.length == 0) { + // Note: this is not only a small performance optimization but also the fix for + // bug 344352. When removing no breakpoints the DeleteMarkersOperation will show + // an error dialog about missing markers. + return; + } + IMarker[] markers= new IMarker[breakpoints.length]; int markerCount; for (markerCount= 0; markerCount < breakpoints.length; markerCount++) { @@ -322,11 +327,6 @@ public class DebugUITools { DebugPlugin.getDefault().getBreakpointManager().removeBreakpoints(breakpoints, !allowUndo); if (allowUndo) { - - for (int i= 0; i < markers.length; i++) { - markers[i].setAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, true); - } - IAdaptable context= null; if (shell != null) { context= new IAdaptable() { @@ -342,7 +342,7 @@ public class DebugUITools { } String operationName= markers.length == 1 ? ActionMessages.DeleteBreakpointOperationName : ActionMessages.DeleteBreakpointsOperationName; - IUndoableOperation deleteMarkerOperation= new DeleteMarkersOperation(markers, operationName); + IUndoableOperation deleteMarkerOperation = new DeleteBreakpointMarkersOperation(markers, operationName); deleteMarkerOperation.removeContext(WorkspaceUndoUtil.getWorkspaceUndoContext()); deleteMarkerOperation.addContext(DebugUITools.getBreakpointsUndoContext()); IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory(); @@ -537,8 +537,7 @@ public class DebugUITools { @Deprecated public static int openLaunchConfigurationDialog(Shell shell, IStructuredSelection selection, String mode) { ILaunchGroup[] groups = getLaunchGroups(); - for (int i = 0; i < groups.length; i++) { - ILaunchGroup group = groups[i]; + for (ILaunchGroup group : groups) { if (group.getMode().equals(mode) && group.getCategory() == null) { return openLaunchConfigurationDialogOnGroup(shell, selection, group.getIdentifier()); } @@ -859,8 +858,7 @@ public class DebugUITools { try { IResource[] configResource = iLaunch.getLaunchConfiguration().getMappedResources(); if (configResource != null && configResource.length == 1) { - for (Iterator<Object> iter = fgLaunchToggleTerminateMap.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); + for (Object key : fgLaunchToggleTerminateMap.keySet()) { if (key instanceof IEditorPart) { IEditorInput input = ((IEditorPart) key).getEditorInput(); if (input.getAdapter(IResource.class).equals(configResource[0])) { @@ -871,7 +869,7 @@ public class DebugUITools { TreePath[] treePath = selection.getPaths(); if (treePath != null && treePath.length == 1) { Object lastSegmentObj = treePath[0].getLastSegment(); - IResource selectedResource = ((IAdaptable) lastSegmentObj).getAdapter(IResource.class); + IResource selectedResource = Adapters.adapt(lastSegmentObj, IResource.class); if (selectedResource!= null && selectedResource.equals(configResource[0])) { return isShiftTerminateLaunch(key); } @@ -879,8 +877,7 @@ public class DebugUITools { } } } else { - for (Iterator<Object> iter = fgLaunchToggleTerminateMap.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); + for (Object key : fgLaunchToggleTerminateMap.keySet()) { if (key instanceof IStructuredSelection) { Object toggleValue = getToggleTerminateValue(key); if (toggleValue instanceof TerminateToggleValue) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java index 28c6bf347..966500e90 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java @@ -18,6 +18,7 @@ *******************************************************************************/ package org.eclipse.debug.ui; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -63,7 +64,6 @@ import org.eclipse.jface.viewers.IBaseLabelProvider; import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -88,8 +88,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; @@ -98,8 +96,6 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.PlatformUI; -import com.ibm.icu.text.MessageFormat; - /** * Launch configuration tab for configuring the environment passed into * Runtime.exec(...) when a config is launched. @@ -237,7 +233,6 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { public EnvironmentTab() { super(); setHelpContextId(IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB); - try { this.copyKeyStroke = KeyStroke.getInstance("M1+C"); //$NON-NLS-1$ } catch (ParseException e) { @@ -315,12 +310,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { environmentTable.setContentProvider(new EnvironmentVariableContentProvider()); environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider()); environmentTable.setColumnProperties(new String[] { P_VARIABLE, P_VALUE }); - environmentTable.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - handleTableSelectionChanged(event); - } - }); + environmentTable.addSelectionChangedListener(this::handleTableSelectionChanged); // Setup right-click context menu Menu menuTable = new Menu(table); @@ -328,8 +318,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // Create add environment variable menu item MenuItem miAdd = new MenuItem(menuTable, SWT.NONE); - miAdd.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu0); - + miAdd.setText(LaunchConfigurationsMessages.EnvironmentTab_Add_4); miAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -339,7 +328,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // Create copy environment variable menu item MenuItem miCopy = new MenuItem(menuTable, SWT.NONE); - miCopy.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu1); + miCopy.setText(LaunchConfigurationsMessages.EnvironmentTab_Copy); miCopy.addSelectionListener(new SelectionAdapter() { @Override @@ -350,7 +339,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // Create paste environment variable menu item MenuItem miPaste = new MenuItem(menuTable, SWT.NONE); - miPaste.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu2); + miPaste.setText(LaunchConfigurationsMessages.EnvironmentTab_Paste); miPaste.addSelectionListener(new SelectionAdapter() { @Override @@ -361,7 +350,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // Create remove environment variable menu item MenuItem miRemove = new MenuItem(menuTable, SWT.NONE); - miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu3); + miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_Remove_6); miRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -369,33 +358,26 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { } }); - environmentTable.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = environmentTable.getStructuredSelection(); - if (selection.size() == 1) { - miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu3); - } else if (selection.size() > 1) { - miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu4); - } + environmentTable.addSelectionChangedListener(event -> { + IStructuredSelection selection = environmentTable.getStructuredSelection(); + if (selection.size() == 1) { + miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_Remove_6); + } else if (selection.size() > 1) { + miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_Remove_All); } }); // Disable certain context menu item's if no table item is selected - table.addListener(SWT.MenuDetect, new Listener() { - @Override - public void handleEvent(Event event) { - if (table.getSelectionCount() <= 0) { - miRemove.setEnabled(false); - miCopy.setEnabled(false); - } else { - miRemove.setEnabled(true); - miCopy.setEnabled(true); - } + table.addListener(SWT.MenuDetect, event -> { + if (table.getSelectionCount() <= 0) { + miRemove.setEnabled(false); + miCopy.setEnabled(false); + } else { + miRemove.setEnabled(true); + miCopy.setEnabled(true); } }); - // Setup and create Columns ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(environmentTable) { @Override @@ -404,32 +386,32 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } + }; - int feature = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR - | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION; + int feature = ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_HORIZONTAL + | ColumnViewerEditor.KEYBOARD_ACTIVATION + | ColumnViewerEditor.TABBING_CYCLE_IN_VIEWER; TableViewerEditor.create(environmentTable, actSupport, feature); // Setup environment variable name column final TableViewerColumn tcv1 = new TableViewerColumn(environmentTable, SWT.NONE, 0); - tcv1.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - return ((EnvironmentVariable) element).getName(); - } - }); + tcv1.setLabelProvider( + ColumnLabelProvider.createTextProvider(element -> ((EnvironmentVariable) element).getName())); TableColumn tc1 = tcv1.getColumn(); tc1.setText(envTableColumnHeaders[0]); tcv1.setEditingSupport(new TextGetSetEditingSupport<>(tcv1.getViewer(), EnvironmentVariable::getName, (EnvironmentVariable envVar, String value) -> { - if (value != null && !value.isEmpty()) { - if (!value.equals(envVar.getName())) { - // Trim environment variable names - EnvironmentVariable editedVar = new EnvironmentVariable(value.trim(), envVar.getValue()); - if (addVariable(editedVar)) { - environmentTable.remove(envVar); + // Trim environment variable names + String newName = value.trim(); + if (newName != null && !newName.isEmpty()) { + if (!newName.equals(envVar.getName())) { + if (canRenameVariable(newName)) { + envVar.setName(newName); + updateAppendReplace(); + updateLaunchConfigurationDialog(); } } } @@ -437,17 +419,14 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // Setup environment variable value column final TableViewerColumn tcv2 = new TableViewerColumn(environmentTable, SWT.NONE, 1); - tcv2.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - return ((EnvironmentVariable) element).getValue(); - } - }); + tcv2.setLabelProvider( + ColumnLabelProvider.createTextProvider(element -> ((EnvironmentVariable) element).getValue())); TableColumn tc2 = tcv2.getColumn(); tc2.setText(envTableColumnHeaders[1]); tcv2.setEditingSupport( new TextGetSetEditingSupport<>(tcv2.getViewer(), EnvironmentVariable::getValue, (envVar, value) -> { + // Don't trim environment variable values envVar.setValue(value); updateAppendReplace(); updateLaunchConfigurationDialog(); @@ -461,7 +440,6 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { tableComposite.setLayout(tableColumnLayout); environmentTable.getTable().addKeyListener(new KeyAdapter() { - @Override public void keyReleased(KeyEvent e) { KeyStroke current = computeKeyStroke(e); @@ -498,7 +476,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END, 0, 0); // Create buttons - envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_New_4, null); + envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_Add_4, null); envAddButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -570,19 +548,44 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { } /** - * Attempts to add the given variable. Returns whether the variable was added or - * not (as when the user answers not to overwrite an existing variable). + * Returns whether the environment variable can be renamed to the given variable + * name. If the name is already used for another variable, the user decides with + * a dialog whether to overwrite the existing variable * - * @param variable the variable to add - * @param forceOverwrite whether the user should be given a confirmation prompt - * when overwriting a variable + * @param newVariableName the chosen name to give to the variable + * @return whether the new name should be used or not + */ + private boolean canRenameVariable(String newVariableName) { + for (TableItem item : environmentTable.getTable().getItems()) { + EnvironmentVariable existingVariable = (EnvironmentVariable) item.getData(); + if (existingVariable.getName().equals(newVariableName)) { + + boolean overWrite = MessageDialog.openQuestion(getShell(), + LaunchConfigurationsMessages.EnvironmentTab_12, + MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, + new Object[] { newVariableName })); + if (!overWrite) { + return false; + } + environmentTable.remove(existingVariable); + return true; + } + } + return true; + } + + /** + * Attempts to add the given variable. Returns whether the variable + * was added or not (as when the user answers not to overwrite an + * existing variable). + * @param variable the variable to add * @return whether the variable was added */ protected boolean addVariable(EnvironmentVariable variable) { String name = variable.getName(); TableItem[] items = environmentTable.getTable().getItems(); - for (int i = 0; i < items.length; i++) { - EnvironmentVariable existingVariable = (EnvironmentVariable) items[i].getData(); + for (TableItem item : items) { + EnvironmentVariable existingVariable = (EnvironmentVariable) item.getData(); if (existingVariable.getName().equals(name)) { boolean overWrite = MessageDialog.openQuestion(getShell(), @@ -590,7 +593,6 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, new Object[] { name })); // if (!overWrite) { return false; - } environmentTable.remove(existingVariable); break; @@ -659,8 +661,8 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // get Environment Variables from the table TableItem[] items = environmentTable.getTable().getItems(); - for (int i = 0; i < items.length; i++) { - EnvironmentVariable var = (EnvironmentVariable) items[i].getData(); + for (TableItem item : items) { + EnvironmentVariable var = (EnvironmentVariable) item.getData(); envVariables.remove(var.getName()); } @@ -670,8 +672,8 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { int button = dialog.open(); if (button == Window.OK) { Object[] selected = dialog.getResult(); - for (int i = 0; i < selected.length; i++) { - environmentTable.add(selected[i]); + for (Object o : selected) { + environmentTable.add(o); } } @@ -709,7 +711,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11); dialog.addTextField(NAME_LABEL, originalName, false); - if (value != null && value.contains(System.getProperty("line.separator"))) { //$NON-NLS-1$ + if (value != null && value.contains(System.lineSeparator())) { dialog.addMultilinedVariablesField(VALUE_LABEL, value, true); } else { dialog.addVariablesField(VALUE_LABEL, value, true); @@ -857,8 +859,8 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { // configuration's attributes. TableItem[] items = environmentTable.getTable().getItems(); Map<String, String> map = new HashMap<>(items.length); - for (int i = 0; i < items.length; i++) { - EnvironmentVariable var = (EnvironmentVariable) items[i].getData(); + for (TableItem item : items) { + EnvironmentVariable var = (EnvironmentVariable) item.getData(); map.put(var.getName(), var.getValue()); } if (map.isEmpty()) { @@ -1011,13 +1013,10 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { public Object[] getElements(Object inputElement) { EnvironmentVariable[] elements = null; if (inputElement instanceof HashMap) { - Comparator<Object> comparator = new Comparator<Object>() { - @Override - public int compare(Object o1, Object o2) { - String s1 = (String) o1; - String s2 = (String) o2; - return s1.compareTo(s2); - } + Comparator<Object> comparator = (o1, o2) -> { + String s1 = (String) o1; + String s2 = (String) o2; + return s1.compareTo(s2); }; TreeMap<Object, Object> envVars = new TreeMap<>(comparator); envVars.putAll((Map<?, ?>) inputElement); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IBreakpointOrganizerDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IBreakpointOrganizerDelegate.java index 34673c50b..d9ae2d270 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IBreakpointOrganizerDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IBreakpointOrganizerDelegate.java @@ -30,7 +30,7 @@ import org.eclipse.jface.util.IPropertyChangeListener; * <p> * Following is example plug-in XML for contributing a breakpoint organizer. * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.breakpointOrganizers"> * <breakpointOrganizer @@ -40,7 +40,7 @@ import org.eclipse.jface.util.IPropertyChangeListener; * icon="icons/full/obj16/example_org.png"/> * </extension> * </pre> - * + * * The attributes are specified as follows: * <ul> * <li><code>class</code> Fully qualified name of a Java class that implements @@ -55,7 +55,7 @@ import org.eclipse.jface.util.IPropertyChangeListener; * Clients contributing a breakpoint organizer are intended to implement this * interface. * </p> - * + * * @since 3.1 */ public interface IBreakpointOrganizerDelegate { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index 58be140f4..208e033e8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -966,9 +966,8 @@ public interface IDebugUIConstants { String ATTR_CAPTURE_IN_CONSOLE = PLUGIN_ID + ".ATTR_CONSOLE_OUTPUT_ON"; //$NON-NLS-1$ /** - * Launch configuration boolean attribute specifying whether input for the - * launched process will be captured from file. Default value is - * <code>null</code>. + * Launch configuration attribute to specifying a file whose content is supplied + * to the launched process input stream. Default value is <code>null</code>. * * @since 3.11 */ @@ -1281,6 +1280,13 @@ public interface IDebugUIConstants { String PREF_DETAIL_PANE_FONT= "org.eclipse.debug.ui.DetailPaneFont"; //$NON-NLS-1$ /** + * Preference to enable variable view inline on text editors. + * + * @since 3.16 + */ + String PREF_SHOW_VARIABLES_INLINE = "org.eclipse.debug.ui.ShowVariableInline"; //$NON-NLS-1$ + + /** * Instruction pointer image for editor ruler for the currently executing * instruction in the top stack frame. * @@ -1348,4 +1354,5 @@ public interface IDebugUIConstants { * @since 3.8 */ String COLUMN_ID_VARIABLE_VALUE_TYPE = COLUMN_PRESENTATION_ID_VARIABLE + ".COL_VALUE_TYPE"; //$NON-NLS-1$ + } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDetailPaneFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDetailPaneFactory.java index 0d2ebf204..b2a68b98b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDetailPaneFactory.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDetailPaneFactory.java @@ -24,7 +24,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; * <code>org.eclipse.debug.ui.detailPaneFactories</code> extension point. * Following is an example of a detail pane factory extension: * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.detailPaneFactories"> * <detailFactories @@ -33,10 +33,10 @@ import org.eclipse.jface.viewers.IStructuredSelection; * </detailFactories> * </extension> * </pre> - * + * * Clients contributing a detail pane factory are intended to implement this * interface. - * + * * @see IDetailPane * @since 3.3 * diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java index 9c421cbfc..d539985c0 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java @@ -33,7 +33,7 @@ import org.eclipse.ui.IEditorPart; * A launch shortcut extension is defined in <code>plugin.xml</code>. Following * is an example definition of a launch shortcut extension. * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.launchShortcuts"> * <shortcut diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ISourcePresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ISourcePresentation.java index 77659434a..2f440f239 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ISourcePresentation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ISourcePresentation.java @@ -43,7 +43,7 @@ import org.eclipse.ui.IEditorInput; * {@link org.eclipse.debug.ui.IDebugModelPresentation} or as an optional * extension to an {@link org.eclipse.debug.core.model.ISourceLocator}. * </p> - * + * * @since 2.0 */ public interface ISourcePresentation { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java index 244d2d55f..f49774165 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java @@ -110,9 +110,7 @@ public class InspectPopupDialog extends DebugPopup { if (view != null) { // copy over properties IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext(); - String[] properties = copy.getProperties(); - for (int i = 0; i < properties.length; i++) { - String key = properties[i]; + for (String key : copy.getProperties()) { fContext.setProperty(key, copy.getProperty(key)); } } @@ -140,9 +138,8 @@ public class InspectPopupDialog extends DebugPopup { if (view != null) { StructuredViewer structuredViewer = (StructuredViewer) view.getViewer(); if (structuredViewer != null) { - ViewerFilter[] filters = structuredViewer.getFilters(); - for (int i = 0; i < filters.length; i++) { - fViewer.addFilter(filters[i]); + for (ViewerFilter filter : structuredViewer.getFilters()) { + fViewer.addFilter(filter); } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java index 8db2295f0..e2f8c1dc1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java @@ -49,6 +49,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.osgi.framework.FrameworkUtil; /** * A dialog that prompts the user to choose and configure a string @@ -183,13 +184,13 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog { ArrayList<Object> filtered = new ArrayList<>(); filtered.addAll(Arrays.asList(elements)); if(!fFilters.isEmpty() && !fShowAllSelected) { - for (int i = 0; i < elements.length; i++) { - if(elements[i] instanceof IDynamicVariable) { + for (Object element : elements) { + if (element instanceof IDynamicVariable) { boolean bFiltered = false; for (int j = 0; (j < fFilters.size()) && !bFiltered; j++) { VariableFilter filter = fFilters.get(j); - if(filter.isFiltered((IDynamicVariable)elements[i])) { - filtered.remove(elements[i]); + if (filter.isFiltered((IDynamicVariable) element)) { + filtered.remove(element); bFiltered = true; } } @@ -387,7 +388,9 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog { @Override protected IDialogSettings getDialogBoundsSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings settings = PlatformUI + .getDialogSettingsProvider(FrameworkUtil.getBundle(StringVariableSelectionDialog.class)) + .getDialogSettings(); IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); if (section == null) { section = settings.addNewSection(getDialogSettingsSectionName()); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java index d0fc7c389..f68a5a13d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java @@ -14,9 +14,11 @@ package org.eclipse.debug.ui.actions; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.concurrent.CompletableFuture; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -51,6 +53,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.MenuAdapter; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; @@ -58,8 +61,6 @@ import org.eclipse.ui.IActionDelegate2; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -import com.ibm.icu.text.MessageFormat; - /** * Abstract implementation of an action that displays a drop-down launch * history for a specific launch group. @@ -181,8 +182,8 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I */ private boolean existsConfigTypesForMode() { ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); - for (int i = 0; i < configTypes.length; i++) { - if (configTypes[i].supportsMode(getMode())) { + for (ILaunchConfigurationType configType : configTypes) { + if (configType.supportsMode(getMode())) { return true; } } @@ -198,7 +199,10 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I * </p> */ protected void updateTooltip() { - getAction().setToolTipText(getToolTip()); + CompletableFuture.supplyAsync(this::getToolTip) + .thenAccept(tooltip -> + Display.getDefault().asyncExec(() -> getAction().setToolTipText(tooltip)) + ); } /** @@ -314,8 +318,8 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I if (fRecreateMenu) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : items) { + item.dispose(); } fillMenu(m); fRecreateMenu= false; @@ -347,8 +351,7 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I // Add favorites int accelerator = 1; - for (int i = 0; i < favoriteList.length; i++) { - ILaunchConfiguration launch= favoriteList[i]; + for (ILaunchConfiguration launch : favoriteList) { LaunchAction action= new LaunchAction(launch, getMode()); addToMenu(menu, action, accelerator); accelerator++; @@ -360,8 +363,7 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I } // Add history launches next - for (int i = 0; i < historyList.length; i++) { - ILaunchConfiguration launch= historyList[i]; + for (ILaunchConfiguration launch : historyList) { LaunchAction action= new LaunchAction(launch, getMode()); addToMenu(menu, action, accelerator); accelerator++; @@ -423,7 +425,7 @@ public abstract class AbstractLaunchHistoryAction implements IActionDelegate2, I /** * @since 3.12 */ - protected void runInternal(IAction action, boolean isShift) { + protected void runInternal(IAction action, @SuppressWarnings("unused") boolean isShift) { run(action); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java index 30eba5386..2abcd920a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java @@ -118,8 +118,8 @@ public class AddMemoryRenderingActionDelegate extends Action implements IViewAct public void menuShown(MenuEvent e) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : items) { + item.dispose(); } fillMenu(m); } @@ -133,9 +133,8 @@ public class AddMemoryRenderingActionDelegate extends Action implements IViewAct { IMemoryRenderingType[] types = fActionDelegate.getMemoryRenderingTypes(fPart, fCurrentSelection); - for (int i=0; i<types.length; i++) - { - AddMemoryRenderingAction action = new AddMemoryRenderingAction(types[i]); + for (IMemoryRenderingType type : types) { + AddMemoryRenderingAction action = new AddMemoryRenderingAction(type); ActionContributionItem item = new ActionContributionItem(action); item.fill(parent, -1); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/BreakpointTypesContribution.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/BreakpointTypesContribution.java index e652248c1..60f9384ae 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/BreakpointTypesContribution.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/BreakpointTypesContribution.java @@ -47,7 +47,7 @@ import org.eclipse.ui.services.IServiceLocator; * Following is example plug-in XML used to contribute this action to an * editor's vertical ruler context menu. * </p> - * + * * <pre> * <extension point="org.eclipse.ui.menus"> * <menuContribution diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java index a763267c5..f3a9da714 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java @@ -86,8 +86,7 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I fMode = mode; ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); fGroupsByCategory = new HashMap<>(3); - for (int i = 0; i < groups.length; i++) { - ILaunchGroup group = groups[i]; + for (ILaunchGroup group : groups) { if (group.getMode().equals(mode)) { if (group.getCategory() == null) { fGroup = group; @@ -132,8 +131,8 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I if (fFillMenu) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : items) { + item.dispose(); } fillMenu(m); fFillMenu = false; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java index c3ce545d2..528fe429e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java @@ -16,7 +16,6 @@ package org.eclipse.debug.ui.actions; import org.eclipse.debug.core.IRequest; import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; -import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant; import org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.contexts.DebugContextEvent; @@ -82,12 +81,7 @@ public abstract class DebugCommandAction extends Action implements IDebugContext */ private IAction fAction; - private IEnabledTarget fEnabledTarget = new IEnabledTarget() { - @Override - public void setEnabled(boolean enabled) { - DebugCommandAction.this.setEnabled(enabled); - } - }; + private IEnabledTarget fEnabledTarget = DebugCommandAction.this::setEnabled; /** * Constructor @@ -122,12 +116,7 @@ public abstract class DebugCommandAction extends Action implements IDebugContext private boolean execute(final Object[] targets) { return fUpdateService.executeCommand( getCommandType(), targets, - new ICommandParticipant() { - @Override - public void requestDone(org.eclipse.debug.core.IRequest request) { - DebugCommandAction.this.postExecute(request, targets); - } - }); + request -> DebugCommandAction.this.postExecute(request, targets)); } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java index 442bbc396..973128ba6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java @@ -25,7 +25,6 @@ import org.eclipse.core.commands.HandlerEvent; import org.eclipse.core.expressions.IEvaluationContext; import org.eclipse.debug.core.IRequest; import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; -import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant; import org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.contexts.DebugContextEvent; @@ -228,12 +227,7 @@ public abstract class DebugCommandHandler extends AbstractHandler { DebugCommandService service = DebugCommandService.getService(window); return service.executeCommand( getCommandType(), targets, - new ICommandParticipant() { - @Override - public void requestDone(org.eclipse.debug.core.IRequest request) { - DebugCommandHandler.this.postExecute(request, targets); - } - }); + request -> DebugCommandHandler.this.postExecute(request, targets)); } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java index 9d26718bf..40ad4cfb5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java @@ -21,6 +21,7 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; +import java.text.MessageFormat; import java.util.Map.Entry; import org.eclipse.core.resources.IMarker; @@ -41,8 +42,6 @@ import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.XMLMemento; -import com.ibm.icu.text.MessageFormat; - /** * Exports breakpoints to a file or string buffer. * <p> @@ -90,11 +89,10 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress { SubMonitor localmonitor = SubMonitor.convert(monitor, ImportExportMessages.ExportOperation_0, fBreakpoints.length); XMLMemento memento = XMLMemento.createWriteRoot(IImportExportConstants.IE_NODE_BREAKPOINTS); try (Writer writer = fWriter) { - for (int i = 0; i < fBreakpoints.length; i++) { + for (IBreakpoint breakpoint : fBreakpoints) { if (localmonitor.isCanceled()) { return; } - IBreakpoint breakpoint = fBreakpoints[i]; //in the event we are in working set view, we can have multiple selection of the same breakpoint //so do a simple check for it IMarker marker = breakpoint.getMarker(); @@ -170,10 +168,9 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress { IWorkingSetManager mgr = PlatformUI.getWorkbench().getWorkingSetManager(); StringBuilder buffer = new StringBuilder(); IWorkingSet[] sets = mgr.getWorkingSets(); - for (int i = 0; i < sets.length; i++) { - if(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(sets[i].getId()) && - containsBreakpoint(sets[i], breakpoint)) { - buffer.append(IImportExportConstants.DELIMITER).append(sets[i].getName()); + for (IWorkingSet set : sets) { + if (IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(set.getId()) && containsBreakpoint(set, breakpoint)) { + buffer.append(IImportExportConstants.DELIMITER).append(set.getName()); } } return buffer.toString(); @@ -188,8 +185,8 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress { */ private boolean containsBreakpoint(IWorkingSet set, IBreakpoint breakpoint) { IAdaptable[] elements = set.getElements(); - for (int i = 0; i < elements.length; i++) { - if (elements[i].equals(breakpoint)) { + for (IAdaptable element : elements) { + if (element.equals(breakpoint)) { return true; } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IAddMemoryRenderingsTarget.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IAddMemoryRenderingsTarget.java index e33c28e1c..37bee0107 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IAddMemoryRenderingsTarget.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IAddMemoryRenderingsTarget.java @@ -43,7 +43,7 @@ import org.eclipse.ui.IWorkbenchPart; * <p> * Clients may implement this interface. * </p> - * + * * @since 3.2 * @see AddMemoryRenderingActionDelegate */ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java index 3b5b744f6..acca1d12d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java @@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.Shell; * <p> * Following is example plug-in XML for contributing a variable value editor. * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.variableValueEditors"> * <variableEditor @@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Shell; * class="com.examples.variables.MyVariableValueEditor"/> * </extension> * </pre> - * + * * The attributes are specified as follows: * <ul> * <li><code>modelId</code> the debug model identifier for which the given @@ -42,7 +42,7 @@ import org.eclipse.swt.widgets.Shell; * <p> * Clients may implement this interface. * </p> - * + * * @since 3.1 */ public interface IVariableValueEditor { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java index 945cc6422..a01b70189 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java @@ -23,6 +23,7 @@ import java.io.Reader; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -53,8 +54,6 @@ import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.XMLMemento; -import com.ibm.icu.text.MessageFormat; - /** * Imports breakpoints from a file or string buffer into the workspace. * <p> @@ -183,11 +182,11 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { localmonitor.setWorkRemaining(nodes.length); Map<String, Object> attributes = null; IBreakpointImportParticipant[] participants = null; - for(int i = 0; i < nodes.length; i++) { + for (IMemento node : nodes) { if(localmonitor.isCanceled()) { return; } - attributes = collectBreakpointProperties(nodes[i]); + attributes = collectBreakpointProperties(node); if(attributes == null) { continue; } @@ -197,7 +196,6 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { } else { resource = workspace; } - // filter resource breakpoints that do not exist in this workspace if(resource != null) { try { @@ -245,14 +243,13 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { */ protected IMarker findExistingMarker(Map<String, Object> attributes, IBreakpointImportParticipant[] participants) { IBreakpoint[] bps = fManager.getBreakpoints(); - for(int i = 0; i < bps.length; i++) { - for(int j = 0; j < participants.length; j++) { + for (IBreakpoint bp : bps) { + for (IBreakpointImportParticipant participant : participants) { try { - if(participants[j].matches(attributes, bps[i])) { - return bps[i].getMarker(); + if (participant.matches(attributes, bp)) { + return bp.getMarker(); } - } - catch(CoreException ce) {} + }catch(CoreException ce) {} } } return null; @@ -285,8 +282,8 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { //copy all the marker attributes to the map IMemento[] children = child.getChildren(IImportExportConstants.IE_NODE_ATTRIB); - for(int i = 0; i < children.length; i++) { - readAttribute(children[i], map); + for (IMemento c : children) { + readAttribute(c, map); } //collect attributes from the 'resource' node @@ -349,8 +346,8 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { updateWorkingSets(names, breakpoint); } if(participants != null) { - for(int i = 0; i < participants.length; i++) { - participants[i].verify(breakpoint); + for (IBreakpointImportParticipant participant : participants) { + participant.verify(breakpoint); } } } @@ -376,14 +373,14 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { IWorkingSetManager mgr = PlatformUI.getWorkbench().getWorkingSetManager(); ArrayList<IWorkingSet> sets = new ArrayList<>(); collectContainingWorkingsets(breakpoint, sets); - for (int i = 0; i < wsnames.length; i++) { - if("".equals(wsnames[i])) { //$NON-NLS-1$ + for (String wsname : wsnames) { + if ("".equals(wsname)) { //$NON-NLS-1$ continue; } - IWorkingSet set = mgr.getWorkingSet(wsnames[i]); - if(set == null) { + IWorkingSet set = mgr.getWorkingSet(wsname); + if (set == null) { //create working set - set = mgr.createWorkingSet(wsnames[i], new IAdaptable[] {}); + set = mgr.createWorkingSet(wsname, new IAdaptable[] {}); set.setId(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID); mgr.addWorkingSet(set); } @@ -416,10 +413,9 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { private void collectContainingWorkingsets(IBreakpoint breakpoint, List<IWorkingSet> collector) { IWorkingSetManager mgr = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSet[] sets = mgr.getWorkingSets(); - for (int i = 0; i < sets.length; i++) { - if(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(sets[i].getId()) && - containsBreakpoint(sets[i], breakpoint)) { - collector.add(sets[i]); + for (IWorkingSet set : sets) { + if (IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(set.getId()) && containsBreakpoint(set, breakpoint)) { + collector.add(set); } } } @@ -432,8 +428,8 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { */ private boolean containsBreakpoint(IWorkingSet set, IBreakpoint breakpoint) { IAdaptable[] elements = set.getElements(); - for (int i = 0; i < elements.length; i++) { - if (elements[i].equals(breakpoint)) { + for (IAdaptable element : elements) { + if (element.equals(breakpoint)) { return true; } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java index 1e010a204..41c5cb3ed 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java @@ -14,6 +14,7 @@ package org.eclipse.debug.ui.actions; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Set; @@ -36,8 +37,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.ui.PlatformUI; -import com.ibm.icu.text.MessageFormat; - /** * Launches a launch configuration in a specific mode. * <p> @@ -143,12 +142,12 @@ public class LaunchAction extends Action { */ private void removeFromLaunchHistories(ILaunchConfiguration config, ILaunchGroup[] groups) { LaunchHistory history = null; - for(int i = 0; i < groups.length; i++) { - history = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchHistory(groups[i].getIdentifier()); - if(history != null) { + for (ILaunchGroup group : groups) { + history = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchHistory(group.getIdentifier()); + if (history != null) { history.removeFromHistory(fConfiguration); } else { - DebugUIPlugin.logErrorMessage(MessageFormat.format("Unable to remove configuration [{0}] from launch history. The launch history for mode [{1}] does not exist.", new Object[] { config.getName(), groups[i].getMode() })); //$NON-NLS-1$ + DebugUIPlugin.logErrorMessage(MessageFormat.format("Unable to remove configuration [{0}] from launch history. The launch history for mode [{1}] does not exist.", new Object[]{config.getName(), group.getMode()})); //$NON-NLS-1$ } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java index b0d800b58..082b7c817 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java @@ -182,8 +182,8 @@ public class LaunchAsAction extends Action implements IMenuCreator, IWorkbenchWi public void menuShown(MenuEvent e) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : items) { + item.dispose(); } fillMenu(); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java index 17dcd129a..dd9b6994c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java @@ -275,8 +275,8 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork public void menuShown(MenuEvent e) { Menu m = (Menu)e.widget; MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : items) { + item.dispose(); } fillMenu(); } @@ -335,8 +335,7 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork */ private boolean existsConfigTypesForMode() { ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); - for (int i = 0; i < configTypes.length; i++) { - ILaunchConfigurationType configType = configTypes[i]; + for (ILaunchConfigurationType configType : configTypes) { if (configType.supportsMode(getMode())) { return true; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java index 9eabdfa9b..b2535ba23 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java @@ -14,6 +14,8 @@ package org.eclipse.debug.ui.actions; +import java.text.MessageFormat; + import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; @@ -35,8 +37,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; -import com.ibm.icu.text.MessageFormat; - /** * Opens the launch configuration dialog in the context of a launch group. * <p> @@ -115,8 +115,7 @@ public class OpenLaunchDialogAction extends Action implements IActionDelegate2, */ private boolean existsConfigTypesForMode() { ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); - for (int i = 0; i < configTypes.length; i++) { - ILaunchConfigurationType configType = configTypes[i]; + for (ILaunchConfigurationType configType : configTypes) { if (configType.supportsMode(getMode())) { return true; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java index 14ec2c03e..b0fe19821 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java @@ -15,6 +15,8 @@ package org.eclipse.debug.ui.actions; +import java.text.MessageFormat; + import org.eclipse.core.commands.Command; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -47,8 +49,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; -import com.ibm.icu.text.MessageFormat; - /** * Re-launches the last launch. * @@ -195,8 +195,7 @@ public abstract class RelaunchLastAction implements IWorkbenchWindowActionDelega */ private boolean existsConfigTypesForMode() { ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); - for (int i = 0; i < configTypes.length; i++) { - ILaunchConfigurationType configType = configTypes[i]; + for (ILaunchConfigurationType configType : configTypes) { if (configType.supportsMode(getMode())) { return true; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java index 65bf5a1df..60c14b0a9 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointTypesActionDelegate.java @@ -54,7 +54,7 @@ import org.eclipse.ui.texteditor.ITextEditorExtension; * extension point, by referencing the ruler's context menu identifier in the * <code>targetID</code> attribute. * </p> - * + * * <pre> * <extension point="org.eclipse.ui.popupMenus"> * <viewerContribution @@ -72,7 +72,7 @@ import org.eclipse.ui.texteditor.ITextEditorExtension; * Clients may refer to this class as an action delegate in plug-in XML. This * class is not intended to be subclassed. * </p> - * + * * @see IToggleBreakpointsTargetManager * @see IToggleBreakpointsTargetFactory * @noextend This class is not intended to be subclassed by clients. @@ -241,9 +241,8 @@ public class RulerBreakpointTypesActionDelegate implements IEditorActionDelegate @Override public void menuShown(MenuEvent e) { Menu m = (Menu)e.widget; - MenuItem[] items = m.getItems(); - for (int i=0; i < items.length; i++) { - items[i].dispose(); + for (MenuItem item : m.getItems()) { + item.dispose(); } fillMenu(m); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java index 8a6b7ad75..c1bc665d7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java @@ -67,8 +67,7 @@ public class RunToLineHandler implements IDebugEventSetListener, IBreakpointMana @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event= events[i]; + for (DebugEvent event : events) { Object source= event.getSource(); if (source instanceof IThread && event.getKind() == DebugEvent.SUSPEND && event.getDetail() == DebugEvent.BREAKPOINT) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java index 5f020524e..ca2d2c969 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java @@ -52,12 +52,7 @@ public class ToggleBreakpointAction extends Action implements IUpdate { private IWorkbenchPart fPart; private IDocument fDocument; private IVerticalRulerInfo fRulerInfo; - private IToggleBreakpointsTargetManagerListener fListener = new IToggleBreakpointsTargetManagerListener() { - @Override - public void preferredTargetsChanged() { - update(); - } - }; + private IToggleBreakpointsTargetManagerListener fListener = this::update; /** * Constructs a new action to toggle a breakpoint in the given diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java index 89cb28b9e..897526c27 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java @@ -30,6 +30,7 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; @@ -56,14 +57,15 @@ public class FileLink implements IConsoleHyperlink { /** * Constructs a hyperlink to the specified file. * - * @param file the file to open when activated - * @param editorId the identifier of the editor to open the file in, or - * <code>null</code> if the default editor should be used - * @param fileOffset the offset in the file to select when activated, or -1 - * @param fileLength the length of text to select in the file when activated - * or -1 - * @param fileLineNumber the line number to select in the file when - * activated, or -1 + * @param file the file to open when activated + * @param editorId the identifier of the editor to open the file in, or + * <code>null</code> if the default editor should be used + * @param fileOffset the offset in the file to select when activated, or -1 + * @param fileLength the length of text to select in the file when activated + * or -1 + * @param fileLineNumber the line number to select in the file when activated, + * or -1. First line number is 1. Only used if + * <em>fileOffset</em> is not set. */ public FileLink(IFile file, String editorId, int fileOffset, int fileLength, int fileLineNumber) { fFile = file; @@ -81,7 +83,7 @@ public class FileLink implements IConsoleHyperlink { if (page != null) { try { IEditorPart editorPart = page.openEditor(new FileEditorInput(fFile), getEditorId() , true); - if (fFileLineNumber > 0) { + if (fFileLineNumber > 0 || (fFileOffset >= 0 && fFileLength >= 0)) { ITextEditor textEditor = null; if (editorPart instanceof ITextEditor) { textEditor = (ITextEditor) editorPart; @@ -89,8 +91,8 @@ public class FileLink implements IConsoleHyperlink { textEditor = editorPart.getAdapter(ITextEditor.class); } if (textEditor != null) { - IEditorInput input = editorPart.getEditorInput(); if (fFileOffset < 0) { + IEditorInput input = editorPart.getEditorInput(); IDocumentProvider provider = textEditor.getDocumentProvider(); try { provider.connect(input); @@ -132,7 +134,7 @@ public class FileLink implements IConsoleHyperlink { private String getEditorId() { if (fEditorId == null) { - IWorkbench workbench= DebugUIPlugin.getDefault().getWorkbench(); + IWorkbench workbench= PlatformUI.getWorkbench(); // If there is a registered editor for the file use it. IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor(fFile.getName(), getFileContentType()); if (desc == null) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleColorProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleColorProvider.java index c0531a590..fca86242d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleColorProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleColorProvider.java @@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.Color; * A console color provider extension is defined in <code>plugin.xml</code>. * Following is an example definition of a console color provider extension. * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.consoleColorProviders"> * <consoleColorProvider @@ -39,7 +39,7 @@ import org.eclipse.swt.graphics.Color; * </consoleColorProvider> * </extension> * </pre> - * + * * The attributes are specified as follows: * <ul> * <li><code>id</code> specifies a unique identifier for this color @@ -53,7 +53,7 @@ import org.eclipse.swt.graphics.Color; * <p> * Clients may implement this interface. * </p> - * + * * @since 2.1 */ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java index 21e0887d0..6d96bedb6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java @@ -1450,17 +1450,15 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering // clean up old columns TableColumn[] oldColumns = fTableViewer.getTable().getColumns(); - for (int i=0; i<oldColumns.length; i++) - { - oldColumns[i].dispose(); + for (TableColumn oldColumn : oldColumns) { + oldColumn.dispose(); } // clean up old cell editors CellEditor[] oldCellEditors = fTableViewer.getCellEditors(); - for (int i=0; i<oldCellEditors.length; i++) - { - oldCellEditors[i].dispose(); + for (CellEditor oldCellEditor : oldCellEditors) { + oldCellEditor.dispose(); } } @@ -2377,9 +2375,8 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering fTableCursor = null; // clean up cell editors - for (int i=0; i<fEditors.length; i++) - { - fEditors[i].dispose(); + for (CellEditor editor : fEditors) { + editor.dispose(); } // remove font change listener when the view tab is disposed @@ -2751,9 +2748,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering int colNum = -1; int numCol = fTableViewer.getColumnProperties().length; - for (int j=0; j<tableItems.length; j++) - { - TableItem item = tableItems[j]; + for (TableItem item : tableItems) { for (int i=0; i<numCol; i++) { Rectangle bound = item.getBounds(i); @@ -3350,9 +3345,8 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering // check each of the items and find the minimum TableItem[] items = table.getItems(); int minHeight = table.getItemHeight(); - for (int i=0; i<items.length; i++) - { - minHeight = Math.min(items[i].getBounds(0).height, minHeight); + for (TableItem item : items) { + minHeight = Math.min(item.getBounds(0).height, minHeight); } return minHeight; @@ -3432,7 +3426,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering } // update UI asynchronously - Display display = DebugUIPlugin.getDefault().getWorkbench().getDisplay(); + Display display = PlatformUI.getWorkbench().getDisplay(); display.asyncExec(() -> { updateLabels(); @@ -3676,14 +3670,12 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering private TableItem getItem(Point point) { TableItem[] items = fTableViewer.getTable().getItems(); - for (int i=0; i<items.length; i++) - { - Point start = new Point(items[i].getBounds(0).x, items[i].getBounds(0).y); + for (TableItem item : items) { + Point start = new Point(item.getBounds(0).x, item.getBounds(0).y); start = fTableViewer.getTable().toDisplay(start); - Point end = new Point(start.x + items[i].getBounds(0).width, start.y + items[i].getBounds(0).height); - + Point end = new Point(start.x + item.getBounds(0).width, start.y + item.getBounds(0).height); if (start.y < point.y && point.y < end.y) { - return items[i]; + return item; } } return null; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/IMemoryBlockTablePresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/IMemoryBlockTablePresentation.java index 0681f3170..fdfd6a7c5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/IMemoryBlockTablePresentation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/IMemoryBlockTablePresentation.java @@ -16,6 +16,7 @@ package org.eclipse.debug.ui.memory; import java.math.BigInteger; + import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.ui.IDebugModelPresentation; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java index e718db992..709dd4758 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java @@ -269,8 +269,7 @@ public class CommonSourceNotFoundEditor extends EditorPart implements IReusableE Object artifact = getArtifact(); if (artifact instanceof IDebugElement) { IDebugElement element = (IDebugElement)artifact; - for (int i = 0; i < launches.length; i++) { - ILaunch launch = launches[i]; + for (ILaunch launch : launches) { if (launch.equals(element.getLaunch())) { closeEditor(); return; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java index f0a3ed757..7fee68f8e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.debug.ui.sourcelookup; +import java.text.MessageFormat; + import org.eclipse.core.runtime.PlatformObject; import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; @@ -22,8 +24,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; -import com.ibm.icu.text.MessageFormat; - /** * Editor input for the <code>CommonSourceNotFoundEditor</code>. The editor * input can be created on an artifact that has a source association. diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/ISourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/ISourceContainerBrowser.java index e6d7be9cb..d45c0930f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/ISourceContainerBrowser.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/ISourceContainerBrowser.java @@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Shell; * contributes a source container browser via the <code>browserClass</code> * attribute. * </p> - * + * * <pre> * <extension point="org.eclipse.debug.ui.sourceContainerPresentations"> * <sourceContainerPresentation @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Shell; * </sourceContainerPresentation> * </extension> * </pre> - * + * * @since 3.0 */ public interface ISourceContainerBrowser { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java index 92440853b..3aa4351e6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java @@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; +import org.osgi.framework.FrameworkUtil; /** * A dialog for editing the source lookup path of a @@ -128,7 +129,8 @@ public class SourceLookupDialog extends TitleAreaDialog { @Override protected IDialogSettings getDialogBoundsSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings settings = PlatformUI + .getDialogSettingsProvider(FrameworkUtil.getBundle(SourceLookupDialog.class)).getDialogSettings(); IDialogSettings section = settings.getSection(getClass().getName()); if (section == null) { section = settings.addNewSection(getClass().getName()); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java index 722cef429..0a0425397 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java @@ -86,18 +86,17 @@ public class WorkingSetSourceContainer extends CompositeSourceContainer{ } ArrayList<ISourceContainer> locationList = new ArrayList<>(); - for (int i = 0; i < elements.length; i++) { - IResource resource = elements[i].getAdapter(IResource.class); - + for (IAdaptable element : elements) { + IResource resource = element.getAdapter(IResource.class); if (resource != null) { switch (resource.getType()) { - case IResource.FOLDER: - locationList.add(new FolderSourceContainer((IFolder)resource, true)); - break; - case IResource.PROJECT: - locationList.add(new ProjectSourceContainer((IProject)resource, true)); - break; - //if the element corresponds to an IFile, do nothing + case IResource.FOLDER: + locationList.add(new FolderSourceContainer((IFolder)resource, true)); + break; + case IResource.PROJECT: + locationList.add(new ProjectSourceContainer((IProject)resource, true)); + break; + //if the element corresponds to an IFile, do nothing default: break; } |