Skip to content

Commit

Permalink
JavaScript API refactor + jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
lichnost committed May 8, 2019
1 parent be80e74 commit 5590179
Show file tree
Hide file tree
Showing 99 changed files with 1,798 additions and 1,673 deletions.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<module>whirl-selenium</module>
<module>whirl-app</module>
<module>whirl-codemirror</module>
<module>whirl-editor</module>
<module>whirl-jsdoc</module>
<module>whirl-editor</module>
</modules>

<properties>
Expand Down Expand Up @@ -53,6 +53,14 @@
<name>JBoss public</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>nodejs-proxy</id>
<name>NodeJS proxy repository</name>
<url>https://maven-nodejs-proxy.pvtool.org/</url>
</repository>
</repositories>

<build>
Expand Down
5 changes: 0 additions & 5 deletions whirl-app/whirl-app-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
<artifactId>gxt</artifactId>
</dependency>

<dependency>
<groupId>org.timepedia.exporter</groupId>
<artifactId>gwtexporter</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.seanchenxi.gwt</groupId>
<artifactId>gwt-storage</artifactId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.whirlplatform.app.client;

import com.sencha.gxt.widget.core.client.container.Viewport;
import org.timepedia.exporter.client.Export;
import org.whirlplatform.component.client.ComponentBuilder;
import org.whirlplatform.component.client.Containable;

Expand Down Expand Up @@ -49,7 +48,6 @@ public ComponentBuilder[] getChildren() {
}
}

@Export
public int getChildrenCount() {
if (topComponent == null) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.gwt.user.client.Window.ClosingEvent;
import com.google.gwt.user.client.Window.ClosingHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.timepedia.exporter.client.ExporterUtil;
import org.whirlplatform.rpc.client.DataServiceAsync;
import org.whirlplatform.rpc.shared.SessionToken;

Expand Down Expand Up @@ -66,8 +65,4 @@ public static void setRemoveToken(boolean remove) {
removeToken = remove;
}

public static void exportJavaScript() {
ExporterUtil.exportAll();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.whirlplatform.component.client.ComponentBuilder;
import org.whirlplatform.component.client.event.ClickEvent;
Expand All @@ -20,7 +21,7 @@
/**
* Button.
*/
@JsType(namespace = "Whirl", name = "Button")
@JsType(name = "Button")
public class ButtonBuilder extends ComponentBuilder implements ClickEvent.HasClickHandlers {

private TextButton button;
Expand Down Expand Up @@ -119,7 +120,8 @@ public HandlerRegistration addClickHandler(ClickEvent.ClickHandler handler) {
*
* @return title
*/
public String getHTML() {
@JsProperty(name = "html")
public String getHTML() {
return button.getHTML();
}

Expand All @@ -128,7 +130,8 @@ public String getHTML() {
*
* @param html title
*/
public void setHTML(String html) {
@JsProperty(name = "html")
public void setHTML(String html) {
button.setHTML(html == null ? "" : html);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.base;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.check;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.combo;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.date;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -1,80 +1,60 @@
package org.whirlplatform.component.client.event;

import com.google.gwt.core.client.JavaScriptObject;
import org.timepedia.exporter.client.ExporterUtil;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsType;
import org.whirlplatform.component.client.ComponentBuilder;
import org.whirlplatform.meta.shared.JavaScriptEventResult;
import org.whirlplatform.meta.shared.data.DataValue;

import java.util.List;

@JsType(name = "Context")
public class JavaScriptContext {
private ComponentBuilder source;
private List<DataValue> parameters;

public JavaScriptContext() {
}
private ComponentBuilder source;
private List<DataValue> parameters;

@JsIgnore
public JavaScriptContext() {
}

@JsIgnore
public JavaScriptContext(ComponentBuilder source, List<DataValue> parameters) {
this.source = source;
this.parameters = parameters;
}

@JsIgnore
public ComponentBuilder getSource() {
return source;
}

@JsIgnore
public DataValue[] getParameters() {
return parameters.toArray(new DataValue[0]);
}

@JsIgnore
public DataValue getParameter(int index) {
return parameters.get(index);
}

@JsIgnore
public DataValue getParameter(String code) {
if (code == null) {
return null;
}
for (DataValue v : parameters) {
if (code.equals(v.getCode())) {
return v;
}
}
return null;
}

@JsIgnore
public JavaScriptEventResult newResult() {
return new JavaScriptEventResult();
}

public JavaScriptContext(ComponentBuilder source, List<DataValue> parameters) {
this.source = source;
this.parameters = parameters;
}

public ComponentBuilder getSource() {
return source;
}

public DataValue[] getParameters() {
return parameters.toArray(new DataValue[0]);
}

public DataValue getParameter(int index) {
return parameters.get(index);
}

public DataValue getParameter(String code) {
if (code == null) {
return null;
}
for (DataValue v : parameters) {
if (code.equals(v.getCode())) {
return v;
}
}
return null;
}

public JavaScriptEventResult newResult() {
return new JavaScriptEventResult();
}

// @SuppressWarnings("unchecked")
// public static JavaScriptContext init(String context) {
// Map<String, Object> root = XJSONConverter.decodeSimple(context);
//
// JavaScriptContext result = new JavaScriptContext();
// String componentId = (String) root.get("source");
// result.source = BuilderManager.findBuilder(componentId, false);
// result.parameters = new ArrayList<DataValue>();
//
// for (Map<String, String> item : (List<Map<String, String>>) root
// .get("parameters")) {
// DataType type = DataType.valueOf(item.get("type"));
// DataValue value = new DataValue(type);
// value.setCode(item.get("code"));
// value.setValue(DataValue.convertValueFromString(item.get("value"),
// item.get("listTitle"), type));
// result.parameters.add(value);
// }
//
// return result;
// }

public static Object init(Object context) {
return context;
}

public JavaScriptObject asObject() {
return ExporterUtil.wrap(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.event;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.grid;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.whirlplatform.component.client.js;

import com.google.gwt.http.client.UrlBuilder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import jsinterop.annotations.JsType;
import org.whirlplatform.app.client.ClientLoginUtils;
import org.whirlplatform.app.client.LocationManager;
import org.whirlplatform.meta.shared.AppConstant;

/**
* Application level helper methods.
*/
@JsType
public class Application {

/**
* Changes opened application in the current window.
*
* @param appCode application code
*/
public static void setCurrentApplication(String appCode) {
LocationManager.get().setRole(appCode);
LocationManager.get().reload();
}

/**
* Opens application in new browser window with the new session of current user.
*
* @param appCode application code
*/
public static void openApplication(String appCode) {
UrlBuilder url = Location.createUrlBuilder();
url.setParameter(AppConstant.NEW_SESSION, String.valueOf(true));
url.setParameter(AppConstant.APPLICATION_URL, appCode);
Window.open(url.buildString(), "_blank", "");
}

/**
* Logout.
*/
public static void logout() {
ClientLoginUtils.logout();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.whirlplatform.component.client.js;

import jsinterop.annotations.JsType;
import org.whirlplatform.component.client.BuilderManager;
import org.whirlplatform.component.client.ComponentBuilder;
import org.whirlplatform.component.client.Containable;

/**
* This helper class contains static methods to work with application components.
*/
@JsType
public class Components {

/**
* Finds component by code.
*
* @param code component code
* @return component
*/
public static ComponentBuilder findByCode(String code) {
return BuilderManager.findBuilder(code, true);
}

/**
* Finds component by code in the particular container.
*
* @param container
* @param code component code
* @return component
*/
public static ComponentBuilder findByCodeInContainer(
ComponentBuilder container, String code) {
if (container instanceof Containable) {
return BuilderManager
.findBuilder((Containable) container, code, true);
} else {
return null;
}
}

/**
* Returns all application components currently available in application.
*
* @return components array
*/
public static ComponentBuilder[] getAll() {
return BuilderManager.getAllBuilders().toArray(new ComponentBuilder[0]);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client.js;

import jsinterop.annotations.JsPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@JsPackage(namespace = "Whirl")
package org.whirlplatform.component.client;

import jsinterop.annotations.JsPackage;
Loading

0 comments on commit 5590179

Please sign in to comment.