Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.m2e.binaryproject.ui/src/org/eclipse/m2e/binaryproject/ui/internal/BinaryProjectImportWizard.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/MavenVersionDecorator.java24
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenDebugOutputAction.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java45
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/TextComboBoxCellEditor.java10
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsoleImpl.java62
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java20
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/InputHistory.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenPropertyDialog.java14
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java59
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LifecycleMappingPreferencePage.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/LocalArchetypeCatalogDialog.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java16
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java18
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java35
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java29
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java24
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/ControlDecoration.java88
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/M2EUIUtils.java16
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java49
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/build/BuildDebugView.java36
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/CustomArchetypeDialog.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java50
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MappingDiscoveryJob.java11
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenDependenciesWizardPage.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java73
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java29
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java49
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java68
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java32
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizardPage.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectSelectionDialog.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java18
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java352
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java40
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArtifactPage.java13
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardLocationPage.java8
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java8
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java73
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java7
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java107
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/FormHoverProvider.java115
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java19
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java37
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingResolution.java21
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java146
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ListEditorComposite.java7
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/internal/actions/ShowDependencyHierarchyAction.java6
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependencyTreePage.java119
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java57
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java112
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java515
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/PropertiesSection.java93
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/SearchControl.java8
-rw-r--r--org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/actions/OpenJavaDocAction.java42
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchExtensionsTab.java26
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java50
-rw-r--r--org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/ProfileSelectionHandler.java19
-rw-r--r--org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/dialog/SelectProfilesDialog.java863
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/MavenRenameWizardPage.java13
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java77
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java67
67 files changed, 1665 insertions, 2344 deletions
diff --git a/org.eclipse.m2e.binaryproject.ui/src/org/eclipse/m2e/binaryproject/ui/internal/BinaryProjectImportWizard.java b/org.eclipse.m2e.binaryproject.ui/src/org/eclipse/m2e/binaryproject/ui/internal/BinaryProjectImportWizard.java
index 39a3181c..7ba170f2 100644
--- a/org.eclipse.m2e.binaryproject.ui/src/org/eclipse/m2e/binaryproject/ui/internal/BinaryProjectImportWizard.java
+++ b/org.eclipse.m2e.binaryproject.ui/src/org/eclipse/m2e/binaryproject/ui/internal/BinaryProjectImportWizard.java
@@ -20,9 +20,7 @@ import org.apache.maven.model.Dependency;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.m2e.binaryproject.internal.AbstractBinaryProjectsImportJob;
import org.eclipse.m2e.core.embedder.ArtifactKey;
@@ -66,12 +64,7 @@ public class BinaryProjectImportWizard extends Wizard implements IImportWizard {
}
};
artifactsPage.setDependencies(dependencies.toArray(new Dependency[dependencies.size()]));
- artifactsPage.addListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- getContainer().updateButtons();
- }
- });
+ artifactsPage.addListener(event -> getContainer().updateButtons());
this.initialDependencies = Collections.unmodifiableList(dependencies);
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/MavenVersionDecorator.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/MavenVersionDecorator.java
index 3e0c8f6b..092c0fed 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/MavenVersionDecorator.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/MavenVersionDecorator.java
@@ -18,7 +18,6 @@ import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -30,7 +29,6 @@ import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
-import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
/**
@@ -75,21 +73,19 @@ public class MavenVersionDecorator implements ILabelDecorator {
}
public void addListener(final ILabelProviderListener listener) {
- IMavenProjectChangedListener projectChangeListener = new IMavenProjectChangedListener() {
- public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
- ArrayList<IResource> pomList = new ArrayList<IResource>();
- for(int i = 0; i < events.length; i++ ) {
- // pomList.add(events[i].getSource());
- if(events[i] != null && events[i].getMavenProject() != null) {
- IFile pom = events[i].getMavenProject().getPom();
- pomList.add(pom);
- if(pom.getParent().getType() == IResource.PROJECT) {
- pomList.add(pom.getParent());
- }
+ IMavenProjectChangedListener projectChangeListener = (events, monitor) -> {
+ ArrayList<IResource> pomList = new ArrayList<IResource>();
+ for(int i = 0; i < events.length; i++ ) {
+ // pomList.add(events[i].getSource());
+ if(events[i] != null && events[i].getMavenProject() != null) {
+ IFile pom = events[i].getMavenProject().getPom();
+ pomList.add(pom);
+ if(pom.getParent().getType() == IResource.PROJECT) {
+ pomList.add(pom.getParent());
}
}
- listener.labelProviderChanged(new LabelProviderChangedEvent(MavenVersionDecorator.this, pomList.toArray()));
}
+ listener.labelProviderChanged(new LabelProviderChangedEvent(MavenVersionDecorator.this, pomList.toArray()));
};
listeners.put(listener, projectChangeListener);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
index 825cdf9f..74007491 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
@@ -105,12 +105,8 @@ public class UpdateMavenProjectJob extends WorkspaceJob {
private void handleErrors(final Map<String, Throwable> updateErrors) {
final Display display = Display.getDefault();
if(display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- M2EUIUtils.showErrorsForProjectsDialog(display.getActiveShell(), Messages.UpdateSourcesAction_error_title,
- Messages.UpdateSourcesAction_error_message, updateErrors);
- }
- });
+ display.asyncExec(() -> M2EUIUtils.showErrorsForProjectsDialog(display.getActiveShell(),
+ Messages.UpdateSourcesAction_error_title, Messages.UpdateSourcesAction_error_message, updateErrors));
}
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenDebugOutputAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenDebugOutputAction.java
index ecdcc273..b247ef6e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenDebugOutputAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenDebugOutputAction.java
@@ -14,7 +14,6 @@ package org.eclipse.m2e.core.ui.internal.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants;
import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
@@ -27,11 +26,9 @@ import org.eclipse.m2e.core.ui.internal.Messages;
*/
public class MavenDebugOutputAction extends Action {
- private IPropertyChangeListener listener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if(MavenPreferenceConstants.P_DEBUG_OUTPUT.equals(event.getProperty())) {
- setChecked(isDebug());
- }
+ private IPropertyChangeListener listener = event -> {
+ if(MavenPreferenceConstants.P_DEBUG_OUTPUT.equals(event.getProperty())) {
+ setChecked(isDebug());
}
};
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
index 6d2c6d3b..6d3afe22 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
@@ -134,12 +134,9 @@ public class OpenPomAction extends ActionDelegate implements IWorkbenchWindowAct
}
} catch(CoreException ex) {
log.error(ex.getMessage(), ex);
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
- Messages.OpenPomAction_open_error_title, Messages.OpenPomAction_open_error_message);
- }
- });
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
+ Messages.OpenPomAction_open_error_title, Messages.OpenPomAction_open_error_message));
}
}
}
@@ -269,21 +266,19 @@ public class OpenPomAction extends ActionDelegate implements IWorkbenchWindowAct
public IEditorPart openPomEditor(final IEditorInput editorInput, final String name) {
final IEditorPart[] part = new IEditorPart[1];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- public void run() {
- IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
- IContentType contentType = contentTypeManager.findContentTypeFor(name);
- IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
- IEditorDescriptor editor = editorRegistry.getDefaultEditor(name, contentType);
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window != null) {
- IWorkbenchPage page = window.getActivePage();
- if(page != null) {
- try {
- part[0] = page.openEditor(editorInput, editor.getId());
- } catch(PartInitException ex) {
- openDialog(NLS.bind(Messages.OpenPomAction_33, editorInput.getName(), ex.toString()));
- }
+ PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ IContentType contentType = contentTypeManager.findContentTypeFor(name);
+ IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
+ IEditorDescriptor editor = editorRegistry.getDefaultEditor(name, contentType);
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if(window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if(page != null) {
+ try {
+ part[0] = page.openEditor(editorInput, editor.getId());
+ } catch(PartInitException ex) {
+ openDialog(NLS.bind(Messages.OpenPomAction_33, editorInput.getName(), ex.toString()));
}
}
}
@@ -292,12 +287,8 @@ public class OpenPomAction extends ActionDelegate implements IWorkbenchWindowAct
}
protected void openDialog(final String msg) {
- Runnable r = new Runnable() {
- public void run() {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
- Messages.OpenPomAction_open_title, msg);
- }
- };
+ Runnable r = () -> MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
+ Messages.OpenPomAction_open_title, msg);
Display display = PlatformUI.getWorkbench().getDisplay();
if(display == Display.getCurrent()) {
r.run();
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 aa1145d5..3b9e9f77 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
@@ -44,7 +44,6 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.NLS;
@@ -219,11 +218,7 @@ public class NestedProjectsComposite extends Composite implements IMenuListener
createMenu();
- codebaseViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateSelectedProjects();
- }
- });
+ codebaseViewer.addSelectionChangedListener(event -> updateSelectedProjects());
updateSelectedProjects();
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/TextComboBoxCellEditor.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/TextComboBoxCellEditor.java
index 2affc2de..0ceb70fb 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/TextComboBoxCellEditor.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/TextComboBoxCellEditor.java
@@ -17,8 +17,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -48,11 +46,9 @@ public class TextComboBoxCellEditor extends CellEditor {
keyReleaseOccured(e);
}
});
- combo.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if(e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
+ combo.addTraverseListener(e -> {
+ if(e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
}
});
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 ab7f6022..b0ba0472 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
@@ -24,11 +24,9 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
@@ -201,11 +199,7 @@ public class WorkingSetGroup {
}
});
- workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateConfiguration();
- }
- });
+ workingsetComboViewer.addSelectionChangedListener(event -> updateConfiguration());
}
protected void updateConfiguration() {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsoleImpl.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsoleImpl.java
index cfa44455..e79c4999 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsoleImpl.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsoleImpl.java
@@ -78,12 +78,10 @@ public class MavenConsoleImpl extends IOConsole implements MavenConsole, IProper
super.init();
// Ensure that initialization occurs in the UI thread
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- JFaceResources.getFontRegistry().addListener(MavenConsoleImpl.this);
- initializeConsoleStreams(Display.getDefault());
- dumpConsole();
- }
+ Display.getDefault().asyncExec(() -> {
+ JFaceResources.getFontRegistry().addListener(MavenConsoleImpl.this);
+ initializeConsoleStreams(Display.getDefault());
+ dumpConsole();
});
}
@@ -147,31 +145,29 @@ public class MavenConsoleImpl extends IOConsole implements MavenConsole, IProper
//the synchronization here caused a deadlock. since the writes are simply appending to the output stream
//or the document, just doing it on the main thread to avoid deadlocks and or corruption of the
//document or output stream
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if(isVisible()) {
- try {
- switch(type) {
- case ConsoleDocument.COMMAND:
- getCommandStream().write(line);
- getCommandStream().write('\n');
- break;
- case ConsoleDocument.MESSAGE:
- getMessageStream().write(line);
- getMessageStream().write('\n');
- break;
- case ConsoleDocument.ERROR:
- getErrorStream().write(line);
- getErrorStream().write('\n');
- break;
- }
- } catch(IOException ex) {
- // Don't log using slf4j - it will cause a cycle
- ex.printStackTrace();
+ Display.getDefault().asyncExec(() -> {
+ if(isVisible()) {
+ try {
+ switch(type) {
+ case ConsoleDocument.COMMAND:
+ getCommandStream().write(line);
+ getCommandStream().write('\n');
+ break;
+ case ConsoleDocument.MESSAGE:
+ getMessageStream().write(line);
+ getMessageStream().write('\n');
+ break;
+ case ConsoleDocument.ERROR:
+ getErrorStream().write(line);
+ getErrorStream().write('\n');
+ break;
}
- } else {
- getConsoleDocument().appendConsoleLine(type, line);
+ } catch(IOException ex) {
+ // Don't log using slf4j - it will cause a cycle
+ ex.printStackTrace();
}
+ } else {
+ getConsoleDocument().appendConsoleLine(type, line);
}
});
}
@@ -231,11 +227,9 @@ public class MavenConsoleImpl extends IOConsole implements MavenConsole, IProper
// Here we can't call super.dispose() because we actually want the partitioner to remain
// connected, but we won't show lines until the console is added to the console manager
// again.
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- setVisible(false);
- JFaceResources.getFontRegistry().removeListener(MavenConsoleImpl.this);
- }
+ Display.getDefault().asyncExec(() -> {
+ setVisible(false);
+ JFaceResources.getFontRegistry().removeListener(MavenConsoleImpl.this);
});
}
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 f5357450..00c34758 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
@@ -18,11 +18,7 @@ import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -122,22 +118,16 @@ public class AssignWorkingSetDialog extends TitleAreaDialog {
lblNewLabel.setText(Messages.AssignWorkingSetDialog_lblWorkingSet);
workingSetCombo = new Combo(workingSetComposite, SWT.BORDER);
- workingSetCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- workingSetName = workingSetCombo.getText();
- }
- });
+ workingSetCombo.addModifyListener(e -> workingSetName = workingSetCombo.getText());
GridData gd_workingSetName = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_workingSetName.horizontalIndent = 10;
workingSetCombo.setLayoutData(gd_workingSetName);
workingSetCombo.setItems(WorkingSets.getWorkingSets());
- selectedProjects.addSelectionChangeListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IProject selection = selectedProjects.getSelection();
- if(selection != null && workingSetCombo.getSelectionIndex() < 0) {
- workingSetCombo.setText(selection.getName());
- }
+ selectedProjects.addSelectionChangeListener(event -> {
+ IProject selection = selectedProjects.getSelection();
+ if(selection != null && workingSetCombo.getSelectionIndex() < 0) {
+ workingSetCombo.setText(selection.getName());
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/InputHistory.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/InputHistory.java
index 238ceba8..b9787189 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/InputHistory.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/InputHistory.java
@@ -13,8 +13,6 @@ import java.util.Set;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
@@ -145,11 +143,7 @@ public class InputHistory {
protected ControlWrapper(Control control) {
this.control = control;
- control.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- collect();
- }
- });
+ control.addDisposeListener(e -> collect());
}
protected void collect() {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenPropertyDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenPropertyDialog.java
index 2fcdf99a..55b0633b 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenPropertyDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenPropertyDialog.java
@@ -15,8 +15,6 @@ package org.eclipse.m2e.core.ui.internal.dialogs;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
@@ -78,11 +76,7 @@ public class MavenPropertyDialog extends Dialog {
nameText.setLayoutData(gd);
nameText.setFont(comp.getFont());
nameText.setText(initialName == null ? "" : initialName); //$NON-NLS-1$
- nameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateButtons();
- }
- });
+ nameText.addModifyListener(e -> updateButtons());
Label valueLabel = new Label(comp, SWT.NONE);
valueLabel.setText(Messages.launchPropertyDialogValue);
@@ -94,11 +88,7 @@ public class MavenPropertyDialog extends Dialog {
valueText.setLayoutData(gd);
valueText.setFont(comp.getFont());
valueText.setText(initialValue == null ? "" : initialValue); //$NON-NLS-1$
- valueText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateButtons();
- }
- });
+ valueText.addModifyListener(e -> updateButtons());
// if(variables) {
// Button variablesButton = new Button(comp, SWT.PUSH);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
index d28c4dda..696b7a18 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
@@ -20,13 +20,7 @@ import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@@ -242,18 +236,14 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
pomSelectionComponent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- pomSelectionComponent.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- if(!pomSelectionComponent.getStatus().matches(IStatus.ERROR)) {
- okPressedDelegate();
- }
+ pomSelectionComponent.addDoubleClickListener(event -> {
+ if(!pomSelectionComponent.getStatus().matches(IStatus.ERROR)) {
+ okPressedDelegate();
}
});
- pomSelectionComponent.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateStatusDelegate(pomSelectionComponent.getStatus());
- computeResultFromTree();
- }
+ pomSelectionComponent.addSelectionChangedListener(event -> {
+ updateStatusDelegate(pomSelectionComponent.getStatus());
+ computeResultFromTree();
});
pomSelectionComponent.setFocus();
@@ -334,34 +324,25 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
ProposalUtil.addArtifactIdProposal(project, txtGroupId, txtArtifactId, pack);
ProposalUtil.addVersionProposal(project, mavenproject, txtGroupId, txtArtifactId, txtVersion, pack);
- txtArtifactId.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- updateStatus(validateArtifactEntries());
- if(!ignoreTextChange && !hasDisposedTextField()) {
- computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
- valueOrNull(txtVersion.getText()));
- }
+ txtArtifactId.addModifyListener(e -> {
+ updateStatus(validateArtifactEntries());
+ if(!ignoreTextChange && !hasDisposedTextField()) {
+ computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
+ valueOrNull(txtVersion.getText()));
}
});
- txtGroupId.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- updateStatus(validateArtifactEntries());
- if(!ignoreTextChange && !hasDisposedTextField()) {
- computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
- valueOrNull(txtVersion.getText()));
- }
+ txtGroupId.addModifyListener(e -> {
+ updateStatus(validateArtifactEntries());
+ if(!ignoreTextChange && !hasDisposedTextField()) {
+ computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
+ valueOrNull(txtVersion.getText()));
}
});
- txtVersion.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- if(!ignoreTextChange && !hasDisposedTextField()) {
- computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
- valueOrNull(txtVersion.getText()));
- }
+ txtVersion.addModifyListener(e -> {
+ if(!ignoreTextChange && !hasDisposedTextField()) {
+ computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
+ valueOrNull(txtVersion.getText()));
}
});
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 c3a632f8..25f4cff7 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
@@ -21,8 +21,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
@@ -127,11 +125,7 @@ public class LifecycleMappingPreferencePage extends PreferencePage implements IW
mappingFileTextBox = new Text(composite, SWT.BORDER);
mappingFileTextBox.setText(getCurrentLocation());
- mappingFileTextBox.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- mappingFilePath = mappingFileTextBox.getText();
- }
- });
+ mappingFileTextBox.addModifyListener(e -> mappingFilePath = mappingFileTextBox.getText());
Button newFileButton = new Button(composite, SWT.PUSH);
newFileButton.setText(Messages.LifecycleMappingPreferencePage_Browse);
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 0301bdd2..687002cc 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
@@ -24,7 +24,6 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -142,11 +141,7 @@ public class LocalArchetypeCatalogDialog extends TitleAreaDialog {
catalogDescriptionText.setText(archetypeCatalogFactory.getDescription());
}
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- update();
- }
- };
+ ModifyListener modifyListener = e -> update();
catalogLocationCombo.addModifyListener(modifyListener);
catalogDescriptionText.addModifyListener(modifyListener);
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 31ebd440..4acd613f 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
@@ -26,11 +26,9 @@ import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
@@ -266,14 +264,12 @@ public class MavenArchetypesPreferencePage extends PreferencePage implements IWo
}
});
- archetypesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if(archetypesViewer.getSelection() instanceof IStructuredSelection) {
- ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
- boolean isEnabled = factory != null && factory.isEditable();
- removeButton.setEnabled(isEnabled);
- editButton.setEnabled(isEnabled);
- }
+ archetypesViewer.addSelectionChangedListener(event -> {
+ if(archetypesViewer.getSelection() instanceof IStructuredSelection) {
+ ArchetypeCatalogFactory factory = getSelectedArchetypeCatalogFactory();
+ boolean isEnabled = factory != null && factory.isEditable();
+ removeButton.setEnabled(isEnabled);
+ editButton.setEnabled(isEnabled);
}
});
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 b58fe7f9..e359736c 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
@@ -32,7 +32,6 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -48,7 +47,6 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -285,11 +283,9 @@ public class MavenSettingsPreferencePage extends PreferencePage implements IWork
}
});
- ModifyListener settingsModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent modifyevent) {
- updateLocalRepository();
- checkSettings();
- }
+ ModifyListener settingsModifyListener = modifyevent -> {
+ updateLocalRepository();
+ checkSettings();
};
userSettingsText.addModifyListener(settingsModifyListener);
globalSettingsText.addModifyListener(settingsModifyListener);
@@ -400,11 +396,9 @@ public class MavenSettingsPreferencePage extends PreferencePage implements IWork
//external editor was opened
return;
}
- editor.addPropertyListener(new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if(!editor.isDirty()) {
- log.info("Refreshing settings " + fileName); //$NON-NLS-1$
- }
+ editor.addPropertyListener((source, propId) -> {
+ if(!editor.isDirty()) {
+ log.info("Refreshing settings " + fileName); //$NON-NLS-1$
}
});
} catch(PartInitException ex) {
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 afedca3e..7243a606 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
@@ -27,7 +27,6 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -137,11 +136,7 @@ public class RemoteArchetypeCatalogDialog extends TitleAreaDialog {
catalogDescriptionText.setText(archetypeCatalogFactory.getDescription());
}
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- update();
- }
- };
+ ModifyListener modifyListener = e -> update();
catalogUrlCombo.addModifyListener(modifyListener);
catalogDescriptionText.addModifyListener(modifyListener);
@@ -188,21 +183,19 @@ public class RemoteArchetypeCatalogDialog extends TitleAreaDialog {
if(shell == null) {
return status;
}
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- 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);
- }
+ 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);
}
});
}
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 f2812612..c2433d52 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
@@ -15,24 +15,19 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@@ -181,11 +176,7 @@ public class MavenInstallationWizardPage extends WizardPage {
lblInstallationLocation.setText(Messages.ExternalInstallPage_lblInstallationLocation_text);
location = new Text(container, SWT.BORDER);
- location.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateStatus();
- }
- });
+ location.addModifyListener(e -> updateStatus());
location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnDirectory = new Button(container, SWT.NONE);
@@ -202,11 +193,7 @@ public class MavenInstallationWizardPage extends WizardPage {
lblInstallationName.setText(Messages.ExternalInstallPage_lblInstallationName_text);
name = new Text(container, SWT.BORDER);
- name.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateStatus();
- }
- });
+ name.addModifyListener(e -> updateStatus());
name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblInstallationLibraries = new Label(container, SWT.NONE);
@@ -214,11 +201,7 @@ public class MavenInstallationWizardPage extends WizardPage {
lblInstallationLibraries.setText(Messages.ExternalInstallPage_lblInstallationLibraries_text);
treeViewerLibrariries = new TreeViewer(container, SWT.BORDER);
- treeViewerLibrariries.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonsState();
- }
- });
+ treeViewerLibrariries.addSelectionChangedListener(event -> updateButtonsState());
treeViewerLibrariries.setContentProvider(new TreeContentProvider());
treeViewerLibrariries.setLabelProvider(new TreeLabelProvider());
treeViewerLibrariries.setInput(extensions);
@@ -342,11 +325,7 @@ public class MavenInstallationWizardPage extends WizardPage {
projects.add(project);
}
}
- Collections.sort(projects, new Comparator<IProject>() {
- public int compare(IProject p1, IProject p2) {
- return p1.getName().compareTo(p2.getName());
- }
- });
+ Collections.sort(projects, (p1, p2) -> p1.getName().compareTo(p2.getName()));
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new MavenProjectLabelProvider());
dialog.setElements(projects.toArray());
dialog.setMessage(Messages.MavenInstallationWizardPage_selectProjectMessage);
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 beed797c..a972a4f2 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
@@ -16,16 +16,12 @@ import java.util.List;
import java.util.Set;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
@@ -254,22 +250,16 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
}
});
- runtimesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if(runtimesViewer.getSelection() instanceof IStructuredSelection) {
- AbstractMavenRuntime runtime = getSelectedMavenRuntime();
- boolean isEnabled = runtime != null && runtime.isEditable();
- removeButton.setEnabled(isEnabled);
- editButton.setEnabled(isEnabled);
- }
+ runtimesViewer.addSelectionChangedListener(event -> {
+ if(runtimesViewer.getSelection() instanceof IStructuredSelection) {
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
+ boolean isEnabled = runtime != null && runtime.isEditable();
+ removeButton.setEnabled(isEnabled);
+ editButton.setEnabled(isEnabled);
}
});
- runtimesViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- setCheckedRuntime((AbstractMavenRuntime) event.getElement());
- }
- });
+ runtimesViewer.addCheckStateListener(event -> setCheckedRuntime((AbstractMavenRuntime) event.getElement()));
Label noteLabel = new Label(composite, SWT.WRAP);
GridData noteLabelData = new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1);
noteLabelData.widthHint = 100;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/ControlDecoration.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/ControlDecoration.java
index 294218e2..91e8c82e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/ControlDecoration.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/ControlDecoration.java
@@ -15,7 +15,6 @@ import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
@@ -23,7 +22,6 @@ import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -244,12 +242,10 @@ public class ControlDecoration {
hoverShell = new Shell(parent, SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
hoverShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
hoverShell.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- hoverShell.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent pe) {
- pe.gc.drawText(text, hm, hm);
- if(!CARBON) {
- pe.gc.drawPolygon(getPolygon(true));
- }
+ hoverShell.addPaintListener(pe -> {
+ pe.gc.drawText(text, hm, hm);
+ if(!CARBON) {
+ pe.gc.drawPolygon(getPolygon(true));
}
});
hoverShell.addMouseListener(new MouseAdapter() {
@@ -515,11 +511,7 @@ public class ControlDecoration {
* Add any listeners needed on the target control and on the composite where the decoration is to be rendered.
*/
private void addControlListeners() {
- disposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- dispose();
- }
- };
+ disposeListener = event -> dispose();
printAddListener(control, "DISPOSE"); //$NON-NLS-1$
control.addDisposeListener(disposeListener);
@@ -542,28 +534,24 @@ public class ControlDecoration {
control.addFocusListener(focusListener);
// Listener for painting the decoration
- paintListener = new PaintListener() {
- public void paintControl(PaintEvent event) {
- Control control = (Control) event.widget;
- Rectangle rect = getDecorationRectangle(control);
- if(shouldShowDecoration()) {
- event.gc.drawImage(getImage(), rect.x, rect.y);
- }
+ paintListener = event -> {
+ Control control = (Control) event.widget;
+ Rectangle rect = getDecorationRectangle(control);
+ if(shouldShowDecoration()) {
+ event.gc.drawImage(getImage(), rect.x, rect.y);
}
};
// Listener for tracking the end of a hover. Only installed
// after a hover begins.
- mouseMoveListener = new MouseMoveListener() {
- public void mouseMove(MouseEvent event) {
- if(showHover) {
- if(!decorationRectangle.contains(event.x, event.y)) {
- hideHover();
- // No need to listen any longer
- printRemoveListener(event.widget, "MOUSEMOVE"); //$NON-NLS-1$
- ((Control) event.widget).removeMouseMoveListener(mouseMoveListener);
- moveListeningTarget = null;
- }
+ mouseMoveListener = event -> {
+ if(showHover) {
+ if(!decorationRectangle.contains(event.x, event.y)) {
+ hideHover();
+ // No need to listen any longer
+ printRemoveListener(event.widget, "MOUSEMOVE"); //$NON-NLS-1$
+ ((Control) event.widget).removeMouseMoveListener(mouseMoveListener);
+ moveListeningTarget = null;
}
}
};
@@ -609,27 +597,25 @@ public class ControlDecoration {
}
};
- compositeListener = new Listener() {
- public void handleEvent(Event event) {
- // Don't forward events if decoration is not showing
- if(!visible) {
- return;
- }
- // Notify listeners if any are registered.
- switch(event.type) {
- case SWT.MouseDown:
- if(!selectionListeners.isEmpty())
- notifySelectionListeners(event);
- break;
- case SWT.MouseDoubleClick:
- if(!selectionListeners.isEmpty())
- notifySelectionListeners(event);
- break;
- case SWT.MenuDetect:
- if(!menuDetectListeners.isEmpty())
- notifyMenuDetectListeners(event);
- break;
- }
+ compositeListener = event -> {
+ // Don't forward events if decoration is not showing
+ if(!visible) {
+ return;
+ }
+ // Notify listeners if any are registered.
+ switch(event.type) {
+ case SWT.MouseDown:
+ if(!selectionListeners.isEmpty())
+ notifySelectionListeners(event);
+ break;
+ case SWT.MouseDoubleClick:
+ if(!selectionListeners.isEmpty())
+ notifySelectionListeners(event);
+ break;
+ case SWT.MenuDetect:
+ if(!menuDetectListeners.isEmpty())
+ notifyMenuDetectListeners(event);
+ break;
}
};
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/M2EUIUtils.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/M2EUIUtils.java
index bec34e4f..fedf2762 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/M2EUIUtils.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/M2EUIUtils.java
@@ -67,15 +67,13 @@ public class M2EUIUtils {
public static void showErrorsForProjectsDialog(final Shell shell, final String title, final String message,
final Map<String, Throwable> errorMap) {
// TODO Auto-generated method showErrorsForProjectsDialog
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- String[] buttons = {IDialogConstants.OK_LABEL};
- int ok_button = 0;
- M2EErrorDialog errDialog = new M2EErrorDialog(shell, title, Dialog.getImage(Dialog.DLG_IMG_MESSAGE_ERROR),
- message, MessageDialog.ERROR, buttons, ok_button, errorMap);
- errDialog.create();
- errDialog.open();
- }
+ Display.getDefault().asyncExec(() -> {
+ String[] buttons = {IDialogConstants.OK_LABEL};
+ int ok_button = 0;
+ M2EErrorDialog errDialog = new M2EErrorDialog(shell, title, Dialog.getImage(Dialog.DLG_IMG_MESSAGE_ERROR),
+ message, MessageDialog.ERROR, buttons, ok_button, errorMap);
+ errDialog.create();
+ errDialog.open();
});
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
index a500be64..92da3ab0 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
@@ -26,15 +26,12 @@ import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -153,10 +150,8 @@ public class MavenRepositoryView extends ViewPart {
viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(labelProvider,
PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null));
- viewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
+ viewer.addDoubleClickListener(event -> {
- }
});
viewer.setInput(getViewSite());
drillDownAdapter = new DrillDownAdapter(viewer);
@@ -164,11 +159,7 @@ public class MavenRepositoryView extends ViewPart {
makeActions();
hookContextMenu();
- viewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- openPomAction.run();
- }
- });
+ viewer.addDoubleClickListener(event -> openPomAction.run());
contributeToActionBars();
this.indexListener = new IndexListener() {
@@ -186,11 +177,7 @@ public class MavenRepositoryView extends ViewPart {
}
public void indexUpdating(IRepository repository) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- viewer.refresh(true);
- }
- });
+ Display.getDefault().asyncExec(() -> viewer.refresh(true));
}
};
@@ -200,11 +187,9 @@ public class MavenRepositoryView extends ViewPart {
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu-" + MENU_ID); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- MavenRepositoryView.this.fillContextMenu(manager);
- manager.update();
- }
+ menuMgr.addMenuListener(manager -> {
+ MavenRepositoryView.this.fillContextMenu(manager);
+ manager.update();
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
@@ -376,12 +361,8 @@ public class MavenRepositoryView extends ViewPart {
: Messages.MavenRepositoryView_rebuild_msg2;
final boolean result[] = new boolean[1];
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- result[0] = MessageDialog.openConfirm(getViewSite().getShell(), title, msg);
- }
- });
+ Display.getDefault()
+ .syncExec(() -> result[0] = MessageDialog.openConfirm(getViewSite().getShell(), title, msg));
if(result[0]) {
SubMonitor mon = SubMonitor.convert(monitor, nodes.size());
try {
@@ -555,14 +536,12 @@ public class MavenRepositoryView extends ViewPart {
}
void refreshView() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Object[] expandedElems = viewer.getExpandedElements();
- if(!viewer.getControl().isDisposed()) {
- viewer.setInput(getViewSite());
- if(expandedElems != null && expandedElems.length > 0) {
- viewer.setExpandedElements(expandedElems);
- }
+ Display.getDefault().asyncExec(() -> {
+ Object[] expandedElems = viewer.getExpandedElements();
+ if(!viewer.getControl().isDisposed()) {
+ viewer.setInput(getViewSite());
+ if(expandedElems != null && expandedElems.length > 0) {
+ viewer.setExpandedElements(expandedElems);
}
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/build/BuildDebugView.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/build/BuildDebugView.java
index 81265573..b1e5e16f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/build/BuildDebugView.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/build/BuildDebugView.java
@@ -25,7 +25,6 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -63,14 +62,12 @@ import org.eclipse.m2e.core.ui.internal.Messages;
@SuppressWarnings("restriction")
public class BuildDebugView extends ViewPart implements BuildDebugHook {
- /*package*/static final Comparator<Node> NODE_COMPARATOR = new Comparator<Node>() {
- public int compare(Node p1, Node p2) {
- int d = p2.getBuildCount() - p1.getBuildCount();
- if(d != 0) {
- return d;
- }
- return p1.getName().compareTo(p2.getName());
+ /*package*/static final Comparator<Node> NODE_COMPARATOR = (p1, p2) -> {
+ int d = p2.getBuildCount() - p1.getBuildCount();
+ if(d != 0) {
+ return d;
}
+ return p1.getName().compareTo(p2.getName());
};
/*package*/TreeViewer viewer;
@@ -82,14 +79,7 @@ public class BuildDebugView extends ViewPart implements BuildDebugHook {
/*package*/final Job refreshJob = new Job("") {
protected IStatus run(IProgressMonitor monitor) {
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- viewer.refresh();
-// for(TreeColumn column : viewer.getTree().getColumns()) {
-// column.pack();
-// }
- }
- });
+ getSite().getShell().getDisplay().asyncExec(() -> viewer.refresh());
return Status.OK_STATUS;
}
};
@@ -273,16 +263,14 @@ public class BuildDebugView extends ViewPart implements BuildDebugHook {
try {
if(delta != null) {
- delta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) {
- if(delta.getAffectedChildren().length == 0) {
- IResource resource = delta.getResource();
- if(resource instanceof IFile || resource instanceof IFolder) {
- projectNode.addResource(resource.getProjectRelativePath()).setBuildCount(buildCount);
- }
+ delta.accept(delta1 -> {
+ if(delta1.getAffectedChildren().length == 0) {
+ IResource resource = delta1.getResource();
+ if(resource instanceof IFile || resource instanceof IFolder) {
+ projectNode.addResource(resource.getProjectRelativePath()).setBuildCount(buildCount);
}
- return true; // keep visiting
}
+ return true; // keep visiting
});
}
refreshJob.schedule(1000L);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/CustomArchetypeDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/CustomArchetypeDialog.java
index ddc5d3dc..ccbe4136 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/CustomArchetypeDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/CustomArchetypeDialog.java
@@ -21,7 +21,6 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -142,11 +141,7 @@ public class CustomArchetypeDialog extends TitleAreaDialog {
repositoryCombo.setItems(getSavedValues(KEY_REPOSITORY_URL));
repositoryCombo.setData("name", "repository"); //$NON-NLS-1$ //$NON-NLS-2$
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- update();
- }
- };
+ ModifyListener modifyListener = e -> update();
archetypeGroupIdCombo.addModifyListener(modifyListener);
archetypeArtifactIdCombo.addModifyListener(modifyListener);
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 5abda768..1f72360f 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
@@ -40,11 +40,9 @@ import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -444,34 +442,30 @@ public class LifecycleMappingPage extends WizardPage {
}
});
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- @SuppressWarnings("synthetic-access")
- public void selectionChanged(SelectionChangedEvent event) {
- if(event.getSelection() instanceof IStructuredSelection
- && ((IStructuredSelection) event.getSelection()).size() == 1) {
- ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) ((IStructuredSelection) event
- .getSelection()).getFirstElement();
- if(ignore.contains(prov)) {
- details.setText(Messages.LifecycleMappingPage_doNotExecutePomDescription);
- license.setText(EMPTY_STRING);
- } else if(ignoreAtDefinition.contains(prov)) {
- details.setText(Messages.LifecycleMappingPage_doNotExecuteParentDescription);
- license.setText(EMPTY_STRING);
- } else if(ignoreWorkspace.contains(prov)) {
- details.setText(Messages.LifecycleMappingPage_doNotExecuteWorkspaceDescription);
- license.setText(EMPTY_STRING);
- } else {
- IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey());
- details.setText(proposal != null ? proposal.getDescription()
- : mappingConfiguration.getProposals(prov.getKey()).isEmpty()
- ? NLS.bind(Messages.LifecycleMappingPage_noMarketplaceEntryDescription, prov.getMavenText())
- : EMPTY_STRING);
- license.setText(proposal == null ? EMPTY_STRING : proposal.getLicense());
- }
+ treeViewer.addSelectionChangedListener(event -> {
+ if(event.getSelection() instanceof IStructuredSelection
+ && ((IStructuredSelection) event.getSelection()).size() == 1) {
+ ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) ((IStructuredSelection) event
+ .getSelection()).getFirstElement();
+ if(ignore.contains(prov)) {
+ details.setText(Messages.LifecycleMappingPage_doNotExecutePomDescription);
+ license.setText(EMPTY_STRING);
+ } else if(ignoreAtDefinition.contains(prov)) {
+ details.setText(Messages.LifecycleMappingPage_doNotExecuteParentDescription);
+ license.setText(EMPTY_STRING);
+ } else if(ignoreWorkspace.contains(prov)) {
+ details.setText(Messages.LifecycleMappingPage_doNotExecuteWorkspaceDescription);
+ license.setText(EMPTY_STRING);
} else {
- resetDetails();
+ IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey());
+ details.setText(proposal != null ? proposal.getDescription()
+ : mappingConfiguration.getProposals(prov.getKey()).isEmpty()
+ ? NLS.bind(Messages.LifecycleMappingPage_noMarketplaceEntryDescription, prov.getMavenText())
+ : EMPTY_STRING);
+ license.setText(proposal == null ? EMPTY_STRING : proposal.getLicense());
}
+ } else {
+ resetDetails();
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MappingDiscoveryJob.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MappingDiscoveryJob.java
index b03ec3d2..67acbed8 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MappingDiscoveryJob.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MappingDiscoveryJob.java
@@ -70,13 +70,10 @@ public class MappingDiscoveryJob extends WorkspaceJob {
final MavenDiscoveryProposalWizard proposalWizard = new MavenDiscoveryProposalWizard(projects, discoveryRequest);
proposalWizard.init(null, null);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- final IWorkbench workbench = PlatformUI.getWorkbench();
- WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), proposalWizard);
- dialog.open();
- }
+ Display.getDefault().asyncExec(() -> {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), proposalWizard);
+ dialog.open();
});
}
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 e8bba957..7d5bd704 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
@@ -162,11 +162,9 @@ public class MavenDependenciesWizardPage extends AbstractMavenWizardPage {
}
});
- dependencyViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- removeDependencyButton.setEnabled(selection.size() > 0);
- }
+ dependencyViewer.addSelectionChangedListener(event -> {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ removeDependencyButton.setEnabled(selection.size() > 0);
});
}
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 7514e11d..88540e22 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
@@ -38,25 +38,19 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
-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.graphics.Color;
@@ -67,9 +61,7 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Tree;
@@ -186,15 +178,13 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
}
});
- rootDirectoryCombo.addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event e) {
- if(e.keyCode == SWT.CR && rootDirectoryChanged()) {
- //New location entered : don't finish the wizard
- if(e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
- scanProjects();
+ rootDirectoryCombo.addListener(SWT.Traverse, e -> {
+ if(e.keyCode == SWT.CR && rootDirectoryChanged()) {
+ //New location entered : don't finish the wizard
+ if(e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
}
+ scanProjects();
}
});
@@ -215,11 +205,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
public void widgetSelected(SelectionEvent e) {
if(rootDirectoryChanged()) {
//in runnable to have the combo popup collapse before disabling controls.
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- scanProjects();
- }
- });
+ Display.getDefault().asyncExec(() -> scanProjects());
}
}
});
@@ -231,31 +217,26 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
projectTreeViewer = new CheckboxTreeViewer(composite, SWT.BORDER);
- projectTreeViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- updateCheckedState();
- setPageComplete();
- }
+ projectTreeViewer.addCheckStateListener(event -> {
+ updateCheckedState();
+ setPageComplete();
});
- projectTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- btnSelectTree.setEnabled(!selection.isEmpty());
- btnDeselectTree.setEnabled(!selection.isEmpty());
- if(selection.getFirstElement() != null) {
- String errorMsg = validateProjectInfo((MavenProjectInfo) selection.getFirstElement());
- if(errorMsg != null) {
- setMessage(errorMsg, IMessageProvider.WARNING);
- } else {
- //TODO if no error on current, shall show any existing general errors if found..
- setMessage(loadingErrorMessage, IMessageProvider.WARNING);
- }
+ projectTreeViewer.addSelectionChangedListener(event -> {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ btnSelectTree.setEnabled(!selection.isEmpty());
+ btnDeselectTree.setEnabled(!selection.isEmpty());
+ if(selection.getFirstElement() != null) {
+ String errorMsg = validateProjectInfo((MavenProjectInfo) selection.getFirstElement());
+ if(errorMsg != null) {
+ setMessage(errorMsg, IMessageProvider.WARNING);
} else {
- //TODO if on current selection, shall show any existing general errors if existing..
+ //TODO if no error on current, shall show any existing general errors if found..
setMessage(loadingErrorMessage, IMessageProvider.WARNING);
}
+ } else {
+ //TODO if on current selection, shall show any existing general errors if existing..
+ setMessage(loadingErrorMessage, IMessageProvider.WARNING);
}
});
@@ -408,15 +389,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
workingSetName.setLayoutData(gd_workingSet);
createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
- resolverConfigurationComponent.template.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent arg0) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- validate();
- }
- });
- }
- });
+ resolverConfigurationComponent.template.addModifyListener(arg0 -> Display.getDefault().asyncExec(() -> validate()));
if(locations != null && !locations.isEmpty()) {
scanProjects();
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 545f4a45..5d12f9bf 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
@@ -21,7 +21,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -86,11 +85,7 @@ public class MavenInstallFileArtifactWizardPage extends WizardPage {
container.setLayout(new GridLayout(3, false));
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- ModifyListener modifyingListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- pageChanged();
- }
- };
+ ModifyListener modifyingListener = e -> pageChanged();
Label artifactFileNameLabel = new Label(container, SWT.NONE);
artifactFileNameLabel.setText(Messages.MavenInstallFileArtifactWizardPage_lblFileName);
@@ -98,11 +93,9 @@ public class MavenInstallFileArtifactWizardPage extends WizardPage {
artifactFileNameText = new Text(container, SWT.BORDER);
artifactFileNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
artifactFileNameText.setData("name", "artifactFileNametext"); //$NON-NLS-1$ //$NON-NLS-2$
- artifactFileNameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateFileName(getArtifactFileName());
- pageChanged();
- }
+ artifactFileNameText.addModifyListener(e -> {
+ updateFileName(getArtifactFileName());
+ pageChanged();
});
final Button artifactFileNameButton = new Button(container, SWT.NONE);
@@ -127,11 +120,9 @@ public class MavenInstallFileArtifactWizardPage extends WizardPage {
pomFileNameText = new Text(container, SWT.BORDER);
pomFileNameText.setData("name", "pomFileNameText"); //$NON-NLS-1$ //$NON-NLS-2$
pomFileNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- pomFileNameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- generatePomButton.setSelection(getPomFileName().length() == 0);
- pageChanged();
- }
+ pomFileNameText.addModifyListener(e -> {
+ generatePomButton.setSelection(getPomFileName().length() == 0);
+ pageChanged();
});
final Button pomFileNameButton = new Button(container, SWT.NONE);
@@ -220,11 +211,7 @@ public class MavenInstallFileArtifactWizardPage extends WizardPage {
GridData classifierTextData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
classifierTextData.widthHint = 150;
classifierCombo.setLayoutData(classifierTextData);
- classifierCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- generatePomButton.setSelection(getClassifier().length() == 0);
- }
- });
+ classifierCombo.addModifyListener(e -> generatePomButton.setSelection(getClassifier().length() == 0));
if(file != null) {
updateFileName(file.getLocation().toOSString());
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 00bf9122..c573c612 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
@@ -25,7 +25,6 @@ import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.eclipse.core.resources.IFile;
@@ -39,11 +38,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.osgi.util.NLS;
-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.widgets.Composite;
@@ -129,24 +124,16 @@ public class MavenModuleWizard extends AbstractMavenProjectWizard implements INe
}
});
- parentPage.addModuleNameListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- parametersPage.setProjectName(parentPage.getModuleName());
- artifactPage.setProjectName(parentPage.getModuleName());
- }
+ parentPage.addModuleNameListener(e -> {
+ parametersPage.setProjectName(parentPage.getModuleName());
+ artifactPage.setProjectName(parentPage.getModuleName());
});
- parentPage.addParentProjectListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- copyParentValues();
- }
- });
+ parentPage.addParentProjectListener(e -> copyParentValues());
- archetypePage.addArchetypeSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent selectionchangedevent) {
- parametersPage.setArchetype(archetypePage.getArchetype());
- getContainer().updateButtons();
- }
+ archetypePage.addArchetypeSelectionListener(selectionchangedevent -> {
+ parametersPage.setArchetype(archetypePage.getArchetype());
+ getContainer().updateButtons();
});
if(selection != null && selection.size() > 0) {
@@ -273,13 +260,11 @@ public class MavenModuleWizard extends AbstractMavenProjectWizard implements INe
if(!isEditor) {
//add the <module> element to the parent pom
try {
- performOnDOMDocument(new OperationTuple(parentPom, new Operation() {
- public void process(Document document) {
- Element root = document.getDocumentElement();
- Element modules = getChild(root, "modules"); //$NON-NLS-1$
- if(findChild(modules, "module", textEquals(moduleName)) == null) { //$NON-NLS-1$
- format(createElementWithText(modules, "module", moduleName)); //$NON-NLS-1$
- }
+ performOnDOMDocument(new OperationTuple(parentPom, (Operation) document -> {
+ Element root = document.getDocumentElement();
+ Element modules = getChild(root, "modules"); //$NON-NLS-1$
+ if(findChild(modules, "module", textEquals(moduleName)) == null) { //$NON-NLS-1$
+ format(createElementWithText(modules, "module", moduleName)); //$NON-NLS-1$
}
}));
} catch(Exception e) {
@@ -288,13 +273,9 @@ public class MavenModuleWizard extends AbstractMavenProjectWizard implements INe
}
} else {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openError(getShell(), //
- NLS.bind(Messages.wizardProjectJobFailed, moduleName), //
- result.getMessage());
- }
- });
+ Display.getDefault().asyncExec(() -> MessageDialog.openError(getShell(), //
+ NLS.bind(Messages.wizardProjectJobFailed, moduleName), //
+ result.getMessage()));
}
}
});
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 3c6e6d88..dca4bdc7 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
@@ -27,7 +27,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -119,11 +118,7 @@ public class MavenModuleWizardParentPage extends AbstractMavenWizardPage {
GridData gd_moduleNameCombo = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
gd_moduleNameCombo.verticalIndent = 10;
moduleNameCombo.setLayoutData(gd_moduleNameCombo);
- moduleNameCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
+ moduleNameCombo.addModifyListener(e -> validate());
addFieldWithHistory("moduleName", moduleNameCombo); //$NON-NLS-1$
Label parentLabel = new Label(container, SWT.NONE);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
index db51dc18..f27ca231 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
@@ -50,8 +50,6 @@ import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -168,11 +166,7 @@ public class MavenPomSelectionComponent extends Composite {
}
});
- searchText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- scheduleSearch(searchText.getText(), true);
- }
- });
+ searchText.addModifyListener(e -> scheduleSearch(searchText.getText(), true));
if(!MavenPlugin.getMavenConfiguration().isUpdateIndexesOnStartup()) {
createWarningArea(this);
@@ -272,38 +266,34 @@ public class MavenPomSelectionComponent extends Composite {
decoratingLabelProvider.setDecorationContext(decorationContext);
searchResultViewer.setLabelProvider(decoratingLabelProvider);
- searchResultViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- if(!selection.isEmpty()) {
- List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles(selection);
+ searchResultViewer.addSelectionChangedListener(event -> {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if(!selection.isEmpty()) {
+ List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles(selection);
- ArtifactFilterManager filterManager = MavenPluginActivator.getDefault().getArifactFilterManager();
+ ArtifactFilterManager filterManager = MavenPluginActivator.getDefault().getArifactFilterManager();
- for(IndexedArtifactFile file : files) {
- ArtifactKey key = file.getAdapter(ArtifactKey.class);
- IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
- if(!status.isOK()) {
- setStatus(IStatus.ERROR, status.getMessage());
- return; // TODO not nice to exit method like this
- }
+ for(IndexedArtifactFile file : files) {
+ ArtifactKey key = file.getAdapter(ArtifactKey.class);
+ IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
+ if(!status.isOK()) {
+ setStatus(IStatus.ERROR, status.getMessage());
+ return; // TODO not nice to exit method like this
}
+ }
- if(files.size() == 1) {
- IndexedArtifactFile f = files.get(0);
- // int severity = artifactKeys.contains(f.group + ":" + f.artifact) ? IStatus.ERROR : IStatus.OK;
- int severity = IStatus.OK;
- String date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(f.date);
- setStatus(
- severity,
- NLS.bind(Messages.MavenPomSelectionComponent_detail1, f.fname,
- (f.size != -1 ? NLS.bind(Messages.MavenPomSelectionComponent_details2, date, f.size) : date)));
- } else {
- setStatus(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_selected, selection.size()));
- }
+ if(files.size() == 1) {
+ IndexedArtifactFile f = files.get(0);
+ // int severity = artifactKeys.contains(f.group + ":" + f.artifact) ? IStatus.ERROR : IStatus.OK;
+ int severity = IStatus.OK;
+ String date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(f.date);
+ setStatus(severity, NLS.bind(Messages.MavenPomSelectionComponent_detail1, f.fname,
+ (f.size != -1 ? NLS.bind(Messages.MavenPomSelectionComponent_details2, date, f.size) : date)));
} else {
- setStatus(IStatus.ERROR, Messages.MavenPomSelectionComponent_nosel);
+ setStatus(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_selected, selection.size()));
}
+ } else {
+ setStatus(IStatus.ERROR, Messages.MavenPomSelectionComponent_nosel);
}
});
setupClassifiers();
@@ -502,13 +492,11 @@ public class MavenPomSelectionComponent extends Composite {
private void setResult(final int severity, final String message, final Map<String, IndexedArtifact> result) {
if(stop)
return;
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- setStatus(severity, message);
- if(result != null) {
- if(!searchResultViewer.getControl().isDisposed()) {
- searchResultViewer.setInput(result);
- }
+ Display.getDefault().syncExec(() -> {
+ setStatus(severity, message);
+ if(result != null) {
+ if(!searchResultViewer.getControl().isDisposed()) {
+ searchResultViewer.setInput(result);
}
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
index 5795bb50..84386952 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
@@ -86,17 +86,15 @@ public class MavenPomWizard extends Wizard implements INewWizard {
final String projectName = artifactPage.getProject();
final Model model = artifactPage.getModel();
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- monitor.beginTask(Messages.MavenPomWizard_task, 1);
- try {
- doFinish(projectName, model, monitor);
- monitor.worked(1);
- } catch(CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
+ IRunnableWithProgress op = monitor -> {
+ monitor.beginTask(Messages.MavenPomWizard_task, 1);
+ try {
+ doFinish(projectName, model, monitor);
+ monitor.worked(1);
+ } catch(CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
}
};
@@ -144,13 +142,11 @@ public class MavenPomWizard extends Wizard implements INewWizard {
MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
modelManager.createMavenModel(file, model);
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try {
- IDE.openEditor(page, file, true);
- } catch(PartInitException e) {
- }
+ getShell().getDisplay().asyncExec(() -> {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, true);
+ } catch(PartInitException e) {
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizardPage.java
index e57d4cf6..003a8ae5 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizardPage.java
@@ -21,7 +21,6 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -65,11 +64,7 @@ public class MavenPomWizardPage extends AbstractMavenWizardPage {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(layout);
- ModifyListener modifyingListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- };
+ ModifyListener modifyingListener = e -> dialogChanged();
Label label = new Label(container, SWT.NULL);
label.setText(Messages.MavenPomWizardPage_lblProject);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectSelectionDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectSelectionDialog.java
index 7393f62f..1c8f5950 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectSelectionDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectSelectionDialog.java
@@ -24,8 +24,6 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
@@ -109,11 +107,7 @@ public class MavenProjectSelectionDialog extends AbstractMavenDialog {
getViewer().setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
getViewer().setInput(ResourcesPlugin.getWorkspace());
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- okPressed();
- }
- });
+ getViewer().addDoubleClickListener(event -> okPressed());
return composite;
}
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 152fa268..0187798f 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
@@ -26,8 +26,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -148,11 +146,9 @@ public class MavenProjectWizard extends AbstractMavenProjectWizard implements IN
}
});
- archetypePage.addArchetypeSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent selectionchangedevent) {
- parametersPage.setArchetype(archetypePage.getArchetype());
- getContainer().updateButtons();
- }
+ archetypePage.addArchetypeSelectionListener(selectionchangedevent -> {
+ parametersPage.setArchetype(archetypePage.getArchetype());
+ getContainer().updateButtons();
});
// locationPage.addProjectNameListener(new ModifyListener() {
@@ -251,12 +247,8 @@ public class MavenProjectWizard extends AbstractMavenProjectWizard implements IN
public void done(IJobChangeEvent event) {
final IStatus result = event.getResult();
if(!result.isOK()) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openError(getShell(), //
- NLS.bind(Messages.wizardProjectJobFailed, projectName), result.getMessage());
- }
- });
+ Display.getDefault().asyncExec(() -> MessageDialog.openError(getShell(), //
+ NLS.bind(Messages.wizardProjectJobFailed, projectName), result.getMessage()));
}
MappingDiscoveryJob discoveryJob = new MappingDiscoveryJob(job.getCreatedProjects());
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 aa5ecdf1..ab3a370e 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
@@ -34,18 +34,14 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -114,31 +110,27 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
private static final String ALL_CATALOGS = org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_all;
- public static final Comparator<Archetype> ARCHETYPE_COMPARATOR = new Comparator<Archetype>() {
-
- public int compare(Archetype a1, Archetype a2) {
- String g1 = a1.getGroupId();
- String g2 = a2.getGroupId();
- int res = g1.compareTo(g2);
- if(res != 0) {
- return res;
- }
-
- String i1 = a1.getArtifactId();
- String i2 = a2.getArtifactId();
- res = i1.compareTo(i2);
- if(res != 0) {
- return res;
- }
+ public static final Comparator<Archetype> ARCHETYPE_COMPARATOR = (a1, a2) -> {
+ String g1 = a1.getGroupId();
+ String g2 = a2.getGroupId();
+ int res = g1.compareTo(g2);
+ if(res != 0) {
+ return res;
+ }
- String v1 = a1.getVersion();
- String v2 = a2.getVersion();
- if(v1 == null) {
- return v2 == null ? 0 : -1;
- }
- return v1.compareTo(v2);
+ String i1 = a1.getArtifactId();
+ String i2 = a2.getArtifactId();
+ res = i1.compareTo(i2);
+ if(res != 0) {
+ return res;
}
+ String v1 = a1.getVersion();
+ String v2 = a2.getVersion();
+ if(v1 == null) {
+ return v2 == null ? 0 : -1;
+ }
+ return v1.compareTo(v2);
};
private static final boolean DEFAULT_SHOW_LAST_VERSION = true;
@@ -247,40 +239,38 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
});
- catalogsComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- boolean loadAll = false;
- //hide previous archetypes when switching catalog
- if(selection instanceof IStructuredSelection) {
- Object factory = ((IStructuredSelection) selection).getFirstElement();
- ArchetypeCatalogFactory newCatalogFactory = null;
- if(factory instanceof ArchetypeCatalogFactory) {
- newCatalogFactory = (ArchetypeCatalogFactory) factory;
- }
- if(factory != null && newCatalogFactory == null) {
- loadAll = true;
- } else if(Objects.equals(catalogFactory, newCatalogFactory) && viewer.getInput() != null) {
- return;
- }
- catalogFactory = newCatalogFactory;
- viewer.setInput(null);
- reloadViewer();
- } else {
- loadAll = true;
- }
- if(loadAll) {
- catalogFactory = null;
- viewer.setInput(null);
- loadArchetypes(null, null, null);
+ catalogsComboViewer.addSelectionChangedListener(event -> {
+ ISelection selection = event.getSelection();
+ boolean loadAll = false;
+ //hide previous archetypes when switching catalog
+ if(selection instanceof IStructuredSelection) {
+ Object factory = ((IStructuredSelection) selection).getFirstElement();
+ ArchetypeCatalogFactory newCatalogFactory = null;
+ if(factory instanceof ArchetypeCatalogFactory) {
+ newCatalogFactory = (ArchetypeCatalogFactory) factory;
}
- //remember what was switched to here
- if(dialogSettings != null) {
- if(catalogFactory != null)
- dialogSettings.put(KEY_CATALOG, catalogFactory.getId());
- else
- dialogSettings.put(KEY_CATALOG, ALL_CATALOGS);
+ if(factory != null && newCatalogFactory == null) {
+ loadAll = true;
+ } else if(Objects.equals(catalogFactory, newCatalogFactory) && viewer.getInput() != null) {
+ return;
}
+ catalogFactory = newCatalogFactory;
+ viewer.setInput(null);
+ reloadViewer();
+ } else {
+ loadAll = true;
+ }
+ if(loadAll) {
+ catalogFactory = null;
+ viewer.setInput(null);
+ loadArchetypes(null, null, null);
+ }
+ //remember what was switched to here
+ if(dialogSettings != null) {
+ if(catalogFactory != null)
+ dialogSettings.put(KEY_CATALOG, catalogFactory.getId());
+ else
+ dialogSettings.put(KEY_CATALOG, ALL_CATALOGS);
}
});
@@ -360,11 +350,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
});
- filterText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- clearToolItem.setEnabled(filterText.getText().length() > 0);
- }
- });
+ filterText.addModifyListener(e -> clearToolItem.setEnabled(filterText.getText().length() > 0));
SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
GridData gd_sashForm = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1);
@@ -443,34 +429,30 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
});
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Archetype archetype = getArchetype();
- if(archetype != null) {
- String repositoryUrl = archetype.getRepository();
- String description = archetype.getDescription();
-
- String text = description == null ? "" : description; //$NON-NLS-1$
- text = text.replaceAll("\n", "").replaceAll("\\s{2,}", " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ viewer.addSelectionChangedListener(event -> {
+ Archetype archetype = getArchetype();
+ if(archetype != null) {
+ String repositoryUrl = archetype.getRepository();
+ String description = archetype.getDescription();
- if(repositoryUrl != null) {
- text += text.length() > 0 ? "\n" + repositoryUrl : repositoryUrl; //$NON-NLS-1$
- }
+ String text = description == null ? "" : description; //$NON-NLS-1$
+ text = text.replaceAll("\n", "").replaceAll("\\s{2,}", " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- descriptionText.setText(text);
- setPageComplete(true);
- } else {
- descriptionText.setText(""); //$NON-NLS-1$
- setPageComplete(false);
+ if(repositoryUrl != null) {
+ text += text.length() > 0 ? "\n" + repositoryUrl : repositoryUrl; //$NON-NLS-1$
}
+
+ descriptionText.setText(text);
+ setPageComplete(true);
+ } else {
+ descriptionText.setText(""); //$NON-NLS-1$
+ setPageComplete(false);
}
});
- viewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent openevent) {
- if(canFlipToNextPage()) {
- getContainer().showPage(getNextPage());
- }
+ viewer.addOpenListener(openevent -> {
+ if(canFlipToNextPage()) {
+ getContainer().showPage(getNextPage());
}
});
@@ -645,22 +627,14 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
error = null;
}
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- setErrorMessage(error);
- }
- });
+ Display.getDefault().asyncExec(() -> setErrorMessage(error));
TreeSet<Archetype> archs = new TreeSet<Archetype>(ARCHETYPE_COMPARATOR);
if(catalogArchetypes != null) {
archs.addAll(catalogArchetypes);
}
archetypes = archs;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- updateViewer(groupId, artifactId, version);
- }
- });
+ Display.getDefault().asyncExec(() -> updateViewer(groupId, artifactId, version));
}
});
job.schedule();
@@ -774,11 +748,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
versions.add(v);
}
- final Comparator<ArtifactVersion> comparator = new Comparator<ArtifactVersion>() {
- public int compare(ArtifactVersion v1, ArtifactVersion v2) {
- return v2.compareTo(v1);
- }
- };
+ final Comparator<ArtifactVersion> comparator = (v1, v2) -> v2.compareTo(v1);
for(List<ArtifactVersion> versions : archetypeVersions.values()) {
Collections.sort(versions, comparator);
@@ -818,102 +788,92 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
final String archetypeName = archetypeGroupId + ":" + archetypeArtifactId + ":" + archetypeVersion; //$NON-NLS-1$ //$NON-NLS-2$
try {
- getContainer().run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException {
- monitor.beginTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_downloading
- + archetypeName, IProgressMonitor.UNKNOWN);
-
- try {
- final IMaven maven = MavenPlugin.getMaven();
-
- final List<ArtifactRepository> remoteRepositories;
- if(repositoryUrl.length() == 0) {
- remoteRepositories = maven.getArtifactRepositories(); // XXX should use ArchetypeManager.getArchetypeRepositories()
- } else {
- //Use id = archetypeArtifactId+"-repo" to enable mirror/proxy authentication
- //see http://maven.apache.org/archetype/maven-archetype-plugin/faq.html
- ArtifactRepository repository = maven.createArtifactRepository(archetypeArtifactId + "-repo", //$NON-NLS-1$
- repositoryUrl);
-
- remoteRepositories = Collections.singletonList(repository);
- }
+ getContainer().run(true, true, monitor -> {
+ monitor.beginTask(
+ org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_downloading + archetypeName,
+ IProgressMonitor.UNKNOWN);
+
+ try {
+ final IMaven maven = MavenPlugin.getMaven();
- monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_resolving);
- Artifact pomArtifact = maven.resolve(archetypeGroupId, archetypeArtifactId, archetypeVersion, "pom", null, //$NON-NLS-1$
+ final List<ArtifactRepository> remoteRepositories;
+ if(repositoryUrl.length() == 0) {
+ remoteRepositories = maven.getArtifactRepositories(); // XXX should use ArchetypeManager.getArchetypeRepositories()
+ } else {
+ //Use id = archetypeArtifactId+"-repo" to enable mirror/proxy authentication
+ //see http://maven.apache.org/archetype/maven-archetype-plugin/faq.html
+ ArtifactRepository repository = maven.createArtifactRepository(archetypeArtifactId + "-repo", //$NON-NLS-1$
+ repositoryUrl);
+
+ remoteRepositories = Collections.singletonList(repository);
+ }
+
+ monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_resolving);
+ Artifact pomArtifact = maven.resolve(archetypeGroupId, archetypeArtifactId, archetypeVersion, "pom", null, //$NON-NLS-1$
+ remoteRepositories, monitor);
+ monitor.worked(1);
+ if(monitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+
+ File pomFile = pomArtifact.getFile();
+ if(pomFile.exists()) {
+ monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_resolving2);
+ Artifact jarArtifact = maven.resolve(archetypeGroupId, archetypeArtifactId, archetypeVersion, "jar", null, //$NON-NLS-1$
remoteRepositories, monitor);
monitor.worked(1);
if(monitor.isCanceled()) {
throw new InterruptedException();
}
- File pomFile = pomArtifact.getFile();
- if(pomFile.exists()) {
- monitor
- .subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_resolving2);
- Artifact jarArtifact = maven.resolve(archetypeGroupId, archetypeArtifactId, archetypeVersion, "jar", null, //$NON-NLS-1$
- remoteRepositories, monitor);
- monitor.worked(1);
- if(monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- File jarFile = jarArtifact.getFile();
-
- monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_reading);
- monitor.worked(1);
- if(monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_indexing);
- IndexManager indexManager = MavenPlugin.getIndexManager();
- IMutableIndex localIndex = indexManager.getLocalIndex();
- localIndex.addArtifact(jarFile, new ArtifactKey(pomArtifact));
-
- //save out the archetype
- //TODO move this logic out of UI code!
- Archetype archetype = new Archetype();
- archetype.setGroupId(archetypeGroupId);
- archetype.setArtifactId(archetypeArtifactId);
- archetype.setVersion(archetypeVersion);
- archetype.setRepository(repositoryUrl);
- org.apache.maven.archetype.ArchetypeManager archetyper = MavenPluginActivator.getDefault()
- .getArchetypeManager().getArchetyper();
- archetyper.updateLocalCatalog(archetype);
-
- archetypesCache.clear();
-
- loadArchetypes(archetypeGroupId, archetypeArtifactId, archetypeVersion);
- } else {
- final Artifact pom = pomArtifact;
- //the user tried to add an archetype that couldn't be resolved on the server
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- setErrorMessage(
- NLS.bind(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_error_resolve,
- pom.toString()));
- }
- });
+ File jarFile = jarArtifact.getFile();
+
+ monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_reading);
+ monitor.worked(1);
+ if(monitor.isCanceled()) {
+ throw new InterruptedException();
}
- } catch(InterruptedException ex) {
- throw ex;
+ monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_indexing);
+ IndexManager indexManager = MavenPlugin.getIndexManager();
+ IMutableIndex localIndex = indexManager.getLocalIndex();
+ localIndex.addArtifact(jarFile, new ArtifactKey(pomArtifact));
+
+ //save out the archetype
+ //TODO move this logic out of UI code!
+ Archetype archetype = new Archetype();
+ archetype.setGroupId(archetypeGroupId);
+ archetype.setArtifactId(archetypeArtifactId);
+ archetype.setVersion(archetypeVersion);
+ archetype.setRepository(repositoryUrl);
+ org.apache.maven.archetype.ArchetypeManager archetyper = MavenPluginActivator.getDefault()
+ .getArchetypeManager().getArchetyper();
+ archetyper.updateLocalCatalog(archetype);
+
+ archetypesCache.clear();
+
+ loadArchetypes(archetypeGroupId, archetypeArtifactId, archetypeVersion);
+ } else {
+ final Artifact pom = pomArtifact;
+ //the user tried to add an archetype that couldn't be resolved on the server
+ getShell().getDisplay()
+ .asyncExec(() -> setErrorMessage(
+ NLS.bind(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_error_resolve,
+ pom.toString())));
+ }
- } catch(final Exception ex) {
- final String msg = NLS.bind(
- org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_error_resolve2,
- archetypeName);
- log.error(msg, ex);
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- setErrorMessage(msg + "\n" + ex.toString()); //$NON-NLS-1$
- }
- });
+ } catch(InterruptedException ex1) {
+ throw ex1;
- } finally {
- monitor.done();
+ } catch(final Exception ex2) {
+ final String msg = NLS.bind(
+ org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_error_resolve2, archetypeName);
+ log.error(msg, ex2);
+ getShell().getDisplay().asyncExec(() -> setErrorMessage(msg + "\n" + ex2.toString()));
+
+ } finally {
+ monitor.done();
- }
}
});
@@ -1056,19 +1016,17 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
//reload the table when index updating finishes
//try to preserve selection in case this is a rebuild
protected void reloadViewer() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if(isCurrentPage()) {
- StructuredSelection sel = (StructuredSelection) viewer.getSelection();
- Archetype selArchetype = null;
- if(sel != null && sel.getFirstElement() != null) {
- selArchetype = (Archetype) sel.getFirstElement();
- }
- if(selArchetype != null) {
- loadArchetypes(selArchetype.getGroupId(), selArchetype.getArtifactId(), selArchetype.getVersion());
- } else {
- loadArchetypes("org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
+ Display.getDefault().asyncExec(() -> {
+ if(isCurrentPage()) {
+ StructuredSelection sel = (StructuredSelection) viewer.getSelection();
+ Archetype selArchetype = null;
+ if(sel != null && sel.getFirstElement() != null) {
+ selArchetype = (Archetype) sel.getFirstElement();
+ }
+ if(selArchetype != null) {
+ loadArchetypes(selArchetype.getGroupId(), selArchetype.getArtifactId(), selArchetype.getVersion());
+ } else {
+ loadArchetypes("org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
});
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 8e78361c..d7e4b87d 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
@@ -38,8 +38,6 @@ import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -141,11 +139,7 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
validate();
createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
- resolverConfigurationComponent.setModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
+ resolverConfigurationComponent.setModifyListener(e -> validate());
setControl(composite);
@@ -164,11 +158,9 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
groupIdCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
addFieldWithHistory("groupId", groupIdCombo); //$NON-NLS-1$
groupIdCombo.setData("name", "groupId"); //$NON-NLS-1$ //$NON-NLS-2$
- groupIdCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateJavaPackage();
- validate();
- }
+ groupIdCombo.addModifyListener(e -> {
+ updateJavaPackage();
+ validate();
});
Label artifactIdLabel = new Label(parent, SWT.NONE);
@@ -178,11 +170,9 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
artifactIdCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
addFieldWithHistory("artifactId", artifactIdCombo); //$NON-NLS-1$
artifactIdCombo.setData("name", "artifactId"); //$NON-NLS-1$ //$NON-NLS-2$
- artifactIdCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateJavaPackage();
- validate();
- }
+ artifactIdCombo.addModifyListener(e -> {
+ updateJavaPackage();
+ validate();
});
Label versionLabel = new Label(parent, SWT.NONE);
@@ -194,11 +184,7 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
versionCombo.setLayoutData(gd_versionCombo);
versionCombo.setText(DEFAULT_VERSION);
addFieldWithHistory("version", versionCombo); //$NON-NLS-1$
- versionCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
+ versionCombo.addModifyListener(e -> validate());
Label packageLabel = new Label(parent, SWT.NONE);
packageLabel.setText(Messages.artifactComponentPackage);
@@ -207,13 +193,11 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
packageCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
packageCombo.setData("name", "package"); //$NON-NLS-1$ //$NON-NLS-2$
addFieldWithHistory("package", packageCombo); //$NON-NLS-1$
- packageCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if(!packageCustomized && !packageCombo.getText().equals(getDefaultJavaPackage())) {
- packageCustomized = true;
- }
- validate();
+ packageCombo.addModifyListener(e -> {
+ if(!packageCustomized && !packageCombo.getText().equals(getDefaultJavaPackage())) {
+ packageCustomized = true;
}
+ validate();
});
}
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 9e22ce6c..ce10e6be 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
@@ -17,7 +17,6 @@ import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -129,11 +128,7 @@ public class MavenProjectWizardArtifactPage extends AbstractMavenWizardPage {
WidthGroup widthGroup = new WidthGroup();
container.addControlListener(widthGroup);
- ModifyListener modifyingListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
+ ModifyListener modifyingListener = e -> validate();
artifactComponent = new MavenArtifactComponent(container, SWT.NONE);
artifactComponent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
@@ -162,11 +157,7 @@ public class MavenProjectWizardArtifactPage extends AbstractMavenWizardPage {
});
createAdvancedSettings(container, new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
- resolverConfigurationComponent.setModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
+ resolverConfigurationComponent.setModifyListener(e -> validate());
addFieldWithHistory("groupId", artifactComponent.getGroupIdCombo()); //$NON-NLS-1$
addFieldWithHistory("artifactId", artifactComponent.getArtifactIdCombo()); //$NON-NLS-1$
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 7c0128a1..7ff53244 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
@@ -20,8 +20,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -123,11 +121,7 @@ public class MavenProjectWizardLocationPage extends AbstractMavenWizardPage {
locationCombo = new Combo(container, SWT.NONE);
GridData locationComboData = new GridData(SWT.FILL, SWT.CENTER, true, false);
locationCombo.setLayoutData(locationComboData);
- locationCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
+ locationCombo.addModifyListener(e -> validate());
locationCombo.setEnabled(false);
addFieldWithHistory("location", locationCombo); //$NON-NLS-1$
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 99f23c62..07fd0595 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
@@ -12,7 +12,6 @@
package org.eclipse.m2e.core.ui.internal.wizards;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -101,11 +100,7 @@ public class ResolverConfigurationComponent extends ExpandableComposite {
profiles = new Text(advancedComposite, SWT.BORDER);
profiles.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- profiles.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- resolverConfiguration.setSelectedProfiles(profiles.getText());
- }
- });
+ profiles.addModifyListener(e -> resolverConfiguration.setSelectedProfiles(profiles.getText()));
if(enableProjectNameTemplate) {
Label templateLabel = new Label(advancedComposite, SWT.NONE);
@@ -116,11 +111,7 @@ public class ResolverConfigurationComponent extends ExpandableComposite {
template.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
template.setToolTipText(Messages.resolverConfigurationTemplateDescription);
template.setItems(DEFAULT_NAME_TEMPLATES);
- template.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- propectImportConfiguration.setProjectNameTemplate(template.getText());
- }
- });
+ template.addModifyListener(e -> propectImportConfiguration.setProjectNameTemplate(template.getText()));
}
loadData();
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
index faf149ed..09c28854 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
@@ -14,7 +14,6 @@ package org.eclipse.m2e.core.internal;
import java.io.File;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -136,12 +135,7 @@ public class MavenPluginActivator extends Plugin {
private IMavenConfiguration mavenConfiguration;
- private BundleListener bundleListener = new BundleListener() {
-
- public void bundleChanged(BundleEvent event) {
- LifecycleMappingFactory.setBundleMetadataSources(null);
- }
- };
+ private BundleListener bundleListener = event -> LifecycleMappingFactory.setBundleMetadataSources(null);
private ISaveParticipant saveParticipant = new ISaveParticipant() {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
index 7a9864c3..ab5e5cd7 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
@@ -29,7 +29,6 @@ import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@@ -41,7 +40,6 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalCause;
import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
@@ -333,30 +331,26 @@ public class ProjectRegistryManager {
// safety net -- do not force refresh of the same installed/resolved artifact more than once
final Set<ArtifactKey> installedArtifacts = new HashSet<ArtifactKey>();
- ILocalRepositoryListener listener = new ILocalRepositoryListener() {
- public void artifactInstalled(File repositoryBasedir, ArtifactKey baseArtifact, ArtifactKey artifact,
- File artifactFile) {
- if(artifactFile == null) {
- // resolution error
- return;
- }
- // TODO remove=false?
- Set<IFile> refresh = new LinkedHashSet<IFile>();
- if(installedArtifacts.add(artifact)) {
- refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(artifact), true));
- refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(artifact), true));
- refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(artifact), true));
- }
- if(installedArtifacts.add(baseArtifact)) {
- refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(baseArtifact), true));
- refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(baseArtifact), true));
- refresh
- .addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(baseArtifact), true));
- }
- if(!refresh.isEmpty()) {
- log.debug("Automatic refresh. artifact={}/{}. projects={}", new Object[] {baseArtifact, artifact, refresh});
- context.forcePomFiles(refresh);
- }
+ ILocalRepositoryListener listener = (repositoryBasedir, baseArtifact, artifact, artifactFile) -> {
+ if(artifactFile == null) {
+ // resolution error
+ return;
+ }
+ // TODO remove=false?
+ Set<IFile> refresh = new LinkedHashSet<IFile>();
+ if(installedArtifacts.add(artifact)) {
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(artifact), true));
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(artifact), true));
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(artifact), true));
+ }
+ if(installedArtifacts.add(baseArtifact)) {
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(baseArtifact), true));
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(baseArtifact), true));
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(baseArtifact), true));
+ }
+ if(!refresh.isEmpty()) {
+ log.debug("Automatic refresh. artifact={}/{}. projects={}", new Object[] {baseArtifact, artifact, refresh});
+ context.forcePomFiles(refresh);
}
};
@@ -1064,11 +1058,8 @@ public class ProjectRegistryManager {
mavenProject = mavenProjects.get(facade);
if(mavenProject == null) {
try {
- mavenProject = mavenProjectCache.get(facade, new Callable<MavenProject>() {
- public MavenProject call() throws Exception {
- return readProjectWithDependencies(facade.getPom(), facade.getResolverConfiguration(), monitor);
- }
- });
+ mavenProject = mavenProjectCache.get(facade,
+ () -> readProjectWithDependencies(facade.getPom(), facade.getResolverConfiguration(), monitor));
} catch(ExecutionException ex) {
Throwable cause = ex.getCause();
if(cause instanceof CoreException) {
@@ -1137,17 +1128,15 @@ public class ProjectRegistryManager {
}
private Cache<MavenProjectFacade, MavenProject> createProjectCache() {
- final RemovalListener<MavenProjectFacade, MavenProject> removalListener = new RemovalListener<MavenProjectFacade, MavenProject>() {
- public void onRemoval(RemovalNotification<MavenProjectFacade, MavenProject> notification) {
- if(notification.getCause() == RemovalCause.SIZE || notification.getCause() == RemovalCause.REPLACED) {
- // there is currently no good way to determine if MavenProject instance is still being used or not
- // for now assume that cache entries removed from project cache can only be referenced by context map
- final MavenProjectFacade facade = notification.getKey();
- final MavenProject mavenProject = notification.getValue();
- final Map<MavenProjectFacade, MavenProject> contextProjects = getContextProjects();
- if(contextProjects != null && !contextProjects.containsKey(facade)) {
- flushMavenCaches(facade.getPomFile(), facade.getArtifactKey(), mavenProject, false);
- }
+ final RemovalListener<MavenProjectFacade, MavenProject> removalListener = notification -> {
+ if(notification.getCause() == RemovalCause.SIZE || notification.getCause() == RemovalCause.REPLACED) {
+ // there is currently no good way to determine if MavenProject instance is still being used or not
+ // for now assume that cache entries removed from project cache can only be referenced by context map
+ final MavenProjectFacade facade = notification.getKey();
+ final MavenProject mavenProject = notification.getValue();
+ final Map<MavenProjectFacade, MavenProject> contextProjects = getContextProjects();
+ if(contextProjects != null && !contextProjects.containsKey(facade)) {
+ flushMavenCaches(facade.getPomFile(), facade.getArtifactKey(), mavenProject, false);
}
}
};
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
index 11f195f5..505ed360 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
@@ -92,11 +92,8 @@ public class MavenDiscovery {
public static void launchWizard(final Collection<String> packagingTypes, final Collection<MojoExecutionKey> mojos,
final Collection<String> lifecycleIds, final Collection<String> configuratorIds) {
final Display display = Workbench.getInstance().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- launchWizard(display.getActiveShell(), packagingTypes, mojos, lifecycleIds, configuratorIds);
- }
- });
+ display
+ .asyncExec(() -> launchWizard(display.getActiveShell(), packagingTypes, mojos, lifecycleIds, configuratorIds));
}
public static void launchWizard(Shell shell, Collection<String> packagingTypes, Collection<MojoExecutionKey> mojos,
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
index 76a12ae1..2eaf6a14 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
@@ -64,8 +64,8 @@ public class MavenCatalogViewer extends CatalogViewer {
final SubMonitor subMon = SubMonitor.convert(monitor, getCatalog().getItems().size() * 3);
try {
for(CatalogItem connector : getCatalog().getItems()) {
- connector.setInstalled(installedFeatures != null
- && installedFeatures.containsAll(connector.getInstallableUnits()));
+ connector
+ .setInstalled(installedFeatures != null && installedFeatures.containsAll(connector.getInstallableUnits()));
subMon.worked(1);
}
@@ -81,43 +81,15 @@ public class MavenCatalogViewer extends CatalogViewer {
if(!selectedConfiguratorIds.isEmpty() || !selectedLifecycleIds.isEmpty() || !selectedMojos.isEmpty()
|| !selectedPackagingTypes.isEmpty()) {
noneApplicable = true;
- shellProvider.getShell().getDisplay().syncExec(new Runnable() {
- @SuppressWarnings("synthetic-access")
- public void run() {
- for(CatalogItem ci : getCatalog().getItems()) {
- boolean selected = false;
- subMon.worked(2);
-
- LifecycleMappingMetadataSource src = MavenDiscovery.getLifecycleMappingMetadataSource(ci);
- if(src != null) {
- for(String packagingType : selectedPackagingTypes) {
- if(hasPackaging(src, packagingType)) {
- selected = true;
- select(ci);
- break;
- }
- }
- if(selected) {
- continue;
- }
- for(MojoExecutionKey mojoExecution : selectedMojos) {
- if(matchesFilter(src, mojoExecution)) {
- selected = true;
- select(ci);
- break;
- }
- }
- if(selected) {
- continue;
- }
- }
-
- List<String> projectConfigurators = new ArrayList<String>();
- List<String> mappingStrategies = new ArrayList<String>();
- MavenDiscovery.getProvidedProjectConfigurators(ci, projectConfigurators, mappingStrategies);
-
- for(String configuratorId : selectedConfiguratorIds) {
- if(projectConfigurators.contains(configuratorId)) {
+ shellProvider.getShell().getDisplay().syncExec(() -> {
+ for(CatalogItem ci : getCatalog().getItems()) {
+ boolean selected = false;
+ subMon.worked(2);
+
+ LifecycleMappingMetadataSource src = MavenDiscovery.getLifecycleMappingMetadataSource(ci);
+ if(src != null) {
+ for(String packagingType : selectedPackagingTypes) {
+ if(hasPackaging(src, packagingType)) {
selected = true;
select(ci);
break;
@@ -126,19 +98,44 @@ public class MavenCatalogViewer extends CatalogViewer {
if(selected) {
continue;
}
-
- for(String lifecycleId : selectedLifecycleIds) {
- if(mappingStrategies.contains(lifecycleId)) {
+ for(MojoExecutionKey mojoExecution : selectedMojos) {
+ if(matchesFilter(src, mojoExecution)) {
+ selected = true;
select(ci);
break;
}
}
+ if(selected) {
+ continue;
+ }
+ }
+
+ List<String> projectConfigurators = new ArrayList<String>();
+ List<String> mappingStrategies = new ArrayList<String>();
+ MavenDiscovery.getProvidedProjectConfigurators(ci, projectConfigurators, mappingStrategies);
+
+ for(String configuratorId : selectedConfiguratorIds) {
+ if(projectConfigurators.contains(configuratorId)) {
+ selected = true;
+ select(ci);
+ break;
+ }
}
- if(noneApplicable) {
- handleStatus(new Status(IStatus.ERROR, DiscoveryActivator.PLUGIN_ID,
- Messages.MavenCatalogViewer_noApplicableCatalogItems));
+ if(selected) {
+ continue;
+ }
+
+ for(String lifecycleId : selectedLifecycleIds) {
+ if(mappingStrategies.contains(lifecycleId)) {
+ select(ci);
+ break;
+ }
}
}
+ if(noneApplicable) {
+ handleStatus(new Status(IStatus.ERROR, DiscoveryActivator.PLUGIN_ID,
+ Messages.MavenCatalogViewer_noApplicableCatalogItems));
+ }
});
}
}
@@ -203,18 +200,16 @@ public class MavenCatalogViewer extends CatalogViewer {
}
if(shellProvider instanceof WizardPage) {
- shellProvider.getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- // Display the error in the wizard header
- int messageType = IMessageProvider.INFORMATION;
- if(status.matches(IStatus.ERROR)) {
- messageType = IMessageProvider.ERROR;
- } else if(status.matches(IStatus.WARNING)) {
- messageType = IMessageProvider.WARNING;
- }
- ((WizardPage) shellProvider).setMessage(status.getMessage(), messageType);
- StatusManager.getManager().handle(status);
+ shellProvider.getShell().getDisplay().asyncExec(() -> {
+ // Display the error in the wizard header
+ int messageType = IMessageProvider.INFORMATION;
+ if(status.matches(IStatus.ERROR)) {
+ messageType = IMessageProvider.ERROR;
+ } else if(status.matches(IStatus.WARNING)) {
+ messageType = IMessageProvider.WARNING;
}
+ ((WizardPage) shellProvider).setMessage(status.getMessage(), messageType);
+ StatusManager.getManager().handle(status);
});
} else {
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/FormHoverProvider.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/FormHoverProvider.java
index 7db77494..92a5bdbc 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/FormHoverProvider.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/FormHoverProvider.java
@@ -22,13 +22,10 @@ import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.texteditor.MarkerAnnotation;
@@ -42,42 +39,40 @@ public final class FormHoverProvider {
public static Execute createHoverRunnable(final Shell parentShell, final IMarker[] markers,
final ISourceViewer sourceViewer) {
if(markers.length > 0) {
- return new Execute() {
- public void run(Point position) {
- List<IMarker> markersSet = Arrays.asList(markers);
- PomTextHover.CompoundRegion compound = new PomTextHover.CompoundRegion(sourceViewer, 0);
- Iterator<Annotation> it = sourceViewer.getAnnotationModel().getAnnotationIterator();
- while(it.hasNext()) {
- Annotation ann = it.next();
- if(ann instanceof MarkerAnnotation) {
- MarkerAnnotation mann = (MarkerAnnotation) ann;
- if(markersSet.contains(mann.getMarker()))
- ;
- compound.addRegion(new PomHyperlinkDetector.MarkerRegion(0, 0, mann));
- }
+ return position -> {
+ List<IMarker> markersSet = Arrays.asList(markers);
+ PomTextHover.CompoundRegion compound = new PomTextHover.CompoundRegion(sourceViewer, 0);
+ Iterator<Annotation> it = sourceViewer.getAnnotationModel().getAnnotationIterator();
+ while(it.hasNext()) {
+ Annotation ann = it.next();
+ if(ann instanceof MarkerAnnotation) {
+ MarkerAnnotation mann = (MarkerAnnotation) ann;
+ if(markersSet.contains(mann.getMarker()))
+ ;
+ compound.addRegion(new PomHyperlinkDetector.MarkerRegion(0, 0, mann));
}
- final MarkerHoverControl mhc = new MarkerHoverControl(parentShell);
- final Display fDisplay = mhc.getMyShell().getDisplay();
+ }
+ final MarkerHoverControl mhc = new MarkerHoverControl(parentShell);
+ final Display fDisplay = mhc.getMyShell().getDisplay();
- final Listener displayListener = new Listener() {
- public void handleEvent(Event event) {
- if(event.type == SWT.MouseMove) {
- if(!(event.widget instanceof Control) || event.widget.isDisposed())
- return;
+ final Listener displayListener = event -> {
+ if(event.type == SWT.MouseMove) {
+ if(!(event.widget instanceof Control) || event.widget.isDisposed())
+ return;
- IInformationControl infoControl = mhc;
- if(infoControl != null && !infoControl.isFocusControl()
- && infoControl instanceof IInformationControlExtension3) {
- IInformationControlExtension3 iControl3 = (IInformationControlExtension3) infoControl;
- Rectangle controlBounds = iControl3.getBounds();
- if(controlBounds != null) {
- Point mouseLoc = event.display.map((Control) event.widget, null, event.x, event.y);
- int margin = 20;
- Geometry.expand(controlBounds, margin, margin, margin, margin);
- if(!controlBounds.contains(mouseLoc)) {
- mhc.setVisible(false);
- }
- }
+ IInformationControl infoControl = mhc;
+ if(infoControl != null && !infoControl.isFocusControl()
+ && infoControl instanceof IInformationControlExtension3) {
+ IInformationControlExtension3 iControl3 = (IInformationControlExtension3) infoControl;
+ Rectangle controlBounds = iControl3.getBounds();
+ if(controlBounds != null) {
+ Point mouseLoc = event.display.map((Control) event.widget, null, event.x, event.y);
+ int margin = 20;
+ Geometry.expand(controlBounds, margin, margin, margin, margin);
+ if(!controlBounds.contains(mouseLoc)) {
+ mhc.setVisible(false);
+ }
+ }
// } else {
// System.out.println("removing mouse move..");
@@ -87,41 +82,37 @@ public final class FormHoverProvider {
// */
// if (fDisplay != null && !fDisplay.isDisposed())
// fDisplay.removeFilter(SWT.MouseMove, this);
- }
-
- } else if(event.type == SWT.FocusOut) {
- IInformationControl iControl = mhc;
- if(iControl != null && !iControl.isFocusControl())
- mhc.setVisible(false);
- }
}
- };
- mhc.setLocation(new Point(position.x, position.y));
- mhc.setSizeConstraints(400, 400);
- mhc.setInput(compound);
- Point hint = mhc.computeSizeHint();
- mhc.setSize(hint.x, Math.min(hint.y, 400));
- if(!fDisplay.getBounds().contains(position.x + hint.x, position.y)) {
- mhc.setLocation(new Point(position.x - (position.x + hint.x - fDisplay.getBounds().width), position.y));
+ } else if(event.type == SWT.FocusOut) {
+ IInformationControl iControl = mhc;
+ if(iControl != null && !iControl.isFocusControl())
+ mhc.setVisible(false);
}
+ };
+
+ mhc.setLocation(new Point(position.x, position.y));
+ mhc.setSizeConstraints(400, 400);
+ mhc.setInput(compound);
+ Point hint = mhc.computeSizeHint();
+ mhc.setSize(hint.x, Math.min(hint.y, 400));
+ if(!fDisplay.getBounds().contains(position.x + hint.x, position.y)) {
+ mhc.setLocation(new Point(position.x - (position.x + hint.x - fDisplay.getBounds().width), position.y));
+ }
// mhc.getMyShell().addShellListener(new ShellAdapter() {
// public void shellActivated(ShellEvent e) {
// mhc.setFocus();
// }
// });
- if(!fDisplay.isDisposed()) {
- fDisplay.addFilter(SWT.MouseMove, displayListener);
- fDisplay.addFilter(SWT.FocusOut, displayListener);
- }
- mhc.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fDisplay.removeFilter(SWT.MouseMove, displayListener);
- fDisplay.removeFilter(SWT.FocusOut, displayListener);
- }
- });
- mhc.setVisible(true);
+ if(!fDisplay.isDisposed()) {
+ fDisplay.addFilter(SWT.MouseMove, displayListener);
+ fDisplay.addFilter(SWT.FocusOut, displayListener);
}
+ mhc.addDisposeListener(e -> {
+ fDisplay.removeFilter(SWT.MouseMove, displayListener);
+ fDisplay.removeFilter(SWT.FocusOut, displayListener);
+ });
+ mhc.setVisible(true);
};
} else {
return null;
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 5fffad5e..dd4590e9 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,8 +43,6 @@ 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.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
@@ -375,11 +373,9 @@ public class MarkerHoverControl extends AbstractInformationControl
gridData.widthHint = 17;
gridData.heightHint = 16;
canvas.setLayoutData(gridData);
- canvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- e.gc.setFont(null);
- markerAccess.paint(annotation.getAnnotation(), e.gc, canvas, new Rectangle(0, 0, 16, 16));
- }
+ canvas.addPaintListener(e -> {
+ e.gc.setFont(null);
+ markerAccess.paint(annotation.getAnnotation(), e.gc, canvas, new Rectangle(0, 0, 16, 16));
});
//and now comes the text
@@ -542,14 +538,7 @@ public class MarkerHoverControl extends AbstractInformationControl
* {@inheritDoc} This default implementation returns <code>null</code>. Subclasses may override.
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
- return new IInformationControlCreator() {
- /*
- * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
- */
- public IInformationControl createInformationControl(Shell parent) {
- return new MarkerHoverControl(parent, new ToolBarManager(SWT.FLAT));
- }
- };
+ return parent -> new MarkerHoverControl(parent, new ToolBarManager(SWT.FLAT));
}
private void apply(IMarkerResolution res, IMarker mark, ITextViewer viewer, int offset) {
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 861c2439..c5cf0e6b 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
@@ -18,17 +18,13 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
@@ -151,17 +147,15 @@ public class SelectSPDXLicenseDialog extends AbstractMavenDialog {
});
licensesViewer.setInput(SPDXLicense.getStandardLicenses());
- licenseFilter.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String text = licenseFilter.getText();
- ViewerFilter[] filters;
- if(text != null && text.trim().length() > 0) {
- filters = new ViewerFilter[] {new LicenseFilter(text.trim())};
- } else {
- filters = new ViewerFilter[] {};
- }
- licensesViewer.setFilters(filters);
+ licenseFilter.addModifyListener(e -> {
+ String text = licenseFilter.getText();
+ ViewerFilter[] filters;
+ if(text != null && text.trim().length() > 0) {
+ filters = new ViewerFilter[] {new LicenseFilter(text.trim())};
+ } else {
+ filters = new ViewerFilter[] {};
}
+ licensesViewer.setFilters(filters);
});
Label lblPomxml = new Label(container, SWT.NONE);
@@ -174,15 +168,12 @@ public class SelectSPDXLicenseDialog extends AbstractMavenDialog {
handleDoubleClick();
}
});
- parentComposite.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = parentComposite.getSelection();
- if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
- ParentHierarchyEntry mavenProject = (ParentHierarchyEntry) ((IStructuredSelection) selection)
- .getFirstElement();
- targetProject = mavenProject.getFacade();
- updateStatus();
- }
+ parentComposite.addSelectionChangedListener(event -> {
+ ISelection selection = parentComposite.getSelection();
+ if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ ParentHierarchyEntry mavenProject = (ParentHierarchyEntry) ((IStructuredSelection) selection).getFirstElement();
+ targetProject = mavenProject.getFacade();
+ updateStatus();
}
});
parentComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingResolution.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingResolution.java
index fab007bd..348af30f 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingResolution.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingResolution.java
@@ -83,18 +83,15 @@ public class LifecycleMappingResolution extends AbstractLifecycleMappingResoluti
private void performIgnore(List<IMarker> markers) throws IOException, CoreException {
final IFile[] pomFile = new IFile[1];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
-
- public void run() {
- LifecycleMappingDialog dialog = new LifecycleMappingDialog(Display.getCurrent().getActiveShell(),
- (IFile) getMarker().getResource(), getMarker().getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, ""),
- getMarker().getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, ""),
- getMarker().getAttribute(IMavenConstants.MARKER_ATTR_VERSION, ""),
- getMarker().getAttribute(IMavenConstants.MARKER_ATTR_GOAL, ""));
- dialog.setBlockOnOpen(true);
- if(dialog.open() == Window.OK) {
- pomFile[0] = dialog.getPomFile();
- }
+ PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ LifecycleMappingDialog dialog = new LifecycleMappingDialog(Display.getCurrent().getActiveShell(),
+ (IFile) getMarker().getResource(), getMarker().getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, ""),
+ getMarker().getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, ""),
+ getMarker().getAttribute(IMavenConstants.MARKER_ATTR_VERSION, ""),
+ getMarker().getAttribute(IMavenConstants.MARKER_ATTR_GOAL, ""));
+ dialog.setBlockOnOpen(true);
+ if(dialog.open() == Window.OK) {
+ pomFile[0] = dialog.getPomFile();
}
});
if(pomFile[0] != null) {
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 622848b8..ceb820c3 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
@@ -41,7 +41,6 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.eclipse.core.runtime.CoreException;
@@ -55,17 +54,13 @@ import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
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.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;
@@ -90,7 +85,6 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.ui.internal.dialogs.EditDependencyDialog;
import org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog;
-import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
import org.eclipse.m2e.core.ui.internal.editing.PomHelper;
import org.eclipse.m2e.core.ui.internal.util.ParentGatherer;
@@ -203,22 +197,20 @@ public class DependenciesComposite extends Composite {
public void widgetSelected(SelectionEvent e) {
final List<Object> dependencyList = dependenciesEditor.getSelection();
try {
- editorPage.performEditOperation(new Operation() {
- public void process(Document 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);
- }
+ 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);
}
+ removeIfNoChildElement(deps);
}, log, "error removing dependencies");
} finally {
setDependenciesInput();
@@ -280,13 +272,11 @@ public class DependenciesComposite extends Composite {
final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
final String selectedScope = addDepDialog.getSelectedScope();
try {
- editorPage.performEditOperation(new Operation() {
- public void process(Document 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);
- }
+ 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();
@@ -413,20 +403,18 @@ public class DependenciesComposite extends Composite {
public void widgetSelected(SelectionEvent e) {
final List<Dependency> dependencyList = dependencyManagementEditor.getSelection();
try {
- editorPage.performEditOperation(new Operation() {
- public void process(Document 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);
+ 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();
@@ -454,13 +442,11 @@ public class DependenciesComposite extends Composite {
}
});
- dependencyManagementEditor.addSelectionListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- List<Dependency> selection = dependencyManagementEditor.getSelection();
+ dependencyManagementEditor.addSelectionListener(event -> {
+ List<Dependency> selection = dependencyManagementEditor.getSelection();
- if(!selection.isEmpty()) {
- dependenciesEditor.setSelection(Collections.<Object> emptyList());
- }
+ if(!selection.isEmpty()) {
+ dependenciesEditor.setSelection(Collections.<Object> emptyList());
}
});
@@ -476,12 +462,10 @@ public class DependenciesComposite extends Composite {
final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
final String selectedScope = addDepDialog.getSelectedScope();
try {
- editorPage.performEditOperation(new Operation() {
- public void process(Document document) {
- Element depsEl = getChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT, DEPENDENCIES);
- PomHelper.addOrUpdateDependency(depsEl, dep.group, dep.artifact, dep.version, dep.type, selectedScope,
- dep.classifier);
- }
+ 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();
@@ -627,13 +611,11 @@ public class DependenciesComposite extends Composite {
};
// Run the update job when the user modifies the filter text.
- this.searchControl.getSearchText().addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- // The net effect here is that the field will update 200 ms after
- // the user stops typing.
- updateJob.cancel();
- updateJob.schedule(200);
- }
+ this.searchControl.getSearchText().addModifyListener(e -> {
+ // The net effect here is that the field will update 200 ms after
+ // the user stops typing.
+ updateJob.cancel();
+ updateJob.schedule(200);
});
}
@@ -663,17 +645,15 @@ public class DependenciesComposite extends Composite {
*/
final List<ParentHierarchyEntry> hierarchy = new ArrayList<ParentHierarchyEntry>();
- IRunnableWithProgress projectLoader = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
- IMavenProjectFacade projectFacade = projectManager.create(pomEditor.getPomFile(), true, monitor);
- if(projectFacade != null) {
- hierarchy.addAll(new ParentGatherer(projectFacade).getParentHierarchy(monitor));
- }
- } catch(CoreException e) {
- throw new InvocationTargetException(e);
+ IRunnableWithProgress projectLoader = monitor -> {
+ try {
+ IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
+ IMavenProjectFacade projectFacade = projectManager.create(pomEditor.getPomFile(), true, monitor);
+ if(projectFacade != null) {
+ hierarchy.addAll(new ParentGatherer(projectFacade).getParentHierarchy(monitor));
}
+ } catch(CoreException e) {
+ throw new InvocationTargetException(e);
}
};
@@ -731,14 +711,12 @@ public class DependenciesComposite extends Composite {
if(manageddependencies == null) {
manageddependencies = new ArrayList<Dependency>();
try {
- performOnDOMDocument(new OperationTuple(pomEditor.getDocument(), new Operation() {
- public void process(Document document) {
- Element dms = findChild(findChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT), DEPENDENCIES);
- for(Element depEl : findChilds(dms, DEPENDENCY)) {
- Dependency dep = toDependency(depEl);
- if(dep != null) {
- manageddependencies.add(dep);
- }
+ performOnDOMDocument(new OperationTuple(pomEditor.getDocument(), document -> {
+ Element dms = findChild(findChild(document.getDocumentElement(), DEPENDENCY_MANAGEMENT), DEPENDENCIES);
+ for(Element depEl : findChilds(dms, DEPENDENCY)) {
+ Dependency dep = toDependency(depEl);
+ if(dep != null) {
+ manageddependencies.add(dep);
}
}
}, true));
@@ -763,14 +741,12 @@ public class DependenciesComposite extends Composite {
if(dependencies == null) {
dependencies = new ArrayList<Dependency>();
try {
- performOnDOMDocument(new OperationTuple(pomEditor.getDocument(), new Operation() {
- public void process(Document document) {
- Element dms = findChild(document.getDocumentElement(), DEPENDENCIES);
- for(Element depEl : findChilds(dms, DEPENDENCY)) {
- Dependency dep = toDependency(depEl);
- if(dep != null) {
- dependencies.add(dep);
- }
+ performOnDOMDocument(new OperationTuple(pomEditor.getDocument(), document -> {
+ Element dms = findChild(document.getDocumentElement(), DEPENDENCIES);
+ for(Element depEl : findChilds(dms, DEPENDENCY)) {
+ Dependency dep = toDependency(depEl);
+ if(dep != null) {
+ dependencies.add(dep);
}
}
}, true));
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 ab08833a..61a02567 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
@@ -27,7 +27,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
@@ -106,11 +105,7 @@ public class ListEditorComposite<T> extends Composite {
table.setLayoutData(viewerData);
viewer.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.TRUE);
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- viewerSelectionChanged();
- }
- });
+ viewer.addSelectionChangedListener(event -> viewerSelectionChanged());
toolkit.paintBordersFor(this);
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/internal/actions/ShowDependencyHierarchyAction.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/internal/actions/ShowDependencyHierarchyAction.java
index 8e9411e9..d7580d47 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/internal/actions/ShowDependencyHierarchyAction.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/internal/actions/ShowDependencyHierarchyAction.java
@@ -67,11 +67,7 @@ public class ShowDependencyHierarchyAction extends ActionDelegate {
final IEditorPart editor = OpenPomAction.openEditor(projectKey.getGroupId(), //
projectKey.getArtifactId(), projectKey.getVersion(), monitor);
if(editor instanceof MavenPomEditor) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ((MavenPomEditor) editor).showDependencyHierarchy(artifactKey);
- }
- });
+ Display.getDefault().asyncExec(() -> ((MavenPomEditor) editor).showDependencyHierarchy(artifactKey));
}
return Status.OK_STATUS;
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependencyTreePage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependencyTreePage.java
index 02196de3..76390816 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependencyTreePage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/DependencyTreePage.java
@@ -39,13 +39,11 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -59,8 +57,6 @@ import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
@@ -236,33 +232,28 @@ public class DependencyTreePage extends FormPage implements IMavenProjectChanged
}
});
- getPartControl().getDisplay().syncExec(new Runnable() {
- public void run() {
- FormUtils.setMessage(getManagedForm().getForm(), null, IMessageProvider.NONE);
- if(treeViewer.getTree().isDisposed()) {
- return;
- }
+ getPartControl().getDisplay().syncExec(() -> {
+ FormUtils.setMessage(getManagedForm().getForm(), null, IMessageProvider.NONE);
+ if(treeViewer.getTree().isDisposed()) {
+ return;
+ }
- treeViewer.setInput(dependencyNode);
- treeViewer.getTree().setRedraw(false);
- try {
- treeViewer.expandAll();
- } finally {
- treeViewer.getTree().setRedraw(true);
- }
- if(listViewer.getTable().isDisposed()) {
- return;
- }
- listViewer.setInput(mavenProject);
+ treeViewer.setInput(dependencyNode);
+ treeViewer.getTree().setRedraw(false);
+ try {
+ treeViewer.expandAll();
+ } finally {
+ treeViewer.getTree().setRedraw(true);
+ }
+ if(listViewer.getTable().isDisposed()) {
+ return;
}
+ listViewer.setInput(mavenProject);
});
} catch(final CoreException ex) {
log.error(ex.getMessage(), ex);
- getPartControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- FormUtils.setMessage(getManagedForm().getForm(), ex.getMessage(), IMessageProvider.ERROR);
- }
- });
+ getPartControl().getDisplay().asyncExec(
+ () -> FormUtils.setMessage(getManagedForm().getForm(), ex.getMessage(), IMessageProvider.ERROR));
}
return Status.OK_STATUS;
@@ -294,26 +285,22 @@ public class DependencyTreePage extends FormPage implements IMavenProjectChanged
treeViewer.setContentProvider(new DependencyTreeContentProvider());
treeViewer.setLabelProvider(treeLabelProvider);
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if(!isSettingSelection) {
- isSettingSelection = true;
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- selectListElements(new DependencyNodeMatcher(selection));
- isSettingSelection = false;
- }
+ treeViewer.addSelectionChangedListener(event -> {
+ if(!isSettingSelection) {
+ isSettingSelection = true;
+ IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+ selectListElements(new DependencyNodeMatcher(selection));
+ isSettingSelection = false;
}
});
- treeViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- for(Iterator<?> it = selection.iterator(); it.hasNext();) {
- Object o = it.next();
- if(o instanceof DependencyNode) {
- org.eclipse.aether.artifact.Artifact a = ((DependencyNode) o).getDependency().getArtifact();
- OpenPomAction.openEditor(a.getGroupId(), a.getArtifactId(), a.getVersion(), mavenProject, null);
- }
+ treeViewer.addOpenListener(event -> {
+ IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+ for(Iterator<?> it = selection.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if(o instanceof DependencyNode) {
+ org.eclipse.aether.artifact.Artifact a = ((DependencyNode) o).getDependency().getArtifact();
+ OpenPomAction.openEditor(a.getGroupId(), a.getArtifactId(), a.getVersion(), mavenProject, null);
}
}
});
@@ -325,17 +312,17 @@ public class DependencyTreePage extends FormPage implements IMavenProjectChanged
FormToolkit formToolkit) {
ToolBarManager hiearchyToolBarManager = new ToolBarManager(SWT.FLAT);
- hiearchyToolBarManager.add(new Action(Messages.DependencyTreePage_action_collapseAll,
- MavenEditorImages.COLLAPSE_ALL) {
- public void run() {
- treeViewer.getTree().setRedraw(false);
- try {
- treeViewer.collapseAll();
- } finally {
- treeViewer.getTree().setRedraw(true);
- }
- }
- });
+ hiearchyToolBarManager
+ .add(new Action(Messages.DependencyTreePage_action_collapseAll, MavenEditorImages.COLLAPSE_ALL) {
+ public void run() {
+ treeViewer.getTree().setRedraw(false);
+ try {
+ treeViewer.collapseAll();
+ } finally {
+ treeViewer.getTree().setRedraw(true);
+ }
+ }
+ });
hiearchyToolBarManager.add(new Action(Messages.DependencyTreePage_action_expandAll, MavenEditorImages.EXPAND_ALL) {
public void run() {
@@ -443,15 +430,13 @@ public class DependencyTreePage extends FormPage implements IMavenProjectChanged
listViewer.addSelectionChangedListener(listSelectionFilter);
listViewer.getTable().addFocusListener(listSelectionFilter);
- listViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
- for(Iterator<?> it = selection.iterator(); it.hasNext();) {
- Object o = it.next();
- if(o instanceof Artifact) {
- Artifact a = (Artifact) o;
- OpenPomAction.openEditor(a.getGroupId(), a.getArtifactId(), a.getVersion(), mavenProject, null);
- }
+ listViewer.addOpenListener(event -> {
+ IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
+ for(Iterator<?> it = selection.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if(o instanceof Artifact) {
+ Artifact a = (Artifact) o;
+ OpenPomAction.openEditor(a.getGroupId(), a.getArtifactId(), a.getVersion(), mavenProject, null);
}
}
});
@@ -608,11 +593,9 @@ public class DependencyTreePage extends FormPage implements IMavenProjectChanged
}
});
- searchControl.getSearchText().addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateJob.cancel();
- updateJob.schedule(200);
- }
+ searchControl.getSearchText().addModifyListener(e -> {
+ updateJob.cancel();
+ updateJob.schedule(200);
});
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index 86afabd0..d71e5d92 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -49,7 +49,6 @@ import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
@@ -201,11 +200,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
//handle project delete
if(event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) {
if(pomFile.getProject().equals(event.getResource())) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- close(false);
- }
- });
+ Display.getDefault().asyncExec(() -> close(false));
}
return;
}
@@ -228,11 +223,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
RemovedResourceDeltaVisitor visitor = new RemovedResourceDeltaVisitor();
event.getDelta().accept(visitor);
if(visitor.removed) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- close(true);
- }
- });
+ Display.getDefault().asyncExec(() -> close(true));
}
} catch(CoreException ex) {
log.error(ex.getMessage(), ex);
@@ -274,21 +265,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
private void handleContentChanged() {
reloadMavenProjectCache();
if(!resourceChangeEventSkip) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
-/* MNGECLIPSE-1789: commented this out since forced model reload caused the XML editor to go crazy;
- the model is already updated at this point so reloading from file is unnecessary;
- externally originated file updates are checked in handleActivation() */
-// try {
-// structuredModel.reload(pomFile.getContents());
- reload();
-// } catch(CoreException e) {
-// log.error(e.getMessage(), e);
-// } catch(Exception e) {
-// log.error("Error loading pom editor model.", e);
-// }
- }
- });
+ Display.getDefault().asyncExec(() -> reload());
}
}
@@ -305,11 +282,9 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
: IMessageProvider.ERROR)
: IMessageProvider.NONE;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for(MavenPomEditorPage page : getMavenPomEditorPages()) {
- page.setErrorMessage(msg, msg == null ? IMessageProvider.NONE : severity);
- }
+ Display.getDefault().asyncExec(() -> {
+ for(MavenPomEditorPage page : getMavenPomEditorPages()) {
+ page.setErrorMessage(msg, msg == null ? IMessageProvider.NONE : severity);
}
});
} catch(CoreException ex) {
@@ -974,11 +949,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11731
* Will be removed when SWT has solved the problem.
*/
- window.getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- handleActivation();
- }
- });
+ window.getShell().getDisplay().asyncExec(() -> handleActivation());
}
}
@@ -1004,11 +975,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
final boolean[] changed = new boolean[] {false};
try {
- ITextListener listener = new ITextListener() {
- public void textChanged(TextEvent event) {
- changed[0] = true;
- }
- };
+ ITextListener listener = event -> changed[0] = true;
if(sourcePage != null && sourcePage.getTextViewer() != null) {
sourcePage.getTextViewer().addTextListener(listener);
try {
@@ -1111,11 +1078,9 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
if(mp != null) {
mavenProject = mp;
if(getContainer() != null && !getContainer().isDisposed())
- getContainer().getDisplay().asyncExec(new Runnable() {
- public void run() {
- for(MavenPomEditorPage page : getMavenPomEditorPages()) {
- page.mavenProjectHasChanged();
- }
+ getContainer().getDisplay().asyncExec(() -> {
+ for(MavenPomEditorPage page : getMavenPomEditorPages()) {
+ page.mavenProjectHasChanged();
}
});
}
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 796e1f8a..51d5204c 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
@@ -26,7 +26,6 @@ import static org.eclipse.m2e.editor.pom.FormUtils.isEmpty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -79,7 +78,6 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction;
import org.eclipse.m2e.core.ui.internal.dialogs.InputHistory;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits;
-import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
import org.eclipse.m2e.editor.MavenEditorImages;
import org.eclipse.m2e.editor.internal.Messages;
@@ -180,13 +178,11 @@ public abstract class MavenPomEditorPage extends FormPage {
public void run() {
final String[] ret = new String[3];
try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element parent = findChild(document.getDocumentElement(), PARENT);
- ret[0] = getTextValue(findChild(parent, GROUP_ID));
- ret[1] = getTextValue(findChild(parent, ARTIFACT_ID));
- ret[2] = getTextValue(findChild(parent, VERSION));
- }
+ performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
+ Element parent = findChild(document.getDocumentElement(), PARENT);
+ ret[0] = getTextValue(findChild(parent, GROUP_ID));
+ ret[1] = getTextValue(findChild(parent, ARTIFACT_ID));
+ ret[2] = getTextValue(findChild(parent, VERSION));
}, true));
// XXX listen to parent modification and accordingly enable/disable action
if(!isEmpty(ret[0]) && !isEmpty(ret[1]) && !isEmpty(ret[2])) {
@@ -253,14 +249,12 @@ public abstract class MavenPomEditorPage extends FormPage {
if(active && !dataLoaded) {
dataLoaded = true;
if(getPartControl() != null) {
- getPartControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- try {
- loadData();
- updateParentAction();
- } catch(Throwable e) {
- LOG.error("Error loading data", e); //$NON-NLS-1$
- }
+ getPartControl().getDisplay().asyncExec(() -> {
+ try {
+ loadData();
+ updateParentAction();
+ } catch(Throwable e) {
+ LOG.error("Error loading data", e); //$NON-NLS-1$
}
});
}
@@ -355,16 +349,14 @@ public abstract class MavenPomEditorPage extends FormPage {
private void setErrorMessageForMarkers(final String msg, final String tip, final int severity,
final IMarker[] markers) {
if(getPartControl() != null && !getPartControl().isDisposed()) {
- getPartControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if(!getManagedForm().getForm().isDisposed()) {
- FormHoverProvider.Execute runnable = FormHoverProvider.createHoverRunnable(
- getManagedForm().getForm().getShell(), markers, getPomEditor().getSourcePage().getTextViewer());
- if(runnable != null) {
- FormUtils.setMessageWithPerformer(getManagedForm().getForm(), msg, severity, runnable);
- } else {
- FormUtils.setMessageAndTTip(getManagedForm().getForm(), msg, tip, severity);
- }
+ getPartControl().getDisplay().asyncExec(() -> {
+ if(!getManagedForm().getForm().isDisposed()) {
+ FormHoverProvider.Execute runnable = FormHoverProvider.createHoverRunnable(
+ getManagedForm().getForm().getShell(), markers, getPomEditor().getSourcePage().getTextViewer());
+ if(runnable != null) {
+ FormUtils.setMessageWithPerformer(getManagedForm().getForm(), msg, severity, runnable);
+ } else {
+ FormUtils.setMessageAndTTip(getManagedForm().getForm(), msg, tip, severity);
}
}
});
@@ -373,11 +365,9 @@ public abstract class MavenPomEditorPage extends FormPage {
public void setErrorMessage(final String msg, final int severity) {
if(getPartControl() != null && !getPartControl().isDisposed()) {
- getPartControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if(!getManagedForm().getForm().isDisposed()) {
- FormUtils.setMessage(getManagedForm().getForm(), msg, severity);
- }
+ getPartControl().getDisplay().asyncExec(() -> {
+ if(!getManagedForm().getForm().isDisposed()) {
+ FormUtils.setMessage(getManagedForm().getForm(), msg, severity);
}
});
}
@@ -391,14 +381,12 @@ public abstract class MavenPomEditorPage extends FormPage {
if(selectParentAction != null) {
final boolean[] ret = new boolean[1];
try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element parent = findChild(document.getDocumentElement(), PARENT);
- String g = getTextValue(findChild(parent, GROUP_ID));
- String a = getTextValue(findChild(parent, ARTIFACT_ID));
- String v = getTextValue(findChild(parent, VERSION));
- ret[0] = g != null && a != null && v != null;
- }
+ performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
+ Element parent = findChild(document.getDocumentElement(), PARENT);
+ String g = getTextValue(findChild(parent, GROUP_ID));
+ String a = getTextValue(findChild(parent, ARTIFACT_ID));
+ String v = getTextValue(findChild(parent, VERSION));
+ ret[0] = g != null && a != null && v != null;
}, true));
} catch(Exception e) {
ret[0] = false;
@@ -447,14 +435,12 @@ public abstract class MavenPomEditorPage extends FormPage {
decoration.showHoverText(decoration.getDescriptionText());
}
});
- ModifyListener listener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String text = control instanceof Text ? ((Text) control).getText() : ((CCombo) control).getText();
- if(text.indexOf("${") != -1 && text.indexOf("}") != -1) {
- decoration.show();
- } else {
- decoration.hide();
- }
+ ModifyListener listener = e -> {
+ String text = control instanceof Text ? ((Text) control).getText() : ((CCombo) control).getText();
+ if(text.indexOf("${") != -1 && text.indexOf("}") != -1) {
+ decoration.show();
+ } else {
+ decoration.hide();
}
};
if(control instanceof Text) {
@@ -514,24 +500,22 @@ public abstract class MavenPomEditorPage extends FormPage {
if(provider == null) {
throw new IllegalStateException("no value provider for " + control);
}
- performEditOperation(new Operation() {
- public void process(Document document) {
- String text = getText(control);
- if(isEmpty(text) || text.equals(provider.getDefaultValue())) {
- //remove value
- Element el = provider.find(document);
- if(el != null) {
- Node parent = el.getParentNode();
- if(parent instanceof Element) {
- removeChild((Element) parent, el);
- removeIfNoChildElement((Element) parent);
- }
+ performEditOperation(document -> {
+ String text = getText(control);
+ if(isEmpty(text) || text.equals(provider.getDefaultValue())) {
+ //remove value
+ Element el1 = provider.find(document);
+ if(el1 != null) {
+ Node parent = el1.getParentNode();
+ if(parent instanceof Element) {
+ removeChild((Element) parent, el1);
+ removeIfNoChildElement((Element) parent);
}
- } else {
- //set value and any parents..
- Element el = provider.get(document);
- setText(el, text);
}
+ } else {
+ //set value and any parents..
+ Element el2 = provider.get(document);
+ setText(el2, text);
}
}, LOG, "Error updating document");
}
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 da307ff9..b43713ce 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
@@ -55,7 +55,6 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.eclipse.core.resources.IContainer;
@@ -70,8 +69,6 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
@@ -83,7 +80,6 @@ import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -394,9 +390,9 @@ public class OverviewPage extends MavenPomEditorPage {
if(parentGroup != null && parentArtifact != null && parentVersion != null) {
current.add(new ArtifactKey(parentGroup, parentArtifact, parentVersion, null));
}
- MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchParentDialog(getEditorSite()
- .getShell(), Messages.OverviewPage_searchDialog_selectParent, getPomEditor().getMavenProject(),
- getProject());
+ MavenRepositorySearchDialog dialog = MavenRepositorySearchDialog.createSearchParentDialog(
+ getEditorSite().getShell(), Messages.OverviewPage_searchDialog_selectParent,
+ getPomEditor().getMavenProject(), getProject());
if(parentGroup != null && parentGroup.trim().length() != 0) {
//chances are we will get good match by adding the groupid here..
dialog.setQuery(parentGroupIdText.getText());
@@ -503,23 +499,21 @@ public class OverviewPage extends MavenPomEditorPage {
parentVersionText.setLayoutData(parentVersionTextData);
parentVersionText.setData("name", "parentVersion"); //$NON-NLS-1$ //$NON-NLS-2$
ProposalUtil.addVersionProposal(getProject(), null/** null because we don't want expressions from parent pom here */
- , parentGroupIdText, parentArtifactIdText, parentVersionText, Packaging.POM);
+ , parentGroupIdText, parentArtifactIdText, parentVersionText, Packaging.POM);
M2EUIUtils.addRequiredDecoration(parentVersionText);
createEvaluatorInfo(parentVersionText);
setElementValueProvider(parentVersionText, new ElementValueProvider(PomEdits.PARENT, PomEdits.VERSION));
setModifyListener(parentVersionText);
- ModifyListener ml = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- //apparently the loadParent() method also participates in the enablement logic from time to time..
- String text1 = parentArtifactIdText.getText().trim();
- String text2 = parentGroupIdText.getText().trim();
- String text3 = parentVersionText.getText().trim();
- if(text1.length() > 0 && text2.length() > 0 && text3.length() > 0) {
- parentOpenAction.setEnabled(true);
- } else {
- parentOpenAction.setEnabled(false);
- }
+ ModifyListener ml = e -> {
+ //apparently the loadParent() method also participates in the enablement logic from time to time..
+ String text1 = parentArtifactIdText.getText().trim();
+ String text2 = parentGroupIdText.getText().trim();
+ String text3 = parentVersionText.getText().trim();
+ if(text1.length() > 0 && text2.length() > 0 && text3.length() > 0) {
+ parentOpenAction.setEnabled(true);
+ } else {
+ parentOpenAction.setEnabled(false);
}
};
parentArtifactIdText.addModifyListener(ml);
@@ -543,8 +537,8 @@ public class OverviewPage extends MavenPomEditorPage {
widthGroup.addControl(parentRealtivePathLabel);
toolkit.paintBordersFor(parentComposite);
- parentComposite.setTabList(new Control[] {parentGroupIdText, parentArtifactIdText, parentVersionText,
- parentRelativePathText});
+ parentComposite
+ .setTabList(new Control[] {parentGroupIdText, parentArtifactIdText, parentVersionText, parentRelativePathText});
}
private void createPropertiesSection(FormToolkit toolkit, Composite composite, WidthGroup widthGroup) {
@@ -590,28 +584,26 @@ public class OverviewPage extends MavenPomEditorPage {
modulesEditor.setContentProvider(new ListEditorContentProvider<String>());
modulesEditor.setLabelProvider(new ModulesLabelProvider(this));
- modulesEditor.setOpenListener(new IOpenListener() {
- public void open(OpenEvent openevent) {
- final List<String> selection = modulesEditor.getSelection();
- new Job(Messages.OverviewPage_opening_editors) {
- protected IStatus run(IProgressMonitor monitor) {
- for(String module : selection) {
- IMavenProjectFacade projectFacade = findModuleProject(module);
- if(projectFacade != null) {
- ArtifactKey key = projectFacade.getArtifactKey();
- OpenPomAction.openEditor(key.getGroupId(), key.getArtifactId(), key.getVersion(), getPomEditor()
- .getMavenProject(), monitor);
- } else {
- IFile modulePom = findModuleFile(module);
- if(modulePom != null && modulePom.isAccessible()) {
- OpenPomAction.openEditor(new FileEditorInput(modulePom), "pom.xml"); //$NON-NLS-1$
- }
+ modulesEditor.setOpenListener(openevent -> {
+ final List<String> selection = modulesEditor.getSelection();
+ new Job(Messages.OverviewPage_opening_editors) {
+ protected IStatus run(IProgressMonitor monitor) {
+ for(String module : selection) {
+ IMavenProjectFacade projectFacade = findModuleProject(module);
+ if(projectFacade != null) {
+ ArtifactKey key = projectFacade.getArtifactKey();
+ OpenPomAction.openEditor(key.getGroupId(), key.getArtifactId(), key.getVersion(),
+ getPomEditor().getMavenProject(), monitor);
+ } else {
+ IFile modulePom = findModuleFile(module);
+ if(modulePom != null && modulePom.isAccessible()) {
+ OpenPomAction.openEditor(new FileEditorInput(modulePom), "pom.xml"); //$NON-NLS-1$
}
}
- return Status.OK_STATUS;
}
- }.schedule();
- }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
});
modulesEditor.setAddButtonListener(new SelectionAdapter() {
@@ -620,14 +612,12 @@ public class OverviewPage extends MavenPomEditorPage {
final Set<Object> moduleContainers = new HashSet<Object>();
final List<String> modules = new ArrayList<String>();
try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element modsEl = findChild(document.getDocumentElement(), MODULES);
- for(Element el : findChilds(modsEl, MODULE)) {
- String m = getTextValue(el);
- if(m != null) {
- modules.add(m);
- }
+ 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));
@@ -673,20 +663,18 @@ public class OverviewPage extends MavenPomEditorPage {
modulesEditor.setRemoveButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
try {
- performEditOperation(new Operation() {
- public void process(Document 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);
- }
+ 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);
}
+ //now remove the <modules> element itself when there are no more elements left
+ removeIfNoChildElement(modules);
}
}, LOG, "error removing module entry");
} finally {
@@ -707,13 +695,11 @@ public class OverviewPage extends MavenPomEditorPage {
public void modify(Object element, String property, final Object value) {
final int n = modulesEditor.getViewer().getTable().getSelectionIndex();
try {
- performEditOperation(new Operation() {
- public void process(Document document) {
- Element root = document.getDocumentElement();
- Element module = findChild(findChild(root, MODULES), MODULE, childAt(n));
- if(module != null && !value.equals(getTextValue(module))) {
- setText(module, value.toString());
- }
+ performEditOperation(document -> {
+ Element root = document.getDocumentElement();
+ Element module = findChild(findChild(root, MODULES), MODULE, childAt(n));
+ if(module != null && !value.equals(getTextValue(module))) {
+ setText(module, value.toString());
}
}, LOG, "error changing module entry");
} finally {
@@ -860,8 +846,8 @@ public class OverviewPage extends MavenPomEditorPage {
widthGroup.addControl(inceptionYearLabel);
toolkit.paintBordersFor(projectComposite);
- projectComposite.setTabList(new Control[] {projectNameText, projectUrlText, projectDescriptionText,
- inceptionYearText});
+ projectComposite
+ .setTabList(new Control[] {projectNameText, projectUrlText, projectDescriptionText, inceptionYearText});
}
private void createOrganizationSection(FormToolkit toolkit, Composite composite, WidthGroup widthGroup) {
@@ -1003,8 +989,8 @@ public class OverviewPage extends MavenPomEditorPage {
toolkit.paintBordersFor(issueManagementSystemCombo);
toolkit.adapt(issueManagementSystemCombo, true, true);
createEvaluatorInfo(issueManagementSystemCombo);
- setElementValueProvider(issueManagementSystemCombo, new ElementValueProvider(PomEdits.ISSUE_MANAGEMENT,
- PomEdits.SYSTEM));
+ setElementValueProvider(issueManagementSystemCombo,
+ new ElementValueProvider(PomEdits.ISSUE_MANAGEMENT, PomEdits.SYSTEM));
setModifyListener(issueManagementSystemCombo);
Hyperlink issueManagementUrlLabel = toolkit.createHyperlink(issueManagementComposite, Messages.OverviewPage_lblUrl,
@@ -1102,168 +1088,164 @@ public class OverviewPage extends MavenPomEditorPage {
}
private void loadThis(final int mask) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
-
- removeNotifyListener(parentGroupIdText);
- removeNotifyListener(parentArtifactIdText);
- removeNotifyListener(parentVersionText);
- removeNotifyListener(parentRelativePathText);
-
- removeNotifyListener(artifactGroupIdText);
- removeNotifyListener(artifactIdText);
- removeNotifyListener(artifactVersionText);
- removeNotifyListener(artifactPackagingCombo);
- removeNotifyListener(projectNameText);
- removeNotifyListener(projectDescriptionText);
- removeNotifyListener(projectUrlText);
- removeNotifyListener(inceptionYearText);
-
- removeNotifyListener(organizationNameText);
- removeNotifyListener(organizationUrlText);
-
- removeNotifyListener(scmUrlText);
- removeNotifyListener(scmConnectionText);
- removeNotifyListener(scmDevConnectionText);
- removeNotifyListener(scmTagText);
-
- removeNotifyListener(ciManagementUrlCombo);
- removeNotifyListener(ciManagementSystemCombo);
-
- removeNotifyListener(issueManagementUrlCombo);
- removeNotifyListener(issueManagementSystemCombo);
-
- try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element root = document.getDocumentElement();
- String pack = nvl(getTextValue(findChild(root, PACKAGING)));
- pack = "".equals(pack) ? "jar" : pack; //$NON-NLS-1$ //$NON-NLS-2$
- if((mask & RELOAD_BASE) != 0) {
- setText(artifactGroupIdText, nvl(getTextValue(findChild(root, GROUP_ID))));
- setText(artifactIdText, nvl(getTextValue(findChild(root, ARTIFACT_ID))));
- setText(artifactVersionText, nvl(getTextValue(findChild(root, VERSION))));
- setText(artifactPackagingCombo, pack);
-
- String name = getTextValue(findChild(root, NAME));
- setText(projectNameText, nvl(name));
- String desc = getTextValue(findChild(root, DESCRIPTION));
- setText(projectDescriptionText, nvl(desc));
- String url = getTextValue(findChild(root, URL));
- setText(projectUrlText, nvl(url));
- String incep = getTextValue(findChild(root, INCEPTION_YEAR));
- setText(inceptionYearText, nvl(incep));
- boolean expandProjectSection = name != null || desc != null || url != null || incep != null;
- projectSectionData.grabExcessVerticalSpace = expandProjectSection;
- projectSection.setExpanded(expandProjectSection);
- }
- if((mask & RELOAD_PARENT) != 0) {
- //parent section
- Element parent = findChild(root, PARENT);
- String parentGrId = getTextValue(findChild(parent, GROUP_ID));
- String parentArtId = getTextValue(findChild(parent, ARTIFACT_ID));
- String parentVers = getTextValue(findChild(parent, VERSION));
- setText(parentGroupIdText, nvl(parentGrId));
- setText(parentArtifactIdText, nvl(parentArtId));
- setText(parentVersionText, nvl(parentVers));
- setText(parentRelativePathText, nvl(getTextValue(findChild(parent, RELATIVE_PATH))));
-
- parentSelectAction.setEnabled(!isReadOnly());
- // only enable when all 3 coordinates are actually present.
- parentOpenAction.setEnabled(root != null && parentGrId != null && parentArtId != null
- && parentVers != null);
- parentSection.setExpanded(parent != null);
- }
- if((mask & RELOAD_ORG) != 0) {
- //organization section
- Element org = findChild(root, ORGANIZATION);
- setText(organizationNameText, nvl(getTextValue(findChild(org, NAME))));
- setText(organizationUrlText, nvl(getTextValue(findChild(org, URL))));
- organizationSection.setExpanded(org != null);
- }
- if((mask & RELOAD_SCM) != 0) {
- //scm section
- Element scm = findChild(root, SCM);
- setText(scmUrlText, nvl(getTextValue(findChild(scm, URL))));
- setText(scmConnectionText, nvl(getTextValue(findChild(scm, CONNECTION))));
- setText(scmDevConnectionText, nvl(getTextValue(findChild(scm, DEV_CONNECTION))));
- setText(scmTagText, nvl(getTextValue(findChild(scm, TAG))));
- scmSection.setExpanded(scm != null);
- }
- if((mask & RELOAD_CI) != 0) {
- //ci section
- Element ci = findChild(root, CI_MANAGEMENT);
- setText(ciManagementSystemCombo, nvl(getTextValue(findChild(ci, SYSTEM))));
- setText(ciManagementUrlCombo, nvl(getTextValue(findChild(ci, URL))));
- ciManagementSection.setExpanded(ci != null);
- }
- if((mask & RELOAD_IM) != 0) {
- // issue management
- Element im = findChild(root, ISSUE_MANAGEMENT);
- setText(issueManagementSystemCombo, nvl(getTextValue(findChild(im, SYSTEM))));
- setText(issueManagementUrlCombo, nvl(getTextValue(findChild(im, URL))));
- issueManagementSection.setExpanded(im != null);
- }
-
- if((mask & RELOAD_MODULES) != 0) {
- //modules section..
- List<Element> moduleEls = findChilds(findChild(root, MODULES), MODULE);
- List<String> modules = new ArrayList<String>();
- for(Element moduleEl : moduleEls) {
- String text = getTextValue(moduleEl);
- if(text != null) {
- modules.add(text);
- }
- }
- loadModules(modules, pack);
- //#335337 no editing of packaging when there are modules, results in error anyway
- if(modules.size() > 0) {
- artifactPackagingCombo.setEnabled(false);
- } else {
- artifactPackagingCombo.setEnabled(true);
- }
- }
+ Display.getDefault().asyncExec(() -> {
+
+ removeNotifyListener(parentGroupIdText);
+ removeNotifyListener(parentArtifactIdText);
+ removeNotifyListener(parentVersionText);
+ removeNotifyListener(parentRelativePathText);
+
+ removeNotifyListener(artifactGroupIdText);
+ removeNotifyListener(artifactIdText);
+ removeNotifyListener(artifactVersionText);
+ removeNotifyListener(artifactPackagingCombo);
+ removeNotifyListener(projectNameText);
+ removeNotifyListener(projectDescriptionText);
+ removeNotifyListener(projectUrlText);
+ removeNotifyListener(inceptionYearText);
+
+ removeNotifyListener(organizationNameText);
+ removeNotifyListener(organizationUrlText);
+
+ removeNotifyListener(scmUrlText);
+ removeNotifyListener(scmConnectionText);
+ removeNotifyListener(scmDevConnectionText);
+ removeNotifyListener(scmTagText);
+
+ removeNotifyListener(ciManagementUrlCombo);
+ removeNotifyListener(ciManagementSystemCombo);
+
+ removeNotifyListener(issueManagementUrlCombo);
+ removeNotifyListener(issueManagementSystemCombo);
+
+ try {
+ performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
+ Element root = document.getDocumentElement();
+ String pack = nvl(getTextValue(findChild(root, PACKAGING)));
+ pack = "".equals(pack) ? "jar" : pack; //$NON-NLS-1$ //$NON-NLS-2$
+ if((mask & RELOAD_BASE) != 0) {
+ setText(artifactGroupIdText, nvl(getTextValue(findChild(root, GROUP_ID))));
+ setText(artifactIdText, nvl(getTextValue(findChild(root, ARTIFACT_ID))));
+ setText(artifactVersionText, nvl(getTextValue(findChild(root, VERSION))));
+ setText(artifactPackagingCombo, pack);
+
+ String name = getTextValue(findChild(root, NAME));
+ setText(projectNameText, nvl(name));
+ String desc = getTextValue(findChild(root, DESCRIPTION));
+ setText(projectDescriptionText, nvl(desc));
+ String url = getTextValue(findChild(root, URL));
+ setText(projectUrlText, nvl(url));
+ String incep = getTextValue(findChild(root, INCEPTION_YEAR));
+ setText(inceptionYearText, nvl(incep));
+ boolean expandProjectSection = name != null || desc != null || url != null || incep != null;
+ projectSectionData.grabExcessVerticalSpace = expandProjectSection;
+ projectSection.setExpanded(expandProjectSection);
+ }
+ if((mask & RELOAD_PARENT) != 0) {
+ //parent section
+ Element parent = findChild(root, PARENT);
+ String parentGrId = getTextValue(findChild(parent, GROUP_ID));
+ String parentArtId = getTextValue(findChild(parent, ARTIFACT_ID));
+ String parentVers = getTextValue(findChild(parent, VERSION));
+ setText(parentGroupIdText, nvl(parentGrId));
+ setText(parentArtifactIdText, nvl(parentArtId));
+ setText(parentVersionText, nvl(parentVers));
+ setText(parentRelativePathText, nvl(getTextValue(findChild(parent, RELATIVE_PATH))));
+
+ parentSelectAction.setEnabled(!isReadOnly());
+ // only enable when all 3 coordinates are actually present.
+ parentOpenAction
+ .setEnabled(root != null && parentGrId != null && parentArtId != null && parentVers != null);
+ parentSection.setExpanded(parent != null);
+ }
+ if((mask & RELOAD_ORG) != 0) {
+ //organization section
+ Element org = findChild(root, ORGANIZATION);
+ setText(organizationNameText, nvl(getTextValue(findChild(org, NAME))));
+ setText(organizationUrlText, nvl(getTextValue(findChild(org, URL))));
+ organizationSection.setExpanded(org != null);
+ }
+ if((mask & RELOAD_SCM) != 0) {
+ //scm section
+ Element scm = findChild(root, SCM);
+ setText(scmUrlText, nvl(getTextValue(findChild(scm, URL))));
+ setText(scmConnectionText, nvl(getTextValue(findChild(scm, CONNECTION))));
+ setText(scmDevConnectionText, nvl(getTextValue(findChild(scm, DEV_CONNECTION))));
+ setText(scmTagText, nvl(getTextValue(findChild(scm, TAG))));
+ scmSection.setExpanded(scm != null);
+ }
+ if((mask & RELOAD_CI) != 0) {
+ //ci section
+ Element ci = findChild(root, CI_MANAGEMENT);
+ setText(ciManagementSystemCombo, nvl(getTextValue(findChild(ci, SYSTEM))));
+ setText(ciManagementUrlCombo, nvl(getTextValue(findChild(ci, URL))));
+ ciManagementSection.setExpanded(ci != null);
+ }
+ if((mask & RELOAD_IM) != 0) {
+ // issue management
+ Element im = findChild(root, ISSUE_MANAGEMENT);
+ setText(issueManagementSystemCombo, nvl(getTextValue(findChild(im, SYSTEM))));
+ setText(issueManagementUrlCombo, nvl(getTextValue(findChild(im, URL))));
+ issueManagementSection.setExpanded(im != null);
+ }
- if((mask & RELOAD_PROPERTIES) != 0) {
- propertiesSection.refresh();
- Element props = findChild(root, PROPERTIES);
- propertiesSection.setExpanded(props != null);
- //TODO used to check teh model's empty state as well, not done now..
+ if((mask & RELOAD_MODULES) != 0) {
+ //modules section..
+ List<Element> moduleEls = findChilds(findChild(root, MODULES), MODULE);
+ List<String> modules = new ArrayList<String>();
+ for(Element moduleEl : moduleEls) {
+ String text = getTextValue(moduleEl);
+ if(text != null) {
+ modules.add(text);
}
}
- }, true));
- } catch(Exception e) {
- LOG.error("Failed to populate overview panel", e);
- }
+ loadModules(modules, pack);
+ //#335337 no editing of packaging when there are modules, results in error anyway
+ if(modules.size() > 0) {
+ artifactPackagingCombo.setEnabled(false);
+ } else {
+ artifactPackagingCombo.setEnabled(true);
+ }
+ }
- addNotifyListener(artifactGroupIdText);
- addNotifyListener(artifactIdText);
- addNotifyListener(artifactVersionText);
- addNotifyListener(artifactPackagingCombo);
- addNotifyListener(projectNameText);
- addNotifyListener(projectDescriptionText);
- addNotifyListener(projectUrlText);
- addNotifyListener(inceptionYearText);
-
- addNotifyListener(parentGroupIdText);
- addNotifyListener(parentArtifactIdText);
- addNotifyListener(parentVersionText);
- addNotifyListener(parentRelativePathText);
-
- addNotifyListener(organizationNameText);
- addNotifyListener(organizationUrlText);
-
- addNotifyListener(scmUrlText);
- addNotifyListener(scmConnectionText);
- addNotifyListener(scmDevConnectionText);
- addNotifyListener(scmTagText);
-
- addNotifyListener(ciManagementUrlCombo);
- addNotifyListener(ciManagementSystemCombo);
-
- addNotifyListener(issueManagementUrlCombo);
- addNotifyListener(issueManagementSystemCombo);
+ if((mask & RELOAD_PROPERTIES) != 0) {
+ propertiesSection.refresh();
+ Element props = findChild(root, PROPERTIES);
+ propertiesSection.setExpanded(props != null);
+ //TODO used to check teh model's empty state as well, not done now..
+ }
+ }, true));
+ } catch(Exception e) {
+ LOG.error("Failed to populate overview panel", e);
}
+
+ addNotifyListener(artifactGroupIdText);
+ addNotifyListener(artifactIdText);
+ addNotifyListener(artifactVersionText);
+ addNotifyListener(artifactPackagingCombo);
+ addNotifyListener(projectNameText);
+ addNotifyListener(projectDescriptionText);
+ addNotifyListener(projectUrlText);
+ addNotifyListener(inceptionYearText);
+
+ addNotifyListener(parentGroupIdText);
+ addNotifyListener(parentArtifactIdText);
+ addNotifyListener(parentVersionText);
+ addNotifyListener(parentRelativePathText);
+
+ addNotifyListener(organizationNameText);
+ addNotifyListener(organizationUrlText);
+
+ addNotifyListener(scmUrlText);
+ addNotifyListener(scmConnectionText);
+ addNotifyListener(scmDevConnectionText);
+ addNotifyListener(scmTagText);
+
+ addNotifyListener(ciManagementUrlCombo);
+ addNotifyListener(ciManagementSystemCombo);
+
+ addNotifyListener(issueManagementUrlCombo);
+ addNotifyListener(issueManagementSystemCombo);
});
}
@@ -1287,14 +1269,11 @@ public class OverviewPage extends MavenPomEditorPage {
private void createNewModule(final String moduleName) {
try {
- performEditOperation(new Operation() {
- //same with MavenModuleWizard's module adding operation..
- public void process(Document document) {
- Element root = document.getDocumentElement();
- Element modules = getChild(root, MODULES);
- if(findChild(modules, MODULE, textEquals(moduleName)) == null) {
- format(createElementWithText(modules, MODULE, moduleName));
- }
+ performEditOperation(document -> {
+ Element root = document.getDocumentElement();
+ Element modules = getChild(root, MODULES);
+ if(findChild(modules, MODULE, textEquals(moduleName)) == null) {
+ format(createElementWithText(modules, MODULE, moduleName));
}
}, LOG, "error updating modules list for pom file");
} finally {
@@ -1305,23 +1284,21 @@ public class OverviewPage extends MavenPomEditorPage {
private void addSelectedModules(Object[] result, boolean updateParentSection) {
final String[] vals = new String[3];
try {
- performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element root = document.getDocumentElement();
- String grid = getTextValue(findChild(root, GROUP_ID));
- Element parent = findChild(root, PARENT);
- if(grid == null) {
- grid = getTextValue(findChild(parent, GROUP_ID));
- }
- String artifactId = getTextValue(findChild(root, ARTIFACT_ID));
- String version = getTextValue(findChild(root, VERSION));
- if(version == null) {
- version = getTextValue(findChild(parent, VERSION));
- }
- vals[0] = grid;
- vals[1] = artifactId;
- vals[2] = version;
+ performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
+ Element root = document.getDocumentElement();
+ String grid = getTextValue(findChild(root, GROUP_ID));
+ Element parent = findChild(root, PARENT);
+ if(grid == null) {
+ grid = getTextValue(findChild(parent, GROUP_ID));
+ }
+ String artifactId = getTextValue(findChild(root, ARTIFACT_ID));
+ String version = getTextValue(findChild(root, VERSION));
+ if(version == null) {
+ version = getTextValue(findChild(parent, VERSION));
}
+ vals[0] = grid;
+ vals[1] = artifactId;
+ vals[2] = version;
}, true));
} catch(Exception ex) {
LOG.error("Error getting values from document", ex);
@@ -1356,24 +1333,22 @@ public class OverviewPage extends MavenPomEditorPage {
if(updateParentSection) {
final String relativePath = projectPath.makeRelativeTo(resultPath).toString();
try {
- performOnDOMDocument(new OperationTuple(pomFile, new Operation() {
- public void process(Document document) {
- Element root = document.getDocumentElement();
- Element parent = getChild(root, PARENT);
- setText(getChild(parent, GROUP_ID), parentGroupId);
- setText(getChild(parent, ARTIFACT_ID), parentArtifactId);
- setText(getChild(parent, VERSION), parentVersion);
- setText(getChild(parent, RELATIVE_PATH), relativePath);
- Element grId = findChild(root, GROUP_ID);
- String grIdText = getTextValue(grId);
- if(grIdText != null && grIdText.equals(parentGroupId)) {
- removeChild(root, grId);
- }
- Element ver = findChild(root, VERSION);
- String verText = getTextValue(ver);
- if(verText != null && verText.equals(parentVersion)) {
- removeChild(root, ver);
- }
+ performOnDOMDocument(new OperationTuple(pomFile, (Operation) document -> {
+ Element root = document.getDocumentElement();
+ Element parent = getChild(root, PARENT);
+ setText(getChild(parent, GROUP_ID), parentGroupId);
+ setText(getChild(parent, ARTIFACT_ID), parentArtifactId);
+ setText(getChild(parent, VERSION), parentVersion);
+ setText(getChild(parent, RELATIVE_PATH), relativePath);
+ Element grId = findChild(root, GROUP_ID);
+ String grIdText = getTextValue(grId);
+ if(grIdText != null && grIdText.equals(parentGroupId)) {
+ removeChild(root, grId);
+ }
+ Element ver = findChild(root, VERSION);
+ String verText = getTextValue(ver);
+ if(verText != null && verText.equals(parentVersion)) {
+ removeChild(root, ver);
}
}));
} catch(Exception e) {
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 205ce7b0..95dbf26d 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
@@ -26,21 +26,17 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.eclipse.emf.ecore.xml.type.internal.DataValue.XMLChar;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
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.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -52,7 +48,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.m2e.core.ui.internal.dialogs.MavenPropertyDialog;
-import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
import org.eclipse.m2e.editor.MavenEditorImages;
import org.eclipse.m2e.editor.composites.ListEditorComposite;
@@ -79,11 +74,7 @@ public class PropertiesSection {
ListEditorComposite<PropertyElement> propertiesEditor;
- private VerifyListener listener = new VerifyListener() {
- public void verifyText(VerifyEvent e) {
- e.doit = XMLChar.isValidName(e.text);
- }
- };
+ private VerifyListener listener = e -> e.doit = XMLChar.isValidName(e.text);
private GridData propertiesSectionData;
@@ -98,16 +89,14 @@ public class PropertiesSection {
final List<PropertyElement> toRet = new ArrayList<PropertyElement>();
try {
- performOnDOMDocument(new OperationTuple(page.getPomEditor().getDocument(), new Operation() {
- public void process(Document document) {
- Element properties = findChild(document.getDocumentElement(), PROPERTIES);
- if(properties != null) {
- NodeList nl = properties.getChildNodes();
- for(int i = 0; i < nl.getLength(); i++ ) {
- Node child = nl.item(i);
- if(child instanceof Element) {
- toRet.add(new PropertyElement(child.getNodeName(), getTextValue(child)));
- }
+ performOnDOMDocument(new OperationTuple(page.getPomEditor().getDocument(), document -> {
+ Element properties = findChild(document.getDocumentElement(), PROPERTIES);
+ if(properties != null) {
+ NodeList nl = properties.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++ ) {
+ Node child = nl.item(i);
+ if(child instanceof Element) {
+ toRet.add(new PropertyElement(child.getNodeName(), getTextValue(child)));
}
}
}
@@ -150,11 +139,7 @@ public class PropertiesSection {
deleteProperties(propertiesEditor.getSelection());
}
});
- propertiesEditor.setDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- editProperty(propertiesEditor.getSelection());
- }
- });
+ propertiesEditor.setDoubleClickListener(event -> editProperty(propertiesEditor.getSelection()));
toolkit.paintBordersFor(propertiesEditor);
toolkit.adapt(propertiesEditor);
@@ -180,23 +165,21 @@ public class PropertiesSection {
final String key = dialog.getName();
final String value = dialog.getValue();
try {
- page.performEditOperation(new Operation() {
- public void process(Document document) {
- Element properties = getChild(document.getDocumentElement(), PROPERTIES);
- Element old = findChild(properties, pp.getName());
- if(old == null) {
- //should never happen..
- old = getChild(properties, pp.getName());
- }
- if(!pp.getName().equals(key)) {
- Element newElement = document.createElement(key);
- properties.replaceChild(newElement, old);
- setText(newElement, pp.getValue());
- old = newElement;
- }
- if(!pp.getValue().equals(value)) {
- setText(old, value);
- }
+ page.performEditOperation(document -> {
+ Element properties = getChild(document.getDocumentElement(), PROPERTIES);
+ Element old = findChild(properties, pp.getName());
+ if(old == null) {
+ //should never happen..
+ old = getChild(properties, pp.getName());
+ }
+ if(!pp.getName().equals(key)) {
+ Element newElement = document.createElement(key);
+ properties.replaceChild(newElement, old);
+ setText(newElement, pp.getValue());
+ old = newElement;
+ }
+ if(!pp.getValue().equals(value)) {
+ setText(old, value);
}
}, LOG, "error updating property");
} finally {
@@ -212,11 +195,9 @@ public class PropertiesSection {
final String key = dialog.getName();
final String value = dialog.getValue();
try {
- page.performEditOperation(new Operation() {
- public void process(Document document) {
- Element prop = getChild(document.getDocumentElement(), PROPERTIES, key);
- setText(prop, value);
- }
+ page.performEditOperation(document -> {
+ Element prop = getChild(document.getDocumentElement(), PROPERTIES, key);
+ setText(prop, value);
}, LOG, "error creating property");
} finally {
propertiesEditor.setInput(getProperties());
@@ -226,17 +207,15 @@ public class PropertiesSection {
void deleteProperties(final List<PropertyElement> selection) {
try {
- page.performEditOperation(new Operation() {
- public void process(Document document) {
- Element props = findChild(document.getDocumentElement(), PROPERTIES);
- if(props != null) {
- //now what if we don't find the props? profile or parent? or out of sync?
- for(PropertyElement el : selection) {
- Element prop = findChild(props, el.getName());
- removeChild(props, prop);
- }
- removeIfNoChildElement(props);
+ page.performEditOperation(document -> {
+ Element props = findChild(document.getDocumentElement(), PROPERTIES);
+ if(props != null) {
+ //now what if we don't find the props? profile or parent? or out of sync?
+ for(PropertyElement el : selection) {
+ Element prop = findChild(props, el.getName());
+ removeChild(props, prop);
}
+ removeIfNoChildElement(props);
}
}, LOG, "error deleting property");
} finally {
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 eb77cda3..998ea462 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
@@ -13,8 +13,6 @@ package org.eclipse.m2e.editor.pom;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -96,11 +94,7 @@ public class SearchControl extends ControlContribution {
}
});
- searchText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- clearToolItem.setEnabled(searchText.getText().length() > 0);
- }
- });
+ searchText.addModifyListener(e -> clearToolItem.setEnabled(searchText.getText().length() > 0));
toolkit.paintBordersFor(composite);
diff --git a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/actions/OpenJavaDocAction.java b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/actions/OpenJavaDocAction.java
index a0b673f7..d9abd45c 100644
--- a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/actions/OpenJavaDocAction.java
+++ b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/actions/OpenJavaDocAction.java
@@ -83,12 +83,9 @@ public class OpenJavaDocAction extends ActionDelegate {
} catch(CoreException ex) {
log.error(ex.getMessage(), ex);
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
- Messages.OpenJavaDocAction_error_title, Messages.OpenJavaDocAction_error_message);
- }
- });
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
+ Messages.OpenJavaDocAction_error_title, Messages.OpenJavaDocAction_error_message));
}
}
}
@@ -110,19 +107,17 @@ public class OpenJavaDocAction extends ActionDelegate {
return;
}
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- try {
- String url = "jar:" + file.toURI().toString() + "!/index.html"; //$NON-NLS-1$ //$NON-NLS-2$
- URL helpUrl = PlatformUI.getWorkbench().getHelpSystem().resolve(url, true);
-
- IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
- IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR, //
- name, name, name);
- browser.openURL(helpUrl);
- } catch(PartInitException ex) {
- log.error(ex.getMessage(), ex);
- }
+ PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
+ try {
+ String url = "jar:" + file.toURI().toString() + "!/index.html"; //$NON-NLS-1$ //$NON-NLS-2$
+ URL helpUrl = PlatformUI.getWorkbench().getHelpSystem().resolve(url, true);
+
+ IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
+ IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR, //
+ name, name, name);
+ browser.openURL(helpUrl);
+ } catch(PartInitException ex) {
+ log.error(ex.getMessage(), ex);
}
});
@@ -135,12 +130,9 @@ public class OpenJavaDocAction extends ActionDelegate {
}
private static void openDialog(final String msg) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
- Messages.OpenJavaDocAction_info_title, msg);
- }
- });
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> MessageDialog.openInformation(Display.getDefault().getActiveShell(), //
+ Messages.OpenJavaDocAction_info_title, msg));
}
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchExtensionsTab.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchExtensionsTab.java
index e42a5e44..7fdfc115 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchExtensionsTab.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchExtensionsTab.java
@@ -21,9 +21,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -66,18 +64,16 @@ public class MavenLaunchExtensionsTab extends AbstractLaunchConfigurationTab {
lblMavenLaunchExtensions.setText(Messages.MavenLaunchExtensionsTab_lblExtensions);
checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION);
- checkboxTableViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- if(event.getElement() instanceof MavenLaunchParticipantInfo) {
- MavenLaunchParticipantInfo participant = (MavenLaunchParticipantInfo) event.getElement();
- if(event.getChecked()) {
- disabledParticipants.remove(participant.getId());
- } else {
- disabledParticipants.add(participant.getId());
- }
- setDirty(true);
- updateLaunchConfigurationDialog();
+ checkboxTableViewer.addCheckStateListener(event -> {
+ if(event.getElement() instanceof MavenLaunchParticipantInfo) {
+ MavenLaunchParticipantInfo participant = (MavenLaunchParticipantInfo) event.getElement();
+ if(event.getChecked()) {
+ disabledParticipants.remove(participant.getId());
+ } else {
+ disabledParticipants.add(participant.getId());
}
+ setDirty(true);
+ updateLaunchConfigurationDialog();
}
});
Table table = checkboxTableViewer.getTable();
@@ -145,8 +141,8 @@ public class MavenLaunchExtensionsTab extends AbstractLaunchConfigurationTab {
@SuppressWarnings("unchecked")
public void initializeFrom(ILaunchConfiguration configuration) {
try {
- disabledParticipants = new HashSet<String>(configuration.getAttribute(
- MavenLaunchConstants.ATTR_DISABLED_EXTENSIONS, Collections.EMPTY_SET));
+ disabledParticipants = new HashSet<String>(
+ configuration.getAttribute(MavenLaunchConstants.ATTR_DISABLED_EXTENSIONS, Collections.EMPTY_SET));
} catch(CoreException ex) {
disabledParticipants = new HashSet<String>();
}
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 0bd4c0ea..06cfcdeb 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
@@ -30,10 +30,6 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
@@ -314,30 +310,24 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement
new Label(mainComposite, SWT.NONE);
TableViewer tableViewer = new TableViewer(mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
- tableViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TableItem[] selection = propsTable.getSelection();
- if(selection.length == 1) {
- editProperty(selection[0].getText(0), selection[0].getText(1));
- }
+ tableViewer.addDoubleClickListener(event -> {
+ TableItem[] selection = propsTable.getSelection();
+ if(selection.length == 1) {
+ editProperty(selection[0].getText(0), selection[0].getText(1));
}
});
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- TableItem[] items = propsTable.getSelection();
- if(items == null || items.length == 0) {
- editPropButton.setEnabled(false);
- removePropButton.setEnabled(false);
- } else if(items.length == 1) {
- editPropButton.setEnabled(true);
- removePropButton.setEnabled(true);
- } else {
- editPropButton.setEnabled(false);
- removePropButton.setEnabled(true);
- }
+ tableViewer.addSelectionChangedListener(event -> {
+ TableItem[] items = propsTable.getSelection();
+ if(items == null || items.length == 0) {
+ editPropButton.setEnabled(false);
+ removePropButton.setEnabled(false);
+ } else if(items.length == 1) {
+ editPropButton.setEnabled(true);
+ removePropButton.setEnabled(true);
+ } else {
+ editPropButton.setEnabled(false);
+ removePropButton.setEnabled(true);
}
-
});
this.propsTable = tableViewer.getTable();
@@ -395,11 +385,7 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement
runtimeSelector = new MavenRuntimeSelector(mainComposite);
runtimeSelector.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
- runtimeSelector.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- entriesChanged();
- }
- });
+ runtimeSelector.addSelectionChangedListener(event -> entriesChanged());
goalsText.setFocus();
}
@@ -472,8 +458,8 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement
IMavenConfiguration mavenConfiguration = MavenPlugin.getMavenConfiguration();
this.offlineButton.setSelection(getAttribute(configuration, ATTR_OFFLINE, mavenConfiguration.isOffline()));
- this.debugOutputButton.setSelection(getAttribute(configuration, ATTR_DEBUG_OUTPUT,
- mavenConfiguration.isDebugOutput()));
+ this.debugOutputButton
+ .setSelection(getAttribute(configuration, ATTR_DEBUG_OUTPUT, mavenConfiguration.isDebugOutput()));
this.updateSnapshotsButton.setSelection(getAttribute(configuration, ATTR_UPDATE_SNAPSHOTS, false));
this.skipTestsButton.setSelection(getAttribute(configuration, ATTR_SKIP_TESTS, false));
diff --git a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/ProfileSelectionHandler.java b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/ProfileSelectionHandler.java
index 5009e628..86577d5c 100644
--- a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/ProfileSelectionHandler.java
+++ b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/actions/ProfileSelectionHandler.java
@@ -119,17 +119,14 @@ public class ProfileSelectionHandler extends AbstractHandler {
@Override
public void done(IJobChangeEvent event) {
if(getProfilesJob.getResult().isOK()) {
- shell.getDisplay().syncExec(new Runnable() {
-
- public void run() {
- List<ProfileSelection> sharedProfiles = getProfilesJob.getSharedProfiles();
- Map<IMavenProjectFacade, List<ProfileData>> allProfiles = getProfilesJob.getAllProfiles();
- final SelectProfilesDialog dialog = new SelectProfilesDialog(shell, facades, sharedProfiles);
- if(dialog.open() == Dialog.OK) {
- Job job = new UpdateProfilesJob(allProfiles, sharedProfiles, profileManager, dialog);
- job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
- job.schedule();
- }
+ shell.getDisplay().syncExec(() -> {
+ List<ProfileSelection> sharedProfiles = getProfilesJob.getSharedProfiles();
+ Map<IMavenProjectFacade, List<ProfileData>> allProfiles = getProfilesJob.getAllProfiles();
+ final SelectProfilesDialog dialog = new SelectProfilesDialog(shell, facades, sharedProfiles);
+ if(dialog.open() == Dialog.OK) {
+ Job job = new UpdateProfilesJob(allProfiles, sharedProfiles, profileManager, dialog);
+ job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
+ job.schedule();
}
});
diff --git a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/dialog/SelectProfilesDialog.java b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/dialog/SelectProfilesDialog.java
index 7c011272..54785d04 100644
--- a/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/dialog/SelectProfilesDialog.java
+++ b/org.eclipse.m2e.profiles.ui/src/org/eclipse/m2e/profiles/ui/internal/dialog/SelectProfilesDialog.java
@@ -8,6 +8,7 @@
* Contributors:
* Fred Bricon / JBoss by Red Hat - Initial implementation.
************************************************************************************/
+
package org.eclipse.m2e.profiles.ui.internal.dialog;
import java.util.Iterator;
@@ -23,19 +24,13 @@ import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.profiles.core.internal.ProfileState;
-import org.eclipse.m2e.profiles.ui.internal.Messages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -57,6 +52,12 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.profiles.core.internal.ProfileState;
+import org.eclipse.m2e.profiles.ui.internal.Messages;
+
+
/**
* Maven Profile selection dialog.
*
@@ -64,439 +65,421 @@ import org.eclipse.swt.widgets.Text;
* @since 1.5.0
*/
@SuppressWarnings("synthetic-access")
-public class SelectProfilesDialog extends TitleAreaDialog implements
- IMenuListener {
-
- private static int PROFILE_ID_COLUMN = 0;
- private static int SOURCE_COLUMN = 1;
-
- private CheckboxTableViewer profileTableViewer;
- private Button offlineModeBtn;
- private Button forceUpdateBtn;
- private Text profilesText;
-
- private boolean offlineMode ;
- private boolean forceUpdate;
-
- List<ProfileSelection> sharedProfiles;
- Set<IMavenProjectFacade> facades;
- IMavenProjectFacade facade;
-
- final Action activationAction = new ChangeProfileStateAction(ProfileState.Active);
-
- final Action deActivationAction = new ChangeProfileStateAction(ProfileState.Disabled);
- private Label warningImg;
- private Label warningLabel;
-
- public SelectProfilesDialog(Shell parentShell, Set<IMavenProjectFacade> facades,
- List<ProfileSelection> sharedProfiles) {
- super(parentShell);
- setShellStyle(super.getShellStyle() | SWT.RESIZE | SWT.MODELESS);
- offlineMode = MavenPlugin.getMavenConfiguration().isOffline();
- this.facades = facades;
- if(facades.size() == 1){
- facade = facades.iterator().next();
- }
- this.sharedProfiles = sharedProfiles;
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(Messages.SelectProfilesDialog_Select_Maven_profiles);
- }
-
-
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite area = (Composite) super.createDialogArea(parent);
-
- Composite container = new Composite(area, SWT.NONE);
- container.setEnabled(true);
-
- GridLayout layout = new GridLayout(3, false);
- layout.marginLeft = 12;
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- setTitle(Messages.SelectProfilesDialog_Maven_profile_selection);
- String text;
- boolean hasProfiles = !sharedProfiles.isEmpty();
- if (facade == null) {
- text = NLS.bind(Messages.SelectProfilesDialog_Select_active_profiles_for_selected_projects,
- facades.size()
- );
- } else {
- text = NLS.bind(
- Messages.SelectProfilesDialog_Select_the_active_Maven_profiles,
- facade.getProject().getName());
- if (hasProfiles) {
- displayProfilesAsText(container);
- }
- }
- setMessage(text);
-
- if (hasProfiles && facade == null) {
- displayWarning(container);
- }
-
- Label lblAvailable = new Label(container, SWT.NONE);
- lblAvailable.setLayoutData(new GridData(SWT.WRAP, SWT.CENTER, true,
- false, 2, 1));
-
- String textLabel = getAvailableText(hasProfiles);
- lblAvailable.setText(textLabel);
-
- if (hasProfiles) {
-
- displayProfilesTable(container);
-
- addSelectionButton(container, Messages.SelectProfilesDialog_SelectAll, true);
- addSelectionButton(container, Messages.SelectProfilesDialog_DeselectAll, false);
- addActivationButton(container, "Activate", ProfileState.Active);
- addActivationButton(container, "Deactivate", ProfileState.Disabled);
- offlineModeBtn = addCheckButton(container, Messages.SelectProfilesDialog_Offline, offlineMode);
- forceUpdateBtn = addCheckButton(container, Messages.SelectProfilesDialog_Force_update, forceUpdate);
- }
-
- return area;
- }
-
- private void displayWarning(Composite container) {
- warningImg = new Label(container, SWT.CENTER);
- warningLabel = new Label(container, SWT.NONE);
- warningLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(warningImg);
- warningImg.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING));
- warningLabel.setText( Messages.SelectProfilesDialog_Warning_Common_profiles);
- }
-
- private String getAvailableText(boolean hasProfiles) {
- String textLabel;
- if (hasProfiles) {
- textLabel = Messages.SelectProfilesDialog_Available_profiles;
- } else {
- if (facade == null) {
- textLabel = NLS.bind(Messages.SelectProfilesDialog_No_Common_Profiles,
- facades.size());
- } else {
- textLabel =
- NLS.bind(Messages.SelectProfilesDialog_Project_has_no_available_profiles,
- facade.getProject().getName());
- }
- }
- return textLabel;
- }
-
- private void displayProfilesTable(Composite container) {
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 4);
- gd.heightHint = 200;
- gd.widthHint = 500;
-
- profileTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.MULTI);
- Table table = profileTableViewer.getTable();
- table.setFocus();
- table.setLayoutData(gd);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
-
- TableColumn profileColumn = new TableColumn(table, SWT.NONE);
- profileColumn.setText(Messages.SelectProfilesDialog_Profile_id_header);
- profileColumn.setWidth(350);
-
- TableColumn sourceColumn = new TableColumn(table, SWT.NONE);
- sourceColumn.setText(Messages.SelectProfilesDialog_Profile_source_header);
- sourceColumn.setWidth(120);
-
-
- profileTableViewer.setContentProvider(ArrayContentProvider.getInstance());
-
- profileTableViewer.setLabelProvider(new ProfileLabelProvider(container
- .getFont()));
-
-
- profileTableViewer.addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- ProfileSelection profile = (ProfileSelection) event.getElement();
- if (profileTableViewer.getGrayed(profile)) {
- profileTableViewer.setGrayed(profile, false);
- }
- profile.setSelected(profileTableViewer.getChecked(profile));
- if (Boolean.FALSE.equals(profile.getSelected())
- || profile.getActivationState() == null) {
- profile.setActivationState(ProfileState.Active);
- }
-
- updateProfilesAsText();
- profileTableViewer.refresh();
- }
- });
-
- profileTableViewer.setInput(sharedProfiles);
-
- createMenu();
- }
-
- private void displayProfilesAsText(Composite container) {
- Label profilesLabel = new Label(container, SWT.NONE);
- profilesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
- profilesLabel.setText(NLS.bind(Messages.SelectProfilesDialog_Active_Profiles_for_Project,
- facade.getProject().getName()));
-
- profilesText = new Text(container, SWT.BORDER);
- profilesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
- profilesText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- profilesText.setEditable(false);
- profilesText.setToolTipText(Messages.SelectProfilesDialog_Read_Only_profiles);
-
- updateProfilesAsText();
- }
-
- private void updateProfilesAsText() {
- if (profilesText != null) {
- profilesText.setText(ProfileUtil.toString(sharedProfiles));
- }
- }
-
- private Button addCheckButton(Composite container, String label, boolean selected) {
- Button checkBtn = new Button(container, SWT.CHECK);
- checkBtn.setText(label);
- checkBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
- true, false, 2, 1));
- checkBtn.setSelection(selected);
- return checkBtn;
- }
-
- private Button addSelectionButton(Composite container, String label, final boolean ischecked) {
- Button button = new Button(container, SWT.NONE);
- button.setLayoutData(new GridData(SWT.FILL, SWT.UP,
- false, false, 1, 1));
- button.setText(label);
- button.addSelectionListener(new SelectionListener() {
+public class SelectProfilesDialog extends TitleAreaDialog implements IMenuListener {
+
+ private static int PROFILE_ID_COLUMN = 0;
+
+ private static int SOURCE_COLUMN = 1;
+
+ private CheckboxTableViewer profileTableViewer;
+
+ private Button offlineModeBtn;
+
+ private Button forceUpdateBtn;
+
+ private Text profilesText;
+
+ private boolean offlineMode;
+
+ private boolean forceUpdate;
+
+ List<ProfileSelection> sharedProfiles;
+
+ Set<IMavenProjectFacade> facades;
+
+ IMavenProjectFacade facade;
+
+ final Action activationAction = new ChangeProfileStateAction(ProfileState.Active);
+
+ final Action deActivationAction = new ChangeProfileStateAction(ProfileState.Disabled);
+
+ private Label warningImg;
+
+ private Label warningLabel;
+
+ public SelectProfilesDialog(Shell parentShell, Set<IMavenProjectFacade> facades,
+ List<ProfileSelection> sharedProfiles) {
+ super(parentShell);
+ setShellStyle(super.getShellStyle() | SWT.RESIZE | SWT.MODELESS);
+ offlineMode = MavenPlugin.getMavenConfiguration().isOffline();
+ this.facades = facades;
+ if(facades.size() == 1) {
+ facade = facades.iterator().next();
+ }
+ this.sharedProfiles = sharedProfiles;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(Messages.SelectProfilesDialog_Select_Maven_profiles);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite area = (Composite) super.createDialogArea(parent);
+
+ Composite container = new Composite(area, SWT.NONE);
+ container.setEnabled(true);
+
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginLeft = 12;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ setTitle(Messages.SelectProfilesDialog_Maven_profile_selection);
+ String text;
+ boolean hasProfiles = !sharedProfiles.isEmpty();
+ if(facade == null) {
+ text = NLS.bind(Messages.SelectProfilesDialog_Select_active_profiles_for_selected_projects, facades.size());
+ } else {
+ text = NLS.bind(Messages.SelectProfilesDialog_Select_the_active_Maven_profiles, facade.getProject().getName());
+ if(hasProfiles) {
+ displayProfilesAsText(container);
+ }
+ }
+ setMessage(text);
+
+ if(hasProfiles && facade == null) {
+ displayWarning(container);
+ }
+
+ Label lblAvailable = new Label(container, SWT.NONE);
+ lblAvailable.setLayoutData(new GridData(SWT.WRAP, SWT.CENTER, true, false, 2, 1));
+
+ String textLabel = getAvailableText(hasProfiles);
+ lblAvailable.setText(textLabel);
+
+ if(hasProfiles) {
+
+ displayProfilesTable(container);
+
+ addSelectionButton(container, Messages.SelectProfilesDialog_SelectAll, true);
+ addSelectionButton(container, Messages.SelectProfilesDialog_DeselectAll, false);
+ addActivationButton(container, "Activate", ProfileState.Active);
+ addActivationButton(container, "Deactivate", ProfileState.Disabled);
+ offlineModeBtn = addCheckButton(container, Messages.SelectProfilesDialog_Offline, offlineMode);
+ forceUpdateBtn = addCheckButton(container, Messages.SelectProfilesDialog_Force_update, forceUpdate);
+ }
+
+ return area;
+ }
+
+ private void displayWarning(Composite container) {
+ warningImg = new Label(container, SWT.CENTER);
+ warningLabel = new Label(container, SWT.NONE);
+ warningLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(warningImg);
+ warningImg.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING));
+ warningLabel.setText(Messages.SelectProfilesDialog_Warning_Common_profiles);
+ }
+
+ private String getAvailableText(boolean hasProfiles) {
+ String textLabel;
+ if(hasProfiles) {
+ textLabel = Messages.SelectProfilesDialog_Available_profiles;
+ } else {
+ if(facade == null) {
+ textLabel = NLS.bind(Messages.SelectProfilesDialog_No_Common_Profiles, facades.size());
+ } else {
+ textLabel = NLS.bind(Messages.SelectProfilesDialog_Project_has_no_available_profiles,
+ facade.getProject().getName());
+ }
+ }
+ return textLabel;
+ }
+
+ private void displayProfilesTable(Composite container) {
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 4);
+ gd.heightHint = 200;
+ gd.widthHint = 500;
+
+ profileTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.MULTI);
+ Table table = profileTableViewer.getTable();
+ table.setFocus();
+ table.setLayoutData(gd);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ TableColumn profileColumn = new TableColumn(table, SWT.NONE);
+ profileColumn.setText(Messages.SelectProfilesDialog_Profile_id_header);
+ profileColumn.setWidth(350);
+
+ TableColumn sourceColumn = new TableColumn(table, SWT.NONE);
+ sourceColumn.setText(Messages.SelectProfilesDialog_Profile_source_header);
+ sourceColumn.setWidth(120);
+
+ profileTableViewer.setContentProvider(ArrayContentProvider.getInstance());
+
+ profileTableViewer.setLabelProvider(new ProfileLabelProvider(container.getFont()));
+
+ profileTableViewer.addCheckStateListener(event -> {
+ ProfileSelection profile = (ProfileSelection) event.getElement();
+ if(profileTableViewer.getGrayed(profile)) {
+ profileTableViewer.setGrayed(profile, false);
+ }
+ profile.setSelected(profileTableViewer.getChecked(profile));
+ if(Boolean.FALSE.equals(profile.getSelected()) || profile.getActivationState() == null) {
+ profile.setActivationState(ProfileState.Active);
+ }
+
+ updateProfilesAsText();
+ profileTableViewer.refresh();
+ });
+
+ profileTableViewer.setInput(sharedProfiles);
+
+ createMenu();
+ }
+
+ private void displayProfilesAsText(Composite container) {
+ Label profilesLabel = new Label(container, SWT.NONE);
+ profilesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
+ profilesLabel
+ .setText(NLS.bind(Messages.SelectProfilesDialog_Active_Profiles_for_Project, facade.getProject().getName()));
+
+ profilesText = new Text(container, SWT.BORDER);
+ profilesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+ profilesText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
+ profilesText.setEditable(false);
+ profilesText.setToolTipText(Messages.SelectProfilesDialog_Read_Only_profiles);
+
+ updateProfilesAsText();
+ }
+
+ private void updateProfilesAsText() {
+ if(profilesText != null) {
+ profilesText.setText(ProfileUtil.toString(sharedProfiles));
+ }
+ }
+
+ private Button addCheckButton(Composite container, String label, boolean selected) {
+ Button checkBtn = new Button(container, SWT.CHECK);
+ checkBtn.setText(label);
+ checkBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ checkBtn.setSelection(selected);
+ return checkBtn;
+ }
+
+ private Button addSelectionButton(Composite container, String label, final boolean ischecked) {
+ Button button = new Button(container, SWT.NONE);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.UP, false, false, 1, 1));
+ button.setText(label);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ profileTableViewer.setAllGrayed(false);
+ for(ProfileSelection profile : sharedProfiles) {
+ profileTableViewer.setChecked(profile, ischecked);
+ profile.setSelected(ischecked);
+ if(!ischecked || profile.getActivationState() == null) {
+ profile.setActivationState(ProfileState.Active);
+ }
+ }
+ refresh();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return button;
+ }
+
+ private Button addActivationButton(Composite container, String label, final ProfileState state) {
+ Button button = new Button(container, SWT.NONE);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.UP, false, false, 1, 1));
+ button.setText(label);
+ button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- profileTableViewer.setAllGrayed(false);
- for (ProfileSelection profile : sharedProfiles) {
- profileTableViewer.setChecked(profile, ischecked);
- profile.setSelected(ischecked);
- if (!ischecked || profile.getActivationState() == null) {
- profile.setActivationState(ProfileState.Active);
- }
- }
- refresh();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
- });
-
- return button;
- }
-
- private Button addActivationButton(Composite container, String label, final ProfileState state) {
- Button button = new Button(container, SWT.NONE);
- button.setLayoutData(new GridData(SWT.FILL, SWT.UP,
- false, false, 1, 1));
- button.setText(label);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- ISelection s = profileTableViewer.getSelection();
- if (s instanceof IStructuredSelection) {
- IStructuredSelection sel = (IStructuredSelection) s;
- setActivationState(sel, state);
- }
- refresh();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
- });
-
- return button;
- }
-
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- if (profileTableViewer != null) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- }
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- @Override
- protected void okPressed() {
- if (profileTableViewer != null) {
- offlineMode = offlineModeBtn.getSelection();
- forceUpdate = forceUpdateBtn.getSelection();
- }
- super.okPressed();
- }
-
- private void createMenu() {
- MenuManager menuMgr = new MenuManager();
- Menu contextMenu = menuMgr.createContextMenu(profileTableViewer
- .getControl());
- menuMgr.addMenuListener(this);
- profileTableViewer.getControl().setMenu(contextMenu);
- menuMgr.setRemoveAllWhenShown(true);
-
- for (ProfileSelection p : sharedProfiles) {
- Boolean selected = p.getSelected();
- if (selected ==null || p.getActivationState() == null) {
- profileTableViewer.setGrayed(p, true);
- profileTableViewer.setChecked(p, true);
- } else {
- profileTableViewer.setChecked(p, selected );
- }
- }
- }
-
- public void menuAboutToShow(IMenuManager manager) {
-
- IStructuredSelection selection = (IStructuredSelection) profileTableViewer
- .getSelection();
- if (!selection.isEmpty()) {
- boolean multiSelection = selection.size() > 1;
- ProfileState state = null;
- String selectionText;
- String text;
- if (multiSelection) {
- selectionText = "selected profiles";
- } else {
- ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
- state = entry.getActivationState();
- selectionText = entry.getId();
- }
-
- if ( state == null || ProfileState.Disabled.equals(state)) {
- text = Messages.SelectProfilesDialog_Activate_menu;
- activationAction.setText(NLS.bind(text, selectionText));
- manager.add(activationAction);
- }
- if( !ProfileState.Disabled.equals(state)) {
- text = Messages.SelectProfilesDialog_Deactivate_menu;
- deActivationAction.setText(NLS.bind(text, selectionText));
- manager.add(deActivationAction);
- }
- }
- }
-
- public boolean isOffline() {
- return offlineMode;
- }
-
- public boolean isForceUpdate() {
- return forceUpdate;
- }
-
- private void setActivationState(final IStructuredSelection sel, ProfileState state) {
- if (sel == null) return;
- Iterator<?> ite = sel.iterator();
- while (ite.hasNext()) {
- Object o = ite.next();
- if (o instanceof ProfileSelection) {
- ProfileSelection ps = (ProfileSelection) o;
- ps.setActivationState(state);
- profileTableViewer.setGrayed(ps, false);
- if (ProfileState.Disabled.equals(state)) {
- profileTableViewer.setChecked(ps, true);
- ps.setSelected(true);
- }
- }
- }
- }
-
-
- private void refresh() {
- profileTableViewer.refresh();
- updateProfilesAsText();
- }
-
-
- private class ChangeProfileStateAction extends Action {
-
- private final ProfileState state;
-
- public ChangeProfileStateAction(ProfileState state) {
- this.state = state;
- }
-
- @Override
- public void run() {
- IStructuredSelection selection = (IStructuredSelection) profileTableViewer
- .getSelection();
- if (!selection.isEmpty()) {
- setActivationState(selection, state);
- refresh();
- }
- super.run();
- }
- }
-
- private class ProfileLabelProvider extends LabelProvider implements
- ITableLabelProvider, ITableFontProvider, ITableColorProvider {
-
- private Font implicitActivationFont;
-
- private Color inactiveColor;
-
- public ProfileLabelProvider(Font defaultFont) {
- FontData[] fds = defaultFont.getFontData();
- for (FontData fd : fds) {
- fd.setStyle(SWT.ITALIC);
- }
- implicitActivationFont = new Font(defaultFont.getDevice(), fds);
- inactiveColor = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
- }
-
- public Font getFont(Object element, int columnIndex) {
- ProfileSelection entry = (ProfileSelection) element;
- Font font = null;
- if (Boolean.TRUE.equals(entry.getAutoActive())
- && PROFILE_ID_COLUMN == columnIndex) {
- font = implicitActivationFont;
- }
- return font;
- }
-
- public Color getForeground(Object element, int columnIndex) {
- ProfileSelection entry = (ProfileSelection) element;
- if (ProfileState.Disabled.equals(entry.getActivationState())) {
- return inactiveColor;
- }
- return null;
- }
-
- public Color getBackground(Object element, int columnIndex) {
- return null;
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- ProfileSelection entry = (ProfileSelection) element;
- StringBuilder text = new StringBuilder();
- if (entry != null) {
- if (columnIndex == PROFILE_ID_COLUMN) {
- text.append(entry.getId());
- ProfileState state = entry.getActivationState();
- if (Boolean.TRUE.equals(entry.getSelected())
- && state == ProfileState.Disabled) {
- text.append(Messages.SelectProfilesDialog_deactivated);
- } else if (Boolean.TRUE.equals(entry.getAutoActive())) {
- text.append(Messages.SelectProfilesDialog_autoactivated);
- }
- } else if (columnIndex == SOURCE_COLUMN) {
- text.append(entry.getSource());
- }
- }
- return text.toString();
- }
- }
+ ISelection s = profileTableViewer.getSelection();
+ if(s instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) s;
+ setActivationState(sel, state);
+ }
+ refresh();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return button;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ if(profileTableViewer != null) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ @Override
+ protected void okPressed() {
+ if(profileTableViewer != null) {
+ offlineMode = offlineModeBtn.getSelection();
+ forceUpdate = forceUpdateBtn.getSelection();
+ }
+ super.okPressed();
+ }
+
+ private void createMenu() {
+ MenuManager menuMgr = new MenuManager();
+ Menu contextMenu = menuMgr.createContextMenu(profileTableViewer.getControl());
+ menuMgr.addMenuListener(this);
+ profileTableViewer.getControl().setMenu(contextMenu);
+ menuMgr.setRemoveAllWhenShown(true);
+
+ for(ProfileSelection p : sharedProfiles) {
+ Boolean selected = p.getSelected();
+ if(selected == null || p.getActivationState() == null) {
+ profileTableViewer.setGrayed(p, true);
+ profileTableViewer.setChecked(p, true);
+ } else {
+ profileTableViewer.setChecked(p, selected);
+ }
+ }
+ }
+
+ public void menuAboutToShow(IMenuManager manager) {
+
+ IStructuredSelection selection = (IStructuredSelection) profileTableViewer.getSelection();
+ if(!selection.isEmpty()) {
+ boolean multiSelection = selection.size() > 1;
+ ProfileState state = null;
+ String selectionText;
+ String text;
+ if(multiSelection) {
+ selectionText = "selected profiles";
+ } else {
+ ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
+ state = entry.getActivationState();
+ selectionText = entry.getId();
+ }
+
+ if(state == null || ProfileState.Disabled.equals(state)) {
+ text = Messages.SelectProfilesDialog_Activate_menu;
+ activationAction.setText(NLS.bind(text, selectionText));
+ manager.add(activationAction);
+ }
+ if(!ProfileState.Disabled.equals(state)) {
+ text = Messages.SelectProfilesDialog_Deactivate_menu;
+ deActivationAction.setText(NLS.bind(text, selectionText));
+ manager.add(deActivationAction);
+ }
+ }
+ }
+
+ public boolean isOffline() {
+ return offlineMode;
+ }
+
+ public boolean isForceUpdate() {
+ return forceUpdate;
+ }
+
+ private void setActivationState(final IStructuredSelection sel, ProfileState state) {
+ if(sel == null)
+ return;
+ Iterator<?> ite = sel.iterator();
+ while(ite.hasNext()) {
+ Object o = ite.next();
+ if(o instanceof ProfileSelection) {
+ ProfileSelection ps = (ProfileSelection) o;
+ ps.setActivationState(state);
+ profileTableViewer.setGrayed(ps, false);
+ if(ProfileState.Disabled.equals(state)) {
+ profileTableViewer.setChecked(ps, true);
+ ps.setSelected(true);
+ }
+ }
+ }
+ }
+
+ private void refresh() {
+ profileTableViewer.refresh();
+ updateProfilesAsText();
+ }
+
+ private class ChangeProfileStateAction extends Action {
+
+ private final ProfileState state;
+
+ public ChangeProfileStateAction(ProfileState state) {
+ this.state = state;
+ }
+
+ @Override
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) profileTableViewer.getSelection();
+ if(!selection.isEmpty()) {
+ setActivationState(selection, state);
+ refresh();
+ }
+ super.run();
+ }
+ }
+
+ private class ProfileLabelProvider extends LabelProvider
+ implements ITableLabelProvider, ITableFontProvider, ITableColorProvider {
+
+ private Font implicitActivationFont;
+
+ private Color inactiveColor;
+
+ public ProfileLabelProvider(Font defaultFont) {
+ FontData[] fds = defaultFont.getFontData();
+ for(FontData fd : fds) {
+ fd.setStyle(SWT.ITALIC);
+ }
+ implicitActivationFont = new Font(defaultFont.getDevice(), fds);
+ inactiveColor = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ ProfileSelection entry = (ProfileSelection) element;
+ Font font = null;
+ if(Boolean.TRUE.equals(entry.getAutoActive()) && PROFILE_ID_COLUMN == columnIndex) {
+ font = implicitActivationFont;
+ }
+ return font;
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ ProfileSelection entry = (ProfileSelection) element;
+ if(ProfileState.Disabled.equals(entry.getActivationState())) {
+ return inactiveColor;
+ }
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ return null;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ ProfileSelection entry = (ProfileSelection) element;
+ StringBuilder text = new StringBuilder();
+ if(entry != null) {
+ if(columnIndex == PROFILE_ID_COLUMN) {
+ text.append(entry.getId());
+ ProfileState state = entry.getActivationState();
+ if(Boolean.TRUE.equals(entry.getSelected()) && state == ProfileState.Disabled) {
+ text.append(Messages.SelectProfilesDialog_deactivated);
+ } else if(Boolean.TRUE.equals(entry.getAutoActive())) {
+ text.append(Messages.SelectProfilesDialog_autoactivated);
+ }
+ } else if(columnIndex == SOURCE_COLUMN) {
+ text.append(entry.getSource());
+ }
+ }
+ return text.toString();
+ }
+ }
}
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 7acbb24a..6c0f43b0 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
@@ -14,7 +14,6 @@ package org.eclipse.m2e.refactoring.rename;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -140,13 +139,11 @@ public class MavenRenameWizardPage extends UserInputWizardPage {
}
});
- ModifyListener listener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- newGroupId = groupIdText.getText();
- newArtifactId = artifactIdText.getText();
- newVersion = versionText.getText();
- getWizard().getContainer().updateButtons();
- }
+ ModifyListener listener = e -> {
+ newGroupId = groupIdText.getText();
+ newArtifactId = artifactIdText.getText();
+ newVersion = versionText.getText();
+ getWizard().getContainer().updateButtons();
};
groupIdText.setText(groupId);
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 7f10791d..5a9718ce 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
@@ -24,7 +24,6 @@ import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -113,14 +112,12 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
for(int i = 0; i < types.length; i++ ) {
scmTypeCombo.add(types[i]);
}
- scmTypeCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String newScmType = scmTypeCombo.getText();
- if(!newScmType.equals(scmType)) {
- scmType = newScmType;
- scmUrlCombo.setText(""); //$NON-NLS-1$
- updatePage();
- }
+ scmTypeCombo.addModifyListener(e -> {
+ String newScmType = scmTypeCombo.getText();
+ if(!newScmType.equals(scmType)) {
+ scmType = newScmType;
+ scmUrlCombo.setText(""); //$NON-NLS-1$
+ updatePage();
}
});
@@ -168,11 +165,7 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
}
}
- revisionText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updatePage();
- }
- });
+ revisionText.addModifyListener(e -> updatePage());
revisionBrowseButton = new Button(composite, SWT.NONE);
GridData gd_revisionBrowseButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
@@ -238,33 +231,27 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
}
});
- scmUrlCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- final String url = scmUrlCombo.getText().trim();
- if(url.startsWith("scm:")) { //$NON-NLS-1$
- try {
- final String type = ScmUrl.getType(url);
- scmTypeCombo.setText(type);
- scmType = type;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- scmUrlCombo.setText(url.substring(type.length() + 5));
- }
- });
- } catch(CoreException ex) {
- }
- return;
- }
-
- if(scmUrls == null) {
- scmUrls = new ScmUrl[1];
+ scmUrlCombo.addModifyListener(e -> {
+ final String url = scmUrlCombo.getText().trim();
+ if(url.startsWith("scm:")) { //$NON-NLS-1$
+ try {
+ final String type = ScmUrl.getType(url);
+ scmTypeCombo.setText(type);
+ scmType = type;
+ Display.getDefault().asyncExec(() -> scmUrlCombo.setText(url.substring(type.length() + 5)));
+ } catch(CoreException ex) {
}
+ return;
+ }
- ScmUrl scmUrl = new ScmUrl("scm:" + scmType + ":" + url); //$NON-NLS-1$ //$NON-NLS-2$
- scmUrls[0] = scmUrl;
- scmParentUrl = scmUrl.getUrl();
- updatePage();
+ if(scmUrls == null) {
+ scmUrls = new ScmUrl[1];
}
+
+ ScmUrl scmUrl = new ScmUrl("scm:" + scmType + ":" + url); //$NON-NLS-1$ //$NON-NLS-2$
+ scmUrls[0] = scmUrl;
+ scmParentUrl = scmUrl.getUrl();
+ updatePage();
});
}
if(Platform.getBundle("org.eclipse.m2e.discovery") != null) {
@@ -286,8 +273,8 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
for(IConfigurationElement element : extension[0].getConfigurationElements()) {
if(element.getName().equals("launcher")) {
try {
- ((IMavenDiscovery) element.createExecutableExtension("class")).launch(Display.getCurrent()
- .getActiveShell());
+ ((IMavenDiscovery) element.createExecutableExtension("class"))
+ .launch(Display.getCurrent().getActiveShell());
break;
} catch(CoreException e1) {
//
@@ -478,12 +465,10 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
}
public void addListener(final SelectionListener listener) {
- ModifyListener listenerProxy = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Event event = new Event();
- event.widget = e.widget;
- listener.widgetSelected(new SelectionEvent(event));
- }
+ ModifyListener listenerProxy = e -> {
+ Event event = new Event();
+ event.widget = e.widget;
+ listener.widgetSelected(new SelectionEvent(event));
};
scmUrlCombo.addModifyListener(listenerProxy);
revisionText.addModifyListener(listenerProxy);
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
index fcee8472..a14e7880 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
@@ -170,39 +170,34 @@ public abstract class MavenProjectCheckoutJob extends WorkspaceJob {
String[] projectFiles = projectScanner.getIncludedFiles();
if(projectFiles != null && projectFiles.length > 0) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), //
- Messages.MavenProjectCheckoutJob_confirm_title, //
- Messages.MavenProjectCheckoutJob_confirm_message);
- if(res) {
- IWizard wizard = new ExternalProjectImportWizard(collectedLocations.get(0));
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- wizard);
- dialog.open();
- } else {
- cleanup(collectedLocations);
- }
- }
- });
- return;
- }
-
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- public void run() {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), //
- Messages.MavenProjectCheckoutJob_confirm2_title, //
- Messages.MavenProjectCheckoutJob_confirm2_message);
+ Messages.MavenProjectCheckoutJob_confirm_title, //
+ Messages.MavenProjectCheckoutJob_confirm_message);
if(res) {
- Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
- clipboard.setContents(new Object[] {location}, new Transfer[] {TextTransfer.getInstance()});
-
- NewProjectAction newProjectAction = new NewProjectAction(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow());
- newProjectAction.run();
+ IWizard wizard = new ExternalProjectImportWizard(collectedLocations.get(0));
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
+ dialog.open();
} else {
cleanup(collectedLocations);
}
+ });
+ return;
+ }
+
+ PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), //
+ Messages.MavenProjectCheckoutJob_confirm2_title, //
+ Messages.MavenProjectCheckoutJob_confirm2_message);
+ if(res) {
+ Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
+ clipboard.setContents(new Object[] {location}, new Transfer[] {TextTransfer.getInstance()});
+
+ NewProjectAction newProjectAction = new NewProjectAction(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ newProjectAction.run();
+ } else {
+ cleanup(collectedLocations);
}
});
return;
@@ -220,15 +215,13 @@ public abstract class MavenProjectCheckoutJob extends WorkspaceJob {
job.schedule();
} else {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations);
- wizard.setBasedirRemameRequired(true);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- int res = dialog.open();
- if(res == Window.CANCEL) {
- cleanup(collectedLocations);
- }
+ PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
+ MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations);
+ wizard.setBasedirRemameRequired(true);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
+ int res = dialog.open();
+ if(res == Window.CANCEL) {
+ cleanup(collectedLocations);
}
});
}

Back to the top