Добавление пользовательского подкласса JSplitPane в SwingBuilder с использованием container () вызывает исключение IllegalArgumentException - PullRequest
2 голосов
/ 16 марта 2012

Я новичок в Groovy и Griffon и в настоящее время немного играюсь с SwingBuilder.Я хотел бы добавить подкласс JSplitPane (который использует тонкий делитель, как описано в http://www.formdev.com/blog/swing-tip-jsplitpane-with-zero-size-divider/).

Ниже вы можете найти скрипт определения представления. Я использовал контейнер () - Элемент для добавления моей Splitpane-подкласс. Когда я запускаю свое приложение, я получаю исключение java.lang.IllegalArgumentException. Любые идеи, как это исправить?


Вид:

frame(id:"frame",
 title: 'The new database explorer implemented with groovy/griffon',
 size: [600, 400],
 locationByPlatform:true,
 iconImage: imageIcon('/griffon-icon-48x48.png').image,
 iconImages: [imageIcon('/griffon-icon-48x48.png').image,
              imageIcon('/griffon-icon-32x32.png').image,
              imageIcon('/griffon-icon-16x16.png').image]) {

   panel (id:'mainPanel',
           opaque:false) {
       borderLayout()
       toolBar(id:'toolBar',
               constraints:NORTH,
               floatable:false,
               opaque: false,
               preferredSize: new Dimension(200,50)) {
           hglue()
           textField(id:'search', "clientPropertyJTextField.variant":"search",
                   maximumSize: new Dimension(150,35),
                   preferredSize: new Dimension(150,35))
       }
       panel(id: 'centerPanel',
               constraints: CENTER,
               opaque: true,
               background: new Color(238, 238, 238)) {
           borderLayout()
           container (new SplitPaneWithThinDivider(),
                      id:'mainSplitPane',
                      constraints: CENTER,
                      dividerLocation: 150
                      ) {
               scrollPane(id:'treeScroller', border:null) {
                   tree(id:'explorerTree',
                           rootVisible: false)
               }
               scrollPane(border:null) {
                   textArea()
               }
           }
       }
   }
}

Исключение:

2012-03-15 06:45:01,778 [AWT-EventQueue-0] ERROR org.codehaus.griffon.runtime.builder.UberBuilder - An error occurred while building at.rehdie.dbexp.main.ExplorerFrameView@59c87031
java.lang.IllegalArgumentException: cannot add to layout: unknown constraint: null
    at java_awt_Container$add.call(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy:54)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy:49)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy:47)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy:31)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:167)
    at at.rehdie.dbexp.main.ExplorerFrameView.run(ExplorerFrameView.groovy:23)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:151)
    at org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:155)
    at org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129)
2012-03-15 06:45:01,781 [main] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception
java.lang.RuntimeException: java.lang.IllegalArgumentException: cannot add to layout: unknown constraint: null
    at griffon.swing.SwingUIThreadHandler.executeSync(SwingUIThreadHandler.java:46)
    at griffon.core.UIThreadManager.executeSync(UIThreadManager.java:247)
    at org.codehaus.griffon.runtime.core.AbstractMVCGroup.buildScriptMember(AbstractMVCGroup.java:127)
    at org.codehaus.griffon.runtime.core.DefaultMVCGroupManager.initializeMembers(DefaultMVCGroupManager.java:230)
    at org.codehaus.griffon.runtime.core.DefaultMVCGroupManager.buildMVCGroup(DefaultMVCGroupManager.java:149)
    at org.codehaus.griffon.runtime.core.AbstractMVCGroupManager.createMVCGroup(AbstractMVCGroupManager.java:238)
    at org.codehaus.griffon.runtime.core.AbstractMVCGroupManager.createMVCGroup(AbstractMVCGroupManager.java:186)
    at org.codehaus.griffon.runtime.core.AbstractGriffonApplication.createMVCGroup(AbstractGriffonApplication.java:499)
    at org.codehaus.griffon.runtime.core.AbstractGriffonApplication.startup(AbstractGriffonApplication.java:313)
    at griffon.swing.AbstractSwingGriffonApplication.realize(AbstractSwingGriffonApplication.java:78)
    at griffon.swing.AbstractSwingGriffonApplication.run(AbstractSwingGriffonApplication.java:132)
    at griffon.swing.SwingApplication.main(SwingApplication.java:36)
Caused by: java.lang.IllegalArgumentException: cannot add to layout: unknown constraint: null
    at java_awt_Container$add.call(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy:54)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy:49)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy:47)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:140)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy:31)
    at at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod(UberInterceptorMetaClass.groovy:96)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent(Unknown Source)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:167)
    at at.rehdie.dbexp.main.ExplorerFrameView.run(ExplorerFrameView.groovy:23)
    at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:151)
    at org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:155)
    at org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129)

Ответы [ 3 ]

2 голосов
/ 16 марта 2012

Дикое, непроверенное предположение, но работает ли:

       widget( new SplitPaneWithThinDivider(),
               id:'mainSplitPane',
               constraints: CENTER,
               dividerLocation: 150,
               leftComponent: scrollPane(id:'treeScroller', border:null) {
                 tree(id:'explorerTree', rootVisible: false )
               },
               rightComponent: scrollPane(border:null) {
                 textArea()
               } )

Работает ли вообще?

0 голосов
/ 17 марта 2012

Спасибо за ваш ответ, версия Тима работает отлично.Я также попробовал следующее:

splitPane (new SplitPaneWithThinDivider(),
           id:'mainSplitPane',
           constraints: CENTER,
           dividerLocation: 150,
           "clientPropertyQuaqua.Tree.style": "sideBar",
           border: null) {

   scrollPane(id:'treeScroller', border:null) {
       tree(id:'explorerTree',
            rootVisible: false)
   },           
   scrollPane(border:null) {
       textArea()
   }           
}

Но таким образом левый компонент разделенной панели всегда был «левой кнопкой» по умолчанию (то же самое было верно, когда я использовал new JSplitPane() вместо new SplitPaneWithThinDivider()).

Когда я изменил его на

splitPane (new SplitPaneWithThinDivider(),
           id:'mainSplitPane',
           constraints: CENTER,
           dividerLocation: 150,
           "clientPropertyQuaqua.Tree.style": "sideBar",
           border: null) {

   scrollPane(id:'treeScroller', border:null) {
       tree(id:'explorerTree',
            rootVisible: false)
   },           
   scrollPane(border:null) {
       textArea()
   }           
}
bean(mainSplitPane, leftComponent: treeScroller)

, это сработало.

0 голосов
/ 16 марта 2012

Пробовал код с Griffon 0.9.5-rc2, но использовал application () вместо frame () и splitPane (), поскольку у меня нет доступа к пользовательскому компоненту SplitPaneWithThinDivider, и он работает. Я предполагаю, что ExplorerFrameView принадлежит к вторичной группе MVC. Вы пытались использовать application () вместо frame ()?

У вас может быть столько узлов application () для View, сколько у этого узла такое же поведение, как и у frame (), но он знает, как обращаться с апплетами.

...