无法在GWT(2.7)GWTP(1.5)项目中添加GwtQuery(1.0.6)DragAndDropCellTree

时间:2015-11-21 18:15:32

标签: java gwt gwtp gwtquery

我试图在我的GWTP项目中向MyView.java添加GwtQuery DragAndDropCellTree。但我无法通过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();

样式已成功设置',但其injected字段为false。所以ensureInjected()不会返回(它必须抛出异常)。

我可能在使用TreeViewModel和AbstractCell做错了,我用它来构造我的DragAndDropCellTree ......我不确定。

有关如何解决此问题的任何想法,或其他任何需要研究的内容? 感谢。

编辑:我的pom.xml(请参阅针对底部的DND依赖关系,以及每个DragAndDropPlugin configuration上方的存储库)

<?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'/>

2 个答案:

答案 0 :(得分:3)

查看CellBasedWidgetImplStandard.java的源代码,我可以确切地看到它失败的原因。它传递给DOM.dispatchEvent()的第二个论点是:

Lcom/google/gwt/user/client/Element;

在最新版本的GWT中,该方法的第二个参数是:

Lcom/google/gwt/dom/client/Element;

注意两者之间包名的不同。这是GWT 2.6中的一个变化(如果我没记错的话),所以我认为这里的解决方案是找到DnD库的更新版本。也许这个符合法案:

https://github.com/ArcBees/gwtquery-droppable-plugin

答案 1 :(得分:1)

正如我对@Simon DeWolf的Accepted Answer所做的评论所说,这里有更多关于获取GwtQuery DragAndDropCellTree进行实例化和GWT编译的细节。他的答案说明这个解决方案的必要性超出了我在本课题中的描述。

  • 如果您的GWT项目是Maven项目,这些详细信息适用:它们包括添加JitPack作为Maven存储库以使用gwtquery-droppable-plugin的更新版本(非常简单)
  • 但你可以随时使用准系统方法下载Github源代码,并将其编译成.jar以添加到项目的类路径

    1. 在项目中将gwtquery-droppable-plugin的更新版本设为Maven依赖项。这些指示适用于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>`
  1. 将此添加到.gwt.xml模块文件中:

    <inherits name='gwtquery.plugins.droppable.Droppable'/>
    <!-- to prevent the GWT error [compile error, I think], "IFrame linker is deprecated; consider switching to the xsiframe linker", after making ArcBees' gwtquery-droppable-plugin a Maven dependency (from Github via JitPack) and instantiating a DragAndDropCellTree (in [db0f3c6]). *See https://groups.google.com/forum/#!topic/google-web-toolkit/OiMZA-6oCDc --> <add-linker name="xsiframe" />

  2. 您现在应该可以声明DragAndDropCellTree

  3. 然后要实例化DragAndDropCellTree,我有这些建议可以闯入学习:

    • 我建议关注gwtquery-arcbees-plugin sample
    • 以下可能有点密集,因为除了源注释之外没有文档...我建议首先创建一个本机GWT CellTree(DragAndDropCellTree扩展),然后将其转换为DragAndDropCellTree,以便随后在gwtquery之后更容易转换-arcbees-plugin sample
    • 从CellTree开始,我建议您遵循CellTreeExample.java
    • 中的代码示例#1(GWT CellTree doc