Skip to content

Commit

Permalink
Spreading the script core
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jan 10, 2021
1 parent bc1ad2c commit 91ce131
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions src/main/java/org/luwrain/app/studio/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

public final class App extends AppBase<Strings>
{
static public final String LOG_COMPONENT = "studio";

private final String arg;
private Conversations conv = null;
private ProjectBaseLayout projectBaseLayout = null;
Expand Down Expand Up @@ -73,6 +75,12 @@ private void loadScriptCore() throws IOException
final File[] scripts = scriptsDir.listFiles();
if (scripts == null)
return;
for(File f: scripts)
if (f != null)
{
Log.debug(LOG_COMPONENT, "loading " + f.getAbsolutePath());
scriptCore.load(f);
}
}

/*
Expand Down Expand Up @@ -143,6 +151,10 @@ private boolean runForeground(RunControl runControl)
IDE getIde()
{
return new IDE(){
@Override public ScriptCore getScriptCore()
{
return scriptCore;
}
@Override public void onFoldersUpdate()
{
}
Expand Down Expand Up @@ -266,6 +278,13 @@ Conversations conv()
return projectBaseLayout.getLayout();
}

@Override public boolean onEscape(InputEvent event)
{
NullCheck.notNull(event, "event");
closeApp();
return true;
}

@Override public void closeApp()
{
if (proj != null)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/luwrain/studio/ProjectFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.io.*;

import org.luwrain.core.*;
import org.luwrain.script.*;
import org.luwrain.script.hooks.*;
import org.luwrain.script2.*;
import org.luwrain.script2.hooks.*;
import org.luwrain.util.*;

import org.luwrain.studio.backends.java.JavaProjectLoader;
Expand Down Expand Up @@ -89,7 +89,7 @@ public Project create(String projType, File destDir) throws IOException
NullCheck.notNull(destDir, "destDir");
final Object res;
try {
res = new ProviderHook(luwrain).run(CREATE_HOOK, new Object[]{projType, destDir.getAbsolutePath()});
res = new ProviderHook(ide.getScriptCore()).run(CREATE_HOOK, new Object[]{projType, destDir.getAbsolutePath()});
}
catch(RuntimeException e)
{
Expand All @@ -110,7 +110,7 @@ public ProjectType[] getNewProjectTypes()
{
final Object[] objs;
try {
objs = new CollectorHook(luwrain).runForArrays(TYPES_LIST_HOOK, new Object[0]);
objs = new CollectorHook(ide.getScriptCore()).runForArrays(TYPES_LIST_HOOK, new Object[0]);
}
catch(RuntimeException e)
{
Expand All @@ -126,9 +126,9 @@ public ProjectType[] getNewProjectTypes()
final Object titleObj = ScriptUtils.getMember(o, "title");
if (idObj == null || titleObj == null || orderIndexObj == null)
continue;
final String id = ScriptUtils.getStringValue(idObj);
final Integer orderIndex = ScriptUtils.getIntegerValue(orderIndexObj);
final String title = ScriptUtils.getStringValue(titleObj);
final String id = ScriptUtils.asString(idObj);
final Integer orderIndex = ScriptUtils.asInt(orderIndexObj);
final String title = ScriptUtils.asString(titleObj);
if (id == null || id.isEmpty() ||
orderIndex == null || orderIndex.intValue() < 0 ||
title == null || title.isEmpty())
Expand Down

0 comments on commit 91ce131

Please sign in to comment.