Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinventor/appengine/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@
<arg line="-logLevel INFO"/>
<arg value="-extra"/>
<arg value="${build.extra.dir}"/>
<arg value="-generateJsInteropExports"/>
<arg line="-setProperty local.services=${local.services}"/>
<arg line="-setProperty locale=${locale}" if:set="locale"/>
<arg line="-draftCompile" if:blank="release"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import jsinterop.annotations.JsMethod;

/**
* Main entry point for Ode. Defines the startup UI elements in
* {@link #onModuleLoad()}.
Expand Down Expand Up @@ -317,6 +319,7 @@ public class Ode implements EntryPoint {
*
* @return global Ode instance
*/
@JsMethod
public static Ode getInstance() {
return instance;
}
Expand Down Expand Up @@ -1102,6 +1105,7 @@ public void onWindowClosing(Window.ClosingEvent event) {
*
* @return {@link EditorManager}
*/
@JsMethod
public EditorManager getEditorManager() {
return editorManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;

import jsinterop.annotations.JsMethod;

/**
* Manager class for opened project editors.
*
Expand Down Expand Up @@ -136,6 +138,20 @@ public ProjectEditor getOpenProjectEditor(long projectId) {
return openProjectEditors.get(projectId);
}

/**
* Gets the open project editor of the given project ID.
* Long data type can't be represented in java script
* so this verion takes in string
*
* @param projectId the project ID
* @return the ProjectEditor of the specified project, or null
*/
@JsMethod
public ProjectEditor getOpenProjectEditorFromString(String projectIdStr) {
long projectId = Long.parseLong(projectIdStr);
return openProjectEditors.get(projectId);
}

/**
* Closes the file editors for the specified files, without saving.
* This is used when the files are about to be deleted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import java.util.Set;
import java.util.logging.Logger;

import jsinterop.annotations.JsMethod;

/**
* BlocksEditor is an ancestor of all blocks editors in App Inventor.
*
Expand Down Expand Up @@ -216,6 +218,7 @@ public boolean isLoaded() {
return loadComplete;
}

@JsMethod
public WorkspaceSvg getWorkspace() {
return blocksArea.getWorkspace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ public Map<String, MockComponent> getComponents() {
return map;
}

public Map<String, MockComponent> getComponentsByUUID() {
Map<String, MockComponent> map = Maps.newHashMap();
if (loadComplete) {
populateComponentsMapUUID(root.asMockComponent(), map);
}
return map;
}

@Override
public List<String> getComponentNames() {
return new ArrayList<>(getComponents().keySet());
Expand Down Expand Up @@ -579,6 +587,15 @@ private void populateComponentsMap(MockComponent component, Map<String, MockComp
}
}

private void populateComponentsMapUUID(MockComponent component, Map<String, MockComponent> map) {
EditableProperties properties = component.getProperties();
map.put(properties.getPropertyValue("Uuid"), component);
List<MockComponent> children = component.getChildren();
for (MockComponent child : children) {
populateComponentsMapUUID(child, map);
}
}

protected void onFileLoaded(String content) {
// Set loadCompleted to true.
// From now on, all change events will be taken seriously.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import jsinterop.annotations.JsMethod;

/**
* Abstract superclass for all components in the visual designer.
*
Expand Down Expand Up @@ -661,6 +663,7 @@ public String getPropertyValue(String name) {
* @param name property name
* @param value new property value
*/
@JsMethod
public void changeProperty(String name, String value) {
properties.changePropertyValue(name, value);
}
Expand All @@ -669,6 +672,7 @@ public void changeProperty(String name, String value) {
* Renames the component to {@code newName}.
* @param newName The new name for the component.
*/
@JsMethod
public void rename(String newName) {
String oldName = getPropertyValue(PROPERTY_NAME_NAME);
properties.changePropertyValue(PROPERTY_NAME_NAME, newName);
Expand Down Expand Up @@ -1204,7 +1208,8 @@ public void onRemoved()
{

}


@JsMethod
public void delete() {
this.editor.getProjectEditor().clearLocation(getName());
getRoot().select(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Map;

import jsinterop.annotations.JsMethod;

/**
* Abstract superclass for all container mock components.
*
Expand Down Expand Up @@ -130,9 +132,14 @@ public void collectTypesAndIcons(Map<String, String> typesAndIcons) {
/**
* Adds a new component to the end of this container.
*
* @param component component to be added
* @param component to be added
*/
@JsMethod
public final void addComponent(MockComponent component) {
MockContainer oldParent = component.getContainer();
if (oldParent != null) {
oldParent.removeComponent(component, false); //Does not permanently delete
}
addComponent(component, -1);
}

Expand All @@ -143,6 +150,7 @@ public final void addComponent(MockComponent component) {
* @param beforeVisibleIndex visible-index at which the inserted component will appear,
* or {@code -1} to insert the component at the end
*/
@JsMethod
public final void addVisibleComponent(MockComponent component, int beforeVisibleIndex) {
List<MockComponent> visibleChildren = getShowingVisibleChildren();

Expand All @@ -159,7 +167,10 @@ public final void addVisibleComponent(MockComponent component, int beforeVisible
// Insert before the specified visible component
beforeActualIndex = getChildren().indexOf(visibleChildren.get(beforeVisibleIndex));
}

MockContainer oldParent = component.getContainer();
if (oldParent != null) {
oldParent.removeComponent(component, false);
}
addComponent(component, beforeActualIndex);
}

Expand Down Expand Up @@ -212,6 +223,7 @@ private void addComponent(MockComponent component, int beforeIndex) {
* @param left left margin of the component inside the container
* @param top top margin of the component inside the container
*/
@JsMethod(name = "addComponentAtMargins")
public final void addComponent(MockComponent component, int left, int top) {
List<MockComponent> visibleChildren = getShowingVisibleChildren();

Expand All @@ -223,7 +235,10 @@ public final void addComponent(MockComponent component, int left, int top) {
beforeActualIndex = getChildren().indexOf(visibleChildren.get(visibleChildren.size() - 1))
+ 1;
}

MockContainer oldParent = component.getContainer();
if (oldParent != null) {
oldParent.removeComponent(component, false); //Does not permanently delete
}
component.setContainer(this);
children.add(beforeActualIndex, component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.appinventor.client.editor.simple.ComponentNotFoundException;
import com.google.appinventor.client.editor.simple.SimpleComponentDatabase;
import com.google.appinventor.client.editor.simple.components.MockComponent;
import com.google.appinventor.client.editor.simple.components.MockContainer;
import com.google.appinventor.client.editor.simple.components.MockForm;
import com.google.appinventor.client.editor.simple.palette.AbstractPalettePanel;
import com.google.appinventor.client.editor.simple.palette.DropTargetProvider;
Expand Down Expand Up @@ -49,6 +50,8 @@

import static com.google.appinventor.client.Ode.MESSAGES;

import jsinterop.annotations.JsMethod;

/**
* Editor for Young Android Form (.scm) files.
*
Expand Down Expand Up @@ -530,4 +533,40 @@ public void onKeyDown(KeyDownEvent event) {
}
}

/**
* Gets the mock component of the given UUID.
*
* Note: a little hacky, creating a new component map each time
*
* @param UUID the component UUID
* @return the MockComponent of the specified UUID
*/
@JsMethod
public MockComponent getComponent(String uuid) {
Map<String, MockComponent> componentMap = getComponentsByUUID();
return componentMap.get(uuid);
}

/**
* Converts JSON string to JSON object needed to create component.
*
* @param JSON string of component properties
* @return the JSON object of JSON string
*/
@JsMethod
public JSONObject parseJsonString(String jsonString) {
return JSON_PARSER.parse(jsonString).asObject();
}

/**
* Creates mock component from JSON propeties object.
*
* @param JSON object of component properties
* @return Mock Component with properties in JSON object
*/
@JsMethod
public MockComponent createMockComponentFromJson(JSONObject propertiesObject) {
MockForm rootForm = getForm();
return createMockComponent(propertiesObject, rootForm, MockForm.TYPE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import java.util.Set;
import java.util.logging.Logger;

import jsinterop.annotations.JsMethod;

/**
* Project editor for Young Android projects. Each instance corresponds to
* one project that has been opened in this App Inventor session.
Expand Down Expand Up @@ -430,6 +432,7 @@ else if (node instanceof YoungAndroidBlocksNode) {
/*
* Returns the BlocksEditor for the given form name in this project
*/
@JsMethod
public BlocksEditor<?, ?> getBlocksFileEditor(String formName) {
if (editorMap.containsKey(formName)) {
return editorMap.get(formName).blocksEditor;
Expand All @@ -440,6 +443,7 @@ else if (node instanceof YoungAndroidBlocksNode) {
/*
* Returns the YaFormEditor for the given form name in this project
*/
@JsMethod
public DesignerEditor<?, ?, ?, ?, ?> getFormFileEditor(String formName) {
if (editorMap.containsKey(formName)) {
return editorMap.get(formName).formEditor;
Expand Down
6 changes: 3 additions & 3 deletions appinventor/docs/markdown/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.17.1)
ffi (1.17.2-arm64-darwin)
forwardable-extended (2.6.0)
http_parser.rb (0.8.0)
i18n (0.9.5)
Expand Down Expand Up @@ -60,12 +60,12 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)

PLATFORMS
ruby
arm64-darwin-24

DEPENDENCIES
jekyll (~> 3.8.5)
minima (~> 2.0)
tzinfo-data

BUNDLED WITH
2.4.22
2.4.5