01 /*
02 * Copyright 2014-2016 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package griffon.plugins.glazedlists;
17
18 import ca.odell.glazedlists.swing.EventTreeModel
19
20 import javax.swing.event.TreeModelEvent
21 import javax.swing.tree.TreePath
22
23 /**
24 * @author Alexander Klein
25 */
26 class ClosureEventTreeModel extends EventTreeModel {
27 Closure update
28
29 ClosureEventTreeModel(def source, Closure c = null) {
30 super(source)
31 update = c
32 }
33
34 void valueForPathChanged(TreePath path, Object newValue) {
35 if (update) {
36 update.call(path, path.lastPathComponent, newValue)
37 } else {
38 super.valueForPathChanged(path, newValue)
39 }
40 listenerList.each { listener ->
41 listener.treeNodesChanged(new TreeModelEvent(this, path))
42 }
43 }
44 }
|