Refactored WTP new project code to easily extend to include flex support.#1497
Refactored WTP new project code to easily extend to include flex support.#1497nbashirbello merged 18 commits intomasterfrom
Conversation
Property tester works
|
PR not ready for review |
|
PR ready for review |
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| public class StandardProjectWizardTest { |
There was a problem hiding this comment.
should probably rename this too
|
|
||
| /** | ||
| * Collects all data needed to create and configure an App Engine Standard Project. | ||
| * Collects all data needed to create and configure an App Engine Project. |
There was a problem hiding this comment.
App Engine Eclipse project.
| * Collects all data needed to create and configure an App Engine Project. | ||
| */ | ||
| class AppEngineStandardProjectConfig { | ||
| public class AppEngineProjectConfig { |
There was a problem hiding this comment.
I start to get nervous when methods get more public. This is now exposing mutable internal state publicly.
| setNeedsProgressMonitor(true); | ||
| } | ||
|
|
||
| public abstract AppEngineWizardPage getWizardPage(); |
There was a problem hiding this comment.
It looks like this may not be a pure getter method if it's not returning the value of the page field. If so, please rename. Maybe createWizardPage()?
| private ILibraryClasspathContainerResolverService resolverService; | ||
|
|
||
| public AppEngineStandardProjectWizard(){ | ||
| super(); |
There was a problem hiding this comment.
delete this line since it's automatic
| } | ||
|
|
||
| @Override | ||
| public AppEngineWizardPage getWizardPage() { |
There was a problem hiding this comment.
yes, definitely rename this method since getters aren't creators.
|
|
||
| try (InputStream contentXml = new FileInputStream( | ||
| "../com.google.cloud.tools.eclipse.appengine.newproject/helpContexts.xml")) { | ||
| "../com.google.cloud.tools.eclipse.appengine.newproject/standardHelpContexts.xml")) { |
There was a problem hiding this comment.
It's kind of convention to use the name helpContexts.xml. We also test if the file is included in build.properties: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/blob/master/plugins/com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/BasePluginXmlTest.java#L112
I think you can keep the name helpContexts.xml, and put both standard and flex help contexts into this file.
| plugin.properties,\ | ||
| plugin.xml,\ | ||
| helpContexts.xml | ||
| standardHelpContexts.xml |
| point="org.eclipse.help.contexts"> | ||
| <contexts | ||
| file="helpContexts.xml"> | ||
| file="standardHelpContexts.xml"> |
|
|
||
| public abstract void sendAnalyticsPing(); | ||
|
|
||
| public abstract IStatus validateDependencies(boolean fork, boolean cancelable); |
There was a problem hiding this comment.
The two arguments are always true, so I don't see a great value to accept them.
| } | ||
|
|
||
| @Override | ||
| public void sendAnalyticsPing(Composite parent) { |
There was a problem hiding this comment.
Please rename parent to shell, and let the caller pass parent.getShell().
| @Override | ||
| public void setHelp(Composite container) { | ||
| PlatformUI.getWorkbench().getHelpSystem().setHelp(container, | ||
| "com.google.cloud.tools.eclipse.appengine.newproject.NewStandardProjectContext"); //$NON-NLS-1$ |
There was a problem hiding this comment.
You'll have to duplicate PlatformUI.getWorkbench().getHelpSystem().setHelp(container, ...) in flex too.
Somewhat in a similar vein as https://github.com/GoogleCloudPlatform/google-cloud-eclipse/pull/1497/files#r103506394, I wonder if it's better to accept a help context ID (the literal string here) through a constructor (accepting null) and just have this code at the base class instead of having this extra setHelp() method. It's your preference though.
There was a problem hiding this comment.
Same as the earlier comment.
|
|
||
| public abstract String getCreateNewProjectOperationLabel(); | ||
|
|
||
| public abstract IFile createProjectFiles(IProject newProject, AppEngineProjectConfig config, |
There was a problem hiding this comment.
Please add a javadoc saying that this method should return the most important file that the IDE will auto-open.
|
|
||
| public abstract void addAppEngineFacet(IProject newProject, IProgressMonitor monitor) throws CoreException; | ||
|
|
||
| public abstract String getCreateNewProjectOperationLabel(); |
There was a problem hiding this comment.
It will be helpful to add a Javadoc about where the label will be used.
There was a problem hiding this comment.
I'm not experienced in design patterns, but I think you don't really have to have an abstract method if what you want to get is just a literal value? That is, you can have a field for this label here and let subclasses pass the value through a constructor. Thoughts?
There was a problem hiding this comment.
Both approaches would work in this case. It's not uncommon for abstract methods to provide labels and descriptions.
| public AppEngineStandardWizardPage() { | ||
| super(); | ||
| setTitle(Messages.getString("app.engine.standard.project")); //$NON-NLS-1$ | ||
| setDescription(Messages.getString("create.app.engine.standard.project")); //$NON-NLS-1$ |
There was a problem hiding this comment.
What do you think about passing a title and a description through arguments. (No strong opinion here.)
|
|
||
| public AppEngineStandardProjectWizard(){ | ||
| super(); | ||
| setWindowTitle(Messages.getString("new.app.engine.standard.project")); |
There was a problem hiding this comment.
You forgot to call this in the flex counterpart. How about accepting the title as an argument?
| Composite container = (Composite) getControl(); | ||
| PlatformUI.getWorkbench().getHelpSystem().setHelp(container, | ||
| "com.google.cloud.tools.eclipse.appengine.newproject.NewProjectContext"); //$NON-NLS-1$ | ||
| setHelp(container.getShell()); |
There was a problem hiding this comment.
I think this should be container.
| setNeedsProgressMonitor(true); | ||
| } | ||
|
|
||
| public abstract AppEngineWizardPage createWizardPage(); |
There was a problem hiding this comment.
Which wizard page? Is this the main page?
There was a problem hiding this comment.
Yes, there is only one page for creating the wtp project.
| import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; | ||
|
|
||
| /** | ||
| * Utility to make a new Eclipse project with the App Engine Standard facets in the workspace. |
|
|
||
| public abstract void addAppEngineFacet(IProject newProject, IProgressMonitor monitor) throws CoreException; | ||
|
|
||
| public abstract String getCreateNewProjectOperationLabel(); |
| private String serviceName; | ||
|
|
||
| File getCloudSdkLocation() { | ||
| public File getCloudSdkLocation() { |
There was a problem hiding this comment.
Aside: seems odd for the Cloud SDK location to be here.
|
|
||
| public abstract IStatus validateDependencies(boolean fork, boolean cancelable); | ||
|
|
||
| public abstract CreateAppEngineWtpProject getAppEngineProjectCreationOperation( |
There was a problem hiding this comment.
This seems odd. I wonder if we wouldn't be better to have an abstract createProject() operation like what you've done for validateDependencies().
There was a problem hiding this comment.
Chatted offline. Will leave as is since all the flex operation are workspace operations
| * Returns a user visible name for the resource operation that generates the files | ||
| * for the App Engine WTP project. | ||
| */ | ||
| public abstract String getCreateNewProjectOperationLabel(); |
There was a problem hiding this comment.
Not a big fan of this name. getDescription()?
| import org.eclipse.swt.widgets.Composite; | ||
| import org.eclipse.swt.widgets.Shell; | ||
|
|
||
| public class AppEngineFlexWizardPage extends AppEngineWizardPage { |
There was a problem hiding this comment.
I'm curious to see how this will be different from the AppEngineStandardWizardPage. If it's just the ping-type and help id, then we could make those configurable items passed in during creation?
There was a problem hiding this comment.
This will be expanded in a subsequent PR.
| AnalyticsPingManager.getInstance().sendPing( | ||
| AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_COMPLETE, | ||
| AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_TYPE, | ||
| AnalyticsEvents.APP_ENGINE_NEW_PROJECT_WIZARD_TYPE_NATIVE); |
There was a problem hiding this comment.
Do we need to add something here to differentiate between std and flex?
There was a problem hiding this comment.
This would be done in a subsequent PR.
|
|
||
|
|
||
| </plugin> | ||
|
|
There was a problem hiding this comment.
I don't think we need two blank lines?
| sdk.validateCloudSdk(); | ||
| sdk.validateAppEngineJavaComponents(); | ||
| page = new AppEngineStandardWizardPage(); | ||
| page = createWizardPage(); |
There was a problem hiding this comment.
My 2¢: since it's important to have the Cloud SDK validation test here, I'd prefer following the addPages() pattern here and delegate the add-page to an abstract method like addAppEnginePages(). This gives AppEngine Std and Flex the flexibility to independently add multiple pages should they need to (e.g., Flex may need to select a runtime?) without having to refactor this or figure out how to shoehorn the functionality into a single page.
Codecov Report
@@ Coverage Diff @@
## master #1497 +/- ##
============================================
+ Coverage 69.91% 70.79% +0.87%
- Complexity 1237 1349 +112
============================================
Files 219 230 +11
Lines 8796 9239 +443
Branches 743 790 +47
============================================
+ Hits 6150 6541 +391
- Misses 2331 2380 +49
- Partials 315 318 +3
Continue to review full report at Codecov.
|
No description provided.