From a56b4d9cfa145f5ec6261d4ff8cda43b634592c8 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 8 Dec 2016 15:15:08 -0500 Subject: [PATCH] Add context help to new Maven project wizard (#1083) * Add help contexts for Maven new project wizard * Allow getting Workbench in tests * Lower-case "standard" in normal text body --- .../pom.xml | 15 ++++++- .../newproject/maven/ContextXmlTest.java | 45 +++++++++++++++++++ .../helpContexts.xml | 15 +++++++ .../plugin.xml | 7 +++ ...nAppEngineStandardArchetypeWizardPage.java | 14 +++--- .../MavenAppEngineStandardWizardPage.java | 8 +++- .../pom.xml | 2 - .../newproject/StandardProjectWizardTest.java | 4 +- .../helpContexts.xml | 4 +- 9 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/ContextXmlTest.java create mode 100644 plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/helpContexts.xml diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/pom.xml b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/pom.xml index ae22b34aca..438cdc2b3e 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/pom.xml +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/pom.xml @@ -11,6 +11,17 @@ com.google.cloud.tools.eclipse.appengine.newproject.maven.test 0.1.0-SNAPSHOT eclipse-test-plugin - - + + + + org.eclipse.tycho + tycho-surefire-plugin + + true + org.eclipse.platform.ide + + + + + diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/ContextXmlTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/ContextXmlTest.java new file mode 100644 index 0000000000..19a2668627 --- /dev/null +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven.test/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/ContextXmlTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.tools.eclipse.appengine.newproject.maven; + +import static org.junit.Assert.assertEquals; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.junit.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +public class ContextXmlTest { + + @Test + public void testWellFormed() throws ParserConfigurationException, IOException, SAXException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + DocumentBuilder builder = factory.newDocumentBuilder(); + + try (InputStream contentXml = new FileInputStream( + "../com.google.cloud.tools.eclipse.appengine.newproject.maven/helpContexts.xml")) { + Document document = builder.parse(contentXml); + assertEquals(2, document.getElementsByTagName("context").getLength()); + } + } +} diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/helpContexts.xml b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/helpContexts.xml new file mode 100644 index 0000000000..c0ab6a1f16 --- /dev/null +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/helpContexts.xml @@ -0,0 +1,15 @@ + + + + Create a new Maven-based Eclipse project that can be deployed to the App Engine standard environment. + +<b>Group ID:</b> The Maven Group ID. Should be an alphanumeric path separated by periods. + +<b>Artifact ID:</b> The Maven Artifact ID. Should be an alphanumeric name separated by dashes. + +<b>Libraries to add to build path:</b> Adds useful libraries for the App Engine standard environment for your project build path. + + + Choose one of the Maven archetypes pre-configured for the App Engine standard environment. + + diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/plugin.xml b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/plugin.xml index 88a1a4f4ea..81694ba1da 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/plugin.xml +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/plugin.xml @@ -44,4 +44,11 @@ + + + + + diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardArchetypeWizardPage.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardArchetypeWizardPage.java index bff529987d..7d6e514fb1 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardArchetypeWizardPage.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardArchetypeWizardPage.java @@ -18,7 +18,8 @@ import com.google.cloud.tools.eclipse.appengine.ui.AppEngineImages; import com.google.common.annotations.VisibleForTesting; - +import java.util.Arrays; +import java.util.Collections; import org.apache.maven.archetype.catalog.Archetype; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridDataFactory; @@ -30,15 +31,13 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.List; - -import java.util.Arrays; -import java.util.Collections; +import org.eclipse.ui.PlatformUI; /** * UI to select an archetype in creating a new Maven-based App Engine Standard Java project. */ public class MavenAppEngineStandardArchetypeWizardPage extends WizardPage { - + @VisibleForTesting static final java.util.List PRESET_ARCHETYPES = Collections.unmodifiableList(Arrays.asList( @@ -68,6 +67,9 @@ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(container); + PlatformUI.getWorkbench().getHelpSystem().setHelp(container, + "com.google.cloud.tools.eclipse.appengine.newproject.maven.ArchetypeSelectionContext"); //$NON-NLS-1$ + // List of (selectable) archetypes on the left archetypeList = new List(container, SWT.SINGLE | SWT.BORDER); for (ArchetypeTuple tuple : PRESET_ARCHETYPES) { @@ -109,7 +111,7 @@ static class ArchetypeTuple { Archetype archetype; String displayName; String description; - + ArchetypeTuple(String groupId, String artifactId, String displayName, String description) { archetype = new Archetype(); archetype.setGroupId(groupId); diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardWizardPage.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardWizardPage.java index 45235d8b45..c6637d00a0 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardWizardPage.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.maven/src/com/google/cloud/tools/eclipse/appengine/newproject/maven/MavenAppEngineStandardWizardPage.java @@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; /** * UI to collect all information necessary to create a new Maven-based App Engine Standard Java @@ -110,6 +111,9 @@ public void createControl(Composite parent) { GridLayoutFactory.swtDefaults().numColumns(2).applyTo(container); setControl(container); + PlatformUI.getWorkbench().getHelpSystem().setHelp(container, + "com.google.cloud.tools.eclipse.appengine.newproject.maven.NewMavenProjectContext"); //$NON-NLS-1$ + createLocationArea(container); createMavenCoordinatesArea(container); createAppEngineProjectDetailsArea(container); @@ -307,11 +311,11 @@ static boolean validateLocation(String location, WizardPage page) { } catch (FileAlreadyExistsException ex) { String message = Messages.getString("FILE_LOCATION", location); //$NON-NLS-1$ page.setMessage(message, ERROR); - return false; + return false; } catch (IOException ex) { String message = Messages.getString("INVALID_PATH", location); //$NON-NLS-1$ page.setMessage(message, ERROR); - return false; + return false; } } } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/pom.xml b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/pom.xml index 8033a94fbd..90cfede2c1 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/pom.xml +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/pom.xml @@ -72,5 +72,3 @@ - - diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizardTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizardTest.java index 6a548477cd..210d96ba3a 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizardTest.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizardTest.java @@ -38,7 +38,7 @@ public void setUp() { public void testTitleSet() { Assert.assertEquals("New App Engine Standard Project", wizard.getWindowTitle()); } - + @Test public void testAddPages() { wizard.addPages(); @@ -46,5 +46,5 @@ public void testAddPages() { Assert.assertEquals(1, wizard.getPageCount()); Assert.assertNotNull(wizard.getPage("basicNewProjectPage")); } - + } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml b/plugins/com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml index 965b244dd7..77167c2a82 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml @@ -1,10 +1,10 @@ - Create a new Eclipse project that can be deployed to the App Engine Standard environment. + Create a new Eclipse project that can be deployed to the App Engine standard environment. <b>Project name:</b> An Eclipse project name. -<b>Libraries to add to build path:</b> Add some libraries on the App Engine Standard environment to your build path. +<b>Libraries to add to build path:</b> Adds useful libraries for the App Engine standard environment for your project build path.