Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2994)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/ApplicationGenerator.java

Issue 9120017: modified New Application Wizard to allow for generation of web/command line application (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/generated-dart-server.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/ApplicationGenerator.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/ApplicationGenerator.java (revision 3100)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/ApplicationGenerator.java (working copy)
@@ -47,6 +47,8 @@
private String applicationLocation;
+ private boolean isWebApplication;
+
private IFile iApplicationFile = null;
/**
@@ -71,31 +73,13 @@
}
String applicationFileName = appendIfNoExtension(applicationName, Extensions.DOT_DART);
+ File applicationFile;
+ if (isWebApplication) {
+ applicationFile = generateWebApplication(monitor, applicationFileName);
+ } else {
+ applicationFile = generateCommandLineApp(monitor, applicationFileName);
+ }
- SubMonitor subMonitor = SubMonitor.convert(monitor,
- GeneratorMessages.ApplicationGenerator_message, 100);
- String className = applicationFileName.substring(0, applicationFileName.indexOf('.'));
- final HashMap<String, String> substitutions = new HashMap<String, String>();
- substitutions.put("className", className); //$NON-NLS-1$
- substitutions.put("extends", ""); //$NON-NLS-1$ //$NON-NLS-2$
- substitutions.put("implements", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- File applicationFile = getSystemFile(applicationFileName);
- execute("generated-dart-class-main.txt", applicationFile, substitutions, monitor); //$NON-NLS-1$
- subMonitor.newChild(100);
- subMonitor.done();
-
- // html file
- subMonitor = SubMonitor.convert(monitor,
- GeneratorMessages.ApplicationGenerator_htmlFileMessage, 100);
- String htmlFileName = appendIfNoExtension(applicationName, HTML_FILENAME_EXTENSION);
- File iHtmlFile = getSystemFile(htmlFileName);
- substitutions.put("title", className);
- substitutions.put("dartPath", applicationFileName + "." + JavascriptBackend.EXTENSION_APP_JS);
- execute("generated-html.txt", iHtmlFile, substitutions, monitor); //$NON-NLS-1$
- subMonitor.newChild(100);
- subMonitor.done();
-
DartLibrary library = DartCore.openLibrary(applicationFile, monitor);
if (library != null) {
library.setTopLevel(true);
@@ -126,6 +110,10 @@
return new File(applicationLocation + File.separator + fileName);
}
+ public boolean isWebApplication() {
+ return isWebApplication;
+ }
+
public void setApplicationLocation(String applicationLocation) {
this.applicationLocation = applicationLocation;
}
@@ -134,6 +122,10 @@
this.applicationName = applicationName;
}
+ public void setWebApplication(boolean isWebApplication) {
+ this.isWebApplication = isWebApplication;
+ }
+
/**
* Checks that the library location and file name are both valid.
*
@@ -148,6 +140,51 @@
return status;
}
+ private File generateCommandLineApp(IProgressMonitor monitor, String applicationFileName)
+ throws CoreException {
+ SubMonitor subMonitor = SubMonitor.convert(monitor,
+ GeneratorMessages.ApplicationGenerator_message, 100);
+
+ final HashMap<String, String> substitutions = new HashMap<String, String>();
+
+ File applicationFile = getSystemFile(applicationFileName);
+ execute("generated-dart-server.txt", applicationFile, substitutions, monitor); //$NON-NLS-1$
+ subMonitor.newChild(100);
+ subMonitor.done();
+
+ return applicationFile;
+ }
+
+ private File generateWebApplication(IProgressMonitor monitor, String applicationFileName)
+ throws CoreException {
+ SubMonitor subMonitor = SubMonitor.convert(monitor,
+ GeneratorMessages.ApplicationGenerator_message, 100);
+
+ String className = applicationFileName.substring(0, applicationFileName.indexOf('.'));
+
+ final HashMap<String, String> substitutions = new HashMap<String, String>();
+ substitutions.put("className", className); //$NON-NLS-1$
+ substitutions.put("extends", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ substitutions.put("implements", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ File applicationFile = getSystemFile(applicationFileName);
+ execute("generated-dart-class-main.txt", applicationFile, substitutions, monitor); //$NON-NLS-1$
+ subMonitor.newChild(100);
+ subMonitor.done();
+
+ // html file
+ subMonitor = SubMonitor.convert(monitor,
+ GeneratorMessages.ApplicationGenerator_htmlFileMessage, 100);
+ String htmlFileName = appendIfNoExtension(applicationName, HTML_FILENAME_EXTENSION);
+ File iHtmlFile = getSystemFile(htmlFileName);
+ substitutions.put("title", className);
+ substitutions.put("dartPath", applicationFileName + "." + JavascriptBackend.EXTENSION_APP_JS);
+ execute("generated-html.txt", iHtmlFile, substitutions, monitor); //$NON-NLS-1$
+ subMonitor.newChild(100);
+ subMonitor.done();
+ return applicationFile;
+ }
+
/**
* Validate the application location.
*
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/generator/generated-dart-server.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698