Skip to content

Commit

Permalink
Last fixes before 0.4.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Mar 9, 2011
1 parent e677f43 commit 169f140
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 45 deletions.
2 changes: 1 addition & 1 deletion editor/MoBL-Builders.esv
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ builders
builder : "Show ATerm" = generate-aterm (openeditor) (realtime) (meta)
//builder : "Format code" = format-code (openeditor) (realtime)
builder : "Desugar" = editor-desugar (openeditor) (realtime) (meta)
builder : "Optimized build" = editor-optimize
builder : "Release build" = editor-optimize
builder : "Clean project" = editor-clean-project
builder : "Rebuild project" = editor-rebuild-project

Expand Down
3 changes: 3 additions & 0 deletions editor/MoBL-Completions.esv
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,8 @@ completions
completion template : Setting =
"output " <"www"> (blank)

completion template : Setting =
"release" "output " <"www"> (blank)

completion template : Setting =
"database " <"mydb"> (blank)
61 changes: 40 additions & 21 deletions editor/java/mobl/MoblEditorWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
Expand All @@ -20,7 +17,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
Expand Down Expand Up @@ -66,7 +62,8 @@ public boolean performFinish() {
System.out.println(appName + projectName);

IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
public void run(IProgressMonitor monitor)
throws InvocationTargetException {
try {
doFinish(appName, projectName, monitor);
} catch (Exception e) {
Expand All @@ -84,8 +81,10 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException {
return false;
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
Environment.logException("Exception while creating new project", realException);
MessageDialog.openError(getShell(), "Error: " + realException.getClass().getName(), realException
Environment.logException("Exception while creating new project",
realException);
MessageDialog.openError(getShell(), "Error: "
+ realException.getClass().getName(), realException
.getMessage());
rollback();
return false;
Expand All @@ -103,21 +102,20 @@ private void rollback() {
}
}

private void doFinish(String appName, String projectName, IProgressMonitor monitor) throws IOException,
CoreException {
private void doFinish(String appName, String projectName,
IProgressMonitor monitor) throws IOException, CoreException {
final int TASK_COUNT = 3;
lastProject = null;
monitor.beginTask("Creating " + appName + " application", TASK_COUNT);

monitor.setTaskName("Creating Eclipse project");
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = lastProject = workspace.getRoot().getProject(projectName);
IProject project = lastProject = workspace.getRoot().getProject(
projectName);
project.create(null);
project.open(null);
monitor.worked(1);

try {

monitor.setTaskName("Generating default app");
StringBuilder sb = new StringBuilder();
sb.append("application " + appName + "\n");
Expand All @@ -128,7 +126,22 @@ private void doFinish(String appName, String projectName, IProgressMonitor monit
sb.append("\theader(\"" + appName + "\")\n");
sb.append("}\n");
monitor.worked(1);
writeStringToFile(sb.toString(), project.getLocation().toString()+"/"+appName + ".mobl");
writeStringToFile(sb.toString(), project.getLocation().toString()
+ "/" + appName + ".mobl");
} catch (IOException e) {
Environment.logException(e);
throw e;
}

try {
monitor.setTaskName("Generating configuration file");
StringBuilder sb = new StringBuilder();
sb.append("configuration\n");
sb.append("\n");
sb.append("title \"" + appName + "\"\n");
monitor.worked(1);
writeStringToFile(sb.toString(), project.getLocation().toString()
+ "/config.mobl");
} catch (IOException e) {
Environment.logException(e);
throw e;
Expand All @@ -140,17 +153,20 @@ private void doFinish(String appName, String projectName, IProgressMonitor monit
monitor.setTaskName("Opening editor tab");

Display display = getShell().getDisplay();
EditorState.asyncOpenEditor(display, project.getFile(appName + ".mobl"), true);
EditorState.asyncOpenEditor(display,
project.getFile(appName + ".mobl"), true);
monitor.worked(1);
}

public static void writeStringToFile(String s, String file) throws IOException {
public static void writeStringToFile(String s, String file)
throws IOException {
FileOutputStream in = null;
try {
File buildxml = new File(file);
in = new FileOutputStream(buildxml);
FileChannel fchan = in.getChannel();
BufferedWriter bf = new BufferedWriter(Channels.newWriter(fchan, "UTF-8"));
BufferedWriter bf = new BufferedWriter(Channels.newWriter(fchan,
"UTF-8"));
bf.write(s);
bf.close();
} finally {
Expand All @@ -164,7 +180,8 @@ public static void createDirs(String dirs) {
new File(dirs).mkdirs();
}

public static void copyFile(String ssource, String sdest) throws IOException {
public static void copyFile(String ssource, String sdest)
throws IOException {
System.out.println("Copying " + ssource + " to " + sdest);
File dest = new File(sdest);
File source = new File(ssource);
Expand All @@ -186,9 +203,10 @@ public static void copyFile(String ssource, String sdest) throws IOException {
}
}
}

/*
// If targetLocation does not exist, it will be created.
public void copyDirectory(File sourceLocation, File targetLocation) throws IOException {
public void copyDirectory(File sourceLocation, File targetLocation)
throws IOException {
if (sourceLocation.isDirectory()) {
if (!targetLocation.exists()) {
Expand All @@ -197,7 +215,8 @@ public void copyDirectory(File sourceLocation, File targetLocation) throws IOExc
String[] children = sourceLocation.list();
for (int i = 0; i < children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, children[i]));
copyDirectory(new File(sourceLocation, children[i]), new File(
targetLocation, children[i]));
}
} else {
Expand All @@ -213,7 +232,7 @@ public void copyDirectory(File sourceLocation, File targetLocation) throws IOExc
in.close();
out.close();
}
}
}*/

private void refreshProject(final IProject project) {
try {
Expand Down
13 changes: 5 additions & 8 deletions editor/java/mobl/MoblEditorWizardPage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mobl;

import java.util.regex.Pattern;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.imp.preferences.fields.RadioGroupFieldEditor;
Expand Down Expand Up @@ -104,6 +106,7 @@ private void distributeProjectName() {
private void onChange() {
if (!ignoreEvents) {
setErrorMessage(null);
setErrorStatus(null);

if (getInputProjectName().length() == 0) {
setErrorStatus("Project name must be specified");
Expand All @@ -118,8 +121,8 @@ private void onChange() {
setErrorStatus("Project name must be valid");
return;
}
if (!toLanguageName(getInputAppName()).equalsIgnoreCase(getInputAppName())) {
setErrorStatus("Application name must be valid");
if (!getInputAppName().matches("^[a-zA-Z0-9]+$")) {
setErrorStatus("Application name may only contain alphanumeric characters.");
return;
}

Expand All @@ -128,12 +131,6 @@ private void onChange() {
setErrorStatus("A project with this name already exists");
return;
}

if (getInputProjectName().indexOf(' ') != -1) {
setWarningStatus("Project names with spaces may not be supported depending on your configuration");
} else {
setErrorStatus(null);
}
}
}

Expand Down
Binary file modified icons/mobl.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<primaryWizard id="mobl.EditorWizard"/>
<wizard
class="mobl.MoblEditorWizard"
icon="icons/mobl.gif"
icon="icons/mobl.png"
id="mobl.EditorWizard"
name="mobl project"
project="true">
Expand Down
1 change: 0 additions & 1 deletion samples/tipcalculator/tipcalculator.mobl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ screen root() {
item { numField(percentage, label="percentage") }
item { "$" label(Math.round(amount * (1 + percentage/100))) }
}

}
2 changes: 1 addition & 1 deletion stdlib
Submodule stdlib updated 2 files
+1 −1 js/mobl.boot.js
+2 −2 mobl.mobl
13 changes: 7 additions & 6 deletions trans/generation/action.str
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ strategies
; rest := <filter(not(?Entity(_, _, _, _) <+ ?Import(_)))> def*
; to-import := <concat; make-set> [<filter(not(?Import(_))); collect-om(?QId(<id>, _)); filter(not(?qid))> def*, <filter(?Import(<id>))> def*]
; <map(import-to-js)> to-import
; <filter(definition-to-js <+ where(?<id>#(_); not(string-starts-with(|"External"))); not(?MiddlewareUse(_) <+ ?DynamicImport(_) <+ ?Load(_) <+ ?Mixin(_) <+ ?StyleVarDecl(_, _) <+ ?StyleMixin(_, _, _, _) <+ ?Style(_, _, _)); emit-tl-statement)> rest
; <filter(definition-to-js <+ where(?<id>#(_); not(string-starts-with(|"External"))); not(?MiddlewareUse(_) <+ ?DynamicImport(_) <+ ?Load(_) <+ ?Resource(_) <+ ?Mixin(_) <+ ?StyleVarDecl(_, _) <+ ?StyleMixin(_, _, _, _) <+ ?Style(_, _, _)); emit-tl-statement)> rest
; <entities-to-js> entities

strategies

import-to-js :
qid -> <id> //<emit> $[mobl.load('[<qid-to-path> qid].js');
//]
qid -> <id>
where not(ServerContext)

definition-to-js :
Load(path@Path(part*)) -> <id> //<emit> $[mobl.load('[<path-to-string> path]');]
Load(path@Path(part*)) -> <id>
where not(ServerContext)
with path-str := <path-to-string> path
; <cut-off-last-element; separate-by(|"/"); <concat-strings> [<OutputPath>, "/"|<id>]; ensure-existing-dir> part*
where not(OptimizedMode; <string-ends-with(|".js") <+ string-ends-with(|".css")> path-str; not(<string-starts-with(|"http://")> path-str))
with <cut-off-last-element; separate-by(|"/"); <concat-strings> [<OutputPath>, "/"|<id>]; ensure-existing-dir> part*
; <copy-file> (<resolve-file> path-str, $[[<OutputPath>]/[path-str]])
; <refresh-workspace-file> $[[<OutputPath>]/[path-str]]

definition-to-js :
Resource(path@Path(part*)) -> <id>
with path-str := <path-to-string> path
; <cut-off-last-element; separate-by(|"/"); <concat-strings> [<OutputPath>, "/"|<id>]; ensure-existing-dir> part*
where not(OptimizedMode; <string-ends-with(|".js")> path-str; not(<string-starts-with(|"http://")> path-str))
with <cut-off-last-element; separate-by(|"/"); <concat-strings> [<OutputPath>, "/"|<id>]; ensure-existing-dir> part*
; <copy-file> (<resolve-file> path-str, $[[<OutputPath>]/[path-str]])
; <refresh-workspace-file> $[[<OutputPath>]/[path-str]]

Expand Down
12 changes: 9 additions & 3 deletions trans/generation/compile.str
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ strategies
index-html-filename := <concat-strings; guarantee-extension(|"html")> [<OutputPath>, "/", path]
end
; manifest-filename := <concat-strings; guarantee-extension(|"manifest")> [<OutputPath>, "/", path]
; chrome-manifest-filename := <concat-strings> [<OutputPath>, "/manifest.json"])
//; chrome-manifest-filename := <concat-strings> [<OutputPath>, "/manifest.json"]
)
; fp := <fopen> (js-filename, "w")
; <fputs> ($[mobl.provides('[<qid-to-js> qid]');
], fp)
Expand Down Expand Up @@ -97,10 +98,10 @@ strategies
; <fclose> fp3
; <refresh-workspace-file> manifest-filename
end
; fp4 := <fopen <+ debug(!"Could not open file: "); fail> (chrome-manifest-filename, "w")
/*; fp4 := <fopen <+ debug(!"Could not open file: "); fail> (chrome-manifest-filename, "w")
; <fputs> (<generate-chrome-manifest(|<get-all-resources-no-dynamic(|qid)> def*, setting*)> app, fp4)
; <fclose> fp4
; <refresh-workspace-file> chrome-manifest-filename
; <refresh-workspace-file> chrome-manifest-filename*/
)
end
; <refresh-workspace-file> js-filename
Expand Down Expand Up @@ -150,3 +151,8 @@ strategies
qid-to-path :
QId(qid, x) -> $[[qids]/[x]]
with qids := <qid-to-path> qid

strategies // hack

ignoreme = rules ( ProjectPath := "" )

2 changes: 1 addition & 1 deletion trans/generation/html.str
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ strategies
</head>
<body>
<div id="mobl-loading">
Loading... <img src="img/loading.gif"/>
Loading... <img src="data:image/gif;base64,R0lGODlhCgAKAJEDAMzMzP9mZv8AAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAADACwAAAAACgAKAAACF5wncgaAGgJzJ647cWua4sOBFEd62VEAACH5BAUAAAMALAEAAAAIAAMAAAIKnBM2IoMDAFMQFAAh+QQFAAADACwAAAAABgAGAAACDJwHMBGofKIRItJYAAAh+QQFAAADACwAAAEAAwAIAAACChxgOBPBvpYQYxYAIfkEBQAAAwAsAAAEAAYABgAAAgoEhmPJHOGgEGwWACH5BAUAAAMALAEABwAIAAMAAAIKBIYjYhOhRHqpAAAh+QQFAAADACwEAAQABgAGAAACDJwncqi7EQYAA0p6CgAh+QQJAAADACwHAAEAAwAIAAACCpRmoxoxvQAYchQAOw==" width="10" height="10">
<p>(If this message still shows after a few seconds, probably something went wrong. Does your browser support Javascript?)</p>
</div>
<script src="js/jquery-1.4.min.js" type="application/x-javascript" charset="utf-8"></script>
Expand Down
4 changes: 2 additions & 2 deletions trans/optimize/optimize.str
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ rules
; fp2 := <fopen> (index-html-filename, "w")
; <fputs> (<generate-optimized-index-html(|[$[[<qid-to-path> mod-name].js], $[[<qid-to-path> mod-name].css], script-tag-js*, style-tag-css*], setting*)> ast, fp2)
; <fclose> fp2
; <map(<concat-strings> [<OutputPath>, "/", <id>]; remove-file <+ debug(!"Could not remove file: "))> [special-js*, inlinable-css*, inlinable-js*]
//; <map(<concat-strings> [<OutputPath>, "/", <id>]; remove-file <+ debug(!"Could not remove file: "))> [special-js*, inlinable-css*, inlinable-js*]
; <map(refresh-workspace-file)> [js-filename, css-filename, html-filename]
|}

Expand Down Expand Up @@ -106,7 +106,7 @@ rules
</head>
<body>
<div id="mobl-loading">
Loading... <img src="img/loading.gif"/>
Loading... <img src="data:image/gif;base64,R0lGODlhCgAKAJEDAMzMzP9mZv8AAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAADACwAAAAACgAKAAACF5wncgaAGgJzJ647cWua4sOBFEd62VEAACH5BAUAAAMALAEAAAAIAAMAAAIKnBM2IoMDAFMQFAAh+QQFAAADACwAAAAABgAGAAACDJwHMBGofKIRItJYAAAh+QQFAAADACwAAAEAAwAIAAACChxgOBPBvpYQYxYAIfkEBQAAAwAsAAAEAAYABgAAAgoEhmPJHOGgEGwWACH5BAUAAAMALAEABwAIAAMAAAIKBIYjYhOhRHqpAAAh+QQFAAADACwEAAQABgAGAAACDJwncqi7EQYAA0p6CgAh+QQJAAADACwHAAEAAwAIAAACCpRmoxoxvQAYchQAOw==" width="10" height="10">
<p>(If this message still shows after a few seconds, probably something went wrong. Does your browser support Javascript?)</p>
</div>
[<filter(res-to-script-html)> res*]
Expand Down

0 comments on commit 169f140

Please sign in to comment.