diff options
author | Alexander Kurtakov | 2017-05-18 13:27:35 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-05-18 14:56:01 +0000 |
commit | 57642a908d93abde7dbe77f92cdcf2fb960a1fa0 (patch) | |
tree | fd0e6ccf1e5dabc586a576c271227ba00934c25e | |
parent | 7cf4a497c86e0216748e457bbd8975e548905d72 (diff) | |
download | org.eclipse.linuxtools-57642a908d93abde7dbe77f92cdcf2fb960a1fa0.tar.gz org.eclipse.linuxtools-57642a908d93abde7dbe77f92cdcf2fb960a1fa0.tar.xz org.eclipse.linuxtools-57642a908d93abde7dbe77f92cdcf2fb960a1fa0.zip |
Make use of the new lambda listeners in SWT.
This saves hundreds of anonymous classes being created.
Change-Id: I3ca2b8a2add0f107d36728666adef8305f75e3a9
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Reviewed-on: https://git.eclipse.org/r/97445
Tested-by: Hudson CI
71 files changed, 1608 insertions, 2482 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerFileSelectionDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerFileSelectionDialog.java index 6d2a01452b..0b2db49319 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerFileSelectionDialog.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerFileSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 Red Hat Inc. and others. + * Copyright (c) 2016, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,8 +15,6 @@ import java.util.Iterator; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -108,23 +106,14 @@ public class ContainerFileSelectionDialog extends SelectionDialog { Button selectButton = new Button(buttonComposite, SWT.PUSH); selectButton.setText(Messages.getString(SELECT_ALL_TITLE)); - SelectionListener listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectionGroup.setAllSelections(true); - } - }; + SelectionListener listener = SelectionListener.widgetSelectedAdapter( + e -> selectionGroup.setAllSelections(true)); selectButton.addSelectionListener(listener); Button deselectButton = new Button(buttonComposite, SWT.PUSH); deselectButton.setText(Messages.getString(DESELECT_ALL_TITLE)); - listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectionGroup.setAllSelections(false); - - } - }; + listener = SelectionListener.widgetSelectedAdapter( + e -> selectionGroup.setAllSelections(false)); deselectButton.addSelectionListener(listener); } diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java index f996c79672..c55485770a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Red Hat Inc. and others. + * Copyright (c) 2015, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -234,14 +234,8 @@ public class BuildDockerImageLaunchConfigurationMainTab } private SelectionListener onAlwaysRemoveIntermediateContainers() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - toggleRemoveIntermediateContainersButtonState(); - } - - }; + return SelectionListener.widgetSelectedAdapter( + e -> toggleRemoveIntermediateContainersButtonState()); } /** @@ -251,35 +245,29 @@ public class BuildDockerImageLaunchConfigurationMainTab */ private SelectionListener onBrowseWorkspace(final Text pathText, final Class<?> expectedType) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( - getShell(), new WorkbenchLabelProvider(), - new WorkbenchContentProvider()); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setTitle(LaunchMessages - .getString(BROWSE_WORKSPACE_DIALOG_TITLE)); - dialog.setComparator( - new ResourceComparator(ResourceComparator.NAME)); - dialog.setAllowMultiple(false); - dialog.setValidator(selection -> { - if (selection.length == 1 && expectedType - .isAssignableFrom(selection[0].getClass())) { - return new Status(IStatus.OK, Activator.PLUGIN_ID, - null); - } - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null); - }); - if (dialog.open() == IDialogConstants.OK_ID) { - final IResource selection = (IResource) dialog - .getFirstResult(); - pathText.setText(selection.getFullPath().toOSString()); - buildContextPathWorkspaceRelative = true; + return SelectionListener.widgetSelectedAdapter(e -> { + final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( + getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setTitle( + LaunchMessages.getString(BROWSE_WORKSPACE_DIALOG_TITLE)); + dialog.setComparator( + new ResourceComparator(ResourceComparator.NAME)); + dialog.setAllowMultiple(false); + dialog.setValidator(selection -> { + if (selection.length == 1 && expectedType + .isAssignableFrom(selection[0].getClass())) { + return new Status(IStatus.OK, Activator.PLUGIN_ID, null); } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null); + }); + if (dialog.open() == IDialogConstants.OK_ID) { + final IResource selection = (IResource) dialog.getFirstResult(); + pathText.setText(selection.getFullPath().toOSString()); + buildContextPathWorkspaceRelative = true; } - }; + }); } /** @@ -288,18 +276,14 @@ public class BuildDockerImageLaunchConfigurationMainTab * @return */ private SelectionListener onBrowseFileSystemForDirectory(final Text pathText) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final DirectoryDialog dialog = new DirectoryDialog(getShell()); - final String selection = dialog.open(); - if (selection != null) { - pathText.setText(selection); - buildContextPathWorkspaceRelative = false; - } + return SelectionListener.widgetSelectedAdapter(e -> { + final DirectoryDialog dialog = new DirectoryDialog(getShell()); + final String selection = dialog.open(); + if (selection != null) { + pathText.setText(selection); + buildContextPathWorkspaceRelative = false; } - }; + }); } @Override diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/DockerComposeUpLaunchConfigurationMainTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/DockerComposeUpLaunchConfigurationMainTab.java index d31e6056e4..13ebee10e4 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/DockerComposeUpLaunchConfigurationMainTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/DockerComposeUpLaunchConfigurationMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Red Hat Inc. and others. + * Copyright (c) 2015, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -147,35 +147,29 @@ public class DockerComposeUpLaunchConfigurationMainTab */ private SelectionListener onBrowseWorkspace(final Text pathText, final Class<?> expectedType) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( - getShell(), new WorkbenchLabelProvider(), - new WorkbenchContentProvider()); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setTitle(LaunchMessages.getString( - "DockerComposeUpLaunchConfigurationMainTab.dockerComposePath.browseworkspace.dialog.title")); //$NON-NLS-1$ - dialog.setComparator( - new ResourceComparator(ResourceComparator.NAME)); - dialog.setAllowMultiple(false); - dialog.setValidator(selection -> { - if (selection.length == 1 && expectedType - .isAssignableFrom(selection[0].getClass())) { - return new Status(IStatus.OK, Activator.PLUGIN_ID, - null); - } - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null); - }); - if (dialog.open() == IDialogConstants.OK_ID) { - final IResource selection = (IResource) dialog - .getFirstResult(); - pathText.setText(selection.getFullPath().toOSString()); - dockerComposeFilePathWorkspaceRelative = true; + return SelectionListener.widgetSelectedAdapter(e -> { + final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( + getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setTitle(LaunchMessages.getString( + "DockerComposeUpLaunchConfigurationMainTab.dockerComposePath.browseworkspace.dialog.title")); //$NON-NLS-1$ + dialog.setComparator( + new ResourceComparator(ResourceComparator.NAME)); + dialog.setAllowMultiple(false); + dialog.setValidator(selection -> { + if (selection.length == 1 && expectedType + .isAssignableFrom(selection[0].getClass())) { + return new Status(IStatus.OK, Activator.PLUGIN_ID, null); } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null); + }); + if (dialog.open() == IDialogConstants.OK_ID) { + final IResource selection = (IResource) dialog.getFirstResult(); + pathText.setText(selection.getFullPath().toOSString()); + dockerComposeFilePathWorkspaceRelative = true; } - }; + }); } /** @@ -185,18 +179,14 @@ public class DockerComposeUpLaunchConfigurationMainTab */ private SelectionListener onBrowseFileSystemForDirectory( final Text pathText) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final DirectoryDialog dialog = new DirectoryDialog(getShell()); - final String selection = dialog.open(); - if (selection != null) { - pathText.setText(selection); - dockerComposeFilePathWorkspaceRelative = false; - } + return SelectionListener.widgetSelectedAdapter(e -> { + final DirectoryDialog dialog = new DirectoryDialog(getShell()); + final String selection = dialog.open(); + if (selection != null) { + pathText.setText(selection); + dockerComposeFilePathWorkspaceRelative = false; } - }; + }); } @Override diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageEnvironmentTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageEnvironmentTab.java index fad8364f56..8e3f09c5da 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageEnvironmentTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageEnvironmentTab.java @@ -37,8 +37,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.EnvironmentVariableMode import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -180,65 +178,55 @@ public class RunImageEnvironmentTab extends AbstractLaunchConfigurationTab { private SelectionListener onAddEnvironmentVariable( final TableViewer environmentVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getEnvironmentVariables() - .add(dialog.getEnvironmentVariable()); - environmentVariablesTableViewer - .add(dialog.getEnvironmentVariable()); - environmentVariablesTableViewer.refresh(); - updateLaunchConfigurationDialog(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getEnvironmentVariables() + .add(dialog.getEnvironmentVariable()); + environmentVariablesTableViewer + .add(dialog.getEnvironmentVariable()); + environmentVariablesTableViewer.refresh(); + updateLaunchConfigurationDialog(); } - }; + }); } private SelectionListener onEditEnvironmentVariable( final TableViewer environmentVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final EnvironmentVariableModel selectedVariable = (EnvironmentVariableModel) environmentVariablesTableViewer - .getStructuredSelection().getFirstElement(); - final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( - getShell(), selectedVariable); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedVariable - .setName(dialog.getEnvironmentVariable().getName()); - selectedVariable.setValue( - dialog.getEnvironmentVariable().getValue()); - environmentVariablesTableViewer.refresh(); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final EnvironmentVariableModel selectedVariable = (EnvironmentVariableModel) environmentVariablesTableViewer + .getStructuredSelection().getFirstElement(); + final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( + getShell(), selectedVariable); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedVariable + .setName(dialog.getEnvironmentVariable().getName()); + selectedVariable + .setValue(dialog.getEnvironmentVariable().getValue()); + environmentVariablesTableViewer.refresh(); } - }; + updateLaunchConfigurationDialog(); + }); } private SelectionListener onRemoveEnvironmentVariables( final TableViewer environmentVariablesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = environmentVariablesTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<EnvironmentVariableModel> iterator = selection - .iterator(); iterator.hasNext();) { - EnvironmentVariableModel m = iterator.next(); - model.removeEnvironmentVariable(m); - environmentVariablesTableViewer.remove(m); - environmentVariablesTableViewer.refresh(); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = environmentVariablesTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<EnvironmentVariableModel> iterator = selection + .iterator(); iterator.hasNext();) { + EnvironmentVariableModel m = iterator.next(); + model.removeEnvironmentVariable(m); + environmentVariablesTableViewer.remove(m); + environmentVariablesTableViewer.refresh(); } - }; + updateLaunchConfigurationDialog(); + }); } private static void setControlsEnabled(final Control[] controls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLabelsTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLabelsTab.java index aa4980b235..4b173a3041 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLabelsTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLabelsTab.java @@ -37,8 +37,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumes import org.eclipse.linuxtools.internal.docker.ui.wizards.LabelVariableModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -178,63 +176,51 @@ public class RunImageLabelsTab extends AbstractLaunchConfigurationTab { private SelectionListener onAddLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getLabelVariables().add(dialog.getLabelVariable()); - labelVariablesTableViewer.add(dialog.getLabelVariable()); - labelVariablesTableViewer.refresh(); - updateLaunchConfigurationDialog(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getLabelVariables().add(dialog.getLabelVariable()); + labelVariablesTableViewer.add(dialog.getLabelVariable()); + labelVariablesTableViewer.refresh(); + updateLaunchConfigurationDialog(); } - }; + }); } private SelectionListener onEditLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final LabelVariableModel selectedVariable = (LabelVariableModel) labelVariablesTableViewer - .getStructuredSelection().getFirstElement(); - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell(), selectedVariable); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedVariable - .setName(dialog.getLabelVariable().getName()); - selectedVariable.setValue( - dialog.getLabelVariable().getValue()); - labelVariablesTableViewer.refresh(); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final LabelVariableModel selectedVariable = (LabelVariableModel) labelVariablesTableViewer + .getStructuredSelection().getFirstElement(); + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell(), selectedVariable); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedVariable.setName(dialog.getLabelVariable().getName()); + selectedVariable.setValue(dialog.getLabelVariable().getValue()); + labelVariablesTableViewer.refresh(); } - }; + updateLaunchConfigurationDialog(); + }); } private SelectionListener onRemoveLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = labelVariablesTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<LabelVariableModel> iterator = selection - .iterator(); iterator.hasNext();) { - LabelVariableModel m = iterator.next(); - model.removeLabelVariable(m); - labelVariablesTableViewer.remove(m); - labelVariablesTableViewer.refresh(); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = labelVariablesTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<LabelVariableModel> iterator = selection + .iterator(); iterator.hasNext();) { + LabelVariableModel m = iterator.next(); + model.removeLabelVariable(m); + labelVariablesTableViewer.remove(m); + labelVariablesTableViewer.refresh(); } - }; + updateLaunchConfigurationDialog(); + }); } private static void setControlsEnabled(final Control[] controls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLinksTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLinksTab.java index 3271d79b30..68e4a77ddc 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLinksTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageLinksTab.java @@ -36,8 +36,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ContainerLinkModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -167,64 +165,52 @@ public class RunImageLinksTab extends AbstractLaunchConfigurationTab { } private SelectionListener onAddLink() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final ContainerLinkDialog dialog = new ContainerLinkDialog( - getShell(), model.getSelectedConnection()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.addLink(dialog.getContainerName(), - dialog.getContainerAlias()); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerLinkDialog dialog = new ContainerLinkDialog( + getShell(), model.getSelectedConnection()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.addLink(dialog.getContainerName(), + dialog.getContainerAlias()); } - }; + updateLaunchConfigurationDialog(); + }); } private SelectionListener onEditLink(final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); - final ContainerLinkModel selectedContainerLink = (ContainerLinkModel) selection - .getFirstElement(); - final ContainerLinkDialog dialog = new ContainerLinkDialog( - getShell(), model.getSelectedConnection(), - selectedContainerLink); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedContainerLink - .setContainerName(dialog.getContainerName()); - selectedContainerLink - .setContainerAlias(dialog.getContainerAlias()); - linksTableViewer.refresh(); - updateLaunchConfigurationDialog(); - } + final ContainerLinkModel selectedContainerLink = (ContainerLinkModel) selection + .getFirstElement(); + final ContainerLinkDialog dialog = new ContainerLinkDialog( + getShell(), model.getSelectedConnection(), + selectedContainerLink); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedContainerLink + .setContainerName(dialog.getContainerName()); + selectedContainerLink + .setContainerAlias(dialog.getContainerAlias()); + linksTableViewer.refresh(); + updateLaunchConfigurationDialog(); } - }; + }); } private SelectionListener onRemoveLinks( final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<ContainerLinkModel> iterator = selection - .iterator(); iterator.hasNext();) { - model.removeLink(iterator.next()); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<ContainerLinkModel> iterator = selection + .iterator(); iterator.hasNext();) { + model.removeLink(iterator.next()); } - }; + updateLaunchConfigurationDialog(); + }); } private static void setControlsEnabled(final Control[] controls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageMainTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageMainTab.java index 0d43a76e14..6708256f72 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageMainTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Red Hat Inc. and others. + * Copyright (c) 2015, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,8 +61,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ExposedPortModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.graphics.Point; @@ -457,23 +455,19 @@ public class RunImageMainTab extends AbstractLaunchConfigurationTab { } private SelectionListener onSearchImage() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final ImageSearch imageSearchWizard = new ImageSearch( - RunImageMainTab.this.model.getSelectedConnection(), - RunImageMainTab.this.model.getSelectedImageName(), - new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, - true)); - final boolean completed = CommandUtils - .openWizard(imageSearchWizard, getShell()); - if (completed) { - model.setSelectedImageName( - imageSearchWizard.getSelectedImage()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ImageSearch imageSearchWizard = new ImageSearch( + RunImageMainTab.this.model.getSelectedConnection(), + RunImageMainTab.this.model.getSelectedImageName(), + new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, + true)); + final boolean completed = CommandUtils.openWizard(imageSearchWizard, + getShell()); + if (completed) { + model.setSelectedImageName( + imageSearchWizard.getSelectedImage()); } - }; + }); } @Override diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageNetworkTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageNetworkTab.java index f929d3cb28..df3af5748a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageNetworkTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageNetworkTab.java @@ -29,8 +29,6 @@ import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunNetworkModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.GridLayout; @@ -240,26 +238,18 @@ public class RunImageNetworkTab extends AbstractLaunchConfigurationTab private SelectionListener onContainerSelection(final Button containerButton, final Combo containerList) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final boolean selection = containerButton.getSelection(); - containerList.setEnabled(selection); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final boolean selection = containerButton.getSelection(); + containerList.setEnabled(selection); + }); } private SelectionListener onOtherSelection(final Button otherButton, final Text otherText) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final boolean selection = otherButton.getSelection(); - otherText.setEnabled(selection); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final boolean selection = otherButton.getSelection(); + otherText.setEnabled(selection); + }); } @Override diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImagePortsTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImagePortsTab.java index b977b5dcee..f2853c9cce 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImagePortsTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImagePortsTab.java @@ -45,8 +45,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ExposedPortModel; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -251,68 +249,57 @@ public class RunImagePortsTab extends AbstractLaunchConfigurationTab private SelectionListener onAddPort( final CheckboxTableViewer exposedPortsTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerPortDialog dialog = new ContainerPortDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final ExposedPortModel port = dialog.getPort(); - model.addAvailablePort(port); - model.getSelectedPorts().add(port); - port.setSelected(true); - exposedPortsTableViewer.setChecked(port, true); - updateLaunchConfigurationDialog(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerPortDialog dialog = new ContainerPortDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final ExposedPortModel port = dialog.getPort(); + model.addAvailablePort(port); + model.getSelectedPorts().add(port); + port.setSelected(true); + exposedPortsTableViewer.setChecked(port, true); + updateLaunchConfigurationDialog(); } - }; + }); } private SelectionListener onEditPort( final CheckboxTableViewer exposedPortsTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = exposedPortsTableViewer - .getStructuredSelection(); - final ExposedPortModel selectedContainerPort = (ExposedPortModel) selection - .getFirstElement(); - final ContainerPortDialog dialog = new ContainerPortDialog( - getShell(), selectedContainerPort); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final ExposedPortModel configuredPort = dialog.getPort(); - selectedContainerPort.setContainerPort( - configuredPort.getContainerPort()); - selectedContainerPort - .setHostAddress(configuredPort.getHostAddress()); - selectedContainerPort - .setHostPort(configuredPort.getHostPort()); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = exposedPortsTableViewer + .getStructuredSelection(); + final ExposedPortModel selectedContainerPort = (ExposedPortModel) selection + .getFirstElement(); + final ContainerPortDialog dialog = new ContainerPortDialog( + getShell(), selectedContainerPort); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final ExposedPortModel configuredPort = dialog.getPort(); + selectedContainerPort + .setContainerPort(configuredPort.getContainerPort()); + selectedContainerPort + .setHostAddress(configuredPort.getHostAddress()); + selectedContainerPort.setHostPort(configuredPort.getHostPort()); } - }; + updateLaunchConfigurationDialog(); + }); } private SelectionListener onRemovePorts( final TableViewer portsTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = portsTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<ExposedPortModel> iterator = selection - .iterator(); iterator.hasNext();) { - final ExposedPortModel port = iterator.next(); - model.removeAvailablePort(port); - model.getSelectedPorts().remove(port); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = portsTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<ExposedPortModel> iterator = selection.iterator(); iterator + .hasNext();) { + final ExposedPortModel port = iterator.next(); + model.removeAvailablePort(port); + model.getSelectedPorts().remove(port); } - }; + updateLaunchConfigurationDialog(); + }); } private void togglePortMappingControls(final Control... controls) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageVolumesTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageVolumesTab.java index f9a6387c79..3db390fc0e 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageVolumesTab.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/RunImageVolumesTab.java @@ -53,8 +53,6 @@ import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumes import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType; import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -234,31 +232,23 @@ public class RunImageVolumesTab extends AbstractLaunchConfigurationTab { private SelectionListener onAddDataVolume( final CheckboxTableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( - getShell(), model.getConnection()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getDataVolumes().add(dialog.getDataVolume()); - model.getSelectedDataVolumes().add(dialog.getDataVolume()); - dialog.getDataVolume().setSelected(true); - dataVolumesTableViewer.setChecked(dialog.getDataVolume(), - true); - updateLaunchConfigurationDialog(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( + getShell(), model.getConnection()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getDataVolumes().add(dialog.getDataVolume()); + model.getSelectedDataVolumes().add(dialog.getDataVolume()); + dialog.getDataVolume().setSelected(true); + dataVolumesTableViewer.setChecked(dialog.getDataVolume(), true); + updateLaunchConfigurationDialog(); } - }; + }); } private SelectionListener onEditDataVolume( final CheckboxTableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { + return SelectionListener.widgetSelectedAdapter(e -> { final IStructuredSelection selection = (IStructuredSelection) dataVolumesTableViewer .getSelection(); if (selection.isEmpty()) { @@ -287,27 +277,23 @@ public class RunImageVolumesTab extends AbstractLaunchConfigurationTab { updateLaunchConfigurationDialog(); } } - }; + ); } private SelectionListener onRemoveDataVolumes( final TableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = dataVolumesTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<DataVolumeModel> iterator = selection - .iterator(); iterator.hasNext();) { - final DataVolumeModel volume = iterator.next(); - model.removeDataVolume(volume); - model.getSelectedDataVolumes().remove(volume); - } - updateLaunchConfigurationDialog(); + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = dataVolumesTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<DataVolumeModel> iterator = selection.iterator(); iterator + .hasNext();) { + final DataVolumeModel volume = iterator.next(); + model.removeDataVolume(volume); + model.getSelectedDataVolumes().remove(volume); } - }; + updateLaunchConfigurationDialog(); + }); } private CheckboxTableViewer createVolumesTable(final Composite container) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java index e74bbbce28..32279214ba 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java @@ -64,8 +64,6 @@ import org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils; import org.eclipse.linuxtools.internal.docker.ui.propertytesters.ContainerPropertyTester; import org.eclipse.swt.SWT; 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.widgets.Composite; @@ -417,17 +415,13 @@ public class DockerContainersView extends ViewPart implements } private SelectionListener onColumnSelected() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final TableColumn sortColumn = (TableColumn) e.getSource(); - final DockerContainersComparator comparator = (DockerContainersComparator) viewer - .getComparator(); - comparator.setColumn(sortColumn); - viewer.refresh(); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final TableColumn sortColumn = (TableColumn) e.getSource(); + final DockerContainersComparator comparator = (DockerContainersComparator) viewer + .getComparator(); + comparator.setColumn(sortColumn); + viewer.refresh(); + }); } private void setLayout(final TableViewerColumn viewerColumn, final TableColumnLayout tableLayout, final int weight) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java index e4e4523461..56894e1d61 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java @@ -38,8 +38,7 @@ import org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils; import org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection; import org.eclipse.swt.SWT; 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.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -245,15 +244,12 @@ public class DockerExplorerView extends CommonNavigator implements return form; } - private SelectionAdapter onExplanationClicked() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - CommandUtils.openWizard(new NewDockerConnection(), - PlatformUI.getWorkbench().getModalDialogShellProvider() - .getShell()); - } - }; + private SelectionListener onExplanationClicked() { + return SelectionListener.widgetSelectedAdapter(e -> CommandUtils + .openWizard(new NewDockerConnection(), PlatformUI.getWorkbench() + .getModalDialogShellProvider().getShell()) + + ); } /** diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java index 9312af2f61..886229bd8a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java @@ -49,8 +49,6 @@ import org.eclipse.linuxtools.internal.docker.ui.DockerConnectionWatcher; import org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils; import org.eclipse.swt.SWT; 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.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -326,17 +324,13 @@ public class DockerImagesView extends ViewPart implements IDockerImageListener, } private SelectionListener onColumnSelected() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final TableColumn sortColumn = (TableColumn) e.getSource(); - final DockerImagesComparator comparator = (DockerImagesComparator) viewer - .getComparator(); - comparator.setColumn(sortColumn); - viewer.refresh(); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final TableColumn sortColumn = (TableColumn) e.getSource(); + final DockerImagesComparator comparator = (DockerImagesComparator) viewer + .getComparator(); + comparator.setColumn(sortColumn); + viewer.refresh(); + }); } private void setLayout(final TableViewerColumn viewerColumn, final TableColumnLayout tableLayout, final int weight) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ConfigureLabelsPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ConfigureLabelsPage.java index c1af5c2416..03278c91dd 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ConfigureLabelsPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ConfigureLabelsPage.java @@ -30,8 +30,6 @@ import org.eclipse.linuxtools.docker.ui.Activator; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.linuxtools.internal.docker.ui.launch.LaunchMessages; import org.eclipse.swt.SWT; -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.widgets.Button; @@ -196,60 +194,48 @@ public class ConfigureLabelsPage extends WizardPage { private SelectionListener onAddLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getLabelVariables().add(dialog.getLabelVariable()); - labelVariablesTableViewer.add(dialog.getLabelVariable()); - labelVariablesTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getLabelVariables().add(dialog.getLabelVariable()); + labelVariablesTableViewer.add(dialog.getLabelVariable()); + labelVariablesTableViewer.refresh(); } - }; + }); } private SelectionListener onEditLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final LabelVariableModel selectedVariable = (LabelVariableModel) labelVariablesTableViewer - .getStructuredSelection().getFirstElement(); - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell(), selectedVariable); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedVariable - .setName(dialog.getLabelVariable().getName()); - selectedVariable - .setValue(dialog.getLabelVariable().getValue()); - labelVariablesTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final LabelVariableModel selectedVariable = (LabelVariableModel) labelVariablesTableViewer + .getStructuredSelection().getFirstElement(); + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell(), selectedVariable); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedVariable.setName(dialog.getLabelVariable().getName()); + selectedVariable.setValue(dialog.getLabelVariable().getValue()); + labelVariablesTableViewer.refresh(); } - }; + }); } private SelectionListener onRemoveLabelVariable( final TableViewer labelVariablesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = labelVariablesTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<LabelVariableModel> iterator = selection - .iterator(); iterator.hasNext();) { - LabelVariableModel m = iterator.next(); - model.removeLabelVariable(m); - labelVariablesTableViewer.remove(m); - labelVariablesTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = labelVariablesTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<LabelVariableModel> iterator = selection + .iterator(); iterator.hasNext();) { + LabelVariableModel m = iterator.next(); + model.removeLabelVariable(m); + labelVariablesTableViewer.remove(m); + labelVariablesTableViewer.refresh(); } - }; + }); } private static void setControlsEnabled(final Control[] controls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyFromPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyFromPage.java index cc41322b15..08db0ef14d 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyFromPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyFromPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 Red Hat. + * Copyright (c) 2016, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,8 +26,6 @@ import org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.swt.SWT; 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.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -279,18 +277,14 @@ public class ContainerCopyFromPage extends WizardPage { private SelectionListener onBrowseSelect() { final ContainerCopyFromPage page = this; - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - DirectoryDialog d = new DirectoryDialog( - Activator.getActiveWorkbenchShell()); - String x = d.open(); - if (x != null) { - page.targetText.setText(x); - } + return SelectionListener.widgetSelectedAdapter(e -> { + DirectoryDialog d = new DirectoryDialog( + Activator.getActiveWorkbenchShell()); + String x = d.open(); + if (x != null) { + page.targetText.setText(x); } - }; - + }); } /** * Returns a content provider for <code>FileSystemElement</code>s that returns diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java index 31173f8d29..f852c23daa 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,12 +42,8 @@ import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -225,38 +221,28 @@ public class ContainerCopyToPage selectTypesButton = createButton(buttonComposite, IDialogConstants.SELECT_TYPES_ID, SELECT_TYPES_TITLE, false); - SelectionListener listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleTypesEditButtonPressed(); - } - }; + SelectionListener listener = SelectionListener + .widgetSelectedAdapter(e -> handleTypesEditButtonPressed()); selectTypesButton.addSelectionListener(listener); setButtonLayoutData(selectTypesButton); selectAllButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, SELECT_ALL_TITLE, false); - listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - setAllSelections(true); - updateWidgetEnablements(); - } - }; + listener = SelectionListener.widgetSelectedAdapter(e -> { + setAllSelections(true); + updateWidgetEnablements(); + }); selectAllButton.addSelectionListener(listener); setButtonLayoutData(selectAllButton); deselectAllButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, DESELECT_ALL_TITLE, false); - listener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - setAllSelections(false); - updateWidgetEnablements(); - } - }; + listener = SelectionListener.widgetSelectedAdapter(e -> { + setAllSelections(false); + updateWidgetEnablements(); + }); deselectAllButton.addSelectionListener(listener); setButtonLayoutData(deselectAllButton); @@ -335,57 +321,26 @@ public class ContainerCopyToPage sourceNameField.setFont(parent.getFont()); BidiUtils.applyBidiProcessing(sourceNameField, "file"); - sourceNameField.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateFromSourceField(); - } - }); - - sourceNameField.addKeyListener(new KeyListener() { - /* - * @see KeyListener.keyPressed - */ - @Override - public void keyPressed(KeyEvent e) { - if (e.character == SWT.CR) { - entryChanged = false; - updateFromSourceField(); - } - } + sourceNameField.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> updateFromSourceField())); - /* - * @see KeyListener.keyReleased - */ - @Override - public void keyReleased(KeyEvent e) { + sourceNameField.addKeyListener(KeyListener.keyPressedAdapter(e -> { + if (e.character == SWT.CR) { + entryChanged = false; + updateFromSourceField(); } - }); + })); sourceNameField.addModifyListener(e -> entryChanged = true); - sourceNameField.addFocusListener(new FocusListener() { - /* - * @see FocusListener.focusGained(FocusEvent) - */ - @Override - public void focusGained(FocusEvent e) { - // Do nothing when getting focus + sourceNameField.addFocusListener(FocusListener.focusLostAdapter(e -> { + // Clear the flag to prevent constant update + if (entryChanged) { + entryChanged = false; + updateFromSourceField(); } - /* - * @see FocusListener.focusLost(FocusEvent) - */ - @Override - public void focusLost(FocusEvent e) { - // Clear the flag to prevent constant update - if (entryChanged) { - entryChanged = false; - updateFromSourceField(); - } - - } - }); + })); // source browse button sourceBrowseButton = new Button(sourceContainerGroup, SWT.PUSH); diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java index 256cbd850f..fad15cefa5 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java @@ -44,8 +44,6 @@ import org.eclipse.linuxtools.docker.core.IDockerContainerInfo; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; @@ -343,32 +341,24 @@ public class ContainerDataVolumeDialog extends Dialog { } private SelectionListener onHostDirectoryPath() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final DirectoryDialog directoryDialog = new DirectoryDialog( - getShell()); - final String selectedPath = directoryDialog.open(); - if (selectedPath != null) { - model.setHostPathMount(selectedPath); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final DirectoryDialog directoryDialog = new DirectoryDialog( + getShell()); + final String selectedPath = directoryDialog.open(); + if (selectedPath != null) { + model.setHostPathMount(selectedPath); } - }; + }); } private SelectionListener onHostFilePath() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final FileDialog fileDialog = new FileDialog(getShell()); - final String selectedPath = fileDialog.open(); - if (selectedPath != null) { - model.setHostPathMount(selectedPath); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final FileDialog fileDialog = new FileDialog(getShell()); + final String selectedPath = fileDialog.open(); + if (selectedPath != null) { + model.setHostPathMount(selectedPath); } - }; + }); } /** diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/EditDockerConnectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/EditDockerConnectionPage.java index e52f770072..65ca079ef7 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/EditDockerConnectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/EditDockerConnectionPage.java @@ -317,31 +317,25 @@ public class EditDockerConnectionPage extends WizardPage { } private SelectionListener onBrowseUnixSocketPath() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - final FileDialog fileDialog = new FileDialog(getShell()); - final String selectedPath = fileDialog.open(); - if (selectedPath != null) { - model.setUnixSocketPath("unix://" + selectedPath); //$NON-NLS-1$ - } + return SelectionListener.widgetSelectedAdapter(e -> { + final FileDialog fileDialog = new FileDialog(getShell()); + final String selectedPath = fileDialog.open(); + if (selectedPath != null) { + model.setUnixSocketPath("unix://" + selectedPath); //$NON-NLS-1$ } - }; + }); } private SelectionListener onBrowseTcpCertPath() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - final DirectoryDialog directoryDialog = new DirectoryDialog( - getShell()); - directoryDialog.setFilterPath(model.getTcpCertPath()); - final String selectedPath = directoryDialog.open(); - if (selectedPath != null) { - model.setTcpCertPath(selectedPath); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final DirectoryDialog directoryDialog = new DirectoryDialog( + getShell()); + directoryDialog.setFilterPath(model.getTcpCertPath()); + final String selectedPath = directoryDialog.open(); + if (selectedPath != null) { + model.setTcpCertPath(selectedPath); } - }; + }); } private void updateWidgetsState(final Control[] unixSocketControls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageBuildPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageBuildPage.java index 8069af50f4..a4f23b59db 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageBuildPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageBuildPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Red Hat Inc. and others. + * Copyright (c) 2015, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,7 @@ import org.eclipse.linuxtools.docker.ui.Activator; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.swt.SWT; 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.Point; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -194,49 +193,49 @@ public class ImageBuildPage extends WizardPage { Button browse = new Button(container, SWT.NULL); browse.setText(WizardMessages.getString(BROWSE_LABEL)); - browse.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - DirectoryDialog d = new DirectoryDialog(container.getShell()); - String k = d.open(); - if (k != null) - directoryText.setText(k); - } - }); + browse.addSelectionListener( + SelectionListener.widgetSelectedAdapter(e -> { + DirectoryDialog d = new DirectoryDialog( + container.getShell()); + String k = d.open(); + if (k != null) + directoryText.setText(k); + })); editButton = new Button(container, SWT.NULL); editButton.setText(WizardMessages.getString(EDIT_LABEL)); editButton.setEnabled(false); - editButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - String dir = directoryText.getText(); - IFileStore fileStore = EFS.getLocalFileSystem().getStore( - new Path(dir).append("Dockerfile")); //$NON-NLS-1$ - java.nio.file.Path filePath = Paths.get(dir, "Dockerfile"); //$NON-NLS-1$ - if (!Files.exists(filePath)) { - try { - Files.createFile(filePath); - } catch (IOException e1) { - // File won't exist, and directory should be writable - } - } - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + editButton.addSelectionListener( + SelectionListener.widgetSelectedAdapter(e -> { + String dir = directoryText.getText(); + IFileStore fileStore = EFS.getLocalFileSystem() + .getStore(new Path(dir).append("Dockerfile")); //$NON-NLS-1$ + java.nio.file.Path filePath = Paths.get(dir, "Dockerfile"); //$NON-NLS-1$ + if (!Files.exists(filePath)) { try { - IEditorPart dockerFileEditor = IDE.openEditorOnFileStore(page, fileStore); - IWorkbenchPartSite site = page.getActivePart().getSite(); - EModelService s = site.getService(EModelService.class); - MPartSashContainerElement p = site.getService(MPart.class); - s.detach(p, 100, 100, 500, 375); - editors.add(dockerFileEditor); - } catch (PartInitException e1) { - Activator.log(e1); + Files.createFile(filePath); + } catch (IOException e1) { + // File won't exist, and directory should be + // writable } - validate(); - } - }); + } + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + try { + IEditorPart dockerFileEditor = IDE + .openEditorOnFileStore(page, fileStore); + IWorkbenchPartSite site = page.getActivePart() + .getSite(); + EModelService s = site.getService(EModelService.class); + MPartSashContainerElement p = site + .getService(MPart.class); + s.detach(p, 100, 100, 500, 375); + editors.add(dockerFileEditor); + } catch (PartInitException e1) { + Activator.log(e1); + } + validate(); + })); Point p1 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point p2 = directoryText.computeSize(SWT.DEFAULT, SWT.DEFAULT); diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java index ac3b1ff250..b8e0362b9a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,8 +23,6 @@ import org.eclipse.linuxtools.docker.core.IRegistry; import org.eclipse.linuxtools.docker.ui.wizards.ImageSearch; import org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -32,9 +30,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -/** - * - */ public class ImagePullPage extends ImagePullPushPage<ImagePullPageModel> { private final IDockerConnection connection; @@ -133,23 +128,18 @@ public class ImagePullPage extends ImagePullPushPage<ImagePullPageModel> { * @return */ private SelectionListener onSearchImage() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final ImageSearch imageSearchWizard = new ImageSearch( - ImagePullPage.this.connection, - ImagePullPage.this.getModel().getSelectedImageName(), - ImagePullPage.this.getModel() - .getSelectedRegistry()); - final boolean completed = CommandUtils - .openWizard(imageSearchWizard, getShell()); - if (completed) { - ImagePullPage.this.getModel().setSelectedImageName( - imageSearchWizard.getSelectedImage()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ImageSearch imageSearchWizard = new ImageSearch( + ImagePullPage.this.connection, + ImagePullPage.this.getModel().getSelectedImageName(), + ImagePullPage.this.getModel().getSelectedRegistry()); + final boolean completed = CommandUtils.openWizard(imageSearchWizard, + getShell()); + if (completed) { + ImagePullPage.this.getModel().setSelectedImageName( + imageSearchWizard.getSelectedImage()); } - }; + }); } } diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPushPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPushPage.java index db3072ab0b..017e9fd4a0 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPushPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPushPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 Red Hat. + * Copyright (c) 2016, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,8 +34,6 @@ import org.eclipse.linuxtools.internal.docker.core.RegistryInfo; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceConstants; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; @@ -139,28 +137,23 @@ public abstract class ImagePullPushPage<M extends ImagePullPushPageModel> private SelectionListener onAddRegistry( final ComboViewer registryAccountComboViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final RegistryAccountDialog dialog = new RegistryAccountDialog( - getShell(), - WizardMessages - .getString( - "ImagePullPushPage.addregistry.title"), //$NON-NLS-1$ - AbstractRegistry.DOCKERHUB_REGISTRY, - WizardMessages.getString( - "RegistryAccountDialog.add.explanation")); ///$NON-NLS-1$ - if (dialog.open() == Window.OK) { - RegistryAccountManager.getInstance() - .add(dialog.getSignonInformation()); - final List<IRegistry> updatedRegistryAccounts = getRegistryAccounts(); - registryAccountComboViewer - .setInput(updatedRegistryAccounts); - // set selection on the newly created registry - model.setSelectedRegistry(dialog.getSignonInformation()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final RegistryAccountDialog dialog = new RegistryAccountDialog( + getShell(), + WizardMessages + .getString("ImagePullPushPage.addregistry.title"), //$NON-NLS-1$ + AbstractRegistry.DOCKERHUB_REGISTRY, + WizardMessages.getString( + "RegistryAccountDialog.add.explanation")); ///$NON-NLS-1$ + if (dialog.open() == Window.OK) { + RegistryAccountManager.getInstance() + .add(dialog.getSignonInformation()); + final List<IRegistry> updatedRegistryAccounts = getRegistryAccounts(); + registryAccountComboViewer.setInput(updatedRegistryAccounts); + // set selection on the newly created registry + model.setSelectedRegistry(dialog.getSignonInformation()); } - }; + }); } /** diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRemoveTagPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRemoveTagPage.java index df131eae88..5a599edba0 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRemoveTagPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRemoveTagPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,8 +18,7 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.docker.core.IDockerImage; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; @@ -63,12 +62,8 @@ public class ImageRemoveTagPage extends WizardPage { .grab(false, false).applyTo(repoLabel); final Combo tagCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY); tagCombo.setToolTipText(WizardMessages.getString(REMOVE_TAG_TOOLTIP)); - tagCombo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectedTag = tagCombo.getText(); - } - }); + tagCombo.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> selectedTag = tagCombo.getText())); // Set up combo with repoTags that can be removed final List<String> repoTags = image.repoTags(); tagCombo.setItems(repoTags.toArray(new String[0])); diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunNetworkPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunNetworkPage.java index 9bb03abf6d..a6873d9fb1 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunNetworkPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunNetworkPage.java @@ -28,8 +28,6 @@ import org.eclipse.linuxtools.docker.ui.Activator; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridLayout; @@ -315,26 +313,18 @@ public class ImageRunNetworkPage extends WizardPage { private SelectionListener onContainerSelection(final Button containerButton, final Combo containerList) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final boolean selection = containerButton.getSelection(); - containerList.setEnabled(selection); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final boolean selection = containerButton.getSelection(); + containerList.setEnabled(selection); + }); } private SelectionListener onOtherSelection(final Button otherButton, final Text otherText) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final boolean selection = otherButton.getSelection(); - otherText.setEnabled(selection); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final boolean selection = otherButton.getSelection(); + otherText.setEnabled(selection); + }); } private void setDefaultValues() { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java index 58092c4030..73fdd044f9 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java @@ -64,8 +64,6 @@ import org.eclipse.linuxtools.internal.docker.ui.jobs.FindImageInfoRunnable; import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -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.graphics.Point; @@ -506,79 +504,64 @@ image); private SelectionListener onAddDataVolume( final CheckboxTableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( - getShell(), model.getConnection()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final DataVolumeModel dataVolume = dialog.getDataVolume(); - dataVolume.setSelected(true); - model.getDataVolumes().add(dataVolume); - model.getSelectedDataVolumes().add(dataVolume); - dataVolumesTableViewer.setChecked(dataVolume, - true); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( + getShell(), model.getConnection()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final DataVolumeModel dataVolume = dialog.getDataVolume(); + dataVolume.setSelected(true); + model.getDataVolumes().add(dataVolume); + model.getSelectedDataVolumes().add(dataVolume); + dataVolumesTableViewer.setChecked(dataVolume, true); } - }; + }); } private SelectionListener onEditDataVolume( final CheckboxTableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = (IStructuredSelection) dataVolumesTableViewer - .getSelection(); - if (selection.isEmpty()) { - return; - } - final DataVolumeModel selectedDataVolume = (DataVolumeModel) selection - .getFirstElement(); - final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( - getShell(), model.getConnection(), selectedDataVolume); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final DataVolumeModel dialogDataVolume = dialog - .getDataVolume(); - selectedDataVolume.setContainerMount( - dialogDataVolume.getContainerMount()); - selectedDataVolume - .setMountType(dialogDataVolume.getMountType()); - selectedDataVolume.setHostPathMount( - dialogDataVolume.getHostPathMount()); - selectedDataVolume.setContainerMount( - dialogDataVolume.getContainerMount()); - selectedDataVolume - .setReadOnly(dialogDataVolume.isReadOnly()); - model.getSelectedDataVolumes().add(selectedDataVolume); - dataVolumesTableViewer.setChecked(selectedDataVolume, true); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = (IStructuredSelection) dataVolumesTableViewer + .getSelection(); + if (selection.isEmpty()) { + return; } - }; + final DataVolumeModel selectedDataVolume = (DataVolumeModel) selection + .getFirstElement(); + final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog( + getShell(), model.getConnection(), selectedDataVolume); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final DataVolumeModel dialogDataVolume = dialog.getDataVolume(); + selectedDataVolume.setContainerMount( + dialogDataVolume.getContainerMount()); + selectedDataVolume + .setMountType(dialogDataVolume.getMountType()); + selectedDataVolume + .setHostPathMount(dialogDataVolume.getHostPathMount()); + selectedDataVolume.setContainerMount( + dialogDataVolume.getContainerMount()); + selectedDataVolume.setReadOnly(dialogDataVolume.isReadOnly()); + model.getSelectedDataVolumes().add(selectedDataVolume); + dataVolumesTableViewer.setChecked(selectedDataVolume, true); + } + }); } private SelectionListener onRemoveDataVolumes( final TableViewer dataVolumesTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = dataVolumesTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<DataVolumeModel> iterator = selection - .iterator(); iterator.hasNext();) { - final DataVolumeModel volume = iterator.next(); - model.removeDataVolume(volume); - model.getSelectedDataVolumes().remove(volume); - } - + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = dataVolumesTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<DataVolumeModel> iterator = selection.iterator(); iterator + .hasNext();) { + final DataVolumeModel volume = iterator.next(); + model.removeDataVolume(volume); + model.getSelectedDataVolumes().remove(volume); } - }; + + }); } private CheckboxTableViewer createVolumesTable(final Composite container) { @@ -689,55 +672,43 @@ image); } private SelectionListener onAddLabelVariable() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getLabelVariables().add(dialog.getLabelVariable()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getLabelVariables().add(dialog.getLabelVariable()); } - }; + }); } private SelectionListener onEditLabelVariable( final TableViewer LabelVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final LabelVariableModel selectedVariable = (LabelVariableModel) LabelVariablesTableViewer - .getStructuredSelection().getFirstElement(); - final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( - getShell(), selectedVariable); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedVariable - .setName(dialog.getLabelVariable().getName()); - selectedVariable - .setValue(dialog.getLabelVariable().getValue()); - LabelVariablesTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final LabelVariableModel selectedVariable = (LabelVariableModel) LabelVariablesTableViewer + .getStructuredSelection().getFirstElement(); + final ContainerLabelVariableDialog dialog = new ContainerLabelVariableDialog( + getShell(), selectedVariable); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedVariable.setName(dialog.getLabelVariable().getName()); + selectedVariable.setValue(dialog.getLabelVariable().getValue()); + LabelVariablesTableViewer.refresh(); } - }; + }); } private SelectionListener onRemoveLabelVariables( final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<LabelVariableModel> iterator = selection - .iterator(); iterator.hasNext();) { - model.removeLabelVariable(iterator.next()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<LabelVariableModel> iterator = selection + .iterator(); iterator.hasNext();) { + model.removeLabelVariable(iterator.next()); } - }; + }); } private void createEnvironmentVariablesContainer( @@ -812,56 +783,46 @@ image); } private SelectionListener onAddEnvironmentVariable() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.getEnvironmentVariables() - .add(dialog.getEnvironmentVariable()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.getEnvironmentVariables() + .add(dialog.getEnvironmentVariable()); } - }; + }); } private SelectionListener onEditEnvironmentVariable( final TableViewer environmentVariablesTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final EnvironmentVariableModel selectedVariable = (EnvironmentVariableModel) environmentVariablesTableViewer - .getStructuredSelection().getFirstElement(); - final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( - getShell(), selectedVariable); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedVariable.setName( - dialog.getEnvironmentVariable().getName()); - selectedVariable.setValue( - dialog.getEnvironmentVariable().getValue()); - environmentVariablesTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final EnvironmentVariableModel selectedVariable = (EnvironmentVariableModel) environmentVariablesTableViewer + .getStructuredSelection().getFirstElement(); + final ContainerEnvironmentVariableDialog dialog = new ContainerEnvironmentVariableDialog( + getShell(), selectedVariable); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedVariable + .setName(dialog.getEnvironmentVariable().getName()); + selectedVariable + .setValue(dialog.getEnvironmentVariable().getValue()); + environmentVariablesTableViewer.refresh(); } - }; + }); } private SelectionListener onRemoveEnvironmentVariables( final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<EnvironmentVariableModel> iterator = selection - .iterator(); iterator.hasNext();) { - model.removeEnvironmentVariable(iterator.next()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<EnvironmentVariableModel> iterator = selection + .iterator(); iterator.hasNext();) { + model.removeEnvironmentVariable(iterator.next()); } - }; + }); } private static void setControlsEnabled(final Control[] controls, diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java index 3eedb9c8f3..755606a341 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java @@ -595,61 +595,49 @@ public class ImageRunSelectionPage extends WizardPage { } private SelectionListener onAddLink() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final ContainerLinkDialog dialog = new ContainerLinkDialog( - getShell(), model.getSelectedConnection()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - model.addLink(dialog.getContainerName(), - dialog.getContainerAlias()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerLinkDialog dialog = new ContainerLinkDialog( + getShell(), model.getSelectedConnection()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + model.addLink(dialog.getContainerName(), + dialog.getContainerAlias()); } - }; + }); } private SelectionListener onEditLink(final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); - - final ContainerLinkModel selectedContainerLink = (ContainerLinkModel) selection - .getFirstElement(); - final ContainerLinkDialog dialog = new ContainerLinkDialog( - getShell(), model.getSelectedConnection(), - selectedContainerLink); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - selectedContainerLink - .setContainerName(dialog.getContainerName()); - selectedContainerLink - .setContainerAlias(dialog.getContainerAlias()); - linksTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); + + final ContainerLinkModel selectedContainerLink = (ContainerLinkModel) selection + .getFirstElement(); + final ContainerLinkDialog dialog = new ContainerLinkDialog( + getShell(), model.getSelectedConnection(), + selectedContainerLink); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + selectedContainerLink + .setContainerName(dialog.getContainerName()); + selectedContainerLink + .setContainerAlias(dialog.getContainerAlias()); + linksTableViewer.refresh(); } - }; + }); } private SelectionListener onRemoveLinks( final TableViewer linksTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = linksTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<ContainerLinkModel> iterator = selection - .iterator(); iterator.hasNext();) { - model.removeLink(iterator.next()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = linksTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<ContainerLinkModel> iterator = selection + .iterator(); iterator.hasNext();) { + model.removeLink(iterator.next()); } - }; + }); } private void createRunOptionsSection(final Composite container) { @@ -756,89 +744,72 @@ public class ImageRunSelectionPage extends WizardPage { } private SelectionListener onSearchImage() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - final ImageSearch imageSearchWizard = new ImageSearch( - ImageRunSelectionPage.this.model - .getSelectedConnection(), - ImageRunSelectionPage.this.model - .getSelectedImageName(), - new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, - true)); - final boolean completed = CommandUtils - .openWizard(imageSearchWizard, getShell()); - if (completed) { - model.setSelectedImageName( - imageSearchWizard.getSelectedImage()); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ImageSearch imageSearchWizard = new ImageSearch( + ImageRunSelectionPage.this.model.getSelectedConnection(), + ImageRunSelectionPage.this.model.getSelectedImageName(), + new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, + true)); + final boolean completed = CommandUtils.openWizard(imageSearchWizard, + getShell()); + if (completed) { + model.setSelectedImageName( + imageSearchWizard.getSelectedImage()); } - }; + }); } private SelectionListener onAddPort( final CheckboxTableViewer exposedPortsTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final ContainerPortDialog dialog = new ContainerPortDialog( - getShell()); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final ExposedPortModel port = dialog.getPort(); - port.setSelected(true); - model.addAvailablePort(port); - model.getSelectedPorts().add(port); - exposedPortsTableViewer.setChecked(port, true); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final ContainerPortDialog dialog = new ContainerPortDialog( + getShell()); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final ExposedPortModel port = dialog.getPort(); + port.setSelected(true); + model.addAvailablePort(port); + model.getSelectedPorts().add(port); + exposedPortsTableViewer.setChecked(port, true); } - }; + }); } private SelectionListener onEditPort( final CheckboxTableViewer exposedPortsTableViewer) { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = exposedPortsTableViewer - .getStructuredSelection(); - final ExposedPortModel selectedContainerPort = (ExposedPortModel) selection - .getFirstElement(); - final ContainerPortDialog dialog = new ContainerPortDialog( - getShell(), selectedContainerPort); - dialog.create(); - if (dialog.open() == IDialogConstants.OK_ID) { - final ExposedPortModel configuredPort = dialog.getPort(); - selectedContainerPort.setContainerPort( - configuredPort.getContainerPort()); - selectedContainerPort - .setHostAddress(configuredPort.getHostAddress()); - selectedContainerPort - .setHostPort(configuredPort.getHostPort()); - exposedPortsTableViewer.refresh(); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = exposedPortsTableViewer + .getStructuredSelection(); + final ExposedPortModel selectedContainerPort = (ExposedPortModel) selection + .getFirstElement(); + final ContainerPortDialog dialog = new ContainerPortDialog( + getShell(), selectedContainerPort); + dialog.create(); + if (dialog.open() == IDialogConstants.OK_ID) { + final ExposedPortModel configuredPort = dialog.getPort(); + selectedContainerPort + .setContainerPort(configuredPort.getContainerPort()); + selectedContainerPort + .setHostAddress(configuredPort.getHostAddress()); + selectedContainerPort.setHostPort(configuredPort.getHostPort()); + exposedPortsTableViewer.refresh(); } - }; + }); } private SelectionListener onRemovePorts( final TableViewer portsTableViewer) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - final IStructuredSelection selection = portsTableViewer - .getStructuredSelection(); - for (@SuppressWarnings("unchecked") - Iterator<ExposedPortModel> iterator = selection - .iterator(); iterator.hasNext();) { - final ExposedPortModel port = iterator.next(); - model.removeAvailablePort(port); - model.getSelectedPorts().remove(port); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final IStructuredSelection selection = portsTableViewer + .getStructuredSelection(); + for (@SuppressWarnings("unchecked") + Iterator<ExposedPortModel> iterator = selection.iterator(); iterator + .hasNext();) { + final ExposedPortModel port = iterator.next(); + model.removeAvailablePort(port); + model.getSelectedPorts().remove(port); } - }; + }); } /** diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchPage.java index be3299706a..a4083d4d5d 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2016 Red Hat Inc. and others. + * Copyright (c) 2014, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,11 +50,7 @@ import org.eclipse.linuxtools.docker.core.IRegistry; import org.eclipse.linuxtools.docker.ui.Activator; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.graphics.Image; @@ -69,10 +65,6 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Text; -/** - * @author xcoulon - * - */ public class ImageSearchPage extends WizardPage { private final ImageSearchModel model; @@ -246,31 +238,19 @@ public class ImageSearchPage extends WizardPage { } private KeyListener onKeyPressed() { - return new KeyAdapter() { - - @Override - public void keyReleased(final KeyEvent event) { - final IStatus status = AggregateValidationStatus - .getStatusMaxSeverity( - ctx.getValidationStatusProviders()); - final String searchTerm = ImageSearchPage.this.model.getTerm(); - if (event.character == SWT.CR && searchTerm != null - && !searchTerm.isEmpty() - && status.isOK()) { - searchImages(); - } + return KeyListener.keyReleasedAdapter(event -> { + final IStatus status = AggregateValidationStatus + .getStatusMaxSeverity(ctx.getValidationStatusProviders()); + final String searchTerm = ImageSearchPage.this.model.getTerm(); + if (event.character == SWT.CR && searchTerm != null + && !searchTerm.isEmpty() && status.isOK()) { + searchImages(); } - }; + }); } private SelectionListener onSearchImageButtonSelected() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent event) { - searchImages(); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> searchImages()); } private void searchImages() { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java index f561126dee..9a75ca4c67 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java @@ -401,31 +401,25 @@ public class NewDockerConnectionPage extends WizardPage { } private SelectionListener onBrowseUnixSocketPath() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - final FileDialog fileDialog = new FileDialog(getShell()); - final String selectedPath = fileDialog.open(); - if (selectedPath != null) { - model.setUnixSocketPath("unix://" + selectedPath); //$NON-NLS-1$ - } + return SelectionListener.widgetSelectedAdapter(e -> { + final FileDialog fileDialog = new FileDialog(getShell()); + final String selectedPath = fileDialog.open(); + if (selectedPath != null) { + model.setUnixSocketPath("unix://" + selectedPath); //$NON-NLS-1$ } - }; + }); } private SelectionListener onBrowseTcpCertPath() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - final DirectoryDialog directoryDialog = new DirectoryDialog( - getShell()); - directoryDialog.setFilterPath(model.getTcpCertPath()); - final String selectedPath = directoryDialog.open(); - if (selectedPath != null) { - model.setTcpCertPath(selectedPath); - } + return SelectionListener.widgetSelectedAdapter(e -> { + final DirectoryDialog directoryDialog = new DirectoryDialog( + getShell()); + directoryDialog.setFilterPath(model.getTcpCertPath()); + final String selectedPath = directoryDialog.open(); + if (selectedPath != null) { + model.setTcpCertPath(selectedPath); } - }; + }); } /** diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java index d22ad13cc1..70652b0453 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java +++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/dialog/OpenGCDialog.java @@ -34,8 +34,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; 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.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -142,20 +141,12 @@ public class OpenGCDialog extends Dialog { cbBin.setLayout(new GridLayout(2, true)); Button binBrowseWorkspaceButton = new Button(cbBin, SWT.PUSH); binBrowseWorkspaceButton.setText(Messages.OpenGCDialog_bin_browser_button_text); - binBrowseWorkspaceButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - handleBrowseWorkspace(Messages.OpenGCDialog_bin_browser_handler_text, binText); - } - }); + binBrowseWorkspaceButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> + handleBrowseWorkspace(Messages.OpenGCDialog_bin_browser_handler_text, binText))); Button binBrowseFileSystemButton = new Button(cbBin, SWT.PUSH); binBrowseFileSystemButton.setText(Messages.OpenGCDialog_bin_browser_fs_button_text); - binBrowseFileSystemButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - handleBrowse(Messages.OpenGCDialog_bin_browser_handler_text, binText); - } - }); + binBrowseFileSystemButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> + handleBrowse(Messages.OpenGCDialog_bin_browser_handler_text, binText))); Group covMode = new Group(composite, SWT.NONE); covMode.setText(Messages.OpenGCDialog_coverage_mode_header); @@ -174,12 +165,8 @@ public class OpenGCDialog extends Dialog { openCoverageSummaryButton.setSelection(true); - SelectionAdapter sa = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - openCoverageSummary = openCoverageSummaryButton.getSelection(); - } - }; + SelectionListener sa = SelectionListener.widgetSelectedAdapter(e -> + openCoverageSummary = openCoverageSummaryButton.getSelection()); openCoverageSummaryButton.addSelectionListener(sa); openThisFileOnlyButton.addSelectionListener(sa); diff --git a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/dialog/OpenGmonDialog.java b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/dialog/OpenGmonDialog.java index 578fe1940d..2990cb23f5 100644 --- a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/dialog/OpenGmonDialog.java +++ b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/dialog/OpenGmonDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 STMicroelectronics. + * Copyright (c) 2009, 2017 STMicroelectronics and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,7 @@ import org.eclipse.linuxtools.internal.gprof.Messages; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; 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.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -131,20 +130,12 @@ public class OpenGmonDialog extends Dialog { cbBin.setLayout(new GridLayout(2, true)); Button binBrowseWorkspaceButton = new Button(cbBin, SWT.PUSH); binBrowseWorkspaceButton.setText(Messages.OpenGmonDialog_WORKSPACE); - binBrowseWorkspaceButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - handleBrowseWorkspace(Messages.OpenGmonDialog_OPEN_BINARY_FILE, binText); - } - }); + binBrowseWorkspaceButton.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> handleBrowseWorkspace(Messages.OpenGmonDialog_OPEN_BINARY_FILE, binText))); Button binBrowseFileSystemButton = new Button(cbBin, SWT.PUSH); binBrowseFileSystemButton.setText(Messages.OpenGmonDialog_FILE_SYSTEM); - binBrowseFileSystemButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - handleBrowse(Messages.OpenGmonDialog_OPEN_BINARY_FILE, binText); - } - }); + binBrowseFileSystemButton.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> handleBrowse(Messages.OpenGmonDialog_OPEN_BINARY_FILE, binText))); /* 2sd line */ errorLabel = new Label(composite, SWT.NONE); diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/preferences/LibHoverPreferencePage.java b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/preferences/LibHoverPreferencePage.java index cd401c6763..3aa43c1307 100644 --- a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/preferences/LibHoverPreferencePage.java +++ b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/preferences/LibHoverPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. + * Copyright (c) 2011, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,8 +34,7 @@ import org.eclipse.linuxtools.internal.cdt.libhover.LibHoverLibrary; import org.eclipse.linuxtools.internal.cdt.libhover.devhelp.DevHelpPlugin; import org.eclipse.linuxtools.internal.cdt.libhover.devhelp.ParseDevHelp; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -141,12 +140,7 @@ public class LibHoverPreferencePage extends FieldEditorPreferencePage implements generateButton = new Button(parent, SWT.NONE); generateButton.setFont(parent.getFont()); generateButton.setText(LibHoverMessages.getString(GENERATE)); - generateButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - regenerate(); - } - }); + generateButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> regenerate())); generateButton.addDisposeListener(event -> generateButton = null); GridData gd = new GridData(); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java index 6ed0b8f723..6d2b62839c 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java @@ -42,8 +42,7 @@ import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchMessages; import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -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; import org.eclipse.swt.layout.GridLayout; @@ -175,12 +174,8 @@ public abstract class AbstractEventConfigTab extends AbstractLaunchConfiguration defaultEventCheck = new Button(top, SWT.CHECK); defaultEventCheck.setText(OprofileLaunchMessages.getString("tab.event.defaultevent.button.text")); //$NON-NLS-1$ defaultEventCheck.setLayoutData(new GridData()); - defaultEventCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleEnabledToggle(); - } - }); + defaultEventCheck + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleEnabledToggle())); createVerticalSpacer(top, 1); createCounterTabs(top); } @@ -551,14 +546,11 @@ public abstract class AbstractEventConfigTab extends AbstractLaunchConfiguration enabledCheck = new Button(parent, SWT.CHECK); enabledCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.enabled.button.text")); //$NON-NLS-1$ enabledCheck.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); - enabledCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - counter.setEnabled(enabledCheck.getSelection()); - internalSetEnabledState(counter.getEnabled()); - updateLaunchConfigurationDialog(); - } - }); + enabledCheck.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + counter.setEnabled(enabledCheck.getSelection()); + internalSetEnabledState(counter.getEnabled()); + updateLaunchConfigurationDialog(); + })); enabledCheck.setEnabled(false); //label for textbox @@ -732,22 +724,14 @@ public abstract class AbstractEventConfigTab extends AbstractLaunchConfiguration //profile kernel checkbox profileKernelCheck = new Button(parent, SWT.CHECK); profileKernelCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.profileKernel.check.text")); //$NON-NLS-1$ - profileKernelCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleProfileKernelToggle(); - } - }); + profileKernelCheck + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleProfileKernelToggle())); //profile user checkbox -- should this ever be disabled? profileUserCheck = new Button(parent, SWT.CHECK); profileUserCheck.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.profileUser.check.text")); //$NON-NLS-1$ - profileUserCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleProfileUserToggle(); - } - }); + profileUserCheck + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleProfileUserToggle())); } @@ -1118,12 +1102,8 @@ public abstract class AbstractEventConfigTab extends AbstractLaunchConfiguration maskButton.setEnabled(true); maskButton.setText(mask.getText(i)); maskButton.setSelection(selected); - maskButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleToggle((Button)se.getSource(), maskButtonIndex); - } - }); + maskButton.addSelectionListener(SelectionListener + .widgetSelectedAdapter(se -> handleToggle((Button) se.getSource(), maskButtonIndex))); maskButtons.add(maskButton); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java index f39a7b5f38..69364af894 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java @@ -34,8 +34,7 @@ import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager; import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; -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; import org.eclipse.swt.layout.GridLayout; @@ -204,12 +203,7 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { Button button = createPushButton(p, OprofileLaunchMessages.getString("tab.global.kernelImage.browse.button.text"), null); //$NON-NLS-1$ final Shell shell = top.getShell(); - button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - showFileDialog(shell); - } - }); + button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> showFileDialog(shell))); createVerticalSpacer(top, 1); @@ -248,12 +242,7 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { private Button myCreateCheckButton(Composite parent, String label) { final Button b = new Button(parent, SWT.CHECK); b.setText(label); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleCheckSelected(b); - } - }); + b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleCheckSelected(b))); return b; } diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfEventsTab.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfEventsTab.java index bb7df6b001..0323dd1b22 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfEventsTab.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfEventsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 Red Hat, Inc. and others. + * Copyright (c) 2004, 2017 Red Hat, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,8 +26,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.linuxtools.internal.perf.PerfCore; import org.eclipse.linuxtools.internal.perf.PerfPlugin; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; @@ -113,12 +112,9 @@ public class PerfEventsTab extends AbstractLaunchConfigurationTab { Table table = new Table(c, SWT.CHECK | SWT.MULTI); eventTable[i] = table; table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - table.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - updateLaunchConfigurationDialog(); - } - }); + table.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + updateLaunchConfigurationDialog(); + })); // Right side to enter new events and delete old ones Composite right = new Composite(c, SWT.NONE); @@ -144,18 +140,15 @@ public class PerfEventsTab extends AbstractLaunchConfigurationTab { Button b = new Button(right, SWT.PUSH); b.setText(Messages.PerfEventsTab_Add); b.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - int i = tabFolder.getSelectionIndex(); - if (rawTabIndex == i) { - new TableItem(eventTable[i], SWT.NONE).setText(rawText.getText()); - } else if(bpTabIndex == i) { - new TableItem(eventTable[i], SWT.NONE).setText(bpText.getText()); - } - updateLaunchConfigurationDialog(); - } - }); + b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + int index = tabFolder.getSelectionIndex(); + if (rawTabIndex == index) { + new TableItem(eventTable[index], SWT.NONE).setText(rawText.getText()); + } else if (bpTabIndex == index) { + new TableItem(eventTable[index], SWT.NONE).setText(bpText.getText()); + } + updateLaunchConfigurationDialog(); + })); l = new Label(right, SWT.NONE); l.setForeground(new Color(right.getDisplay(), 100,100,100)); if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) { @@ -174,13 +167,11 @@ public class PerfEventsTab extends AbstractLaunchConfigurationTab { b = new Button(right, SWT.PUSH); b.setText(Messages.PerfEventsTab_RemoveSelectedEvents); b.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false,2,1)); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - eventTable[tabFolder.getSelectionIndex()].remove(eventTable[tabFolder.getSelectionIndex()].getSelectionIndices()); - updateLaunchConfigurationDialog(); - } - }); + b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + eventTable[tabFolder.getSelectionIndex()] + .remove(eventTable[tabFolder.getSelectionIndex()].getSelectionIndices()); + updateLaunchConfigurationDialog(); + })); l = new Label(right, SWT.NONE); l.setForeground(new Color(right.getDisplay(), 100,100,100)); l.setText(Messages.PerfEventsTab_Note); @@ -199,12 +190,8 @@ public class PerfEventsTab extends AbstractLaunchConfigurationTab { item.setText(event); } - table.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - updateLaunchConfigurationDialog(); - } - }); + table.addSelectionListener( + SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); eventTabItems[i].setControl(table); } @@ -241,13 +228,10 @@ public class PerfEventsTab extends AbstractLaunchConfigurationTab { chkDefaultEvent = new Button(top, SWT.CHECK); chkDefaultEvent.setText("Default Event"); //$NON-NLS-1$ chkDefaultEvent.setLayoutData(new GridData()); - chkDefaultEvent.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - refreshDefaultEnabled(); - updateLaunchConfigurationDialog(); - } - }); + chkDefaultEvent.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + refreshDefaultEnabled(); + updateLaunchConfigurationDialog(); + })); createEventTabs(top, config); } diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java index a3968f614f..f55386f7ad 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java @@ -25,8 +25,7 @@ import org.eclipse.linuxtools.internal.perf.PerfPlugin; import org.eclipse.linuxtools.internal.perf.PerfVersion; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -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.graphics.Point; import org.eclipse.swt.layout.GridData; @@ -117,12 +116,7 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab { Button button = createPushButton(kernelComp, Messages.PerfOptionsTab_Browse, null); final Shell shell = top.getShell(); - button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent sev) { - showFileDialog(shell); - } - }); + button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> showFileDialog(shell))); createVerticalSpacer(top, 1); @@ -143,39 +137,28 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab { showStatComp.setLayout(parallelLayout); chkShowStat = createCheckButtonHelper(showStatComp, PerfPlugin.STRINGS_ShowStat); - chkShowStat.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - handleShowStatSelection(); - } - }); + chkShowStat.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleShowStatSelection())); statRunCount = new Spinner(showStatComp, SWT.BORDER); statRunCount.setEnabled(false); statRunCount.setMinimum(1); statRunCount.addModifyListener(e -> updateLaunchConfigurationDialog()); - chkSourceLineNumbers.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - if ((chkKernelSourceLineNumbers != null) && (!chkSourceLineNumbers.getSelection())) { - chkKernelSourceLineNumbers.setEnabled(false); - } else { - chkKernelSourceLineNumbers.setEnabled(true); - } - } - }); + chkSourceLineNumbers.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + if ((chkKernelSourceLineNumbers != null) && (!chkSourceLineNumbers.getSelection())) { + chkKernelSourceLineNumbers.setEnabled(false); + } else { + chkKernelSourceLineNumbers.setEnabled(true); + } + })); chkKernelSourceLineNumbers = createCheckButtonHelper(chkBoxComp, PerfPlugin.STRINGS_Kernel_SourceLineNumbers); Composite realtimeComp = new Composite(top, SWT.NONE); realtimeComp.setLayout(parallelLayout); chkRecordRealtime = createCheckButtonHelper(realtimeComp, PerfPlugin.STRINGS_Record_Realtime); - chkRecordRealtime.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - rtPriority.setEnabled(chkRecordRealtime.getSelection()); - } - }); + chkRecordRealtime.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + rtPriority.setEnabled(chkRecordRealtime.getSelection()); + })); rtPriority = new Spinner(realtimeComp, SWT.BORDER); rtPriority.setEnabled(chkRecordRealtime.getSelection()); rtPriority.setMinimum(1); @@ -202,13 +185,10 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab { private Button createCheckButtonHelper(Composite parent, String label) { final Button b = new Button(parent, SWT.CHECK); b.setText(label); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent se) { - setDirty(true); - updateLaunchConfigurationDialog(); - } - }); + b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + setDirty(true); + updateLaunchConfigurationDialog(); + })); return b; } diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/ReportComparisonView.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/ReportComparisonView.java index 229d94cc10..910eacea09 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/ReportComparisonView.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/ReportComparisonView.java @@ -36,7 +36,6 @@ import org.eclipse.linuxtools.internal.perf.handlers.Messages; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; @@ -85,18 +84,10 @@ public class ReportComparisonView extends Viewer { reverse.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED)); reverse.setToolTipText(Messages.StatComparisonView_reverseToolTip); reverse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - reverse.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - toggleReverse(); - setInput(fInput); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); + reverse.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + toggleReverse(); + setInput(fInput); + })); result = new StyledText(fComposite, SWT.V_SCROLL | SWT.H_SCROLL); result.setAlwaysShowScrollBars(false); diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/StatComparisonView.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/StatComparisonView.java index 38fb1317d7..20ca62acaa 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/StatComparisonView.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/StatComparisonView.java @@ -36,7 +36,6 @@ import org.eclipse.linuxtools.internal.perf.model.PMStatEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; @@ -82,18 +81,10 @@ public class StatComparisonView extends Viewer { reverse.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED)); reverse.setToolTipText(Messages.StatComparisonView_reverseToolTip); reverse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - reverse.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - toggleReverse(); - setInput(fInput); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); + reverse.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + toggleReverse(); + setInput(fInput); + })); text = new StyledText(fComposite, SWT.V_SCROLL | SWT.H_SCROLL); text.setAlwaysShowScrollBars(false); diff --git a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java index 900b98026c..7dcefe0bdd 100644 --- a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java +++ b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 STMicroelectronics. + * Copyright (c) 2009, 2017 STMicroelectronics and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,8 +32,7 @@ import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.window.Window; import org.eclipse.linuxtools.internal.Activator; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -120,32 +119,21 @@ public class STCSourceNotFoundEditor extends CommonSourceNotFoundEditor { } @Override - protected void createButtons(Composite parent) { - locateFileButton = new Button(parent, SWT.PUSH); - GridData data = new GridData(); - data.grabExcessHorizontalSpace = false; - data.grabExcessVerticalSpace = false; - locateFileButton.setLayoutData(data); - locateFileButton.setText(Messages.STCSourceNotFoundEditor_locate_file); - locateFileButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - locateFile(); - } - }); - - editLookupButton = new Button(parent, SWT.PUSH); - editLookupButton.setLayoutData(data); - editLookupButton - .setText(Messages.STCSourceNotFoundEditor_edit_source_lookup_path); - editLookupButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - editSourceLookupPath(); - } - }); - syncButtons(); - } + protected void createButtons(Composite parent) { + locateFileButton = new Button(parent, SWT.PUSH); + GridData data = new GridData(); + data.grabExcessHorizontalSpace = false; + data.grabExcessVerticalSpace = false; + locateFileButton.setLayoutData(data); + locateFileButton.setText(Messages.STCSourceNotFoundEditor_locate_file); + locateFileButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> locateFile())); + + editLookupButton = new Button(parent, SWT.PUSH); + editLookupButton.setLayoutData(data); + editLookupButton.setText(Messages.STCSourceNotFoundEditor_edit_source_lookup_path); + editLookupButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> editSourceLookupPath())); + syncButtons(); + } @Override protected void editSourceLookupPath() { diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java index 0ff2002410..23e7e161a2 100755 --- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java +++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 STMicroelectronics. + * Copyright (c) 2009, 2017 STMicroelectronics and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -191,12 +191,8 @@ public class ChartDialog extends Dialog { barGraphButton = new Button(chartTypeGroup, SWT.RADIO); barGraphButton.setText(Messages.ChartConstants_BAR_GRAPH); barGraphButton.addSelectionListener(listener); - barGraphButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - verticalBarsButton.setEnabled(barGraphButton.getSelection()); - } - }); + barGraphButton.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> verticalBarsButton.setEnabled(barGraphButton.getSelection()))); data = new GridData(); barGraphButton.setLayoutData(data); diff --git a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java index 51bdad1f60..08391a1ec9 100644 --- a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java +++ b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 STMicroelectronics. + * Copyright (c) 2009, 2017 STMicroelectronics and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,6 @@ import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExport import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporterConstants; import org.eclipse.swt.SWT; 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.Color; @@ -166,23 +165,14 @@ public class STDataViewersExportToCSVDialog extends Dialog { Button browseOutputButton = new Button(browseComposite, SWT.PUSH); browseOutputButton.setText("File System..."); - browseOutputButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleBrowse(); - } - }); + browseOutputButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleBrowse())); layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1); browseOutputButton.setLayoutData(layoutData); Button browseOutputInWorkspaceButton = new Button(browseComposite, SWT.PUSH); browseOutputInWorkspaceButton.setText("Workspace..."); - browseOutputInWorkspaceButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleBrowseWorkspace(); - } - }); + browseOutputInWorkspaceButton + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleBrowseWorkspace())); layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1); browseOutputInWorkspaceButton.setLayoutData(layoutData); } diff --git a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java index 6e46444ecb..6bc7c35f6f 100644 --- a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java +++ b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 STMicroelectronics. + * Copyright (c) 2009, 2017 STMicroelectronics and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -120,20 +121,10 @@ public class STDataViewersSortDialog extends TrayDialog { ascendingButtons[i] = new Button(directionGroup, SWT.RADIO); ascendingButtons[i].setText(getAscendingText(i)); - ascendingButtons[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); + ascendingButtons[i].addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> markDirty())); descendingButtons[i] = new Button(directionGroup, SWT.RADIO); descendingButtons[i].setText(getDescendingText(i)); - descendingButtons[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); + descendingButtons[i].addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> markDirty())); if (i < priorityCombos.length - 1) { priorityCombos[i].addSelectionListener(new SelectionAdapter() { @@ -171,12 +162,7 @@ public class STDataViewersSortDialog extends TrayDialog { } }); } else { - priorityCombos[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); + priorityCombos[i].addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> markDirty())); } } @@ -234,13 +220,10 @@ public class STDataViewersSortDialog extends TrayDialog { Button defaultsButton = new Button(parent, SWT.PUSH); defaultsButton.setText(STDataViewersMessages.restoreDefaults_text); setButtonSize(defaultsButton, new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL)); - defaultsButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - restoreDefaults(); - markDirty(); - } - }); + defaultsButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + restoreDefaults(); + markDirty(); + })); } private void createSeparatorLine(Composite parent) { diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java index 83a8e21c00..51d47c2848 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Red Hat, Inc. + * Copyright (c) 2013, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; -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; import org.eclipse.swt.layout.GridLayout; @@ -88,19 +87,16 @@ public abstract class AbstractProfilingOptionsTab extends AbstractLaunchConfigur tabgroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); - providerCombo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String curProviderId = comboItems.get(providerCombo.getText()); - loadTabGroupItems(tabgroup, curProviderId); - initializeFrom(initial); - // Since we are calling initializeFrom manually, we have to - // update the launch configuration dialog manually to ensure - // initial validation on the configuration. - updateLaunchConfigurationDialog(); - top.layout(); - } - }); + providerCombo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String curProviderId = comboItems.get(providerCombo.getText()); + loadTabGroupItems(tabgroup, curProviderId); + initializeFrom(initial); + // Since we are calling initializeFrom manually, we have to + // update the launch configuration dialog manually to ensure + // initial validation on the configuration. + updateLaunchConfigurationDialog(); + top.layout(); + })); } /** diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java index 55a78f05df..51d5d349f6 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Red Hat, Inc. + * Copyright (c) 2012, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,8 +24,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.Messages; import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -76,12 +75,7 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab { useProjectSetting.setText(Messages.UseProjectSetting_0); useProjectSetting.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); useProjectSetting.setSelection(getPreferenceStore().getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + getType())); - useProjectSetting.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateOptionsEnable(); - } - }); + useProjectSetting.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateOptionsEnable())); String highestProviderId = ProviderFramework.getHighestProviderId(getType()); if (highestProviderId != null) { @@ -93,12 +87,8 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab { fLink= new Link(usercomp, SWT.NULL); fLink.setText(Messages.PreferenceLink_0); fLink.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false, 1, 1)); - fLink.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - PreferencesUtil.createPreferenceDialogOn(parent.getShell(), getPrefPageId(), null, null).open(); - } - }); + fLink.addSelectionListener(SelectionListener.widgetSelectedAdapter( + e -> PreferencesUtil.createPreferenceDialogOn(parent.getShell(), getPrefPageId(), null, null).open())); HashMap<String, String> map = ProviderFramework @@ -147,12 +137,8 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab { radio.setText(labelAndValue[0]); radio.setData(labelAndValue[1]); radio.setFont(parent.getFont()); - radio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - value = (String) event.widget.getData(); - } - }); + radio.addSelectionListener( + SelectionListener.widgetSelectedAdapter(event -> value = (String) event.widget.getData())); } projectSettingsGroup.addDisposeListener(event -> { projectSettingsGroup = null; diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyCMainTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyCMainTab.java index e049a09d7c..abe97c5d9b 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyCMainTab.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyCMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 QNX Software Systems and others. + * Copyright (c) 2005, 2017 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,8 +49,7 @@ import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin; import org.eclipse.linuxtools.profiling.launch.ui.ResourceSelectorWidget; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -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; import org.eclipse.swt.layout.GridLayout; @@ -174,13 +173,8 @@ public class RemoteProxyCMainTab extends CAbstractMainTab { fTerminalButton = createCheckButton(mainComp, LaunchMessages.CMainTab_UseTerminal); - fTerminalButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - updateLaunchConfigurationDialog(); - } - }); + fTerminalButton + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog())); fTerminalButton.setEnabled(PTY.isSupported()); } @@ -386,14 +380,10 @@ public class RemoteProxyCMainTab extends CAbstractMainTab { fProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null); - fProjButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - handleProjectButtonSelected(); - updateLaunchConfigurationDialog(); - } - }); + fProjButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleProjectButtonSelected(); + updateLaunchConfigurationDialog(); + })); } @Override @@ -463,14 +453,11 @@ public class RemoteProxyCMainTab extends CAbstractMainTab { toLabel.setEnabled(false); - enableCopyFromExeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean copyEnabled = enableCopyFromExeButton.getSelection(); - setEnableCopyFromSection(copyEnabled); - updateLaunchConfigurationDialog(); - } - }); + enableCopyFromExeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + boolean copyEnabled = enableCopyFromExeButton.getSelection(); + setEnableCopyFromSection(copyEnabled); + updateLaunchConfigurationDialog(); + })); copyFromExeText = copyFromExeSelector.getURIText(); copyFromExeText.addModifyListener(evt -> updateLaunchConfigurationDialog()); diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java index 73cf5cbe44..4193826004 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 IBM Corporation and others. + * Copyright (c) 2012, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,8 +19,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin; import org.eclipse.osgi.util.TextProcessor; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -174,12 +173,7 @@ public class ResourceSelectorWidget { // browse button browseButton = new Button(browserComp, SWT.PUSH); browseButton.setText(BROWSE_LABEL); - browseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleURIBrowseButtonPressed(); - } - }); + browseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleURIBrowseButtonPressed())); uriField.addModifyListener(e -> updateFilesystemSelector(uriField.getText())); } diff --git a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java index f534b2c448..9a0410f506 100644 --- a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java +++ b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 IBM Corporation + * Copyright (c) 2011, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,8 +26,7 @@ import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.linuxtools.tools.launch.core.LaunchCoreConstants; import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -116,12 +115,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { systemEnvButton = new Button(radios, SWT.RADIO); systemEnvButton.setText(Messages.LINUXTOOLS_PATH_SYSTEM_ENV); systemEnvButton.setSelection(systemPathSelected); - systemEnvButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateOptionsEnable(); - } - }); + systemEnvButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateOptionsEnable())); customButton = new Button(radios, SWT.RADIO); customButton.setText(Messages.LINUXTOOLS_PATH_CUSTOM); diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java index c40cea946e..9ebbd73a4e 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java @@ -25,8 +25,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.window.Window; import org.eclipse.linuxtools.internal.callgraph.core.PluginConstants; import org.eclipse.swt.SWT; -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.FillLayout; import org.eclipse.swt.layout.GridData; @@ -170,17 +169,14 @@ public class LaunchWizard extends SystemTapLaunchShortcut { Button scriptButton = new Button(fileComp, SWT.PUSH); scriptButton.setText(Messages.getString("SystemTapOptionsTab.BrowseFiles")); //$NON-NLS-1$ scriptButton.setLayoutData(new GridData()); - scriptButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = scriptLocation.getText(); - FileDialog dialog = new FileDialog(sh, SWT.SAVE); - filePath = dialog.open(); - if (filePath != null) { - scriptLocation.setText(filePath); - } - } - }); + scriptButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String filePath = scriptLocation.getText(); + FileDialog dialog = new FileDialog(sh, SWT.SAVE); + filePath = dialog.open(); + if (filePath != null) { + scriptLocation.setText(filePath); + } + })); GridData gd2 = new GridData(); @@ -193,21 +189,19 @@ public class LaunchWizard extends SystemTapLaunchShortcut { textData.applyTo(binaryLocation); Button binaryButton = new Button(fileComp, SWT.PUSH); binaryButton.setText(Messages.getString("SystemTapOptionsTab.WorkspaceButton2")); //$NON-NLS-1$ - binaryButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(sh, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ - dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - String arg = resource.getFullPath().toString(); - binaryLocation.setText(workspacePath + arg); - } - } - }); + binaryButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(sh, new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ + dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + String arg = resource.getFullPath().toString(); + binaryLocation.setText(workspacePath + arg); + } + })); Composite argumentsComp = new Composite(sh, SWT.BORDER_DASH); argumentsComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -223,15 +217,11 @@ public class LaunchWizard extends SystemTapLaunchShortcut { argumentsLocation.setLayoutData(gd3); Button argumentsButton = new Button(argumentsComp, SWT.PUSH); argumentsButton.setText(Messages.getString("LaunchWizard.Func")); //$NON-NLS-1$ - argumentsButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - argumentsLocation.setText( - argumentsLocation.getText() + " process(\"" //$NON-NLS-1$ - + binaryLocation.getText() + "\").function(\"\")"); //$NON-NLS-1$ - } - }); + argumentsButton.addSelectionListener(SelectionListener + .widgetSelectedAdapter(e -> argumentsLocation.setText(argumentsLocation.getText() + " process(\"" //$NON-NLS-1$ + + binaryLocation.getText() + "\").function(\"\")") //$NON-NLS-1$ + )); //TODO: Don't use blank labels to move button to the right column :P Label blankLabel2 = new Label(argumentsComp, SWT.HORIZONTAL); @@ -241,22 +231,19 @@ public class LaunchWizard extends SystemTapLaunchShortcut { Button launch = new Button(sh, SWT.PUSH); launch.setLayoutData(new GridData(GridData.CENTER, GridData.BEGINNING, false, false)); launch.setText(Messages.getString("LaunchWizard.Launch")); //$NON-NLS-1$ - launch.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - scriptPath = scriptLocation.getText(); - binaryPath = binaryLocation.getText(); - arguments = argumentsLocation.getText(); - ILaunchConfigurationWorkingCopy wc = createConfiguration(null, name); - try { - finishLaunch(scriptPath + ": " + binName, mode, wc);//$NON-NLS-1$ - } catch (Exception e1) { - e1.printStackTrace(); - } - sh.dispose(); - } - - }); + launch.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + scriptPath = scriptLocation.getText(); + binaryPath = binaryLocation.getText(); + arguments = argumentsLocation.getText(); + ILaunchConfigurationWorkingCopy wc = createConfiguration(null, name); + try { + finishLaunch(scriptPath + ": " + binName, mode, wc);//$NON-NLS-1$ + } catch (Exception e1) { + e1.printStackTrace(); + } + sh.dispose(); + + })); //TODO: Verify that this works Display.getCurrent().asyncExec(() -> sh.open()); diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapOptionsTab.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapOptionsTab.java index 88e9d4e37a..a339bae786 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapOptionsTab.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapOptionsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,12 +42,8 @@ import org.eclipse.linuxtools.internal.callgraph.core.LaunchConfigurationConstan import org.eclipse.linuxtools.internal.callgraph.core.PluginConstants; import org.eclipse.linuxtools.internal.callgraph.core.SystemTapView; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; 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; @@ -132,29 +128,22 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ * and a final */ - private SelectionListener graphicsModeListener = new SelectionAdapter(){ - @Override - public void widgetSelected(SelectionEvent e) { - if (scriptFile.isEnabled()){ - scriptFile.setEnabled(false); - workspaceBrowseButton.setEnabled(false); - fileBrowseButton.setEnabled(false); - scriptFile.setText(PluginConstants.getPluginLocation()+"parse_function.stp"); //$NON-NLS-1$ - }else{ - scriptFile.setEnabled(true); - workspaceBrowseButton.setEnabled(true); - fileBrowseButton.setEnabled(true); - } - updateLaunchConfigurationDialog(); - } - }; - - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener graphicsModeListener = SelectionListener.widgetSelectedAdapter(e -> { + if (scriptFile.isEnabled()) { + scriptFile.setEnabled(false); + workspaceBrowseButton.setEnabled(false); + fileBrowseButton.setEnabled(false); + scriptFile.setText(PluginConstants.getPluginLocation() + "parse_function.stp"); //$NON-NLS-1$ + } else { + scriptFile.setEnabled(true); + workspaceBrowseButton.setEnabled(true); + fileBrowseButton.setEnabled(true); + } + updateLaunchConfigurationDialog(); + }); + + private SelectionListener selectListener = SelectionListener + .widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @@ -163,18 +152,15 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ outputFileHasChanged = true; }; - private FocusListener focusListener = new FocusAdapter() { + private FocusListener focusListener = FocusListener.focusLostAdapter(e -> { - @Override - public void focusLost(FocusEvent e) { - if (outputFileHasChanged) { - checkOverwrite(); - } - outputFileHasChanged = false; + if (outputFileHasChanged) { + checkOverwrite(); + } + outputFileHasChanged = false; - updateLaunchConfigurationDialog(); - } - }; + updateLaunchConfigurationDialog(); + }); /** * Convenience method to check if the overwrite permissions are consistent @@ -311,25 +297,20 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ Button parserButton = createPushButton(browseTop, "Find parsers", null); //$NON-NLS-1$ - parserButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), - new ListLabelProvider()); - dialog.setTitle("Select parser"); //$NON-NLS-1$ - dialog.setMessage("Select parser to use."); //$NON-NLS-1$ - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] extensions = reg - .getConfigurationElementsFor(PluginConstants.PARSER_RESOURCE, - PluginConstants.PARSER_NAME); - - dialog.setElements(extensions); - if (dialog.open() == IDialogConstants.OK_ID) { - String arg = getUsefulLabel(dialog.getFirstResult()); - parser.setText(arg); - } - } - }); + parserButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new ListLabelProvider()); + dialog.setTitle("Select parser"); //$NON-NLS-1$ + dialog.setMessage("Select parser to use."); //$NON-NLS-1$ + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IConfigurationElement[] extensions = reg.getConfigurationElementsFor(PluginConstants.PARSER_RESOURCE, + PluginConstants.PARSER_NAME); + + dialog.setElements(extensions); + if (dialog.open() == IDialogConstants.OK_ID) { + String arg = getUsefulLabel(dialog.getFirstResult()); + parser.setText(arg); + } + })); viewer = new Text(browseTop, SWT.BORDER); @@ -338,38 +319,33 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ Button viewerButton = createPushButton(browseTop, "Find viewers", null); //$NON-NLS-1$ - viewerButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), - new ListLabelProvider()); - dialog.setTitle("Select viewer"); //$NON-NLS-1$ - dialog.setMessage("Select viewer to use."); //$NON-NLS-1$ - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] extensions = reg - .getConfigurationElementsFor(PluginConstants.VIEW_RESOURCE, - PluginConstants.VIEW_NAME); - ArrayList<IConfigurationElement> ext = new ArrayList<>(); - for (IConfigurationElement el : extensions) { - if (!el.getNamespaceIdentifier().contains("org.eclipse.linuxtools")) //$NON-NLS-1$ - continue; - //TODO: Rough hack to get all the objects. We restrict to id's containing org.eclipse.linuxtools, then see if the class extends SystemTapView - try { - if (el.createExecutableExtension(PluginConstants.ATTR_CLASS) - instanceof SystemTapView) { - ext.add(el); - } - } catch (CoreException e1) { - } - } - - dialog.setElements(ext.toArray()); - if (dialog.open() == IDialogConstants.OK_ID) { - String arg = getUsefulLabel(dialog.getFirstResult()); - viewer.setText(arg); - } - } - }); + viewerButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new ListLabelProvider()); + dialog.setTitle("Select viewer"); //$NON-NLS-1$ + dialog.setMessage("Select viewer to use."); //$NON-NLS-1$ + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IConfigurationElement[] extensions = reg.getConfigurationElementsFor(PluginConstants.VIEW_RESOURCE, + PluginConstants.VIEW_NAME); + ArrayList<IConfigurationElement> ext = new ArrayList<>(); + for (IConfigurationElement el : extensions) { + if (!el.getNamespaceIdentifier().contains("org.eclipse.linuxtools")) //$NON-NLS-1$ + continue; + // TODO: Rough hack to get all the objects. We restrict to id's containing + // org.eclipse.linuxtools, then see if the class extends SystemTapView + try { + if (el.createExecutableExtension(PluginConstants.ATTR_CLASS) instanceof SystemTapView) { + ext.add(el); + } + } catch (CoreException e1) { + } + } + + dialog.setElements(ext.toArray()); + if (dialog.open() == IDialogConstants.OK_ID) { + String arg = getUsefulLabel(dialog.getFirstResult()); + viewer.setText(arg); + } + })); } @@ -392,12 +368,9 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ Button probeFunctionButton = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.ProbeFunction"), null); //$NON-NLS-1$ - probeFunctionButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - arguments.setText(arguments.getText() + " process(\"" + binaryFile.getText() + "\").function(\"\")"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); + probeFunctionButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> arguments + .setText(arguments.getText() + " process(\"" + binaryFile.getText() + "\").function(\"\")") //$NON-NLS-1$ //$NON-NLS-2$ + )); } private void createFileOption(Composite top) { @@ -413,34 +386,29 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ scriptFile.addModifyListener(modifyListener); workspaceBrowseButton = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton"), null); //$NON-NLS-1$ - workspaceBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(Messages.getString("SystemTapOptionsTab.ResourceButton")); //$NON-NLS-1$ - dialog.setMessage(Messages.getString("SystemTapOptionsTab.SuppresionsFile")); //$NON-NLS-1$ - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - String arg = resource.getFullPath().toString(); - scriptFile.setText(workspacePath + arg); - } - } - }); + workspaceBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.getString("SystemTapOptionsTab.ResourceButton")); //$NON-NLS-1$ + dialog.setMessage(Messages.getString("SystemTapOptionsTab.SuppresionsFile")); //$NON-NLS-1$ + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + String arg = resource.getFullPath().toString(); + scriptFile.setText(workspacePath + arg); + } + })); fileBrowseButton = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.FileSystem"), null); //$NON-NLS-1$ - fileBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = scriptFile.getText(); - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - filePath = dialog.open(); - if (filePath != null) { - scriptFile.setText(filePath); - } - } - }); + fileBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String filePath = scriptFile.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + filePath = dialog.open(); + if (filePath != null) { + scriptFile.setText(filePath); + } + })); Label binaryFileLabel = new Label(browseTop, SWT.NONE); @@ -452,36 +420,32 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ Button workspaceBrowseButton2 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton2"), null); //$NON-NLS-1$ - workspaceBrowseButton2.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ - dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - String arg = resource.getFullPath().toString(); - binaryFile.setText(workspacePath + arg); - } - } - }); + workspaceBrowseButton2.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ + dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + String arg = resource.getFullPath().toString(); + binaryFile.setText(workspacePath + arg); + } + })); Button fileBrowseButton2 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.BrowseFiles"), null); //$NON-NLS-1$ - fileBrowseButton2.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = binaryFile.getText(); - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - filePath = dialog.open(); - if (filePath != null) { - File file = new File(filePath); - if (file.exists()) binaryFile.setText(filePath); - } - } - }); + fileBrowseButton2.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String filePath = binaryFile.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + filePath = dialog.open(); + if (filePath != null) { + File file = new File(filePath); + if (file.exists()) + binaryFile.setText(filePath); + } + })); Label outputFileLabel = new Label(browseTop, SWT.NONE); @@ -493,39 +457,34 @@ public class SystemTapOptionsTab extends CLaunchConfigurationTab{ outputFile.addFocusListener(focusListener); Button workspaceBrowseButton3 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton2"), null); //$NON-NLS-1$ - workspaceBrowseButton3.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ - dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - String arg = resource.getFullPath().toString(); - outputFile.setText(workspacePath + arg); - checkOverwrite(); - updateLaunchConfigurationDialog(); - - } - } - }); + workspaceBrowseButton3.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource")); //$NON-NLS-1$ + dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions")); //$NON-NLS-1$ + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + String arg = resource.getFullPath().toString(); + outputFile.setText(workspacePath + arg); + checkOverwrite(); + updateLaunchConfigurationDialog(); + + } + })); Button fileBrowseButton3 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.BrowseFiles"), null); //$NON-NLS-1$ - fileBrowseButton3.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = outputFile.getText(); - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - filePath = dialog.open(); - if (filePath != null) { - outputFile.setText(filePath); - checkOverwrite(); - updateLaunchConfigurationDialog(); - } - } - }); + fileBrowseButton3.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String filePath = outputFile.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + filePath = dialog.open(); + if (filePath != null) { + outputFile.setText(filePath); + checkOverwrite(); + updateLaunchConfigurationDialog(); + } + })); useColourButton = new Button(browseTop, SWT.CHECK); useColourButton.setText(Messages.getString("SystemTapOptionsTab.ColourCodes")); //$NON-NLS-1$ diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java index 46e3c6b4a0..23b0ede359 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java +++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,8 +37,7 @@ import org.eclipse.linuxtools.internal.callgraph.core.SystemTapUIErrorMessages; import org.eclipse.linuxtools.internal.callgraph.core.SystemTapView; import org.eclipse.linuxtools.internal.callgraph.graphlisteners.AutoScrollSelectionListener; import org.eclipse.swt.SWT; -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.FillLayout; import org.eclipse.swt.layout.GridData; @@ -722,37 +721,34 @@ public class CallgraphView extends SystemTapView { Button setLimit = new Button(sh, SWT.PUSH); setLimit.setText(Messages.getString("CallgraphView.SetValues")); //$NON-NLS-1$ setLimit.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - setLimit.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean redraw = false; - if (limit.getSelection() >= 0 && buffer.getSelection() >= 0) { - g.setMaxNodes(limit.getSelection()); - g.setLevelBuffer(buffer.getSelection()); - - if (g.changeLevelLimits(g.getLevelOfNode(g.getRootVisibleNodeNumber()))) { - SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( - Messages.getString("CallgraphView.BufferTooHigh"), Messages.getString("CallgraphView.BufferTooHigh"), //$NON-NLS-1$ //$NON-NLS-2$ - Messages.getString("CallgraphView.BufferMessage1") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage2") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage3") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage4") + g.getLevelBuffer() + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage5") + PluginConstants.NEW_LINE + PluginConstants.NEW_LINE + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage6") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage7")); //$NON-NLS-1$ - mess.schedule(); - } - - redraw = true; - } - sh.dispose(); - - if (redraw) { - g.draw(); - } - } - - }); + setLimit.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + boolean redraw = false; + if (limit.getSelection() >= 0 && buffer.getSelection() >= 0) { + g.setMaxNodes(limit.getSelection()); + g.setLevelBuffer(buffer.getSelection()); + + if (g.changeLevelLimits(g.getLevelOfNode(g.getRootVisibleNodeNumber()))) { + SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( + Messages.getString("CallgraphView.BufferTooHigh"), //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferTooHigh"), //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage1") + //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage2") + //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage3") + //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage4") + g.getLevelBuffer() + //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage5") + PluginConstants.NEW_LINE //$NON-NLS-1$ + + PluginConstants.NEW_LINE + Messages.getString("CallgraphView.BufferMessage6") + //$NON-NLS-1$ + Messages.getString("CallgraphView.BufferMessage7")); //$NON-NLS-1$ + mess.schedule(); + } + + redraw = true; + } + sh.dispose(); + + if (redraw) { + g.draw(); + } + })); sh.open(); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/FilterWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/FilterWizardPage.java index a31cfdad33..ef9b65a5e9 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/FilterWizardPage.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/FilterWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation. + * Copyright (c) 2006, 2017 IBM Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,8 +14,6 @@ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.wizards.filter; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.systemtap.graphing.core.filters.IDataSetFilter; 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.widgets.Composite; @@ -46,12 +44,7 @@ public abstract class FilterWizardPage extends WizardPage { super.dispose(); } - protected final SelectionListener selectionListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - update(); - } - }; + protected final SelectionListener selectionListener = SelectionListener.widgetSelectedAdapter(e -> update()); protected final ModifyListener modifyListener = e -> update(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/RangeFilterWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/RangeFilterWizardPage.java index fe659f5a9f..0a5ca24748 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/RangeFilterWizardPage.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/wizards/filter/RangeFilterWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation. + * Copyright (c) 2006, 2017 IBM Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,8 +14,6 @@ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.wizards.filter; import org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization; import org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -182,19 +180,15 @@ public class RangeFilterWizardPage extends FilterWizardPage { } } - private final KeyListener numberKeyListener = new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if((e.character >= ' ' && e.character <= '~') - && (e.character > '9' || e.character < '0')) { - e.doit = false; - } - if(e.character == '.' && !((Text)e.widget).getText().contains(".")) { //$NON-NLS-1$ - e.doit = true; - } - } + private final KeyListener numberKeyListener = KeyListener.keyPressedAdapter(e -> { + if ((e.character >= ' ' && e.character <= '~') && (e.character > '9' || e.character < '0')) { + e.doit = false; + } + if (e.character == '.' && !((Text) e.widget).getText().contains(".")) { //$NON-NLS-1$ + e.doit = true; + } - }; + }); private Combo cboColumn; private Text txtLow, txtHigh; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousXControl.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousXControl.java index fa5e1068aa..e902e670ef 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousXControl.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousXControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. + * Copyright (c) 2013, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,8 +13,7 @@ package org.eclipse.linuxtools.systemtap.graphing.ui.widgets; import org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -56,13 +55,10 @@ public class GraphContinuousXControl extends Composite { data.left = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); zoomOutButton.setLayoutData(data); - zoomOutButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - zoomScale.setSelection(zoomScale.getSelection() - CLICK_INCREMENT); - updateScale(); - } - }); + zoomOutButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + zoomScale.setSelection(zoomScale.getSelection() - CLICK_INCREMENT); + updateScale(); + })); Button zoomInButton = new Button(this, SWT.CENTER); zoomInButton.setText(Messages.GraphContinuousControl_ZoomInLabel); @@ -72,13 +68,10 @@ public class GraphContinuousXControl extends Composite { data.right = new FormAttachment(100, 0); data.bottom = ((FormData) zoomOutButton.getLayoutData()).bottom; zoomInButton.setLayoutData(data); - zoomInButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - zoomScale.setSelection(zoomScale.getSelection() + CLICK_INCREMENT); - updateScale(); - } - }); + zoomInButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + zoomScale.setSelection(zoomScale.getSelection() + CLICK_INCREMENT); + updateScale(); + })); zoomScale = new Scale(this,SWT.HORIZONTAL); zoomScale.setMinimum(0); @@ -107,18 +100,8 @@ public class GraphContinuousXControl extends Composite { data.right = new FormAttachment(zoomInButton, 0); scrollBar.setLayoutData(data); - zoomScale.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateScale(); - } - }); - scrollBar.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateScroll(); - } - }); + zoomScale.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateScale())); + scrollBar.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateScroll())); updateScale(); updateScroll(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousYControl.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousYControl.java index dda4ababd7..d8bd3fd2d0 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousYControl.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphContinuousYControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. + * Copyright (c) 2013, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,8 +13,7 @@ package org.eclipse.linuxtools.systemtap.graphing.ui.widgets; import org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -56,13 +55,10 @@ public class GraphContinuousYControl extends Composite { data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); zoomOutButton.setLayoutData(data); - zoomOutButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - zoomScale.setSelection(zoomScale.getSelection() + CLICK_INCREMENT); - updateScaleY(); - } - }); + zoomOutButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + zoomScale.setSelection(zoomScale.getSelection() + CLICK_INCREMENT); + updateScaleY(); + })); Button zoomInButton = new Button(this, SWT.CENTER); zoomInButton.setText(Messages.GraphContinuousControl_ZoomInLabel); @@ -72,13 +68,10 @@ public class GraphContinuousYControl extends Composite { data.top = new FormAttachment(0, 0); data.left = ((FormData) zoomOutButton.getLayoutData()).left; zoomInButton.setLayoutData(data); - zoomInButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - zoomScale.setSelection(zoomScale.getSelection() - CLICK_INCREMENT); - updateScaleY(); - } - }); + zoomInButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + zoomScale.setSelection(zoomScale.getSelection() - CLICK_INCREMENT); + updateScaleY(); + })); zoomScale = new Scale(this,SWT.VERTICAL); zoomScale.setMinimum(1); @@ -107,18 +100,8 @@ public class GraphContinuousYControl extends Composite { data.bottom = new FormAttachment(zoomOutButton, 0); scrollBar.setLayoutData(data); - zoomScale.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateScaleY(); - } - }); - scrollBar.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateScrollY(); - } - }); + zoomScale.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateScaleY())); + scrollBar.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateScrollY())); updateScaleY(); updateScrollY(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphDiscreteXControl.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphDiscreteXControl.java index d638b75968..b157f4ee29 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphDiscreteXControl.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/widgets/GraphDiscreteXControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. + * Copyright (c) 2013, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,8 +14,7 @@ package org.eclipse.linuxtools.systemtap.graphing.ui.widgets; import org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder; import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -57,86 +56,57 @@ public class GraphDiscreteXControl extends Composite implements IUpdateListener firstButton.setText(Messages.GraphDiscreteXControl_First); firstButton.setFont(font); firstButton.setEnabled(false); - firstButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - builder.setScroll(0); - firstButton.setEnabled(false); - leftButton.setEnabled(false); - rightButton.setEnabled(true); - lastButton.setEnabled(true); - } - }); + firstButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + builder.setScroll(0); + firstButton.setEnabled(false); + leftButton.setEnabled(false); + rightButton.setEnabled(true); + lastButton.setEnabled(true); + })); leftButton = new Button(this, SWT.CENTER); leftButton.setText(Messages.GraphDiscreteXControl_Left); leftButton.setFont(font); leftButton.setEnabled(false); - leftButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - stepScroll(-1); - } - }); + leftButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> stepScroll(-1))); zoomInButton = new Button(this, SWT.CENTER); zoomInButton.setText(Messages.GraphDiscreteXControl_ZoomIn); zoomInButton.setFont(font); zoomInButton.setEnabled(false); - zoomInButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - builder.setScale(builder.getScale() / ZOOM_AMOUNT); - } - }); + zoomInButton.addSelectionListener( + SelectionListener.widgetSelectedAdapter(e -> builder.setScale(builder.getScale() / ZOOM_AMOUNT))); zoomOutButton = new Button(this, SWT.CENTER); zoomOutButton.setText(Messages.GraphDiscreteXControl_ZoomOut); zoomOutButton.setFont(font); zoomOutButton.setEnabled(false); - zoomOutButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - builder.setScale(builder.getScale() * ZOOM_AMOUNT); - } - }); + zoomOutButton.addSelectionListener( + SelectionListener.widgetSelectedAdapter(e -> builder.setScale(builder.getScale() * ZOOM_AMOUNT))); allButton = new Button(this, SWT.CENTER); allButton.setText(Messages.GraphDiscreteXControl_All); allButton.setFont(font); allButton.setEnabled(false); - allButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - builder.setScale(1.0); - } - }); + allButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> builder.setScale(1.0))); rightButton = new Button(this, SWT.CENTER); rightButton.setText(Messages.GraphDiscreteXControl_Right); rightButton.setFont(font); rightButton.setEnabled(false); - rightButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - stepScroll(1); - } - }); + rightButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> stepScroll(1))); lastButton = new Button(this, SWT.CENTER); lastButton.setText(Messages.GraphDiscreteXControl_Last); lastButton.setFont(font); lastButton.setEnabled(false); - lastButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - builder.setScroll(1); - firstButton.setEnabled(true); - leftButton.setEnabled(true); - rightButton.setEnabled(false); - lastButton.setEnabled(false); - } - }); + lastButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + builder.setScroll(1); + firstButton.setEnabled(true); + leftButton.setEnabled(true); + rightButton.setEnabled(false); + lastButton.setEnabled(false); + })); } private int getNumItems() { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java index 6ca7d78001..231dcb86cf 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,8 +17,8 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; @@ -378,11 +378,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements * the user interacts with them. Namely, it checks for naming errors * and invalid series selections, and handles display of Y-series combo boxes. */ - private class ComboSelectionListener implements SelectionListener { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - + private class ComboSelectionListener extends SelectionAdapter { @Override public void widgetSelected(SelectionEvent e) { Combo source = (Combo) e.getSource(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java index 01f954f9ad..50881c147a 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Red Hat. + * Copyright (c) 2012, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,7 +44,6 @@ import org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.SelectGraphAnd import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; 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; @@ -201,80 +200,79 @@ public class SystemTapScriptGraphOptionsTab extends updateLaunchConfigurationDialog(); }; - private SelectionAdapter regexGenerator = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - MessageDialog dialog; - IWorkbench workbench = PlatformUI.getWorkbench(); - IPath scriptPath = null; - for (ILaunchConfigurationTab tab : getLaunchConfigurationDialog().getTabs()) { - if (tab instanceof SystemTapScriptLaunchConfigurationTab) { - scriptPath = ((SystemTapScriptLaunchConfigurationTab) tab).getScriptPath(); - break; - } - } - if (scriptPath == null) { - dialog = new MessageDialog(workbench - .getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null, - Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsError, - MessageDialog.ERROR, new String[]{"OK"}, 0); //$NON-NLS-1$ - dialog.open(); - return; - } - - dialog = new MessageDialog(workbench - .getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTitle, null, - Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsMessage, - MessageDialog.QUESTION, new String[]{"Yes", "Cancel"}, 0); //$NON-NLS-1$ //$NON-NLS-2$ - int result = dialog.open(); - if (result != 0) { // Cancel - return; - } - - List<Entry<String, Integer>> regexs = SystemTapRegexGenerator.generateFromPrintf(scriptPath, MAX_NUMBER_OF_REGEXS); - - if (regexs.size() == 0) { - dialog = new MessageDialog(workbench - .getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null, - Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsEmpty, - MessageDialog.ERROR, new String[]{"OK"}, 0); //$NON-NLS-1$ - dialog.open(); - } else { - // Since script output has been found, reset the configuration's regexs. - textListenersEnabled = false; - regularExpressionCombo.removeAll(); - outputList.clear(); - regexErrorMessages.clear(); - columnNamesList.clear(); - cachedNamesList.clear(); - graphsTable.removeAll(); - graphsDataList.clear(); - badGraphs.clear(); - for (int i = 0, n = regexs.size(); i < n; i++) { - List<String> columnNames = new ArrayList<>(); - for (int c = 0, numColumns = regexs.get(i).getValue(); c < numColumns; c++) { - columnNames.add(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, c+1)); - } - regularExpressionCombo.add(regexs.get(i).getKey()); - outputList.add(""); //$NON-NLS-1$ //For empty "sample output" entry. - regexErrorMessages.add(null); - columnNamesList.add(columnNames); - cachedNamesList.add(new Stack<String>()); - graphsDataList.add(new LinkedList<GraphData>()); - } - if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { - regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew); - } - textListenersEnabled = true; - - removeRegexButton.setEnabled(getNumberOfRegexs() > 1); - regularExpressionCombo.select(0); - updateRegexSelection(0, true); - checkAllOtherErrors(); // Check for errors in case there was a problem with regex generation - updateLaunchConfigurationDialog(); - } - } - }; + private SelectionListener regexGenerator = SelectionListener.widgetSelectedAdapter(e -> { + MessageDialog dialog; + IWorkbench workbench = PlatformUI.getWorkbench(); + IPath scriptPath = null; + for (ILaunchConfigurationTab tab : getLaunchConfigurationDialog().getTabs()) { + if (tab instanceof SystemTapScriptLaunchConfigurationTab) { + scriptPath = ((SystemTapScriptLaunchConfigurationTab) tab).getScriptPath(); + break; + } + } + if (scriptPath == null) { + dialog = new MessageDialog(workbench.getActiveWorkbenchWindow().getShell(), + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null, + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsError, MessageDialog.ERROR, + new String[] { "OK" }, 0); //$NON-NLS-1$ + dialog.open(); + return; + } + + dialog = new MessageDialog(workbench.getActiveWorkbenchWindow().getShell(), + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTitle, null, + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsMessage, MessageDialog.QUESTION, + new String[] { "Yes", "Cancel" }, 0); //$NON-NLS-1$ //$NON-NLS-2$ + int result = dialog.open(); + if (result != 0) { // Cancel + return; + } + + List<Entry<String, Integer>> regexs = SystemTapRegexGenerator.generateFromPrintf(scriptPath, + MAX_NUMBER_OF_REGEXS); + + if (regexs.size() == 0) { + dialog = new MessageDialog(workbench.getActiveWorkbenchWindow().getShell(), + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null, + Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsEmpty, MessageDialog.ERROR, + new String[] { "OK" }, 0); //$NON-NLS-1$ + dialog.open(); + } else { + // Since script output has been found, reset the configuration's regexs. + textListenersEnabled = false; + regularExpressionCombo.removeAll(); + outputList.clear(); + regexErrorMessages.clear(); + columnNamesList.clear(); + cachedNamesList.clear(); + graphsTable.removeAll(); + graphsDataList.clear(); + badGraphs.clear(); + for (int i = 0, n = regexs.size(); i < n; i++) { + List<String> columnNames = new ArrayList<>(); + for (int c = 0, numColumns = regexs.get(i).getValue(); c < numColumns; c++) { + columnNames.add(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, + c + 1)); + } + regularExpressionCombo.add(regexs.get(i).getKey()); + outputList.add(""); //$NON-NLS-1$ //For empty "sample output" entry. + regexErrorMessages.add(null); + columnNamesList.add(columnNames); + cachedNamesList.add(new Stack<String>()); + graphsDataList.add(new LinkedList<GraphData>()); + } + if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { + regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew); + } + textListenersEnabled = true; + + removeRegexButton.setEnabled(getNumberOfRegexs() > 1); + regularExpressionCombo.select(0); + updateRegexSelection(0, true); + checkAllOtherErrors(); // Check for errors in case there was a problem with regex generation + updateLaunchConfigurationDialog(); + } + }); /** * Returns the list of the names given to reach regular expression. @@ -476,79 +474,73 @@ public class SystemTapScriptGraphOptionsTab extends regularExpressionCombo = new Combo(regexButtonLayout, SWT.DROP_DOWN); regularExpressionCombo.setTextLimit(MAX_REGEX_LENGTH); regularExpressionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - regularExpressionCombo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int selected = regularExpressionCombo.getSelectionIndex(); - if (selected == selectedRegex) { - return; - } - - // If deselecting an empty regular expression, delete it automatically. - if (regularExpressionCombo.getItem(selectedRegex).isEmpty() - && graphsDataList.get(selectedRegex).size() == 0 - && outputList.get(selectedRegex).isEmpty()) { - - // If the deselected regex is the last one in the combo, just quit. - // Otherwise, the deleted blank entry would be replaced by another blank entry. - if (selected == regularExpressionCombo.getItemCount() - 1) { - regularExpressionCombo.select(selectedRegex); // To keep the text blank. - return; - } - removeRegex(false); - if (selected > selectedRegex) { - selected--; - } - } - - // When selecting the "Add New Regex" item in the combo (which is always the last item), - // update all appropriate values to make room for a new regular expression. - if (selected == regularExpressionCombo.getItemCount() - 1 && getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { - outputList.add(""); //$NON-NLS-1$ - regexErrorMessages.add(null); - columnNamesList.add(new ArrayList<String>()); - cachedNamesList.add(new Stack<String>()); - graphsDataList.add(new LinkedList<GraphData>()); - - // Remove "Add New Regex" from the selected combo item; make it blank. - regularExpressionCombo.setItem(selected, ""); //$NON-NLS-1$ - regularExpressionCombo.select(selected); - updateRegexSelection(selected, false); - updateLaunchConfigurationDialog(); - - // Enable the "remove" button if only one item was present before. - // (Don't do this _every_ time something is added.) - if (getNumberOfRegexs() == 2) { - removeRegexButton.setEnabled(true); - } - if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { - regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew); - } - } else { - updateRegexSelection(selected, false); - } - } - }); + regularExpressionCombo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + int selected = regularExpressionCombo.getSelectionIndex(); + if (selected == selectedRegex) { + return; + } + + // If deselecting an empty regular expression, delete it automatically. + if (regularExpressionCombo.getItem(selectedRegex).isEmpty() && graphsDataList.get(selectedRegex).size() == 0 + && outputList.get(selectedRegex).isEmpty()) { + + // If the deselected regex is the last one in the combo, just quit. + // Otherwise, the deleted blank entry would be replaced by another blank entry. + if (selected == regularExpressionCombo.getItemCount() - 1) { + regularExpressionCombo.select(selectedRegex); // To keep the text blank. + return; + } + removeRegex(false); + if (selected > selectedRegex) { + selected--; + } + } + + // When selecting the "Add New Regex" item in the combo (which is always the + // last item), + // update all appropriate values to make room for a new regular expression. + if (selected == regularExpressionCombo.getItemCount() - 1 && getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { + outputList.add(""); //$NON-NLS-1$ + regexErrorMessages.add(null); + columnNamesList.add(new ArrayList<String>()); + cachedNamesList.add(new Stack<String>()); + graphsDataList.add(new LinkedList<GraphData>()); + + // Remove "Add New Regex" from the selected combo item; make it blank. + regularExpressionCombo.setItem(selected, ""); //$NON-NLS-1$ + regularExpressionCombo.select(selected); + updateRegexSelection(selected, false); + updateLaunchConfigurationDialog(); + + // Enable the "remove" button if only one item was present before. + // (Don't do this _every_ time something is added.) + if (getNumberOfRegexs() == 2) { + removeRegexButton.setEnabled(true); + } + if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) { + regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew); + } + } else { + updateRegexSelection(selected, false); + } + })); regularExpressionCombo.addModifyListener(regexListener); removeRegexButton = new Button(regexButtonLayout, SWT.PUSH); removeRegexButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); removeRegexButton.setText(Messages.SystemTapScriptGraphOptionsTab_regexRemove); - removeRegexButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IWorkbench workbench = PlatformUI.getWorkbench(); - MessageDialog dialog = new MessageDialog(workbench - .getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_removeRegexTitle, null, - MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_removeRegexAsk, - regularExpressionCombo.getItem(selectedRegex)), - MessageDialog.QUESTION, new String[]{"Yes", "No"}, 0); //$NON-NLS-1$ //$NON-NLS-2$ - int result = dialog.open(); - if (result == 0) { //Yes - removeRegex(true); - } - } - }); + removeRegexButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + IWorkbench workbench = PlatformUI.getWorkbench(); + MessageDialog dialog = new MessageDialog(workbench.getActiveWorkbenchWindow().getShell(), + Messages.SystemTapScriptGraphOptionsTab_removeRegexTitle, null, + MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_removeRegexAsk, + regularExpressionCombo.getItem(selectedRegex)), + MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); //$NON-NLS-1$ //$NON-NLS-2$ + int result = dialog.open(); + if (result == 0) { // Yes + removeRegex(true); + } + })); GridLayout twoColumns = new GridLayout(2, false); @@ -645,99 +637,82 @@ public class SystemTapScriptGraphOptionsTab extends // Action to notify the buttons when to enable/disable themselves based // on list selection - graphsTable.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectedTableItem = (TableItem) e.item; - setSelectionControlsEnabled(true); - } - }); + graphsTable.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + selectedTableItem = (TableItem) e.item; + setSelectionControlsEnabled(true); + })); // Brings up a new dialog box when user clicks the add button. Allows // selecting a new graph to display. - addGraphButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), null); - IWorkbench workbench = PlatformUI.getWorkbench(); - wizard.init(workbench, null); - WizardDialog dialog = new WizardDialog(workbench - .getActiveWorkbenchWindow().getShell(), wizard); - dialog.create(); - dialog.open(); - - GraphData gd = wizard.getGraphData(); - - if (gd != null) { - TableItem item = new TableItem(graphsTable, SWT.NONE); - graphsData.add(gd); - setUpGraphTableItem(item, gd, false); - updateLaunchConfigurationDialog(); - } - } - }); + addGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), null); + IWorkbench workbench = PlatformUI.getWorkbench(); + wizard.init(workbench, null); + WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); + dialog.create(); + dialog.open(); + + GraphData gd = wizard.getGraphData(); + + if (gd != null) { + TableItem item = new TableItem(graphsTable, SWT.NONE); + graphsData.add(gd); + setUpGraphTableItem(item, gd, false); + updateLaunchConfigurationDialog(); + } + })); // Adds a new entry to the list of graphs that is a copy of the one selected. - duplicateGraphButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - GraphData gd = ((GraphData) selectedTableItem.getData()).getCopy(); - - TableItem item = new TableItem(graphsTable, SWT.NONE); - graphsData.add(gd); - if (badGraphs.contains(selectedTableItem.getData())) { - badGraphs.add(gd); - setUpGraphTableItem(item, gd, true); - } else { - setUpGraphTableItem(item, gd, false); - } - updateLaunchConfigurationDialog(); - } - }); + duplicateGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + GraphData gd = ((GraphData) selectedTableItem.getData()).getCopy(); + + TableItem item = new TableItem(graphsTable, SWT.NONE); + graphsData.add(gd); + if (badGraphs.contains(selectedTableItem.getData())) { + badGraphs.add(gd); + setUpGraphTableItem(item, gd, true); + } else { + setUpGraphTableItem(item, gd, false); + } + updateLaunchConfigurationDialog(); + })); // When button is clicked, brings up same wizard as the one for adding // a graph. Data in the wizard is filled out to match the properties // of the selected graph. - editGraphButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), - (GraphData) selectedTableItem.getData()); - IWorkbench workbench = PlatformUI.getWorkbench(); - wizard.init(workbench, null); - WizardDialog dialog = new WizardDialog(workbench - .getActiveWorkbenchWindow().getShell(), wizard); - dialog.create(); - dialog.open(); - - GraphData gd = wizard.getGraphData(); - if (gd == null) { - return; - } - GraphData old_gd = (GraphData) selectedTableItem.getData(); - if (!gd.isCopyOf(old_gd)) { - badGraphs.remove(old_gd); - setUpGraphTableItem(selectedTableItem, gd, false); - graphsData.set(graphsTable.indexOf(selectedTableItem), gd); - checkErrors(selectedRegex); - updateLaunchConfigurationDialog(); - } - } - }); + editGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), + (GraphData) selectedTableItem.getData()); + IWorkbench workbench = PlatformUI.getWorkbench(); + wizard.init(workbench, null); + WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); + dialog.create(); + dialog.open(); + + GraphData gd = wizard.getGraphData(); + if (gd == null) { + return; + } + GraphData old_gd = (GraphData) selectedTableItem.getData(); + if (!gd.isCopyOf(old_gd)) { + badGraphs.remove(old_gd); + setUpGraphTableItem(selectedTableItem, gd, false); + graphsData.set(graphsTable.indexOf(selectedTableItem), gd); + checkErrors(selectedRegex); + updateLaunchConfigurationDialog(); + } + })); // Removes the selected graph/filter from the table - removeGraphButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - GraphData gd = (GraphData) selectedTableItem.getData(); - graphsData.remove(gd); - badGraphs.remove(gd); - selectedTableItem.dispose(); - setSelectionControlsEnabled(false); - checkErrors(selectedRegex); - updateLaunchConfigurationDialog(); - } - }); + removeGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + GraphData gd = (GraphData) selectedTableItem.getData(); + graphsData.remove(gd); + badGraphs.remove(gd); + selectedTableItem.dispose(); + setSelectionControlsEnabled(false); + checkErrors(selectedRegex); + updateLaunchConfigurationDialog(); + })); } private void removeRegex(boolean autoSelect) { @@ -935,43 +910,37 @@ public class SystemTapScriptGraphOptionsTab extends textFieldsComposite.pack(); // Add button listeners for shifting column names. - buttonUp.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - Control clickedButton = (Control) e.widget; - Control[] children = textFieldsComposite.getChildren(); - int currentColumn = 0; - for (; currentColumn < numberOfVisibleColumns - 1; currentColumn++) { - if (children[currentColumn*4].equals(clickedButton)) { - break; - } - } - String edgeName = ((Text)children[currentColumn*4 + 2]).getText(); - for (int i = currentColumn; i < numberOfVisibleColumns - 1; i++) { - ((Text)children[i*4 + 2]).setText(((Text)children[(i + 1)*4 + 2]).getText()); - } - ((Text)children[(numberOfVisibleColumns - 1)*4 + 2]).setText(edgeName); - } - }); - - buttonDown.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - Control clickedButton = (Control) e.widget; - Control[] children = textFieldsComposite.getChildren(); - int currentColumn = 0; - for (; currentColumn < numberOfVisibleColumns - 1; currentColumn++) { - if (children[currentColumn*4 + 1].equals(clickedButton)) { - break; - } - } - String edgeName = ((Text)children[(numberOfVisibleColumns - 1)*4 + 2]).getText(); - for (int i = numberOfVisibleColumns - 1; i > currentColumn; i--) { - ((Text)children[i*4 + 2]).setText(((Text)children[(i - 1)*4 + 2]).getText()); - } - ((Text)children[currentColumn*4 + 2]).setText(edgeName); - } - }); + buttonUp.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + Control clickedButton = (Control) e.widget; + Control[] children = textFieldsComposite.getChildren(); + int currentColumn = 0; + for (; currentColumn < numberOfVisibleColumns - 1; currentColumn++) { + if (children[currentColumn * 4].equals(clickedButton)) { + break; + } + } + String edgeName = ((Text) children[currentColumn * 4 + 2]).getText(); + for (int i = currentColumn; i < numberOfVisibleColumns - 1; i++) { + ((Text) children[i * 4 + 2]).setText(((Text) children[(i + 1) * 4 + 2]).getText()); + } + ((Text) children[(numberOfVisibleColumns - 1) * 4 + 2]).setText(edgeName); + })); + + buttonDown.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + Control clickedButton = (Control) e.widget; + Control[] children = textFieldsComposite.getChildren(); + int currentColumn = 0; + for (; currentColumn < numberOfVisibleColumns - 1; currentColumn++) { + if (children[currentColumn * 4 + 1].equals(clickedButton)) { + break; + } + } + String edgeName = ((Text) children[(numberOfVisibleColumns - 1) * 4 + 2]).getText(); + for (int i = numberOfVisibleColumns - 1; i > currentColumn; i--) { + ((Text) children[i * 4 + 2]).setText(((Text) children[(i - 1) * 4 + 2]).getText()); + } + ((Text) children[currentColumn * 4 + 2]).setText(edgeName); + })); } /** diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java index e5a00f7798..e1d1e435a6 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Red Hat. + * Copyright (c) 2012, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,7 +28,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin; import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.PathEditorInput; import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; @@ -128,16 +127,12 @@ public class SystemTapScriptLaunchConfigurationTab extends gridData.widthHint = 110; selectScriptButon.setLayoutData(gridData); selectScriptButon.setText(Messages.SystemTapScriptLaunchConfigurationTab_browse); - selectScriptButon.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - String path = fileDialog.open(); - if (path != null) { - scriptPathText.setText(path); - } - } - }); + selectScriptButon.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String path = fileDialog.open(); + if (path != null) { + scriptPathText.setText(path); + } + })); // User Settings Group userSettingsGroup = new Group(top, SWT.SHADOW_ETCHED_IN); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptOptionsTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptOptionsTab.java index 2b1bb59f9f..be86e435b2 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptOptionsTab.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptOptionsTab.java @@ -25,7 +25,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenc import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog; import org.eclipse.swt.SWT; 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; @@ -92,16 +91,12 @@ public class SystemTapScriptOptionsTab extends AbstractLaunchConfigurationTab { selectTargetProgramButton.setLayoutData(gridData); selectTargetProgramButton .setText(Messages.SystemTapScriptLaunchConfigurationTab_browse); - selectTargetProgramButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - String fileName = fileDialog.open(); - if (fileName != null) { - targetProgramText.setText(fileName); - } - } - }); + selectTargetProgramButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String fileName = fileDialog.open(); + if (fileName != null) { + targetProgramText.setText(fileName); + } + })); // Check boxes Composite cmpChkBoxes = new Composite(comp, SWT.NONE); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/wizards/StapNewWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/wizards/StapNewWizardPage.java index 476c8b7474..f19beb4aff 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/wizards/StapNewWizardPage.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/wizards/StapNewWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 Red Hat Inc. and others. + * Copyright (c) 2012, 2017 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,8 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -86,12 +85,7 @@ public class StapNewWizardPage extends WizardPage { Button button = new Button(container, SWT.PUSH); button.setText(resourceBundle.getString("StapNewWizardPage.Browse")); //$NON-NLS-1$ - button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleBrowse(); - } - }); + button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleBrowse())); initialize(); dialogChanged(); setControl(container); diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java index f0bdd3c172..d8e498b02f 100644 --- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java +++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,6 @@ import org.eclipse.linuxtools.vagrant.core.IVagrantVM; import org.eclipse.linuxtools.vagrant.core.VagrantService; import org.eclipse.swt.SWT; 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.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -165,15 +163,14 @@ public class VagrantBoxView extends ViewPart implements IVagrantBoxListener { } private SelectionListener onColumnSelected() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final TableColumn sortColumn = (TableColumn) e.getSource(); - final VagrantBoxComparator comparator = (VagrantBoxComparator) viewer.getComparator(); - comparator.setColumn(sortColumn); - viewer.refresh(); + return SelectionListener.widgetSelectedAdapter(e -> { + final TableColumn sortColumn = (TableColumn) e.getSource(); + final VagrantBoxComparator comparator = (VagrantBoxComparator) viewer + .getComparator(); + comparator.setColumn(sortColumn); + viewer.refresh(); } - }; + ); } private void setLayout(final TableViewerColumn viewerColumn, final TableColumnLayout tableLayout, final int weight) { diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java index 91cbc2bab3..44845ae59e 100644 --- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java +++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,8 +33,6 @@ import org.eclipse.linuxtools.vagrant.core.IVagrantVMListener; import org.eclipse.linuxtools.vagrant.core.VagrantService; import org.eclipse.swt.SWT; 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.widgets.Composite; @@ -190,16 +188,13 @@ public class VagrantVMView extends ViewPart implements IVagrantVMListener { } private SelectionListener onColumnSelected() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - final TableColumn sortColumn = (TableColumn) e.getSource(); - final VagrantVMComparator comparator = (VagrantVMComparator) viewer - .getComparator(); - comparator.setColumn(sortColumn); - viewer.refresh(); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + final TableColumn sortColumn = (TableColumn) e.getSource(); + final VagrantVMComparator comparator = (VagrantVMComparator) viewer + .getComparator(); + comparator.setColumn(sortColumn); + viewer.refresh(); + }); } private void setLayout(final TableViewerColumn viewerColumn, final TableColumnLayout tableLayout, final int weight) { diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/AddBoxPage.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/AddBoxPage.java index 9181c96d7d..8503e009df 100644 --- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/AddBoxPage.java +++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/AddBoxPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,8 +28,6 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.internal.vagrant.ui.SWTImagesFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; @@ -140,17 +138,13 @@ public class AddBoxPage extends WizardPage { * @return */ private SelectionListener onSearchImage() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - FileDialog fd = new FileDialog(getShell()); - String location = fd.open(); - if (location != null && !location.isEmpty()) { - model.setBoxLoc(location); - } + return SelectionListener.widgetSelectedAdapter(e -> { + FileDialog fd = new FileDialog(getShell()); + String location = fd.open(); + if (location != null && !location.isEmpty()) { + model.setBoxLoc(location); } - }; + }); } private class CreateBoxValidationStatusProvider extends MultiValidator { diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java index 52dbf740bc..94ef440cb4 100644 --- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java +++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,8 +34,6 @@ import org.eclipse.linuxtools.internal.vagrant.ui.SWTImagesFactory; import org.eclipse.linuxtools.vagrant.core.IVagrantBox; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; @@ -207,57 +205,47 @@ public class CreateVMPage extends WizardPage { private SelectionListener onCheckCustomVMFile(Text vmNameText, Text boxRefText, Text boxLocText, Button searchButton, Button boxSearchButton) { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - if (e.widget instanceof Button) { - Button bt = (Button) e.widget; - if (bt.getSelection()) { - vmNameText.setEnabled(false); - boxRefText.setEnabled(false); - boxSearchButton.setEnabled(false); - searchButton.setEnabled(true); - boxLocText.setEnabled(true); - model.setVFileMode(true); - } else { - vmNameText.setEnabled(true); - boxRefText.setEnabled(true); - boxSearchButton.setEnabled(true); - searchButton.setEnabled(false); - boxLocText.setEnabled(false); - model.setVFileMode(false); - } + return SelectionListener.widgetSelectedAdapter(e -> { + if (e.widget instanceof Button) { + Button bt = (Button) e.widget; + if (bt.getSelection()) { + vmNameText.setEnabled(false); + boxRefText.setEnabled(false); + boxSearchButton.setEnabled(false); + searchButton.setEnabled(true); + boxLocText.setEnabled(true); + model.setVFileMode(true); + } else { + vmNameText.setEnabled(true); + boxRefText.setEnabled(true); + boxSearchButton.setEnabled(true); + searchButton.setEnabled(false); + boxLocText.setEnabled(false); + model.setVFileMode(false); } } - }; + }); } private SelectionListener onSearchImage() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - FileDialog fd = new FileDialog(getShell()); - String location = fd.open(); - if (location != null && !location.isEmpty()) { - model.setBoxRef(location); - } + return SelectionListener.widgetSelectedAdapter(e -> { + FileDialog fd = new FileDialog(getShell()); + String location = fd.open(); + if (location != null && !location.isEmpty()) { + model.setBoxRef(location); } - }; + }); } private SelectionListener onSearchVMFile() { - return new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - FileDialog fd = new FileDialog(getShell()); - String location = fd.open(); - if (location != null && !location.isEmpty()) { - model.setVMFile(location); - vmFileChanged(location); - } + return SelectionListener.widgetSelectedAdapter(e -> { + FileDialog fd = new FileDialog(getShell()); + String location = fd.open(); + if (location != null && !location.isEmpty()) { + model.setVMFile(location); + vmFileChanged(location); } - }; + }); } private void vmFileChanged(String vagrantFile) { diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/PackageVMPage.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/PackageVMPage.java index 021cf818b5..3bee46d3b8 100644 --- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/PackageVMPage.java +++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/PackageVMPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat. + * Copyright (c) 2015, 2017 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,6 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.internal.vagrant.ui.SWTImagesFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; @@ -144,17 +142,13 @@ public class PackageVMPage extends WizardPage { * @return */ private SelectionListener onSearchFolder() { - return new SelectionAdapter() { - - @Override - public void widgetSelected(final SelectionEvent e) { - DirectoryDialog fd = new DirectoryDialog(getShell()); - String location = fd.open(); - if (location != null && !location.isEmpty()) { - model.setBoxFolder(location); - } + return SelectionListener.widgetSelectedAdapter(e -> { + DirectoryDialog fd = new DirectoryDialog(getShell()); + String location = fd.open(); + if (location != null && !location.isEmpty()) { + model.setBoxFolder(location); } - }; + }); } private class PackageVMValidationStatusProvider extends MultiValidator { diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindToolPage.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindToolPage.java index 572ad382b7..15054666d9 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindToolPage.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindToolPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,8 +18,6 @@ import org.eclipse.linuxtools.internal.valgrind.launch.LaunchConfigurationConsta import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; import org.eclipse.swt.SWT; 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.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -49,12 +47,7 @@ public class CachegrindToolPage extends AbstractLaunchConfigurationTab private Button l2Button; private boolean isInitializing = false; - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener selectListener = SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @Override @@ -81,13 +74,10 @@ public class CachegrindToolPage extends AbstractLaunchConfigurationTab // I1 Cache i1Button = new Button(cacheGroup, SWT.CHECK); i1Button.setText(Messages.getString("CachegrindToolPage.I1_Cache")); //$NON-NLS-1$ - i1Button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkI1Enablement(); - updateLaunchConfigurationDialog(); - } - }); + i1Button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkI1Enablement(); + updateLaunchConfigurationDialog(); + })); Composite i1Top = new Composite(cacheGroup, SWT.BORDER); GridLayout i1Layout = new GridLayout(6, false); @@ -118,13 +108,10 @@ public class CachegrindToolPage extends AbstractLaunchConfigurationTab // D1 Cache d1Button = new Button(cacheGroup, SWT.CHECK); d1Button.setText(Messages.getString("CachegrindToolPage.D1_Cache")); //$NON-NLS-1$ - d1Button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkD1Enablement(); - updateLaunchConfigurationDialog(); - } - }); + d1Button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkD1Enablement(); + updateLaunchConfigurationDialog(); + })); Composite d1Top = new Composite(cacheGroup, SWT.BORDER); GridLayout d1Layout = new GridLayout(6, false); @@ -155,13 +142,10 @@ public class CachegrindToolPage extends AbstractLaunchConfigurationTab // D1 Cache l2Button = new Button(cacheGroup, SWT.CHECK); l2Button.setText(Messages.getString("CachegrindToolPage.L2_Cache")); //$NON-NLS-1$ - l2Button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkL2Enablement(); - updateLaunchConfigurationDialog(); - } - }); + l2Button.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkL2Enablement(); + updateLaunchConfigurationDialog(); + })); Composite l2Top = new Composite(cacheGroup, SWT.BORDER); GridLayout l2Layout = new GridLayout(6, false); diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindViewPart.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindViewPart.java index ae98c037a9..a4659465f9 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindViewPart.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/internal/valgrind/cachegrind/CachegrindViewPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,8 +39,6 @@ import org.eclipse.linuxtools.valgrind.ui.CollapseAction; import org.eclipse.linuxtools.valgrind.ui.ExpandAction; import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -207,70 +205,63 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { return doubleClickListener; } - private SelectionListener getHeaderListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - TreeColumn column = (TreeColumn) e.widget; - Tree tree = viewer.getTree(); - if (column.equals(tree.getSortColumn())) { - int direction = tree.getSortDirection() == SWT.UP ? SWT.DOWN - : SWT.UP; - tree.setSortDirection(direction); - } else { - tree.setSortDirection(SWT.UP); - } - tree.setSortColumn(column); - viewer.setComparator(new ViewerComparator() { - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - Tree tree = ((TreeViewer) viewer).getTree(); - int direction = tree.getSortDirection(); - ICachegrindElement o1 = (ICachegrindElement) e1; - ICachegrindElement o2 = (ICachegrindElement) e2; - long result = 0; - - int sortIndex = Arrays.asList(tree.getColumns()).indexOf(tree.getSortColumn()); - if (sortIndex == 0) { // use compareTo - result = o1.compareTo(o2); - } - else { - long[] v1 = null; - long[] v2 = null; - if (o1 instanceof CachegrindFunction && o2 instanceof CachegrindFunction) { - v1 = ((CachegrindFunction) o1).getTotals(); - v2 = ((CachegrindFunction) o2).getTotals(); - } - else if (o1 instanceof CachegrindLine && o2 instanceof CachegrindLine) { - v1 = ((CachegrindLine) o1).getValues(); - v2 = ((CachegrindLine) o2).getValues(); - } - else if (o1 instanceof CachegrindOutput && o2 instanceof CachegrindOutput) { - v1 = ((CachegrindOutput) o1).getSummary(); - v2 = ((CachegrindOutput) o2).getSummary(); - } - - if (v1 != null && v2 != null) { - result = v1[sortIndex - 1] - v2[sortIndex - 1]; - } - } - - // ascending or descending - result = direction == SWT.UP ? result : -result; - - // overflow check - if (result > Integer.MAX_VALUE) { - result = Integer.MAX_VALUE; - } else if (result < Integer.MIN_VALUE) { - result = Integer.MIN_VALUE; - } - - return (int) result; - } - }); - } - }; - } + private SelectionListener getHeaderListener() { + return SelectionListener.widgetSelectedAdapter(e -> { + TreeColumn column = (TreeColumn) e.widget; + Tree tree = viewer.getTree(); + if (column.equals(tree.getSortColumn())) { + int direction = tree.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP; + tree.setSortDirection(direction); + } else { + tree.setSortDirection(SWT.UP); + } + tree.setSortColumn(column); + viewer.setComparator(new ViewerComparator() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + Tree tree = ((TreeViewer) viewer).getTree(); + int direction = tree.getSortDirection(); + ICachegrindElement o1 = (ICachegrindElement) e1; + ICachegrindElement o2 = (ICachegrindElement) e2; + long result = 0; + + int sortIndex = Arrays.asList(tree.getColumns()).indexOf(tree.getSortColumn()); + if (sortIndex == 0) { // use compareTo + result = o1.compareTo(o2); + } else { + long[] v1 = null; + long[] v2 = null; + if (o1 instanceof CachegrindFunction && o2 instanceof CachegrindFunction) { + v1 = ((CachegrindFunction) o1).getTotals(); + v2 = ((CachegrindFunction) o2).getTotals(); + } else if (o1 instanceof CachegrindLine && o2 instanceof CachegrindLine) { + v1 = ((CachegrindLine) o1).getValues(); + v2 = ((CachegrindLine) o2).getValues(); + } else if (o1 instanceof CachegrindOutput && o2 instanceof CachegrindOutput) { + v1 = ((CachegrindOutput) o1).getSummary(); + v2 = ((CachegrindOutput) o2).getSummary(); + } + + if (v1 != null && v2 != null) { + result = v1[sortIndex - 1] - v2[sortIndex - 1]; + } + } + + // ascending or descending + result = direction == SWT.UP ? result : -result; + + // overflow check + if (result > Integer.MAX_VALUE) { + result = Integer.MAX_VALUE; + } else if (result < Integer.MIN_VALUE) { + result = Integer.MIN_VALUE; + } + + return (int) result; + } + }); + }); + } private String getFullEventName(String event) { String result = event; diff --git a/valgrind/org.eclipse.linuxtools.valgrind.helgrind/src/org/eclipse/linuxtools/internal/valgrind/helgrind/HelgrindToolPage.java b/valgrind/org.eclipse.linuxtools.valgrind.helgrind/src/org/eclipse/linuxtools/internal/valgrind/helgrind/HelgrindToolPage.java index c7c6617308..882545efa6 100755 --- a/valgrind/org.eclipse.linuxtools.valgrind.helgrind/src/org/eclipse/linuxtools/internal/valgrind/helgrind/HelgrindToolPage.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.helgrind/src/org/eclipse/linuxtools/internal/valgrind/helgrind/HelgrindToolPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation + * Copyright (c) 2011, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,13 +15,10 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -import org.eclipse.linuxtools.internal.valgrind.helgrind.HelgrindPlugin; import org.eclipse.linuxtools.internal.valgrind.launch.LaunchConfigurationConstants; import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; import org.eclipse.swt.SWT; 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.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -41,12 +38,7 @@ public class HelgrindToolPage extends AbstractLaunchConfigurationTab implements private boolean isInitializing = false; - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener selectListener = SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @Override diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindExportWizardPage.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindExportWizardPage.java index f1c5c42d89..867894fe6b 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindExportWizardPage.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindExportWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. + * Copyright (c) 2009, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,8 +24,7 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -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; import org.eclipse.swt.layout.GridLayout; @@ -98,22 +97,13 @@ public class ValgrindExportWizardPage extends WizardPage { Button selectAllButton = new Button(selectAllNoneTop, SWT.NONE); selectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); selectAllButton.setText(Messages.getString("ValgrindExportWizardPage.Select_all")); //$NON-NLS-1$ - selectAllButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - viewer.setAllChecked(true); - } - }); + selectAllButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> viewer.setAllChecked(true))); Button deselectAllButton = new Button(selectAllNoneTop, SWT.NONE); deselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); deselectAllButton.setText(Messages.getString("ValgrindExportWizardPage.Deselect_all")); //$NON-NLS-1$ - deselectAllButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - viewer.setAllChecked(false); - } - }); + deselectAllButton + .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> viewer.setAllChecked(false))); createDestinationGroup(top); @@ -153,19 +143,16 @@ public class ValgrindExportWizardPage extends WizardPage { Button browseButton = new Button(destGroup, SWT.PUSH); browseButton.setText(Messages.getString("ValgrindExportWizardPage.Browse")); //$NON-NLS-1$ - browseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - // Prompt for output directory - Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - DirectoryDialog dialog = new DirectoryDialog(parent); - dialog.setText(Messages.getString("ValgrindLaunchConfigurationDelegate.Select_Destination")); //$NON-NLS-1$ - String strpath = dialog.open(); - if (strpath != null) { - destText.setText(strpath); - } - } - }); + browseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + // Prompt for output directory + Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + DirectoryDialog dialog = new DirectoryDialog(parent); + dialog.setText(Messages.getString("ValgrindLaunchConfigurationDelegate.Select_Destination")); //$NON-NLS-1$ + String strpath = dialog.open(); + if (strpath != null) { + destText.setText(strpath); + } + })); } private boolean isValid() { diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java index 869bc7ae74..113ec8e6ff 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Red Hat, Inc. and others. + * Copyright (c) 2008, 2017 Red Hat, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,8 +32,6 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; 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.graphics.Point; @@ -117,12 +115,8 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { this.tool = tools[0]; } - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener selectListener = SelectionListener + .widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @@ -332,13 +326,10 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { mainStackSizeTop.setLayout(mainStackSizeLayout); mainStackSizeButton = new Button(mainStackSizeTop, SWT.CHECK); mainStackSizeButton.setText(Messages.getString("ValgrindOptionsTab.Main_stack_size")); //$NON-NLS-1$ - mainStackSizeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkMainStackEnablement(); - updateLaunchConfigurationDialog(); - } - }); + mainStackSizeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkMainStackEnablement(); + updateLaunchConfigurationDialog(); + })); mainStackSizeSpinner = new Spinner(mainStackSizeTop, SWT.BORDER); mainStackSizeSpinner.setMaximum(Integer.MAX_VALUE); mainStackSizeSpinner.addModifyListener(modifyListener); @@ -388,47 +379,40 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { buttonTop.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false)); Button workspaceBrowseButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.Workspace"), null); //$NON-NLS-1$ - workspaceBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.setTitle(Messages.getString("ValgrindOptionsTab.Select_a_Resource")); //$NON-NLS-1$ - dialog.setMessage(Messages.getString("ValgrindOptionsTab.Select_a_Suppressions_File")); //$NON-NLS-1$ - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - if (dialog.open() == IDialogConstants.OK_ID) { - IResource resource = (IResource) dialog.getFirstResult(); - String arg = resource.getFullPath().toString(); - String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ - suppFileList.add(fileLoc); - updateLaunchConfigurationDialog(); - } - } - }); + workspaceBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); + dialog.setTitle(Messages.getString("ValgrindOptionsTab.Select_a_Resource")); //$NON-NLS-1$ + dialog.setMessage(Messages.getString("ValgrindOptionsTab.Select_a_Suppressions_File")); //$NON-NLS-1$ + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + String arg = resource.getFullPath().toString(); + String fileLoc = VariablesPlugin.getDefault().getStringVariableManager() + .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ + suppFileList.add(fileLoc); + updateLaunchConfigurationDialog(); + } + })); Button fileBrowseButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.File_System"), null); //$NON-NLS-1$ - fileBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String filePath = null; - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - filePath = dialog.open(); - if (filePath != null) { - suppFileList.add(filePath); - updateLaunchConfigurationDialog(); - } - } - }); + fileBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + String filePath = null; + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + filePath = dialog.open(); + if (filePath != null) { + suppFileList.add(filePath); + updateLaunchConfigurationDialog(); + } + })); Button removeButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.Supp_remove"), null); //$NON-NLS-1$ - removeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int[] selected = suppFileList.getSelectionIndices(); - if (selected.length > 0) { - suppFileList.remove(selected); - updateLaunchConfigurationDialog(); - } - } - }); + removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + int[] selected = suppFileList.getSelectionIndices(); + if (selected.length > 0) { + suppFileList.remove(selected); + updateLaunchConfigurationDialog(); + } + })); } private void handleToolChanged() { diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifToolPage.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifToolPage.java index a0ae5cfac6..a4b5f88976 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifToolPage.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifToolPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Red Hat, Inc. + * Copyright (c) 2008, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,8 +23,6 @@ import org.eclipse.linuxtools.internal.valgrind.launch.LaunchConfigurationConsta import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; import org.eclipse.swt.SWT; 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.FontMetrics; import org.eclipse.swt.layout.GridData; @@ -67,12 +65,7 @@ public class MassifToolPage extends AbstractLaunchConfigurationTab private boolean isInitializing = false; private Version valgrindVersion; - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener selectListener = SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @Override @@ -191,13 +184,10 @@ public class MassifToolPage extends AbstractLaunchConfigurationTab alignmentTop.setLayout(alignmentLayout); alignmentButton = new Button(alignmentTop, SWT.CHECK); alignmentButton.setText(Messages.getString("MassifToolPage.minimum_heap_block")); //$NON-NLS-1$ - alignmentButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkAlignmentEnablement(); - updateLaunchConfigurationDialog(); - } - }); + alignmentButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkAlignmentEnablement(); + updateLaunchConfigurationDialog(); + })); alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER); alignmentSpinner.setMinimum(0); alignmentSpinner.setMaximum(4096); @@ -245,24 +235,18 @@ public class MassifToolPage extends AbstractLaunchConfigurationTab Button newButton = new Button(allocButtons, SWT.PUSH); newButton.setText(Messages.getString("MassifToolPage.New")); //$NON-NLS-1$ newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - newButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleAllocNewButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); + newButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleAllocNewButtonPressed(); + updateLaunchConfigurationDialog(); + })); Button removeButton = new Button(allocButtons, SWT.PUSH); removeButton.setText(Messages.getString("MassifToolPage.Remove")); //$NON-NLS-1$ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - removeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleAllocRemoveButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); + removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleAllocRemoveButtonPressed(); + updateLaunchConfigurationDialog(); + })); } private void createIgnoreFnControls(Composite top) { @@ -280,24 +264,18 @@ public class MassifToolPage extends AbstractLaunchConfigurationTab Button newButton = new Button(ignoreButtons, SWT.PUSH); newButton.setText(Messages.getString("MassifToolPage.New")); //$NON-NLS-1$ newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - newButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleIgnoreNewButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); + newButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleIgnoreNewButtonPressed(); + updateLaunchConfigurationDialog(); + })); Button removeButton = new Button(ignoreButtons, SWT.PUSH); removeButton.setText(Messages.getString("MassifToolPage.Remove")); //$NON-NLS-1$ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - removeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleIgnoreRemoveButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); + removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleIgnoreRemoveButtonPressed(); + updateLaunchConfigurationDialog(); + })); } private void handleAllocNewButtonPressed() { diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java index 1bef28c2aa..91dc77f283 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Red Hat, Inc. + * Copyright (c) 2008, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,8 +35,6 @@ import org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart; import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -165,56 +163,52 @@ public class MassifViewPart extends ViewPart implements IValgrindToolView { } private SelectionListener getHeaderListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - TableColumn column = (TableColumn) e.widget; - Table table = viewer.getTable(); - if (column.equals(table.getSortColumn())) { - int direction = table.getSortDirection() == SWT.UP ? SWT.DOWN - : SWT.UP; - table.setSortDirection(direction); - } else { - table.setSortDirection(SWT.UP); - } - table.setSortColumn(column); - viewer.setComparator(new ViewerComparator() { - @Override - public int compare(Viewer viewer, Object o1, Object o2) { - Table table = ((TableViewer) viewer).getTable(); - int direction = table.getSortDirection(); - MassifSnapshot s1 = (MassifSnapshot) o1; - MassifSnapshot s2 = (MassifSnapshot) o2; - long result; - TableColumn column = table.getSortColumn(); - if (column.getText().equals(TITLE_NUMBER)) { - result = s1.getNumber() - s2.getNumber(); - } else if (column.getText().startsWith(TITLE_TIME)) { - result = s1.getTime() - s2.getTime(); - } else if (column.getText().equals(TITLE_TOTAL)) { - result = s1.getTotal() - s2.getTotal(); - } else if (column.getText().equals(TITLE_USEFUL)) { - result = s1.getHeapBytes() - s2.getHeapBytes(); - } else if (column.getText().equals(TITLE_EXTRA)) { - result = s1.getHeapExtra() - s2.getHeapExtra(); - } else { - result = s1.getStacks() - s2.getStacks(); - } - - // ascending / descending - result = direction == SWT.UP ? result : -result; - - // overflow check - if (result > Integer.MAX_VALUE) { - result = Integer.MAX_VALUE; - } else if (result < Integer.MIN_VALUE) { - result = Integer.MIN_VALUE; - } - return (int) result; - } - }); - } - }; + return SelectionListener.widgetSelectedAdapter(e -> { + TableColumn column = (TableColumn) e.widget; + Table table = viewer.getTable(); + if (column.equals(table.getSortColumn())) { + int direction = table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP; + table.setSortDirection(direction); + } else { + table.setSortDirection(SWT.UP); + } + table.setSortColumn(column); + viewer.setComparator(new ViewerComparator() { + @Override + public int compare(Viewer viewer, Object o1, Object o2) { + Table table = ((TableViewer) viewer).getTable(); + int direction = table.getSortDirection(); + MassifSnapshot s1 = (MassifSnapshot) o1; + MassifSnapshot s2 = (MassifSnapshot) o2; + long result; + TableColumn column = table.getSortColumn(); + if (column.getText().equals(TITLE_NUMBER)) { + result = s1.getNumber() - s2.getNumber(); + } else if (column.getText().startsWith(TITLE_TIME)) { + result = s1.getTime() - s2.getTime(); + } else if (column.getText().equals(TITLE_TOTAL)) { + result = s1.getTotal() - s2.getTotal(); + } else if (column.getText().equals(TITLE_USEFUL)) { + result = s1.getHeapBytes() - s2.getHeapBytes(); + } else if (column.getText().equals(TITLE_EXTRA)) { + result = s1.getHeapExtra() - s2.getHeapExtra(); + } else { + result = s1.getStacks() - s2.getStacks(); + } + + // ascending / descending + result = direction == SWT.UP ? result : -result; + + // overflow check + if (result > Integer.MAX_VALUE) { + result = Integer.MAX_VALUE; + } else if (result < Integer.MIN_VALUE) { + result = Integer.MIN_VALUE; + } + return (int) result; + } + }); + }); } @Override diff --git a/valgrind/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/internal/valgrind/memcheck/MemcheckToolPage.java b/valgrind/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/internal/valgrind/memcheck/MemcheckToolPage.java index 34158d250e..76748ac498 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/internal/valgrind/memcheck/MemcheckToolPage.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.memcheck/src/org/eclipse/linuxtools/internal/valgrind/memcheck/MemcheckToolPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Red Hat, Inc. + * Copyright (c) 2008, 2017 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,8 +24,6 @@ import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; 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.FontMetrics; import org.eclipse.swt.layout.GridData; @@ -69,12 +67,7 @@ public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements private Version valgrindVersion; private CoreException ex = null; - private SelectionListener selectListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; + private SelectionListener selectListener = SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()); private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog(); @Override @@ -146,13 +139,10 @@ public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements alignmentButton = new Button(alignmentTop, SWT.CHECK); alignmentButton.setText(Messages.getString("MemcheckToolPage.minimum_heap_block")); //$NON-NLS-1$ - alignmentButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkAlignmentEnablement(); - updateLaunchConfigurationDialog(); - } - }); + alignmentButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkAlignmentEnablement(); + updateLaunchConfigurationDialog(); + })); alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER); alignmentSpinner.setMinimum(0); alignmentSpinner.setMaximum(4096); @@ -174,13 +164,10 @@ public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements mallocFillButton = new Button(mallocFillTop, SWT.CHECK); mallocFillButton.setText(Messages.getString("MemcheckToolPage.Malloc_Fill")); //$NON-NLS-1$ - mallocFillButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkMallocFillEnablement(); - updateLaunchConfigurationDialog(); - } - }); + mallocFillButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkMallocFillEnablement(); + updateLaunchConfigurationDialog(); + })); mallocFillText = new Text(mallocFillTop, SWT.BORDER); mallocFillText.setTextLimit(8); mallocFillText.addModifyListener(modifyListener); @@ -194,13 +181,10 @@ public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements freeFillButton = new Button(freeFillTop, SWT.CHECK); freeFillButton.setText(Messages.getString("MemcheckToolPage.Free_Fill")); //$NON-NLS-1$ - freeFillButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - checkFreeFillEnablement(); - updateLaunchConfigurationDialog(); - } - }); + freeFillButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + checkFreeFillEnablement(); + updateLaunchConfigurationDialog(); + })); freeFillText = new Text(freeFillTop, SWT.BORDER); mallocFillText.setTextLimit(8); freeFillText.addModifyListener(modifyListener); @@ -231,25 +215,18 @@ public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements Button newButton = new Button(ignoreButtons, SWT.PUSH); newButton.setText(Messages.getString("MemcheckToolPage.New")); //$NON-NLS-1$ newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - newButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleIgnoreNewButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); + newButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleIgnoreNewButtonPressed(); + updateLaunchConfigurationDialog(); + })); Button removeButton = new Button(ignoreButtons, SWT.PUSH); removeButton.setText(Messages.getString("MemcheckToolPage.Remove")); //$NON-NLS-1$ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - removeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleIgnoreRemoveButtonPressed(); - updateLaunchConfigurationDialog(); - } - }); - + removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + handleIgnoreRemoveButtonPressed(); + updateLaunchConfigurationDialog(); + })); } private void handleIgnoreNewButtonPressed() { |