Skip to content

Commit

Permalink
Added basic structure for importing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
meriouma committed Feb 26, 2015
1 parent 0f077fe commit 80c65f4
Show file tree
Hide file tree
Showing 16 changed files with 920 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Package Files #
target/**/*.jar
*.war
*.class

# gwt caches and compiled units #
war/gwt_bree/
gwt-unitCache/
*/.gwt/
*/gen*

# boilerplate generated classes #
.apt_generated/

# more caches and things from deploy #
war/WEB-INF/deploy/
war/WEB-INF/classes/

# maven #
target/

# intellij generated files #
*.iml
*.ipr
*.iws
.idea/
velocity_implicit.vm

# Eclipse generated files #
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
*.ucls
*.checkstyle

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# Mac os specific
.DS_Store

#bower
bower_components

21 changes: 21 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "webapp",
"version": "0.0.0",
"homepage": "https://github.com/ArcBees/gwt-polymer",
"authors": [
"Maxime Mériouma-Caron <maxime.meriouma@arcbees.com>"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"**/test",
"**/tests"
],
"dependencies": {
"polymer": "Polymer/polymer#0.5.5",
"paper-elements": "Polymer/paper-elements#0.5.5"
}
}
51 changes: 51 additions & 0 deletions gwt-polymer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.arcbees</groupId>
<artifactId>gwt-polymer-parent</artifactId>
<version>0.5.5-SNAPSHOT</version>
</parent>

<artifactId>gwt-polymer</artifactId>
<packaging>jar</packaging>
<name>gwt-polymer</name>

<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.vm</include>
</includes>
</resource>
</resources>
</build>

<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-codeserver</artifactId>
</dependency>

<!-- Rebind dependency -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
"https://raw.githubusercontent.com/gwtproject/gwt/2.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.arcbees.gwtpolymer.elements.webcomponentsjs.Webcomponentsjs"/>

<source path="base"/>
<source path="event"/>

<define-configuration-property name="gwtpolymer.elements" is-multi-valued="true"/>
<set-configuration-property name="gwtpolymer.elements" value=""/>

<generate-with class="com.arcbees.gwtpolymer.rebind.ImportsGenerator">
<when-type-is class="com.arcbees.gwtpolymer.base.Imports"/>
</generate-with>
</module>
21 changes: 21 additions & 0 deletions gwt-polymer/src/main/java/com/arcbees/gwtpolymer/base/Imports.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.base;

public interface Imports {
void injectImports();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.event;

import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.shared.EventHandler;

public class AnimatedPagesTransitionEndEvent
extends DomEvent<AnimatedPagesTransitionEndEvent.AnimatedPagesTransitionEndHandler> {
public interface AnimatedPagesTransitionEndHandler extends EventHandler {
void onAnimatedPagesTransitionEnd(AnimatedPagesTransitionEndEvent event);
}

private static final Type<AnimatedPagesTransitionEndHandler> TYPE =
new Type<>(PolymerEvents.ANIMATED_PAGES_TRANSITION_END, new AnimatedPagesTransitionEndEvent());

public static Type<AnimatedPagesTransitionEndHandler> getType() {
return TYPE;
}

@Override
public Type<AnimatedPagesTransitionEndHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(AnimatedPagesTransitionEndHandler handler) {
handler.onAnimatedPagesTransitionEnd(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.event;

import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.shared.EventHandler;

public class MediaChangeEvent extends DomEvent<MediaChangeEvent.MediaChangeHandler> {
public interface MediaChangeHandler extends EventHandler {
void onMediaChange(MediaChangeEvent event);
}

private static final Type<MediaChangeHandler> TYPE =
new Type<>(PolymerEvents.MEDIA_CHANGE, new MediaChangeEvent());

public static Type<MediaChangeHandler> getType() {
return TYPE;
}

public boolean matches() {
return matches(getNativeEvent());
}

@Override
public Type<MediaChangeHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(MediaChangeHandler handler) {
handler.onMediaChange(this);
}

private native boolean matches(NativeEvent nativeEvent) /*-{
return nativeEvent.detail.matches;
}-*/;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.event;

public class PolymerEvents {
public static final String RESPONSIVE_CHANGE = "core-responsive-change";
public static final String MEDIA_CHANGE = "core-media-change";
public static final String ANIMATED_PAGES_TRANSITION_END = "core-animated-pages-transition-end";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.event;

import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.shared.EventHandler;

public class ResponsiveChangeEvent extends DomEvent<ResponsiveChangeEvent.ResponsiveChangeHandler> {
public interface ResponsiveChangeHandler extends EventHandler {
void onResponsiveChange(ResponsiveChangeEvent event);
}

private static final Type<ResponsiveChangeHandler> TYPE =
new Type<>(PolymerEvents.RESPONSIVE_CHANGE, new ResponsiveChangeEvent());

public static Type<ResponsiveChangeHandler> getType() {
return TYPE;
}

@Override
public Type<ResponsiveChangeHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(ResponsiveChangeHandler handler) {
handler.onResponsiveChange(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.arcbees.gwtpolymer.rebind;

import com.arcbees.gwtpolymer.rebind.velocity.ImportsVelocityGenerator;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.inject.Guice;
import com.google.inject.Injector;

public class ImportsGenerator extends Generator {
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
Injector injector = Guice.createInjector(new RebindModule(logger, context));

ImportsVelocityGenerator generator = injector.getInstance(ImportsVelocityGenerator.class);

return generator.generate();
}
}
Loading

0 comments on commit 80c65f4

Please sign in to comment.