Skip to content

Commit 8aae460

Browse files
authored
Refactored WTP new project code to easily extend to include flex support. (#1497)
* Added menu items for creating a new flex project under File.. and under the CT4E dropdown * Merged master and moved FlexFacetPropertyTester into new flex bundle. Property tester works * Moved flex new project declaration into new flex bundle * Added help context for Flex * Refactored WTP new project code to easily extend to include flex support. * Removed code for viewing flex new project wizard. Will move this code to a different PR * Removed FlexFacetPropertyTester. * Clean up * Removed some flex ui stuff * Reverted c.g.c.t.e.appengine.flex/plugin.xml * Fixed path to AppEngineStandardProjectWizard * Minor changes per PR comments * Renamed standardHelpContexts.xml back to helpContents.xml * Minor changes per PR comments * Passed container to setHelp in AppEngineWizardPage#createControl * Minor changes per PR comments. * Remove extra blank line
1 parent 5ae9f20 commit 8aae460

21 files changed

Lines changed: 441 additions & 112 deletions

File tree

plugins/com.google.cloud.tools.eclipse.appengine.flex/plugin.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@
2727
<delegate class="com.google.cloud.tools.eclipse.appengine.facets.FlexFacetUninstallDelegate"/>
2828
</action>
2929
</extension>
30-
3130

32-
</plugin>
31+
</plugin>

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineStandardProjectConfigTest.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineProjectConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import org.junit.Assert;
3232
import org.junit.Test;
3333

34-
public class AppEngineStandardProjectConfigTest {
34+
public class AppEngineProjectConfigTest {
3535

36-
private AppEngineStandardProjectConfig config = new AppEngineStandardProjectConfig();
36+
private AppEngineProjectConfig config = new AppEngineProjectConfig();
3737

3838
public void testProject() throws CoreException {
3939
try {

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void cleanUp() throws CoreException {
7373
@Test
7474
public void testMaterialize()
7575
throws CoreException, ParserConfigurationException, SAXException, IOException {
76-
AppEngineStandardProjectConfig config = new AppEngineStandardProjectConfig();
76+
AppEngineProjectConfig config = new AppEngineProjectConfig();
7777

7878
IFile mostImportant = CodeTemplates.materialize(project, config, monitor);
7979

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizardTest.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/standard/AppEngineStandardProjectWizardTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.tools.eclipse.appengine.newproject;
17+
package com.google.cloud.tools.eclipse.appengine.newproject.standard;
1818

19+
import com.google.cloud.tools.eclipse.appengine.newproject.AppEngineProjectWizard;
1920
import org.junit.Assert;
2021
import org.junit.Before;
2122
import org.junit.Test;
2223

23-
public class StandardProjectWizardTest {
24+
public class AppEngineStandardProjectWizardTest {
2425

25-
private StandardProjectWizard wizard;
26+
private AppEngineProjectWizard wizard;
2627

2728
@Before
2829
public void setUp() {
2930
try {
30-
wizard = new StandardProjectWizard();
31+
wizard = new AppEngineStandardProjectWizard();
3132
// I don't know why this fails the first time and passes the second, but it does.
3233
} catch (NullPointerException ex) {
33-
wizard = new StandardProjectWizard();
34+
wizard = new AppEngineStandardProjectWizard();
3435
}
3536
}
3637

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineStandardWizardPageTest.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/standard/AppEngineStandardWizardPageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.tools.eclipse.appengine.newproject;
17+
package com.google.cloud.tools.eclipse.appengine.newproject.standard;
1818

1919
import org.eclipse.swt.SWT;
2020
import org.eclipse.swt.widgets.Composite;

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CreateAppEngineStandardWtpProjectTest.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/standard/CreateAppEngineStandardWtpProjectTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.tools.eclipse.appengine.newproject;
17+
package com.google.cloud.tools.eclipse.appengine.newproject.standard;
1818

1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertNotNull;
@@ -23,6 +23,8 @@
2323

2424
import com.google.cloud.tools.eclipse.appengine.facets.AppEngineStandardFacet;
2525
import com.google.cloud.tools.eclipse.appengine.libraries.model.Library;
26+
import com.google.cloud.tools.eclipse.appengine.newproject.AppEngineProjectConfig;
27+
import com.google.cloud.tools.eclipse.appengine.newproject.CreateAppEngineWtpProject;
2628
import com.google.cloud.tools.eclipse.test.util.ThreadDumpingWatchdog;
2729
import com.google.cloud.tools.eclipse.test.util.project.ProjectUtils;
2830
import java.lang.reflect.InvocationTargetException;
@@ -61,7 +63,7 @@ public class CreateAppEngineStandardWtpProjectTest {
6163
@Mock private IAdaptable adaptable;
6264

6365
private NullProgressMonitor monitor = new NullProgressMonitor();
64-
private AppEngineStandardProjectConfig config = new AppEngineStandardProjectConfig();
66+
private AppEngineProjectConfig config = new AppEngineProjectConfig();
6567
private IProject project;
6668

6769
@Before
@@ -83,7 +85,7 @@ public void testConstructor() {
8385

8486
@Test
8587
public void testUnitTestCreated() throws InvocationTargetException, CoreException {
86-
CreateAppEngineStandardWtpProject creator =
88+
CreateAppEngineWtpProject creator =
8789
new CreateAppEngineStandardWtpProject(config, adaptable);
8890
creator.execute(new NullProgressMonitor());
8991

@@ -109,7 +111,7 @@ private void assertJunitAndHamcrestAreOnClasspath() throws CoreException {
109111

110112
@Test
111113
public void testMostImportantFile() throws InvocationTargetException, CoreException {
112-
CreateAppEngineStandardWtpProject creator =
114+
CreateAppEngineWtpProject creator =
113115
new CreateAppEngineStandardWtpProject(config, adaptable);
114116
creator.execute(new NullProgressMonitor());
115117

@@ -138,7 +140,7 @@ public void testFaviconAdded() throws InvocationTargetException, CoreException {
138140
public void testAppEngineLibrariesAdded() throws InvocationTargetException, CoreException {
139141
Library library = new Library(APP_ENGINE_API);
140142
config.setAppEngineLibraries(Collections.singletonList(library));
141-
CreateAppEngineStandardWtpProject creator =
143+
CreateAppEngineWtpProject creator =
142144
new CreateAppEngineStandardWtpProject(config, adaptable);
143145
creator.execute(new NullProgressMonitor());
144146

plugins/com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<contexts>
3-
<context id="NewProjectContext" title="Create App Engine Standard Project">
3+
<context id="NewStandardProjectContext" title="Create App Engine Standard Project">
44
<description>Create a new Eclipse project that can be deployed to the App Engine standard environment.
55

66
&lt;b&gt;Project name:&lt;/b&gt; An Eclipse project name.

plugins/com.google.cloud.tools.eclipse.appengine.newproject/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<wizard
66
id="com.google.cloud.tools.eclipse.appengine.newproject.AppEngineStandard"
77
name="%wizard.name"
8-
class="com.google.cloud.tools.eclipse.util.service.ServiceContextFactory:com.google.cloud.tools.eclipse.appengine.newproject.StandardProjectWizard"
8+
class="com.google.cloud.tools.eclipse.util.service.ServiceContextFactory:com.google.cloud.tools.eclipse.appengine.newproject.standard.AppEngineStandardProjectWizard"
99
icon="platform:/plugin/com.google.cloud.tools.eclipse.appengine.ui/icons/gae-16x16.png"
1010
project="true"
1111
category="com.google.cloud.tools.eclipse.appengine.wizards">

plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineStandardProjectConfig.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineProjectConfig.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,64 +26,64 @@
2626
import org.eclipse.core.resources.IProject;
2727

2828
/**
29-
* Collects all data needed to create and configure an App Engine Standard Project.
29+
* Collects all data needed to create and configure an App Engine Eclipse Project.
3030
*/
31-
class AppEngineStandardProjectConfig {
31+
public class AppEngineProjectConfig {
3232
private File cloudSdkLocation = null;
3333
private URI eclipseProjectLocationUri = null;
3434
private String packageName = "";
3535
private IProject project;
3636
private List<Library> appEngineLibraries = Collections.emptyList();
3737
private String serviceName;
3838

39-
File getCloudSdkLocation() {
39+
public File getCloudSdkLocation() {
4040
return cloudSdkLocation;
4141
}
4242

43-
void setCloudSdkLocation(File cloudSdkLocation) {
43+
public void setCloudSdkLocation(File cloudSdkLocation) {
4444
this.cloudSdkLocation = cloudSdkLocation;
4545
}
4646

47-
void setPackageName(String name) {
47+
public void setPackageName(String name) {
4848
this.packageName = name;
4949
}
5050

51-
String getPackageName() {
51+
public String getPackageName() {
5252
return this.packageName;
5353
}
5454

5555
/**
5656
* Null project location URI means the default location.
5757
*/
58-
void setProject(IProject project) {
58+
public void setProject(IProject project) {
5959
this.project = project;
6060
}
6161

62-
IProject getProject() {
62+
public IProject getProject() {
6363
return this.project;
6464
}
6565

66-
URI getEclipseProjectLocationUri() {
66+
public URI getEclipseProjectLocationUri() {
6767
return this.eclipseProjectLocationUri;
6868
}
6969

70-
void setEclipseProjectLocationUri(URI uri) {
70+
public void setEclipseProjectLocationUri(URI uri) {
7171
this.eclipseProjectLocationUri = uri;
7272
}
7373

74-
List<Library> getAppEngineLibraries() {
74+
public List<Library> getAppEngineLibraries() {
7575
return appEngineLibraries;
7676
}
7777

78-
void setAppEngineLibraries(Collection<Library> libraries) {
78+
public void setAppEngineLibraries(Collection<Library> libraries) {
7979
this.appEngineLibraries = new ArrayList<>(libraries);
8080
}
8181

82-
String getServiceName() {
82+
public String getServiceName() {
8383
return serviceName;
8484
}
8585

86-
void setServiceName(String serviceName) {
86+
public void setServiceName(String serviceName) {
8787
this.serviceName = serviceName;
8888
}
8989

plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/StandardProjectWizard.java renamed to plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineProjectWizard.java

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,51 @@
2020
import com.google.cloud.tools.appengine.cloudsdk.CloudSdk;
2121
import com.google.cloud.tools.appengine.cloudsdk.CloudSdkNotFoundException;
2222
import com.google.cloud.tools.appengine.cloudsdk.CloudSdkOutOfDateException;
23-
import com.google.cloud.tools.eclipse.appengine.libraries.ILibraryClasspathContainerResolverService;
24-
import com.google.cloud.tools.eclipse.appengine.libraries.ILibraryClasspathContainerResolverService.AppEngineRuntime;
2523
import com.google.cloud.tools.eclipse.appengine.ui.AppEngineJavaComponentMissingPage;
2624
import com.google.cloud.tools.eclipse.appengine.ui.CloudSdkMissingPage;
2725
import com.google.cloud.tools.eclipse.appengine.ui.CloudSdkOutOfDatePage;
2826
import com.google.cloud.tools.eclipse.sdk.ui.preferences.CloudSdkPrompter;
2927
import com.google.cloud.tools.eclipse.ui.util.WorkbenchUtil;
3028
import com.google.cloud.tools.eclipse.usagetracker.AnalyticsEvents;
31-
import com.google.cloud.tools.eclipse.usagetracker.AnalyticsPingManager;
3229
import com.google.cloud.tools.eclipse.util.status.StatusUtil;
3330
import java.io.File;
3431
import java.lang.reflect.InvocationTargetException;
35-
import javax.inject.Inject;
3632
import org.eclipse.core.resources.IFile;
3733
import org.eclipse.core.runtime.IAdaptable;
38-
import org.eclipse.core.runtime.IProgressMonitor;
3934
import org.eclipse.core.runtime.IStatus;
4035
import org.eclipse.core.runtime.Status;
41-
import org.eclipse.jface.operation.IRunnableWithProgress;
4236
import org.eclipse.jface.viewers.IStructuredSelection;
4337
import org.eclipse.jface.wizard.Wizard;
4438
import org.eclipse.ui.INewWizard;
4539
import org.eclipse.ui.IWorkbench;
4640
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
4741

48-
public class StandardProjectWizard extends Wizard implements INewWizard {
42+
public abstract class AppEngineProjectWizard extends Wizard implements INewWizard {
4943

50-
private AppEngineStandardWizardPage page = null;
51-
private AppEngineStandardProjectConfig config = new AppEngineStandardProjectConfig();
44+
private AppEngineWizardPage page = null;
45+
private AppEngineProjectConfig config = new AppEngineProjectConfig();
5246
private IWorkbench workbench;
5347

54-
@Inject
55-
private ILibraryClasspathContainerResolverService resolverService;
56-
57-
public StandardProjectWizard() {
58-
setWindowTitle(Messages.getString("new.app.engine.standard.project"));
48+
public AppEngineProjectWizard() {
5949
setNeedsProgressMonitor(true);
6050
}
6151

52+
public abstract AppEngineWizardPage createWizardPage();
53+
54+
public abstract void sendAnalyticsPing();
55+
56+
public abstract IStatus validateDependencies(boolean fork, boolean cancelable);
57+
58+
public abstract CreateAppEngineWtpProject getAppEngineProjectCreationOperation(
59+
AppEngineProjectConfig config, IAdaptable uiInfoAdapter);
60+
6261
@Override
6362
public void addPages() {
6463
try {
6564
CloudSdk sdk = new CloudSdk.Builder().build();
6665
sdk.validateCloudSdk();
6766
sdk.validateAppEngineJavaComponents();
68-
page = new AppEngineStandardWizardPage();
67+
page = createWizardPage();
6968
addPage(page);
7069
} catch (CloudSdkNotFoundException ex) {
7170
addPage(new CloudSdkMissingPage(AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_TYPE_NATIVE));
@@ -79,31 +78,15 @@ public void addPages() {
7978

8079
@Override
8180
public boolean performFinish() {
82-
AnalyticsPingManager.getInstance().sendPing(
83-
AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_COMPLETE,
84-
AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_TYPE,
85-
AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_TYPE_NATIVE);
81+
sendAnalyticsPing();
8682

8783
if (page == null) {
8884
return true;
8985
}
9086

9187
boolean fork = true;
9288
boolean cancelable = true;
93-
IStatus status = Status.OK_STATUS;
94-
try {
95-
DependencyValidator dependencyValidator = new DependencyValidator();
96-
getContainer().run(fork, cancelable, dependencyValidator);
97-
if (!dependencyValidator.result.isOK()) {
98-
status = StatusUtil.setErrorStatus(this,
99-
Messages.getString("project.creation.failed"),
100-
dependencyValidator.result);
101-
}
102-
} catch (InvocationTargetException ex) {
103-
status = StatusUtil.setErrorStatus(this, Messages.getString("project.creation.failed"), ex.getCause());
104-
} catch (InterruptedException e) {
105-
status = Status.CANCEL_STATUS;
106-
}
89+
IStatus status = validateDependencies(fork, cancelable);
10790
if (!status.isOK()) {
10891
return false;
10992
}
@@ -119,8 +102,7 @@ public boolean performFinish() {
119102

120103
// todo set up
121104
IAdaptable uiInfoAdapter = WorkspaceUndoUtil.getUIInfoAdapter(getShell());
122-
CreateAppEngineStandardWtpProject runnable =
123-
new CreateAppEngineStandardWtpProject(config, uiInfoAdapter);
105+
CreateAppEngineWtpProject runnable = getAppEngineProjectCreationOperation(config, uiInfoAdapter);
124106

125107
try {
126108
getContainer().run(fork, cancelable, runnable);
@@ -149,14 +131,4 @@ public void init(IWorkbench workbench, IStructuredSelection selection) {
149131
}
150132
}
151133

152-
private class DependencyValidator implements IRunnableWithProgress {
153-
154-
private IStatus result = null;
155-
156-
@Override
157-
public void run(IProgressMonitor monitor)
158-
throws InvocationTargetException, InterruptedException {
159-
result = resolverService.checkRuntimeAvailability(AppEngineRuntime.STANDARD_JAVA_7, monitor);
160-
}
161-
}
162134
}

0 commit comments

Comments
 (0)