Bug 562630 - Extract WTP-based source tab in a separate (uninstallable)
feature

Change-Id: I23895919a033da5b4470a8b3248da4c41c1b43b8
Signed-off-by: Mickael Istria <mistria@redhat.com>
diff --git a/org.eclipse.m2e.editor.pomeditor/META-INF/MANIFEST.MF b/org.eclipse.m2e.editor.pomeditor/META-INF/MANIFEST.MF
deleted file mode 100644
index 0403d6d..0000000
--- a/org.eclipse.m2e.editor.pomeditor/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,36 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Pomeditor
-Bundle-SymbolicName: org.eclipse.m2e.editor.pomeditor;singleton:=true
-Bundle-Version: 1.16.0.qualifier
-Automatic-Module-Name: org.eclipse.m2e.editor.pomeditor
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.search,
- org.eclipse.ui.ide,
- org.eclipse.ui.forms,
- org.eclipse.jface.text,
- org.eclipse.wst.sse.core,
- org.eclipse.wst.xml.core,
- org.eclipse.ui.workbench,
- org.eclipse.m2e.core;bundle-version="[1.16.0,1.17.0)",
- org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,1.17.0)",
- org.eclipse.m2e.editor.xml;bundle-version="[1.16.0,1.17.0)",
- org.eclipse.m2e.core.ui;bundle-version="[1.16.0,1.17.0)",
- org.eclipse.wst.sse.core,
- org.eclipse.wst.common.emf,
- org.eclipse.swt,
- org.eclipse.jface,
- org.eclipse.jface.text,
- org.eclipse.ui.workbench.texteditor,
- org.eclipse.ui.editors,
- org.eclipse.emf.common,
- org.eclipse.emf.ecore,
- org.eclipse.ui.views,
- org.eclipse.m2e.editor
-Bundle-ClassPath: .
-Import-Package: org.eclipse.wst.sse.ui,
- org.eclipse.wst.sse.ui.internal,
- org.eclipse.wst.sse.ui.internal.contentoutline,
- org.slf4j;version="1.6.2"
diff --git a/org.eclipse.m2e.editor.pomeditor/plugin.xml b/org.eclipse.m2e.editor.pomeditor/plugin.xml
deleted file mode 100644
index 624d370..0000000
--- a/org.eclipse.m2e.editor.pomeditor/plugin.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<plugin>
-   <extension
-         point="org.eclipse.m2e.editor.pageFactories">
-      <factory
-            class="org.eclipse.m2e.editor.xml.pomeditor.MavenStructuredPomEditorPageFactory">
-      </factory>
-   </extension>
-</plugin>
diff --git a/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredPomEditorPageFactory.java b/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredPomEditorPageFactory.java
deleted file mode 100644
index 468a045..0000000
--- a/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredPomEditorPageFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2020 RedHat and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- *******************************************************************************/
-package org.eclipse.m2e.editor.xml.pomeditor;
-
-import org.eclipse.m2e.editor.pom.MavenPomEditor;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MavenStructuredPomEditorPageFactory extends org.eclipse.m2e.editor.pom.MavenPomEditorPageFactory {
-
-	private static final Logger log = LoggerFactory.getLogger(MavenStructuredPomEditorPageFactory.class);
-
-	@Override
-	public void addPages(MavenPomEditor pomEditor) {
-
-		ITextEditor sourcePage = new MavenStructuredSourceTextEditor(pomEditor);
-		ITextEditor effectPomPage = new MavenStructuredSourceTextEditor(pomEditor);
-
-		try {
-			int dex = pomEditor.addPage(effectPomPage, pomEditor.getEffectivePomEditorInput());
-			pomEditor.setPageText(dex, MavenPomEditor.EFFECTIVE_POM);
-			pomEditor.setEffectivePomSourcePage(effectPomPage);
-
-			int sourcePageIndex = pomEditor.addPage(sourcePage, pomEditor.getEditorInput());
-			pomEditor.setPageText(sourcePageIndex, MavenPomEditor.POM_XML);
-			pomEditor.setSourcePage(sourcePage);
-
-		} catch (PartInitException ex) {
-			log.error(ex.getMessage(), ex);
-		}
-	}
-
-}
diff --git a/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredSourceTextEditor.java b/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredSourceTextEditor.java
deleted file mode 100644
index 7721e2c..0000000
--- a/org.eclipse.m2e.editor.pomeditor/src/org/eclipse/m2e/editor/xml/pomeditor/MavenStructuredSourceTextEditor.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.pomeditor;
-
-import org.apache.maven.project.MavenProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.m2e.editor.pom.MavenPomEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
-
-// TODO extract to specific bundle and extension
-class MavenStructuredSourceTextEditor extends StructuredTextEditor {
-
-	protected class MavenStructuredTextViewer extends StructuredTextViewer implements IAdaptable {
-
-		public MavenStructuredTextViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
-				boolean showAnnotationsOverview, int styles) {
-			super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
-		}
-
-		public MavenProject getMavenProject() {
-			return MavenStructuredSourceTextEditor.this.mavenPomEditor.getMavenProject();
-		}
-
-		public <T> T getAdapter(Class<T> adapter) {
-			if (MavenProject.class.equals(adapter)) {
-				return adapter.cast(getMavenProject());
-			}
-			return null;
-		}
-
-	}
-
-	/**
-	 * 
-	 */
-	private final MavenPomEditor mavenPomEditor;
-
-	/**
-	 * @param mavenPomEditor
-	 */
-	MavenStructuredSourceTextEditor(MavenPomEditor mavenPomEditor) {
-		this.mavenPomEditor = mavenPomEditor;
-	}
-
-	private long fModificationStamp = -1;
-
-	private MavenProject mvnprj;
-
-	protected void updateModificationStamp() {
-		IDocumentProvider p = this instanceof ITextEditor ? ((ITextEditor) this).getDocumentProvider() : null;
-		if (p == null)
-			return;
-		if (p instanceof IDocumentProviderExtension3) {
-			fModificationStamp = p.getModificationStamp(this.mavenPomEditor.getEditorInput());
-		}
-	}
-
-	/**
-	 * we override the creation of StructuredTextViewer to have our own subclass
-	 * created that drags along an instance of resolved MavenProject via
-	 * implementing IMavenProjectCache
-	 */
-	protected StructuredTextViewer createStructedTextViewer(Composite parent, IVerticalRuler verticalRuler,
-			int styles) {
-		return new MavenStructuredTextViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(),
-				styles);
-	}
-
-	protected void sanityCheckState(IEditorInput input) {
-
-		IDocumentProvider p = this instanceof ITextEditor ? ((ITextEditor) this).getDocumentProvider() : null;
-		if (p == null)
-			return;
-
-		if (p instanceof IDocumentProviderExtension3) {
-
-			IDocumentProviderExtension3 p3 = (IDocumentProviderExtension3) p;
-
-			long stamp = p.getModificationStamp(input);
-			if (stamp != fModificationStamp) {
-				fModificationStamp = stamp;
-				if (!p3.isSynchronized(input))
-					handleEditorInputChanged();
-			}
-
-		} else {
-
-			if (fModificationStamp == -1)
-				fModificationStamp = p.getSynchronizationStamp(input);
-
-			long stamp = p.getModificationStamp(input);
-			if (stamp != fModificationStamp) {
-				fModificationStamp = stamp;
-				if (stamp != p.getSynchronizationStamp(input))
-					handleEditorInputChanged();
-			}
-		}
-
-		updateState(this.getEditorInput());
-		updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
-	}
-
-	private boolean oldDirty;
-
-	public boolean isDirty() {
-		boolean dirty = super.isDirty();
-		if (oldDirty != dirty) {
-			oldDirty = dirty;
-			updatePropertyDependentActions();
-		}
-		return dirty;
-	}
-
-	@Override
-	public void dispose() {
-		Object outlinePage = this.getAdapter(IContentOutlinePage.class);
-		if (outlinePage instanceof ConfigurableContentOutlinePage) {
-			((ConfigurableContentOutlinePage) outlinePage).setEditorPart(null);
-		}
-		super.dispose();
-	}
-
-}
diff --git a/org.eclipse.m2e.feature/feature.xml b/org.eclipse.m2e.feature/feature.xml
index 888422a..9225652 100644
--- a/org.eclipse.m2e.feature/feature.xml
+++ b/org.eclipse.m2e.feature/feature.xml
@@ -21,20 +21,10 @@
          id="org.eclipse.m2e.lemminx.feature"
          version="0.0.0"
          optional="true"/>
-
-   <requires>
-      <import plugin="org.eclipse.emf.ecore"/>
-      <import plugin="org.eclipse.emf.ecore.xmi"/>
-      <import plugin="org.eclipse.emf.edit"/>
-      <import plugin="org.eclipse.emf.ecore.edit"/>
-      <import plugin="org.eclipse.wst.common.emf"/>
-      <import plugin="org.eclipse.wst.sse.core"/>
-      <import plugin="org.eclipse.wst.xml.core"/>
-      <import plugin="org.eclipse.jem.util"/>
-      <import plugin="org.eclipse.platform"/>
-      <import feature="org.eclipse.rcp" version="3.6.0" match="greaterOrEqual"/>
-      <import feature="org.eclipse.jdt" version="3.6.0" match="greaterOrEqual"/>
-   </requires>
+   <includes
+         id="org.eclipse.m2e.sse.ui.feature"
+         version="0.0.0"
+         optional="true"/>
 
    <plugin
          id="org.eclipse.m2e.archetype.common"
@@ -91,13 +81,6 @@
          unpack="false"/>
 
    <plugin
-         id="org.eclipse.m2e.editor.xml"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
          id="org.eclipse.m2e.maven.runtime"
          download-size="0"
          install-size="0"
diff --git a/org.eclipse.m2e.site/category.xml b/org.eclipse.m2e.site/category.xml
index 217a5af..e7e7651 100644
--- a/org.eclipse.m2e.site/category.xml
+++ b/org.eclipse.m2e.site/category.xml
@@ -12,5 +12,8 @@
    <feature id="org.eclipse.m2e.lemminx.feature">
       <category name="m2e"/>
    </feature>
+   <feature id="org.eclipse.m2e.sse.ui.feature">
+      <category name="m2e"/>
+   </feature>
    <category-def name="m2e" label="Maven Integration for Eclipse"/>
 </site>
diff --git a/org.eclipse.m2e.editor.pomeditor/build.properties b/org.eclipse.m2e.sse.ui.feature/build.properties
similarity index 73%
rename from org.eclipse.m2e.editor.pomeditor/build.properties
rename to org.eclipse.m2e.sse.ui.feature/build.properties
index 38537d3..8d3e57a 100644
--- a/org.eclipse.m2e.editor.pomeditor/build.properties
+++ b/org.eclipse.m2e.sse.ui.feature/build.properties
@@ -10,9 +10,5 @@
 #      Sonatype, Inc. - initial API and implementation
 #
 
-jars.compile.order = .
-source.. = src/
-output.. = target/classes/
-bin.includes = plugin.xml,\
-               .,\
-               META-INF/,\
\ No newline at end of file
+bin.includes = feature.xml,\
+               feature.properties
diff --git a/org.eclipse.m2e.sse.ui.feature/feature.properties b/org.eclipse.m2e.sse.ui.feature/feature.properties
new file mode 100644
index 0000000..eff3eae
--- /dev/null
+++ b/org.eclipse.m2e.sse.ui.feature/feature.properties
@@ -0,0 +1,39 @@
+###############################################################################
+# Copyright (c) 2008, 2010 Sonatype, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License 2.0
+# which accompanies this distribution, and is available at
+# https://www.eclipse.org/legal/epl-2.0/
+#
+# SPDX-License-Identifier: EPL-2.0# 
+# Contributors:
+#     Sonatype, Inc. - initial API and implementation
+###############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=POM Editor (Legacy) using WebTools SourceEditing UI
+
+# "providerName" property - name of the company that provides the feature
+providerName=Eclipse.org - m2e
+
+# "updateSiteName" property - label for the update site
+#updateSiteName=The Eclipse Project Updates
+
+# "description" property - description of the feature
+description=(Legacy) POM Editor using WebTools SourceEditing UI
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=\
+Copyright (c) 2020 Red Hat Inc.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License 2.0\n\
+which accompanies this distribution, and is available at\n\
+https://www.eclipse.org/legal/epl-2.0/\n\
+\n\
+  SPDX-License-Identifier: EPL-2.0\n
+################ end of copyright property ####################################
diff --git a/org.eclipse.m2e.sse.ui.feature/feature.xml b/org.eclipse.m2e.sse.ui.feature/feature.xml
new file mode 100644
index 0000000..cb60992
--- /dev/null
+++ b/org.eclipse.m2e.sse.ui.feature/feature.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.eclipse.m2e.sse.ui.feature"
+      label="%featureName"
+      version="1.16.0.qualifier"
+      provider-name="%providerName"
+      license-feature="org.eclipse.license"
+      license-feature-version="0.0.0">
+   <install-handler/>
+
+   <description>
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <plugin
+         id="org.eclipse.m2e.editor.xml"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.m2e.editor.pomeditor/pom.xml b/org.eclipse.m2e.sse.ui.feature/pom.xml
similarity index 79%
rename from org.eclipse.m2e.editor.pomeditor/pom.xml
rename to org.eclipse.m2e.sse.ui.feature/pom.xml
index c1d70d7..2abc95e 100644
--- a/org.eclipse.m2e.editor.pomeditor/pom.xml
+++ b/org.eclipse.m2e.sse.ui.feature/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  Copyright (c) 2008 Sonatype, Inc.
+  Copyright (c) 2020 Red Hat, Inc.
   All rights reserved. This program and the accompanying materials
   are made available under the terms of the Eclipse Public License 2.0
   which accompanies this distribution, and is available at
@@ -17,9 +17,6 @@
     <version>1.16.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>org.eclipse.m2e.editor.pomeditor</artifactId>
-  <packaging>eclipse-plugin</packaging>
-
-  <name>Structured Maven POM Editor</name>
-
+  <artifactId>org.eclipse.m2e.sse.ui.feature</artifactId>
+  <packaging>eclipse-feature</packaging>
 </project>
diff --git a/pom.xml b/pom.xml
index 29ec08b..ee4a469 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,6 @@
     <module>org.eclipse.m2e.sourcelookup</module>
     <module>org.eclipse.m2e.sourcelookup.ui</module>
     <module>org.eclipse.m2e.editor.lemminx</module>
-	<module>org.eclipse.m2e.editor.pomeditor</module>
 
     <!-- common test helpers -->
     <module>org.eclipse.m2e.tests.common</module>
@@ -140,6 +139,7 @@
     <!-- features and update site -->
     <module>org.eclipse.m2e.feature</module>
     <module>org.eclipse.m2e.lemminx.feature</module>
+    <module>org.eclipse.m2e.sse.ui.feature</module>
     <module>org.eclipse.m2e.sdk.feature</module>
     <module>org.eclipse.m2e.logback.feature</module>
     <module>org.eclipse.m2e.site</module>