Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/icons/license.pngbin0 -> 784 bytes
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/AddLicensePomOperation.java104
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertSPDXLicenseProposal.java106
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/MvnImages.java2
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java10
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java7
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java19
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SPDXLicense.java215
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java249
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties7
10 files changed, 713 insertions, 6 deletions
diff --git a/org.eclipse.m2e.editor.xml/icons/license.png b/org.eclipse.m2e.editor.xml/icons/license.png
new file mode 100644
index 00000000..69db8fa5
--- /dev/null
+++ b/org.eclipse.m2e.editor.xml/icons/license.png
Binary files differ
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/AddLicensePomOperation.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/AddLicensePomOperation.java
new file mode 100644
index 00000000..ccbb7c27
--- /dev/null
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/AddLicensePomOperation.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.editor.xml;
+
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElement;
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.format;
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild;
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.insertAt;
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+
+import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
+import org.eclipse.m2e.editor.xml.internal.dialogs.SPDXLicense;
+
+
+@SuppressWarnings("restriction")
+public class AddLicensePomOperation implements Operation {
+
+ private final SPDXLicense license;
+
+ private final PomTemplateContext context;
+
+ private final Region region;
+
+ private int generatedOffset = -1;
+
+ private int generatedLength = -1;
+
+ public AddLicensePomOperation(SPDXLicense license, PomTemplateContext context, Region region) {
+ if(license == null) {
+ throw new NullPointerException();
+ }
+ if(context != PomTemplateContext.PROJECT && context != PomTemplateContext.LICENSES) {
+ throw new IllegalArgumentException();
+ }
+ if(context == PomTemplateContext.LICENSES && region == null) {
+ throw new IllegalArgumentException();
+ }
+
+ this.license = license;
+ this.context = context;
+ this.region = region;
+ }
+
+ public void process(Document doc) {
+ Element element;
+ if(context == PomTemplateContext.PROJECT) {
+ element = createLicenses(doc);
+ } else {
+ element = createLicense(doc);
+ }
+ format(element);
+
+ if(element instanceof IndexedRegion) {
+ generatedOffset = ((IndexedRegion) element).getStartOffset();
+ generatedLength = ((IndexedRegion) element).getEndOffset() - generatedOffset;
+ }
+ }
+
+ private Element createLicenses(Document doc) {
+ Element licensesDom;
+ if(region != null) {
+ licensesDom = insertAt(doc.createElement("licenses"), region.getOffset());
+ } else {
+ licensesDom = getChild(doc.getDocumentElement(), "licenses");
+ }
+
+ setLicense(createElement(licensesDom, "license"));
+
+ return licensesDom;
+ }
+
+ private Element createLicense(Document doc) {
+ Element licenseDom = insertAt(doc.createElement("license"), region.getOffset());
+
+ setLicense(licenseDom);
+
+ return licenseDom;
+ }
+
+ void setLicense(Element licenseDom) {
+ setText(getChild(licenseDom, "name"), license.getName());
+ setText(getChild(licenseDom, "url"), license.getURL());
+ }
+
+ public Point getSelection() {
+ return new Point(generatedOffset, generatedLength);
+ }
+}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertSPDXLicenseProposal.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertSPDXLicenseProposal.java
new file mode 100644
index 00000000..c9a86a4b
--- /dev/null
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertSPDXLicenseProposal.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.editor.xml;
+
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
+import org.eclipse.m2e.editor.xml.internal.Messages;
+import org.eclipse.m2e.editor.xml.internal.XmlUtils;
+import org.eclipse.m2e.editor.xml.internal.dialogs.SPDXLicense;
+import org.eclipse.m2e.editor.xml.internal.dialogs.SelectSPDXLicenseDialog;
+
+
+public class InsertSPDXLicenseProposal implements ICompletionProposal {
+ private static final Logger log = LoggerFactory.getLogger(InsertSPDXLicenseProposal.class);
+
+ private final ISourceViewer sourceViewer;
+
+ private final Region region;
+
+ private final PomTemplateContext context;
+
+ private Point selection;
+
+ public InsertSPDXLicenseProposal(ISourceViewer sourceViewer, PomTemplateContext context, Region region) {
+ this.sourceViewer = sourceViewer;
+ this.context = context;
+ this.region = region;
+ }
+
+ public void apply(IDocument document) {
+ IProject project = XmlUtils.extractProject(sourceViewer);
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(project);
+ SelectSPDXLicenseDialog dialog = new SelectSPDXLicenseDialog(sourceViewer.getTextWidget().getShell(), facade);
+
+ if(dialog.open() == Window.OK) {
+ final SPDXLicense license = dialog.getLicense();
+ try {
+
+ IMavenProjectFacade targetProject = dialog.getTargetProject();
+ if(!targetProject.getPom().equals(facade.getPom())) {
+ // add license to a parent
+ AddLicensePomOperation operation = new AddLicensePomOperation(license, PomTemplateContext.PROJECT, null);
+ performOnDOMDocument(new OperationTuple(targetProject.getPom(), operation));
+ } else {
+ AddLicensePomOperation operation = new AddLicensePomOperation(license, context, region);
+ performOnDOMDocument(new OperationTuple(document, operation));
+ this.selection = operation.getSelection();
+ }
+
+ } catch(CoreException e) {
+ log.error("Failed inserting parent element", e); //$NON-NLS-1$
+ } catch(IOException e) {
+ log.error("Failed inserting parent element", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public Point getSelection(IDocument document) {
+ return selection;
+ }
+
+ public String getAdditionalProposalInfo() {
+ return null;
+ }
+
+ public String getDisplayString() {
+ return Messages.InsertSPDXLicenseProposal_0;
+ }
+
+ public Image getImage() {
+ return MvnImages.IMG_LICENSE;
+ }
+
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/MvnImages.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/MvnImages.java
index faa96fd6..f8f495f6 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/MvnImages.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/MvnImages.java
@@ -67,6 +67,8 @@ public class MvnImages {
public static final Image IMG_PARAMETER = createImage("parameter_obj.gif"); //$NON-NLS-1$
+ public static final Image IMG_LICENSE = createImage("license.png"); //$NON-NLS-1$
+
public static final Image IMG_BUILD = createImage("build_obj.gif"); //$NON-NLS-1$
public static final Image IMG_ELEMENT = createImage("element_obj.gif"); //$NON-NLS-1$
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
index 8a3bb5f9..b6dd1d53 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
@@ -318,10 +318,14 @@ public class PomContentAssistProcessor extends XMLContentAssistProcessor {
}
}
}
-
-
+ if((context == PomTemplateContext.PROJECT && XmlUtils.findChild((Element) node, "licenses") == null)
+ || context == PomTemplateContext.LICENSES) {
+ Region region = new Region(request.getReplacementBeginPosition(), 0);
+ ICompletionProposal proposal = new InsertSPDXLicenseProposal(sourceViewer, context, region);
+ request.addProposal(proposal);
+ }
}
-
+
private static String findRelativePath(ISourceViewer viewer, Element parent) {
String groupId = XmlUtils.getTextValue(XmlUtils.findChild(parent, "groupId")); //$NON-NLS-1$
String artifactId = XmlUtils.getTextValue(XmlUtils.findChild(parent, "artifactId")); //$NON-NLS-1$
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
index 0061026b..cdc07b62 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
@@ -470,7 +470,10 @@ public enum PomTemplateContext {
}
}
}
- };
+ },
+
+ LICENSES("licenses");
+
private static final Logger log = LoggerFactory.getLogger(PomTemplateContext.class);
private static final String PREFIX = MvnIndexPlugin.PLUGIN_ID + ".templates.contextType."; //$NON-NLS-1$
@@ -734,5 +737,5 @@ public enum PomTemplateContext {
private static void add(Collection<Template> proposals, String contextTypeId, String name, String description) {
proposals.add(new Template(name, description, contextTypeId, name, false));
- }
+ }
}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
index 5f29f36a..f0aa3c69 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
@@ -9,7 +9,6 @@
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
-
package org.eclipse.m2e.editor.xml.internal;
import org.eclipse.osgi.util.NLS;
@@ -40,6 +39,8 @@ public class Messages extends NLS {
public static String InsertExpressionProposal_hint2;
+ public static String InsertSPDXLicenseProposal_0;
+
public static String LifecycleMappingProposal_all_desc;
public static String LifecycleMappingProposal_execute_desc;
@@ -55,6 +56,7 @@ public class Messages extends NLS {
public static String MavenMarkerResolution_error_title;
public static String MavenMarkerResolution_schema_label;
+
public static String PomContentAssistProcessor_insert_relPath_title;
public static String PomContentAssistProcessor_set_relPath_title;
@@ -76,6 +78,7 @@ public class Messages extends NLS {
public static String PomQuickAssistProcessor_name;
public static String PomQuickAssistProcessor_remove_hint;
+
public static String PomQuickAssistProcessor_title_groupId;
public static String PomQuickAssistProcessor_title_version;
@@ -157,6 +160,7 @@ public class Messages extends NLS {
public static String PomTextHover_eval2;
public static String PomTextHover_jump_to;
+
public static String PomTextHover_managed_location;
public static String PomTextHover_managed_location_missing;
@@ -168,6 +172,19 @@ public class Messages extends NLS {
public static String PomTextHover_more_quickfixes;
public static String PomTextHover_one_quickfix;
+
+ public static String SelectSPDXLicenseDialog_noWorkspacePomSelected_status;
+
+ public static String SelectSPDXLicenseDialog_Title;
+
+ public static String SelectSPDXLicenseDialog_lblLicenses_text;
+
+ public static String SelectSPDXLicenseDialog_lblLicenseNameFilter_text;
+
+ public static String SelectSPDXLicenseDialog_noLicenseSelected_status;
+
+ public static String SelectSPDXLicenseDialog_lblPomxml_text;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SPDXLicense.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SPDXLicense.java
new file mode 100644
index 00000000..8170bcf0
--- /dev/null
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SPDXLicense.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.editor.xml.internal.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+public class SPDXLicense {
+
+ private static final List<SPDXLicense> LICENSES;
+
+ public static final String BASEURL = "http://www.spdx.org/licenses/"; //$NON-NLS-1$
+
+ private final String name;
+
+ private final String id;
+
+ private SPDXLicense(String name, String id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURL() {
+ return BASEURL + id;
+ }
+
+ public static List<SPDXLicense> getStandardLicenses() {
+ return LICENSES;
+ }
+
+ static {
+ ArrayList<SPDXLicense> licenses = new ArrayList<SPDXLicense>();
+
+ // SPDX License List v1.13
+ // http://spdx.org/wiki/spdx-license-list-working-version
+ licenses.add(new SPDXLicense("Academic Free License v1.1", "AFL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Academic Free License v1.2", "AFL-1.2")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Academic Free License v2.0", "AFL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Academic Free License v2.1", "AFL-2.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Academic Free License v3.0", "AFL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Adaptive Public License 1.0", "APL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("ANTLR Software Rights Notice", "ANTLR-PD")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apache License 1.0", "Apache-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apache License 1.1", "Apache-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apache License 2.0", "Apache-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apple Public Source License 1.0", "APSL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apple Public Source License 1.1", "APSL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apple Public Source License 1.2", "APSL-1.2")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Apple Public Source License 2.0", "APSL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Artistic License 1.0", "Artistic-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Artistic License 2.0", "Artistic-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Attribution Assurance License", "AAL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Boost Software License 1.0", "BSL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("BSD 2-clause \"Simplified\" or \"FreeBSD\" License", "BSD-2-Clause")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("BSD 3-clause \"New\" or \"Revised\" License", "BSD-3-Clause")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("BSD 4-clause \"Original\" or \"Old\" License", "BSD-4-Clause")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CeCILL Free Software License Agreement v1.0", "CECILL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CeCILL Free Software License Agreement v1.1", "CECILL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CeCILL Free Software License Agreement v2.0", "CECILL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CeCILL-B Free Software License Agreement", "CECILL-B")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CeCILL-C Free Software License Agreement", "CECILL-C")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Clarified Artistic License", "ClArtistic")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Common Development and Distribution License 1.0", "CDDL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Common Public Attribution License 1.0 ", "CPAL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Common Public License 1.0", "CPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Computer Associates Trusted Open Source License 1.1", "CATOSL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution 1.0", "CC-BY-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution 2.0", "CC-BY-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution 2.5", "CC-BY-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution 3.0", "CC-BY-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution No Derivatives 1.0", "CC-BY-ND-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution No Derivatives 2.0", "CC-BY-ND-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution No Derivatives 2.5", "CC-BY-ND-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution No Derivatives 3.0", "CC-BY-ND-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial 1.0", "CC-BY-NC-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial 2.0", "CC-BY-NC-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial 2.5", "CC-BY-NC-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial 3.0", "CC-BY-NC-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial No Derivatives 1.0", "CC-BY-NC-ND-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial No Derivatives 2.0", "CC-BY-NC-ND-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial No Derivatives 2.5", "CC-BY-NC-ND-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial No Derivatives 3.0", "CC-BY-NC-ND-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial Share Alike 1.0", "CC-BY-NC-SA-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial Share Alike 2.0", "CC-BY-NC-SA-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial Share Alike 2.5", "CC-BY-NC-SA-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Non Commercial Share Alike 3.0", "CC-BY-NC-SA-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Share Alike 1.0", "CC-BY-SA-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Share Alike 2.0", "CC-BY-SA-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Share Alike 2.5", "CC-BY-SA-2.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Attribution Share Alike 3.0", "CC-BY-SA-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Creative Commons Zero v1.0 Universal", "CC0-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("CUA Office Public License v1.0", "CUA-OPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Eclipse Public License 1.0", "EPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("eCos license version 2.0", "eCos-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Educational Community License v1.0", "ECL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Educational Community License v2.0", "ECL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Eiffel Forum License v1.0", "EFL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Eiffel Forum License v2.0", "EFL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Entessa Public License", "Entessa")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Erlang Public License v1.1", "ErlPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("EU DataGrid Software License", "EUDatagrid")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("European Union Public License 1.0", "EUPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("European Union Public License 1.1", "EUPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Fair License", "Fair")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Frameworx Open License 1.0", "Frameworx-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Affero General Public License v3", "AGPL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Free Documentation License v1.1", "GFDL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Free Documentation License v1.2", "GFDL-1.2")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Free Documentation License v1.3", "GFDL-1.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v1.0 only", "GPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v1.0 or later", "GPL-1.0+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v2.0 only", "GPL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v2.0 or later", "GPL-2.0+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense(
+ "GNU General Public License v2.0 w/Autoconf exception", "GPL-2.0-with-autoconf-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v2.0 w/Bison exception", "GPL-2.0-with-bison-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense(
+ "GNU General Public License v2.0 w/Classpath exception", "GPL-2.0-with-classpath-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v2.0 w/Font exception", "GPL-2.0-with-font-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense(
+ "GNU General Public License v2.0 w/GCC Runtime Library exception", "GPL-2.0-with-GCC-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v3.0 only", "GPL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU General Public License v3.0 or later", "GPL-3.0+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense(
+ "GNU General Public License v3.0 w/Autoconf exception", "GPL-3.0-with-autoconf-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense(
+ "GNU General Public License v3.0 w/GCC Runtime Library exception", "GPL-3.0-with-GCC-exception")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Lesser General Public License v2.1 only", "LGPL-2.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Lesser General Public License v2.1 or later", "LGPL-2.1+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Lesser General Public License v3.0 only", "LGPL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Lesser General Public License v3.0 or later", "LGPL-3.0+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Library General Public License v2 only", "LGPL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("GNU Library General Public License v2 or later", "LGPL-2.0+")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("gSOAP Public License v1.b", "gSOAP-1.3b")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Historic Permission Notice and Disclaimer", "HPND")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("IBM Public License v1.0", "IPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("IPA Font License", "IPA")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("ISC License (Bind, DHCP Server)", "ISC")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("LaTeX Project Public License v1.0", "LPPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("LaTeX Project Public License v1.1", "LPPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("LaTeX Project Public License v1.2", "LPPL-1.2")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("LaTeX Project Public License v1.3c", "LPPL-1.3c")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("libpng License", "Libpng")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Lucent Public License v1.02 (Plan9)", "LPL-1.02")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Microsoft Public License", "MS-PL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Microsoft Reciprocal License", "MS-RL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("MirOS Licence", "MirOS")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("MIT license (also X11)", "MIT")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Motosoto License", "Motosoto")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Mozilla Public License 1.0", "MPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Mozilla Public License 1.1 ", "MPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Multics License", "Multics")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("NASA Open Source Agreement 1.3", "NASA-1.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Naumen Public License", "Naumen")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Nethack General Public License", "NGPL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Nokia Open Source License", "Nokia")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Non-Profit Open Software License 3.0", "NPOSL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("NTP License", "NTP")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("OCLC Research Public License 2.0", "OCLC-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("ODC Open Database License v1.0", "ODbL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("ODC Public Domain Dedication & License 1.0", "PDDL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Open Group Test Suite License", "OGTSL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Open Software License 1.0", "OSL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Open Software License 2.0", "OSL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Open Software License 3.0", "OSL-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("OpenLDAP Public License v2.8", "OLDAP-2.8")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("OpenSSL License", "OpenSSL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("PHP License v3.0", "PHP-3.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("PostgreSQL License", "PostgreSQL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Python License 2.0", "Python-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Q Public License 1.0", "QPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("RealNetworks Public Source License v1.0", "RPSL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Reciprocal Public License 1.5 ", "RPL-1.5")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Red Hat eCos Public License v1.1", "RHeCos-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Ricoh Source Code Public License", "RSCPL")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Ruby License", "Ruby")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Sax Public Domain Notice", "SAX-PD")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("SIL Open Font License 1.1", "OFL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Simple Public License 2.0", "SimPL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Sleepycat License", "Sleepycat")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("SugarCRM Public License v1.1.3", "SugarCRM-1.1.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Sun Public License v1.0", "SPL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Sybase Open Watcom Public License 1.0", "Watcom-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("University of Illinois/NCSA Open Source License", "NCSA")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Vovida Software License v1.0", "VSL-1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("W3C Software and Notice License", "W3C")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("wxWindows Library License", "WXwindows")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("X.Net License", "Xnet")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("XFree86 License 1.1", "XFree86-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Yahoo! Public License v1.1", "YPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Zimbra Publice License v1.3", "Zimbra-1.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("zlib License", "Zlib")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Zope Public License 1.1", "ZPL-1.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Zope Public License 2.0", "ZPL-2.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ licenses.add(new SPDXLicense("Zope Public License 2.1", "ZPL-2.1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ LICENSES = Collections.unmodifiableList(licenses);
+ }
+
+}
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
new file mode 100644
index 00000000..18bb0862
--- /dev/null
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.editor.xml.internal.dialogs;
+
+import java.util.Collection;
+
+import org.apache.maven.project.MavenProject;
+
+import org.eclipse.core.runtime.IStatus;
+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;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.ui.internal.components.PomHierarchyComposite;
+import org.eclipse.m2e.core.ui.internal.dialogs.AbstractMavenDialog;
+import org.eclipse.m2e.editor.xml.MvnIndexPlugin;
+import org.eclipse.m2e.editor.xml.internal.Messages;
+
+
+@SuppressWarnings("restriction")
+public class SelectSPDXLicenseDialog extends AbstractMavenDialog {
+
+ /*package*/IMavenProjectFacade targetProject;
+
+ /*package*/SPDXLicense license;
+
+ /*package*/final IMavenProjectFacade project;
+
+ /*package*/static final IStatus STATUS_NO_LICENSE_SELECTION = new Status(IStatus.ERROR, MvnIndexPlugin.PLUGIN_ID,
+ Messages.SelectSPDXLicenseDialog_noLicenseSelected_status);
+
+ /*package*/static final IStatus STATUS_NO_WORKSPACE_POM_SELECTION = new Status(IStatus.ERROR,
+ MvnIndexPlugin.PLUGIN_ID, Messages.SelectSPDXLicenseDialog_noWorkspacePomSelected_status);
+
+ public SelectSPDXLicenseDialog(Shell parentShell, IMavenProjectFacade project) {
+ super(parentShell, SelectSPDXLicenseDialog.class.getName());
+ setStatusLineAboveButtons(true);
+ setTitle(Messages.SelectSPDXLicenseDialog_Title);
+ this.project = project;
+ this.targetProject = project;
+ updateStatus(STATUS_NO_LICENSE_SELECTION);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Label lblLicenseNameFilter = new Label(container, SWT.NONE);
+ lblLicenseNameFilter.setText(Messages.SelectSPDXLicenseDialog_lblLicenseNameFilter_text);
+
+ final Text licenseFilter = new Text(container, SWT.BORDER | SWT.SEARCH);
+ licenseFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+
+ Label lblLicenses = new Label(container, SWT.NONE);
+ lblLicenses.setText(Messages.SelectSPDXLicenseDialog_lblLicenses_text);
+
+ final TableViewer licensesViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
+ Table licensesTable = licensesViewer.getTable();
+ licensesTable.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ handleDoubleClick();
+ }
+ });
+ licensesTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = licensesViewer.getSelection();
+ if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ license = (SPDXLicense) ((IStructuredSelection) selection).getFirstElement();
+ } else {
+ license = null;
+ }
+ updateStatus();
+ }
+ });
+ GridData gd_licensesTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ gd_licensesTable.heightHint = 400;
+ licensesTable.setLayoutData(gd_licensesTable);
+ licensesViewer.setContentProvider(new IStructuredContentProvider() {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof Collection<?>) {
+ return ((Collection<?>) inputElement).toArray();
+ }
+ return null;
+ }
+ });
+ licensesViewer.setLabelProvider(new ILabelProvider() {
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void dispose() {
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public String getText(Object element) {
+ if(element instanceof SPDXLicense) {
+ return ((SPDXLicense) element).getName();
+ }
+ return null;
+ }
+
+ public Image getImage(Object element) {
+ return null;
+ }
+ });
+ 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);
+ }
+ });
+
+ Label lblPomxml = new Label(container, SWT.NONE);
+ lblPomxml.setText(Messages.SelectSPDXLicenseDialog_lblPomxml_text);
+
+ final PomHierarchyComposite parentComposite = new PomHierarchyComposite(container, SWT.NONE);
+ parentComposite.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ handleDoubleClick();
+ }
+ });
+ parentComposite.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = parentComposite.getSelection();
+ if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ MavenProject mavenProject = (MavenProject) ((IStructuredSelection) selection).getFirstElement();
+ targetProject = MavenPlugin.getMavenProjectRegistry().getMavenProject(mavenProject.getGroupId(),
+ mavenProject.getArtifactId(), mavenProject.getVersion());
+ updateStatus();
+ }
+ }
+ });
+ parentComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ parentComposite.computeHeirarchy(project, null); // FIXME proper progress monitor
+ parentComposite.setSelection(new StructuredSelection(parentComposite.getHierarchy().get(0)));
+
+ return container;
+ }
+
+ public SPDXLicense getLicense() {
+ return license;
+ }
+
+ public IMavenProjectFacade getTargetProject() {
+ return targetProject;
+ }
+
+ protected void computeResult() {
+ // TODO Auto-generated method computeResult
+
+ }
+
+ private static class LicenseFilter extends ViewerFilter {
+
+ private final String text;
+
+ public LicenseFilter(String text) {
+ this.text = text.toLowerCase();
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof SPDXLicense) {
+ return ((SPDXLicense) element).getName().toLowerCase().contains(text);
+ }
+ return false;
+ }
+
+ }
+
+ /*package*/void updateStatus() {
+ updateStatus(getStatus());
+ }
+
+ private IStatus getStatus() {
+ IStatus status;
+ if(license == null) {
+ status = STATUS_NO_LICENSE_SELECTION;
+ } else if(targetProject == null) {
+ status = STATUS_NO_WORKSPACE_POM_SELECTION;
+ } else {
+ status = Status.OK_STATUS;
+ }
+ return status;
+ }
+
+ /*package*/void handleDoubleClick() {
+ if(getStatus().isOK()) {
+ okPressed();
+ }
+ }
+
+}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
index 77881866..3cf16b38 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
@@ -9,6 +9,7 @@ InsertArtifactProposal_insert_plugin_title=Select Plugin
InsertArtifactProposal_searchDialog_title=Select Parent
InsertExpressionProposal_hint1=The expression evaluates to <b>{0}</b> in the current effective pom.
InsertExpressionProposal_hint2=<br>It is based on property defined in <b>{0}</b>
+InsertSPDXLicenseProposal_0=Insert SPDX License
LifecycleMappingProposal_all_desc=<html>Goal: <b>{0}</b><br/>ExecutionId: <b>{1}</b><br/>Phase: <b>{2}</b><br/>Plugin: {3}<br/><br/>{4}</html>
LifecycleMappingProposal_execute_desc=This quickfix generates a plugin configuration snippet recognized by the m2e integration during project configuration. It marks the given goal to be executed during the Eclipse build.
LifecycleMappingProposal_execute_label=Execute goal {0} as part of Eclipse build
@@ -75,3 +76,9 @@ PomTextHover_managed_version=The managed version is
PomTextHover_managed_version_missing=The managed version could not be determined.
PomTextHover_more_quickfixes={0} quick fixes available:
PomTextHover_one_quickfix=\ 1 quick fix available:
+SelectSPDXLicenseDialog_Title=Select SPDX License
+SelectSPDXLicenseDialog_lblLicenseNameFilter_text=License filter
+SelectSPDXLicenseDialog_lblLicenses_text=Licenses
+SelectSPDXLicenseDialog_lblPomxml_text=pom.xml
+SelectSPDXLicenseDialog_noLicenseSelected_status=Select a license
+SelectSPDXLicenseDialog_noWorkspacePomSelected_status=Select workspace pom.xml

Back to the top