Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-01-09 10:36:35 +0000
committerAlexander Kurtakov2020-01-09 10:36:35 +0000
commit5bbfa969c3af244dcd50e3fc1d0a1a6456eeb242 (patch)
tree2f90c24f7c8d1ea1eba8a4757d6624df61d32dd6 /org.eclipse.m2e.editor
parent6bbd6cb32c2166d23a3d67056d139d0e81d7f47b (diff)
downloadm2e-core-5bbfa969c3af244dcd50e3fc1d0a1a6456eeb242.tar.gz
m2e-core-5bbfa969c3af244dcd50e3fc1d0a1a6456eeb242.tar.xz
m2e-core-5bbfa969c3af244dcd50e3fc1d0a1a6456eeb242.zip
Move from SelectionAdapter to SelectionListener default methods.
Fixes many synthetic access warnings. Change-Id: I4c4c7da0354bb0bfbc3c34ba35df1b577e816164 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java269
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java16
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/MavenModuleSelectionDialog.java28
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependenciesPage.java10
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java10
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java124
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java16
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java9
8 files changed, 215 insertions, 267 deletions
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 7d1859f9..731aeed8 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.viewers.ViewerFilter;
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 @@ public class DependenciesComposite extends Composite {
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);
- }
+ 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);
}
- removeIfNoChildElement(deps);
- }, log, "error removing dependencies");
- } finally {
- setDependenciesInput();
- }
+ }
+ 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.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.
- */
}
+ } 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) {
+ 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(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 {
- 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);
-
- 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)));
- }
+ 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 @@ public class DependenciesComposite extends Composite {
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 @@ public class DependenciesComposite extends Composite {
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 1c709a37..64a21ae8 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.TableViewerColumn;
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 @@ public class ListEditorComposite<T> extends Composite {
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 @@ public class ListEditorComposite<T> extends Composite {
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 5bb53c93..fdcc52ca 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.ILabelProvider;
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 @@ public class MavenModuleSelectionDialog extends MavenProjectSelectionDialog {
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 f4c8158f..b3d5ecbf 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.emf.common.notify.Notification;
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 @@ public class DependenciesPage extends MavenPomEditorPage {
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 2d63e3c5..11415acc 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.ModifyEvent;
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 @@ public abstract class MavenPomEditorPage extends FormPage {
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 a721a7c9..9b39c111 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.DropTargetAdapter;
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 @@ public class OverviewPage extends MavenPomEditorPage {
}.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);
+ }, true));
+ } catch(Exception e1) {
+ LOG.error("Cannot load modules", e1);
+ }
- if(dialog.open() == Window.OK) {
- addSelectedModules(dialog.getResult(), dialog.isPomUpdateRequired());
+ 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());
- 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());
- }
+ 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(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);
- }
+ 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);
}
- //now remove the <modules> element itself when there are no more elements left
- removeIfNoChildElement(modules);
}
- }, LOG, "error removing module entry");
- } finally {
- loadThis(RELOAD_MODULES);
- }
+ //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 12dc3b22..f8fd06d2 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.dialogs.IDialogConstants;
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 @@ public class PropertiesSection {
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 a235fe8e..73fdb7da 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 @@ package org.eclipse.m2e.editor.pom;
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 @@ public class SearchControl extends ControlContribution {
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));

Back to the top