无法在 GWT (2.7) GWTP (1.5) 项目中添加 GwtQuery (1.0.6) DragAndDropCellTree
Can't add a GwtQuery (1.0.6) DragAndDropCellTree in GWT (2.7) GWTP (1.5) project
我正在尝试在我的 GWTP 项目中将 GwtQuery DragAndDropCellTree 添加到 MyView.java。但是我不能用 GWT 编译它:
Tracing compile failure path for type 'com.google.gwt.user.cellview.client.CellBasedWidgetImplStandard'
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplStandard.java'
[ERROR] Line 54: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] Hint: Check that your module inherits 'com.google.gwt.user.User' either directly or indirectly
Tracing compile failure path for type 'com.google.gwt.user.cellview.client.CellBasedWidgetImplTrident'
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplTrident.java'
[ERROR] Line 98: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
...
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImpl.java'
[ERROR] Line 46: Rebind result 'com.google.gwt.user.cellview.client.CellBasedWidgetImplTrident' could not be found
Tracing compile failure path for type 'com.google.gwt.query.client.GQuery'
[ERROR] Errors in 'com/google/gwt/query/client/GQuery.java'
[ERROR] Line 469: The method f(Object[]) is ambiguous for the type Function
如果我尝试在开发模式下导航到 MyView:
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplStandard.java'
[ERROR] Line 54: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
[ERROR] - Member 'null' in JSNI reference '@com.google.gwt.user.client.DOM::null' could not be found; expect subsequent failures
在调试 DragAndDropCellTree 后,我到达了 CellTree 中的第 624-625 行:
this.style = resources.cellTreeStyle();
this.style.ensureInjected();
样式已设置 'successfully',但其 injected
字段为 false
。所以 ensureInjected()
不会 return (它必须抛出异常)。
我可能在构建我的 DragAndDropCellTree 时使用的 TreeViewModel 和 AbstractCell 做错了……我不确定。
关于如何解决这个问题的任何想法,或任何其他需要研究的东西?
谢谢。
编辑:我的 pom.xml(根据 DragAndDropPlugin configuration,请参阅底部的 DND 依赖项以及其正上方的存储库):
<?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>
<groupId>com.priorigram</groupId>
<artifactId>PrioriGram</artifactId>
<version>0</version>
<packaging>war</packaging>
<name>GWTP Basic</name>
<properties>
<!-- client -->
<gwt.version>2.7.0</gwt.version>
<gwtp.version>1.5.1</gwtp.version>
<gin.version>2.1.2</gin.version>
<gwt.style>OBF</gwt.style>
<!-- maven -->
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<target.jdk>1.7</target.jdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
</properties>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java/com/priorigram/client/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- GWT -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<configuration>
<strict>true</strict>
<testTimeOut>180</testTimeOut>
<mode>htmlunit</mode>
<includes>**/*GwtTest.java</includes>
<logLevel>INFO</logLevel>
<runTarget>index.html</runTarget>
<module>com.priorigram.PrioriGram</module>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>plugins</id>
<url>http://gwtquery-plugins.googlecode.com/svn/mavenrepo</url>
</repository>
</repositories>
<dependencies>
<!-- DND -->
<dependency>
<groupId>com.googlecode.gwtquery.bundles</groupId>
<artifactId>gquery-dnd-bundle</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- GWTP -->
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-mvp-client</artifactId>
<version>${gwtp.version}</version>
<scope>provided</scope>
</dependency>
<!-- DI -->
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>${gin.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
编辑:来自我的 .gwt.xml:
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.gwtplatform.mvp.MvpWithEntryPoint"/>
<inherits name='gwtquery.plugins.droppable.Droppable'/>
查看 CellBasedWidgetImplStandard.java
的源代码,我可以准确地了解它失败的原因。它传递给 DOM.dispatchEvent()
的第二个参数是:
Lcom/google/gwt/user/client/Element;
而在最新版本的 GWT 中,该方法的第二个参数是:
Lcom/google/gwt/dom/client/Element;
注意两者包名的区别。这是在 GWT 2.6 中所做的更改(如果我没记错的话),所以我认为这里的解决方案是找到 DnD 库的更新版本。也许这个符合要求:
正如我对@Simon DeWolf 的已接受答案的评论所说,这里有更多关于获取 GwtQuery DragAndDropCellTree 实例化和 GWT 编译的详细信息。除了我在这个问题中描述的尝试之外,他的回答有必要使用此解决方案的原因。
- 如果您的 GWT 项目是 Maven 项目,则这些细节适用:它们包括添加 JitPack as a Maven repository in order to use the updated version of gwtquery-droppable-plugin(非常简单)
但是您始终可以使用准系统方法来下载 Github 源代码,并将其编译成 .jar 以添加到项目的类路径中
- 制作 gwtquery-droppable-plugin a Maven dependency in your project. These directions are for doing that with JitPack 的更新版本。将此添加到您的 pom.xml:
`
<repositories>
<!-- for com.github dependencies (doc @ https://jitpack.io/) -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- GwtQuery - these dependencies must be before gwt dependency (these override/replace some things in gwt) -->
<dependency>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery</artifactId>
<version>1.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Arcbees</groupId>
<artifactId>gwtquery-droppable-plugin</artifactId>
<version>486057e</version>
</dependency>
...
</dependencies>`
将此添加到您的 .gwt.xml 模块文件:
<继承名称='gwtquery.plugins.droppable.Droppable'/><br>
<!-- 防止 GWT 错误 [编译错误,我认为],
"IFrame linker is deprecated; consider switching to the xsiframe linker",
在使 ArcBees 的 gwtquery-droppable-plugin 成为 Maven 依赖项之后(来自 Github 通过 JitPack)
并实例化一个 DragAndDropCellTree(在 [db0f3c6] 中)。
*参见 https://groups.google.com/forum/#!topic/google-web-toolkit/OiMZA-6oCDc -->
<add-linker 名字="xsiframe" />
您现在应该可以声明 DragAndDropCellTree
然后实例化 DragAndDropCellTree,我有这些建议来学习:
- 我建议遵循 gwtquery-arcbees-plugin sample
- 以下内容可能有点密集,因为除了源评论之外没有文档...我建议首先制作一个原生 GWT CellTree(DragAndDropCellTree 扩展),然后将其转换为 DragAndDropCellTree,以便随后在以下内容中更轻松地过渡gwtquery-arcbees-plugin 样本
- 要从 CellTree 开始,我建议遵循代码示例 #1 (CellTreeExample.java) from the GWT CellTree doc
我正在尝试在我的 GWTP 项目中将 GwtQuery DragAndDropCellTree 添加到 MyView.java。但是我不能用 GWT 编译它:
Tracing compile failure path for type 'com.google.gwt.user.cellview.client.CellBasedWidgetImplStandard'
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplStandard.java'
[ERROR] Line 54: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] Hint: Check that your module inherits 'com.google.gwt.user.User' either directly or indirectly
Tracing compile failure path for type 'com.google.gwt.user.cellview.client.CellBasedWidgetImplTrident'
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplTrident.java'
[ERROR] Line 98: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
...
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImpl.java'
[ERROR] Line 46: Rebind result 'com.google.gwt.user.cellview.client.CellBasedWidgetImplTrident' could not be found
Tracing compile failure path for type 'com.google.gwt.query.client.GQuery'
[ERROR] Errors in 'com/google/gwt/query/client/GQuery.java'
[ERROR] Line 469: The method f(Object[]) is ambiguous for the type Function
如果我尝试在开发模式下导航到 MyView:
[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImplStandard.java'
[ERROR] Line 54: Referencing method 'com.google.gwt.user.client.DOM.dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)': unable to resolve method in class 'com.google.gwt.user.client.DOM'
[ERROR] - Member 'null' in JSNI reference '@com.google.gwt.user.client.DOM::null' could not be found; expect subsequent failures
在调试 DragAndDropCellTree 后,我到达了 CellTree 中的第 624-625 行:
this.style = resources.cellTreeStyle();
this.style.ensureInjected();
样式已设置 'successfully',但其 injected
字段为 false
。所以 ensureInjected()
不会 return (它必须抛出异常)。
我可能在构建我的 DragAndDropCellTree 时使用的 TreeViewModel 和 AbstractCell 做错了……我不确定。
关于如何解决这个问题的任何想法,或任何其他需要研究的东西? 谢谢。
编辑:我的 pom.xml(根据 DragAndDropPlugin configuration,请参阅底部的 DND 依赖项以及其正上方的存储库):
<?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>
<groupId>com.priorigram</groupId>
<artifactId>PrioriGram</artifactId>
<version>0</version>
<packaging>war</packaging>
<name>GWTP Basic</name>
<properties>
<!-- client -->
<gwt.version>2.7.0</gwt.version>
<gwtp.version>1.5.1</gwtp.version>
<gin.version>2.1.2</gin.version>
<gwt.style>OBF</gwt.style>
<!-- maven -->
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<target.jdk>1.7</target.jdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
</properties>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java/com/priorigram/client/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- GWT -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<configuration>
<strict>true</strict>
<testTimeOut>180</testTimeOut>
<mode>htmlunit</mode>
<includes>**/*GwtTest.java</includes>
<logLevel>INFO</logLevel>
<runTarget>index.html</runTarget>
<module>com.priorigram.PrioriGram</module>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>plugins</id>
<url>http://gwtquery-plugins.googlecode.com/svn/mavenrepo</url>
</repository>
</repositories>
<dependencies>
<!-- DND -->
<dependency>
<groupId>com.googlecode.gwtquery.bundles</groupId>
<artifactId>gquery-dnd-bundle</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- GWTP -->
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-mvp-client</artifactId>
<version>${gwtp.version}</version>
<scope>provided</scope>
</dependency>
<!-- DI -->
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>${gin.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
编辑:来自我的 .gwt.xml:
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.gwtplatform.mvp.MvpWithEntryPoint"/>
<inherits name='gwtquery.plugins.droppable.Droppable'/>
查看 CellBasedWidgetImplStandard.java
的源代码,我可以准确地了解它失败的原因。它传递给 DOM.dispatchEvent()
的第二个参数是:
Lcom/google/gwt/user/client/Element;
而在最新版本的 GWT 中,该方法的第二个参数是:
Lcom/google/gwt/dom/client/Element;
注意两者包名的区别。这是在 GWT 2.6 中所做的更改(如果我没记错的话),所以我认为这里的解决方案是找到 DnD 库的更新版本。也许这个符合要求:
正如我对@Simon DeWolf 的已接受答案的评论所说,这里有更多关于获取 GwtQuery DragAndDropCellTree 实例化和 GWT 编译的详细信息。除了我在这个问题中描述的尝试之外,他的回答有必要使用此解决方案的原因。
- 如果您的 GWT 项目是 Maven 项目,则这些细节适用:它们包括添加 JitPack as a Maven repository in order to use the updated version of gwtquery-droppable-plugin(非常简单)
但是您始终可以使用准系统方法来下载 Github 源代码,并将其编译成 .jar 以添加到项目的类路径中
- 制作 gwtquery-droppable-plugin a Maven dependency in your project. These directions are for doing that with JitPack 的更新版本。将此添加到您的 pom.xml:
`
<repositories>
<!-- for com.github dependencies (doc @ https://jitpack.io/) -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- GwtQuery - these dependencies must be before gwt dependency (these override/replace some things in gwt) -->
<dependency>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery</artifactId>
<version>1.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Arcbees</groupId>
<artifactId>gwtquery-droppable-plugin</artifactId>
<version>486057e</version>
</dependency>
...
</dependencies>`
将此添加到您的 .gwt.xml 模块文件:
<继承名称='gwtquery.plugins.droppable.Droppable'/><br> <!-- 防止 GWT 错误 [编译错误,我认为], "IFrame linker is deprecated; consider switching to the xsiframe linker", 在使 ArcBees 的 gwtquery-droppable-plugin 成为 Maven 依赖项之后(来自 Github 通过 JitPack) 并实例化一个 DragAndDropCellTree(在 [db0f3c6] 中)。 *参见 https://groups.google.com/forum/#!topic/google-web-toolkit/OiMZA-6oCDc --> <add-linker 名字="xsiframe" />
您现在应该可以声明 DragAndDropCellTree
然后实例化 DragAndDropCellTree,我有这些建议来学习:
- 我建议遵循 gwtquery-arcbees-plugin sample
- 以下内容可能有点密集,因为除了源评论之外没有文档...我建议首先制作一个原生 GWT CellTree(DragAndDropCellTree 扩展),然后将其转换为 DragAndDropCellTree,以便随后在以下内容中更轻松地过渡gwtquery-arcbees-plugin 样本
- 要从 CellTree 开始,我建议遵循代码示例 #1 (CellTreeExample.java) from the GWT CellTree doc