Skip to content

Commit

Permalink
Version 0.0.6 Fix series<XXX> event issue + change events naming issue
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
ronanquillevere committed Jun 3, 2015
1 parent ac95f26 commit 227aca1
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.highcharts4gwt</groupId>
<artifactId>generator</artifactId>
<version>0.0.4</version>
<version>0.0.1</version>
<name>highcharts4gwt</name>
<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,31 @@ else if (context.equals(""))
public static String getEventNamePrefix(Option option)
{
// plotOptions.gauge.events.afterAnimate
String fullname = option.getFullname();

int i = fullname.indexOf(".events");

// plotOptions.gauge
String v1 = fullname.substring(0, i);

// gauge
int i2 = v1.lastIndexOf(".");
String v2 = "";
if (i2 != -1)
{
v2 = v1.substring(i2 + 1, v1.length());
v2 = v2.substring(0, 1).toUpperCase() + v2.substring(1);
}
else
{
v2 = v1.substring(0, 1).toUpperCase() + v1.substring(1);
}

// GaugeClickEvent
String eventName = v2 + option.getTitle().substring(0, 1).toUpperCase() + option.getTitle().substring(1);
eventName = removeLtGt(eventName, true);
String eventName = option.getTitle();
eventName = eventName.substring(0, 1).toUpperCase() + eventName.substring(1);
// String fullname = option.getFullname();
//
// int i = fullname.indexOf(".events");
//
// // plotOptions.gauge
// String v1 = fullname.substring(0, i);
//
// // gauge
// int i2 = v1.lastIndexOf(".");
// String v2 = "";
// if (i2 != -1)
// {
// v2 = v1.substring(i2 + 1, v1.length());
// v2 = v2.substring(0, 1).toUpperCase() + v2.substring(1);
// }
// else
// {
// v2 = v1.substring(0, 1).toUpperCase() + v1.substring(1);
// }
//
// // GaugeClickEvent
// String eventName = v2 + option.getTitle().substring(0, 1).toUpperCase() + option.getTitle().substring(1);
// eventName = removeLtGt(eventName, true);
return eventName;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.github.highcharts4gwt.generator.option.field;

import javax.annotation.CheckForNull;

import com.github.highcharts4gwt.generator.common.OutputTypeVisitor;
import com.github.highcharts4gwt.generator.option.Option;
import com.sun.codemodel.JDefinedClass;

public class FieldFunctionWriter extends AbstractFieldWriter implements OutputTypeVisitor<Object, Void>
{

private Option option;

public FieldFunctionWriter(JDefinedClass jClass, Option option, boolean pipe, String fieldName)
{
super(jClass, pipe, fieldName, option.getDescription());
this.option = option;
}

@Override
@CheckForNull
public Void visitInterface(Object in)
{
// TODO Auto-generated method stub
return null;
}

@Override
@CheckForNull
public Void visitJso(Object in)
{
// TODO Auto-generated method stub
return null;
}

@Override
@CheckForNull
public Void visitMock(Object in)
{
// TODO Auto-generated method stub
return null;
}

@Override
protected String getNameExtension()
{
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public Void visitArrayJsonObject(OutputType in)
@Override
public Void visitFunction(OutputType in)
{
// TODO support function
return null;
return in.accept(new FieldFunctionWriter(jClass, option, pipe, fieldName), null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,19 @@ private static String getJsniEventHandler(String eventName, String handlerMethod
{
String paramName = "this";

return "\n " + "/*-{" + "\n " + "$wnd.jQuery.extend(true, " + paramName + ", " + "\n " + "{" + "\n "
+ "events: {" + "\n " + eventName + ": function(event) {" + "\n " + "handler.@" + handlerClassFqn
+ "::" + handlerMethodName + "(L" + eventTypeFqn + ";)(" + "\n " + "$wnd.jQuery.extend(true, event, {source:this})"
+ "\n " + ");" + "\n " + "}" + "\n " + "}" + "\n " + "});"
+ "\n " + "}-*/;";
return "\n "
+ "/*-{" + "\n"
+" "+ "$wnd.jQuery.extend(true, " + paramName + ", " + "\n"
+ " "+ "{" + "\n"
+" "+ "events: {" + "\n"
+" " + eventName + ": function(event) {" + "\n"
+" "+ "handler.@" + handlerClassFqn+ "::" + handlerMethodName + "(L" + eventTypeFqn + ";)(" + "\n"
+" "+ "$wnd.jQuery.extend(true, event, {source:this})"
+ "\n"+" " + ");"
+ "\n"+" " + "}"
+ "\n"+" " + "}"
+ "\n"+" " + "});"
+ "\n"+" " + "}-*/;";
}

public static void createEventJso(Option option, String packageName, String rootDirectoryPathName)
Expand Down Expand Up @@ -287,9 +295,9 @@ private static String computeEventName(JClass handlerClass)
{
JMethod method = ((JDefinedClass) handlerClass).methods().iterator().next();
String eventName = method.name().substring(2);
eventName = eventName.substring(0, 1).toLowerCase() + eventName.substring(1);
int iCap = firstIndexOfUcl(eventName);
eventName = eventName.substring(iCap);
// eventName = eventName.substring(0, 1).toLowerCase() + eventName.substring(1);
// int iCap = firstIndexOfUcl(eventName);
// eventName = iCap > -1 ? eventName.substring(iCap) : eventName;
eventName = eventName.substring(0, 1).toLowerCase() + eventName.substring(1);
return eventName;
}
Expand Down

0 comments on commit 227aca1

Please sign in to comment.