Move from SelectionAdapter to SelectionListener default methods.
Fixes many synthetic access warnings.
Change-Id: I4c4c7da0354bb0bfbc3c34ba35df1b577e816164
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
index f126c76..d47d7bb 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
@@ -50,7 +50,6 @@
import org.eclipse.jface.viewers.ViewerComparator;
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;
@@ -312,53 +311,37 @@
Button selectAllBtn = new Button(selectionActionComposite, SWT.NONE);
selectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
selectAllBtn.setText(Messages.UpdateDepenciesDialog_selectAll);
- selectAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- for(IProject project : projects) {
- setSubtreeChecked(project, true);
- }
- updateSelectedProjects();
+ selectAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ for(IProject project : projects) {
+ setSubtreeChecked(project, true);
}
- });
+ updateSelectedProjects();
+ }));
if(showOutOfDateUI) {
addOutOfDateBtn = new Button(selectionActionComposite, SWT.NONE);
addOutOfDateBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
addOutOfDateBtn.setText(Messages.NestedProjectsComposite_Add_OutOfDate);
- addOutOfDateBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- includeOutOfDateProjects();
- }
- });
+ addOutOfDateBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> includeOutOfDateProjects()));
}
Button deselectAllBtn = new Button(selectionActionComposite, SWT.NONE);
deselectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
deselectAllBtn.setText(Messages.UpdateDepenciesDialog_deselectAll);
- deselectAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- codebaseViewer.setCheckedElements(new Object[0]);
- updateSelectedProjects();
- }
- });
+ deselectAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ codebaseViewer.setCheckedElements(new Object[0]);
+ updateSelectedProjects();
+ }));
Button expandAllBtn = new Button(selectionActionComposite, SWT.NONE);
expandAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
expandAllBtn.setText(Messages.UpdateDepenciesDialog_expandAll);
- expandAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- codebaseViewer.expandAll();
- }
- });
+ expandAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> codebaseViewer.expandAll()));
Button collapseAllBtn = new Button(selectionActionComposite, SWT.NONE);
collapseAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
collapseAllBtn.setText(Messages.UpdateDepenciesDialog_collapseAll);
- collapseAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- codebaseViewer.collapseAll();
- }
- });
+ collapseAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> codebaseViewer.collapseAll()));
}
String getElePath(Object element) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
index 9efa217..75f9af4 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
@@ -34,8 +34,7 @@
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.window.Window;
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.widgets.Button;
@@ -168,17 +167,15 @@
newWorkingSetButton.setData("name", "configureButton"); //$NON-NLS-1$ //$NON-NLS-2$
newWorkingSetButton.setText(Messages.WorkingSetGroup_btnMore);
newWorkingSetButton.setEnabled(false);
- newWorkingSetButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(final SelectionEvent e) {
- IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
- IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(shell, true,
- WORKING_SET_IDS.toArray(new String[0]));
- if(dialog.open() == Window.OK) {
- IWorkingSet[] workingSets = dialog.getSelection();
- selectWorkingSets(Arrays.asList(workingSets));
- }
+ newWorkingSetButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(shell, true,
+ WORKING_SET_IDS.toArray(new String[0]));
+ if(dialog.open() == Window.OK) {
+ IWorkingSet[] workingSets = dialog.getSelection();
+ selectWorkingSets(Arrays.asList(workingSets));
}
- });
+ }));
if(selectWorkingSets(workingSets)) {
addToWorkingSetButton.setSelection(true);
@@ -187,19 +184,17 @@
newWorkingSetButton.setEnabled(true);
}
- addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
- workingsetLabel.setEnabled(addToWorkingingSet);
- workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
- newWorkingSetButton.setEnabled(addToWorkingingSet);
- if(addToWorkingingSet) {
- updateConfiguration();
- } else {
- workingSets.clear();
- }
+ addToWorkingSetButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
+ workingsetLabel.setEnabled(addToWorkingingSet);
+ workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
+ newWorkingSetButton.setEnabled(addToWorkingingSet);
+ if(addToWorkingingSet) {
+ updateConfiguration();
+ } else {
+ workingSets.clear();
}
- });
+ }));
workingsetComboViewer.addSelectionChangedListener(event -> updateConfiguration());
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
index 2eb18f0..4bc53f8 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
@@ -21,8 +21,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.TitleAreaDialog;
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;
@@ -79,22 +78,14 @@
final Button btnFilterAssignedProjects = new Button(filtersComposite, SWT.CHECK);
btnFilterAssignedProjects.setText(Messages.AssignWorkingSetDialog_btnFilterAssignedProjects_text);
btnFilterAssignedProjects.setSelection(true);
- btnFilterAssignedProjects.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedProjects.refresh();
- }
- });
+ btnFilterAssignedProjects
+ .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> selectedProjects.refresh()));
final Button btnFilterClosedProjects = new Button(filtersComposite, SWT.CHECK);
btnFilterClosedProjects.setText(Messages.AssignWorkingSetDialog_btnFilterClosedProjects_text);
btnFilterClosedProjects.setSelection(true);
- btnFilterClosedProjects.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedProjects.refresh();
- }
- });
+ btnFilterClosedProjects
+ .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> selectedProjects.refresh()));
this.selectedProjects = new NestedProjectsComposite(composite, SWT.NONE, initialSelection, false) {
@Override
@@ -136,12 +127,10 @@
Button btnAssign = new Button(workingSetComposite, SWT.NONE);
btnAssign.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnAssign.setText(Messages.AssignWorkingSetDialog_btnAssign_text);
- btnAssign.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- assignWorkingSets();
- selectedProjects.reset();
- }
- });
+ btnAssign.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ assignWorkingSets();
+ selectedProjects.reset();
+ }));
return area;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingPreferencePage.java
index ee0d243..62441ea 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingPreferencePage.java
@@ -23,8 +23,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.preference.PreferencePage;
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;
import org.eclipse.swt.widgets.Composite;
@@ -98,29 +97,23 @@
new Label(composite, SWT.WRAP).setText(Messages.LifecycleMappingPreferencePage_WorkspaceMappingsDescription);
Button editLifecyclesButton = new Button(composite, SWT.PUSH);
editLifecyclesButton.setText(Messages.LifecycleMappingPreferencePage_WorkspaceMappingsOpen);
- editLifecyclesButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage();
- IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor(
- LifecycleMappingFactory.LIFECYCLE_MAPPING_METADATA_SOURCE_NAME);
- IEditorInput input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(
- new File(mappingFilePath)));
- IDE.openEditor(workbenchPage, input, desc.getId());
- } catch(PartInitException ex) {
- log.error(ex.getMessage(), ex);
- }
+ editLifecyclesButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ try {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = workbench.getEditorRegistry()
+ .getDefaultEditor(LifecycleMappingFactory.LIFECYCLE_MAPPING_METADATA_SOURCE_NAME);
+ IEditorInput input = new FileStoreEditorInput(
+ EFS.getLocalFileSystem().fromLocalFile(new File(mappingFilePath)));
+ IDE.openEditor(workbenchPage, input, desc.getId());
+ } catch(PartInitException ex) {
+ log.error(ex.getMessage(), ex);
}
- });
+ }));
Button refreshLifecyclesButton = new Button(composite, SWT.NONE);
- refreshLifecyclesButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- LifecycleMappingFactory.getWorkspaceMetadata(true);
- }
- });
+ refreshLifecyclesButton.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> LifecycleMappingFactory.getWorkspaceMetadata(true)));
refreshLifecyclesButton.setText(Messages.LifecycleMappingPreferencePage_btnRefreshLifecycles_text);
new Label(composite, SWT.NONE).setText(Messages.LifecycleMappingPreferencePage_ChangeLocation);
@@ -131,19 +124,17 @@
Button newFileButton = new Button(composite, SWT.PUSH);
newFileButton.setText(Messages.LifecycleMappingPreferencePage_Browse);
- newFileButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(LifecycleMappingPreferencePage.this.getShell(), SWT.NONE);
+ newFileButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ FileDialog dialog = new FileDialog(LifecycleMappingPreferencePage.this.getShell(), SWT.NONE);
- dialog.setText(Messages.LifecycleMappingPreferencePage_ChooseNewLocation);
- dialog.setFilterExtensions(new String[] {"*.xml", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- String res = dialog.open();
- if(res == null) {
- return;
- }
- mappingFileTextBox.setText(dialog.getFilterPath() + "/" + dialog.getFileName()); //$NON-NLS-1$
+ dialog.setText(Messages.LifecycleMappingPreferencePage_ChooseNewLocation);
+ dialog.setFilterExtensions(new String[] {"*.xml", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
+ String res = dialog.open();
+ if(res == null) {
+ return;
}
- });
+ mappingFileTextBox.setText(dialog.getFilterPath() + "/" + dialog.getFileName()); //$NON-NLS-1$
+ }));
return composite;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingsViewer.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingsViewer.java
index dd7f937..30178a8 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingsViewer.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingsViewer.java
@@ -44,8 +44,7 @@
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
-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;
@@ -143,13 +142,10 @@
btnShowPhases.setText(Messages.LifecycleMappingPropertyPage_showLIfecyclePhases);
final Button btnShowIgnored = new Button(optionsComposit, SWT.CHECK);
- btnShowIgnored.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- showIgnoredExecutions = btnShowIgnored.getSelection();
- updateMappingsTreeViewer();
- }
- });
+ btnShowIgnored.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ showIgnoredExecutions = btnShowIgnored.getSelection();
+ updateMappingsTreeViewer();
+ }));
btnShowIgnored.setSelection(showIgnoredExecutions);
btnShowIgnored.setText(Messages.LifecycleMappingPropertyPage_mntmShowIgnoredExecutions_text);
final Action actExpandAll = new Action(Messages.LifecycleMappingPropertyPage_mntmExpandAll_text,
@@ -180,15 +176,12 @@
toolBarManager.add(actCollapseAll);
toolBarManager.update(true);
- btnShowPhases.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- showPhases = btnShowPhases.getSelection();
- actExpandAll.setEnabled(showPhases);
- actCollapseAll.setEnabled(showPhases);
- updateMappingsTreeViewer();
- }
- });
+ btnShowPhases.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ showPhases = btnShowPhases.getSelection();
+ actExpandAll.setEnabled(showPhases);
+ actCollapseAll.setEnabled(showPhases);
+ updateMappingsTreeViewer();
+ }));
mappingsTreeViewer = new TreeViewer(container, SWT.BORDER);
Tree tree = mappingsTreeViewer.getTree();
@@ -309,12 +302,7 @@
actionsComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
Button btnCopyToClipboard = new Button(actionsComposite, SWT.NONE);
- btnCopyToClipboard.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- copyToClipboard();
- }
- });
+ btnCopyToClipboard.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> copyToClipboard()));
btnCopyToClipboard.setText(Messages.LifecycleMappingPropertyPage_copyToClipboard);
mappingsTreeViewer.setInput(phases);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LocalArchetypeCatalogDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LocalArchetypeCatalogDialog.java
index 79eabaa..2ff53e7 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LocalArchetypeCatalogDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LocalArchetypeCatalogDialog.java
@@ -27,8 +27,7 @@
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -119,17 +118,15 @@
Button browseButton = new Button(composite, SWT.NONE);
browseButton.setText(Messages.LocalArchetypeCatalogDialog_btnBrowse);
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(getShell());
- dialog.setText(Messages.LocalArchetypeCatalogDialog_dialog_title);
- String location = dialog.open();
- if(location != null) {
- catalogLocationCombo.setText(location);
- update();
- }
+ browseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ FileDialog dialog = new FileDialog(getShell());
+ dialog.setText(Messages.LocalArchetypeCatalogDialog_dialog_title);
+ String location = dialog.open();
+ if(location != null) {
+ catalogLocationCombo.setText(location);
+ update();
}
- });
+ }));
setButtonLayoutData(browseButton);
Label catalogDescriptionLabel = new Label(composite, SWT.NONE);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
index 6a931a0..ec42a77 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
@@ -36,8 +36,7 @@
import org.eclipse.jface.window.Window;
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.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -136,20 +135,18 @@
GridData gd_addRemoveOrLink = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
addRemoveOrLink.setLayoutData(gd_addRemoveOrLink);
addRemoveOrLink.setText(Messages.MavenArchetypesPreferencePage_link);
- addRemoveOrLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- URL url = new URL(
- "http://maven.apache.org/plugins/maven-archetype-plugin/specification/archetype-catalog.html"); //$NON-NLS-1$
- IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();
- browser.openURL(url);
- } catch(MalformedURLException ex) {
- log.error("Malformed URL", ex); //$NON-NLS-1$
- } catch(PartInitException ex) {
- log.error(ex.getMessage(), ex);
- }
+ addRemoveOrLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ try {
+ URL url = new URL(
+ "http://maven.apache.org/plugins/maven-archetype-plugin/specification/archetype-catalog.html"); //$NON-NLS-1$
+ IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();
+ browser.openURL(url);
+ } catch(MalformedURLException ex) {
+ log.error("Malformed URL", ex); //$NON-NLS-1$
+ } catch(PartInitException ex) {
+ log.error(ex.getMessage(), ex);
}
- });
+ }));
archetypesViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION);
@@ -184,87 +181,71 @@
Button enableAllBtn = new Button(composite, SWT.NONE);
enableAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
enableAllBtn.setText(Messages.MavenArchetypesPreferencePage_btnEnableAll);
- enableAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- toggleRepositories(true);
- }
- });
+ enableAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> toggleRepositories(true)));
Button disableAllBtn = new Button(composite, SWT.NONE);
disableAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
disableAllBtn.setText(Messages.MavenArchetypesPreferencePage_btnDisableAll);
- disableAllBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- toggleRepositories(false);
- }
- });
+ disableAllBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> toggleRepositories(false)));
Button addLocalButton = new Button(composite, SWT.NONE);
addLocalButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addLocalButton.setText(Messages.MavenArchetypesPreferencePage_btnAddLocal);
- addLocalButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- LocalArchetypeCatalogDialog dialog = new LocalArchetypeCatalogDialog(getShell(), null);
- if(dialog.open() == Window.OK) {
- addCatalogFactory(dialog.getArchetypeCatalogFactory());
- }
+ addLocalButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ LocalArchetypeCatalogDialog dialog = new LocalArchetypeCatalogDialog(getShell(), null);
+ if(dialog.open() == Window.OK) {
+ addCatalogFactory(dialog.getArchetypeCatalogFactory());
}
- });
+ }));
Button addRemoteButton = new Button(composite, SWT.NONE);
addRemoteButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addRemoteButton.setText(Messages.MavenArchetypesPreferencePage_btnAddRemote);
- addRemoteButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- RemoteArchetypeCatalogDialog dialog = new RemoteArchetypeCatalogDialog(getShell(), null);
- if(dialog.open() == Window.OK) {
- addCatalogFactory(dialog.getArchetypeCatalogFactory());
- }
+ addRemoteButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ RemoteArchetypeCatalogDialog dialog = new RemoteArchetypeCatalogDialog(getShell(), null);
+ if(dialog.open() == Window.OK) {
+ addCatalogFactory(dialog.getArchetypeCatalogFactory());
}
- });
+ }));
final Button editButton = new Button(composite, SWT.NONE);
editButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
editButton.setEnabled(false);
editButton.setText(Messages.MavenArchetypesPreferencePage_btnEdit);
- editButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
- ArchetypeCatalogFactory newFactory = null;
- if(factory instanceof LocalCatalogFactory) {
- LocalArchetypeCatalogDialog dialog = new LocalArchetypeCatalogDialog(getShell(), factory);
- if(dialog.open() == Window.OK) {
- newFactory = dialog.getArchetypeCatalogFactory();
- }
- } else if(factory instanceof RemoteCatalogFactory) {
- RemoteArchetypeCatalogDialog dialog = new RemoteArchetypeCatalogDialog(getShell(), factory);
- if(dialog.open() == Window.OK) {
- newFactory = dialog.getArchetypeCatalogFactory();
- }
+ editButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
+ ArchetypeCatalogFactory newFactory = null;
+ if(factory instanceof LocalCatalogFactory) {
+ LocalArchetypeCatalogDialog dialog = new LocalArchetypeCatalogDialog(getShell(), factory);
+ if(dialog.open() == Window.OK) {
+ newFactory = dialog.getArchetypeCatalogFactory();
}
- if(newFactory != null) {
- int n = archetypeCatalogs.indexOf(factory);
- if(n > -1) {
- archetypeCatalogs.set(n, newFactory);
- archetypesViewer.setInput(archetypeCatalogs);
- archetypesViewer.setSelection(new StructuredSelection(newFactory), true);
- }
+ } else if(factory instanceof RemoteCatalogFactory) {
+ RemoteArchetypeCatalogDialog dialog = new RemoteArchetypeCatalogDialog(getShell(), factory);
+ if(dialog.open() == Window.OK) {
+ newFactory = dialog.getArchetypeCatalogFactory();
}
}
- });
+ if(newFactory != null) {
+ int n = archetypeCatalogs.indexOf(factory);
+ if(n > -1) {
+ archetypeCatalogs.set(n, newFactory);
+ archetypesViewer.setInput(archetypeCatalogs);
+ archetypesViewer.setSelection(new StructuredSelection(newFactory), true);
+ }
+ }
+ }));
final Button removeButton = new Button(composite, SWT.NONE);
removeButton.setEnabled(false);
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
removeButton.setText(Messages.MavenArchetypesPreferencePage_btnRemove);
- removeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
- archetypeCatalogs.remove(factory);
- archetypesViewer.setInput(archetypeCatalogs);
- archetypesViewer.setSelection(null, true);
- }
- });
+ removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
+ archetypeCatalogs.remove(factory);
+ archetypesViewer.setInput(archetypeCatalogs);
+ archetypesViewer.setSelection(null, true);
+ }));
archetypesViewer.addSelectionChangedListener(event -> {
if(archetypesViewer.getSelection() instanceof IStructuredSelection) {
@@ -279,7 +260,7 @@
archetypesViewer.refresh(event.getElement(), true);
});
- archetypeCatalogs = new ArrayList<ArchetypeCatalogFactory>(archetypeManager.getArchetypeCatalogs());
+ archetypeCatalogs = new ArrayList<>(archetypeManager.getArchetypeCatalogs());
archetypesViewer.setInput(archetypeCatalogs);
archetypeCatalogs.forEach(a -> archetypesViewer.setChecked(a, a.isEnabled()));
archetypesViewer.refresh(); // should listen on property changes instead?
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java
index d5ca75d..68febda 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java
@@ -36,8 +36,7 @@
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -203,39 +202,33 @@
globalSettingsLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
globalSettingsLink.setText(Messages.MavenSettingsPreferencePage_globalSettingslink2);
globalSettingsLink.setToolTipText(Messages.MavenSettingsPreferencePage_globalSettingslink_tooltip);
- globalSettingsLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ globalSettingsLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String globalSettings = getGlobalSettings();
if(globalSettings != null) {
openEditor(globalSettings);
}
}
- });
+ ));
globalSettingsText = new Text(composite, SWT.BORDER);
globalSettingsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button globalSettingsBrowseButton = new Button(composite, SWT.NONE);
globalSettingsBrowseButton.setText(Messages.MavenSettingsPreferencePage_globalSettingsBrowseButton_text);
- globalSettingsBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- browseSettingsAction(globalSettingsText);
- }
- });
+ globalSettingsBrowseButton
+ .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> browseSettingsAction(globalSettingsText)));
userSettingsLink = new Link(composite, SWT.NONE);
userSettingsLink.setText(Messages.MavenSettingsPreferencePage_userSettingslink2);
userSettingsLink.setToolTipText(Messages.MavenSettingsPreferencePage_userSettingslink_tooltip);
userSettingsLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- userSettingsLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- String userSettings = getUserSettings();
- if(userSettings == null) {
- userSettings = SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath();
- }
- openEditor(userSettings);
+ userSettingsLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ String userSettings = getUserSettings();
+ if(userSettings == null) {
+ userSettings = SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath();
}
- });
+ openEditor(userSettings);
+ }));
userSettingsText = new Text(composite, SWT.BORDER);
userSettingsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
userSettingsText.setMessage(SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath());
@@ -243,20 +236,13 @@
Button userSettingsBrowseButton = new Button(composite, SWT.NONE);
userSettingsBrowseButton.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, false, false, 1, 1));
userSettingsBrowseButton.setText(Messages.MavenSettingsPreferencePage_userSettingsBrowseButton_text);
- userSettingsBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- browseSettingsAction(userSettingsText);
- }
- });
+ userSettingsBrowseButton
+ .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> browseSettingsAction(userSettingsText)));
Button updateSettings = new Button(composite, SWT.NONE);
updateSettings.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
updateSettings.setText(Messages.MavenSettingsPreferencePage_btnUpdate);
- updateSettings.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updateSettings(true);
- }
- });
+ updateSettings.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateSettings(true)));
Label localRepositoryLabel = new Label(composite, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd.verticalIndent = 25;
@@ -270,18 +256,15 @@
Button reindexButton = new Button(composite, SWT.NONE);
reindexButton.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, false, false, 1, 1));
reindexButton.setText(Messages.preferencesReindexButton);
- reindexButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- new WorkspaceJob(Messages.MavenSettingsPreferencePage_job_indexing) {
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- IndexManager indexManager = MavenPlugin.getIndexManager();
- indexManager.getWorkspaceIndex().updateIndex(true, monitor);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- });
+ reindexButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ new WorkspaceJob(Messages.MavenSettingsPreferencePage_job_indexing) {
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ IndexManager indexManager = MavenPlugin.getIndexManager();
+ indexManager.getWorkspaceIndex().updateIndex(true, monitor);
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }));
ModifyListener settingsModifyListener = modifyevent -> {
updateLocalRepository();
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
index d076159..eedfbe8 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
@@ -30,8 +30,7 @@
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -165,47 +164,44 @@
}
verifyButton = createButton(composite, VERIFY_ID, Messages.RemoteArchetypeCatalogDialog_btnVerify, false);
- verifyButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- verifyButton.setEnabled(false);
- String url = catalogUrlCombo.getText();
- final RemoteCatalogFactory factory = new RemoteCatalogFactory(url, null, true);
+ verifyButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ verifyButton.setEnabled(false);
+ String url = catalogUrlCombo.getText();
+ final RemoteCatalogFactory factory = new RemoteCatalogFactory(url, null, true);
- new Job(Messages.RemoteArchetypeCatalogDialog_job_download) {
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- ArchetypeCatalog catalog = null;
- try {
- catalog = factory.getArchetypeCatalog();
- } finally {
- final IStatus s = status;
- final List<Archetype> archetypes = ((catalog == null) ? Collections.emptyList()
- : catalog.getArchetypes());
- Shell shell = getShell();
- if(shell == null) {
- return status;
- }
- shell.getDisplay().asyncExec(() -> {
- if(verifyButton.isDisposed()) {
- return;
- }
- verifyButton.setEnabled(true);
- if(!s.isOK()) {
- setErrorMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_error_read, s.getMessage()));
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- } else if(archetypes.size() == 0) {
- setMessage(Messages.RemoteArchetypeCatalogDialog_error_empty, IStatus.WARNING);
- } else {
- setMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_message_found, archetypes.size()),
- IStatus.INFO);
- }
- });
+ new Job(Messages.RemoteArchetypeCatalogDialog_job_download) {
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ ArchetypeCatalog catalog = null;
+ try {
+ catalog = factory.getArchetypeCatalog();
+ } finally {
+ final IStatus s = status;
+ final List<Archetype> archetypes = ((catalog == null) ? Collections.emptyList() : catalog.getArchetypes());
+ Shell shell = getShell();
+ if(shell == null) {
+ return status;
}
- return Status.OK_STATUS;
+ shell.getDisplay().asyncExec(() -> {
+ if(verifyButton.isDisposed()) {
+ return;
+ }
+ verifyButton.setEnabled(true);
+ if(!s.isOK()) {
+ setErrorMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_error_read, s.getMessage()));
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ } else if(archetypes.size() == 0) {
+ setMessage(Messages.RemoteArchetypeCatalogDialog_error_empty, IStatus.WARNING);
+ } else {
+ setMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_message_found, archetypes.size()),
+ IStatus.INFO);
+ }
+ });
}
- }.schedule();
- }
- });
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }));
Label filler = new Label(composite, SWT.NONE);
filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
index 656f213..8c97d9e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
@@ -30,8 +30,7 @@
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.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -163,12 +162,7 @@
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
btnExternal = new Button(composite, SWT.RADIO);
- btnExternal.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- changeRuntimeTypeAction();
- }
- });
+ btnExternal.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> changeRuntimeTypeAction()));
btnExternal.setText(Messages.MavenInstallationWizardPage_btnExternal_text_1);
btnWorkspace = new Button(composite, SWT.RADIO);
@@ -182,12 +176,7 @@
location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnDirectory = new Button(container, SWT.NONE);
- btnDirectory.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectLocationAction();
- }
- });
+ btnDirectory.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> selectLocationAction()));
btnDirectory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnDirectory.setText(Messages.ExternalInstallPage_btnDirectory_text);
@@ -211,52 +200,27 @@
treeLibraries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 5));
btnAddProject = new Button(container, SWT.NONE);
- btnAddProject.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- addProjectExtensionAction();
- }
- });
+ btnAddProject.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> addProjectExtensionAction()));
btnAddProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnAddProject.setText(Messages.ExternalInstallPage_btnAddProject_text);
btnRemove = new Button(container, SWT.NONE);
- btnRemove.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- removeExtensionAction();
- }
- });
+ btnRemove.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> removeExtensionAction()));
btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnRemove.setText(Messages.ExternalInstallPage_btnRemove_text);
btnUp = new Button(container, SWT.NONE);
- btnUp.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- moveExtensionAction(-1);
- }
- });
+ btnUp.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> moveExtensionAction(-1)));
btnUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnUp.setText(Messages.ExternalInstallPage_btnUp_text);
btnDown = new Button(container, SWT.NONE);
- btnDown.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- moveExtensionAction(1);
- }
- });
+ btnDown.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> moveExtensionAction(1)));
btnDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnDown.setText(Messages.ExternalInstallPage_btnDown_text);
Button btnRestoreDefault = new Button(container, SWT.NONE);
- btnRestoreDefault.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- resetExtensionsAction();
- }
- });
+ btnRestoreDefault.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> resetExtensionsAction()));
btnRestoreDefault.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
btnRestoreDefault.setText(Messages.ExternalInstallPage_btnRestoreDefault_text);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
index 59812d4..15f0555 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
@@ -28,8 +28,7 @@
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
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;
@@ -207,50 +206,44 @@
Button addButton = new Button(composite, SWT.NONE);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.setText(Messages.MavenInstallationsPreferencePage_btnAdd);
- addButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- MavenInstallationWizard wizard = new MavenInstallationWizard(getForbiddenNames(null));
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- if(dialog.open() == Window.OK) {
- runtimes.add(wizard.getResult());
- refreshRuntimesViewer();
- }
+ addButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ MavenInstallationWizard wizard = new MavenInstallationWizard(getForbiddenNames(null));
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ if(dialog.open() == Window.OK) {
+ runtimes.add(wizard.getResult());
+ refreshRuntimesViewer();
}
- });
+ }));
final Button editButton = new Button(composite, SWT.NONE);
editButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
editButton.setEnabled(false);
editButton.setText(Messages.MavenInstallationsPreferencePage_btnEdit);
- editButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- AbstractMavenRuntime runtime = getSelectedMavenRuntime();
- MavenInstallationWizard wizard = new MavenInstallationWizard(runtime, getForbiddenNames(runtime));
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- if(dialog.open() == Window.OK) {
- AbstractMavenRuntime updatedRuntime = wizard.getResult();
- for(int i = 0; i < runtimes.size(); i++ ) {
- if(runtime == runtimes.get(i)) {
- runtimes.set(i, updatedRuntime);
- break;
- }
+ editButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
+ MavenInstallationWizard wizard = new MavenInstallationWizard(runtime, getForbiddenNames(runtime));
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ if(dialog.open() == Window.OK) {
+ AbstractMavenRuntime updatedRuntime = wizard.getResult();
+ for(int i = 0; i < runtimes.size(); i++ ) {
+ if(runtime == runtimes.get(i)) {
+ runtimes.set(i, updatedRuntime);
+ break;
}
- refreshRuntimesViewer();
}
+ refreshRuntimesViewer();
}
- });
+ }));
final Button removeButton = new Button(composite, SWT.NONE);
removeButton.setEnabled(false);
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removeButton.setText(Messages.MavenInstallationsPreferencePage_btnRemove);
- removeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- AbstractMavenRuntime runtime = getSelectedMavenRuntime();
- runtimes.remove(runtime);
- refreshRuntimesViewer();
- }
- });
+ removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
+ runtimes.remove(runtime);
+ refreshRuntimesViewer();
+ }));
runtimesViewer.addSelectionChangedListener(event -> {
if(runtimesViewer.getSelection() instanceof IStructuredSelection) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
index 82cae48..6eb7235 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
@@ -51,8 +51,7 @@
import org.eclipse.osgi.util.NLS;
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.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -493,33 +492,25 @@
errorCountLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button btnNewButton_1 = new Button(composite, SWT.NONE);
- btnNewButton_1.addSelectionListener(new SelectionAdapter() {
- @Override
- @SuppressWarnings("synthetic-access")
- public void widgetSelected(SelectionEvent e) {
- mappingConfiguration.clearSelectedProposals();
- ignore.clear();
- ignoreAtDefinition.clear();
- ignoreWorkspace.clear();
- treeViewer.refresh();
- getWizard().getContainer().updateButtons(); // needed to enable/disable Finish button
- updateErrorCount();
- }
- });
+ btnNewButton_1.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ mappingConfiguration.clearSelectedProposals();
+ ignore.clear();
+ ignoreAtDefinition.clear();
+ ignoreWorkspace.clear();
+ treeViewer.refresh();
+ getWizard().getContainer().updateButtons(); // needed to enable/disable Finish button
+ updateErrorCount();
+ }));
btnNewButton_1.setText(Messages.LifecycleMappingPage_deselectAllButton);
autoSelectButton = new Button(composite, SWT.NONE);
- autoSelectButton.addSelectionListener(new SelectionAdapter() {
- @Override
- @SuppressWarnings("synthetic-access")
- public void widgetSelected(SelectionEvent e) {
- resetDetails();
- ignore.clear();
- ignoreAtDefinition.clear();
- ignoreWorkspace.clear();
- discoverProposals();
- }
- });
+ autoSelectButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ resetDetails();
+ ignore.clear();
+ ignoreAtDefinition.clear();
+ ignoreWorkspace.clear();
+ discoverProposals();
+ }));
autoSelectButton.setText(Messages.LifecycleMappingPage_autoSelectButton);
// Provide a reasonable height for the details box
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenDependenciesWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenDependenciesWizardPage.java
index fba8293..b0bd58c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenDependenciesWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenDependenciesWizardPage.java
@@ -27,8 +27,7 @@
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardContainer;
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;
@@ -122,47 +121,40 @@
addDependencyButton.setLayoutData(gd_addDependencyButton);
addDependencyButton.setText(Messages.wizardProjectPageDependenciesAdd);
- addDependencyButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog
- .createSearchDependencyDialog(
- getShell(), //
- org.eclipse.m2e.core.ui.internal.Messages.MavenDependenciesWizardPage_searchDialog_title, null, null,
- false);
- if(dialog.open() == Window.OK) {
- Object result = dialog.getFirstResult();
- if(result instanceof IndexedArtifactFile) {
- Dependency dependency = ((IndexedArtifactFile) result).getDependency();
- dependency.setScope(dialog.getSelectedScope());
- dependencyViewer.add(dependency);
+ addDependencyButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchDependencyDialog(getShell(), //
+ org.eclipse.m2e.core.ui.internal.Messages.MavenDependenciesWizardPage_searchDialog_title, null, null, false);
+ if(dialog.open() == Window.OK) {
+ Object result = dialog.getFirstResult();
+ if(result instanceof IndexedArtifactFile) {
+ Dependency dependency = ((IndexedArtifactFile) result).getDependency();
+ dependency.setScope(dialog.getSelectedScope());
+ dependencyViewer.add(dependency);
+ notifyListeners();
+ } else if(result instanceof IndexedArtifact) {
+ // If we have an ArtifactInfo, we add the first FileInfo it contains
+ // which corresponds to the latest version of the artifact.
+ Set<IndexedArtifactFile> files = ((IndexedArtifact) result).getFiles();
+ if(files != null && !files.isEmpty()) {
+ dependencyViewer.add(files.iterator().next().getDependency());
notifyListeners();
- } else if(result instanceof IndexedArtifact) {
- // If we have an ArtifactInfo, we add the first FileInfo it contains
- // which corresponds to the latest version of the artifact.
- Set<IndexedArtifactFile> files = ((IndexedArtifact) result).getFiles();
- if(files != null && !files.isEmpty()) {
- dependencyViewer.add(files.iterator().next().getDependency());
- notifyListeners();
- }
}
}
}
- });
+ }));
final Button removeDependencyButton = new Button(composite, SWT.PUSH);
removeDependencyButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
removeDependencyButton.setText(Messages.wizardProjectPageDependenciesRemove);
removeDependencyButton.setEnabled(false);
- removeDependencyButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IStructuredSelection selection = (IStructuredSelection) dependencyViewer.getSelection();
- if(selection != null) {
- dependencyViewer.remove(selection.toArray());
- notifyListeners();
- }
+ removeDependencyButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ IStructuredSelection selection = (IStructuredSelection) dependencyViewer.getSelection();
+ if(selection != null) {
+ dependencyViewer.remove(selection.toArray());
+ notifyListeners();
}
- });
+ }));
dependencyViewer.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
index ab5d06a..4cdea81 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
@@ -55,6 +55,7 @@
import org.eclipse.swt.events.FocusEvent;
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -160,25 +161,23 @@
final Button browseButton = new Button(composite, SWT.NONE);
browseButton.setText(Messages.wizardImportPageBrowse);
browseButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
- dialog.setText(Messages.wizardImportPageSelectRootFolder);
- String path = rootDirectoryCombo.getText();
- if(path.length() == 0) {
- path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
- }
- dialog.setFilterPath(path);
+ browseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
+ dialog.setText(Messages.wizardImportPageSelectRootFolder);
+ String path = rootDirectoryCombo.getText();
+ if(path.length() == 0) {
+ path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
+ }
+ dialog.setFilterPath(path);
- String result = dialog.open();
- if(result != null) {
- rootDirectoryCombo.setText(result);
- if(rootDirectoryChanged()) {
- scanProjects();
- }
+ String result = dialog.open();
+ if(result != null) {
+ rootDirectoryCombo.setText(result);
+ if(rootDirectoryChanged()) {
+ scanProjects();
}
}
- });
+ }));
rootDirectoryCombo.addListener(SWT.Traverse, e -> {
if(e.keyCode == SWT.CR && rootDirectoryChanged()) {
@@ -300,90 +299,61 @@
projectTree.setMenu(menu);
MenuItem mntmSelectTree = new MenuItem(menu, SWT.NONE);
- mntmSelectTree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setProjectSubtreeChecked(true);
- }
- });
+ mntmSelectTree.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setProjectSubtreeChecked(true)));
mntmSelectTree.setText(Messages.MavenImportWizardPage_mntmSelectTree_text);
MenuItem mntmDeselectTree = new MenuItem(menu, SWT.NONE);
- mntmDeselectTree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setProjectSubtreeChecked(false);
- }
- });
+ mntmDeselectTree
+ .addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setProjectSubtreeChecked(false)));
mntmDeselectTree.setText(Messages.MavenImportWizardPage_mntmDeselectTree_text);
final Button selectAllButton = new Button(composite, SWT.NONE);
selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
selectAllButton.setText(Messages.wizardImportPageSelectAll);
- selectAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- projectTreeViewer.expandAll();
- setAllChecked(true);
- // projectTreeViewer.setSubtreeChecked(projectTreeViewer.getInput(), true);
- validate();
- }
- });
+ selectAllButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ projectTreeViewer.expandAll();
+ setAllChecked(true);
+ // projectTreeViewer.setSubtreeChecked(projectTreeViewer.getInput(), true);
+ validate();
+ }));
final Button deselectAllButton = new Button(composite, SWT.NONE);
deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
deselectAllButton.setText(Messages.wizardImportPageDeselectAll);
- deselectAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setAllChecked(false);
- // projectTreeViewer.setSubtreeChecked(projectTreeViewer.getInput(), false);
- setPageComplete(false);
- }
- });
+ deselectAllButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ setAllChecked(false);
+ // projectTreeViewer.setSubtreeChecked(projectTreeViewer.getInput(), false);
+ setPageComplete(false);
+ }));
btnSelectTree = new Button(composite, SWT.NONE);
btnSelectTree.setEnabled(false);
- btnSelectTree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setProjectSubtreeChecked(true);
- }
- });
+ btnSelectTree.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setProjectSubtreeChecked(true)));
btnSelectTree.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnSelectTree.setText(Messages.MavenImportWizardPage_btnSelectTree_text);
btnDeselectTree = new Button(composite, SWT.NONE);
btnDeselectTree.setEnabled(false);
- btnDeselectTree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setProjectSubtreeChecked(false);
- }
- });
+ btnDeselectTree.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setProjectSubtreeChecked(false)));
btnDeselectTree.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnDeselectTree.setText(Messages.MavenImportWizardPage_btnDeselectTree_text);
final Button refreshButton = new Button(composite, SWT.NONE);
refreshButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
refreshButton.setText(Messages.wizardImportPageRefresh);
- refreshButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- scanProjects();
- }
- });
+ refreshButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> scanProjects()));
createWorkingSet = new Button(composite, SWT.CHECK);
createWorkingSet.setText(Messages.MavenImportWizardPage_createWorkingSet);
createWorkingSet.setSelection(true);
createWorkingSet.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
- createWorkingSet.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean enabled = createWorkingSet.getSelection();
- workingSetName.setEnabled(enabled);
- if(enabled) {
- workingSetName.setFocus();
- }
+ createWorkingSet.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ boolean enabled = createWorkingSet.getSelection();
+ workingSetName.setEnabled(enabled);
+ if(enabled) {
+ workingSetName.setFocus();
}
- });
+ }));
workingSetName = new Combo(composite, SWT.BORDER);
GridData gd_workingSet = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java
index 2a55c8a..dcf1f95 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java
@@ -24,8 +24,7 @@
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -104,17 +103,15 @@
artifactFileNameButton.setLayoutData(new GridData());
artifactFileNameButton.setData("name", "externalPomFileButton"); //$NON-NLS-1$ //$NON-NLS-2$
artifactFileNameButton.setText(Messages.MavenInstallFileArtifactWizardPage_btnFilename);
- artifactFileNameButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(artifactFileNameButton.getShell());
- fileDialog.setText(Messages.MavenInstallFileArtifactWizardPage_file_title);
- fileDialog.setFileName(artifactFileNameText.getText());
- String name = fileDialog.open();
- if(name != null) {
- updateFileName(name);
- }
+ artifactFileNameButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ FileDialog fileDialog = new FileDialog(artifactFileNameButton.getShell());
+ fileDialog.setText(Messages.MavenInstallFileArtifactWizardPage_file_title);
+ fileDialog.setFileName(artifactFileNameText.getText());
+ String name = fileDialog.open();
+ if(name != null) {
+ updateFileName(name);
}
- });
+ }));
Label pomFileNameLabel = new Label(container, SWT.NONE);
pomFileNameLabel.setText(Messages.MavenInstallFileArtifactWizardPage_lblPom);
@@ -131,17 +128,15 @@
pomFileNameButton.setLayoutData(new GridData());
pomFileNameButton.setData("name", "externalPomFileButton"); //$NON-NLS-1$ //$NON-NLS-2$
pomFileNameButton.setText(Messages.MavenInstallFileArtifactWizardPage_btnPom);
- pomFileNameButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(pomFileNameButton.getShell());
- fileDialog.setText(Messages.MavenInstallFileArtifactWizardPage_file_title);
- fileDialog.setFileName(pomFileNameText.getText());
- String res = fileDialog.open();
- if(res != null) {
- updatePOMFileName(res);
- }
+ pomFileNameButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ FileDialog fileDialog = new FileDialog(pomFileNameButton.getShell());
+ fileDialog.setText(Messages.MavenInstallFileArtifactWizardPage_file_title);
+ fileDialog.setFileName(pomFileNameText.getText());
+ String res = fileDialog.open();
+ if(res != null) {
+ updatePOMFileName(res);
}
- });
+ }));
new Label(container, SWT.NONE);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenLocationComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenLocationComponent.java
index 9940f4d..006c768 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenLocationComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenLocationComponent.java
@@ -19,8 +19,7 @@
import org.eclipse.core.runtime.Platform;
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;
import org.eclipse.swt.widgets.Button;
@@ -86,8 +85,7 @@
inWorkspaceButton = new Button(locationGroup, SWT.RADIO);
inWorkspaceButton.setText(Messages.locationComponentInWorkspace);
inWorkspaceButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
- inWorkspaceButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ inWorkspaceButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
boolean isEnabled = !inWorkspaceButton.getSelection();
locationLabel.setEnabled(isEnabled);
locationCombo.setEnabled(isEnabled);
@@ -96,7 +94,7 @@
modifyingListener.modifyText(null);
}
}
- });
+ ));
// second radio button
inExternalLocationButton = new Button(locationGroup, SWT.RADIO);
@@ -119,23 +117,21 @@
gridData = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
locationBrowseButton.setLayoutData(gridData);
- locationBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setText(Messages.locationComponentSelectLocation);
+ locationBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setText(Messages.locationComponentSelectLocation);
- String path = locationCombo.getText();
- if(path.length() == 0) {
- path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
- }
- dialog.setFilterPath(path);
-
- String selectedDir = dialog.open();
- if(selectedDir != null) {
- locationCombo.setText(selectedDir.trim());
- }
+ String path = locationCombo.getText();
+ if(path.length() == 0) {
+ path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
}
- });
+ dialog.setFilterPath(path);
+
+ String selectedDir = dialog.open();
+ if(selectedDir != null) {
+ locationCombo.setText(selectedDir.trim());
+ }
+ }));
inWorkspaceButton.setSelection(true);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java
index 32278ff..afea068 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java
@@ -41,8 +41,7 @@
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
-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;
import org.eclipse.ui.INewWizard;
@@ -118,13 +117,11 @@
parametersPage.setArtifactIdEnabled(false);
- parentPage.addArchetypeSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean isArchetype = !parentPage.isSimpleProject();
- archetypePage.setUsed(isArchetype);
- parametersPage.setUsed(isArchetype);
- }
- });
+ parentPage.addArchetypeSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ boolean isArchetype = !parentPage.isSimpleProject();
+ archetypePage.setUsed(isArchetype);
+ parametersPage.setUsed(isArchetype);
+ }));
parentPage.addModuleNameListener(e -> {
parametersPage.setProjectName(parentPage.getModuleName());
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
index ff0d6eb..e1f92b9 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
@@ -30,8 +30,6 @@
import org.eclipse.jface.wizard.IWizardPage;
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;
@@ -104,11 +102,7 @@
simpleProject.setText(Messages.wizardProjectPageProjectSimpleProject);
simpleProject.setData("name", "simpleProjectButton"); //$NON-NLS-1$ //$NON-NLS-2$
simpleProject.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
- simpleProject.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- validate();
- }
- });
+ simpleProject.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> validate()));
Label nameLabel = new Label(container, SWT.NONE);
GridData gd_nameLabel = new GridData();
@@ -132,15 +126,13 @@
Button browseButton = new Button(container, SWT.NONE);
browseButton.setText(Messages.wizardModulePageParentBrowse);
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- MavenProjectSelectionDialog dialog = new MavenProjectSelectionDialog(getShell());
- if(dialog.open() == Window.OK) {
- setParent(dialog.getFirstResult());
- validate();
- }
+ browseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ MavenProjectSelectionDialog dialog = new MavenProjectSelectionDialog(getShell());
+ if(dialog.open() == Window.OK) {
+ setParent(dialog.getFirstResult());
+ validate();
}
- });
+ }));
this.workingSetGroup = new WorkingSetGroup(container, workingSets, getShell());
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenParentComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenParentComponent.java
index 2ce6f36..f02e050 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenParentComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenParentComponent.java
@@ -15,8 +15,6 @@
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;
@@ -122,11 +120,7 @@
parentClearButton = new Button(buttonPanel, SWT.NONE);
parentClearButton.setText(Messages.wizardProjectPageArtifactParentClear);
parentClearButton.setData("name", "parentClearButton"); //$NON-NLS-1$ //$NON-NLS-2$
- parentClearButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setValues("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- });
+ parentClearButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setValues("", "", "")));
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java
index 95e9279..b15ab12 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java
@@ -31,8 +31,7 @@
import org.eclipse.jface.wizard.IWizardPage;
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.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -105,11 +104,7 @@
simpleProject = new Button(container, SWT.CHECK);
simpleProject.setText(Messages.wizardProjectPageProjectSimpleProject);
simpleProject.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
- simpleProject.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- validate();
- }
- });
+ simpleProject.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> validate()));
Label label = new Label(container, SWT.NONE);
GridData labelData = new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1);
@@ -138,15 +133,13 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- simpleProject.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean isSimpleproject = simpleProject.getSelection();
- archetypePage.setUsed(!isSimpleproject);
- parametersPage.setUsed(!isSimpleproject);
- artifactPage.setUsed(isSimpleproject);
- getContainer().updateButtons();
- }
- });
+ simpleProject.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ boolean isSimpleproject = simpleProject.getSelection();
+ archetypePage.setUsed(!isSimpleproject);
+ parametersPage.setUsed(!isSimpleproject);
+ artifactPage.setUsed(isSimpleproject);
+ getContainer().updateButtons();
+ }));
archetypePage.addArchetypeSelectionListener(selectionchangedevent -> {
parametersPage.setArchetype(archetypePage.getArchetype());
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
index 663854d..99cfefd 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
@@ -58,7 +58,6 @@
import org.eclipse.swt.events.KeyEvent;
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.graphics.Image;
@@ -284,38 +283,36 @@
Button configureButton = new Button(catalogsComposite, SWT.NONE);
configureButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
configureButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_btnConfigure);
- configureButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ configureButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
- Collection<ArchetypeCatalogFactory> oldCatalogs = archetypeManager.getActiveArchetypeCatalogs();
+ Collection<ArchetypeCatalogFactory> oldCatalogs = archetypeManager.getActiveArchetypeCatalogs();
- PreferencesUtil.createPreferenceDialogOn(getShell(),
- "org.eclipse.m2e.core.preferences.MavenArchetypesPreferencePage", null, null).open(); //$NON-NLS-1$
+ PreferencesUtil.createPreferenceDialogOn(getShell(),
+ "org.eclipse.m2e.core.preferences.MavenArchetypesPreferencePage", null, null).open(); //$NON-NLS-1$
- Collection<ArchetypeCatalogFactory> newCatalogs = archetypeManager.getActiveArchetypeCatalogs();
+ Collection<ArchetypeCatalogFactory> newCatalogs = archetypeManager.getActiveArchetypeCatalogs();
- //Deselect removed catalog if needed
- if(catalogFactory != null && !newCatalogs.contains(catalogFactory)) {
- catalogFactory = null;
- }
-
- //Select 1st new catalog
- ArchetypeCatalogFactory selectedCatalog = catalogFactory;
- for(ArchetypeCatalogFactory newCatalog : newCatalogs) {
- if(!oldCatalogs.contains(newCatalog)) {
- selectedCatalog = newCatalog;
- break;
- }
- }
-
- ArrayList allCatalogs = new ArrayList(newCatalogs);
- allCatalogs.add(0, ALL_CATALOGS);
- catalogsComboViewer.setInput(allCatalogs);
- catalogsComboViewer
- .setSelection(new StructuredSelection(selectedCatalog == null ? ALL_CATALOGS : selectedCatalog));
-
+ //Deselect removed catalog if needed
+ if(catalogFactory != null && !newCatalogs.contains(catalogFactory)) {
+ catalogFactory = null;
}
- });
+
+ //Select 1st new catalog
+ ArchetypeCatalogFactory selectedCatalog = catalogFactory;
+ for(ArchetypeCatalogFactory newCatalog : newCatalogs) {
+ if(!oldCatalogs.contains(newCatalog)) {
+ selectedCatalog = newCatalog;
+ break;
+ }
+ }
+
+ ArrayList allCatalogs1 = new ArrayList(newCatalogs);
+ allCatalogs1.add(0, ALL_CATALOGS);
+ catalogsComboViewer.setInput(allCatalogs1);
+ catalogsComboViewer
+ .setSelection(new StructuredSelection(selectedCatalog == null ? ALL_CATALOGS : selectedCatalog));
+
+ }));
Label filterLabel = new Label(parent, SWT.NONE);
filterLabel.setLayoutData(new GridData());
@@ -346,11 +343,9 @@
clearToolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE));
clearToolItem
.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE_DISABLED));
- clearToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- filterText.setText(""); //$NON-NLS-1$
- }
- });
+ clearToolItem.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ filterText.setText(""); //$NON-NLS-1$
+ }));
filterText.addModifyListener(e -> clearToolItem.setEnabled(filterText.getText().length() > 0));
@@ -505,19 +500,17 @@
buttonData.horizontalIndent = 35;
addArchetypeButton.setLayoutData(buttonData);
- addArchetypeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- CustomArchetypeDialog dialog = new CustomArchetypeDialog(getShell(),
- org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_add_title);
- if(dialog.open() == Window.OK) {
- String archetypeGroupId = dialog.getArchetypeGroupId();
- String archetypeArtifactId = dialog.getArchetypeArtifactId();
- String archetypeVersion = dialog.getArchetypeVersion();
- String repositoryUrl = dialog.getRepositoryUrl();
- downloadArchetype(archetypeGroupId, archetypeArtifactId, archetypeVersion, repositoryUrl);
- }
+ addArchetypeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ CustomArchetypeDialog dialog = new CustomArchetypeDialog(getShell(),
+ org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_add_title);
+ if(dialog.open() == Window.OK) {
+ String archetypeGroupId = dialog.getArchetypeGroupId();
+ String archetypeArtifactId = dialog.getArchetypeArtifactId();
+ String archetypeVersion = dialog.getArchetypeVersion();
+ String repositoryUrl = dialog.getRepositoryUrl();
+ downloadArchetype(archetypeGroupId, archetypeArtifactId, archetypeVersion, repositoryUrl);
}
- });
+ }));
}
protected IWizardContainer getContainer() {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
index fa08577..9d217fc 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
@@ -40,8 +40,7 @@
import org.eclipse.jface.wizard.IWizardPage;
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;
@@ -252,32 +251,26 @@
Button addButton = new Button(composite, SWT.NONE);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_btnAdd);
- addButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- TableItem item = addTableItem("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$
- propertiesTable.setFocus();
- propertiesViewer.editElement(item, KEY_INDEX);
- propertiesViewer.setSelection(new StructuredSelection(item.getData()));
- }
- });
+ addButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ TableItem item = addTableItem("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$
+ propertiesTable.setFocus();
+ propertiesViewer.editElement(item, KEY_INDEX);
+ propertiesViewer.setSelection(new StructuredSelection(item.getData()));
+ }));
removeButton = new Button(composite, SWT.NONE);
removeButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
removeButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_btnRemove);
removeButton.setEnabled(propertiesTable.getSelectionCount() > 0);
- removeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- propertiesTable.remove(propertiesTable.getSelectionIndices());
- removeButton.setEnabled(propertiesTable.getSelectionCount() > 0);
- validate();
- }
- });
+ removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ propertiesTable.remove(propertiesTable.getSelectionIndices());
+ removeButton.setEnabled(propertiesTable.getSelectionCount() > 0);
+ validate();
+ }));
- propertiesTable.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeButton.setEnabled(propertiesTable.getSelectionCount() > 0);
- }
- });
+ propertiesTable.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> removeButton.setEnabled(propertiesTable.getSelectionCount() > 0)
+ ));
}
/**
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArtifactPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArtifactPage.java
index 7d0c1dd..32c771c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArtifactPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArtifactPage.java
@@ -20,8 +20,7 @@
import org.eclipse.jface.window.Window;
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;
import org.eclipse.swt.widgets.Composite;
@@ -143,20 +142,18 @@
parentComponent.setWidthGroup(widthGroup);
parentComponent.addModifyListener(modifyingListener);
- parentComponent.addBrowseButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchParentDialog(getShell(),
- org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArtifactPage_searchDialog_title, null, null);
+ parentComponent.addBrowseButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchParentDialog(getShell(),
+ org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArtifactPage_searchDialog_title, null, null);
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile indexedArtifactFile = (IndexedArtifactFile) dialog.getFirstResult();
- if(indexedArtifactFile != null) {
- parentComponent.setValues(indexedArtifactFile.group, indexedArtifactFile.artifact,
- indexedArtifactFile.version);
- }
+ if(dialog.open() == Window.OK) {
+ IndexedArtifactFile indexedArtifactFile = (IndexedArtifactFile) dialog.getFirstResult();
+ if(indexedArtifactFile != null) {
+ parentComponent.setValues(indexedArtifactFile.group, indexedArtifactFile.artifact,
+ indexedArtifactFile.version);
}
}
- });
+ }));
createAdvancedSettings(container, new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
resolverConfigurationComponent.setModifyListener(e -> validate());
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardLocationPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardLocationPage.java
index 6b292a9..e5fd6e2 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardLocationPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardLocationPage.java
@@ -22,8 +22,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
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;
@@ -104,13 +103,11 @@
useDefaultWorkspaceLocationButton.setLayoutData(useDefaultWorkspaceLocationButtonData);
useDefaultWorkspaceLocationButton
.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardLocationPage_btnUserDefault);
- useDefaultWorkspaceLocationButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean inWorkspace = isInWorkspace();
- locationLabel.setEnabled(!inWorkspace);
- locationCombo.setEnabled(!inWorkspace);
- }
- });
+ useDefaultWorkspaceLocationButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ boolean inWorkspace = isInWorkspace();
+ locationLabel.setEnabled(!inWorkspace);
+ locationCombo.setEnabled(!inWorkspace);
+ }));
useDefaultWorkspaceLocationButton.setSelection(true);
locationLabel = new Label(container, SWT.NONE);
@@ -131,25 +128,23 @@
GridData locationBrowseButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false);
locationBrowseButton.setLayoutData(locationBrowseButtonData);
locationBrowseButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardLocationPage_btnLocation);
- locationBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardLocationPage_dialog_location);
+ locationBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardLocationPage_dialog_location);
- String path = locationCombo.getText();
- if(path.length() == 0) {
- path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
- }
- dialog.setFilterPath(path);
-
- String selectedDir = dialog.open();
- if(selectedDir != null) {
- locationCombo.setText(selectedDir);
- useDefaultWorkspaceLocationButton.setSelection(false);
- validate();
- }
+ String path = locationCombo.getText();
+ if(path.length() == 0) {
+ path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
}
- });
+ dialog.setFilterPath(path);
+
+ String selectedDir = dialog.open();
+ if(selectedDir != null) {
+ locationCombo.setText(selectedDir);
+ useDefaultWorkspaceLocationButton.setSelection(false);
+ validate();
+ }
+ }));
this.workingSetGroup = new WorkingSetGroup(container, workingSets, getShell());
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
index 8ef56bc..92c6abe 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
@@ -15,8 +15,7 @@
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.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -90,11 +89,8 @@
resolveWorkspaceProjects = new Button(advancedComposite, SWT.CHECK);
resolveWorkspaceProjects.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
resolveWorkspaceProjects.setText(Messages.resolverConfigurationResolveWorkspaceProjects);
- resolveWorkspaceProjects.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- resolverConfiguration.setResolveWorkspaceProjects(resolveWorkspaceProjects.getSelection());
- }
- });
+ resolveWorkspaceProjects.addSelectionListener(SelectionListener.widgetSelectedAdapter(
+ e -> resolverConfiguration.setResolveWorkspaceProjects(resolveWorkspaceProjects.getSelection())));
Label profilesLabel = new Label(advancedComposite, SWT.NONE);
profilesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/preferences/DiscoveryPreferencePage.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/preferences/DiscoveryPreferencePage.java
index 10dd0dc..b2cb3f6 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/preferences/DiscoveryPreferencePage.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/preferences/DiscoveryPreferencePage.java
@@ -15,8 +15,7 @@
import org.eclipse.jface.preference.PreferencePage;
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;
@@ -58,12 +57,8 @@
catalogUrl.setText(MavenDiscovery.PATH);
Button btnOpenCatalog = new Button(composite, SWT.NONE);
- btnOpenCatalog.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- MavenDiscovery.launchWizard(workbench.getModalDialogShellProvider().getShell());
- }
- });
+ btnOpenCatalog.addSelectionListener(SelectionListener
+ .widgetSelectedAdapter(e -> MavenDiscovery.launchWizard(workbench.getModalDialogShellProvider().getShell())));
btnOpenCatalog.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
btnOpenCatalog.setSize(92, 29);
btnOpenCatalog.setText(Messages.DiscoveryPreferencePage_openCatalog);
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
index 00b2f1f..28b5b04 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
@@ -43,10 +43,8 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-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.Font;
import org.eclipse.swt.graphics.Image;
@@ -249,13 +247,10 @@
//in some cases (managed version comes from imported dependencies) we don't have the location and have nowhere to jump)
if(PomHyperlinkDetector.canCreateHyperLink(man)) {
Link link = createHyperlink(comp);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- dispose();
- PomHyperlinkDetector.createHyperlink(man).open();
- }
- });
+ link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ dispose();
+ PomHyperlinkDetector.createHyperlink(man).open();
+ }));
}
}
@@ -264,13 +259,10 @@
Composite tooltipComposite = createTooltipComposite(composite, PomTextHover.getLabelForRegion(expr));
if(PomHyperlinkDetector.canCreateHyperLink(expr)) {
Link link = createHyperlink(tooltipComposite);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- dispose();
- PomHyperlinkDetector.createHyperlink(expr).open();
- }
- });
+ link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ dispose();
+ PomHyperlinkDetector.createHyperlink(expr).open();
+ }));
}
}
if(region.getRegions().indexOf(reg) < region.getRegions().size() - 1) {
@@ -396,13 +388,10 @@
data2.horizontalIndent = 18;
link.setLayoutData(data2);
link.setText(Messages.MarkerHoverControl_openParentDefinition);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- PomHyperlinkDetector.createHyperlink(annotation).open();
- dispose();
- }
- });
+ link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ PomHyperlinkDetector.createHyperlink(annotation).open();
+ dispose();
+ }));
}
}
@@ -502,20 +491,11 @@
if(image != null) {
proposalImage.setImage(image);
- proposalImage.addMouseListener(new MouseListener() {
-
- public void mouseDoubleClick(MouseEvent e) {
+ proposalImage.addMouseListener(MouseListener.mouseUpAdapter(e -> {
+ if(e.button == 1) {
+ apply(proposal, mark, region.textViewer, region.textOffset);
}
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- if(e.button == 1) {
- apply(proposal, mark, region.textViewer, region.textOffset);
- }
- }
- });
+ }));
}
Link proposalLink = new Link(parent, SWT.WRAP);
@@ -528,11 +508,8 @@
}
proposalLink.setText("<a>" + linkText + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
proposalLink.setLayoutData(layoutData);
- proposalLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- apply(proposal, mark, region.textViewer, region.textOffset);
- }
- });
+ proposalLink.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> apply(proposal, mark, region.textViewer, region.textOffset)));
return proposalLink;
}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
index d09d26b..e620415 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
@@ -29,8 +29,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-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.widgets.Composite;
@@ -93,18 +92,15 @@
handleDoubleClick();
}
});
- licensesTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- ISelection selection = licensesViewer.getSelection();
- if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
- license = (SPDXLicense) ((IStructuredSelection) selection).getFirstElement();
- } else {
- license = null;
- }
- updateStatus();
+ licensesTable.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ ISelection selection = licensesViewer.getSelection();
+ if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ license = (SPDXLicense) ((IStructuredSelection) selection).getFirstElement();
+ } else {
+ license = null;
}
- });
+ updateStatus();
+ }));
GridData gd_licensesTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_licensesTable.heightHint = 400;
licensesTable.setLayoutData(gd_licensesTable);
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index 7d1859f..731aeed 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -63,8 +63,6 @@
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
-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;
@@ -195,102 +193,95 @@
dependenciesEditor.setCellLabelProvider(new DelegatingStyledCellLabelProvider(dependencyLabelProvider));
dependenciesEditor.setContentProvider(dependenciesContentProvider);
- dependenciesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- final List<Object> dependencyList = dependenciesEditor.getSelection();
- try {
- editorPage.performEditOperation(document -> {
- Element deps = findChild(document.getDocumentElement(), DEPENDENCIES);
- if(deps == null) {
- //TODO log
- return;
- }
- for(Object dependency : dependencyList) {
- if(dependency instanceof Dependency) {
- Element dep = findChild(deps, DEPENDENCY, childEquals(GROUP_ID, ((Dependency) dependency).groupId),
- childEquals(ARTIFACT_ID, ((Dependency) dependency).artifactId));
- removeChild(deps, dep);
- }
- }
- removeIfNoChildElement(deps);
- }, log, "error removing dependencies");
- } finally {
- setDependenciesInput();
- }
- }
- });
-
- dependenciesEditor.setPropertiesListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- Object selection = dependenciesEditor.getSelection().get(0);
- if(selection instanceof Dependency) {
- Dependency dependency = (Dependency) selection;
- EditDependencyDialog d = new EditDependencyDialog(getShell(), false, editorPage.getProject(),
- editorPage.getPomEditor().getMavenProject());
- d.setDependency(toApacheDependency(dependency));
- if(d.open() == Window.OK) {
- try {
- editorPage.performEditOperation(d.getEditOperation(), log, "Error updating dependency");
- } finally {
- setDependenciesInput();
- dependenciesEditor.setSelection(Collections.singletonList((Object) dependency));
+ dependenciesEditor.setRemoveButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ final List<Object> dependencyList = dependenciesEditor.getSelection();
+ try {
+ editorPage.performEditOperation(document -> {
+ Element deps = findChild(document.getDocumentElement(), DEPENDENCIES);
+ if(deps == null) {
+ //TODO log
+ return;
+ }
+ for(Object dependency : dependencyList) {
+ if(dependency instanceof Dependency) {
+ Element dep = findChild(deps, DEPENDENCY, childEquals(GROUP_ID, ((Dependency) dependency).groupId),
+ childEquals(ARTIFACT_ID, ((Dependency) dependency).artifactId));
+ removeChild(deps, dep);
}
}
- } else if(selection instanceof org.apache.maven.model.Dependency) {
- /*
- * TODO: Support editing or displaying of inherited/managed dependencies.
- */
- }
+ removeIfNoChildElement(deps);
+ }, log, "error removing dependencies");
+ } finally {
+ setDependenciesInput();
}
+ }));
- });
+ dependenciesEditor.setPropertiesListener(SelectionListener.widgetSelectedAdapter(e -> {
+ Object selection = dependenciesEditor.getSelection().get(0);
+ if(selection instanceof Dependency) {
+ Dependency dependency = (Dependency) selection;
+ EditDependencyDialog d = new EditDependencyDialog(getShell(), false, editorPage.getProject(),
+ editorPage.getPomEditor().getMavenProject());
+ d.setDependency(toApacheDependency(dependency));
+ if(d.open() == Window.OK) {
+ try {
+ editorPage.performEditOperation(d.getEditOperation(), log, "Error updating dependency");
+ } finally {
+ setDependenciesInput();
+ dependenciesEditor.setSelection(Collections.singletonList((Object) dependency));
+ }
+ }
+ } else if(selection instanceof org.apache.maven.model.Dependency) {
+ /*
+ * TODO: Support editing or displaying of inherited/managed dependencies.
+ */
+ }
+ }
+
+ ));
dependenciesSection.setClient(dependenciesEditor);
toolkit.adapt(dependenciesEditor);
toolkit.paintBordersFor(dependenciesEditor);
- dependenciesEditor.setManageButtonListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- openManageDependenciesDialog();
- } catch(InvocationTargetException e1) {
- MavenEditorPlugin.getDefault().getLog()
- .log(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, "Error: ", e1)); //$NON-NLS-1$
- } catch(InterruptedException e1) {
- MavenEditorPlugin.getDefault().getLog()
- .log(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, "Error: ", e1)); //$NON-NLS-1$
- }
+ dependenciesEditor.setManageButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ try {
+ openManageDependenciesDialog();
+ } catch(InvocationTargetException e1) {
+ MavenEditorPlugin.getDefault().getLog()
+ .log(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, "Error: ", e1)); //$NON-NLS-1$
+ } catch(InterruptedException e1) {
+ MavenEditorPlugin.getDefault().getLog()
+ .log(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, "Error: ", e1)); //$NON-NLS-1$
}
- });
+ }));
- dependenciesEditor.setAddButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
- getShell(), Messages.DependenciesComposite_action_selectDependency,
- editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), false);
+ dependenciesEditor.setAddButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
+ getShell(), Messages.DependenciesComposite_action_selectDependency,
+ editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), false);
- if(addDepDialog.open() == Window.OK) {
- final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
- final String selectedScope = addDepDialog.getSelectedScope();
- try {
- editorPage.performEditOperation(document -> {
- Element depsEl = getChild(document.getDocumentElement(), DEPENDENCIES);
- PomHelper.addOrUpdateDependency(depsEl, dep.group, dep.artifact,
- isManaged(dep.group, dep.artifact, dep.version) ? null : dep.version, dep.type, selectedScope,
- dep.classifier);
- }, log, "errror adding dependency");
- } finally {
- setDependenciesInput();
- List<Dependency> deps = getDependencies();
- if(deps.size() > 0) {
- dependenciesEditor.setSelection(Collections.<Object> singletonList(deps.get(deps.size() - 1)));
- }
+ if(addDepDialog.open() == Window.OK) {
+ final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
+ final String selectedScope = addDepDialog.getSelectedScope();
+ try {
+ editorPage.performEditOperation(document -> {
+ Element depsEl = getChild(document.getDocumentElement(), DEPENDENCIES);
+ PomHelper.addOrUpdateDependency(depsEl, dep.group, dep.artifact,
+ isManaged(dep.group, dep.artifact, dep.version) ? null : dep.version, dep.type, selectedScope,
+ dep.classifier);
+ }, log, "errror adding dependency");
+ } finally {
+ setDependenciesInput();
+ List<Dependency> deps = getDependencies();
+ if(deps.size() > 0) {
+ dependenciesEditor.setSelection(Collections.<Object> singletonList(deps.get(deps.size() - 1)));
}
}
}
+ }
- });
+ ));
ToolBarManager modulesToolBarManager = new ToolBarManager(SWT.FLAT);
@@ -401,48 +392,44 @@
dependencyManagementEditor.setLabelProvider(dependencyManagementLabelProvider);
dependencyManagementSection.setClient(dependencyManagementEditor);
- dependencyManagementEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- final List<Dependency> dependencyList = dependencyManagementEditor.getSelection();
+ dependencyManagementEditor.setRemoveButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ final List<Dependency> dependencyList = dependencyManagementEditor.getSelection();
+ try {
+ editorPage.performEditOperation(document -> {
+ Element deps = findChild(findChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT), DEPENDENCIES);
+ if(deps == null) {
+ //TODO log
+ return;
+ }
+ for(Dependency dependency : dependencyList) {
+ Element dep = findChild(deps, DEPENDENCY, childEquals(GROUP_ID, dependency.groupId),
+ childEquals(ARTIFACT_ID, dependency.artifactId));
+ removeChild(deps, dep);
+ }
+ removeIfNoChildElement(deps);
+ }, log, "error removing managed dependencies");
+ } finally {
+ setDependencyManagementInput();
+ dependenciesEditor.refresh();
+ }
+ }));
+
+ dependencyManagementEditor.setPropertiesListener(SelectionListener.widgetSelectedAdapter(e -> {
+ Dependency dependency = dependencyManagementEditor.getSelection().get(0);
+ EditDependencyDialog d = new EditDependencyDialog(getShell(), true, editorPage.getProject(),
+ editorPage.getPomEditor().getMavenProject());
+ d.setDependency(toApacheDependency(dependency));
+ if(d.open() == Window.OK) {
try {
- editorPage.performEditOperation(document -> {
- Element deps = findChild(findChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT), DEPENDENCIES);
- if(deps == null) {
- //TODO log
- return;
- }
- for(Dependency dependency : dependencyList) {
- Element dep = findChild(deps, DEPENDENCY, childEquals(GROUP_ID, dependency.groupId),
- childEquals(ARTIFACT_ID, dependency.artifactId));
- removeChild(deps, dep);
- }
- removeIfNoChildElement(deps);
- }, log, "error removing managed dependencies");
+ editorPage.performEditOperation(d.getEditOperation(), log, "Error updating dependency");
} finally {
setDependencyManagementInput();
+ dependencyManagementEditor.setSelection(Collections.singletonList(dependency));
+ //refresh this one to update decorations..
dependenciesEditor.refresh();
}
}
- });
-
- dependencyManagementEditor.setPropertiesListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- Dependency dependency = dependencyManagementEditor.getSelection().get(0);
- EditDependencyDialog d = new EditDependencyDialog(getShell(), true, editorPage.getProject(),
- editorPage.getPomEditor().getMavenProject());
- d.setDependency(toApacheDependency(dependency));
- if(d.open() == Window.OK) {
- try {
- editorPage.performEditOperation(d.getEditOperation(), log, "Error updating dependency");
- } finally {
- setDependencyManagementInput();
- dependencyManagementEditor.setSelection(Collections.singletonList(dependency));
- //refresh this one to update decorations..
- dependenciesEditor.refresh();
- }
- }
- }
- });
+ }));
dependencyManagementEditor.addSelectionListener(event -> {
List<Dependency> selection = dependencyManagementEditor.getSelection();
@@ -455,34 +442,32 @@
toolkit.adapt(dependencyManagementEditor);
toolkit.paintBordersFor(dependencyManagementEditor);
- dependencyManagementEditor.setAddButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
- getShell(), Messages.DependenciesComposite_action_selectDependency,
- editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), true);
- if(addDepDialog.open() == Window.OK) {
- final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
- final String selectedScope = addDepDialog.getSelectedScope();
- try {
- editorPage.performEditOperation(document -> {
- Element depsEl = getChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT, DEPENDENCIES);
- PomHelper.addOrUpdateDependency(depsEl, dep.group, dep.artifact, dep.version, dep.type, selectedScope,
- dep.classifier);
- }, log, "errror adding dependency");
- } finally {
- setDependencyManagementInput();
- List<Dependency> dlist = getManagedDependencies();
- if(dlist.size() > 0) {
- dependencyManagementEditor
- .setSelection(Collections.<Dependency> singletonList(dlist.get(dlist.size() - 1)));
- }
- //refresh this one to update decorations..
- dependenciesEditor.refresh();
+ dependencyManagementEditor.setAddButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
+ getShell(), Messages.DependenciesComposite_action_selectDependency,
+ editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), true);
+ if(addDepDialog.open() == Window.OK) {
+ final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
+ final String selectedScope = addDepDialog.getSelectedScope();
+ try {
+ editorPage.performEditOperation(document -> {
+ Element depsEl = getChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT, DEPENDENCIES);
+ PomHelper.addOrUpdateDependency(depsEl, dep.group, dep.artifact, dep.version, dep.type, selectedScope,
+ dep.classifier);
+ }, log, "errror adding dependency");
+ } finally {
+ setDependencyManagementInput();
+ List<Dependency> dlist = getManagedDependencies();
+ if(dlist.size() > 0) {
+ dependencyManagementEditor
+ .setSelection(Collections.<Dependency> singletonList(dlist.get(dlist.size() - 1)));
}
-
+ //refresh this one to update decorations..
+ dependenciesEditor.refresh();
}
+
}
- });
+ }));
ToolBarManager modulesToolBarManager = new ToolBarManager(SWT.FLAT);
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java
index 1c709a3..64a21ae 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java
@@ -35,8 +35,7 @@
import org.eclipse.jface.viewers.TableViewerEditor;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -91,15 +90,14 @@
column = new TableViewerColumn(viewer, SWT.LEFT);
//mkleint: TODO this is sort of suboptimal, as the horizontal scrollbar gets never shown and we hide information
// if the viewable are is not enough. No idea what to replace it with just yet.
- table.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- column.getColumn().setWidth(table.getClientArea().width);
- }
- });
+ table.addControlListener(ControlListener.controlResizedAdapter(e -> {
+ column.getColumn().setWidth(table.getClientArea().width);
+ }));
createButtons(includeSearch);
int vSpan = buttons.size();
+
GridData viewerData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, vSpan);
viewerData.widthHint = 100;
viewerData.heightHint = includeSearch ? 125 : 50;
@@ -107,7 +105,9 @@
table.setLayoutData(viewerData);
viewer.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.TRUE);
- viewer.addSelectionChangedListener(event -> viewerSelectionChanged());
+ viewer.addSelectionChangedListener(event ->
+
+ viewerSelectionChanged());
toolkit.paintBordersFor(this);
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/MavenModuleSelectionDialog.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/MavenModuleSelectionDialog.java
index 5bb53c9..fdcc52c 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/MavenModuleSelectionDialog.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/MavenModuleSelectionDialog.java
@@ -9,8 +9,7 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
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.widgets.Button;
@@ -42,29 +41,22 @@
final TreeViewer viewer = getViewer();
viewer.setLabelProvider(new ProjectLabelProvider());
- viewer.getTree().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(e.detail == SWT.CHECK) {
- TreeItem item = (TreeItem) e.item;
- Object data = item.getData();
- if(item.getChecked() && data instanceof IResource && knownModules.contains(((IResource) data).getLocation())) {
- item.setChecked(false);
- }
+ viewer.getTree().addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ if(e.detail == SWT.CHECK) {
+ TreeItem item = (TreeItem) e.item;
+ Object data = item.getData();
+ if(item.getChecked() && data instanceof IResource && knownModules.contains(((IResource) data).getLocation())) {
+ item.setChecked(false);
}
}
- });
+ }));
viewer.getTree().setFocus();
final Button checkbox = new Button((Composite) control, SWT.CHECK);
checkbox.setSelection(false);
checkbox.setText(Messages.OverviewPage_updateModulePoms);
- checkbox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- pomUpdateRequired = checkbox.getSelection();
- }
- });
+ checkbox.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> pomUpdateRequired = checkbox.getSelection()));
return control;
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependenciesPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependenciesPage.java
index f4c8158..b3d5ecb 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependenciesPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependenciesPage.java
@@ -17,8 +17,7 @@
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
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.Link;
@@ -73,11 +72,8 @@
Link link = new Link(managedForm.getForm().getBody(), SWT.NONE);
toolkit.adapt(link, true, true);
link.setText(Messages.DependenciesPage_exclusions_link);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- pomEditor.setActivePage(IMavenConstants.PLUGIN_ID + ".pom.dependencyTree"); //$NON-NLS-1$
- }
- });
+ link.addSelectionListener(SelectionListener
+ .widgetSelectedAdapter(e -> pomEditor.setActivePage(IMavenConstants.PLUGIN_ID + ".pom.dependencyTree")));
searchControl = new SearchControl(Messages.DependenciesPage_find, managedForm);
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
index 2d63e3c..11415ac 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
@@ -58,8 +58,7 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
-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;
import org.eclipse.swt.widgets.Control;
@@ -432,11 +431,8 @@
decoration.setImage(fieldDecoration.getImage());
decoration.setShowHover(true);
decoration.hide(); //hide and wait for the value to be set.
- decoration.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- decoration.showHoverText(decoration.getDescriptionText());
- }
- });
+ decoration.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> decoration.showHoverText(decoration.getDescriptionText())));
ModifyListener listener = e -> {
String text = control instanceof Text ? ((Text) control).getText() : ((CCombo) control).getText();
if(text.indexOf("${") != -1 && text.indexOf("}") != -1) {
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
index a721a7c..9b39c11 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
@@ -83,8 +83,7 @@
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.Transfer;
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;
import org.eclipse.swt.layout.GridLayout;
@@ -608,82 +607,75 @@
}.schedule();
});
- modulesEditor.setAddButtonListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- final Set<Object> moduleContainers = new HashSet<Object>();
- final List<String> modules = new ArrayList<String>();
- try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
- Element modsEl = findChild(document.getDocumentElement(), MODULES);
- for(Element el : findChilds(modsEl, MODULE)) {
- String m = getTextValue(el);
- if(m != null) {
- modules.add(m);
+ modulesEditor.setAddButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ final Set<Object> moduleContainers = new HashSet<Object>();
+ final List<String> modules = new ArrayList<String>();
+ try {
+ performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
+ Element modsEl = findChild(document.getDocumentElement(), MODULES);
+ for(Element el : findChilds(modsEl, MODULE)) {
+ String m = getTextValue(el);
+ if(m != null) {
+ modules.add(m);
+ }
+ }
+ }, true));
+ } catch(Exception e1) {
+ LOG.error("Cannot load modules", e1);
+ }
+
+ for(String module : modules) {
+ IMavenProjectFacade facade = findModuleProject(module);
+ if(facade != null) {
+ moduleContainers.add(facade.getProject().getLocation());
+ }
+ IFile file = findModuleFile(module);
+ if(file != null) {
+ moduleContainers.add(file.getParent().getLocation());
+ }
+ }
+ moduleContainers.add(getProject().getLocation());
+
+ MavenModuleSelectionDialog dialog = new MavenModuleSelectionDialog(getSite().getShell(), moduleContainers);
+
+ if(dialog.open() == Window.OK) {
+ addSelectedModules(dialog.getResult(), dialog.isPomUpdateRequired());
+ }
+ }));
+
+ modulesEditor.setCreateButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ IEditorInput editorInput = OverviewPage.this.pomEditor.getEditorInput();
+ if(editorInput instanceof FileEditorInput) {
+ MavenModuleWizard wizard = new MavenModuleWizard(true);
+ wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(((FileEditorInput) editorInput).getFile()));
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
+ int res = dialog.open();
+ if(res == Window.OK) {
+ createNewModule(wizard.getModuleName());
+ }
+ }
+ }));
+
+ modulesEditor.setRemoveButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
+ try {
+ performEditOperation(document -> {
+ Element root = document.getDocumentElement();
+ Element modules = findChild(root, MODULES);
+ if(modules != null) {
+ for(String module : modulesEditor.getSelection()) {
+ Element modEl = findChild(modules, MODULE, textEquals(module));
+ if(modEl != null) {
+ modules.removeChild(modEl);
}
}
- }, true));
- } catch(Exception e1) {
- LOG.error("Cannot load modules", e1);
- }
-
- for(String module : modules) {
- IMavenProjectFacade facade = findModuleProject(module);
- if(facade != null) {
- moduleContainers.add(facade.getProject().getLocation());
+ //now remove the <modules> element itself when there are no more elements left
+ removeIfNoChildElement(modules);
}
- IFile file = findModuleFile(module);
- if(file != null) {
- moduleContainers.add(file.getParent().getLocation());
- }
- }
- moduleContainers.add(getProject().getLocation());
-
- MavenModuleSelectionDialog dialog = new MavenModuleSelectionDialog(getSite().getShell(), moduleContainers);
-
- if(dialog.open() == Window.OK) {
- addSelectedModules(dialog.getResult(), dialog.isPomUpdateRequired());
- }
+ }, LOG, "error removing module entry");
+ } finally {
+ loadThis(RELOAD_MODULES);
}
- });
-
- modulesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IEditorInput editorInput = OverviewPage.this.pomEditor.getEditorInput();
- if(editorInput instanceof FileEditorInput) {
- MavenModuleWizard wizard = new MavenModuleWizard(true);
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(((FileEditorInput) editorInput).getFile()));
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
- int res = dialog.open();
- if(res == Window.OK) {
- createNewModule(wizard.getModuleName());
- }
- }
- }
- });
-
- modulesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- performEditOperation(document -> {
- Element root = document.getDocumentElement();
- Element modules = findChild(root, MODULES);
- if(modules != null) {
- for(String module : modulesEditor.getSelection()) {
- Element modEl = findChild(modules, MODULE, textEquals(module));
- if(modEl != null) {
- modules.removeChild(modEl);
- }
- }
- //now remove the <modules> element itself when there are no more elements left
- removeIfNoChildElement(modules);
- }
- }, LOG, "error removing module entry");
- } finally {
- loadThis(RELOAD_MODULES);
- }
- }
- });
+ }));
modulesEditor.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java
index 12dc3b2..f8fd06d 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java
@@ -37,8 +37,7 @@
import org.eclipse.jface.viewers.LabelProvider;
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.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -131,16 +130,9 @@
propertiesEditor.setContentProvider(new ListEditorContentProvider<PropertyElement>());
propertiesEditor.setLabelProvider(new PropertyPairLabelProvider());
- propertiesEditor.setCreateButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- createNewProperty();
- }
- });
- propertiesEditor.setRemoveButtonListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- deleteProperties(propertiesEditor.getSelection());
- }
- });
+ propertiesEditor.setCreateButtonListener(SelectionListener.widgetSelectedAdapter(e -> createNewProperty()));
+ propertiesEditor.setRemoveButtonListener(
+ SelectionListener.widgetSelectedAdapter(e -> deleteProperties(propertiesEditor.getSelection())));
propertiesEditor.setDoubleClickListener(event -> editProperty(propertiesEditor.getSelection()));
toolkit.paintBordersFor(propertiesEditor);
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java
index a235fe8..73fdb7d 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java
@@ -15,8 +15,7 @@
import org.eclipse.jface.action.ControlContribution;
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.Composite;
@@ -90,11 +89,7 @@
clearToolItem.setEnabled(false);
clearToolItem.setImage(MavenEditorImages.IMG_CLEAR);
clearToolItem.setDisabledImage(MavenEditorImages.IMG_CLEAR_DISABLED);
- clearToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- searchText.setText(""); //$NON-NLS-1$
- }
- });
+ clearToolItem.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> searchText.setText("")));
searchText.addModifyListener(e -> clearToolItem.setEnabled(searchText.getText().length() > 0));
diff --git a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/MavenClasspathContainerPage.java b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/MavenClasspathContainerPage.java
index 62c5888..1f95818 100644
--- a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/MavenClasspathContainerPage.java
+++ b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/MavenClasspathContainerPage.java
@@ -19,8 +19,7 @@
import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension;
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.Composite;
@@ -28,7 +27,6 @@
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.m2e.core.internal.IMavenConstants;
-import org.eclipse.m2e.jdt.ui.internal.Messages;
/**
@@ -36,8 +34,8 @@
*
* @author Eugene Kuleshov
*/
-public class MavenClasspathContainerPage extends WizardPage implements IClasspathContainerPage,
- IClasspathContainerPageExtension {
+public class MavenClasspathContainerPage extends WizardPage
+ implements IClasspathContainerPage, IClasspathContainerPageExtension {
IJavaProject javaProject;
@@ -75,15 +73,13 @@
Link link = new Link(composite, SWT.NONE);
link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
link.setText(Messages.MavenClasspathContainerPage_link);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- // IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- // container.openPage(MavenProjectPreferencePage.ID, javaProject.getProject());
+ link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ // IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
+ // container.openPage(MavenProjectPreferencePage.ID, javaProject.getProject());
- PreferencesUtil.createPropertyDialogOn(getShell(), javaProject.getProject(), //
- IMavenConstants.PREFERENCE_PAGE_ID, new String[] {IMavenConstants.PREFERENCE_PAGE_ID}, null).open();
- }
- });
+ PreferencesUtil.createPropertyDialogOn(getShell(), javaProject.getProject(), //
+ IMavenConstants.PREFERENCE_PAGE_ID, new String[] {IMavenConstants.PREFERENCE_PAGE_ID}, null).open();
+ }));
}
public boolean finish() {
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java
index 1a9ce5c..cf56c89 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java
@@ -349,11 +349,7 @@
final Button addPropButton = new Button(mainComposite, SWT.NONE);
addPropButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addPropButton.setText(Messages.launchPropAddButton); //$NON-NLS-1$
- addPropButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addProperty();
- }
- });
+ addPropButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> addProperty()));
editPropButton = new Button(mainComposite, SWT.NONE);
editPropButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
editPropButton.setText(Messages.launchPropEditButton); //$NON-NLS-1$
@@ -371,14 +367,12 @@
removePropButton = new Button(mainComposite, SWT.NONE);
removePropButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removePropButton.setText(Messages.launchPropRemoveButton); //$NON-NLS-1$
- removePropButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if(propsTable.getSelectionCount() > 0) {
- propsTable.remove(propsTable.getSelectionIndices());
- entriesChanged();
- }
+ removePropButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ if(propsTable.getSelectionCount() > 0) {
+ propsTable.remove(propsTable.getSelectionIndices());
+ entriesChanged();
}
- });
+ }));
removePropButton.setEnabled(false);
Label mavenRuntimeLabel = new Label(mainComposite, SWT.NONE);
@@ -432,17 +426,15 @@
variablesButton.setFont(comp.getFont());
variablesButton.setText(Messages.launchPropertyDialogBrowseVariables); //$NON-NLS-1$;
- variablesButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent se) {
- StringVariableSelectionDialog variablesDialog = new StringVariableSelectionDialog(getShell());
- if(variablesDialog.open() == IDialogConstants.OK_ID) {
- String variable = variablesDialog.getVariableExpression();
- if(variable != null) {
- valueText.insert(variable.trim());
- }
+ variablesButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ StringVariableSelectionDialog variablesDialog = new StringVariableSelectionDialog(getShell());
+ if(variablesDialog.open() == IDialogConstants.OK_ID) {
+ String variable = variablesDialog.getVariableExpression();
+ if(variable != null) {
+ valueText.insert(variable.trim());
}
}
- });
+ }));
return comp;
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
index 13d664d..4573533 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
@@ -29,8 +29,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
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;
@@ -131,15 +130,13 @@
configureRuntimesButton = new Button(this, SWT.NONE);
configureRuntimesButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
configureRuntimesButton.setText(org.eclipse.m2e.internal.launch.Messages.MavenLaunchMainTab_btnConfigure);
- configureRuntimesButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(mainComposite.getShell(),
- "org.eclipse.m2e.core.preferences.MavenInstallationsPreferencePage", null, null); //$NON-NLS-1$
- if(dialog.open() == Window.OK) {
- setInput();
- }
+ configureRuntimesButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(mainComposite.getShell(),
+ "org.eclipse.m2e.core.preferences.MavenInstallationsPreferencePage", null, null); //$NON-NLS-1$
+ if(dialog.open() == Window.OK) {
+ setInput();
}
- });
+ }));
}
protected String getType(AbstractMavenRuntime runtime) {
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/MavenRenameWizardPage.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/MavenRenameWizardPage.java
index 5f9f6ad..3a91aad 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/MavenRenameWizardPage.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/MavenRenameWizardPage.java
@@ -17,8 +17,7 @@
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
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;
import org.eclipse.swt.widgets.Button;
@@ -135,13 +134,10 @@
renameCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
renameCheckbox.setData("name", "rename"); //$NON-NLS-1$ //$NON-NLS-2$
renameCheckbox.setEnabled(false);
- renameCheckbox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- renamed = renameCheckbox.getSelection();
- getWizard().getContainer().updateButtons();
- }
- });
+ renameCheckbox.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ renamed = renameCheckbox.getSelection();
+ getWizard().getContainer().updateButtons();
+ }));
ModifyListener listener = e -> {
newGroupId = groupIdText.getText();
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
index 185f5ec..be65eb1 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
@@ -27,7 +27,6 @@
import org.eclipse.jface.wizard.WizardDialog;
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;
@@ -95,11 +94,7 @@
composite.setLayout(gridLayout);
setControl(composite);
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updatePage();
- }
- };
+ SelectionListener selectionAdapter = SelectionListener.widgetSelectedAdapter(e -> updatePage());
if(scmUrls == null || scmUrls.length < 2) {
Label urlLabel = new Label(composite, SWT.NONE);
@@ -174,24 +169,22 @@
gd_revisionBrowseButton.verticalIndent = 3;
revisionBrowseButton.setLayoutData(gd_revisionBrowseButton);
revisionBrowseButton.setText(Messages.MavenCheckoutLocationPage_btnRevSelect);
- revisionBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- String url = scmParentUrl;
- if(url == null) {
- return;
- }
-
- String scmType = scmTypeCombo.getText();
-
- ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
- String revision = handlerUi.selectRevision(getShell(), scmUrls[0], revisionText.getText());
- if(revision != null) {
- revisionText.setText(revision);
- headRevisionButton.setSelection(false);
- updatePage();
- }
+ revisionBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ String url = scmParentUrl;
+ if(url == null) {
+ return;
}
- });
+
+ String scmType = scmTypeCombo.getText();
+
+ ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
+ String revision = handlerUi.selectRevision(getShell(), scmUrls[0], revisionText.getText());
+ if(revision != null) {
+ revisionText.setText(revision);
+ headRevisionButton.setSelection(false);
+ updatePage();
+ }
+ }));
checkoutAllProjectsButton = new Button(composite, SWT.CHECK);
GridData checkoutAllProjectsData = new GridData(SWT.LEFT, SWT.TOP, true, false, 5, 1);
@@ -199,11 +192,7 @@
checkoutAllProjectsButton.setLayoutData(checkoutAllProjectsData);
checkoutAllProjectsButton.setText(Messages.MavenCheckoutLocationPage_btnCheckout);
checkoutAllProjectsButton.setSelection(true);
- checkoutAllProjectsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updatePage();
- }
- });
+ checkoutAllProjectsButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updatePage()));
GridData advancedSettingsData = new GridData(SWT.FILL, SWT.TOP, true, false, 5, 1);
advancedSettingsData.verticalIndent = 10;
@@ -215,23 +204,21 @@
}
if(scmUrls == null || scmUrls.length < 2) {
- scmUrlBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
- // XXX should use null if there is no scmUrl selected
- ScmUrl currentUrl = scmUrls == null || scmUrls.length == 0 ? new ScmUrl("scm:" + scmType + ":") : scmUrls[0]; //$NON-NLS-1$ //$NON-NLS-2$
- ScmUrl scmUrl = handlerUi.selectUrl(getShell(), currentUrl);
- if(scmUrl != null) {
- scmUrlCombo.setText(scmUrl.getProviderUrl());
- if(scmUrls == null) {
- scmUrls = new ScmUrl[1];
- }
- scmUrls[0] = scmUrl;
- scmParentUrl = scmUrl.getUrl();
- updatePage();
+ scmUrlBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
+ // XXX should use null if there is no scmUrl selected
+ ScmUrl currentUrl = scmUrls == null || scmUrls.length == 0 ? new ScmUrl("scm:" + scmType + ":") : scmUrls[0]; //$NON-NLS-1$ //$NON-NLS-2$
+ ScmUrl scmUrl = handlerUi.selectUrl(getShell(), currentUrl);
+ if(scmUrl != null) {
+ scmUrlCombo.setText(scmUrl.getProviderUrl());
+ if(scmUrls == null) {
+ scmUrls = new ScmUrl[1];
}
+ scmUrls[0] = scmUrl;
+ scmParentUrl = scmUrl.getUrl();
+ updatePage();
}
- });
+ }));
scmUrlCombo.addModifyListener(e -> {
final String url = scmUrlCombo.getText().trim();
diff --git a/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupInfoDialog.java b/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupInfoDialog.java
index b8e1809..1cfda63 100644
--- a/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupInfoDialog.java
+++ b/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupInfoDialog.java
@@ -33,8 +33,7 @@
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
-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.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -120,26 +119,19 @@
actionsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
Button btnCopy = new Button(actionsComposite, SWT.NONE);
- btnCopy.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- copyToClipboard();
- }
- });
+ btnCopy.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> copyToClipboard()
+ ));
btnCopy.setToolTipText("Copy to clipboard");
btnCopy.setText("Copy");
Button btnRefresh = new Button(actionsComposite, SWT.NONE);
- btnRefresh.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- sourceLookup.getSourceContainer(debugElement, true, monitor);
- } catch (CoreException e1) {
- showError(e1);
- }
- }
- });
+ btnRefresh.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ try {
+ sourceLookup.getSourceContainer(debugElement, true, monitor);
+ } catch (CoreException e1) {
+ showError(e1);
+ }
+ }));
btnRefresh.setToolTipText("Force rediscovery of source lookup information for this code location.");
btnRefresh.setText("Refresh");