diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/build/classes/org/netbeans/modules/viewmodel2/Bundle.properties spi.viewmodel/build/classes/org/netbeans/modules/viewmodel2/Bundle.properties --- /home/enrico/Lavoro/releases/spi.viewmodel/build/classes/org/netbeans/modules/viewmodel2/Bundle.properties 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/build/classes/org/netbeans/modules/viewmodel2/Bundle.properties 2016-11-03 07:23:29.830689299 +0100 @@ -0,0 +1,49 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +OpenIDE-Module-Name=TreeTableView Model (Streamsim) +OpenIDE-Module-Display-Category=Infrastructure +OpenIDE-Module-Short-Description=TreeTableView Model +OpenIDE-Module-Long-Description=TreeTableView Model + +EvaluatingProp=Evaluating... +WaitNode=Please wait... diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/build/no-license.txt spi.viewmodel/build/no-license.txt --- /home/enrico/Lavoro/releases/spi.viewmodel/build/no-license.txt 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/build/no-license.txt 2016-11-03 07:23:29.831689309 +0100 @@ -0,0 +1 @@ +[NO LICENSE SPECIFIED] \ Manca newline alla fine del file diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample1.java spi.viewmodel/examples/TreeModelExample1.java --- /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample1.java 2016-02-04 02:55:43.068100098 +0100 +++ spi.viewmodel/examples/TreeModelExample1.java 2016-11-03 07:23:29.832689319 +0100 @@ -1,47 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - import java.io.File; import java.util.ArrayList; import javax.swing.JComponent; @@ -51,38 +7,43 @@ import org.netbeans.spi.viewmodel.TreeModelListener; public class TreeModelExample1 implements TreeModel { - - public Object[] getChildren (Object parent, int from, int to) { - if (parent == ROOT) - return File.listRoots (); - return ((File) parent).listFiles (); + + public Object[] getChildren(Object parent, int from, int to) { + if (parent == ROOT) { + return File.listRoots(); + } + return ((File) parent).listFiles(); } - - public Object getRoot () { + + public Object getRoot() { return ROOT; } - - public boolean isLeaf (Object node) { - if (node == ROOT) + + public boolean isLeaf(Object node) { + if (node == ROOT) { return false; - return ((File) node).isFile (); + } + return ((File) node).isFile(); } - - public void addTreeModelListener (TreeModelListener l) {} - public void removeTreeModelListener (TreeModelListener l) {} - - public static void main (String[] args) { - TreeModelExample1 tme = new TreeModelExample1 (); - JComponent ttv = Models.createView ( - tme, // TreeModel - null, // NodeModel - null, // TableModel - null, // NodeActionsProvider - new ArrayList () // list of ColumnModels + + public void addTreeModelListener(TreeModelListener l) { + } + + public void removeTreeModelListener(TreeModelListener l) { + } + + public static void main(String[] args) { + TreeModelExample1 tme = new TreeModelExample1(); + JComponent ttv = Models.createView( + tme, // TreeModel + null, // NodeModel + null, // TableModel + null, // NodeActionsProvider + new ArrayList() // list of ColumnModels ); - JFrame f = new JFrame ("Tree Model Example 1"); - f.getContentPane ().add (ttv); - f.pack (); - f.show (); + JFrame f = new JFrame("Tree Model Example 1"); + f.getContentPane().add(ttv); + f.pack(); + f.show(); } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample2.java spi.viewmodel/examples/TreeModelExample2.java --- /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample2.java 2016-02-04 02:55:43.069100098 +0100 +++ spi.viewmodel/examples/TreeModelExample2.java 2016-11-03 07:23:29.832689319 +0100 @@ -1,47 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - import java.awt.event.ActionEvent; import java.io.File; import java.net.MalformedURLException; @@ -57,58 +13,72 @@ import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.TreeModelListener; +public class TreeModelExample2 implements TreeModel, NodeModel { -public class TreeModelExample2 implements TreeModel, NodeModel { - - public Object[] getChildren (Object parent, int from, int to) { - if (parent == ROOT) - return File.listRoots (); - return ((File) parent).listFiles (); + public Object[] getChildren(Object parent, int from, int to) { + if (parent == ROOT) { + return File.listRoots(); + } + return ((File) parent).listFiles(); } - - public Object getRoot () { + + public Object getRoot() { return ROOT; } - - public boolean isLeaf (Object node) { - if (node == ROOT) + + public boolean isLeaf(Object node) { + if (node == ROOT) { return false; - return ((File) node).isFile (); + } + return ((File) node).isFile(); + } + + public void addTreeModelListener(TreeModelListener l) { + } + + public void removeTreeModelListener(TreeModelListener l) { } - - public void addTreeModelListener (TreeModelListener l) {} - public void removeTreeModelListener (TreeModelListener l) {} - - public String getDisplayName (Object node) { - if (node == ROOT) return "Name"; - String name = ((File) node).getName (); - if (name.length () < 1) return ((File) node).getAbsolutePath (); + + public String getDisplayName(Object node) { + if (node == ROOT) { + return "Name"; + } + String name = ((File) node).getName(); + if (name.length() < 1) { + return ((File) node).getAbsolutePath(); + } return name; } - - public String getIconBase (Object node) { - if (node == ROOT) return "folder"; - if (((File) node).isDirectory ()) return "folder"; + + public String getIconBase(Object node) { + if (node == ROOT) { + return "folder"; + } + if (((File) node).isDirectory()) { + return "folder"; + } return "file"; } - - public String getShortDescription (Object node) { - if (node == ROOT) return "Name"; - return ((File) node).getAbsolutePath (); - } - - public static void main (String[] args) { - TreeModelExample2 tme = new TreeModelExample2 (); - JComponent ttv = Models.createView ( - tme, // TreeModel - tme, // NodeModel - null, // TableModel - null, // NodeActionsProvider - new ArrayList () // list of ColumnModels + + public String getShortDescription(Object node) { + if (node == ROOT) { + return "Name"; + } + return ((File) node).getAbsolutePath(); + } + + public static void main(String[] args) { + TreeModelExample2 tme = new TreeModelExample2(); + JComponent ttv = Models.createView( + tme, // TreeModel + tme, // NodeModel + null, // TableModel + null, // NodeActionsProvider + new ArrayList() // list of ColumnModels ); - JFrame f = new JFrame ("Tree Model Example 2"); - f.getContentPane ().add (ttv); - f.pack (); - f.show (); - } + JFrame f = new JFrame("Tree Model Example 2"); + f.getContentPane().add(ttv); + f.pack(); + f.show(); + } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample3.java spi.viewmodel/examples/TreeModelExample3.java --- /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample3.java 2016-02-04 02:55:43.070100098 +0100 +++ spi.viewmodel/examples/TreeModelExample3.java 2016-11-03 07:23:29.831689309 +0100 @@ -1,47 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - import java.awt.event.ActionEvent; import java.io.File; import java.net.MalformedURLException; @@ -58,83 +14,98 @@ import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.TreeModelListener; -public class TreeModelExample3 implements TreeModel, NodeModel, NodeActionsProvider { - - public Object[] getChildren (Object parent, int from, int to) { - if (parent == ROOT) - return File.listRoots (); - return ((File) parent).listFiles (); +public class TreeModelExample3 implements TreeModel, NodeModel, NodeActionsProvider { + + public Object[] getChildren(Object parent, int from, int to) { + if (parent == ROOT) { + return File.listRoots(); + } + return ((File) parent).listFiles(); } - - public Object getRoot () { + + public Object getRoot() { return ROOT; } - - public boolean isLeaf (Object node) { - if (node == ROOT) + + public boolean isLeaf(Object node) { + if (node == ROOT) { return false; - return ((File) node).isFile (); + } + return ((File) node).isFile(); } - - public void addTreeModelListener (TreeModelListener l) {} - public void removeTreeModelListener (TreeModelListener l) {} - - public String getDisplayName (Object node) { - if (node == ROOT) return "Name"; - String name = ((File) node).getName (); - if (name.length () < 1) return ((File) node).getAbsolutePath (); + + public void addTreeModelListener(TreeModelListener l) { + } + + public void removeTreeModelListener(TreeModelListener l) { + } + + public String getDisplayName(Object node) { + if (node == ROOT) { + return "Name"; + } + String name = ((File) node).getName(); + if (name.length() < 1) { + return ((File) node).getAbsolutePath(); + } return name; } - - public String getIconBase (Object node) { - if (node == ROOT) return "folder"; - if (((File) node).isDirectory ()) return "folder"; + + public String getIconBase(Object node) { + if (node == ROOT) { + return "folder"; + } + if (((File) node).isDirectory()) { + return "folder"; + } return "file"; } - - public String getShortDescription (Object node) { - if (node == ROOT) return "Name"; - return ((File) node).getAbsolutePath (); - } - - public Action[] getActions (final Object node) { - return new Action [] { - new AbstractAction ("Open") { - public void actionPerformed (ActionEvent e) { - performDefaultAction (node); + + public String getShortDescription(Object node) { + if (node == ROOT) { + return "Name"; + } + return ((File) node).getAbsolutePath(); + } + + public Action[] getActions(final Object node) { + return new Action[]{ + new AbstractAction("Open") { + public void actionPerformed(ActionEvent e) { + performDefaultAction(node); } }, - new AbstractAction ("Delete") { - public void actionPerformed (ActionEvent e) { - ((File) node).delete (); + new AbstractAction("Delete") { + public void actionPerformed(ActionEvent e) { + ((File) node).delete(); } } }; } - - public void performDefaultAction (Object node) { + + public void performDefaultAction(Object node) { try { - JFrame f = new JFrame ("View"); - f.getContentPane ().add (new JEditorPane (((File) node).toURL ())); - f.pack (); - f.show (); + JFrame f = new JFrame("View"); + f.getContentPane().add(new JEditorPane(((File) node).toURL())); + f.pack(); + f.show(); } catch (Exception e) { e.printStackTrace(); } } - - public static void main (String[] args) { - TreeModelExample3 tme = new TreeModelExample3 (); - JComponent ttv = Models.createView ( - tme, // TreeModel - tme, // NodeModel - null, // TableModel - tme, // NodeActionsProvider - new ArrayList () // list of ColumnModels + + public static void main(String[] args) { + TreeModelExample3 tme = new TreeModelExample3(); + JComponent ttv = Models.createView( + tme, // TreeModel + tme, // NodeModel + null, // TableModel + tme, // NodeActionsProvider + new ArrayList() // list of ColumnModels ); - JFrame f = new JFrame ("Tree Model Example 3"); - f.getContentPane ().add (ttv); - f.pack (); - f.show (); - } + JFrame f = new JFrame("Tree Model Example 3"); + f.getContentPane().add(ttv); + f.pack(); + f.show(); + } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample4.java spi.viewmodel/examples/TreeModelExample4.java --- /home/enrico/Lavoro/releases/spi.viewmodel/examples/TreeModelExample4.java 2016-02-04 02:55:43.070100098 +0100 +++ spi.viewmodel/examples/TreeModelExample4.java 2016-11-03 07:23:29.831689309 +0100 @@ -1,181 +1,154 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - +import com.streamsim.commonsgui.viewmodel.DefaultColumnModel; import java.awt.event.ActionEvent; import java.io.File; import java.io.FileInputStream; -import java.net.MalformedURLException; import java.util.ArrayList; -import java.util.Date; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JComponent; -import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JFrame; - import org.netbeans.spi.viewmodel.Models; -import org.netbeans.spi.viewmodel.ColumnModel; import org.netbeans.spi.viewmodel.NodeActionsProvider; import org.netbeans.spi.viewmodel.NodeModel; import org.netbeans.spi.viewmodel.TableModel; import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.TreeModelListener; +public class TreeModelExample4 implements TreeModel, NodeModel, + NodeActionsProvider, TableModel { -public class TreeModelExample4 implements TreeModel, NodeModel, -NodeActionsProvider, TableModel { - - public Object[] getChildren (Object parent, int from, int to) { - if (parent == ROOT) - return File.listRoots (); - return ((File) parent).listFiles (); + public Object[] getChildren(Object parent, int from, int to) { + if (parent == ROOT) { + return File.listRoots(); + } + return ((File) parent).listFiles(); } - - public Object getRoot () { + + public Object getRoot() { return ROOT; } - - public boolean isLeaf (Object node) { - if (node == ROOT) + + public boolean isLeaf(Object node) { + if (node == ROOT) { return false; - return ((File) node).isFile (); + } + return ((File) node).isFile(); + } + + public void addTreeModelListener(TreeModelListener l) { } - - public void addTreeModelListener (TreeModelListener l) {} - public void removeTreeModelListener (TreeModelListener l) {} - - public String getDisplayName (Object node) { - if (node == ROOT) return "Name"; - String name = ((File) node).getName (); - if (name.length () < 1) return ((File) node).getAbsolutePath (); + + public void removeTreeModelListener(TreeModelListener l) { + } + + public String getDisplayName(Object node) { + if (node == ROOT) { + return "Name"; + } + String name = ((File) node).getName(); + if (name.length() < 1) { + return ((File) node).getAbsolutePath(); + } return name; } - - public String getIconBase (Object node) { - if (node == ROOT) return "folder"; - if (((File) node).isDirectory ()) return "folder"; + + public String getIconBase(Object node) { + if (node == ROOT) { + return "folder"; + } + if (((File) node).isDirectory()) { + return "folder"; + } return "file"; } - - public String getShortDescription (Object node) { - if (node == ROOT) return "Name"; - return ((File) node).getAbsolutePath (); - } - - public Action[] getActions (final Object node) { - return new Action [] { - new AbstractAction ("Open") { - public void actionPerformed (ActionEvent e) { - performDefaultAction (node); + + public String getShortDescription(Object node) { + if (node == ROOT) { + return "Name"; + } + return ((File) node).getAbsolutePath(); + } + + public Action[] getActions(final Object node) { + return new Action[]{ + new AbstractAction("Open") { + public void actionPerformed(ActionEvent e) { + performDefaultAction(node); } }, - new AbstractAction ("Delete") { - public void actionPerformed (ActionEvent e) { - ((File) node).delete (); + new AbstractAction("Delete") { + public void actionPerformed(ActionEvent e) { + ((File) node).delete(); } } }; } - - public void performDefaultAction (Object node) { + + public void performDefaultAction(Object node) { try { - JFrame f = new JFrame ("View"); - f.getContentPane ().add (new JEditorPane (((File) node).toURL ())); - f.pack (); - f.show (); + JFrame f = new JFrame("View"); + f.getContentPane().add(new JEditorPane(((File) node).toURL())); + f.pack(); + f.show(); } catch (Exception e) { e.printStackTrace(); } } - - public Object getValueAt (Object row, String columnID) { + + public Object getValueAt(Object row, String columnID) { try { - if (row == ROOT) return null; - if (columnID.equals ("sizeID")) { - if (((File) row).isDirectory ()) return ""; - return "" + new FileInputStream ((File) row).getChannel ().size (); + if (row == ROOT) { + return null; + } + if (columnID.equals("sizeID")) { + if (((File) row).isDirectory()) { + return ""; + } + return "" + new FileInputStream((File) row).getChannel().size(); } } catch (Exception e) { - e.printStackTrace (); + e.printStackTrace(); } return ""; } - - public boolean isReadOnly (Object row, String columnID) { + + public boolean isReadOnly(Object row, String columnID) { return true; } - - public void setValueAt (Object row, String columnID, Object value) { + + public void setValueAt(Object row, String columnID, Object value) { } - - public static void main (String[] args) { - TreeModelExample4 tme = new TreeModelExample4 (); - ArrayList columns = new ArrayList (); - columns.add (new ColumnModel () { - public String getID () { + + public static void main(String[] args) { + TreeModelExample4 tme = new TreeModelExample4(); + ArrayList columns = new ArrayList(); + columns.add(new DefaultColumnModel() { + @Override + public String getID() { return "sizeID"; } - public String getDisplayName () { + @Override + public String getDisplayName() { return "size"; } - public Class getType () { + @Override + public Class getType() { return String.class; } }); - JComponent ttv = Models.createView ( - tme, // TreeModel - tme, // NodeModel - tme, // TableModel - tme, // NodeActionsProvider - columns // list of ColumnModels + JComponent ttv = Models.createView( + tme, // TreeModel + tme, // NodeModel + tme, // TableModel + tme, // NodeActionsProvider + columns // list of ColumnModels ); - JFrame f = new JFrame ("Tree Model Example 4"); - f.getContentPane ().add (ttv); - f.pack (); - f.show (); - } + JFrame f = new JFrame("Tree Model Example 4"); + f.getContentPane().add(ttv); + f.pack(); + f.show(); + } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/AsynchronousModel.java spi.viewmodel/src/org/netbeans/modules/viewmodel/AsynchronousModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/AsynchronousModel.java 2016-02-04 02:55:43.073100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/AsynchronousModel.java 2016-11-03 07:23:29.835689349 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.concurrent.Executor; @@ -47,21 +46,22 @@ import org.netbeans.spi.viewmodel.UnknownTypeException; /** - * Not in public API, AsynchronousModelFilter is sufficient, since we have a default. + * Not in public API, AsynchronousModelFilter is sufficient, since we have a + * default. * * @author Martin Entlicher */ public interface AsynchronousModel { /** - * Provide the threading information for view models method calls. - * The returned Executor is used to call methods identified by - * {@link CALL} enum. + * Provide the threading information for view models method calls. The + * returned Executor is used to call methods identified by {@link CALL} + * enum. * * @param asynchCall Identification of the method call * @param node Object node * @return an instance of Executor */ Executor asynchronous(CALL asynchCall, Object node) throws UnknownTypeException; - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/Bundle.properties spi.viewmodel/src/org/netbeans/modules/viewmodel/Bundle.properties --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/Bundle.properties 2016-02-04 02:55:43.074100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/Bundle.properties 2016-11-03 07:23:29.835689349 +0100 @@ -40,10 +40,10 @@ # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. -OpenIDE-Module-Name=TreeTableView Model +OpenIDE-Module-Name=TreeTableView Model (Streamsim) OpenIDE-Module-Display-Category=Infrastructure OpenIDE-Module-Short-Description=TreeTableView Model -OpenIDE-Module-Long-Description=TreeTableView Model. For the list of included fixed bugs please check http://wiki.netbeans.org/NetBeans8.1PatchesInfo. +OpenIDE-Module-Long-Description=TreeTableView Model EvaluatingProp=Evaluating... WaitNode=Please wait... diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/Column.java spi.viewmodel/src/org/netbeans/modules/viewmodel/Column.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/Column.java 2016-02-04 02:55:43.074100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/Column.java 2016-11-03 07:23:29.834689339 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.beans.PropertyEditor; @@ -61,31 +60,32 @@ public static final String PROP_ORDER_NUMBER = "OrderNumberOutline"; // NOI18N - private PropertyEditor propertyEditor; - private ColumnModel columnModel; + private final PropertyEditor propertyEditor; + private final ColumnModel columnModel; Column ( ColumnModel columnModel ) { super ( columnModel.getID (), - columnModel.getType () == null ? - String.class : - columnModel.getType (), + columnModel.getType() == null + ? String.class + : columnModel.getType(), Actions.cutAmpersand(columnModel.getDisplayName ()), columnModel.getShortDescription () ); this.columnModel = columnModel; setValue ( "SortableColumn", - Boolean.valueOf (columnModel.isSortable ()) + columnModel.isSortable() ); - if (columnModel.getType () == null) - // Default column! + if (columnModel.getType() == null) // Default column! + { setValue ( "TreeColumnTTV", Boolean.TRUE ); + } if (Mnemonics.findMnemonicAmpersand(columnModel.getDisplayName()) >= 0) { setValue("ColumnDisplayNameWithMnemonicTTV", columnModel.getDisplayName ()); // NOI18N } @@ -106,8 +106,10 @@ int getOrderNumber () { Object o = getValue ("OrderNumberTTV"); - if (o == null) return -1; - return ((Integer) o).intValue (); + if (o == null) { + return -1; + } + return ((Integer) o); } int getModelOrderNumber() { @@ -128,45 +130,49 @@ columnModel.setVisible(!hidden); } + @Override public Object getValue () { return null; } + @Override public void setValue (Object obj) { } + @Override public Object getValue (String propertyName) { if (PROP_ORDER_NUMBER.equals (propertyName)) { int index = columnModel.getCurrentOrderNumber(); - return new Integer(index); + return index; + } + if ("InvisibleInTreeTableView".equals(propertyName)) { + return !columnModel.isVisible(); } - if ("InvisibleInTreeTableView".equals (propertyName)) - return Boolean.valueOf (!columnModel.isVisible ()); if ("SortableColumn".equals (propertyName)) { - return Boolean.valueOf (columnModel.isSortable()); + return columnModel.isSortable(); + } + if ("DescendingOrderTTV".equals(propertyName)) { + return columnModel.isSortedDescending(); } - if ("DescendingOrderTTV".equals (propertyName)) - return Boolean.valueOf (columnModel.isSortedDescending ()); return super.getValue (propertyName); } + @Override public void setValue (String propertyName, Object newValue) { if (PROP_ORDER_NUMBER.equals (propertyName)) { - int index = ((Integer) newValue).intValue(); + int index = ((Integer) newValue); columnModel.setCurrentOrderNumber(index); - } else - /*if ("SortableColumn".equals (propertyName)) + } else /*if ("SortableColumn".equals (propertyName)) columnModel.setSorted ( ((Boolean) newValue).booleanValue () ); - else*/ - if ("DescendingOrderTTV".equals (propertyName)) + else*/ if ("DescendingOrderTTV".equals(propertyName)) { columnModel.setSortedDescending ( - ((Boolean) newValue).booleanValue () - ); - else + ((Boolean) newValue)); + } else { super.setValue (propertyName, newValue); } + } boolean isSorted() { return columnModel.isSorted(); @@ -184,6 +190,7 @@ columnModel.setSortedDescending(descending); } + @Override public PropertyEditor getPropertyEditor () { return propertyEditor; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultColumn.java spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultColumn.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultColumn.java 2016-02-04 02:55:43.075100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultColumn.java 2016-11-03 07:23:29.834689339 +0100 @@ -41,45 +41,42 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; -import java.beans.PropertyEditor; -import org.netbeans.spi.viewmodel.ColumnModel; import org.openide.nodes.PropertySupport; /** * - * @author Jan Jancura + * @author Jan Jancura */ public class DefaultColumn extends PropertySupport.ReadWrite { - - DefaultColumn () { - super ( - "default", - String.class, - "DN", - "SDN" + DefaultColumn() { + super( + "default", + String.class, + "DN", + "SDN" ); - setValue ( - "SortableColumn", - Boolean.TRUE + setValue( + "SortableColumn", + Boolean.TRUE ); - setValue ( - "TreeColumnTTV", - Boolean.TRUE + setValue( + "TreeColumnTTV", + Boolean.TRUE ); } - public Object getValue () { + @Override + public Object getValue() { return null; } - - public void setValue (Object obj) { + + @Override + public void setValue(Object obj) { } // public PropertyEditor getPropertyEditor () { // return propertyEditor; // } } - diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultTreeExpansionManager.java spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultTreeExpansionManager.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultTreeExpansionManager.java 2016-02-04 02:55:43.075100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/DefaultTreeExpansionManager.java 2016-11-03 07:23:29.834689339 +0100 @@ -39,32 +39,33 @@ * * Portions Copyrighted 2008 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; - import org.netbeans.spi.viewmodel.Models; import org.openide.util.WeakSet; /** - * Ugly class, that takes care that the expansion state is always managed for the object under the given node. - * This is necessary for trees that have equal nodes under various branches, or for recursive trees. - * + * Ugly class, that takes care that the expansion state is always managed for + * the object under the given node. This is necessary for trees that have equal + * nodes under various branches, or for recursive trees. + * * @author Martin */ public class DefaultTreeExpansionManager { - - private static Map managers = new WeakHashMap(); + + private static final Map managers = new WeakHashMap<>(); private Object currentChildren; - private Map> expandedNodes = new HashMap>(); - + private final Map> expandedNodes = new HashMap<>(); + public static synchronized DefaultTreeExpansionManager get(Models.CompoundModel model) { - if (model == null) throw new NullPointerException(); + if (model == null) { + throw new NullPointerException(); + } DefaultTreeExpansionManager manager = managers.get(model); if (manager == null) { manager = new DefaultTreeExpansionManager(); @@ -72,29 +73,37 @@ } return manager; } - + public static synchronized void copyExpansions(Models.CompoundModel oldCM, Models.CompoundModel newCM) { DefaultTreeExpansionManager oldManager = get(oldCM); DefaultTreeExpansionManager newManager = get(newCM); Map> expandedNodes; synchronized (oldManager) { - expandedNodes = new java.util.HashMap>(oldManager.expandedNodes); + expandedNodes = new java.util.HashMap<>(oldManager.expandedNodes); } synchronized (newManager) { newManager.expandedNodes.putAll(expandedNodes); } } - - private DefaultTreeExpansionManager() {} - - /** Must be called before every query, external synchronization with the model call is required. */ + + private DefaultTreeExpansionManager() { + } + + /** + * Must be called before every query, external synchronization with the + * model call is required. + */ public void setChildrenToActOn(Object ch) { currentChildren = ch; } - - /** External synchronization with currentNode required. */ + + /** + * External synchronization with currentNode required. + */ public synchronized boolean isExpanded(Object child) { - if (currentChildren == null) throw new NullPointerException("Call setChildrenToActOn() before!!!"); + if (currentChildren == null) { + throw new NullPointerException("Call setChildrenToActOn() before!!!"); + } try { Set expanded = expandedNodes.get(currentChildren); if (expanded != null && expanded.contains(child)) { @@ -107,11 +116,13 @@ } public synchronized void setExpanded(Object child) { - if (currentChildren == null) throw new NullPointerException("Call setChildrenToActOn() before!!!"); + if (currentChildren == null) { + throw new NullPointerException("Call setChildrenToActOn() before!!!"); + } try { Set expanded = expandedNodes.get(currentChildren); if (expanded == null) { - expanded = new WeakSet(); + expanded = new WeakSet<>(); expandedNodes.put(currentChildren, expanded); } expanded.add(child); @@ -121,7 +132,9 @@ } public synchronized void setCollapsed(Object child) { - if (currentChildren == null) throw new NullPointerException("Call setChildrenToActOn() before!!!"); + if (currentChildren == null) { + throw new NullPointerException("Call setChildrenToActOn() before!!!"); + } try { Set expanded = expandedNodes.get(currentChildren); if (expanded != null) { diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellEditor.java spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellEditor.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellEditor.java 2016-02-04 02:55:43.076100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellEditor.java 2016-11-03 07:23:29.834689339 +0100 @@ -41,13 +41,10 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.awt.Component; import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.lang.ref.Reference; import java.lang.ref.WeakReference; @@ -58,7 +55,6 @@ import org.netbeans.spi.viewmodel.TableRendererModel; import org.netbeans.spi.viewmodel.UnknownTypeException; import org.netbeans.swing.outline.Outline; -import org.netbeans.swing.outline.OutlineModel; import org.openide.nodes.Node; import org.openide.util.Exceptions; @@ -68,8 +64,8 @@ */ class DelegatingCellEditor implements TableCellEditor { - private String columnID; - private TableCellEditor defaultEditor; + private final String columnID; + private final TableCellEditor defaultEditor; private TableCellEditor currentEditor; private Reference canceledEditorRef; @@ -126,6 +122,7 @@ if (anEvent instanceof MouseEvent) { MouseEvent event = (MouseEvent) anEvent; Point p = event.getPoint(); + // Locate the editor under the event location //int column = outline.columnAtPoint(p); row = outline.rowAtPoint(p); @@ -186,11 +183,12 @@ if (currentEditor != null) { boolean status = currentEditor.stopCellEditing(); if (status) { - canceledEditorRef = new WeakReference(currentEditor); + canceledEditorRef = new WeakReference<>(currentEditor); currentEditor = null; } return status; } + Exceptions.printStackTrace(new IllegalStateException("No current editor.")); return true; } @@ -198,10 +196,11 @@ public void cancelCellEditing() { if (currentEditor != null) { currentEditor.cancelCellEditing(); - canceledEditorRef = new WeakReference(currentEditor); + canceledEditorRef = new WeakReference<>(currentEditor); currentEditor = null; - return ; + return; } + Exceptions.printStackTrace(new IllegalStateException("No current editor.")); } @Override diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellRenderer.java spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellRenderer.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellRenderer.java 2016-02-04 02:55:43.076100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/DelegatingCellRenderer.java 2016-11-03 07:23:29.835689349 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.awt.Component; @@ -54,7 +53,6 @@ import org.netbeans.swing.outline.OutlineModel; import org.openide.explorer.view.Visualizer; import org.openide.nodes.Node; -import org.openide.util.Exceptions; /** * @@ -62,8 +60,8 @@ */ class DelegatingCellRenderer implements TableCellRenderer { - private String columnID; - private TableCellRenderer defaultRenderer; + private final String columnID; + private final TableCellRenderer defaultRenderer; public DelegatingCellRenderer(String columnID, TableCellRenderer defaultRenderer) { this.columnID = columnID; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/ExceptionNode.java spi.viewmodel/src/org/netbeans/modules/viewmodel/ExceptionNode.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/ExceptionNode.java 2016-02-04 02:55:43.077100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/ExceptionNode.java 2016-11-03 07:23:29.834689339 +0100 @@ -41,69 +41,48 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; -import java.awt.event.ActionEvent; -import java.beans.PropertyEditor; -import java.lang.IllegalAccessException; -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import javax.swing.AbstractAction; -import javax.swing.Action; - -import org.netbeans.spi.viewmodel.ColumnModel; -import org.netbeans.spi.viewmodel.TreeModel; -import org.netbeans.spi.viewmodel.TableModel; -import org.netbeans.spi.viewmodel.UnknownTypeException; - import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; -import org.openide.nodes.Node; -import org.openide.nodes.PropertySupport; -import org.openide.nodes.Sheet; import org.openide.util.HelpCtx; import org.openide.util.lookup.Lookups; - /** * - * @author Jan Jancura + * @author Jan Jancura */ public class ExceptionNode extends AbstractNode { - - private Exception exception; - - // init .................................................................... + private final Exception exception; + // init .................................................................... /** - * Creates root of call stack for given producer. - */ - public ExceptionNode ( - Exception exception + * Creates root of call stack for given producer. + */ + public ExceptionNode( + Exception exception ) { - super ( - Children.LEAF, - Lookups.singleton (exception) + super( + Children.LEAF, + Lookups.singleton(exception) ); this.exception = exception; - setIconBaseWithExtension ("org/openide/resources/actions/empty.gif"); + setIconBaseWithExtension("org/openide/resources/actions/empty.gif"); } - - public String getName () { - return exception.getLocalizedMessage (); + + @Override + public String getName() { + return exception.getLocalizedMessage(); } - - public String getDisplayName () { - return exception.getLocalizedMessage (); + + @Override + public String getDisplayName() { + return exception.getLocalizedMessage(); } + @Override public HelpCtx getHelpCtx() { - return new HelpCtx (getClass ()); + return new HelpCtx(getClass()); } } - diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperColumnModel.java spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperColumnModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperColumnModel.java 2016-02-04 02:55:43.077100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperColumnModel.java 2016-11-03 07:23:29.834689339 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.HashSet; @@ -47,8 +46,8 @@ import org.netbeans.spi.viewmodel.ColumnModel; /** - * Represents a binding of specific column model of inner view - * to the main colum model of the enclosing view. + * Represents a binding of specific column model of inner view to the main colum + * model of the enclosing view. * * @author Martin Entlicher */ @@ -63,7 +62,7 @@ this.specific = specific; ids = createAllIDs(main, specific); } - + private static Set createAllIDs(ColumnModel... cms) { Set allIds = new HashSet(); for (ColumnModel cm : cms) { @@ -103,7 +102,7 @@ public Class getType() { return specific.getType(); } - + Set getAllIDs() { return ids; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperCompoundModel.java spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperCompoundModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperCompoundModel.java 2016-02-04 02:55:43.077100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/HyperCompoundModel.java 2016-11-03 07:23:29.834689339 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.awt.datatransfer.Transferable; @@ -54,13 +53,13 @@ */ public class HyperCompoundModel implements Model { - private Models.CompoundModel main; - private Models.CompoundModel[] models; - private TreeModelFilter treeFilter; + private final Models.CompoundModel main; + private final Models.CompoundModel[] models; + private final TreeModelFilter treeFilter; public HyperCompoundModel(Models.CompoundModel main, - Models.CompoundModel[] models, - TreeModelFilter treeFilter) { + Models.CompoundModel[] models, + TreeModelFilter treeFilter) { this.main = main; this.models = models; this.treeFilter = treeFilter; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/ModelRootChangeListener.java spi.viewmodel/src/org/netbeans/modules/viewmodel/ModelRootChangeListener.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/ModelRootChangeListener.java 2016-02-04 02:55:43.078100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/ModelRootChangeListener.java 2016-11-03 07:23:29.835689349 +0100 @@ -39,16 +39,15 @@ * * Portions Copyrighted 2013 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import org.netbeans.spi.viewmodel.ModelListener; /** * A marker interface for model root change listener. - * + * * @author Martin Entlicher */ public interface ModelRootChangeListener extends ModelListener { - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/OutlineTable.java spi.viewmodel/src/org/netbeans/modules/viewmodel/OutlineTable.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/OutlineTable.java 2016-02-04 02:55:43.079100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/OutlineTable.java 2016-11-03 07:23:29.835689349 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.awt.BorderLayout; @@ -71,27 +70,26 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.TableColumnModelEvent; import javax.swing.event.TableColumnModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.text.DefaultEditorKit; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; - -import org.netbeans.spi.viewmodel.Models; import org.netbeans.spi.viewmodel.ColumnModel; - import org.netbeans.spi.viewmodel.DnDNodeModel; +import org.netbeans.spi.viewmodel.Models; import org.netbeans.swing.etable.ETableColumn; import org.netbeans.swing.etable.ETableColumnModel; import org.netbeans.swing.outline.DefaultOutlineModel; import org.netbeans.swing.outline.Outline; import org.netbeans.swing.outline.OutlineModel; import org.openide.awt.Actions; -import org.openide.explorer.ExplorerUtils; import org.openide.explorer.ExplorerManager; +import org.openide.explorer.ExplorerUtils; import org.openide.explorer.view.OutlineView; import org.openide.explorer.view.Visualizer; - import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -102,44 +100,42 @@ import org.openide.util.Exceptions; import org.openide.windows.TopComponent; - /** - * Implements table visual representation of the data from models, using Outline view. + * Implements table visual representation of the data from models, using Outline + * view. * - * @author Martin Entlicher + * @author Martin Entlicher */ public class OutlineTable extends JPanel implements -ExplorerManager.Provider, PropertyChangeListener { + ExplorerManager.Provider, PropertyChangeListener { private static final Logger logger = Logger.getLogger(OutlineTable.class.getName()); - - private ExplorerManager explorerManager; - final MyTreeTable treeTable; // Accessed from tests - Node.Property[] columns; // Accessed from tests - private TableColumn[] tableColumns; - private int[] columnVisibleMap; // Column index -> visible index - private boolean ignoreCreateDefaultColumnsFromModel; + + private ExplorerManager explorerManager; + final MyTreeTable treeTable; // Accessed from tests + Node.Property[] columns; // Accessed from tests + private TableColumn[] tableColumns; + private int[] columnVisibleMap; // Column index -> visible index + private boolean ignoreCreateDefaultColumnsFromModel; //private IndexedColumn[] icolumns; - private boolean isDefaultColumnAdded; - private int defaultColumnIndex; // The index of the tree column - private boolean ignoreMove; // Whether to ignore column movement events - private boolean isSettingModelUp; // Whether a model is being set up + private boolean isDefaultColumnAdded; + private int defaultColumnIndex; // The index of the tree column + private boolean ignoreMove; // Whether to ignore column movement events + private boolean isSettingModelUp; // Whether a model is being set up //private List expandedPaths = new ArrayList (); - TreeModelRoot currentTreeModelRoot; // Accessed from test - + TreeModelRoot currentTreeModelRoot; // Accessed from test + //private TreeTableView ttv; //private TreeView tv; - - public OutlineTable () { - setLayout (new BorderLayout ()); - treeTable = new MyTreeTable (); - treeTable.getOutline().setRootVisible (false); - treeTable.setVerticalScrollBarPolicy - (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - treeTable.setHorizontalScrollBarPolicy - (JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - treeTable.setTreeHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - add (treeTable, "Center"); //NOI18N + public OutlineTable() { + setLayout(new BorderLayout()); + treeTable = new MyTreeTable(); + treeTable.getOutline().setRootVisible(false); + treeTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + treeTable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + treeTable.setTreeHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + treeTable.setBorder(new JScrollPane().getBorder()); + add(treeTable, "Center"); //NOI18N // ttv = new TreeTableView(); // To test only // add(ttv, "East"); // tv = new BeanTreeView(); // To test only @@ -150,14 +146,13 @@ // Track column visibility changes. // No impact on order property // Change visibility map - @Override public void columnAdded(TableColumnModelEvent e) { if (logger.isLoggable(Level.FINE)) { - logger.fine("columnAdded("+e+") to = "+e.getToIndex()); + logger.fine("columnAdded(" + e + ") to = " + e.getToIndex()); //logger.log(Level.FINE, " called from", new IllegalStateException("TEST")); TableColumnModel tcme = (TableColumnModel) e.getSource(); - logger.fine(" column header = '"+tcme.getColumn(e.getToIndex()).getHeaderValue()+"'"); + logger.fine(" column header = '" + tcme.getColumn(e.getToIndex()).getHeaderValue() + "'"); dumpColumnVisibleMap(); } if (tableColumns != null && e.getToIndex() >= 0) { @@ -177,7 +172,7 @@ } } if (logger.isLoggable(Level.FINE)) { - logger.fine(" to index = "+visibleIndex+", column index = "+columnIndex); + logger.fine(" to index = " + visibleIndex + ", column index = " + columnIndex); } if (columnIndex != -1) { int prefferedVisibleIndex = columnVisibleMap[columnIndex]; @@ -193,14 +188,14 @@ } } if (logger.isLoggable(Level.FINE)) { - logger.fine(" to index = "+visibleIndex+", column = "+columns[columnIndex].getDisplayName()+", columnVisibleIndex = "+columnVisibleIndex+", prefferedVisibleIndex = "+prefferedVisibleIndex); + logger.fine(" to index = " + visibleIndex + ", column = " + columns[columnIndex].getDisplayName() + ", columnVisibleIndex = " + columnVisibleIndex + ", prefferedVisibleIndex = " + prefferedVisibleIndex); } columns[columnIndex].setHidden(false); columnVisibleMap[columnIndex] = prefferedVisibleIndex; for (int i = 0; i < columnVisibleMap.length; i++) { - if (columnVisibleMap[i] >= columnVisibleIndex && i != columnIndex && - getColumnOrder(columns[i]) >= corder) { - + if (columnVisibleMap[i] >= columnVisibleIndex && i != columnIndex + && getColumnOrder(columns[i]) >= corder) { + columnVisibleMap[i]++; } } @@ -209,7 +204,7 @@ } if (prefferedVisibleIndex >= 0 && prefferedVisibleIndex != visibleIndex) { if (logger.isLoggable(Level.FINE)) { - logger.fine("moveColumn("+visibleIndex+", "+prefferedVisibleIndex+")"); + logger.fine("moveColumn(" + visibleIndex + ", " + prefferedVisibleIndex + ")"); } ignoreMove = true; try { @@ -229,7 +224,7 @@ @Override public void columnRemoved(TableColumnModelEvent e) { if (logger.isLoggable(Level.FINE)) { - logger.fine("columnRemoved("+e+") from = "+e.getFromIndex()); + logger.fine("columnRemoved(" + e + ") from = " + e.getFromIndex()); //logger.log(Level.FINE, " called from", new IllegalStateException("TEST")); dumpColumnVisibleMap(); } @@ -255,25 +250,25 @@ @Override public void columnMoved(TableColumnModelEvent e) { if (tableColumns == null || ignoreMove) { - return ; + return; } int from = e.getFromIndex(); int to = e.getToIndex(); if (from == to) { // Ignore Swing strangeness - return ; + return; } int fc = getColumnIndex(from); int tc = getColumnIndex(to); if (logger.isLoggable(Level.FINE)) { - logger.fine("columnMoved("+e+") from = "+from+", to = "+to); - logger.fine(" from = "+from+", to = "+to); - logger.fine(" fc = "+fc+", tc = "+tc); + logger.fine("columnMoved(" + e + ") from = " + from + ", to = " + to); + logger.fine(" from = " + from + ", to = " + to); + logger.fine(" fc = " + fc + ", tc = " + tc); TableColumnModel tcme = (TableColumnModel) e.getSource(); - logger.fine(" column headers = '"+tcme.getColumn(e.getFromIndex()).getHeaderValue()+"' => '"+tcme.getColumn(e.getToIndex()).getHeaderValue()+"'"); + logger.fine(" column headers = '" + tcme.getColumn(e.getFromIndex()).getHeaderValue() + "' => '" + tcme.getColumn(e.getToIndex()).getHeaderValue() + "'"); dumpColumnVisibleMap(); } - + int toColumnOrder = getColumnOrder(columns[tc]); int fromColumnOrder = getColumnOrder(columns[fc]); setColumnOrder(columns[fc], toColumnOrder); @@ -287,11 +282,14 @@ dumpColumnVisibleMap(); } } - + @Override - public void columnMarginChanged(ChangeEvent e) {} + public void columnMarginChanged(ChangeEvent e) { + } + @Override - public void columnSelectionChanged(ListSelectionEvent e) {} + public void columnSelectionChanged(ListSelectionEvent e) { + } }); ActionMap map = getActionMap(); ExplorerManager manager = getExplorerManager(); @@ -304,9 +302,9 @@ private void dumpColumnVisibleMap() { logger.fine(""); - logger.fine("Column Visible Map ("+columnVisibleMap.length+"):"); + logger.fine("Column Visible Map (" + columnVisibleMap.length + "):"); for (int i = 0; i < columnVisibleMap.length; i++) { - logger.fine(" {"+columns[i].getDisplayName()+"} \tvisible map["+i+"] = "+columnVisibleMap[i]+"; columnOrder["+i+"] = "+getColumnOrder(columns[i])+"\t"+(columns[i].isHidden() ? "hidden" : "")); + logger.fine(" {" + columns[i].getDisplayName() + "} \tvisible map[" + i + "] = " + columnVisibleMap[i] + "; columnOrder[" + i + "] = " + getColumnOrder(columns[i]) + "\t" + (columns[i].isHidden() ? "hidden" : "")); } logger.fine(""); } @@ -316,14 +314,14 @@ if (order == null) { return -1; } else { - return order.intValue(); + return order; } } private void setColumnOrder(Node.Property column, int order) { column.setValue(Column.PROP_ORDER_NUMBER, order); if (order != getColumnOrder(column)) { - Exceptions.printStackTrace(new IllegalStateException("The order "+order+" could not be set to column "+column)); + Exceptions.printStackTrace(new IllegalStateException("The order " + order + " could not be set to column " + column)); } } @@ -337,99 +335,98 @@ } /** - * Set list of models. - * Columns are taken from the first model. Children are listed + * Set list of models. Columns are taken from the first model. Children are + * listed + * * @param models */ - public void setModel (Models.CompoundModel model) { + public void setModel(Models.CompoundModel model) { setModel(model, null); } - + /** - * Set list of models. - * Columns are taken from the first model. Children are listed + * Set list of models. Columns are taken from the first model. Children are + * listed + * * @param models */ - public void setModel (Models.CompoundModel model, MessageFormat treeNodeDisplayFormat) { + public void setModel(Models.CompoundModel model, MessageFormat treeNodeDisplayFormat) { isSettingModelUp = true; try { - // 2) save current settings (like columns, expanded paths) - //List ep = treeTable.getExpandedPaths (); - if (currentTreeModelRoot == null || currentTreeModelRoot.getTreeNodeDisplayFormat() == null) { - saveWidths (); - saveSortedState(); - } - - //this.model = model; - - // 1) destroy old model - if (currentTreeModelRoot != null) { - currentTreeModelRoot.destroy (); - currentTreeModelRoot = null; - } - - // 3) no model => set empty root node & return - if (model == null) { - getExplorerManager ().setRootContext ( - new AbstractNode (Children.LEAF) - ); - return; - } - - // 4) set columns for given model - String[] nodesColumnName = new String[] { null, null }; - ColumnModel[] cs = model.getColumns (); - if (logger.isLoggable(Level.FINE)) { - logger.fine("setModel(): creating columns: ("+cs.length+")"); - for (int i = 0; i < cs.length; i++) { - logger.fine(" ColumnModel["+i+"] = "+cs[i].getDisplayName()+", ID = "+cs[i].getID()+", visible = "+cs[i].isVisible()); + // 2) save current settings (like columns, expanded paths) + //List ep = treeTable.getExpandedPaths (); + if (currentTreeModelRoot == null || currentTreeModelRoot.getTreeNodeDisplayFormat() == null) { + saveWidths(); + saveSortedState(); + } + + //this.model = model; + // 1) destroy old model + if (currentTreeModelRoot != null) { + currentTreeModelRoot.destroy(); + currentTreeModelRoot = null; + } + + // 3) no model => set empty root node & return + if (model == null) { + getExplorerManager().setRootContext( + new AbstractNode(Children.LEAF) + ); + return; + } + + // 4) set columns for given model + String[] nodesColumnName = new String[]{null, null}; + ColumnModel[] cs = model.getColumns(); + if (logger.isLoggable(Level.FINE)) { + logger.fine("setModel(): creating columns: (" + cs.length + ")"); + for (int i = 0; i < cs.length; i++) { + logger.fine(" ColumnModel[" + i + "] = " + cs[i].getDisplayName() + ", ID = " + cs[i].getID() + ", visible = " + cs[i].isVisible()); + } } - } - Node.Property[] columnsToSet = createColumns (cs, nodesColumnName); - ignoreCreateDefaultColumnsFromModel = true; - treeTable.setNodesColumnName(nodesColumnName[0], nodesColumnName[1]); - if (logger.isLoggable(Level.FINE)) { - logger.fine("setModel(): setNodesColumnName("+Arrays.toString(nodesColumnName)+") done"); - } - currentTreeModelRoot = new TreeModelRoot (model, treeTable); - currentTreeModelRoot.setTreeNodeDisplayFormat(treeNodeDisplayFormat); - TreeModelNode rootNode = currentTreeModelRoot.getRootNode (); - getExplorerManager ().setRootContext (rootNode); - // The root node must be ready when setting the columns - if (logger.isLoggable(Level.FINE)) { - logger.fine("setModel(): setProperties("+Arrays.toString(columnsToSet)+")"); - } - if (treeNodeDisplayFormat == null) { - treeTable.setProperties (columnsToSet); - updateTableColumns(columnsToSet, null); - } else { - treeTable.setProperties (new Property[]{}); - } - ignoreCreateDefaultColumnsFromModel = false; - treeTable.setAllowedDragActions(model.getAllowedDragActions()); - treeTable.setAllowedDropActions(model.getAllowedDropActions(null)); - treeTable.setDynamicDropActions(model); - - //treeTable.getTable().tableChanged(new TableModelEvent(treeTable.getOutline().getModel())); - //getExplorerManager ().setRootContext (rootNode); - - // 5) set root node for given model - // Moved to 4), because the new root node must be ready when setting columns - - // 6) update column widths & expanded nodes - if (treeNodeDisplayFormat == null) { - updateColumnWidthsAndSorting(); - } - //treeTable.expandNodes (expandedPaths); - // TODO: this is a workaround, we should find a better way later - /* We must not call children here - it can take a long time... + Node.Property[] columnsToSet = createColumns(cs, nodesColumnName); + ignoreCreateDefaultColumnsFromModel = true; + treeTable.setNodesColumnName(nodesColumnName[0], nodesColumnName[1]); + if (logger.isLoggable(Level.FINE)) { + logger.fine("setModel(): setNodesColumnName(" + Arrays.toString(nodesColumnName) + ") done"); + } + currentTreeModelRoot = new TreeModelRoot(model, treeTable); + currentTreeModelRoot.setTreeNodeDisplayFormat(treeNodeDisplayFormat); + TreeModelNode rootNode = currentTreeModelRoot.getRootNode(); + getExplorerManager().setRootContext(rootNode); + // The root node must be ready when setting the columns + if (logger.isLoggable(Level.FINE)) { + logger.fine("setModel(): setProperties(" + Arrays.toString(columnsToSet) + ")"); + } + if (treeNodeDisplayFormat == null) { + treeTable.setProperties(columnsToSet); + updateTableColumns(columnsToSet, null); + } else { + treeTable.setProperties(new Property[]{}); + } + ignoreCreateDefaultColumnsFromModel = false; + treeTable.setAllowedDragActions(model.getAllowedDragActions()); + treeTable.setAllowedDropActions(model.getAllowedDropActions(null)); + treeTable.setDynamicDropActions(model); + + //treeTable.getTable().tableChanged(new TableModelEvent(treeTable.getOutline().getModel())); + //getExplorerManager ().setRootContext (rootNode); + // 5) set root node for given model + // Moved to 4), because the new root node must be ready when setting columns + // 6) update column widths & expanded nodes + if (treeNodeDisplayFormat == null) { + updateColumnWidthsAndSorting(); + } + //treeTable.expandNodes (expandedPaths); + // TODO: this is a workaround, we should find a better way later + /* We must not call children here - it can take a long time... * the expansion is performed in TreeModelNode.TreeModelChildren.applyChildren() final List backupPath = new ArrayList (expandedPaths); if (backupPath.size () == 0) TreeModelNode.getRequestProcessor ().post (new Runnable () { public void run () { try { - final Object[] ch = TreeTable.this.model.getChildren + final Object[] ch = TreeTable.this.model.getChildren (TreeTable.this.model.getRoot (), 0, 0); SwingUtilities.invokeLater (new Runnable () { public void run () { @@ -445,115 +442,113 @@ treeTable.expandNodes (backupPath); } }); - */ - //if (ep.size () > 0) expandedPaths = ep; + */ + //if (ep.size () > 0) expandedPaths = ep; - // Sort of hack(?) After close/open of the view the table becomes empty, - // it looks like the root node stays unexpanded for some reason. - //treeTable.expandNode(rootNode); + // Sort of hack(?) After close/open of the view the table becomes empty, + // it looks like the root node stays unexpanded for some reason. + //treeTable.expandNode(rootNode); } finally { isSettingModelUp = false; } } - + /** - * Set list of models. - * Columns are taken from the first model. Children are listed + * Set list of models. Columns are taken from the first model. Children are + * listed + * * @param models */ - public void setModel (HyperCompoundModel model, MessageFormat treeNodeDisplayFormat) { + public void setModel(HyperCompoundModel model, MessageFormat treeNodeDisplayFormat) { isSettingModelUp = true; try { - // 2) save current settings (like columns, expanded paths) - //List ep = treeTable.getExpandedPaths (); - if (currentTreeModelRoot == null || currentTreeModelRoot.getTreeNodeDisplayFormat() == null) { - saveWidths (); - saveSortedState(); - } - - //this.model = model; - - // 1) destroy old model - if (currentTreeModelRoot != null) { - currentTreeModelRoot.destroy (); - currentTreeModelRoot = null; - } - - // 3) no model => set empty root node & return - if (model == null) { - getExplorerManager ().setRootContext ( - new AbstractNode (Children.LEAF) - ); - return; - } - - // 4) set columns for given model - String[] nodesColumnName = new String[] { null, null }; - ColumnModel[] cs = model.getColumns (); - Node.Property[] columnsToSet = createColumns (cs, nodesColumnName); - ignoreCreateDefaultColumnsFromModel = true; - treeTable.setNodesColumnName(nodesColumnName[0], nodesColumnName[1]); - currentTreeModelRoot = new TreeModelRoot (model, treeTable); - currentTreeModelRoot.setTreeNodeDisplayFormat(treeNodeDisplayFormat); - TreeModelNode rootNode = currentTreeModelRoot.getRootNode (); - getExplorerManager ().setRootContext (rootNode); - // The root node must be ready when setting the columns - if (treeNodeDisplayFormat == null) { - treeTable.setProperties (columnsToSet); - updateTableColumns(columnsToSet, null); - } else { - treeTable.setProperties (new Property[]{}); - } - ignoreCreateDefaultColumnsFromModel = false; - treeTable.setAllowedDragActions(model.getAllowedDragActions()); - treeTable.setAllowedDropActions(model.getAllowedDropActions(null)); - - // 5) set root node for given model - // Moved to 4), because the new root node must be ready when setting columns - - // 6) update column widths & expanded nodes - if (treeNodeDisplayFormat == null) { - updateColumnWidthsAndSorting(); - } - /* We must not call children here - it can take a long time... + // 2) save current settings (like columns, expanded paths) + //List ep = treeTable.getExpandedPaths (); + if (currentTreeModelRoot == null || currentTreeModelRoot.getTreeNodeDisplayFormat() == null) { + saveWidths(); + saveSortedState(); + } + + //this.model = model; + // 1) destroy old model + if (currentTreeModelRoot != null) { + currentTreeModelRoot.destroy(); + currentTreeModelRoot = null; + } + + // 3) no model => set empty root node & return + if (model == null) { + getExplorerManager().setRootContext( + new AbstractNode(Children.LEAF) + ); + return; + } + + // 4) set columns for given model + String[] nodesColumnName = new String[]{null, null}; + ColumnModel[] cs = model.getColumns(); + Node.Property[] columnsToSet = createColumns(cs, nodesColumnName); + ignoreCreateDefaultColumnsFromModel = true; + treeTable.setNodesColumnName(nodesColumnName[0], nodesColumnName[1]); + currentTreeModelRoot = new TreeModelRoot(model, treeTable); + currentTreeModelRoot.setTreeNodeDisplayFormat(treeNodeDisplayFormat); + TreeModelNode rootNode = currentTreeModelRoot.getRootNode(); + getExplorerManager().setRootContext(rootNode); + // The root node must be ready when setting the columns + if (treeNodeDisplayFormat == null) { + treeTable.setProperties(columnsToSet); + updateTableColumns(columnsToSet, null); + } else { + treeTable.setProperties(new Property[]{}); + } + ignoreCreateDefaultColumnsFromModel = false; + treeTable.setAllowedDragActions(model.getAllowedDragActions()); + treeTable.setAllowedDropActions(model.getAllowedDropActions(null)); + + // 5) set root node for given model + // Moved to 4), because the new root node must be ready when setting columns + // 6) update column widths & expanded nodes + if (treeNodeDisplayFormat == null) { + updateColumnWidthsAndSorting(); + } + /* We must not call children here - it can take a long time... * the expansion is performed in TreeModelNode.TreeModelChildren.applyChildren() - */ + */ } finally { isSettingModelUp = false; } } @Override - public ExplorerManager getExplorerManager () { + public ExplorerManager getExplorerManager() { if (explorerManager == null) { - explorerManager = new ExplorerManager (); + explorerManager = new ExplorerManager(); } return explorerManager; } - + @Override - public void propertyChange (PropertyChangeEvent evt) { - String propertyName = evt.getPropertyName (); + public void propertyChange(PropertyChangeEvent evt) { + String propertyName = evt.getPropertyName(); TopComponent tc = (TopComponent) SwingUtilities. - getAncestorOfClass (TopComponent.class, this); + getAncestorOfClass(TopComponent.class, this); if (tc == null) { return; } - if (propertyName.equals (TopComponent.Registry.PROP_CURRENT_NODES)) { + if (propertyName.equals(TopComponent.Registry.PROP_CURRENT_NODES)) { ExplorerUtils.activateActions(getExplorerManager(), equalNodes()); - } else - if (propertyName.equals (ExplorerManager.PROP_SELECTED_NODES)) { - tc.setActivatedNodes ((Node[]) evt.getNewValue ()); + } else if (propertyName.equals(ExplorerManager.PROP_SELECTED_NODES)) { + tc.setActivatedNodes((Node[]) evt.getNewValue()); } } - - private boolean equalNodes () { - Node[] ns1 = TopComponent.getRegistry ().getCurrentNodes (); - Node[] ns2 = getExplorerManager ().getSelectedNodes (); + + private boolean equalNodes() { + Node[] ns1 = TopComponent.getRegistry().getCurrentNodes(); + Node[] ns2 = getExplorerManager().getSelectedNodes(); if (ns1 == ns2) { return true; } - if ( (ns1 == null) || (ns2 == null) ) { + if ((ns1 == null) || (ns2 == null)) { return false; } if (ns1.length != ns2.length) { @@ -561,23 +556,23 @@ } int i, k = ns1.length; for (i = 0; i < k; i++) { - if (!ns1 [i].equals (ns2 [i])) { + if (!ns1[i].equals(ns2[i])) { return false; } } return true; } - - private Node.Property[] createColumns (ColumnModel[] cs, String[] nodesColumnNameAndDescription) { + + private Node.Property[] createColumns(ColumnModel[] cs, String[] nodesColumnNameAndDescription) { int i, k = cs.length; // Check column IDs: { - Map IDs = new HashMap(k); + Map IDs = new HashMap<>(k); for (i = 0; i < k; i++) { String id = cs[i].getID(); if (IDs.containsKey(id)) { ColumnModel csi = IDs.get(id); - logger.severe("\nHave two columns with identical IDs \""+id+"\": "+csi+" ["+csi.getDisplayName()+"] and "+cs[i]+" ["+cs[i].getDisplayName()+"]\n"); + logger.severe("\nHave two columns with identical IDs \"" + id + "\": " + csi + " [" + csi.getDisplayName() + "] and " + cs[i] + " [" + cs[i].getDisplayName() + "]\n"); } else { IDs.put(id, cs[i]); } @@ -589,17 +584,17 @@ isDefaultColumnAdded = false; ColumnModel treeColumn = null; boolean addDefaultColumn = true; - List columnList = new ArrayList(k); + List columnList = new ArrayList<>(k); int d = 0; boolean[] originalOrder = new boolean[k]; for (i = 0; i < k; i++) { - Column c = new Column(cs [i]); + Column c = new Column(cs[i]); columns[i] = c; //IndexedColumn ic = new IndexedColumn(c, i, cs[i].getCurrentOrderNumber()); //icolumns[i] = ic; int order = cs[i].getCurrentOrderNumber(); if (logger.isLoggable(Level.FINE)) { - logger.fine("createColumns(): column {"+c.getDisplayName()+"}: order = "+order+", i = "+i+", d = "+d); + logger.fine("createColumns(): column {" + c.getDisplayName() + "}: order = " + order + ", i = " + i + ", d = " + d); } if (order == -1) { order = i; @@ -628,10 +623,10 @@ } } if (addDefaultColumn) { - PropertySupport.ReadWrite[] columns2 = - new PropertySupport.ReadWrite [columns.length + 1]; - System.arraycopy (columns, 0, columns2, 1, columns.length); - columns2 [0] = new DefaultColumn (); + PropertySupport.ReadWrite[] columns2 + = new PropertySupport.ReadWrite[columns.length + 1]; + System.arraycopy(columns, 0, columns2, 1, columns.length); + columns2[0] = new DefaultColumn(); nodesColumnNameAndDescription[0] = columns2[0].getDisplayName(); nodesColumnNameAndDescription[1] = columns2[0].getShortDescription(); columns = columns2; @@ -683,7 +678,9 @@ return columnProps; } - /** Squeeze gaps and split duplicities to make it a permutation. */ + /** + * Squeeze gaps and split duplicities to make it a permutation. + */ private void checkOrder(int[] orders, boolean[] originalOrder) { if (logger.isLoggable(Level.FINE)) { StringBuilder msg = new StringBuilder("checkOrder("); @@ -786,23 +783,29 @@ if (ci < columnsToSet.length && columns[i] == columnsToSet[ci] && i != defaultColumnIndex) { TableColumn tc = allColumns.get(tci); //tcm.getColumn(tci); tableColumns[i] = tc; - if (columns[i] instanceof Column && tci < tcm.getColumnCount()) { + if (columns[i] instanceof Column) { Column c = (Column) columns[i]; + TableCellEditor cellEditor = tc.getCellEditor(); + if (cellEditor == null) { + cellEditor = treeTable.getTable().getDefaultEditor(Node.Property.class); + } tc.setCellEditor(new DelegatingCellEditor( c.getName(), - treeTable.getTable().getCellEditor(0, tci))); + cellEditor)); + TableCellRenderer cellRenderer = tc.getCellRenderer(); + if (cellRenderer == null) { + cellRenderer = treeTable.getTable().getDefaultRenderer(Node.Property.class); + } tc.setCellRenderer(new DelegatingCellRenderer( c.getName(), - treeTable.getTable().getCellRenderer(0, tci))); + cellRenderer)); tc.setPreferredWidth(c.getColumnWidth()); } if (columns[i].isHidden()) { ecm.setColumnHidden(tc, true); - } else { - if (columns[i] instanceof Column) { - Column c = (Column) columns[i]; - tc.setPreferredWidth(c.getColumnWidth()); - } + } else if (columns[i] instanceof Column) { + Column c = (Column) columns[i]; + tc.setPreferredWidth(c.getColumnWidth()); } tci++; ci++; @@ -827,15 +830,15 @@ } } if (logger.isLoggable(Level.FINE)) { - logger.fine("updateTableColumns("+columns.length+"):"); + logger.fine("updateTableColumns(" + columns.length + "):"); for (int i = 0; i < columns.length; i++) { - logger.fine("Column["+i+"] ("+columns[i].getDisplayName()+") = "+((tableColumns[i] != null) ? tableColumns[i].getHeaderValue() : "null")+"\t"+(columns[i].isHidden() ? "hidden" : "")); + logger.fine("Column[" + i + "] (" + columns[i].getDisplayName() + ") = " + ((tableColumns[i] != null) ? tableColumns[i].getHeaderValue() : "null") + "\t" + (columns[i].isHidden() ? "hidden" : "")); } } setColumnsOrder(); this.tableColumns = tableColumns; } - + private List getAllColumns(ETableColumnModel etcm) { try { Method getAllColumnsMethod = ETableColumnModel.class.getDeclaredMethod("getAllColumns"); @@ -899,7 +902,7 @@ logger.log(Level.FINE, " order[{0}] = {1}", new Object[]{j, i}); if (j != i) { for (int k = j; k > i; k--) { - order[k] = order[k-1]; + order[k] = order[k - 1]; } order[i] = i; logger.log(Level.FINE, " move column({0}, {1})", new Object[]{j, i}); @@ -933,22 +936,22 @@ logger.log(Level.FINE, " visibleOrder[{0}] = {1}, ", new Object[]{i, visibleOrder}); ETableColumn tc; try { - tc = (ETableColumn) tcm.getColumn (visibleOrder); + tc = (ETableColumn) tcm.getColumn(visibleOrder); } catch (ArrayIndexOutOfBoundsException aioobex) { logger.log(Level.SEVERE, - "Column("+i+") "+columns[i].getName()+" visible index = "+visibleOrder+ - ", columnVisibleMap = "+java.util.Arrays.toString(columnVisibleMap)+ - ", num of columns = "+tcm.getColumnCount(), + "Column(" + i + ") " + columns[i].getName() + " visible index = " + visibleOrder + + ", columnVisibleMap = " + java.util.Arrays.toString(columnVisibleMap) + + ", num of columns = " + tcm.getColumnCount(), aioobex); - continue ; + continue; } if (logger.isLoggable(Level.FINE)) { - logger.fine(" GUI column = "+tc.getHeaderValue()); + logger.fine(" GUI column = " + tc.getHeaderValue()); } if (columns[i] instanceof Column) { Column c = (Column) columns[i]; if (logger.isLoggable(Level.FINE)) { - logger.fine(" Retrieved width "+c.getColumnWidth()+" from "+columns[i].getDisplayName()+"["+i+"] for "+tc.getHeaderValue()); + logger.fine(" Retrieved width " + c.getColumnWidth() + " from " + columns[i].getDisplayName() + "[" + i + "] for " + tc.getHeaderValue()); } tc.setPreferredWidth(c.getColumnWidth()); if (c.isSorted()) { @@ -958,19 +961,19 @@ } } - private void saveWidths () { + private void saveWidths() { if (columns == null) { return; } int i, k = columns.length; if (k == 0) { - return ; + return; } TableColumnModel tcm = treeTable.getTable().getColumnModel(); ETableColumnModel ecm = (ETableColumnModel) tcm; Enumeration etc = tcm.getColumns(); boolean defaultState = true; - while(etc.hasMoreElements()) { + while (etc.hasMoreElements()) { if (etc.nextElement().getWidth() != 75) { defaultState = false; break; @@ -979,7 +982,7 @@ if (defaultState) { // All columns have the default width 75. // It's very likely that the table was not fully initialized => do not save anything. - return ; + return; } logger.fine("\nsaveWidths():"); for (i = 0; i < k; i++) { @@ -993,34 +996,34 @@ } TableColumn tc; try { - tc = tcm.getColumn (visibleOrder); + tc = tcm.getColumn(visibleOrder); } catch (ArrayIndexOutOfBoundsException aioobex) { logger.log(Level.SEVERE, - "Column("+i+") "+columns[i].getName()+" visible index = "+visibleOrder+ - ", columnVisibleMap = "+java.util.Arrays.toString(columnVisibleMap)+ - ", num of columns = "+tcm.getColumnCount(), + "Column(" + i + ") " + columns[i].getName() + " visible index = " + visibleOrder + + ", columnVisibleMap = " + java.util.Arrays.toString(columnVisibleMap) + + ", num of columns = " + tcm.getColumnCount(), aioobex); - continue ; + continue; } if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, " GUI column = {0}", tc.getHeaderValue()); } if (columns[i] instanceof Column) { if (logger.isLoggable(Level.FINE)) { - logger.fine(" Setting width "+tc.getWidth()+" from "+tc.getHeaderValue()+" to "+columns[i].getDisplayName()+"["+i+"]"); + logger.fine(" Setting width " + tc.getWidth() + " from " + tc.getHeaderValue() + " to " + columns[i].getDisplayName() + "[" + i + "]"); } ((Column) columns[i]).setColumnWidth(tc.getWidth()); } } } - - private void saveSortedState () { + + private void saveSortedState() { if (columns == null) { return; } int i, k = columns.length; if (k == 0) { - return ; + return; } TableColumnModel tcm = treeTable.getTable().getColumnModel(); ETableColumnModel ecm = (ETableColumnModel) tcm; @@ -1037,21 +1040,21 @@ } ETableColumn tc; try { - tc = (ETableColumn) tcm.getColumn (visibleOrder); + tc = (ETableColumn) tcm.getColumn(visibleOrder); } catch (ArrayIndexOutOfBoundsException aioobex) { logger.log(Level.SEVERE, - "Column("+i+") "+columns[i].getName()+" visible index = "+visibleOrder+ - ", columnVisibleMap = "+java.util.Arrays.toString(columnVisibleMap)+ - ", num of columns = "+tcm.getColumnCount(), + "Column(" + i + ") " + columns[i].getName() + " visible index = " + visibleOrder + + ", columnVisibleMap = " + java.util.Arrays.toString(columnVisibleMap) + + ", num of columns = " + tcm.getColumnCount(), aioobex); - continue ; + continue; } if (logger.isLoggable(Level.FINE)) { - logger.fine(" GUI column = "+tc.getHeaderValue()); + logger.fine(" GUI column = " + tc.getHeaderValue()); } if (columns[i] instanceof Column) { if (logger.isLoggable(Level.FINE)) { - logger.fine(" Setting sorted "+tc.isSorted()+" descending "+(!tc.isAscending())+" to "+columns[i].getDisplayName()+"["+i+"]"); + logger.fine(" Setting sorted " + tc.isSorted() + " descending " + (!tc.isAscending()) + " to " + columns[i].getDisplayName() + "[" + i + "]"); } ((Column) columns[i]).setSorted(tc.isSorted()); ((Column) columns[i]).setSortedDescending(!tc.isAscending()); @@ -1059,52 +1062,54 @@ } } - /** Requests focus for the tree component. Overrides superclass method. */ + /** + * Requests focus for the tree component. Overrides superclass method. + */ @Override - public boolean requestFocusInWindow () { + public boolean requestFocusInWindow() { super.requestFocusInWindow(); - return treeTable.requestFocusInWindow (); + return treeTable.requestFocusInWindow(); } - + @Override - public void addNotify () { - TopComponent.getRegistry ().addPropertyChangeListener (this); - ExplorerUtils.activateActions(getExplorerManager (), true); - getExplorerManager ().addPropertyChangeListener (this); - super.addNotify (); + public void addNotify() { + TopComponent.getRegistry().addPropertyChangeListener(this); + ExplorerUtils.activateActions(getExplorerManager(), true); + getExplorerManager().addPropertyChangeListener(this); + super.addNotify(); } - + @Override - public void removeNotify () { - super.removeNotify (); - TopComponent.getRegistry ().removePropertyChangeListener (this); - ExplorerUtils.activateActions(getExplorerManager (), false); - getExplorerManager ().removePropertyChangeListener (this); - setModel(null); - } - - public boolean isExpanded (Object node) { - Node[] ns = currentTreeModelRoot.findNode (node); + public void removeNotify() { + super.removeNotify(); + TopComponent.getRegistry().removePropertyChangeListener(this); + ExplorerUtils.activateActions(getExplorerManager(), false); + getExplorerManager().removePropertyChangeListener(this); + //setModel(null); + } + + public boolean isExpanded(Object node) { + Node[] ns = currentTreeModelRoot.findNode(node); if (ns.length == 0) { return false; // Something what does not exist is not expanded ;-) } - return treeTable.isExpanded (ns[0]); + return treeTable.isExpanded(ns[0]); } - public void expandNode (Object node) { - Node[] ns = currentTreeModelRoot.findNode (node); + public void expandNode(Object node) { + Node[] ns = currentTreeModelRoot.findNode(node); for (Node n : ns) { - treeTable.expandNode (n); + treeTable.expandNode(n); } } - public void collapseNode (Object node) { - Node[] ns = currentTreeModelRoot.findNode (node); + public void collapseNode(Object node) { + Node[] ns = currentTreeModelRoot.findNode(node); for (Node n : ns) { - treeTable.collapseNode (n); + treeTable.collapseNode(n); } } - + private class CreatedDefaultColumnsFromModel implements PropertyChangeListener { @Override @@ -1124,25 +1129,25 @@ } } } - + } - + static class MyTreeTable extends OutlineView { // Accessed from tests private Reference dndModelRef = new WeakReference(null); private Property[] properties; - MyTreeTable () { - super (); + MyTreeTable() { + super(); Outline outline = getOutline(); - outline.setShowHorizontalLines (true); - outline.setShowVerticalLines (false); + outline.setShowHorizontalLines(true); + outline.setShowVerticalLines(false); filterInputMap(outline, JComponent.WHEN_FOCUSED); filterInputMap(outline, JComponent.WHEN_IN_FOCUSED_WINDOW); filterInputMap(outline, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); outline.putClientProperty("PropertyToolTipShortDescription", Boolean.TRUE); } - + private void filterInputMap(JComponent component, int condition) { InputMap imap = component.getInputMap(condition); if (imap instanceof ComponentInputMap) { @@ -1152,8 +1157,8 @@ } component.setInputMap(condition, imap); } - - JTable getTable () { + + JTable getTable() { return getOutline(); } @@ -1162,11 +1167,11 @@ this.properties = newProperties; super.setProperties(newProperties); } - + Property[] getProperties() { return properties; } - + void setNodesColumnName(String name, String description) { OutlineModel m = getOutline().getOutlineModel(); if (m instanceof DefaultOutlineModel) { @@ -1183,8 +1188,8 @@ em.getRootContext () ); TreePath tp = new TreePath (rtn); // Get the root - - Enumeration exPaths = tree.getExpandedDescendants (tp); + + Enumeration exPaths = tree.getExpandedDescendants (tp); if (exPaths == null) return result; for (;exPaths.hasMoreElements ();) { TreePath ep = (TreePath) exPaths.nextElement (); @@ -1195,13 +1200,13 @@ return result; } */ - - /** Expands all the paths, when exists + /** + * Expands all the paths, when exists */ - public void expandNodes (List exPaths) { - for (Iterator it = exPaths.iterator (); it.hasNext ();) { - String[] sp = (String[]) it.next (); - TreePath tp = stringPath2TreePath (sp); + public void expandNodes(List exPaths) { + for (Iterator it = exPaths.iterator(); it.hasNext();) { + String[] sp = (String[]) it.next(); + TreePath tp = stringPath2TreePath(sp); if (tp != null) { getOutline().expandPath(tp); Rectangle rect = getOutline().getPathBounds(tp); @@ -1212,21 +1217,22 @@ } } - /** Converts path of strings to TreePath if exists null otherwise + /** + * Converts path of strings to TreePath if exists null otherwise */ - private TreePath stringPath2TreePath (String[] sp) { - ExplorerManager em = ExplorerManager.find (this); + private TreePath stringPath2TreePath(String[] sp) { + ExplorerManager em = ExplorerManager.find(this); try { - Node n = NodeOp.findPath (em.getRootContext (), sp); - + Node n = NodeOp.findPath(em.getRootContext(), sp); + // Create the tree path - TreeNode tns[] = new TreeNode [sp.length + 1]; - + TreeNode tns[] = new TreeNode[sp.length + 1]; + for (int i = sp.length; i >= 0; i--) { - tns[i] = Visualizer.findVisualizer (n); - n = n.getParentNode (); - } - return new TreePath (tns); + tns[i] = Visualizer.findVisualizer(n); + n = n.getParentNode(); + } + return new TreePath(tns); } catch (NodeNotFoundException e) { return null; } @@ -1253,11 +1259,11 @@ } } - + private static final class F8FilterComponentInputMap extends ComponentInputMap { - + private KeyStroke f8 = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0); - + public F8FilterComponentInputMap(JComponent component, InputMap imap) { super(component); setParent(imap); @@ -1272,11 +1278,11 @@ } } } - + private static final class F8FilterInputMap extends InputMap { - + private KeyStroke f8 = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0); - + public F8FilterInputMap(InputMap imap) { setParent(imap); } @@ -1290,6 +1296,5 @@ } } } - -} +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelHyperNode.java spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelHyperNode.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelHyperNode.java 2016-02-04 02:55:43.080100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelHyperNode.java 2016-11-03 07:23:29.834689339 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.awt.datatransfer.Transferable; @@ -47,7 +46,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Set; - import java.util.concurrent.Executor; import java.util.logging.Level; import java.util.logging.Logger; @@ -70,33 +68,33 @@ */ public class TreeModelHyperNode extends TreeModelNode { - private HyperCompoundModel model; - + private final HyperCompoundModel model; + public TreeModelHyperNode( - final HyperCompoundModel model, - final TreeModelRoot treeModelRoot, - final Object object + final HyperCompoundModel model, + final TreeModelRoot treeModelRoot, + final Object object ) { super( - model.getMain(), - model.getColumns(), - null, - createChildren(model, treeModelRoot, object), - treeModelRoot, - object + model.getMain(), + model.getColumns(), + null, + createChildren(model, treeModelRoot, object), + treeModelRoot, + object ); this.model = model; } - private static Children createChildren ( - HyperCompoundModel model, - TreeModelRoot treeModelRoot, - Object object + private static Children createChildren( + HyperCompoundModel model, + TreeModelRoot treeModelRoot, + Object object ) { if (object == null) { - throw new NullPointerException (); + throw new NullPointerException(); } - return new HyperModelChildren (model, treeModelRoot, object); + return new HyperModelChildren(model, treeModelRoot, object); } @Override @@ -109,7 +107,7 @@ //hch.cleanCachedChildren(model); hch.refreshChildren(hch.new HyperRefreshingInfo(refreshInfo, models)); } else { - setChildren(new HyperModelChildren (this.model, treeModelRoot, object)); + setChildren(new HyperModelChildren(this.model, treeModelRoot, object)); } } @@ -130,7 +128,9 @@ if (m != mm) { try { p = m.getDropType(object, t, action, index); - if (p != null) break; + if (p != null) { + break; + } } catch (UnknownTypeException ex) { } } @@ -143,11 +143,13 @@ PasteType p = null; HyperModelChildren hch = (HyperModelChildren) getChildren(); int index1 = (index > 0) ? index - 1 : index; // node above - int[] modelIndexPtr = new int[] { -1 }; + int[] modelIndexPtr = new int[]{-1}; CompoundModel cm1 = hch.getRootModelByIndex(index1, modelIndexPtr); if (cm1 != null) { try { - if (index1 < index) modelIndexPtr[0]++; + if (index1 < index) { + modelIndexPtr[0]++; + } //System.err.println("\nTreeModelHyperNode.getDropType("+cm1+", \n"+action+", "+modelIndexPtr[0]+")"); p = cm1.getDropType(object, t, action, modelIndexPtr[0]); } catch (UnknownTypeException e) { @@ -169,16 +171,16 @@ } private static final class HyperModelChildren extends TreeModelChildren { - - private HyperCompoundModel model; - private final java.util.Map rootModelsByChildren = new HashMap(); - private final java.util.Map rootChildrenByModels = new HashMap(); + + private final HyperCompoundModel model; + private final java.util.Map rootModelsByChildren = new HashMap<>(); + private final java.util.Map rootChildrenByModels = new HashMap<>(); private final int[] rootModelIndexes; // Children indexes of root models. First is 0. - public HyperModelChildren ( - HyperCompoundModel model, - TreeModelRoot treeModelRoot, - Object object + public HyperModelChildren( + HyperCompoundModel model, + TreeModelRoot treeModelRoot, + Object object ) { super(null, model.getColumns(), treeModelRoot, object); this.model = model; @@ -200,7 +202,7 @@ } } } catch (UnknownTypeException ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "model = "+model+", object = "+object)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "model = " + model + ", object = " + object)); } } if (exec == null) { @@ -237,27 +239,27 @@ } if (mch == null) { if (tf != null) { - int count = tf.getChildrenCount (m, object); - mch = tf.getChildren ( - m, - object, - 0, - count + int count = tf.getChildrenCount(m, object); + mch = tf.getChildren( + m, + object, + 0, + count ); if (mch == null) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+tf+"\nreturned null children for parent '"+object+"'"); - mch = new Object[] {}; + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + tf + "\nreturned null children for parent '" + object + "'"); + mch = new Object[]{}; } } else { - int count = m.getChildrenCount (object); - mch = m.getChildren ( - object, - 0, - count + int count = m.getChildrenCount(object); + mch = m.getChildren( + object, + 0, + count ); if (mch == null) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+m+"\nreturned null children for parent '"+object+"'"); - mch = new Object[] {}; + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + m + "\nreturned null children for parent '" + object + "'"); + mch = new Object[]{}; } } synchronized (rootModelsByChildren) { @@ -305,14 +307,16 @@ synchronized (rootModelsByChildren) { model = rootModelsByChildren.get(child); } - if (model == null) return ; + if (model == null) { + return; + } try { DefaultTreeExpansionManager.get(model).setChildrenToActOn(getTreeDepth()); - if (model.isExpanded (child)) { - TreeFeatures treeTable = treeModelRoot.getTreeFeatures (); + if (model.isExpanded(child)) { + TreeFeatures treeTable = treeModelRoot.getTreeFeatures(); if (treeTable != null && treeTable.isExpanded(object)) { // Expand the child only if the parent is expanded - treeTable.expandNode (child); + treeTable.expandNode(child); } } } catch (UnknownTypeException ex) { @@ -320,31 +324,32 @@ } @Override - public Node[] createNodes (Object object) { + public Node[] createNodes(Object object) { if (object == WAIT_KEY) { return super.createNodes(object); } - if (object instanceof Exception) - return new Node[] { - new ExceptionNode ((Exception) object) + if (object instanceof Exception) { + return new Node[]{ + new ExceptionNode((Exception) object) }; + } Models.CompoundModel m; synchronized (rootModelsByChildren) { m = rootModelsByChildren.get(object); } if (m == null) { //System.err.println("\n\n\n\n!!! NO NODE for object "+object+"!!!\n\n\n"); - return new Node[] {}; + return new Node[]{}; } - TreeModelNode tmn = new TreeModelNode ( - m, - createHyperColumns(model.getColumns(), m.getColumns()), - treeModelRoot, - object + TreeModelNode tmn = new TreeModelNode( + m, + createHyperColumns(model.getColumns(), m.getColumns()), + treeModelRoot, + object ); //System.err.println("created node for ("+object+") = "+tmn); - objectToNode.put (object, new WeakReference(tmn)); - return new Node[] {tmn}; + objectToNode.put(object, new WeakReference<>(tmn)); + return new Node[]{tmn}; } private static ColumnModel[] createHyperColumns(ColumnModel[] mainColumns, ColumnModel[] columns) { @@ -372,7 +377,7 @@ this.models.addAll(((HyperRefreshingInfo) rinfo).models); } catch (UnsupportedOperationException uoex) { // add not supported, probably a non-modifiable set - this.models = new HashSet(models); + this.models = new HashSet<>(models); this.models.addAll(((HyperRefreshingInfo) rinfo).models); } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelNode.java spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelNode.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelNode.java 2016-02-04 02:55:43.084100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelNode.java 2016-11-03 07:23:29.835689349 +0100 @@ -41,18 +41,16 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; -import java.awt.Component; import java.awt.Image; import java.awt.datatransfer.Transferable; import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyEditor; -import java.lang.ref.WeakReference; import java.io.IOException; +import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; import java.text.Format; @@ -62,8 +60,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -75,13 +71,10 @@ import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.JTable; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; - import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import org.netbeans.spi.viewmodel.AsynchronousModelFilter; @@ -92,7 +85,6 @@ import org.netbeans.spi.viewmodel.Models.TreeFeatures; import org.netbeans.spi.viewmodel.UnknownTypeException; import org.netbeans.swing.etable.ETableColumn; - import org.openide.awt.Actions; import org.openide.explorer.view.CheckableNode; import org.openide.nodes.AbstractNode; @@ -106,117 +98,114 @@ import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.util.RequestProcessor.Task; -import org.openide.util.actions.CallableSystemAction; import org.openide.util.datatransfer.PasteType; import org.openide.util.lookup.Lookups; - +import org.openide.util.lookup.ProxyLookup; /** * - * @author Jan Jancura + * @author Jan Jancura */ public class TreeModelNode extends AbstractNode { /** - * The maximum length of text that is interpreted as HTML. - * This is documented at openide/explorer/src/org/openide/explorer/doc-files/propertyViewCustomization.html + * The maximum length of text that is interpreted as HTML. This is + * documented at + * openide/explorer/src/org/openide/explorer/doc-files/propertyViewCustomization.html */ private static final int MAX_HTML_LENGTH = 511; private static final String HTML_START_TAG = ""; private static final String HTML_END_TAG = ""; - - // variables ............................................................... + // variables ............................................................... private Models.CompoundModel model; - private final ColumnModel[] columns; - protected TreeModelRoot treeModelRoot; - protected Object object; + private final ColumnModel[] columns; + protected TreeModelRoot treeModelRoot; + protected Object object; private final LazyChildrenFactory lazyChildren; - private String displayName, oldDisplayName; - private String htmlDisplayName; - private final Object displayNameLock = new Object(); - private boolean iconLoaded; - private String shortDescription; - private final Object shortDescriptionLock = new Object(); + private String displayName, oldDisplayName; + private String htmlDisplayName; + private final Object displayNameLock = new Object(); + private boolean iconLoaded; + private String shortDescription; + private final Object shortDescriptionLock = new Object(); private final Map properties = new HashMap(); private final Map columnIDsMap; private static final String EVALUATING_STR = NbBundle.getMessage(TreeModelNode.class, "EvaluatingProp"); - // init .................................................................... - /** - * Creates root of call stack for given producer. - */ - public TreeModelNode ( - final Models.CompoundModel model, - final TreeModelRoot treeModelRoot, - final Object object + * Creates root of call stack for given producer. + */ + public TreeModelNode( + final Models.CompoundModel model, + final TreeModelRoot treeModelRoot, + final Object object ) { this( - model, - model.getColumns (), - treeModelRoot, - object + model, + model.getColumns(), + treeModelRoot, + object ); } /** - * Creates root of call stack for given producer. - */ - public TreeModelNode ( - final Models.CompoundModel model, - final ColumnModel[] columns, - final TreeModelRoot treeModelRoot, - final Object object + * Creates root of call stack for given producer. + */ + public TreeModelNode( + final Models.CompoundModel model, + final ColumnModel[] columns, + final TreeModelRoot treeModelRoot, + final Object object ) { this( - model, - columns, - object != model.getRoot() ? - new LazyChildrenFactory(model, columns, treeModelRoot, object) : null, - object != model.getRoot() ? - null : createChildren (model, columns, treeModelRoot, object), - treeModelRoot, - object + model, + columns, + object != model.getRoot() + ? new LazyChildrenFactory(model, columns, treeModelRoot, object) : null, + object != model.getRoot() + ? null : createChildren(model, columns, treeModelRoot, object), + treeModelRoot, + object ); } /** - * Creates root of call stack for given producer. - */ - protected TreeModelNode ( - final Models.CompoundModel model, - final ColumnModel[] columns, - final LazyChildrenFactory lazyChildren, - final Children children, - final TreeModelRoot treeModelRoot, - final Object object + * Creates root of call stack for given producer. + */ + protected TreeModelNode( + final Models.CompoundModel model, + final ColumnModel[] columns, + final LazyChildrenFactory lazyChildren, + final Children children, + final TreeModelRoot treeModelRoot, + final Object object ) { this( - model, - columns, - lazyChildren, - children, - treeModelRoot, - object, - new Index[] { null }); - } - - private TreeModelNode ( - final Models.CompoundModel model, - final ColumnModel[] columns, - final LazyChildrenFactory lazyChildren, - final Children children, - final TreeModelRoot treeModelRoot, - final Object object, - final Index[] indexPtr // Hack, because we can not declare variables before call to super() :-( + model, + columns, + lazyChildren, + children, + treeModelRoot, + object, + new Index[]{null}); + } + + private TreeModelNode( + final Models.CompoundModel model, + final ColumnModel[] columns, + final LazyChildrenFactory lazyChildren, + final Children children, + final TreeModelRoot treeModelRoot, + final Object object, + final Index[] indexPtr // Hack, because we can not declare variables before call to super() :-( ) { - super ( - (lazyChildren != null) ? - Children.createLazy(lazyChildren) : children, - createLookup(object, model, children, indexPtr) + super( + (lazyChildren != null) + ? Children.createLazy(lazyChildren) : children, + createLookup(object, model, children, indexPtr) ); this.model = model; this.treeModelRoot = treeModelRoot; @@ -226,48 +215,56 @@ ((IndexImpl) indexPtr[0]).setNode(this); setIndexWatcher(indexPtr[0]); } - + // - // Use the modified CompoundModel class's field to set the + // Use the modified CompoundModel class's field to set the // propertiesHelpID for properties sheets if the model's helpID // has been set if (model.getHelpId() != null) { this.setValue("propertiesHelpID", model.getHelpId()); // NOI18N } // - - treeModelRoot.registerNode (object, this); + + treeModelRoot.registerNode(object, this); this.columnIDsMap = createColumnIDsMap(columns); this.columns = columns; } private static Lookup createLookup(Object object, Models.CompoundModel model, - Children ch, Index[] indexPtr) { + Children ch, Index[] indexPtr) { CheckNodeCookieImpl cnc = new CheckNodeCookieImpl(model, object); boolean canReorder; try { canReorder = model.canReorder(object); } catch (UnknownTypeException ex) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } canReorder = false; } + + Lookup additional; + try { + additional = model.getLookup(object); + } catch (UnknownTypeException ex) { + additional = Lookup.EMPTY; + } + if (canReorder) { Index i = new IndexImpl(model, object); indexPtr[0] = i; - return Lookups.fixed(object, cnc, i); + return new ProxyLookup(Lookups.fixed(object, cnc, i), additional); } else { - return Lookups.fixed(object, cnc); + return new ProxyLookup(Lookups.fixed(object, cnc), additional); } } - + private static Map createColumnIDsMap(ColumnModel[] columns) { Map cids = null; for (ColumnModel cm : columns) { if (cm instanceof HyperColumnModel) { if (cids == null) { - cids = new HashMap(); + cids = new HashMap<>(); } HyperColumnModel hcm = (HyperColumnModel) cm; String mainID = cm.getID(); @@ -291,7 +288,7 @@ childrenIndex.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (!areChildrenInitialized()) { - return ; + return; } Children ch = getChildren(); if (ch instanceof TreeModelChildren) { @@ -307,52 +304,52 @@ exec = model.asynchronous(asynchCall, object); //System.err.println("Asynchronous("+asynchCall+", "+object+") = "+exec); if (exec == null) { - Exceptions.printStackTrace(Exceptions.attachMessage(new NullPointerException("Provided executor is null."), "model = "+model+", object = "+object)); + Exceptions.printStackTrace(Exceptions.attachMessage(new NullPointerException("Provided executor is null."), "model = " + model + ", object = " + object)); exec = AsynchronousModelFilter.CURRENT_THREAD; } } catch (Exception ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "model = "+model+", object = "+object)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "model = " + model + ", object = " + object)); exec = AsynchronousModelFilter.CURRENT_THREAD; } return exec; } - // Node implementation ..................................................... - @Override protected Sheet createSheet() { Sheet sheet = Sheet.createDefault(); - Sheet.Set ps = Sheet.createPropertiesSet (); + Sheet.Set ps = Sheet.createPropertiesSet(); int i, k = columns.length; - for (i = 0; i < k; i++) - ps.put (new MyProperty (columns [i], treeModelRoot)); - sheet.put (ps); + for (i = 0; i < k; i++) { + ps.put(new MyProperty(columns[i], treeModelRoot)); + } + sheet.put(ps); return sheet; } - private static Children createChildren ( - Models.CompoundModel model, - ColumnModel[] columns, - TreeModelRoot treeModelRoot, - Object object + private static Children createChildren( + Models.CompoundModel model, + ColumnModel[] columns, + TreeModelRoot treeModelRoot, + Object object ) { - if (object == null) - throw new NullPointerException (); + if (object == null) { + throw new NullPointerException(); + } try { - return model.isLeaf (object) ? - Children.LEAF : - new TreeModelChildren (model, columns, treeModelRoot, object); + return model.isLeaf(object) + ? Children.LEAF + : new TreeModelChildren(model, columns, treeModelRoot, object); } catch (UnknownTypeException e) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); } return Children.LEAF; } } @Override - public String getShortDescription () { + public String getShortDescription() { synchronized (shortDescriptionLock) { if (shortDescription != null) { return shortDescription; @@ -374,7 +371,7 @@ private String updateShortDescription() { try { - String sd = model.getShortDescription (object); + String sd = model.getShortDescription(object); if (sd != null) { sd = adjustHTML(sd); } @@ -384,7 +381,7 @@ return sd; } catch (UnknownTypeException e) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); } return null; } @@ -396,16 +393,16 @@ } fireShortDescriptionChange(null, null); } - + @Override - public String getHtmlDisplayName () { + public String getHtmlDisplayName() { synchronized (displayNameLock) { // Compute the HTML display name if the ordinary display name is not available (e.g. was reset) if (displayName == null) { try { setModelDisplayName(); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } } if (displayName == null) { @@ -414,22 +411,23 @@ return htmlDisplayName; } } - + @Override - public Action[] getActions (boolean context) { + public Action[] getActions(boolean context) { Action[] actions; - if (context) - actions = treeModelRoot.getRootNode ().getActions (false); + if (context) { + actions = treeModelRoot.getRootNode().getActions(false); + } try { - actions = filterActionsWhenSorted(model.getActions (object)); + actions = filterActionsWhenSorted(model.getActions(object)); } catch (UnknownTypeException e) { // NodeActionsProvider is voluntary - actions = new Action [0]; + actions = new Action[0]; } presetActionNodes(actions); return actions; } - + private void presetActionNodes(Action[] actions) { for (Action a : actions) { if (a instanceof ActionOnPresetNodes) { @@ -456,7 +454,9 @@ } for (int i = 0; i < actions.length; i++) { Action a = actions[i]; - if (a == null) continue; + if (a == null) { + continue; + } boolean disabled = Boolean.TRUE.equals(a.getValue("DisabledWhenInSortedTable")); // NOI18N if (disabled) { if (a instanceof DisableableAction) { @@ -476,29 +476,32 @@ } @Override - public Action getPreferredAction () { - return new AbstractAction () { - public void actionPerformed (ActionEvent e) { + public Action getPreferredAction() { + return new AbstractAction() { + public void actionPerformed(ActionEvent e) { try { - model.performDefaultAction (object); + model.performDefaultAction(object); } catch (UnknownTypeException ex) { // NodeActionsProvider is voluntary } } }; } - + @Override - public boolean canDestroy () { + public boolean canDestroy() { try { - Action[] as = model.getActions (object); + Action[] as = model.getActions(object); int i, k = as.length; for (i = 0; i < k; i++) { - if (as [i] == null) continue; - Object key = as [i].getValue (Action.ACCELERATOR_KEY); - if ( (key != null) && - (key.equals (KeyStroke.getKeyStroke ("DELETE"))) - ) return as [i].isEnabled (); + if (as[i] == null) { + continue; + } + Object key = as[i].getValue(Action.ACCELERATOR_KEY); + if ((key != null) + && (key.equals(KeyStroke.getKeyStroke("DELETE")))) { + return as[i].isEnabled(); + } } return false; } catch (UnknownTypeException e) { @@ -506,72 +509,72 @@ return false; } } - + @Override - public boolean canCopy () { + public boolean canCopy() { try { return model.canCopy(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); return false; } } - + @Override - public boolean canCut () { + public boolean canCut() { try { return model.canCut(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); return false; } } - + @Override - public void destroy () { + public void destroy() { try { - Action[] as = model.getActions (object); + Action[] as = model.getActions(object); int i, k = as.length; for (i = 0; i < k; i++) { - if (as [i] == null) continue; - Object key = as [i].getValue (Action.ACCELERATOR_KEY); - if ( (key != null) && - (key.equals (KeyStroke.getKeyStroke ("DELETE"))) - ) { - as [i].actionPerformed (null); + if (as[i] == null) { + continue; + } + Object key = as[i].getValue(Action.ACCELERATOR_KEY); + if ((key != null) + && (key.equals(KeyStroke.getKeyStroke("DELETE")))) { + as[i].actionPerformed(null); return; } } } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); } if (model.getRoot() == object) { treeModelRoot.destroy(); } } - // other methods ........................................................... - - void setObject (Object o) { + void setObject(Object o) { setObject(model, o); } - - void setObject (Models.CompoundModel model, Object o) { - setObjectNoRefresh (o); - refresh (model); + + void setObject(Models.CompoundModel model, Object o) { + setObjectNoRefresh(o); + refresh(model); } - private void setObjectNoRefresh (Object o) { + private void setObjectNoRefresh(Object o) { object = o; if (areChildrenInitialized()) { - Children ch = getChildren (); - if (ch instanceof TreeModelChildren) + Children ch = getChildren(); + if (ch instanceof TreeModelChildren) { ((TreeModelChildren) ch).object = o; + } } } - - public Object getObject () { + + public Object getObject() { return object; } @@ -582,24 +585,23 @@ private Task refreshTask; private final Object refreshTaskLock = new Object(); private final Set childrenRefreshModels = new HashSet(); - - void refresh (Models.CompoundModel model) { + + void refresh(Models.CompoundModel model) { //System.err.println("TreeModelNode.refresh("+model+") on "+object); //Thread.dumpStack(); // 1) empty cache synchronized (properties) { properties.clear(); } - - + // 2) refresh name, displayName and iconBase synchronized (childrenRefreshModels) { childrenRefreshModels.add(model); } synchronized (refreshTaskLock) { if (refreshTask == null) { - refreshTask = getRequestProcessor ().create (new Runnable () { - public void run () { + refreshTask = getRequestProcessor().create(new Runnable() { + public void run() { if (!SwingUtilities.isEventDispatchThread()) { try { SwingUtilities.invokeAndWait(this); @@ -607,9 +609,9 @@ } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); } - return ; + return; } - refreshNode (); + refreshNode(); doFireShortDescriptionChange(); // 3) refresh children @@ -627,11 +629,11 @@ refreshTask.schedule(10); } } - - void refresh (final Models.CompoundModel model, int changeMask) { + + void refresh(final Models.CompoundModel model, int changeMask) { if (changeMask == 0xFFFFFFFF) { refresh(model); - return ; + return; } boolean refreshed = false; if ((ModelEvent.NodeChanged.DISPLAY_NAME_MASK & changeMask) != 0) { @@ -664,8 +666,8 @@ doRefresh = childrenRefreshModels.add(model); } if (doRefresh) { - SwingUtilities.invokeLater (new Runnable () { - public void run () { + SwingUtilities.invokeLater(new Runnable() { + public void run() { synchronized (childrenRefreshModels) { childrenRefreshModels.remove(model); } @@ -676,8 +678,8 @@ refreshed = true; } if ((ModelEvent.NodeChanged.EXPANSION_MASK & changeMask) != 0) { - SwingUtilities.invokeLater (new Runnable () { - public void run () { + SwingUtilities.invokeLater(new Runnable() { + public void run() { expandIfSetToExpanded(); } }); @@ -686,32 +688,34 @@ refresh(model); } } - + private static RequestProcessor requestProcessor; + // Accessed from test - RequestProcessor getRequestProcessor () { + RequestProcessor getRequestProcessor() { /*RequestProcessor rp = treeModelRoot.getRequestProcessor(); - if (rp != null) { - return rp; - }*/ + if (rp != null) { + return rp; + }*/ synchronized (TreeModelNode.class) { - if (requestProcessor == null) - requestProcessor = new RequestProcessor ("TreeModel", 1); + if (requestProcessor == null) { + requestProcessor = new RequestProcessor("TreeModel", 1); + } return requestProcessor; } } - private boolean setName (String name, boolean italics) { + private boolean setName(String name, boolean italics) { // XXX HACK: HTMLDisplayName is missing in the models! synchronized (displayNameLock) { String oldHtmlDisplayName = htmlDisplayName; String _oldDisplayName = oldDisplayName; String newDisplayName; - if (name.startsWith (HTML_START_TAG)) { + if (name.startsWith(HTML_START_TAG)) { htmlDisplayName = name; newDisplayName = removeHTML(name); - } else if (name.startsWith ("<_html>")) { //[TODO] use empty string as name in the case of <_html> tag + } else if (name.startsWith("<_html>")) { //[TODO] use empty string as name in the case of <_html> tag htmlDisplayName = '<' + name.substring(2); newDisplayName = ""; } else { @@ -720,11 +724,11 @@ } displayName = newDisplayName; oldDisplayName = newDisplayName; - return _oldDisplayName == null || !_oldDisplayName.equals(newDisplayName) || - oldHtmlDisplayName == null || !oldHtmlDisplayName.equals(htmlDisplayName); + return _oldDisplayName == null || !_oldDisplayName.equals(newDisplayName) + || oldHtmlDisplayName == null || !oldHtmlDisplayName.equals(htmlDisplayName); } } - + private String parseDisplayFormat(String name) { MessageFormat treeNodeDisplayFormat = treeModelRoot.getTreeNodeDisplayFormat(); if (treeNodeDisplayFormat == null) { @@ -742,13 +746,13 @@ String[] argsHTML = new String[n]; boolean nonEmptyArgs = false; for (int i = 0; i < n; i++) { - if (pattern.indexOf("{"+i) >= 0) { - //if (formatsByArgumentIndex[i] != null) { + if (pattern.indexOf("{" + i) >= 0) { + //if (formatsByArgumentIndex[i] != null) { if (columns[i].getType() == null) { - if (name.startsWith (HTML_START_TAG)) { + if (name.startsWith(HTML_START_TAG)) { argsHTML[i] = name; args[i] = removeHTML(name); - } else if (name.startsWith ("<_html>")) { + } else if (name.startsWith("<_html>")) { argsHTML[i] = '<' + name.substring(2); args[i] = removeHTML((String) argsHTML[i]); } else { @@ -792,14 +796,14 @@ } String format = treeNodeDisplayFormat.format(args); if (isHTML) { - format = HTML_START_TAG+format+HTML_END_TAG; + format = HTML_START_TAG + format + HTML_END_TAG; } return format; //new Object[] { name }); } else { return name; } } - + private static String stripHTMLTags(String str) { if (str.startsWith(HTML_START_TAG)) { str = str.substring(HTML_START_TAG.length()); @@ -809,16 +813,16 @@ } return str; } - + private PropertyDisplayNameListener propertyDisplayNameListener; - + private class PropertyDisplayNameListener implements PropertyChangeListener { - + private Set propertyNames = new HashSet(); - + PropertyDisplayNameListener() { } - + void addPropertyName(String propertyName) { propertyNames.add(propertyName); } @@ -830,27 +834,27 @@ setModelDisplayName(); fireDisplayNameChange(null, null); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } } } - + } private void setModelDisplayName() throws UnknownTypeException { Executor exec = asynchronous(model, CALL.DISPLAY_NAME, object); if (exec == AsynchronousModelFilter.CURRENT_THREAD) { - String name = model.getDisplayName (object); + String name = model.getDisplayName(object); if (name == null) { - Throwable t = - new NullPointerException ( - "Model: " + model + ".getDisplayName (" + object + - ") = null!" - ); + Throwable t + = new NullPointerException( + "Model: " + model + ".getDisplayName (" + object + + ") = null!" + ); Exceptions.printStackTrace(t); } else { name = parseDisplayFormat(name); - setName (name, false); + setName(name, false); } } else { final String originalDisplayName = (oldDisplayName != null) ? oldDisplayName : ""; @@ -861,24 +865,22 @@ try { name = model.getDisplayName(object); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); setName(originalDisplayName, false); fireDisplayNameChange(null, originalDisplayName); - return ; + return; } if (name == null) { - Throwable t = - new NullPointerException ( - "Model: " + model + ".getDisplayName (" + object + - ") = null!" - ); + Throwable t + = new NullPointerException( + "Model: " + model + ".getDisplayName (" + object + + ") = null!" + ); Exceptions.printStackTrace(t); setName(originalDisplayName, false); fireDisplayNameChange(null, originalDisplayName); - } else { - if (setName (name, false)) { - fireDisplayNameChange(null, name); - } + } else if (setName(name, false)) { + fireDisplayNameChange(null, name); } } }); @@ -892,7 +894,7 @@ try { setModelDisplayName(); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } } if (displayName == null) { @@ -907,7 +909,7 @@ String sOld; synchronized (displayNameLock) { if ((displayName != null) && displayName.equals(s)) { - return ; + return; } sOld = displayName; displayName = oldDisplayName = s; @@ -918,21 +920,32 @@ private void setModelIcon() throws UnknownTypeException { String iconBase = null; if (model.getRoot() != object) { - iconBase = model.getIconBaseWithExtension (object); + iconBase = model.getIconBaseWithExtension(object); + } + if (iconBase != null) { + setIconBaseWithExtension(iconBase); + } else { + setIconBaseWithExtension("org/openide/resources/actions/empty.gif"); } - if (iconBase != null) - setIconBaseWithExtension (iconBase); - else - setIconBaseWithExtension ("org/openide/resources/actions/empty.gif"); } @Override public Image getIcon(int type) { + + try { + Image icon = model.getIcon(object, type); + if (icon != null) { + return icon; + } + } catch (UnknownTypeException ex) { + Logger.getLogger(TreeModelNode.class.getName()).log(Level.FINE, "no icon from model"); // NOI18N + } + if (!iconLoaded) { try { setModelIcon(); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } iconLoaded = true; } @@ -941,18 +954,27 @@ @Override public Image getOpenedIcon(int type) { + try { + Image icon = model.getOpenedIcon(object, type); + if (icon != null) { + return icon; + } + } catch (UnknownTypeException ex) { + Logger.getLogger(TreeModelNode.class.getName()).log(Level.FINE, "no openedIcon from model"); // NOI18N + } + if (!iconLoaded) { try { setModelIcon(); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } iconLoaded = true; } return super.getOpenedIcon(type); } - private void refreshNode () { + private void refreshNode() { boolean doFireDisplayNameChange; synchronized (displayNameLock) { doFireDisplayNameChange = displayName != null; @@ -969,7 +991,7 @@ } firePropertyChange(null, null, null); } - + void refreshColumn(String column, int changeMask) { String visualColumn = column; if (columnIDsMap != null) { @@ -989,7 +1011,7 @@ properties.remove(column + "#canWrite"); } } - + firePropertyChange(visualColumn, null, null); } @@ -998,17 +1020,18 @@ * @param refreshSubNodes If recursively refresh subnodes. */ protected void refreshTheChildren(Set models, TreeModelChildren.RefreshingInfo refreshInfo) { - for (Models.CompoundModel model: models) { + for (Models.CompoundModel model : models) { refreshTheChildren(model, refreshInfo); } } + /** * @param model The associated model - necessary for hyper node. * @param refreshSubNodes If recursively refresh subnodes. */ private void refreshTheChildren(Models.CompoundModel model, TreeModelChildren.RefreshingInfo refreshInfo) { if (!areChildrenInitialized()) { - return ; + return; } Children ch = getChildren(); try { @@ -1018,20 +1041,22 @@ } else { ((TreeModelChildren) ch).refreshChildren(refreshInfo); } - } else if (!model.isLeaf (object)) { - setChildren(new TreeModelChildren (model, columns, treeModelRoot, object)); + } else if (!model.isLeaf(object)) { + setChildren(new TreeModelChildren(model, columns, treeModelRoot, object)); } } catch (UnknownTypeException utex) { // not known - do not change children if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, utex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, utex); } setChildren(Children.LEAF); } } - - private static String htmlValue (String name) { - if (!(name.length() > 6 && name.substring(0, 6).equalsIgnoreCase(HTML_START_TAG))) return null; + + private static String htmlValue(String name) { + if (!(name.length() > 6 && name.substring(0, 6).equalsIgnoreCase(HTML_START_TAG))) { + return null; + } if (name.length() > MAX_HTML_LENGTH) { int endTagsPos = findEndTagsPos(name); String ending = name.substring(endTagsPos + 1); @@ -1051,43 +1076,48 @@ } return adjustHTML(name); } - + private static int findEndTagsPos(String s) { int openings = 0; int i; for (i = s.length() - 1; i >= 0; i--) { - if (s.charAt(i) == '>') openings++; - else if (s.charAt(i) == '<') openings--; - else if (openings == 0) break; + if (s.charAt(i) == '>') { + openings++; + } else if (s.charAt(i) == '<') { + openings--; + } else if (openings == 0) { + break; + } } return i; } - - private static String removeHTML (String text) { + + private static String removeHTML(String text) { if (!(text.length() > 6 && text.substring(0, 6).equalsIgnoreCase(HTML_START_TAG))) { return text; } - text = text.replaceAll ("", ""); - text = text.replaceAll ("", ""); - text = text.replaceAll ("", ""); - text = text.replaceAll ("", ""); - text = text.replaceAll (HTML_START_TAG, ""); - text = text.replaceAll (HTML_END_TAG, ""); - text = text.replaceAll ("", ""); - int i = text.indexOf ("", ""); + text = text.replaceAll("", ""); + text = text.replaceAll("", ""); + text = text.replaceAll("", ""); + text = text.replaceAll(HTML_START_TAG, ""); + text = text.replaceAll(HTML_END_TAG, ""); + text = text.replaceAll("", ""); + int i = text.indexOf("= 0) { - int j = text.indexOf (">", i); - text = text.substring (0, i) + text.substring (j + 1); - i = text.indexOf (""); - text = text.replaceAll ("&", "&"); + int j = text.indexOf(">", i); + text = text.substring(0, i) + text.substring(j + 1); + i = text.indexOf(""); + text = text.replaceAll("&", "&"); return text; } - - /** Adjusts HTML text so that it's rendered correctly. - * In particular, this assures that white characters are visible. + + /** + * Adjusts HTML text so that it's rendered correctly. In particular, this + * assures that white characters are visible. */ private static String adjustHTML(String text) { text = text.replaceAll(java.util.regex.Matcher.quoteReplacement("\\"), "\\\\\\\\"); @@ -1112,7 +1142,7 @@ sb.append(text.substring(j, i)); } sb.append(replacement); - j = i+1; + j = i + 1; } } if (sb == null) { @@ -1122,14 +1152,13 @@ return sb.toString(); } } - - + @Override public boolean canRename() { try { return model.canRename(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); return false; } } @@ -1140,17 +1169,17 @@ model.setName(object, s); super.setName(s); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); } } - + @Override public Transferable clipboardCopy() throws IOException { Transferable t; try { t = model.clipboardCopy(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); t = null; } if (t == null) { @@ -1159,14 +1188,14 @@ return t; } } - + @Override public Transferable clipboardCut() throws IOException { Transferable t; try { t = model.clipboardCut(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); t = null; } if (t == null) { @@ -1175,14 +1204,14 @@ return t; } } - + @Override public Transferable drag() throws IOException { Transferable t; try { t = model.drag(object); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); t = null; } if (t == null) { @@ -1191,14 +1220,14 @@ return t; } } - + @Override public void createPasteTypes(Transferable t, List l) { PasteType[] p; try { p = model.getPasteTypes(object, t); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); p = null; } if (p == null) { @@ -1207,14 +1236,14 @@ l.addAll(Arrays.asList(p)); } } - + @Override public PasteType getDropType(Transferable t, int action, int index) { PasteType p; try { p = model.getDropType(object, t, action, index); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); p = null; } if (p == null) { @@ -1223,14 +1252,14 @@ return p; } } - + private final void expandIfSetToExpanded() { try { DefaultTreeExpansionManager.get(model).setChildrenToActOn(getTreeDepth()); - if (model.isExpanded (object)) { - TreeFeatures treeTable = treeModelRoot.getTreeFeatures (); + if (model.isExpanded(object)) { + TreeFeatures treeTable = treeModelRoot.getTreeFeatures(); if (treeTable != null) { - treeTable.expandNode (object); + treeTable.expandNode(object); } } } catch (UnknownTypeException ex) { @@ -1247,33 +1276,35 @@ return depth; } else { int d = 1; - while ((p = p.getParentNode()) != null) d++; + while ((p = p.getParentNode()) != null) { + d++; + } depth = new Integer(d); return depth; } } // innerclasses ............................................................ - public static interface DisableableAction extends Action { Action createDisableable(PrivilegedAction enabledTest); - + } - + /** * An action, that can act on a pre-set set of nodes. */ public static interface ActionOnPresetNodes extends Action { - + /** - * Add a node to act on. - * The set of nodes is cleared in the next cycle of event dispatch loop. - * When no nodes are provided, the TopComponent.getRegistry ().getActivatedNodes () are used. + * Add a node to act on. The set of nodes is cleared in the next cycle + * of event dispatch loop. When no nodes are provided, the + * TopComponent.getRegistry ().getActivatedNodes () are used. + * * @param n a node to act on */ void addNode(Node n); - + } private class DisabledWhenSortedAction implements Action { @@ -1338,7 +1369,7 @@ try { return model.isCheckable(object); } catch (UnknownTypeException ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = "+model)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = " + model)); return false; } } @@ -1347,7 +1378,7 @@ try { return model.isCheckEnabled(object); } catch (UnknownTypeException ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = "+model)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = " + model)); return false; } } @@ -1356,7 +1387,7 @@ try { return model.isSelected(object); } catch (UnknownTypeException ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = "+model)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = " + model)); return false; } } @@ -1365,68 +1396,71 @@ try { model.setSelected(object, selected); } catch (UnknownTypeException ex) { - Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = "+model)); + Exceptions.printStackTrace(Exceptions.attachMessage(ex, "Model = " + model)); } } } - - /** Special locals subnodes (children) */ + + /** + * Special locals subnodes (children) + */ static class TreeModelChildren extends Children.Keys - implements Runnable {// LazyEvaluator.Evaluable { - - private boolean initialezed = false; + implements Runnable {// LazyEvaluator.Evaluable { + + private boolean initialezed = false; private final Models.CompoundModel model; - private final ColumnModel[] columns; - protected final TreeModelRoot treeModelRoot; - protected Object object; + private final ColumnModel[] columns; + protected final TreeModelRoot treeModelRoot; + protected Object object; protected final WeakHashMap> objectToNode = new WeakHashMap>(); - private final int[] evaluated = { 0 }; // 0 - not yet, 1 - evaluated, -1 - timeouted - private RefreshingInfo evaluatingRefreshingInfo; - private Object[] children_evaluated; - private RefreshingInfo refreshInfo = null; - private boolean refreshingStarted = true; - - private RequestProcessor.Task task; - private RequestProcessor lastRp; - + private final int[] evaluated = {0}; // 0 - not yet, 1 - evaluated, -1 - timeouted + private RefreshingInfo evaluatingRefreshingInfo; + private Object[] children_evaluated; + private RefreshingInfo refreshInfo = null; + private boolean refreshingStarted = true; + + private RequestProcessor.Task task; + private RequestProcessor lastRp; + protected static final Object WAIT_KEY = new Object(); - - - TreeModelChildren ( - Models.CompoundModel model, - ColumnModel[] columns, - TreeModelRoot treeModelRoot, - Object object + + TreeModelChildren( + Models.CompoundModel model, + ColumnModel[] columns, + TreeModelRoot treeModelRoot, + Object object ) { this.model = model; this.columns = columns; this.treeModelRoot = treeModelRoot; this.object = object; } - + @Override - protected void addNotify () { + protected void addNotify() { if (initialezed) { //System.err.println("\n\nTreeModelChildren.addNotify() called more that once! Parent = "+getNode()+"\n\n"); - return ; + return; } initialezed = true; - refreshChildren (new RefreshingInfo(true)); + refreshChildren(new RefreshingInfo(true)); } - + @Override - protected void removeNotify () { + protected void removeNotify() { initialezed = false; - setKeys (Collections.emptySet()); + setKeys(Collections.emptySet()); } - - void refreshChildren (RefreshingInfo refreshSubNodes) { - if (!initialezed) return; + + void refreshChildren(RefreshingInfo refreshSubNodes) { + if (!initialezed) { + return; + } refreshLazyChildren(refreshSubNodes); } - + public void run() { RefreshingInfo rinfo; synchronized (evaluated) { @@ -1434,10 +1468,8 @@ rinfo = refreshInfo; if (evaluatingRefreshingInfo == null) { evaluatingRefreshingInfo = refreshInfo; - } else { - if (refreshInfo != null) { - evaluatingRefreshingInfo = evaluatingRefreshingInfo.mergeWith(refreshInfo); - } + } else if (refreshInfo != null) { + evaluatingRefreshingInfo = evaluatingRefreshingInfo.mergeWith(refreshInfo); } refreshInfo = null; // reset after use } @@ -1445,9 +1477,9 @@ try { ch = getModelChildren(rinfo); } catch (UnknownTypeException e) { - ch = new Object [0]; + ch = new Object[0]; if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, e); } } catch (ThreadDeath td) { throw td; @@ -1482,15 +1514,15 @@ protected Object[] getModelChildren(RefreshingInfo refreshInfo) throws UnknownTypeException { //System.err.println("! getModelChildren("+object+", "+getNode()+")"); - int count = model.getChildrenCount (object); - Object[] ch = model.getChildren ( - object, - 0, - count + int count = model.getChildrenCount(object); + Object[] ch = model.getChildren( + object, + 0, + count ); if (ch == null) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model+"\nreturned null children for parent '"+object+"'"); - ch = new Object[] {}; + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model + "\nreturned null children for parent '" + object + "'"); + ch = new Object[]{}; } return ch; } @@ -1498,8 +1530,8 @@ protected Executor getModelAsynchronous() { return asynchronous(model, CALL.CHILDREN, object); } - - private void refreshLazyChildren (RefreshingInfo refreshInfo) { + + private void refreshLazyChildren(RefreshingInfo refreshInfo) { //System.err.println("\n!! refreshLazyChildren("+getNode()+") from:"); //Thread.dumpStack(); //System.err.println(""); @@ -1509,13 +1541,13 @@ try { ch = getModelChildren(refreshInfo); } catch (UnknownTypeException ex) { - ch = new Object [0]; + ch = new Object[0]; if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } } applyChildren(ch, refreshInfo, true); - return ; + return; } synchronized (evaluated) { evaluated[0] = 0; @@ -1528,15 +1560,15 @@ //System.err.println(this.hashCode()+" refreshLazyChildren() started = true, evaluated = 0"); } /*if (exec instanceof RequestProcessor) { - // Have a single task for RP - RequestProcessor rp = (RequestProcessor) exec; - if (rp != lastRp) { - task = rp.create(this); - lastRp = rp; - } - task.schedule(0); - } else {*/ - exec.execute(this); + // Have a single task for RP + RequestProcessor rp = (RequestProcessor) exec; + if (rp != lastRp) { + task = rp.create(this); + lastRp = rp; + } + task.schedule(0); + } else {*/ + exec.execute(this); //} // It's refresh => do not check for this children already being evaluated //treeModelRoot.getChildrenEvaluator().evaluate(this, false); @@ -1545,7 +1577,8 @@ if (evaluated[0] != 1) { try { evaluated.wait(getChildrenRefreshWaitTime()); - } catch (InterruptedException iex) {} + } catch (InterruptedException iex) { + } if (evaluated[0] != 1) { evaluated[0] = -1; // timeout ch = null; @@ -1557,7 +1590,9 @@ } //System.err.println(this.hashCode()+" refreshLazyChildren() ending, evaluated[0] = "+evaluated[0]+", refreshingStarted = "+refreshingStarted+", children_evaluated = "+(children_evaluated != null)+", ch = "+(ch != null)); // Do nothing when it's evaluated, but already unset. - if (children_evaluated == null && evaluated[0] == 1) return; + if (children_evaluated == null && evaluated[0] == 1) { + return; + } children_evaluated = null; if (ch != null) { refreshInfo = evaluatingRefreshingInfo; @@ -1574,7 +1609,7 @@ } private static AtomicLong lastChildrenRefresh = new AtomicLong(0); - + private static long getChildrenRefreshWaitTime() { long now = System.currentTimeMillis(); long last = lastChildrenRefresh.getAndSet(now); @@ -1585,57 +1620,62 @@ return 200; } } - + private void applyChildren(final Object[] ch, RefreshingInfo refreshInfo, boolean doSetObject) { //System.err.println(this.hashCode()+" applyChildren("+refreshSubNodes+")"); //System.err.println("applyChildren("+Arrays.toString(ch)+", "+doSetObject+")"); - int i, k = ch.length; + int i, k = ch.length; for (i = 0; i < k; i++) { - if (ch [i] == null) { - throw new NullPointerException("Null child at index "+i+", parent: "+object+", model: "+model+"\nAll children are: "+Arrays.toString(ch)); + if (ch[i] == null) { + throw new NullPointerException("Null child at index " + i + ", parent: " + object + ", model: " + model + "\nAll children are: " + Arrays.toString(ch)); } if (doSetObject) { WeakReference wr; synchronized (objectToNode) { - wr = objectToNode.get(ch [i]); + wr = objectToNode.get(ch[i]); + } + if (wr == null) { + continue; + } + TreeModelNode tmn = wr.get(); + if (tmn == null) { + continue; } - if (wr == null) continue; - TreeModelNode tmn = wr.get (); - if (tmn == null) continue; if (refreshInfo == null || refreshInfo.isRefreshSubNodes(ch[i])) { - tmn.setObject (ch [i]); + tmn.setObject(ch[i]); } else { tmn.setObjectNoRefresh(ch[i]); } } } - setKeys (ch); + setKeys(ch); - SwingUtilities.invokeLater (new Runnable () { - public void run () { + SwingUtilities.invokeLater(new Runnable() { + public void run() { int i, k = ch.length; - for (i = 0; i < k; i++) + for (i = 0; i < k; i++) { expandIfSetToExpanded(ch[i]); + } } }); } - + protected void expandIfSetToExpanded(Object child) { try { DefaultTreeExpansionManager.get(model).setChildrenToActOn(getTreeDepth()); - if (model.isExpanded (child)) { - TreeFeatures treeTable = treeModelRoot.getTreeFeatures (); + if (model.isExpanded(child)) { + TreeFeatures treeTable = treeModelRoot.getTreeFeatures(); if (treeTable != null && treeTable.isExpanded(object)) { // Expand the child only if the parent is expanded - treeTable.expandNode (child); + treeTable.expandNode(child); } } } catch (UnknownTypeException ex) { } } - + private Integer depth; - + Integer getTreeDepth() { Node p = getNode(); if (p == null) { @@ -1644,17 +1684,19 @@ return depth; } else { int d = 1; - while ((p = p.getParentNode()) != null) d++; + while ((p = p.getParentNode()) != null) { + d++; + } depth = new Integer(d); return depth; } } - + private void applyWaitChildren() { //System.err.println(this.hashCode()+" applyWaitChildren()"); - setKeys(new Object[] { WAIT_KEY }); + setKeys(new Object[]{WAIT_KEY}); } - + // protected void destroyNodes (Node[] nodes) { // int i, k = nodes.length; // for (i = 0; i < k; i++) { @@ -1668,29 +1710,29 @@ // nameToChild.remove (name); // } // } - - public Node[] createNodes (Object object) { + public Node[] createNodes(Object object) { if (object == WAIT_KEY) { AbstractNode n = new AbstractNode(Children.LEAF); n.setName(NbBundle.getMessage(TreeModelNode.class, "WaitNode")); n.setIconBaseWithExtension("org/netbeans/modules/viewmodel/wait.gif"); - return new Node[] { n }; + return new Node[]{n}; } - if (object instanceof Exception) - return new Node[] { - new ExceptionNode ((Exception) object) + if (object instanceof Exception) { + return new Node[]{ + new ExceptionNode((Exception) object) }; - TreeModelNode tmn = new TreeModelNode ( - model, - columns, - treeModelRoot, - object + } + TreeModelNode tmn = new TreeModelNode( + model, + columns, + treeModelRoot, + object ); //System.err.println("created node for ("+object+") = "+tmn); synchronized (objectToNode) { - objectToNode.put (object, new WeakReference(tmn)); + objectToNode.put(object, new WeakReference(tmn)); } - return new Node[] {tmn}; + return new Node[]{tmn}; } @Override @@ -1699,7 +1741,7 @@ for (Node n : nodes) { if (n instanceof TreeModelNode) { TreeModelNode tmn = (TreeModelNode) n; - treeModelRoot.unregisterNode (tmn.object, tmn); + treeModelRoot.unregisterNode(tmn.object, tmn); if (tmn.areChildrenInitialized()) { Node[] childrenNodes; try { @@ -1771,7 +1813,7 @@ fireChangeEvent(new ChangeEvent(this)); } catch (UnknownTypeException ex) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model, ex); } } } @@ -1791,9 +1833,9 @@ private volatile boolean childrenCreated = false; LazyChildrenFactory(final Models.CompoundModel model, - final ColumnModel[] columns, - final TreeModelRoot treeModelRoot, - final Object object) { + final ColumnModel[] columns, + final TreeModelRoot treeModelRoot, + final Object object) { this.model = model; this.columns = columns; this.treeModelRoot = treeModelRoot; @@ -1809,7 +1851,7 @@ boolean areChildrenCreated() { return childrenCreated; } - + } // Adaptive property refresh time. Belongs to MyProperty, but can not be there since it's static :-( @@ -1827,51 +1869,51 @@ } private class MyProperty extends PropertySupport implements Runnable { //LazyEvaluator.Evaluable { - - private final String id; - private final String propertyId; + + private final String id; + private final String propertyId; private final ColumnModel columnModel; private final boolean nodeColumn; private TreeModelRoot treeModelRoot; - private final int[] evaluated = { 1 }; // 0 - not yet, 1 - evaluated, -1 - timeouted - - - MyProperty ( - ColumnModel columnModel, TreeModelRoot treeModelRoot + private final int[] evaluated = {1}; // 0 - not yet, 1 - evaluated, -1 - timeouted + + MyProperty( + ColumnModel columnModel, TreeModelRoot treeModelRoot ) { - super ( - columnModel.getID (), - (columnModel.getType() == null) ? String.class : columnModel.getType (), - Actions.cutAmpersand(columnModel.getDisplayName ()), - columnModel.getShortDescription (), - true, - true + super( + columnModel.getID(), + (columnModel.getType() == null) ? String.class : columnModel.getType(), + Actions.cutAmpersand(columnModel.getDisplayName()), + columnModel.getShortDescription(), + true, + true ); this.nodeColumn = columnModel.getType() == null; this.treeModelRoot = treeModelRoot; if (columnModel instanceof HyperColumnModel) { propertyId = columnModel.getID(); // main column ID this.columnModel = ((HyperColumnModel) columnModel).getSpecific(); - id = this.columnModel.getID (); // specific column ID + id = this.columnModel.getID(); // specific column ID } else { - id = propertyId = columnModel.getID (); + id = propertyId = columnModel.getID(); this.columnModel = columnModel; } //System.err.println("new MyProperty("+TreeModelNode.this+", "+id+") = "+this); } - + // A hack - see org/netbeans/modules/debugger/jpda/ui/models/ValuePropertyEditor.java boolean forcedReadOnly; + void forceNotEditable() { forcedReadOnly = true; } /* Can write the value of the property. - * Returns the value passed into constructor. - * @return true if the read of the value is supported - */ + * Returns the value passed into constructor. + * @return true if the read of the value is supported + */ @Override - public boolean canWrite () { + public boolean canWrite() { if (forcedReadOnly) { return false; } @@ -1892,10 +1934,10 @@ canEdit = false; } else { try { - canEdit = !model.isReadOnly (object, columnModel.getID ()); + canEdit = !model.isReadOnly(object, columnModel.getID()); } catch (UnknownTypeException e) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID ()+"\nModel: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID() + "\nModel: " + model, e); } canEdit = false; } @@ -1906,14 +1948,14 @@ } return canEdit; } - + public void run() { Object value = ""; String htmlValue = null; Object nonHtmlValue = null; try { //System.err.println("getValueAt("+object+", "+id+") of node "+TreeModelNode.this); - value = model.getValueAt (object, id); + value = model.getValueAt(object, id); nonHtmlValue = value; boolean hasHTML = model.hasHTMLValueAt(object, id); if (hasHTML) { @@ -1923,15 +1965,15 @@ //System.out.println(" evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value); //System.out.println(" object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null")); if (!hasHTML && (value instanceof String)) { // For backward compatibility - htmlValue = htmlValue ((String) value); - nonHtmlValue = removeHTML ((String) value); + htmlValue = htmlValue((String) value); + nonHtmlValue = removeHTML((String) value); } } catch (UnknownTypeException e) { if (!(object instanceof String)) { - e.printStackTrace (); - System.out.println(" Column id:" + columnModel.getID ()); - System.out.println (model); - System.out.println (); + e.printStackTrace(); + System.out.println(" Column id:" + columnModel.getID()); + System.out.println(model); + System.out.println(); } } catch (Throwable t) { Exceptions.printStackTrace(t); @@ -1939,8 +1981,8 @@ //evaluatedNotify.run(); boolean fire; synchronized (properties) { - properties.put (id, nonHtmlValue); - properties.put (id + "#html", htmlValue); + properties.put(id, nonHtmlValue); + properties.put(id + "#html", htmlValue); synchronized (evaluated) { fire = evaluated[0] == -1; evaluated[0] = 1; @@ -1950,13 +1992,13 @@ } //System.out.println("\nTreeModelNode.evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): value = "+value+", fire = "+fire); if (fire) { - firePropertyChange (propertyId, null, value); + firePropertyChange(propertyId, null, value); } - + } } - - public synchronized Object getValue () { // Sync the calls + + public synchronized Object getValue() { // Sync the calls //System.err.println("TreeModelNode("+object+").getValue("+id+")..."); if (nodeColumn) { return TreeModelNode.this.getDisplayName(); @@ -1964,8 +2006,8 @@ // 1) return value from cache synchronized (properties) { //System.err.println("getValue("+TreeModelNode.this.getDisplayName()+", "+id+"): contains = "+properties.containsKey (id)+", value = "+properties.get (id)+" property object = "+this); - if (properties.containsKey (id)) { - return properties.get (id); + if (properties.containsKey(id)) { + return properties.get(id); } synchronized (evaluated) { //System.err.println(" value of ("+TreeModelNode.this.getDisplayName()+", "+id+") is being evaluated = "+(evaluated[0] != 1)+", evaluated = "+evaluated[0]); @@ -1979,7 +2021,7 @@ } } } - + Executor exec = asynchronous(model, CALL.VALUE, object); if (exec == AsynchronousModelFilter.CURRENT_THREAD) { @@ -1991,25 +2033,26 @@ //System.err.println("Evaluated of ("+TreeModelNode.this.getDisplayName()+", "+id+"): evaluated = "+evaluated[0]); } /*if (exec instanceof RequestProcessor) { - RequestProcessor rp = (RequestProcessor) exec; - if (rp != lastRp) { - task = rp.create(this); - lastRp = rp; - } - task.schedule(0); - } else {*/ + RequestProcessor rp = (RequestProcessor) exec; + if (rp != lastRp) { + task = rp.create(this); + lastRp = rp; + } + task.schedule(0); + } else {*/ //System.err.println("getTheValue of ("+object+", "+id+") executed in "+exec); - exec.execute(this); + exec.execute(this); //} //treeModelRoot.getValuesEvaluator().evaluate(this); - + Object ret = null; - + synchronized (evaluated) { if (evaluated[0] != 1) { try { evaluated.wait(getPropertyRefreshWaitTime()); - } catch (InterruptedException iex) {} + } catch (InterruptedException iex) { + } if (evaluated[0] != 1) { evaluated[0] = -1; // timeout //System.err.println("Timeout of ("+TreeModelNode.this.getDisplayName()+", "+id+"): evaluated = "+evaluated[0]); @@ -2022,11 +2065,11 @@ ret = properties.get(id); } } - - if (ret == EVALUATING_STR && - getValueType() != null && getValueType() != String.class) { + + if (ret == EVALUATING_STR + && getValueType() != null && getValueType() != String.class) { ret = null; // Must not provide String when the property type is different. - // htmlDisplayValue attr will assure that the Evaluating str is there. + // htmlDisplayValue attr will assure that the Evaluating str is there. } return ret; } @@ -2036,7 +2079,7 @@ String htmlValue = null; Object nonHtmlValue = null; try { - value = model.getValueAt (object, id); + value = model.getValueAt(object, id); nonHtmlValue = value; boolean hasHTML = model.hasHTMLValueAt(object, id); if (hasHTML) { @@ -2046,35 +2089,35 @@ //System.out.println(" evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value); //System.out.println(" object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null")); if (!hasHTML && (value instanceof String)) { // For backward compatibility - htmlValue = htmlValue ((String) value); - nonHtmlValue = removeHTML ((String) value); + htmlValue = htmlValue((String) value); + nonHtmlValue = removeHTML((String) value); } } catch (UnknownTypeException e) { if (!(object instanceof String)) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: "+model+"\n,Column id:" + columnModel.getID (), e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Model: " + model + "\n,Column id:" + columnModel.getID(), e); } } finally { synchronized (properties) { - properties.put (id, nonHtmlValue); - properties.put (id + "#html", htmlValue); + properties.put(id, nonHtmlValue); + properties.put(id + "#html", htmlValue); } } return value; } - + @Override - public Object getValue (String attributeName) { - if (attributeName.equals ("htmlDisplayValue")) { + public Object getValue(String attributeName) { + if (attributeName.equals("htmlDisplayValue")) { if (nodeColumn) { return TreeModelNode.this.getHtmlDisplayName(); } synchronized (evaluated) { if (evaluated[0] != 1) { - return HTML_START_TAG+""+EVALUATING_STR+""+HTML_END_TAG; + return HTML_START_TAG + "" + EVALUATING_STR + "" + HTML_END_TAG; } } synchronized (properties) { - return properties.get (id + "#html"); + return properties.get(id + "#html"); } } if (attributeName.equals("suppressCustomEditor")) { @@ -2086,7 +2129,7 @@ } catch (UnknownTypeException ex) { } } - return super.getValue (attributeName); + return super.getValue(attributeName); } @Override @@ -2098,13 +2141,13 @@ if (!properties.containsKey(id)) { return null; // The same as value => EVALUATING_STR } - String shortDescription = (String) properties.get (id + "#shortDescription"); + String shortDescription = (String) properties.get(id + "#shortDescription"); if (shortDescription != null) { return shortDescription; } } Executor exec = asynchronous(model, CALL.SHORT_DESCRIPTION, object); - + if (exec == AsynchronousModelFilter.CURRENT_THREAD) { return updateShortDescription(); } else { @@ -2124,7 +2167,7 @@ String sd = null; try { tooltip.putClientProperty("getShortDescription", object); // NOI18N - Object tooltipObj = model.getValueAt(tooltip, id); + Object tooltipObj = model.getValueAt(object, id); if (tooltipObj != null) { sd = adjustHTML(tooltipObj.toString()); } @@ -2133,7 +2176,7 @@ // We MUST clear the client property, Swing holds this in a static reference! tooltip.putClientProperty("getShortDescription", null); // NOI18N synchronized (properties) { - properties.put (id + "#shortDescription", sd); + properties.put(id + "#shortDescription", sd); } } } catch (UnknownTypeException e) { @@ -2141,9 +2184,9 @@ return null; } } - - public void setValue (final Object value) throws IllegalAccessException, - IllegalArgumentException, java.lang.reflect.InvocationTargetException { + + public void setValue(final Object value) throws IllegalAccessException, + IllegalArgumentException, java.lang.reflect.InvocationTargetException { Executor exec = asynchronous(model, CALL.VALUE, object); if (exec == AsynchronousModelFilter.CURRENT_THREAD) { try { @@ -2165,7 +2208,7 @@ private void setTheValue(final Object value) { try { Object v = value; - model.setValueAt (object, id, v); + model.setValueAt(object, id, v); v = model.getValueAt(object, id); // Store the new value String htmlValue = null; Object nonHtmlValue = v; @@ -2174,29 +2217,29 @@ htmlValue = model.getHTMLValueAt(object, id); } if (!hasHTML && (v instanceof String)) { // For backward compatibility - htmlValue = htmlValue ((String) v); - nonHtmlValue = removeHTML ((String) v); + htmlValue = htmlValue((String) v); + nonHtmlValue = removeHTML((String) v); } synchronized (properties) { - properties.put (id, nonHtmlValue); - properties.put (id + "#html", htmlValue); + properties.put(id, nonHtmlValue); + properties.put(id + "#html", htmlValue); } - firePropertyChange (propertyId, null, null); + firePropertyChange(propertyId, null, null); } catch (UnknownTypeException e) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID ()+"\nModel: "+model, e); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID() + "\nModel: " + model, e); } } - + @Override - public PropertyEditor getPropertyEditor () { + public PropertyEditor getPropertyEditor() { PropertyEditor pe = null; try { pe = model.getPropertyEditor(object, id); } catch (UnknownTypeException ex) { - Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID ()+"\nModel: "+model, ex); + Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID() + "\nModel: " + model, ex); } if (pe == null) { - pe = columnModel.getPropertyEditor (); + pe = columnModel.getPropertyEditor(); } if (pe != null) { return pe; @@ -2207,81 +2250,82 @@ @Override public String toString() { - return super.toString() + ", Value = "+properties.get(id); + return super.toString() + ", Value = " + properties.get(id); } - - } - /** The single-threaded evaluator of lazy models. *//* - static class LazyEvaluator implements Runnable { - - /** Release the evaluator task after this time. *//* - private static final long EXPIRE_TIME = 1000L; - - private final List objectsToEvaluate = new LinkedList(); - private Evaluable currentlyEvaluating; - private Task evalTask; - - public LazyEvaluator(RequestProcessor prefferedRequestProcessor) { - if (prefferedRequestProcessor == null) { - prefferedRequestProcessor = new RequestProcessor("Debugger Values Evaluator", 1); // NOI18N - } - evalTask = prefferedRequestProcessor.create(this, true); - } - - public void evaluate(Evaluable eval) { - evaluate(eval, true); - } - - public void evaluate(Evaluable eval, boolean checkForEvaluating) { - synchronized (objectsToEvaluate) { - for (Iterator it = objectsToEvaluate.iterator(); it.hasNext(); ) { - if (eval == it.next()) return ; // Already scheduled - } - if (checkForEvaluating && currentlyEvaluating == eval) return ; // Is being evaluated - objectsToEvaluate.add(eval); - objectsToEvaluate.notify(); - if (evalTask.isFinished()) { - evalTask.schedule(0); - } - } - } + } - public void run() { - while(true) { - Evaluable eval; - synchronized (objectsToEvaluate) { - if (objectsToEvaluate.size() == 0) { - try { - objectsToEvaluate.wait(EXPIRE_TIME); - } catch (InterruptedException iex) { - return ; - } - if (objectsToEvaluate.size() == 0) { // Expired - return ; - } - } - eval = (Evaluable) objectsToEvaluate.remove(0); - currentlyEvaluating = eval; - } - Runnable evaluatedNotify = new Runnable() { - public void run() { - synchronized (objectsToEvaluate) { - currentlyEvaluating = null; - } - } - }; - eval.evaluateLazily(evaluatedNotify); - } - } + /** + * The single-threaded evaluator of lazy models. + *//* + static class LazyEvaluator implements Runnable { + + /** Release the evaluator task after this time. *//* + private static final long EXPIRE_TIME = 1000L; + + private final List objectsToEvaluate = new LinkedList(); + private Evaluable currentlyEvaluating; + private Task evalTask; + + public LazyEvaluator(RequestProcessor prefferedRequestProcessor) { + if (prefferedRequestProcessor == null) { + prefferedRequestProcessor = new RequestProcessor("Debugger Values Evaluator", 1); // NOI18N + } + evalTask = prefferedRequestProcessor.create(this, true); + } + + public void evaluate(Evaluable eval) { + evaluate(eval, true); + } + + public void evaluate(Evaluable eval, boolean checkForEvaluating) { + synchronized (objectsToEvaluate) { + for (Iterator it = objectsToEvaluate.iterator(); it.hasNext(); ) { + if (eval == it.next()) return ; // Already scheduled + } + if (checkForEvaluating && currentlyEvaluating == eval) return ; // Is being evaluated + objectsToEvaluate.add(eval); + objectsToEvaluate.notify(); + if (evalTask.isFinished()) { + evalTask.schedule(0); + } + } + } + + public void run() { + while(true) { + Evaluable eval; + synchronized (objectsToEvaluate) { + if (objectsToEvaluate.size() == 0) { + try { + objectsToEvaluate.wait(EXPIRE_TIME); + } catch (InterruptedException iex) { + return ; + } + if (objectsToEvaluate.size() == 0) { // Expired + return ; + } + } + eval = (Evaluable) objectsToEvaluate.remove(0); + currentlyEvaluating = eval; + } + Runnable evaluatedNotify = new Runnable() { + public void run() { + synchronized (objectsToEvaluate) { + currentlyEvaluating = null; + } + } + }; + eval.evaluateLazily(evaluatedNotify); + } + } - public interface Evaluable { + public interface Evaluable { - public void evaluateLazily(Runnable evaluatedNotify); + public void evaluateLazily(Runnable evaluatedNotify); - } + } - }*/ + }*/ } - diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelRoot.java spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelRoot.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelRoot.java 2016-02-04 02:55:43.085100098 +0100 +++ spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelRoot.java 2016-11-03 07:23:29.834689339 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.beans.PropertyVetoException; @@ -50,6 +49,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.WeakHashMap; import java.util.logging.Level; @@ -58,7 +58,6 @@ import javax.swing.SwingUtilities; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; - import org.netbeans.spi.viewmodel.ModelEvent; import org.netbeans.spi.viewmodel.Models; import org.netbeans.spi.viewmodel.Models.TreeFeatures; @@ -70,19 +69,19 @@ import org.openide.nodes.Node; import org.openide.util.Exceptions; - /** * Implements root node of hierarchy created for given TreeModel. * - * @author Jan Jancura + * @author Jan Jancura */ public class TreeModelRoot { - /** generated Serialized Version UID */ - static final long serialVersionUID = -1259352660663524178L; - - - // variables ............................................................... + /** + * generated Serialized Version UID + */ + static final long serialVersionUID = -1259352660663524178L; + + // variables ............................................................... private Models.CompoundModel model; private HyperCompoundModel hyperModel; private final ModelChangeListener[] modelListeners; @@ -93,24 +92,24 @@ private ExplorerManager manager; private OutlineView outlineView; private MessageFormat treeNodeDisplayFormat; - - /** The children evaluator for view of this root. * - private final Map childrenEvaluators - = new WeakHashMap(); - /** The values evaluator for view of this root. * - private final Map valuesEvaluators - = new WeakHashMap(); - */ - public TreeModelRoot (Models.CompoundModel model, TreeView treeView) { + /** + * The children evaluator for view of this root. * private final + * Map childrenEvaluators = + * new WeakHashMap(); /** The + * values evaluator for view of this root. * private final + * Map valuesEvaluators = new + * WeakHashMap(); + */ + public TreeModelRoot(Models.CompoundModel model, TreeView treeView) { this.model = model; this.manager = ExplorerManager.find(treeView); this.treeFeatures = new DefaultTreeFeatures(treeView); - modelListeners = new ModelChangeListener[] { new ModelChangeListener(model) }; - model.addModelListener (modelListeners[0]); + modelListeners = new ModelChangeListener[]{new ModelChangeListener(model)}; + model.addModelListener(modelListeners[0]); } - public TreeModelRoot (HyperCompoundModel model, TreeView treeView) { + public TreeModelRoot(HyperCompoundModel model, TreeView treeView) { this.hyperModel = model; this.model = model.getMain(); this.manager = ExplorerManager.find(treeView); @@ -124,16 +123,16 @@ } } - public TreeModelRoot (Models.CompoundModel model, OutlineView outlineView) { + public TreeModelRoot(Models.CompoundModel model, OutlineView outlineView) { this.model = model; this.manager = ExplorerManager.find(outlineView); this.treeFeatures = new DefaultTreeFeatures(outlineView); this.outlineView = outlineView; - modelListeners = new ModelChangeListener[] { new ModelChangeListener(model) }; - model.addModelListener (modelListeners[0]); + modelListeners = new ModelChangeListener[]{new ModelChangeListener(model)}; + model.addModelListener(modelListeners[0]); } - public TreeModelRoot (HyperCompoundModel model, OutlineView outlineView) { + public TreeModelRoot(HyperCompoundModel model, OutlineView outlineView) { this.hyperModel = model; this.model = model.getMain(); this.manager = ExplorerManager.find(outlineView); @@ -148,7 +147,7 @@ } } - public TreeFeatures getTreeFeatures () { + public TreeFeatures getTreeFeatures() { return treeFeatures; } @@ -156,46 +155,46 @@ return outlineView; } - public TreeModelNode getRootNode () { + public TreeModelNode getRootNode() { synchronized (rootNodeLock) { TreeModelNode rn = rootNode; if (rn == null) { if (hyperModel != null) { - rn = new TreeModelHyperNode (hyperModel, this, model.getRoot ()); + rn = new TreeModelHyperNode(hyperModel, this, model.getRoot()); } else { - rn = new TreeModelNode (model, this, model.getRoot ()); + rn = new TreeModelNode(model, this, model.getRoot()); } rootNode = rn; } return rn; } } - - void registerNode (Object o, TreeModelNode n) { + + void registerNode(Object o, TreeModelNode n) { synchronized (objectToNode) { WeakReference[] wrs = objectToNode.get(o); if (wrs == null) { - objectToNode.put (o, new WeakReference[] { new WeakReference(n) }); + objectToNode.put(o, new WeakReference[]{new WeakReference(n)}); } else { for (int i = 0; i < wrs.length; i++) { WeakReference wr = wrs[i]; TreeModelNode tn = wr.get(); if (tn == n) { - return ; + return; } else if (tn == null) { wrs[i] = new WeakReference(n); - return ; + return; } } WeakReference[] wrs2 = new WeakReference[wrs.length + 1]; System.arraycopy(wrs, 0, wrs2, 0, wrs.length); wrs2[wrs.length] = new WeakReference(n); - objectToNode.put (o, wrs2); + objectToNode.put(o, wrs2); } } } - - void unregisterNode (Object o, TreeModelNode n) { + + void unregisterNode(Object o, TreeModelNode n) { synchronized (objectToNode) { WeakReference[] wrs = objectToNode.get(o); if (wrs != null) { @@ -206,39 +205,41 @@ if (wrs.length == 1) { // The only item objectToNode.remove(o); } else if (wrs.length == 2) { // Leave only the other item - wrs = new WeakReference[] { wrs[(i + 1) % 2] }; - objectToNode.put (o, wrs); + wrs = new WeakReference[]{wrs[(i + 1) % 2]}; + objectToNode.put(o, wrs); } else { // Leave only the other items WeakReference[] nwrs = new WeakReference[wrs.length - 1]; if (i > 0) { System.arraycopy(wrs, 0, nwrs, 0, i); } if (i < (wrs.length - 1)) { - System.arraycopy(wrs, i+1, nwrs, i, wrs.length - i - 1); + System.arraycopy(wrs, i + 1, nwrs, i, wrs.length - i - 1); } - objectToNode.put (o, nwrs); + objectToNode.put(o, nwrs); } - return ; + return; } } } } } - TreeModelNode[] findNode (Object o) { + TreeModelNode[] findNode(Object o) { WeakReference[] wrs; synchronized (objectToNode) { - wrs = objectToNode.get (o); + wrs = objectToNode.get(o); } TreeModelNode[] tns = null; if (wrs != null) { for (int i = 0; i < wrs.length; i++) { // Suppose that it's unlikely that wrs.length > 1 WeakReference wr = wrs[i]; - TreeModelNode tn = wr.get (); - if (tn == null) continue; + TreeModelNode tn = wr.get(); + if (tn == null) { + continue; + } if (tns == null) { - tns = new TreeModelNode[] { tn }; + tns = new TreeModelNode[]{tn}; } else { TreeModelNode[] ntns = new TreeModelNode[tns.length + 1]; System.arraycopy(tns, 0, ntns, 0, tns.length); @@ -253,7 +254,7 @@ return tns; } } - + // public void treeNodeChanged (Object parent) { // final TreeModelNode tmn = findNode (parent); // if (tmn == null) return; @@ -283,8 +284,7 @@ return valuesEvaluator; } */ - - public void destroy () { + public void destroy() { boolean doRemoveModelListeners = false; DefaultTreeFeatures tf = null; synchronized (this) { @@ -305,7 +305,7 @@ for (ModelChangeListener mchl : modelListeners) { Models.CompoundModel cm = mchl.getModel(); if (cm != null) { - cm.removeModelListener (mchl); + cm.removeModelListener(mchl); } } } @@ -321,7 +321,7 @@ void setTreeNodeDisplayFormat(MessageFormat treeNodeDisplayFormat) { this.treeNodeDisplayFormat = treeNodeDisplayFormat; } - + MessageFormat getTreeNodeDisplayFormat() { return treeNodeDisplayFormat; } @@ -329,27 +329,27 @@ private final class ModelChangeListener implements ModelRootChangeListener { //private final Logger logger = Logger.getLogger(ModelChangeListener.class.getName()); - private final Reference modelRef; public ModelChangeListener(Models.CompoundModel model) { this.modelRef = new WeakReference(model); } - + Models.CompoundModel getModel() { return modelRef.get(); } - public void modelChanged (final ModelEvent event) { + public void modelChanged(final ModelEvent event) { //System.err.println("TreeModelRoot.modelChanged("+event.getClass()+") from "+model); //Thread.dumpStack(); //logger.fine("TreeModelRoot.modelChanged("+event+")"); //logger.log(Level.FINE, "Called from ", new IllegalStateException("TEST_MODEL_CHANGED")); - SwingUtilities.invokeLater (new Runnable () { - public void run () { + SwingUtilities.invokeLater(new Runnable() { + public void run() { Models.CompoundModel model = getModel(); - if (model == null) + if (model == null) { return; // already disposed + } if (event instanceof ModelEvent.TableValueChanged) { ModelEvent.TableValueChanged tvEvent = (ModelEvent.TableValueChanged) event; Object node = tvEvent.getNode(); @@ -359,14 +359,42 @@ //System.err.println(" nodes = "+Arrays.toString(tmNodes)); int change = tvEvent.getChange(); for (TreeModelNode tmNode : tmNodes) { - String column = tvEvent.getColumnID(); - if (column != null) { - tmNode.refreshColumn(column, change); + Collection columnIDs = tvEvent.getColumnIDs(); + if (columnIDs.isEmpty() || (columnIDs.size() == 1 && columnIDs.contains(null))) { + tmNode.refresh(model); } else { + for (String column : columnIDs) { + if (column != null) { + tmNode.refreshColumn(column, change); + } + } + } + } + return; // We're done + } else { // Refresh all nodes + List nodes = new ArrayList(objectToNode.size()); + for (WeakReference[] wrs : objectToNode.values()) { + for (WeakReference wr : wrs) { + TreeModelNode tm = wr.get(); + if (tm != null) { + nodes.add(tm); + } + } + } + int change = tvEvent.getChange(); + for (TreeModelNode tmNode : nodes) { + Collection columnIDs = tvEvent.getColumnIDs(); + if (columnIDs.isEmpty() || (columnIDs.size() == 1 && columnIDs.contains(null))) { tmNode.refresh(model); + } else { + for (String column : columnIDs) { + if (column != null) { + tmNode.refreshColumn(column, change); + } + } } } - return ; // We're done + return; // We're done } } if (event instanceof ModelEvent.NodeChanged) { @@ -381,7 +409,7 @@ for (TreeModelNode tmNode : tmNodes) { tmNode.refresh(model, nchEvent.getChange()); } - return ; // We're done + return; // We're done } else { // Refresh all nodes List nodes = new ArrayList(objectToNode.size()); for (WeakReference[] wrs : objectToNode.values()) { @@ -395,7 +423,7 @@ for (TreeModelNode tmNode : nodes) { tmNode.refresh(model, nchEvent.getChange()); } - return ; // We're done + return; // We're done } } if (event instanceof ModelEvent.SelectionChanged) { @@ -410,15 +438,15 @@ } } try { - manager.setSelectedNodes(tmNodes.toArray(new Node[] {})); + manager.setSelectedNodes(tmNodes.toArray(new Node[]{})); } catch (PropertyVetoException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Selection of "+Arrays.toString(nodes)+" vetoed.", ex); // NOI18N + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Selection of " + Arrays.toString(nodes) + " vetoed.", ex); // NOI18N } } }); - return ; + return; } - getRootNode().setObject (model, model.getRoot ()); + getRootNode().setObject(model, model.getRoot()); } }); } @@ -429,11 +457,11 @@ * Implements set of tree view features. */ private final class DefaultTreeFeatures extends TreeFeatures implements TreeExpansionListener { - + private TreeView view; private OutlineView outline; - - private DefaultTreeFeatures (TreeView view) { + + private DefaultTreeFeatures(TreeView view) { this.view = view; JTree tree; try { @@ -442,16 +470,16 @@ tree = (JTree) treeField.get(view); } catch (Exception ex) { Exceptions.printStackTrace(ex); - return ; + return; } tree.addTreeExpansionListener(this); } - private DefaultTreeFeatures (OutlineView view) { + private DefaultTreeFeatures(OutlineView view) { this.outline = view; view.addTreeExpansionListener(this); } - + public void destroy() { if (outline != null) { outline.removeTreeExpansionListener(this); @@ -463,27 +491,29 @@ tree = (JTree) treeField.get(view); } catch (Exception ex) { Exceptions.printStackTrace(ex); - return ; + return; } tree.removeTreeExpansionListener(this); } } - + /** * Returns true if given node is expanded. * * @param node a node to be checked * @return true if given node is expanded */ - public boolean isExpanded ( - Object node + public boolean isExpanded( + Object node ) { - Node[] ns = findNode (node); - if (ns.length == 0) return false; // Something what does not exist is not expanded ;-) + Node[] ns = findNode(node); + if (ns.length == 0) { + return false; // Something what does not exist is not expanded ;-) + } if (outline != null) { return outline.isExpanded(ns[0]); } else { - return view.isExpanded (ns[0]); + return view.isExpanded(ns[0]); } } @@ -493,15 +523,15 @@ * * @param node a list of nodes to be expanded */ - public void expandNode ( - Object node + public void expandNode( + Object node ) { - Node[] ns = findNode (node); + Node[] ns = findNode(node); for (Node n : ns) { if (outline != null) { outline.expandNode(n); } else { - view.expandNode (n); + view.expandNode(n); } } } @@ -511,41 +541,41 @@ * * @param node a node to be expanded */ - public void collapseNode ( - Object node + public void collapseNode( + Object node ) { - Node[] ns = findNode (node); + Node[] ns = findNode(node); for (Node n : ns) { if (outline != null) { outline.collapseNode(n); } else { - view.collapseNode (n); + view.collapseNode(n); } } } - + /** - * Called whenever an item in the tree has been expanded. - */ - public void treeExpanded (TreeExpansionEvent event) { + * Called whenever an item in the tree has been expanded. + */ + public void treeExpanded(TreeExpansionEvent event) { Models.CompoundModel model = getModel(); if (model != null) { - model.nodeExpanded (initExpandCollapseNotify(event)); + model.nodeExpanded(initExpandCollapseNotify(event)); } } /** - * Called whenever an item in the tree has been collapsed. - */ - public void treeCollapsed (TreeExpansionEvent event) { + * Called whenever an item in the tree has been collapsed. + */ + public void treeCollapsed(TreeExpansionEvent event) { Models.CompoundModel model = getModel(); if (model != null) { - model.nodeCollapsed (initExpandCollapseNotify(event)); + model.nodeCollapsed(initExpandCollapseNotify(event)); } } private Object initExpandCollapseNotify(TreeExpansionEvent event) { - Node node = Visualizer.findNode(event.getPath ().getLastPathComponent()); + Node node = Visualizer.findNode(event.getPath().getLastPathComponent()); Object obj = node.getLookup().lookup(Object.class); Object actOn; node = node.getParentNode(); @@ -569,4 +599,3 @@ } } - diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java 2016-02-04 02:55:43.086100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java 2016-11-03 07:23:29.836689359 +0100 @@ -39,21 +39,18 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; import java.util.concurrent.Executor; - import org.openide.util.RequestProcessor; /** - * Change threading of implemented models. - * Methods implemented in {@link TreeModel}, {@link NodeModel} ({@link ExtendedNodeModel}) - * and {@link TableModel} can be called synchronously in AWT thread as a direct - * response to user action (this is the default behavior), - * or asynchronously in a Request Processor or other thread. - * Register an implementation of this along with other models, - * if you need to change the original threading. + * Change threading of implemented models. Methods implemented in + * {@link TreeModel}, {@link NodeModel} ({@link ExtendedNodeModel}) and + * {@link TableModel} can be called synchronously in AWT thread as a direct + * response to user action (this is the default behavior), or asynchronously in + * a Request Processor or other thread. Register an implementation of this along + * with other models, if you need to change the original threading. * * @author Martin Entlicher * @since 1.20 @@ -61,13 +58,16 @@ public interface AsynchronousModelFilter extends Model { /** - * This enumeration identifies method(s) of view models for which - * threading information is provided by - * {@link #asynchronous(java.util.concurrent.Executor, org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL, java.lang.Object)} method. + * This enumeration identifies method(s) of view models for which threading + * information is provided by + * {@link #asynchronous(java.util.concurrent.Executor, org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL, java.lang.Object)} + * method. *
- * CHILDREN for TreeModel.getChildrenCount() and TreeModel.getChildren() + * CHILDREN for TreeModel.getChildrenCount() and + * TreeModel.getChildren() *
- * DISPLAY_NAME is for NodeModel.getDisplayName() and ExtendedNodeModel.setName() + * DISPLAY_NAME is for NodeModel.getDisplayName() and + * ExtendedNodeModel.setName() *
* SHORT_DESCRIPTION for NodeModel.getShortDescription() *
@@ -76,17 +76,21 @@ * The rest of the methods on models are called synchronously, or additional * enums can be added in the future. */ - static enum CALL { CHILDREN, DISPLAY_NAME, SHORT_DESCRIPTION, VALUE } + static enum CALL { + + CHILDREN, DISPLAY_NAME, SHORT_DESCRIPTION, VALUE + } /** * Executor for invocation of models method calls in the current thread. * This will make method invocation synchronous. It's important that the - * methods execute fast so that they do not block AWT thread. - * This is the default executor for {@link CALL#DISPLAY_NAME} and + * methods execute fast so that they do not block AWT thread. This is the + * default executor for {@link CALL#DISPLAY_NAME} and * {@link CALL#SHORT_DESCRIPTION}. */ static final Executor CURRENT_THREAD = new Executor() { + @Override public void execute(Runnable command) { command.run(); } @@ -94,19 +98,18 @@ }; /** - * Executor, which uses a shared {@link RequestProcessor} with - * throughoutput = 1 for models method calls, making the method invocation - * asynchronous. The UI gives a visual feedback to the user if models method - * calls take a long time. Use this to keep the UI responsive. - * This is the default executor for {@link CALL#CHILDREN} and - * {@link CALL#VALUE}. + * Executor, which uses a shared {@link RequestProcessor} with throughoutput + * = 1 for models method calls, making the method invocation asynchronous. + * The UI gives a visual feedback to the user if models method calls take a + * long time. Use this to keep the UI responsive. This is the default + * executor for {@link CALL#CHILDREN} and {@link CALL#VALUE}. */ static final Executor DEFAULT = new RequestProcessor("Asynchronous view model", 1); // NOI18N /** - * Change the threading information for view models method calls. - * The returned Executor is used to call methods identified by - * {@link CALL} enum. + * Change the threading information for view models method calls. The + * returned Executor is used to call methods identified by {@link CALL} + * enum. * * @param original The original {@link Executor} * @param asynchCall Identification of the method call diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CachedChildrenTreeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/CachedChildrenTreeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CachedChildrenTreeModel.java 2016-02-04 02:55:43.086100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/CachedChildrenTreeModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -23,7 +23,7 @@ * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" - * + * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution @@ -34,12 +34,11 @@ * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. - * + * * Contributor(s): - * + * * Portions Copyrighted 2008 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; import java.util.HashSet; @@ -50,16 +49,17 @@ import org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL; /** - * A TreeModel, which caches children objects and allow seamless update of children objects. - * + * A TreeModel, which caches children objects and allow seamless update of + * children objects. + * * @author Martin Entlicher * @since 1.49 */ public abstract class CachedChildrenTreeModel extends Object implements TreeModel, AsynchronousModelFilter { private final Map childrenCache = new WeakHashMap(); - private final Set childrenToRefresh = new HashSet(); - + private final Set childrenToRefresh = new HashSet(); + @Override public Executor asynchronous(Executor original, CALL asynchCall, Object node) throws UnknownTypeException { if (CALL.CHILDREN.equals(asynchCall)) { @@ -80,8 +80,8 @@ } @Override - public final Object[] getChildren (Object o, int from, int to) - throws UnknownTypeException { + public final Object[] getChildren(Object o, int from, int to) + throws UnknownTypeException { Object[] ch; boolean cache = cacheChildrenOf(o); if (cache) { @@ -95,18 +95,18 @@ } else { ch = null; } - } else ch = null; + } else { + ch = null; + } if (ch == null) { ch = computeChildren(o); if (ch == null) { - throw new UnknownTypeException (o); - } else { - if (cache) { - ChildrenTree cht = new ChildrenTree(o); - cht.setChildren(ch); - synchronized (childrenCache) { - childrenCache.put(o, cht); - } + throw new UnknownTypeException(o); + } else if (cache) { + ChildrenTree cht = new ChildrenTree(o); + cht.setChildren(ch); + synchronized (childrenCache) { + childrenCache.put(o, cht); } } } @@ -123,23 +123,25 @@ } return ch; } - + /** * Compute the children nodes. This is called when there are no children * cached for this node only. + * * @param node The node to compute the children for * @return The list of children * @throws UnknownTypeException When this implementation is not able to - * resolve children for given node type + * resolve children for given node type */ protected abstract Object[] computeChildren(Object node) throws UnknownTypeException; - + /** * Can be overridden to decide which nodes to cache and which not. + * * @param node The node - * @return true when the children of this node should be cached, - * false otherwise. The default implementation returns - * true always. + * @return true when the children of this node should be + * cached, false otherwise. The default implementation returns + * true always. */ protected boolean cacheChildrenOf(Object node) { return true; @@ -147,6 +149,7 @@ /** * Force a refresh of the cache. + * * @param node The node to refresh the cache for. */ protected final void refreshCache(Object node) { @@ -164,32 +167,36 @@ childrenToRefresh.clear(); } } - + /** - * Allows to reorder the children. This is called each time the children - * are requested, even when they're cached. - * @param nodes The original nodes returned by {@link #computeChildren(java.lang.Object)} - * or by the cache. - * @return The reordered nodes. The default implementation returns the original nodes. + * Allows to reorder the children. This is called each time the children are + * requested, even when they're cached. + * + * @param nodes The original nodes returned by + * {@link #computeChildren(java.lang.Object)} or by the cache. + * @return The reordered nodes. The default implementation returns the + * original nodes. */ protected Object[] reorder(Object[] nodes) { return nodes; } - + /** * Force to recompute all cached children. + * * @throws UnknownTypeException When this implementation is not able to - * resolve children for some node type + * resolve children for some node type */ protected final void recomputeChildren() throws UnknownTypeException { recomputeChildren(getRoot()); } - + /** * Force to recompute children cached for the given node. + * * @param node The node to recompute the children for * @throws UnknownTypeException When this implementation is not able to - * resolve children for the given node type + * resolve children for the given node type */ protected final void recomputeChildren(Object node) throws UnknownTypeException { ChildrenTree cht; @@ -209,24 +216,24 @@ } } } - + private final static class ChildrenTree { - + //private Object node; private Object[] ch; - + public ChildrenTree(Object node) { //this.node = node; } - + public void setChildren(Object[] ch) { this.ch = ch; } - + public Object[] getChildren() { return ch; } - + } - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModelFilter.java 2016-02-04 02:55:43.087100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModelFilter.java 2016-11-03 07:23:29.837689369 +0100 @@ -39,13 +39,12 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; /** - * A model filter for {@link CheckNodeModel}. - * Can be also used to add the check-boxes to an ordinary {@link NodeModel}. - * + * A model filter for {@link CheckNodeModel}. Can be also used to add the + * check-boxes to an ordinary {@link NodeModel}. + * * @author Martin Entlicher * @since 1.17 */ @@ -56,7 +55,8 @@ * * @param original the original node model * @param node the tree node object - * @return true if the check-box should be displayed, false otherwise. + * @return true if the check-box should be displayed, + * false otherwise. */ boolean isCheckable(NodeModel original, Object node) throws UnknownTypeException; @@ -65,7 +65,8 @@ * * @param original the original node model * @param node the tree node object - * @return true if the check-box should be enabled, false otherwise. + * @return true if the check-box should be enabled, + * false otherwise. */ boolean isCheckEnabled(NodeModel original, Object node) throws UnknownTypeException; @@ -75,8 +76,8 @@ * @param original the original node model * @param node the tree node object * @return true if the check-box should be selected, - * false if it should be unselected and - * null if the state is unknown. + * false if it should be unselected and null if + * the state is unknown. */ Boolean isSelected(NodeModel original, Object node) throws UnknownTypeException; @@ -86,8 +87,11 @@ * @param original the original node model * @param node the tree node object * @param selected true if the check-box was selected, - * false if the check-box was unselected. + * false if the check-box was unselected. */ void setSelected(NodeModel original, Object node, Boolean selected) throws UnknownTypeException; + void setSelected(NodeModel original, Object... nodes) throws UnknownTypeException; + + void setUnselected(NodeModel original, Object... nodes) throws UnknownTypeException; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModel.java 2016-02-04 02:55:43.087100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/CheckNodeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -39,14 +39,12 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; /** * The extension of {@link NodeModel} that can display check-boxes next to the - * node display name. - * Instead of a special column with check-boxes, this extension can be used. - * It will make the UI cleaner and more usable. + * node display name. Instead of a special column with check-boxes, this + * extension can be used. It will make the UI cleaner and more usable. * * @author Martin Entlicher * @since 1.17 @@ -57,7 +55,8 @@ * Tell the renderer to display the check-box. * * @param node the tree node object - * @return true if the check-box should be displayed, false otherwise. + * @return true if the check-box should be displayed, + * false otherwise. */ boolean isCheckable(Object node) throws UnknownTypeException; @@ -65,7 +64,8 @@ * Provide the enabled state of the check-box. * * @param node the tree node object - * @return true if the check-box should be enabled, false otherwise. + * @return true if the check-box should be enabled, + * false otherwise. */ boolean isCheckEnabled(Object node) throws UnknownTypeException; @@ -74,8 +74,8 @@ * * @param node the tree node object * @return true if the check-box should be selected, - * false if it should be unselected and - * null if the state is unknown. + * false if it should be unselected and null if + * the state is unknown. */ Boolean isSelected(Object node) throws UnknownTypeException; @@ -84,8 +84,11 @@ * * @param node the tree node object * @param selected true if the check-box was selected, - * false if the check-box was unselected. + * false if the check-box was unselected. */ void setSelected(Object node, Boolean selected) throws UnknownTypeException; + void setSelected(Object... nodes) throws UnknownTypeException; + + void setUnselected(Object... nodes) throws UnknownTypeException; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnModel.java 2016-02-04 02:55:43.088100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,39 +41,37 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.beans.PropertyEditor; - /** * Defines model for one table view column. Can be used together with * {@link TreeModel} for tree table view representation. * - * @author Jan Jancura + * @author Jan Jancura */ public abstract class ColumnModel implements Model { - /** * Returns unique ID of this column. * * @return unique ID of this column */ - public abstract String getID (); + public abstract String getID(); /** * Returns display name of this column. The returned String can contain an * ampersand marking the location of the mnemonic. * - * @return display name of this column, including an optional ampersand for mnemonic location. + * @return display name of this column, including an optional ampersand for + * mnemonic location. */ - public abstract String getDisplayName (); - - /** - * Returns the character, that indicates a mnemonic key - * for this column name. Can be null. + public abstract String getDisplayName(); + + /** + * Returns the character, that indicates a mnemonic key for this column + * name. Can be null. * * @return the mnemonic key or null. * @since 1.11 @@ -82,184 +80,193 @@ public Character getDisplayedMnemonic() { return null; } - + /** * Returns type of column items. * * @return type of column items */ - public abstract Class getType (); - + public abstract Class getType(); + /** - * Returns ID of column this column should be installed before or - * null. Defines default order of columns only. - * This default order can be changed by user, and - * {@link #getCurrentOrderNumber} and {@link #setCurrentOrderNumber} are - * used for sorting after that. + * Returns ID of column this column should be installed before or + * null. Defines default order of columns only. This default + * order can be changed by user, and {@link #getCurrentOrderNumber} and + * {@link #setCurrentOrderNumber} are used for sorting after that. * - * @return ID of column this column should be installed before or + * @return ID of column this column should be installed before or * null * @deprecated Not used. See {@link #getCurrentOrderNumber}. */ - public String getPreviuosColumnID () { + public String getPreviuosColumnID() { return null; } - + /** - * Returns ID of column this column should be installed after or - * null. Defines default order of columns only. - * This default order can be changed by user, and - * {@link #getCurrentOrderNumber} and {@link #setCurrentOrderNumber} are - * used for sorting after that. + * Returns ID of column this column should be installed after or + * null. Defines default order of columns only. This default + * order can be changed by user, and {@link #getCurrentOrderNumber} and + * {@link #setCurrentOrderNumber} are used for sorting after that. * * @return ID of column next to this one or null * @deprecated Not used. See {@link #getCurrentOrderNumber}. */ - public String getNextColumnID () { + public String getNextColumnID() { return null; } - + /** - * Returns tooltip for given column. Default implementation returns + * Returns tooltip for given column. Default implementation returns * null - do not use tooltip. * - * @return tooltip for given node or null + * @return tooltip for given node or null */ - public String getShortDescription () { + public String getShortDescription() { return null; } - + /** - * True if column can be sorted. Default implementation returns + * True if column can be sorted. Default implementation returns * true. * * @return true if column can be sorted */ - public boolean isSortable () { + public boolean isSortable() { return true; } - + /** - * True if column should be visible. Default implementation - * returns true. + * True if column should be visible. Default implementation returns + * true. * * @return true if column should be visible */ - public boolean isVisible () { + public boolean isVisible() { return true; } - + /** * Set true if column is to be visible. Default implementation does nothing. * * @param visible set true if column is to be visible */ - public void setVisible (boolean visible) {} - + public void setVisible(boolean visible) { + } + /** - * True if column is sorted. - * Default implementation returns false. + * True if column is sorted. Default implementation returns + * false. * * @return true if column is sorted. */ - public boolean isSorted () { + public boolean isSorted() { return false; } - + /** * Set true if column is to be sorted. Default implementation does nothing. * * @param sorted set true if column is to be sorted */ - public void setSorted (boolean sorted) {} - + public void setSorted(boolean sorted) { + } + /** - * True if column should be sorted in descending order. - * Default implementation returns false. + * True if column should be sorted in descending order. Default + * implementation returns false. * - * @return true if column should be sorted - * in descending order + * @return true if column should be sorted in descending order */ - public boolean isSortedDescending () { + public boolean isSortedDescending() { return false; } - - /** - * Set true if column is to be sorted in descending order. - * Default implementation does nothing. - * - * @param sortedDescending set true if column is to be sorted - * in descending order - */ - public void setSortedDescending (boolean sortedDescending) {} - + /** - * Should return current order number of this column. Default value is - * -1. + * Set true if column is to be sorted in descending order. Default + * implementation does nothing. * - * @return current order number of this column or -1 + * @param sortedDescending set true if column is to be sorted in descending + * order */ - public int getCurrentOrderNumber () { - return -1; + public void setSortedDescending(boolean sortedDescending) { } - - /** - * Is called when current order number of this column is changed. - * Default implementation does nothing. - * - * @param newOrderNumber new order number - */ - public void setCurrentOrderNumber (int newOrderNumber) {} - +// +// /** +// * Should return current order number of this column. Default value is +// * -1. +// * +// * @return current order number of this column or -1 +// */ +// public final int getCurrentOrderNumber() { +// return -1; +// } +// +// /** +// * Is called when current order number of this column is changed. Default +// * implementation does nothing. +// * +// * @param newOrderNumber new order number +// */ +// public final void setCurrentOrderNumber(int newOrderNumber) { +// } + + private int currentOrderNumber = -1; + + public final int getCurrentOrderNumber() { + return currentOrderNumber; + } + + public final void setCurrentOrderNumber(int newOrderNumber) { + this.currentOrderNumber = newOrderNumber; + } + /** * Return column width of this column. * * @return column width of this column */ - public int getColumnWidth () { + public int getColumnWidth() { return 20; } - + /** - * Is called when column width of this column is changed. - * Default implementation does nothing. + * Is called when column width of this column is changed. Default + * implementation does nothing. * * @param newColumnWidth a new column width */ - public void setColumnWidth (int newColumnWidth) {} - + public void setColumnWidth(int newColumnWidth) { + } + /** - * Returns {@link java.beans.PropertyEditor} to be used for - * this column. Default implementation returns null - - * means use default PropertyEditor. + * Returns {@link java.beans.PropertyEditor} to be used for this column. + * Default implementation returns null - means use default + * PropertyEditor. * - * @return {@link java.beans.PropertyEditor} to be used for - * this column + * @return {@link java.beans.PropertyEditor} to be used for this column */ - public PropertyEditor getPropertyEditor () { + public PropertyEditor getPropertyEditor() { return null; } - + /** - * Rerturns {@link javax.swing.table.TableCellEditor} to be used for - * this column. + * Rerturns {@link javax.swing.table.TableCellEditor} to be used for this + * column. * - * @return {@link javax.swing.table.TableCellEditor} to be used for - * this column + * @return {@link javax.swing.table.TableCellEditor} to be used for this + * column */ // public TableCellEditor getTableCellEditor () { // return null; // } - /** - * Rerturns {@link javax.swing.table.TableCellRenderer} to be used for - * this column. + * Rerturns {@link javax.swing.table.TableCellRenderer} to be used for this + * column. * - * @return {@link javax.swing.table.TableCellRenderer} to be used for - * this column + * @return {@link javax.swing.table.TableCellRenderer} to be used for this + * column */ // public TableCellRenderer getTableCellRenderer () { // return null; // } - } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnsModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnsModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnsModel.java 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ColumnsModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -0,0 +1,84 @@ +// +/*COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +* +* 1. Definitions. +* 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications. +* 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. +* 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. +* 1.4. "Executable" means the Covered Software in any form other than Source Code. +* 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License. +* 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. +* 1.7. "License" means this document. +* 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. +* 1.9 "Modifications" means the Source Code and Executable form of any of the following: +* A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; +* B. Any new file that contains any part of the Original Software or previous Modification; or +* C. Any new file that is contributed or otherwise made available under the terms of this License. +* 1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License. +* 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. +* 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. +* 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. +* 2. License Grants. +* 2.1. The Initial Developer Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). +* (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. +* (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. +* 2.2. Contributor Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). +* (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. +* (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. +* 3. Distribution Obligations. +* 3.1. Availability of Source Code. +* Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. +* 3.2. Modifications. +* The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. +* 3.3. Required Notices. +* You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. +* 3.4. Application of Additional Terms. +* You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients� rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. +* 3.5. Distribution of Executable Versions. +* You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient�s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. +* 3.6. Larger Works. +* You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. +* 4. Versions of the License. +* 4.1. New Versions. +* Oracle Corp. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. +* 4.2. Effect of New Versions. +* You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. +* 4.3. Modified Versions. +* When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. +* 5. DISCLAIMER OF WARRANTY. +* COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +* 6. TERMINATION. +* 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. +* 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. +* 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. +* 7. LIMITATION OF LIABILITY. +* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. +* 8. U.S. GOVERNMENT END USERS. +* The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. +* 9. MISCELLANEOUS. +* This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction�s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys� fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. +* 10. RESPONSIBILITY FOR CLAIMS. +* As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. +* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +* The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. + */ +// +package org.netbeans.spi.viewmodel; + +import java.util.List; + +/** + * + * @author paolo + */ +public interface ColumnsModel extends Model { + + List getColumnModels(); + +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModelFilter.java 2016-02-04 02:55:43.089100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModelFilter.java 2016-11-03 07:23:29.836689359 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; import java.awt.datatransfer.Transferable; @@ -55,20 +54,23 @@ public interface DnDNodeModelFilter extends NodeModelFilter { /** - * Action constants from {@link java.awt.dnd.DnDConstants}. - * No actions are allowed by default. + * Action constants from {@link java.awt.dnd.DnDConstants}. No actions are + * allowed by default. + * * @param original The original DnDNodeModel to filter - * @return int representing set of actions which are allowed when dragging from - * asociated component. + * @return int representing set of actions which are allowed when dragging + * from asociated component. */ int getAllowedDragActions(DnDNodeModel original); /** - * Action constants from {@link java.awt.dnd.DnDConstants}. - * No actions are allowed by default. + * Action constants from {@link java.awt.dnd.DnDConstants}. No actions are + * allowed by default. + * * @param original The original DnDNodeModel to filter - * @param t The transferable for which the allowed drop actions are requested, - * or null to get actions for the creation of DropTarget for the view. + * @param t The transferable for which the allowed drop actions are + * requested, or null to get actions for the creation of + * DropTarget for the view. * @return int representing set of actions which are allowed when dropping * the transferable into the asociated component. */ @@ -76,27 +78,31 @@ /** * Initiate a drag operation. + * * @param original The original DnDNodeModel to filter * @param node The node to drag * @return transferable to represent this node during a drag * @throws IOException when the drag cannot be performed - * @throws UnknownTypeException if this model implementation is not - * able to perform drag for given node type + * @throws UnknownTypeException if this model implementation is not able to + * perform drag for given node type */ Transferable drag(DnDNodeModel original, Object node) throws IOException, UnknownTypeException; /** - * Determines if there is a paste operation that can be performed - * on provided transferable when drop is done. + * Determines if there is a paste operation that can be performed on + * provided transferable when drop is done. * * @param original The original DnDNodeModel to filter * @param node The node where to drop * @param t the transferable to drop - * @param action the Drag and Drop action from {@link java.awt.dnd.DnDConstants} - * @param index index between children the drop occured at or -1 if not specified - * @return the paste type or null when the transferable cannot be accepted - * @throws UnknownTypeException if this model implementation is not - * able to perform drop for given node type + * @param action the Drag and Drop action from + * {@link java.awt.dnd.DnDConstants} + * @param index index between children the drop occured at or -1 if not + * specified + * @return the paste type or null when the transferable cannot + * be accepted + * @throws UnknownTypeException if this model implementation is not able to + * perform drop for given node type */ PasteType getDropType(DnDNodeModel original, Object object, Transferable t, int action, int index) throws UnknownTypeException; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModel.java 2016-02-04 02:55:43.088100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/DnDNodeModel.java 2016-11-03 07:23:29.836689359 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; import java.awt.datatransfer.Transferable; @@ -55,18 +54,21 @@ public interface DnDNodeModel extends NodeModel { /** - * Action constants from {@link java.awt.dnd.DnDConstants}. - * No actions are allowed by default. - * @return int representing set of actions which are allowed when dragging from - * asociated component. + * Action constants from {@link java.awt.dnd.DnDConstants}. No actions are + * allowed by default. + * + * @return int representing set of actions which are allowed when dragging + * from asociated component. */ int getAllowedDragActions(); /** - * Action constants from {@link java.awt.dnd.DnDConstants}. - * No actions are allowed by default. - * @param t The transferable for which the allowed drop actions are requested, - * or null to get actions for the creation of DropTarget for the view. + * Action constants from {@link java.awt.dnd.DnDConstants}. No actions are + * allowed by default. + * + * @param t The transferable for which the allowed drop actions are + * requested, or null to get actions for the creation of + * DropTarget for the view. * @return int representing set of actions which are allowed when dropping * the transferable into the asociated component. */ @@ -74,25 +76,28 @@ /** * Initiate a drag operation. + * * @param node The node to drag * @return transferable to represent this node during a drag * @throws IOException when the drag cannot be performed - * @throws UnknownTypeException if this model implementation is not - * able to perform drag for given node type + * @throws UnknownTypeException if this model implementation is not able to + * perform drag for given node type */ Transferable drag(Object node) throws IOException, UnknownTypeException; /** - * Determines if there is a paste operation that can be performed - * on provided transferable when drop is done. + * Determines if there is a paste operation that can be performed on + * provided transferable when drop is done. * * @param node The node where to drop * @param t the transferable to drop - * @param action the Drag and Drop action from {@link java.awt.dnd.DnDConstants} - * @param index index between children the drop occured at or -1 if not specified + * @param action the Drag and Drop action from + * {@link java.awt.dnd.DnDConstants} + * @param index index between children the drop occured at or -1 if not + * specified * @return null if the transferable cannot be accepted - * @throws UnknownTypeException if this model implementation is not - * able to perform drop for given node type + * @throws UnknownTypeException if this model implementation is not able to + * perform drop for given node type */ PasteType getDropType(Object node, Transferable t, int action, int index) throws UnknownTypeException; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModelFilter.java 2016-02-04 02:55:43.089100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModelFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,43 +41,45 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.awt.datatransfer.Transferable; import java.io.IOException; import org.openide.util.datatransfer.PasteType; - /** - * Provides extension to {@link NodeModelFilter}, - * filters content of some existing {@link ExtendedNodeModel}. + * Provides extension to {@link NodeModelFilter}, filters content of some + * existing {@link ExtendedNodeModel}. * - * @author Martin Entlicher + * @author Martin Entlicher * @since 1.12 */ public interface ExtendedNodeModelFilter extends NodeModelFilter { - + /** * Test whether this node permits renaming. + * * @return true if so */ public abstract boolean canRename(ExtendedNodeModel original, Object node) throws UnknownTypeException; /** * Test whether this node permits copying. + * * @return true if so */ public abstract boolean canCopy(ExtendedNodeModel original, Object node) throws UnknownTypeException; /** * Test whether this node permits cutting. + * * @return true if so */ public abstract boolean canCut(ExtendedNodeModel original, Object node) throws UnknownTypeException; /** * Called when a node is to be copied to the clipboard. + * * @param node The node object * @return the transferable object representing the content of the clipboard * @exception IOException when the copy cannot be performed @@ -86,6 +88,7 @@ /** * Called when a node is to be cut to the clipboard. + * * @param node The node object * @return the transferable object representing the content of the clipboard * @exception IOException when the cut cannot be performed @@ -93,57 +96,63 @@ public abstract Transferable clipboardCut(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException; /** - * Called when a drag is started with this node. - * The node can attach a transfer listener to ExTransferable and - * will be then notified about progress of the drag (accept/reject). + * Called when a drag is started with this node. The node can attach a + * transfer listener to ExTransferable and will be then notified about + * progress of the drag (accept/reject). * * @param node The node object * @return transferable to represent this node during a drag * @exception IOException if a drag cannot be started * - public abstract Transferable drag(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException; + * public abstract Transferable drag(ExtendedNodeModel original, Object + * node) throws IOException, UnknownTypeException; */ - /** - * Determine which paste operations are allowed when a given transferable is in the clipboard. - * For example, a node representing a Java package will permit classes to be pasted into it. + * Determine which paste operations are allowed when a given transferable is + * in the clipboard. For example, a node representing a Java package will + * permit classes to be pasted into it. + * * @param node The node object * @param t the transferable in the clipboard * @return array of operations that are allowed */ public abstract PasteType[] getPasteTypes(ExtendedNodeModel original, Object node, Transferable t) throws UnknownTypeException; - /** Determine if there is a paste operation that can be performed - * on provided transferable. Used by drag'n'drop code to check - * whether the drop is possible. + /** + * Determine if there is a paste operation that can be performed on provided + * transferable. Used by drag'n'drop code to check whether the drop is + * possible. * * @param node The node object * @param t the transferable - * @param action the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINK - * @param index index between children the drop occurred at or -1 if not specified - * @return null if the transferable cannot be accepted or the paste type - * to execute when the drop occurs + * @param action the drag'n'drop action to do DnDConstants.ACTION_MOVE, + * ACTION_COPY, ACTION_LINK + * @param index index between children the drop occurred at or -1 if not + * specified + * @return null if the transferable cannot be accepted or the paste type to + * execute when the drop occurs * - public abstract PasteType getDropType(ExtendedNodeModel original, Object node, Transferable t, int action, int index) throws UnknownTypeException; + * public abstract PasteType getDropType(ExtendedNodeModel original, Object + * node, Transferable t, int action, int index) throws UnknownTypeException; */ - /** * Sets a new name for given node. * * @param node The object to set the new name to. * @param name The new name for the given node */ - public abstract void setName (ExtendedNodeModel original, Object node, String name) throws UnknownTypeException; + public abstract void setName(ExtendedNodeModel original, Object node, String name) throws UnknownTypeException; /** - * Returns icon resource with extension for given node. - * This is the preferred way of icon specification over {@link org.netbeans.spi.viewmodel.NodeModel.getIconBase} + * Returns icon resource with extension for given node. This is the + * preferred way of icon specification over + * {@link org.netbeans.spi.viewmodel.NodeModel.getIconBase} * * @param node The node object * @return The base resouce name with extension (no initial slash) - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type + * @throws UnknownTypeException if this NodeModel implementation is not able + * to resolve icon for given node type */ - public abstract String getIconBaseWithExtension (ExtendedNodeModel original, Object node) throws UnknownTypeException; - + public abstract String getIconBaseWithExtension(ExtendedNodeModel original, Object node) throws UnknownTypeException; + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModel.java 2016-02-04 02:55:43.089100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ExtendedNodeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,44 +41,45 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.awt.datatransfer.Transferable; import java.io.IOException; - import org.openide.util.datatransfer.PasteType; - /** * Provides extension to {@link NodeModel} with cut/copy/paste and rename * functionality, and also allowing to set icons with extension. * - * @author Martin Entlicher + * @author Martin Entlicher * @since 1.12 */ public interface ExtendedNodeModel extends NodeModel { - + /** * Test whether this node permits renaming. + * * @return true if so */ public abstract boolean canRename(Object node) throws UnknownTypeException; /** * Test whether this node permits copying. + * * @return true if so */ public abstract boolean canCopy(Object node) throws UnknownTypeException; /** * Test whether this node permits cutting. + * * @return true if so */ public abstract boolean canCut(Object node) throws UnknownTypeException; /** * Called when a node is to be copied to the clipboard. + * * @param node The node object * @return the transferable object representing the content of the clipboard * @exception IOException when the copy cannot be performed @@ -87,6 +88,7 @@ /** * Called when a node is to be cut to the clipboard. + * * @param node The node object * @return the transferable object representing the content of the clipboard * @exception IOException when the cut cannot be performed @@ -94,57 +96,63 @@ public abstract Transferable clipboardCut(Object node) throws IOException, UnknownTypeException; /** - * Called when a drag is started with this node. - * The node can attach a transfer listener to ExTransferable and - * will be then notified about progress of the drag (accept/reject). + * Called when a drag is started with this node. The node can attach a + * transfer listener to ExTransferable and will be then notified about + * progress of the drag (accept/reject). * * @param node The node object * @return transferable to represent this node during a drag * @exception IOException if a drag cannot be started * - public abstract Transferable drag(Object node) throws IOException, UnknownTypeException; + * public abstract Transferable drag(Object node) throws IOException, + * UnknownTypeException; */ - /** - * Determine which paste operations are allowed when a given transferable is in the clipboard. - * For example, a node representing a Java package will permit classes to be pasted into it. + * Determine which paste operations are allowed when a given transferable is + * in the clipboard. For example, a node representing a Java package will + * permit classes to be pasted into it. + * * @param node The node object * @param t the transferable in the clipboard * @return array of operations that are allowed */ public abstract PasteType[] getPasteTypes(Object node, Transferable t) throws UnknownTypeException; - /** Determine if there is a paste operation that can be performed - * on provided transferable. Used by drag'n'drop code to check - * whether the drop is possible. + /** + * Determine if there is a paste operation that can be performed on provided + * transferable. Used by drag'n'drop code to check whether the drop is + * possible. * * @param node The node object * @param t the transferable - * @param action the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINK - * @param index index between children the drop occurred at or -1 if not specified - * @return null if the transferable cannot be accepted or the paste type - * to execute when the drop occurs + * @param action the drag'n'drop action to do DnDConstants.ACTION_MOVE, + * ACTION_COPY, ACTION_LINK + * @param index index between children the drop occurred at or -1 if not + * specified + * @return null if the transferable cannot be accepted or the paste type to + * execute when the drop occurs * - public abstract PasteType getDropType(Object node, Transferable t, int action, int index) throws UnknownTypeException; + * public abstract PasteType getDropType(Object node, Transferable t, int + * action, int index) throws UnknownTypeException; */ - /** * Sets a new name for given node. * * @param node The object to set the new name to. * @param name The new name for the given node */ - public abstract void setName (Object node, String name) throws UnknownTypeException; + public abstract void setName(Object node, String name) throws UnknownTypeException; /** - * Returns icon resource with extension for given node. - * This is the preferred way of icon specification over {@link org.netbeans.spi.viewmodel.NodeModel.getIconBase} + * Returns icon resource with extension for given node. This is the + * preferred way of icon specification over + * {@link org.netbeans.spi.viewmodel.NodeModel.getIconBase} * * @param node The node object * @return The base resouce name with extension (no initial slash) - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type + * @throws UnknownTypeException if this NodeModel implementation is not able + * to resolve icon for given node type */ - public abstract String getIconBaseWithExtension (Object node) throws UnknownTypeException; - + public abstract String getIconBaseWithExtension(Object node) throws UnknownTypeException; + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/IconNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/IconNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/IconNodeModel.java 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/IconNodeModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -0,0 +1,69 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.spi.viewmodel; + +import java.awt.Image; + +/** + * + * @author matteo + */ +public interface IconNodeModel extends Model { + + /** + * Find an icon for this node. Uses an {@link #setIconBase icon set}. + * + * @param type constants from {@link java.beans.BeanInfo} + * + * @return icon to use to represent the bean + */ + public Image getIcon(Object node, int type) throws UnknownTypeException; + + /** + * Finds an icon for this node when opened. This icon should represent the + * node only when it is opened (when it can have children). + * + * @param type as in {@link #getIcon} + * @return icon to use to represent the bean when opened + */ + public Image getOpenedIcon(Object node, int type) throws UnknownTypeException; +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/LookupNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/LookupNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/LookupNodeModel.java 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/LookupNodeModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -0,0 +1,83 @@ +// +/*COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +* +* 1. Definitions. +* 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications. +* 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. +* 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. +* 1.4. "Executable" means the Covered Software in any form other than Source Code. +* 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License. +* 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. +* 1.7. "License" means this document. +* 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. +* 1.9 "Modifications" means the Source Code and Executable form of any of the following: +* A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; +* B. Any new file that contains any part of the Original Software or previous Modification; or +* C. Any new file that is contributed or otherwise made available under the terms of this License. +* 1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License. +* 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. +* 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. +* 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. +* 2. License Grants. +* 2.1. The Initial Developer Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). +* (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. +* (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. +* 2.2. Contributor Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). +* (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. +* (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. +* 3. Distribution Obligations. +* 3.1. Availability of Source Code. +* Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. +* 3.2. Modifications. +* The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. +* 3.3. Required Notices. +* You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. +* 3.4. Application of Additional Terms. +* You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients� rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. +* 3.5. Distribution of Executable Versions. +* You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient�s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. +* 3.6. Larger Works. +* You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. +* 4. Versions of the License. +* 4.1. New Versions. +* Oracle Corp. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. +* 4.2. Effect of New Versions. +* You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. +* 4.3. Modified Versions. +* When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. +* 5. DISCLAIMER OF WARRANTY. +* COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +* 6. TERMINATION. +* 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. +* 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. +* 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. +* 7. LIMITATION OF LIABILITY. +* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. +* 8. U.S. GOVERNMENT END USERS. +* The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. +* 9. MISCELLANEOUS. +* This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction�s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys� fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. +* 10. RESPONSIBILITY FOR CLAIMS. +* As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. +* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +* The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. + */ +// +package org.netbeans.spi.viewmodel; + +import org.openide.util.Lookup; + +/** + * + * @author matteo + */ +public interface LookupNodeModel extends Model { + + public Lookup getLookup(Object node) throws UnknownTypeException; +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelEvent.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelEvent.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelEvent.java 2016-02-04 02:55:43.091100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelEvent.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,24 +41,24 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.util.Arrays; +import java.util.Collection; import java.util.EventObject; - +import java.util.LinkedHashSet; /** - * Encapsulates information describing changes to a model, and - * used to notify model listeners of the change. + * Encapsulates information describing changes to a model, and used to notify + * model listeners of the change. * - * @author Jan Jancura + * @author Jan Jancura * @since 1.4 */ public class ModelEvent extends EventObject { - private ModelEvent (Object source) { - super (source); + private ModelEvent(Object source) { + super(source); } /** @@ -75,38 +75,52 @@ * * @since 1.4 */ - public TreeChanged (Object source) { - super (source); + public TreeChanged(Object source) { + super(source); } } - + /** * Used to notify that one cell in table has been changed. * * @since 1.4 */ public static class TableValueChanged extends ModelEvent { - + /** * The mask for value change. + * * @since 1.42 */ public static final int VALUE_MASK = 1; /** * The mask for HTML value change. + * * @since 1.42 */ public static final int HTML_VALUE_MASK = 2; /** * The mask for change of the read only state. + * * @since 1.42 */ public static final int IS_READ_ONLY_MASK = 4; - + private Object node; - private String columnID; + private Collection columnIDs = new LinkedHashSet<>(); private int change; - + + @Deprecated + public TableValueChanged( + Object source, + Object node + ) { + super(source); + this.node = node; + this.columnIDs.add(null); + this.change = 0xffffffff; + } + /** * Creates a new instance of TableValueChanged event. * @@ -116,14 +130,22 @@ * * @since 1.4 */ - public TableValueChanged ( - Object source, - Object node, - String columnID + public TableValueChanged( + Object source, + Object node, + String columnID ) { this(source, node, columnID, 0xffffffff); } - + + public TableValueChanged( + Object source, + Object node, + Collection columnIDs + ) { + this(source, node, columnIDs, 0xffffffff); + } + /** * Creates a new instance of TableValueChanged event. * @@ -133,18 +155,39 @@ * @param change one of the *_MASK constants or their aggregation. * @since 1.42 */ - public TableValueChanged ( - Object source, - Object node, - String columnID, - int change + public TableValueChanged( + Object source, + Object node, + String columnID, + int change ) { - super (source); + super(source); this.node = node; - this.columnID = columnID; + this.columnIDs.add(columnID); this.change = change; } - + + /** + * Creates a new instance of TableValueChanged event. + * + * @param source a source if event. + * @param node a changed node instance + * @param columnID a changed column name + * @param change one of the *_MASK constants or their aggregation. + * @since 1.42 + */ + public TableValueChanged( + Object source, + Object node, + Collection columnIDs, + int change + ) { + super(source); + this.node = node; + this.columnIDs.addAll(columnIDs); + this.change = change; + } + /** * Returns changed node instance. * @@ -152,10 +195,10 @@ * * @since 1.4 */ - public Object getNode () { + public Object getNode() { return node; } - + /** * Returns changed column name. * @@ -163,58 +206,64 @@ * * @since 1.4 */ - public String getColumnID () { - return columnID; + public Collection getColumnIDs() { + return columnIDs; } - + /** * Get the change mask. * - * @return the change mask, one of the *_MASK constants or their aggregation. + * @return the change mask, one of the *_MASK constants or their + * aggregation. * @since 1.42 */ public int getChange() { return change; } } - + /** - * Used to notify that one node has been changed (icon, displayName and + * Used to notify that one node has been changed (icon, displayName and * children). * * @since 1.4 */ public static class NodeChanged extends ModelEvent { - + /** * The mask for display name change. + * * @since 1.6 */ public static final int DISPLAY_NAME_MASK = 1; /** * The mask for icon change. + * * @since 1.6 */ public static final int ICON_MASK = 2; /** * The mask for short description change. + * * @since 1.6 */ public static final int SHORT_DESCRIPTION_MASK = 4; /** * The mask for children change. + * * @since 1.6 */ public static final int CHILDREN_MASK = 8; /** * The mask for expansion change. + * * @since 1.15 */ public static final int EXPANSION_MASK = 16; - + private Object node; private int change; - + /** * Creates a new instance of NodeChanged event. * @@ -223,13 +272,13 @@ * * @since 1.4 */ - public NodeChanged ( - Object source, - Object node + public NodeChanged( + Object source, + Object node ) { - this (source, node, 0xFFFFFFFF); + this(source, node, 0xFFFFFFFF); } - + /** * Creates a new instance of NodeChanged event. * @@ -240,11 +289,11 @@ * @since 1.6 */ public NodeChanged(Object source, Object node, int change) { - super (source); + super(source); this.node = node; this.change = change; } - + /** * Returns changed node instance. * @@ -252,14 +301,15 @@ * * @since 1.4 */ - public Object getNode () { + public Object getNode() { return node; } - + /** * Get the change mask. * - * @return the change mask, one of the *_MASK constant or their aggregation. + * @return the change mask, one of the *_MASK constant or their + * aggregation. * @since 1.6 */ public int getChange() { @@ -268,7 +318,7 @@ @Override public String toString() { - return super.toString()+"(node = "+node+", change = "+getChangeString(change)+")"; + return super.toString() + "(node = " + node + ", change = " + getChangeString(change) + ")"; } private static String getChangeString(int change) { @@ -304,16 +354,16 @@ public static class SelectionChanged extends ModelEvent { private Object[] nodes; - + /** * Creates a new instance of SelectionChanged event. * * @param source the source of the event. - * @param nodes list of selected node instances. All nodes are deselected - * when this list is empty. + * @param nodes list of selected node instances. All nodes are + * deselected when this list is empty. */ public SelectionChanged(Object source, Object... nodes) { - super (source); + super(source); this.nodes = nodes; } @@ -328,7 +378,7 @@ @Override public String toString() { - return super.toString()+"(nodes = "+Arrays.toString(nodes)+")"; // NOI18N + return super.toString() + "(nodes = " + Arrays.toString(nodes) + ")"; // NOI18N } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/Model.java spi.viewmodel/src/org/netbeans/spi/viewmodel/Model.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/Model.java 2016-02-04 02:55:43.090100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/Model.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,15 +41,12 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - - /** * Marker interface for all models. * - * @author Jan Jancura + * @author Jan Jancura */ public interface Model { } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelListener.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelListener.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelListener.java 2016-02-04 02:55:43.091100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelListener.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,16 +41,14 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.util.EventListener; - /** * Notifies about changes in view model. * - * @author Jan Jancura + * @author Jan Jancura * @since 1.4 */ public interface ModelListener extends EventListener { @@ -61,5 +59,5 @@ * @param event an event object describing change * @since 1.4 */ - public void modelChanged (ModelEvent event); + public void modelChanged(ModelEvent event); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java 2016-02-04 02:55:43.095100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java 2016-11-03 07:23:29.836689359 +0100 @@ -41,10 +41,10 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import java.awt.Component; +import java.awt.Image; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; import java.awt.event.ActionEvent; @@ -75,7 +75,6 @@ import javax.swing.SwingUtilities; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; - import org.netbeans.modules.viewmodel.AsynchronousModel; import org.netbeans.modules.viewmodel.DefaultTreeExpansionManager; import org.netbeans.modules.viewmodel.HyperCompoundModel; @@ -84,7 +83,6 @@ import org.netbeans.modules.viewmodel.TreeModelNode.ActionOnPresetNodes; import org.netbeans.modules.viewmodel.TreeModelNode.DisableableAction; import org.netbeans.modules.viewmodel.TreeModelRoot; - import org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL; import org.openide.awt.Actions; import org.openide.explorer.ExplorerManager; @@ -92,148 +90,147 @@ import org.openide.explorer.view.TreeView; import org.openide.nodes.Node; import org.openide.util.Exceptions; +import org.openide.util.Lookup; import org.openide.util.datatransfer.PasteType; import org.openide.windows.TopComponent; - /** * Contains various utility methods for various models. * - * @author Jan Jancura + * @author Jan Jancura */ public final class Models { - /** Cached default implementations of expansion models. */ + /** + * Cached default implementations of expansion models. + */ private static final WeakHashMap defaultExpansionModels = new WeakHashMap(); - + /** * Empty model - returns default root node with no children. */ - public static CompoundModel EMPTY_MODEL = createCompoundModel - (new ArrayList ()); - - + public static CompoundModel EMPTY_MODEL = createCompoundModel(new ArrayList()); + public static int MULTISELECTION_TYPE_EXACTLY_ONE = 1; public static int MULTISELECTION_TYPE_ALL = 2; public static int MULTISELECTION_TYPE_ANY = 3; private static final int DEFAULT_DRAG_DROP_ALLOWED_ACTIONS = DnDConstants.ACTION_NONE; - - private static boolean verbose = - System.getProperty ("netbeans.debugger.models") != null; - - + + private static boolean verbose + = System.getProperty("netbeans.debugger.models") != null; + /** - * Creates a new instance of TreeTableView - * for given {@link org.netbeans.spi.viewmodel.Models.CompoundModel}. + * Creates a new instance of TreeTableView for given + * {@link org.netbeans.spi.viewmodel.Models.CompoundModel}. * * @param compoundModel a compound model instance * * @return new instance of complete model view */ - public static JComponent createView ( - CompoundModel compoundModel + public static JComponent createView( + CompoundModel compoundModel ) { /*if (compoundModel.isTree()) { OutlineTree ot = new OutlineTree(); ot.setModel (compoundModel); return ot; } else {*/ - OutlineTable ot = new OutlineTable (); + OutlineTable ot = new OutlineTable(); if (compoundModel != null && compoundModel.isHyperModel()) { ot.setModel(compoundModel.createHyperModel(), compoundModel.getTreeNodeDisplayFormat()); } else { - ot.setModel (compoundModel, (compoundModel != null) ? compoundModel.getTreeNodeDisplayFormat() : null); + ot.setModel(compoundModel, (compoundModel != null) ? compoundModel.getTreeNodeDisplayFormat() : null); } return ot; //} } - + /** - * Creates a root node of the nodes tree structure - * for given {@link org.netbeans.spi.viewmodel.Models.CompoundModel}. + * Creates a root node of the nodes tree structure for given + * {@link org.netbeans.spi.viewmodel.Models.CompoundModel}. * * @param compoundModel a compound model instance - * @param treeView The tree view component where nodes are going to be displayed. + * @param treeView The tree view component where nodes are going to be + * displayed. * * @return new instance root node * @since 1.15 */ - public static Node createNodes ( - CompoundModel compoundModel, - TreeView treeView + public static Node createNodes( + CompoundModel compoundModel, + TreeView treeView ) { if (compoundModel != null && compoundModel.isHyperModel()) { - return new TreeModelRoot (compoundModel.createHyperModel(), treeView).getRootNode(); + return new TreeModelRoot(compoundModel.createHyperModel(), treeView).getRootNode(); } else { - return new TreeModelRoot (compoundModel, treeView).getRootNode(); + return new TreeModelRoot(compoundModel, treeView).getRootNode(); } } - + /** * Set given models to given view instance. * - * @param view a view instance - must be an instance created by {@link #createView} method. + * @param view a view instance - must be an instance created by + * {@link #createView} method. * @param compoundModel a compound model instance */ - public static void setModelsToView ( - final JComponent view, - final CompoundModel compoundModel + public static void setModelsToView( + final JComponent view, + final CompoundModel compoundModel ) { if (!(view instanceof OutlineTable)) { - throw new IllegalArgumentException("Expecting an instance of "+OutlineTable.class.getName()+", which can be obtained from Models.createView(). view = "+view); + throw new IllegalArgumentException("Expecting an instance of " + OutlineTable.class.getName() + ", which can be obtained from Models.createView(). view = " + view); } if (verbose) { - System.out.println (compoundModel); + System.out.println(compoundModel); } - SwingUtilities.invokeLater (new Runnable () { + SwingUtilities.invokeLater(new Runnable() { @Override - public void run () { + public void run() { if (compoundModel != null && compoundModel.isHyperModel()) { - ((OutlineTable) view).setModel (compoundModel.createHyperModel(), compoundModel.getTreeNodeDisplayFormat()); + ((OutlineTable) view).setModel(compoundModel.createHyperModel(), compoundModel.getTreeNodeDisplayFormat()); + } else if (compoundModel != null) { + ((OutlineTable) view).setModel(compoundModel, compoundModel.getTreeNodeDisplayFormat()); } else { - if (compoundModel != null) { - ((OutlineTable) view).setModel (compoundModel, compoundModel.getTreeNodeDisplayFormat()); - } else { - ((OutlineTable) view).setModel (compoundModel); - } + ((OutlineTable) view).setModel(compoundModel); } } }); } - + /** * Creates one {@link CompoundModel} from given list of models. *

* If this list does not include any instance of TreeModel or * TreeExpansionModel, a default implementation of these models is created - * based on the instance of this list. Thus you get one implementation - * per provided instance of the models list. - * + * based on the instance of this list. Thus you get one implementation per + * provided instance of the models list. + * * @param models a list of models * @return {@link CompoundModel} encapsulating given list of models */ - public static CompoundModel createCompoundModel (List models) { + public static CompoundModel createCompoundModel(List models) { return createCompoundModel(models, null); } - + /** * Creates one {@link CompoundModel} from given list of models. *

* If this list does not include any instance of TreeModel or * TreeExpansionModel, a default implementation of these models is created - * based on the instance of this list. Thus you get one implementation - * per provided instance of the models list. - * + * based on the instance of this list. Thus you get one implementation per + * provided instance of the models list. + * * @param models a list of models * @param propertiesHelpID The help ID, which is set for the properties - * sheets created from this model. + * sheets created from this model. * @return {@link CompoundModel} encapsulating given list of models * @since 1.7 */ // TODO: Add createCompoundModel(List models, String propertiesHelpID, RequestProcessor rp) // Or instead of RP use some interface that could provide the desired thread to run in (current, AWT, RP thread,...) - public static CompoundModel createCompoundModel (List models, String propertiesHelpID) { + public static CompoundModel createCompoundModel(List models, String propertiesHelpID) { if (models.size() > 1 && models.get(0) instanceof CompoundModel && models.get(1) instanceof CompoundModel) { // Hypermodel ArrayList subModels = new ArrayList(); @@ -261,17 +258,17 @@ treeNodeDisplayFormat = (MessageFormat) models.remove(models.size() - 1); } ModelLists ml = new ModelLists(); - List otherModels; - + List otherModels; + // Either the list contains 10 lists of individual models + one list of mixed models // + optional TreeExpansionModelFilter(s) + optional AsynchronousModelFilter(s) // ; or the models directly boolean hasLists = false; int modelsSize = models.size(); if (11 <= modelsSize && modelsSize <= 18) { - Iterator it = models.iterator (); + Iterator it = models.iterator(); boolean failure = false; - while (it.hasNext ()) { + while (it.hasNext()) { Object model = it.next(); if (!(model instanceof List)) { failure = true; @@ -283,51 +280,51 @@ } } if (hasLists) { // We have 11 or 12 lists of individual models + optional RP - ml.treeModels = (List) models.get(0); - ml.treeModelFilters = (List) models.get(1); + ml.treeModels = (List) models.get(0); + ml.treeModelFilters = (List) models.get(1); revertOrder(ml.treeModelFilters); - ml.treeExpansionModels = (List) models.get(2); - ml.nodeModels = (List) models.get(3); - ml.nodeModelFilters = (List) models.get(4); + ml.treeExpansionModels = (List) models.get(2); + ml.nodeModels = (List) models.get(3); + ml.nodeModelFilters = (List) models.get(4); revertOrder(ml.nodeModelFilters); - ml.tableModels = (List) models.get(5); - ml.tableModelFilters = (List) models.get(6); + ml.tableModels = (List) models.get(5); + ml.tableModelFilters = (List) models.get(6); revertOrder(ml.tableModelFilters); - ml.nodeActionsProviders = (List) models.get(7); + ml.nodeActionsProviders = (List) models.get(7); ml.nodeActionsProviderFilters = (List) models.get(8); revertOrder(ml.nodeActionsProviderFilters); - ml.columnModels = (List) models.get(9); - otherModels = (List) models.get(10); + ml.columnModels = (List) models.get(9); + otherModels = (List) models.get(10); if (modelsSize > 11) { // TreeExpansionModelFilter ml.treeExpansionModelFilters = (List) models.get(11); //if (modelsSize > 12) { // AsynchronousModel // ml.asynchModels = (List) models.get(12); - if (modelsSize > 12) { // AsynchronousModelFilter - ml.asynchModelFilters = (List) models.get(12); - if (modelsSize > 13) { - ml.tableRendererModels = (List) models.get(13); - if (modelsSize > 14) { - ml.tableRendererModelFilters = (List) models.get(14); - //if (modelsSize > 15) { - // ml.tableHtmlModels = (List) models.get(15); - if (modelsSize > 15) { - ml.tableHtmlModelFilters = (List) models.get(15); - if (modelsSize > 16) { - ml.tablePropertyEditorsModels = (List) models.get(16); - if (modelsSize > 17) { - ml.tablePropertyEditorsModelFilters = (List) models.get(17); - } - } + if (modelsSize > 12) { // AsynchronousModelFilter + ml.asynchModelFilters = (List) models.get(12); + if (modelsSize > 13) { + ml.tableRendererModels = (List) models.get(13); + if (modelsSize > 14) { + ml.tableRendererModelFilters = (List) models.get(14); + //if (modelsSize > 15) { + // ml.tableHtmlModels = (List) models.get(15); + if (modelsSize > 15) { + ml.tableHtmlModelFilters = (List) models.get(15); + if (modelsSize > 16) { + ml.tablePropertyEditorsModels = (List) models.get(16); + if (modelsSize > 17) { + ml.tablePropertyEditorsModelFilters = (List) models.get(17); } - //} + } } + //} } } + } //} } //treeExpansionModelFilters = (models.size() > 11) ? (List) models.get(11) : (List) Collections.EMPTY_LIST; } else { // We have the models, need to find out what they implement - otherModels = (List) models; + otherModels = (List) models; } ml.addOtherModels(otherModels); @@ -362,8 +359,8 @@ return cm; } - private static CompoundModel createCompoundModel (ModelLists ml, String propertiesHelpID) { - if (ml.treeModels.isEmpty ()) { + private static CompoundModel createCompoundModel(ModelLists ml, String propertiesHelpID) { + if (ml.treeModels.isEmpty()) { TreeModel etm = new EmptyTreeModel(); ml.treeModels = Collections.singletonList(etm); } @@ -387,93 +384,97 @@ /*if (ml.asynchModels.isEmpty()) { ml.asynchModels = Collections.singletonList((AsynchronousModel) new DefaultAsynchronousModel()); }*/ - + CompoundModel cm; - if (ml.columnModels == null && ml.tableModels == null && ml.tableModelFilters == null && - ml.tableRendererModels == null && ml.tableRendererModelFilters == null) { - - cm = new CompoundModel ( - createCompoundTreeModel ( - new DelegatingTreeModel (ml.treeModels), - ml.treeModelFilters - ), - createCompoundTreeExpansionModel( - new DelegatingTreeExpansionModel (ml.treeExpansionModels), - ml.treeExpansionModelFilters - ), - createCompoundNodeModel ( - new DelegatingNodeModel (ml.nodeModels), - ml.nodeModelFilters - ), - createCompoundNodeActionsProvider ( - new DelegatingNodeActionsProvider (ml.nodeActionsProviders), - ml.nodeActionsProviderFilters - ), - null, null, - createCompoundAsynchronousModel ( - new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels), - ml.asynchModelFilters - ), - null, null, - propertiesHelpID - ); + if (ml.columnModels == null && ml.tableModels == null && ml.tableModelFilters == null + && ml.tableRendererModels == null && ml.tableRendererModelFilters == null) { + + cm = new CompoundModel( + createCompoundTreeModel( + new DelegatingTreeModel(ml.treeModels), + ml.treeModelFilters + ), + createCompoundTreeExpansionModel( + new DelegatingTreeExpansionModel(ml.treeExpansionModels), + ml.treeExpansionModelFilters + ), + createCompoundNodeModel( + new DelegatingNodeModel(ml.nodeModels), + ml.nodeModelFilters + ), + createCompoundNodeActionsProvider( + new DelegatingNodeActionsProvider(ml.nodeActionsProviders), + ml.nodeActionsProviderFilters + ), + null, null, + createCompoundAsynchronousModel( + new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels), + ml.asynchModelFilters + ), + null, null, + ml.iconNodeModel, + ml.lookupNodeModel, + propertiesHelpID + ); } else { - cm = new CompoundModel ( - createCompoundTreeModel ( - new DelegatingTreeModel (ml.treeModels), - ml.treeModelFilters - ), - createCompoundTreeExpansionModel( - new DelegatingTreeExpansionModel (ml.treeExpansionModels), - ml.treeExpansionModelFilters - ), - createCompoundNodeModel ( - new DelegatingNodeModel (ml.nodeModels), - ml.nodeModelFilters - ), - createCompoundNodeActionsProvider ( - new DelegatingNodeActionsProvider (ml.nodeActionsProviders), - ml.nodeActionsProviderFilters - ), - ml.columnModels, - createCompoundTableModel ( - new DelegatingTableModel (ml.tableModels), - ml.tableModelFilters, - ml.tableHtmlModelFilters - ), - createCompoundAsynchronousModel ( - new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels), - ml.asynchModelFilters - ), - createCompoundTableRendererModel ( - new DelegatingTableRendererModel(ml.tableRendererModels), - ml.tableRendererModelFilters - ), - /*createCompoundTableHTMLModel ( + cm = new CompoundModel( + createCompoundTreeModel( + new DelegatingTreeModel(ml.treeModels), + ml.treeModelFilters + ), + createCompoundTreeExpansionModel( + new DelegatingTreeExpansionModel(ml.treeExpansionModels), + ml.treeExpansionModelFilters + ), + createCompoundNodeModel( + new DelegatingNodeModel(ml.nodeModels), + ml.nodeModelFilters + ), + createCompoundNodeActionsProvider( + new DelegatingNodeActionsProvider(ml.nodeActionsProviders), + ml.nodeActionsProviderFilters + ), + ml.columnModels, + createCompoundTableModel( + new DelegatingTableModel(ml.tableModels), + ml.tableModelFilters, + ml.tableHtmlModelFilters + ), + createCompoundAsynchronousModel( + new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels), + ml.asynchModelFilters + ), + createCompoundTableRendererModel( + new DelegatingTableRendererModel(ml.tableRendererModels), + ml.tableRendererModelFilters + ), + /*createCompoundTableHTMLModel ( new DelegatingTableHTMLModel(ml.tableHtmlModels), ml.tableHtmlModelFilters ),*/ - createCompoundTablePropertyEditorModel ( - new DelegatingTablePropertyEditorsModel(ml.tablePropertyEditorsModels), - ml.tablePropertyEditorsModelFilters - ), - propertiesHelpID - ); + createCompoundTablePropertyEditorModel( + new DelegatingTablePropertyEditorsModel(ml.tablePropertyEditorsModels), + ml.tablePropertyEditorsModelFilters + ), + ml.iconNodeModel, + ml.lookupNodeModel, + propertiesHelpID + ); } if (defaultExpansionModel != null) { defaultExpansionModel.setCompoundModel(cm); } return cm; } - + private static void revertOrder(List filters) { int n = filters.size(); // [TODO] do not remove the following line, prevents null to be returned by filters.remove(i); // needs deeper investigation why it can occure filters.toString(); - for (int i = 0; i < n; ) { + for (int i = 0; i < n;) { T filter = filters.remove(i); - boolean first = filter.getClass ().getName ().endsWith ("First"); + boolean first = filter.getClass().getName().endsWith("First"); if (first) { // The "First" should be the last one in this list filters.add(filter); n--; @@ -483,236 +484,231 @@ } } } - - + /** * Returns {@link javax.swing.Action} for given parameters. * * @param displayName a display name for action * @param performer a performer for action * @param multiselectionType The type of the multi selection - one of the - * MULTISELECTION_TYPE_* constants. + * MULTISELECTION_TYPE_* constants. * * @return a new instance of {@link javax.swing.Action} for given parameters */ - public static Action createAction ( - String displayName, - ActionPerformer performer, - int multiselectionType + public static Action createAction( + String displayName, + ActionPerformer performer, + int multiselectionType ) { - return new ActionSupport ( - displayName, - performer, - multiselectionType + return new ActionSupport( + displayName, + performer, + multiselectionType ); } - + /** * Returns implementation of tree view features for given view. * * @param view a view created by this Models class - * @throws UnsupportedOperationException in the case that given - * view is not tree view + * @throws UnsupportedOperationException in the case that given view is not + * tree view * @return implementation of tree view features */ - public static TreeFeatures treeFeatures (JComponent view) - throws UnsupportedOperationException { - return new DefaultTreeFeatures (view); + public static TreeFeatures treeFeatures(JComponent view) + throws UnsupportedOperationException { + return new DefaultTreeFeatures(view); } - - + // private methods ......................................................... - /** - * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel and - * {@link org.netbeans.spi.viewmodel.TreeModelFilter}. - * + * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel + * and {@link org.netbeans.spi.viewmodel.TreeModelFilter}. + * * @param originalTreeModel a original tree model * @param treeModelFilter a list of tree model filters * * @returns compund tree model */ - private static ReorderableTreeModel createCompoundTreeModel ( - ReorderableTreeModel originalTreeModel, - List treeModelFilters + private static ReorderableTreeModel createCompoundTreeModel( + ReorderableTreeModel originalTreeModel, + List treeModelFilters ) { ReorderableTreeModel tm = originalTreeModel; - int i, k = treeModelFilters.size (); + int i, k = treeModelFilters.size(); for (i = 0; i < k; i++) { - tm = new CompoundTreeModel ( - tm, - (TreeModelFilter) treeModelFilters.get (i) + tm = new CompoundTreeModel( + tm, + (TreeModelFilter) treeModelFilters.get(i) ); } return tm; } - + /** - * Creates {@link org.netbeans.spi.viewmodel.NodeModel} for given NodeModel and - * {@link org.netbeans.spi.viewmodel.NodeModelFilter}. - * + * Creates {@link org.netbeans.spi.viewmodel.NodeModel} for given NodeModel + * and {@link org.netbeans.spi.viewmodel.NodeModelFilter}. + * * @param originalNodeModel a original node model * @param nodeModelFilters a list of node model filters * * @returns compound tree model */ - private static SuperNodeModel createCompoundNodeModel ( - SuperNodeModel originalNodeModel, - List treeNodeModelFilters + private static SuperNodeModel createCompoundNodeModel( + SuperNodeModel originalNodeModel, + List treeNodeModelFilters ) { SuperNodeModel nm = originalNodeModel; - int i, k = treeNodeModelFilters.size (); + int i, k = treeNodeModelFilters.size(); for (i = 0; i < k; i++) { - nm = new CompoundNodeModel ( - nm, - (NodeModelFilter) treeNodeModelFilters.get (i) + nm = new CompoundNodeModel( + nm, + (NodeModelFilter) treeNodeModelFilters.get(i) ); } return nm; } - + /** - * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and - * {@link org.netbeans.spi.viewmodel.TableModelFilter}. - * + * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given + * TableModel and {@link org.netbeans.spi.viewmodel.TableModelFilter}. + * * @param originalTableModel a original table model * @param tableModelFilters a list of table model filters * * @returns compound table model */ - private static TableHTMLModel createCompoundTableModel ( - TableHTMLModel originalTableModel, - List tableModelFilters, - List tableHtmlModelFilters + private static TableHTMLModel createCompoundTableModel( + TableHTMLModel originalTableModel, + List tableModelFilters, + List tableHtmlModelFilters ) { TableHTMLModel tm = originalTableModel; - int i, k = tableModelFilters.size (); + int i, k = tableModelFilters.size(); for (i = 0; i < k; i++) { - tm = new CompoundTableModel ( - tm, - (TableModelFilter) tableModelFilters.get (i) + tm = new CompoundTableModel( + tm, + (TableModelFilter) tableModelFilters.get(i) ); } - k = tableHtmlModelFilters.size (); + k = tableHtmlModelFilters.size(); for (i = 0; i < k; i++) { - tm = new CompoundTableModel ( - tm, - (TableHTMLModelFilter) tableHtmlModelFilters.get (i) + tm = new CompoundTableModel( + tm, + (TableHTMLModelFilter) tableHtmlModelFilters.get(i) ); } return tm; } - + /** - * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and - * {@link org.netbeans.spi.viewmodel.TableModelFilter}. + * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given + * TableModel and {@link org.netbeans.spi.viewmodel.TableModelFilter}. * * @param originalTableModel a original table model * @param tableModelFilters a list of table model filters * * @returns compound table model */ - private static TableRendererModel createCompoundTableRendererModel ( - TableRendererModel originalTableModel, - List tableModelFilters + private static TableRendererModel createCompoundTableRendererModel( + TableRendererModel originalTableModel, + List tableModelFilters ) { TableRendererModel tm = originalTableModel; - int i, k = tableModelFilters.size (); + int i, k = tableModelFilters.size(); for (i = 0; i < k; i++) { - tm = new CompoundTableRendererModel ( - tm, - (TableRendererModelFilter) tableModelFilters.get (i) + tm = new CompoundTableRendererModel( + tm, + (TableRendererModelFilter) tableModelFilters.get(i) ); } return tm; } - - private static TablePropertyEditorsModel createCompoundTablePropertyEditorModel ( - TablePropertyEditorsModel originalTableModel, - List tableModelFilters + + private static TablePropertyEditorsModel createCompoundTablePropertyEditorModel( + TablePropertyEditorsModel originalTableModel, + List tableModelFilters ) { TablePropertyEditorsModel tm = originalTableModel; - int i, k = tableModelFilters.size (); + int i, k = tableModelFilters.size(); for (i = 0; i < k; i++) { - tm = new CompoundTablePropertyEditorsModel ( - tm, - (TablePropertyEditorsModelFilter) tableModelFilters.get (i) + tm = new CompoundTablePropertyEditorsModel( + tm, + (TablePropertyEditorsModelFilter) tableModelFilters.get(i) ); } return tm; } /** - * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for given NodeActionsProvider and + * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for given + * NodeActionsProvider and * {@link org.netbeans.spi.viewmodel.NodeActionsProviderFilter}. - * + * * @param originalNodeActionsProvider a original node actions provider * @param nodeActionsProviderFilters a list of node actions provider filters * * @returns compound node actions provider */ - private static NodeActionsProvider createCompoundNodeActionsProvider ( - NodeActionsProvider originalNodeActionsProvider, - List nodeActionsProviderFilters + private static NodeActionsProvider createCompoundNodeActionsProvider( + NodeActionsProvider originalNodeActionsProvider, + List nodeActionsProviderFilters ) { NodeActionsProvider nap = originalNodeActionsProvider; - int i, k = nodeActionsProviderFilters.size (); + int i, k = nodeActionsProviderFilters.size(); for (i = 0; i < k; i++) { - nap = new CompoundNodeActionsProvider ( - nap, - (NodeActionsProviderFilter) nodeActionsProviderFilters.get (i) + nap = new CompoundNodeActionsProvider( + nap, + (NodeActionsProviderFilter) nodeActionsProviderFilters.get(i) ); } return nap; } - - private static TreeExpansionModel createCompoundTreeExpansionModel ( + + private static TreeExpansionModel createCompoundTreeExpansionModel( TreeExpansionModel expansionModel, List filters ) { for (TreeExpansionModelFilter filter : filters) { - expansionModel = new CompoundTreeExpansionModel (expansionModel, filter); + expansionModel = new CompoundTreeExpansionModel(expansionModel, filter); } return expansionModel; } - private static AsynchronousModel createCompoundAsynchronousModel ( + private static AsynchronousModel createCompoundAsynchronousModel( AsynchronousModel asynchModel, List filters ) { for (AsynchronousModelFilter filter : filters) { - asynchModel = new CompoundAsynchronousModel (asynchModel, filter); + asynchModel = new CompoundAsynchronousModel(asynchModel, filter); } return asynchModel; } - - + // innerclasses ............................................................ - /** - * @author Jan Jancura + * @author Jan Jancura */ private static class ActionSupport extends AbstractAction implements DisableableAction, - ActionOnPresetNodes { + ActionOnPresetNodes { - private ActionPerformer performer; - private int multiselectionType; - private String displayName; - private PrivilegedAction enabledTest; - private List presetNodes; - - - ActionSupport ( - String displayName, - ActionPerformer performer, - int multiselectionType + private ActionPerformer performer; + private int multiselectionType; + private String displayName; + private PrivilegedAction enabledTest; + private List presetNodes; + + ActionSupport( + String displayName, + ActionPerformer performer, + int multiselectionType ) { - super (displayName); + super(displayName); this.performer = performer; this.displayName = displayName; this.multiselectionType = multiselectionType; } - + @Override public void addNode(Node n) { if (SwingUtilities.isEventDispatchThread()) { @@ -723,20 +719,20 @@ presetNodes.add(n); } } - + private Node[] getActiveNodes(ActionEvent e) { Node[] nodes = null; if (e != null) { nodes = getOutlineViewSelection(e); } else if (presetNodes != null) { - nodes = presetNodes.toArray(new Node[] {}); + nodes = presetNodes.toArray(new Node[]{}); } if (nodes == null) { nodes = TopComponent.getRegistry().getActivatedNodes(); } return nodes; } - + private Node[] getOutlineViewSelection(ActionEvent e) { Object source = e.getSource(); if (source instanceof Component) { @@ -762,9 +758,9 @@ } return null; } - + @Override - public boolean isEnabled () { + public boolean isEnabled() { if (enabledTest != null) { if (Boolean.FALSE.equals(enabledTest.run())) { return false; @@ -776,8 +772,8 @@ if (ns.length != 1) { return false; } - return performer.isEnabled ( - ns[0].getLookup().lookup(Object.class) + return performer.isEnabled( + ns[0].getLookup().lookup(Object.class) ); } int i, k = ns.length; @@ -803,23 +799,23 @@ } @Override - public void actionPerformed (ActionEvent e) { + public void actionPerformed(ActionEvent e) { //System.err.println("Models.ActionSupport.actionPerformed("+e+")"); Node[] ns = getActiveNodes(e); int i, k = ns.length; IdentityHashMap> h = new IdentityHashMap>(); for (i = 0; i < k; i++) { Object node = ns[i].getLookup().lookup(Object.class); - Action[] as = ns [i].getActions (false); + Action[] as = ns[i].getActions(false); int j, jj = as.length; for (j = 0; j < jj; j++) { - if (equals (as [j])) { - ArrayList l = h.get (as [j]); + if (equals(as[j])) { + ArrayList l = h.get(as[j]); if (l == null) { l = new ArrayList(); - h.put (as [j], l); + h.put(as[j], l); } - l.add (node); + l.add(node); } } } @@ -830,26 +826,26 @@ } } else { //System.err.println(" h = "+h); - Iterator it = h.keySet ().iterator (); - while (it.hasNext ()) { - ActionSupport a = (ActionSupport) it.next (); + Iterator it = h.keySet().iterator(); + while (it.hasNext()) { + ActionSupport a = (ActionSupport) it.next(); //System.err.println(" "+a.performer+".perform("+((ArrayList) h.get (a))); - a.performer.perform ( - ((ArrayList) h.get (a)).toArray () + a.performer.perform( + ((ArrayList) h.get(a)).toArray() ); } } } - + @Override - public int hashCode () { - return displayName.hashCode (); + public int hashCode() { + return displayName.hashCode(); } - + @Override - public boolean equals (Object o) { - return (o instanceof ActionSupport) && - displayName.equals (((ActionSupport) o).displayName); + public boolean equals(Object o) { + return (o instanceof ActionSupport) + && displayName.equals(((ActionSupport) o).displayName); } @Override @@ -864,19 +860,19 @@ } return a; } - + private class PresetNodesCleaner implements Runnable { @Override public void run() { presetNodes = null; } - + } } /** - * Support interface for + * Support interface for * {@link #createAction(String,Models.ActionPerformer,int)} method. */ public static interface ActionPerformer { @@ -889,97 +885,94 @@ * * @see #createAction(String,Models.ActionPerformer,int) */ - public boolean isEnabled (Object node); + public boolean isEnabled(Object node); /** - * Called when action action is performed for - * nodes. + * Called when action action is performed for nodes. * * @param nodes nodes the action should be applied to * * @see #createAction(String,Models.ActionPerformer,int) */ - public void perform (Object[] nodes); + public void perform(Object[] nodes); } /** - * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel and - * {@link org.netbeans.spi.viewmodel.TreeModelFilter}. - * - * @author Jan Jancura + * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel + * and {@link org.netbeans.spi.viewmodel.TreeModelFilter}. + * + * @author Jan Jancura */ private final static class CompoundTreeModel implements ReorderableTreeModel, ModelListener { - private ReorderableTreeModel model; private TreeModelFilter filter; - + private final Collection modelListeners = new HashSet(); - /** - * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel and - * {@link org.netbeans.spi.viewmodel.TreeModelFilter}. + * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given + * TreeModel and {@link org.netbeans.spi.viewmodel.TreeModelFilter}. */ - CompoundTreeModel (ReorderableTreeModel model, TreeModelFilter filter) { + CompoundTreeModel(ReorderableTreeModel model, TreeModelFilter filter) { this.model = model; this.filter = filter; } - /** + /** * Returns the root node of the tree or null, if the tree is empty. * * @return the root node of the tree or null */ @Override - public Object getRoot () { - return filter.getRoot (model); + public Object getRoot() { + return filter.getRoot(model); } - /** + /** * Returns children for given parent on given indexes. * - * @param parent a parent of returned nodes - * @throws NoInformationException if the set of children can not be - * resolved - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type + * @param parent a parent of returned nodes + * @throws NoInformationException if the set of children can not be + * resolved + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type * - * @return children for given parent on given indexes + * @return children for given parent on given indexes */ @Override - public Object[] getChildren (Object parent, int from, int to) - throws UnknownTypeException { + public Object[] getChildren(Object parent, int from, int to) + throws UnknownTypeException { - return filter.getChildren (model, parent, from, to); + return filter.getChildren(model, parent, from, to); } - + /** * Returns number of children for given node. - * - * @param node the parent node - * @throws NoInformationException if the set of children can not be - * resolved - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws NoInformationException if the set of children can not be + * resolved + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf */ @Override - public int getChildrenCount (Object node) throws UnknownTypeException { - return filter.getChildrenCount (model, node); + public int getChildrenCount(Object node) throws UnknownTypeException { + return filter.getChildrenCount(model, node); } /** * Returns true if node is leaf. - * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * @return true if node is leaf + * + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * @return true if node is leaf */ @Override - public boolean isLeaf (Object node) throws UnknownTypeException { - return filter.isLeaf (model, node); + public boolean isLeaf(Object node) throws UnknownTypeException { + return filter.isLeaf(model, node); } @Override @@ -1000,84 +993,84 @@ } } - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { synchronized (modelListeners) { if (modelListeners.isEmpty()) { - filter.addModelListener (this); - model.addModelListener (this); + filter.addModelListener(this); + model.addModelListener(this); } modelListeners.add(l); } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { synchronized (modelListeners) { modelListeners.remove(l); removeLonelyModelRootChangelisteners(modelListeners); if (modelListeners.isEmpty()) { - filter.removeModelListener (this); - model.removeModelListener (this); + filter.removeModelListener(this); + model.removeModelListener(this); } } } @Override public void modelChanged(ModelEvent event) { - if (event instanceof ModelEvent.NodeChanged && - (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) { + if (event instanceof ModelEvent.NodeChanged + && (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) { // CompoundNodeModel.modelChanged() takes this. - return ; + return; } - if (event instanceof ModelEvent.TableValueChanged && - (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { + if (event instanceof ModelEvent.TableValueChanged + && (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { // CompoundTableModel.modelChanged() takes this. - return ; + return; } ModelEvent newEvent = translateEvent(event, this); Collection listeners; synchronized (modelListeners) { listeners = new ArrayList(modelListeners); } - for (Iterator it = listeners.iterator(); it.hasNext(); ) { + for (Iterator it = listeners.iterator(); it.hasNext();) { it.next().modelChanged(newEvent); } } - + @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { if (model instanceof CompoundTreeModel) { - return n + filter + "\n" + - ((CompoundTreeModel) model).toString (n + " "); + return n + filter + "\n" + + ((CompoundTreeModel) model).toString(n + " "); } - return n + filter + "\n" + - n + " " + model; + return n + filter + "\n" + + n + " " + model; } } - + private static void removeLonelyModelRootChangelisteners(Collection listeners) { if (listeners.isEmpty()) { - return ; + return; } for (ModelListener ml : listeners) { if (!(ml instanceof ModelRootChangeListener)) { - return ; + return; } } listeners.clear(); @@ -1092,7 +1085,7 @@ } else if (event instanceof ModelEvent.TableValueChanged) { newEvent = new ModelEvent.TableValueChanged(newSource, ((ModelEvent.TableValueChanged) event).getNode(), - ((ModelEvent.TableValueChanged) event).getColumnID(), + ((ModelEvent.TableValueChanged) event).getColumnIDs(), ((ModelEvent.TableValueChanged) event).getChange()); } else if (event instanceof ModelEvent.TreeChanged) { newEvent = new ModelEvent.TreeChanged(newSource); @@ -1101,16 +1094,15 @@ } return newEvent; } - + /** - * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel and - * {@link org.netbeans.spi.viewmodel.TreeModelFilter}. - * - * @author Jan Jancura + * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel + * and {@link org.netbeans.spi.viewmodel.TreeModelFilter}. + * + * @author Jan Jancura */ private final static class CompoundNodeModel implements SuperNodeModel, - ModelListener { - + ModelListener { private SuperNodeModel model; private NodeModelFilter filter; @@ -1119,12 +1111,11 @@ private final Collection modelListeners = new HashSet(); - /** - * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given TreeModel and - * {@link org.netbeans.spi.viewmodel.TreeModelFilter}. + * Creates {@link org.netbeans.spi.viewmodel.TreeModel} for given + * TreeModel and {@link org.netbeans.spi.viewmodel.TreeModelFilter}. */ - CompoundNodeModel (SuperNodeModel model, NodeModelFilter filter) { + CompoundNodeModel(SuperNodeModel model, NodeModelFilter filter) { this.model = model; this.filter = filter; if (filter instanceof CheckNodeModelFilter) { @@ -1134,120 +1125,119 @@ this.dndfilter = (DnDNodeModelFilter) filter; } } - + /** * Returns display name for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve display name for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve display name for given node type + * @return display name for given node */ @Override - public String getDisplayName (Object node) - throws UnknownTypeException { - return filter.getDisplayName (model, node); + public String getDisplayName(Object node) + throws UnknownTypeException { + return filter.getDisplayName(model, node); } /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve icon for given node type + * @return icon for given node */ @Override - public String getIconBase (Object node) - throws UnknownTypeException { - return filter.getIconBase (model, node); + public String getIconBase(Object node) + throws UnknownTypeException { + return filter.getIconBase(model, node); } /** * Returns tool tip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tool tip for given node type - * @return tool tip for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve tool tip for given node type + * @return tool tip for given node */ @Override - public String getShortDescription (Object node) - throws UnknownTypeException { - return filter.getShortDescription (model, node); + public String getShortDescription(Object node) + throws UnknownTypeException { + return filter.getShortDescription(model, node); } - - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { synchronized (modelListeners) { if (modelListeners.isEmpty()) { - filter.addModelListener (this); - model.addModelListener (this); + filter.addModelListener(this); + model.addModelListener(this); } modelListeners.add(l); } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { synchronized (modelListeners) { modelListeners.remove(l); removeLonelyModelRootChangelisteners(modelListeners); if (modelListeners.isEmpty()) { - filter.removeModelListener (this); - model.removeModelListener (this); + filter.removeModelListener(this); + model.removeModelListener(this); } } } @Override public void modelChanged(ModelEvent event) { - if (event instanceof ModelEvent.TableValueChanged && - (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { + if (event instanceof ModelEvent.TableValueChanged + && (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { // CompoundTableModel.modelChanged() takes this. - return ; + return; } - if (event instanceof ModelEvent.TreeChanged && - (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { + if (event instanceof ModelEvent.TreeChanged + && (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { // CompoundTreeModel.modelChanged() takes this. - return ; + return; } ModelEvent newEvent = translateEvent(event, this); Collection listeners; synchronized (modelListeners) { listeners = new ArrayList(modelListeners); } - for (Iterator it = listeners.iterator(); it.hasNext(); ) { + for (Iterator it = listeners.iterator(); it.hasNext();) { it.next().modelChanged(newEvent); } } - + @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { if (model instanceof CompoundNodeModel) { - return n + filter + "\n" + - ((CompoundNodeModel) model).toString (n + " "); + return n + filter + "\n" + + ((CompoundNodeModel) model).toString(n + " "); } if (model instanceof DelegatingNodeModel) { - return n + filter + "\n" + - ((DelegatingNodeModel) model).toString (n + " "); + return n + filter + "\n" + + ((DelegatingNodeModel) model).toString(n + " "); } - return n + filter + "\n" + - n + " " + model; + return n + filter + "\n" + + n + " " + model; } - + @Override public boolean canRename(Object node) throws UnknownTypeException { if (filter instanceof ExtendedNodeModelFilter) { @@ -1277,7 +1267,7 @@ @Override public Transferable clipboardCopy(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { if (filter instanceof ExtendedNodeModelFilter) { return ((ExtendedNodeModelFilter) filter).clipboardCopy(model, node); } else { @@ -1287,7 +1277,7 @@ @Override public Transferable clipboardCut(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { if (filter instanceof ExtendedNodeModelFilter) { return ((ExtendedNodeModelFilter) filter).clipboardCut(model, node); } else { @@ -1315,7 +1305,7 @@ @Override public Transferable drag(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { if (dndfilter != null) { return dndfilter.drag(model, node); } else { @@ -1334,7 +1324,7 @@ @Override public PasteType getDropType(Object node, Transferable t, int action, - int index) throws UnknownTypeException { + int index) throws UnknownTypeException { if (dndfilter != null) { return dndfilter.getDropType(model, node, t, action, index); } else { @@ -1366,9 +1356,9 @@ // The filter can not process the icon base filtering // Perhaps it needs to be upgraded to ExtendedNodeModelFilter Logger.getLogger(Models.class.getName()).log(Level.CONFIG, - "The filter "+filter+" does not perform icon base filtering for "+node+".\n"+ - "If this is a problem, it should be upgraded to "+ - "ExtendedNodeModelFilter and getIconBaseWithExtension() implemented.", + "The filter " + filter + " does not perform icon base filtering for " + node + ".\n" + + "If this is a problem, it should be upgraded to " + + "ExtendedNodeModelFilter and getIconBaseWithExtension() implemented.", utex); base = model.getIconBaseWithExtension(node); } @@ -1412,56 +1402,74 @@ } } + @Override + public void setSelected(Object... nodes) throws UnknownTypeException { + if (cfilter != null) { + cfilter.setSelected(model, nodes); + } else { + model.setSelected(nodes); + } + } + + @Override + public void setUnselected(Object... nodes) throws UnknownTypeException { + if (cfilter != null) { + cfilter.setUnselected(model, nodes); + } else { + model.setUnselected(nodes); + } + } } - + /** - * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and - * {@link org.netbeans.spi.viewmodel.TableModelFilter}. - * - * @author Jan Jancura + * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given + * TableModel and {@link org.netbeans.spi.viewmodel.TableModelFilter}. + * + * @author Jan Jancura */ private final static class CompoundTableModel implements TableHTMLModel, ModelListener { - private TableHTMLModel model; private TableModelFilter filter; private TableHTMLModelFilter htmlFilter; private final Collection modelListeners = new HashSet(); - /** - * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and - * {@link org.netbeans.spi.viewmodel.TableModelFilter}. + * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given + * TableModel and {@link org.netbeans.spi.viewmodel.TableModelFilter}. */ - CompoundTableModel (TableHTMLModel model, TableModelFilter filter) { + CompoundTableModel(TableHTMLModel model, TableModelFilter filter) { this.model = model; this.filter = filter; } - - CompoundTableModel (TableHTMLModel model, TableHTMLModelFilter htmlFilter) { + + CompoundTableModel(TableHTMLModel model, TableHTMLModelFilter htmlFilter) { this.model = model; this.htmlFilter = htmlFilter; } - + /** - * Returns value to be displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Returns value to be displayed in column columnID and row + * node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @TreeModel#getChildren}. + * + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return value of variable representing given position in tree table. */ @Override - public Object getValueAt (Object node, String columnID) throws - UnknownTypeException { + public Object getValueAt(Object node, String columnID) throws + UnknownTypeException { if (filter != null) { - return filter.getValueAt (model, node, columnID); + return filter.getValueAt(model, node, columnID); } else { return model.getValueAt(node, columnID); } @@ -1486,83 +1494,89 @@ } /** - * Returns true if value displayed in column columnID - * and row node is read only. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Returns true if value displayed in column columnID and + * row node is read only. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { + * + * @TreeModel#getChildren}. * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return true if variable on given position is read only */ @Override - public boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException { + public boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException { if (filter != null) { - return filter.isReadOnly (model, node, columnID); + return filter.isReadOnly(model, node, columnID); } else { return model.isReadOnly(node, columnID); } } /** - * Changes a value displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Changes a value displayed in column columnID and row + * node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @TreeModel#getChildren}. + * + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} * @param value a new value of variable on given position - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type */ @Override - public void setValueAt (Object node, String columnID, Object value) - throws UnknownTypeException { + public void setValueAt(Object node, String columnID, Object value) + throws UnknownTypeException { if (filter != null) { - filter.setValueAt (model, node, columnID, value); + filter.setValueAt(model, node, columnID, value); } else { model.setValueAt(node, columnID, value); } } - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { synchronized (modelListeners) { if (modelListeners.isEmpty()) { if (filter != null) { - filter.addModelListener (this); + filter.addModelListener(this); } - model.addModelListener (this); + model.addModelListener(this); } modelListeners.add(l); } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { synchronized (modelListeners) { modelListeners.remove(l); removeLonelyModelRootChangelisteners(modelListeners); if (modelListeners.isEmpty()) { if (filter != null) { - filter.removeModelListener (this); + filter.removeModelListener(this); } - model.removeModelListener (this); + model.removeModelListener(this); } } } @@ -1571,61 +1585,61 @@ public void modelChanged(ModelEvent event) { if (event instanceof ModelEvent.NodeChanged && (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) { // CompoundNodeModel.modelChanged() takes this. - return ; + return; } - if (event instanceof ModelEvent.TreeChanged && - (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { + if (event instanceof ModelEvent.TreeChanged + && (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { // CompoundTreeModel.modelChanged() takes this. - return ; + return; } ModelEvent newEvent = translateEvent(event, this); Collection listeners; synchronized (modelListeners) { listeners = new ArrayList(modelListeners); } - for (Iterator it = listeners.iterator(); it.hasNext(); ) { + for (Iterator it = listeners.iterator(); it.hasNext();) { it.next().modelChanged(newEvent); } } - + @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { Model theFilter = (filter != null) ? filter : htmlFilter; if (model instanceof CompoundTableModel) { - return n + theFilter + "\n" + - ((CompoundTableModel) model).toString (n + " "); + return n + theFilter + "\n" + + ((CompoundTableModel) model).toString(n + " "); } if (model instanceof DelegatingTableModel) { - return n + theFilter + "\n" + - ((DelegatingTableModel) model).toString (n + " "); + return n + theFilter + "\n" + + ((DelegatingTableModel) model).toString(n + " "); } - return n + theFilter + "\n" + - n + " " + model; + return n + theFilter + "\n" + + n + " " + model; } } /** - * Creates {@link org.netbeans.spi.viewmodel.TableRendererModel} for given TableRendererModel and + * Creates {@link org.netbeans.spi.viewmodel.TableRendererModel} for given + * TableRendererModel and * {@link org.netbeans.spi.viewmodel.TableRendererModelFilter}. */ private final static class CompoundTableRendererModel implements TableRendererModel, ModelListener { - private TableRendererModel model; private TableRendererModelFilter filter; private final Collection modelListeners = new HashSet(); - /** - * Creates {@link org.netbeans.spi.viewmodel.TableRendererModel} for given TableRendererModel and + * Creates {@link org.netbeans.spi.viewmodel.TableRendererModel} for + * given TableRendererModel and * {@link org.netbeans.spi.viewmodel.TableRendererModelFilter}. */ - CompoundTableRendererModel (TableRendererModel model, TableRendererModelFilter filter) { + CompoundTableRendererModel(TableRendererModel model, TableRendererModelFilter filter) { this.model = model; this.filter = filter; } @@ -1649,18 +1663,18 @@ public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException { return filter.getCellEditor(model, node, columnID); } - + /** * Registers given listener. * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { synchronized (modelListeners) { if (modelListeners.isEmpty()) { - filter.addModelListener (this); - model.addModelListener (this); + filter.addModelListener(this); + model.addModelListener(this); } modelListeners.add(l); } @@ -1672,13 +1686,13 @@ * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { synchronized (modelListeners) { modelListeners.remove(l); removeLonelyModelRootChangelisteners(modelListeners); if (modelListeners.isEmpty()) { - filter.removeModelListener (this); - model.removeModelListener (this); + filter.removeModelListener(this); + model.removeModelListener(this); } } } @@ -1687,201 +1701,200 @@ public void modelChanged(ModelEvent event) { if (event instanceof ModelEvent.NodeChanged && (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) { // CompoundNodeModel.modelChanged() takes this. - return ; + return; } - if (event instanceof ModelEvent.TreeChanged && - (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { + if (event instanceof ModelEvent.TreeChanged + && (event.getSource() instanceof TreeModel || event.getSource() instanceof TreeModelFilter)) { // CompoundTreeModel.modelChanged() takes this. - return ; + return; } ModelEvent newEvent = translateEvent(event, this); Collection listeners; synchronized (modelListeners) { listeners = new ArrayList(modelListeners); } - for (Iterator it = listeners.iterator(); it.hasNext(); ) { + for (Iterator it = listeners.iterator(); it.hasNext();) { it.next().modelChanged(newEvent); } } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - public String toString (String n) { + public String toString(String n) { if (model instanceof CompoundTableRendererModel) { - return n + filter + "\n" + - ((CompoundTableRendererModel) model).toString (n + " "); + return n + filter + "\n" + + ((CompoundTableRendererModel) model).toString(n + " "); } if (model instanceof DelegatingTableRendererModel) { - return n + filter + "\n" + - ((DelegatingTableRendererModel) model).toString (n + " "); + return n + filter + "\n" + + ((DelegatingTableRendererModel) model).toString(n + " "); } - return n + filter + "\n" + - n + " " + model; + return n + filter + "\n" + + n + " " + model; } } /** - * Creates one {@link org.netbeans.spi.viewmodel.TreeModel} - * from given list of TreeModels. DelegatingTreeModel asks all underlaying - * models for each concrete parameter, and returns first returned value. + * Creates one {@link org.netbeans.spi.viewmodel.TreeModel} from given list + * of TreeModels. DelegatingTreeModel asks all underlaying models for each + * concrete parameter, and returns first returned value. * - * @author Jan Jancura + * @author Jan Jancura */ private final static class DelegatingTreeModel implements ReorderableTreeModel { private TreeModel[] models; private HashMap classNameToModel = new HashMap(); - /** - * Creates new instance of DelegatingTreeModel for given list of + * Creates new instance of DelegatingTreeModel for given list of * TableModels. * * @param models a list of TableModels */ - DelegatingTreeModel (List models) { - this (convert (models)); + DelegatingTreeModel(List models) { + this(convert(models)); } - private static TreeModel[] convert (List l) { - TreeModel[] models = new TreeModel [l.size ()]; - return l.toArray (models); - } + private static TreeModel[] convert(List l) { + TreeModel[] models = new TreeModel[l.size()]; + return l.toArray(models); + } /** - * Creates new instance of DelegatingTreeModel for given array of + * Creates new instance of DelegatingTreeModel for given array of * TableModels. * * @param models a array of TreeModel */ - private DelegatingTreeModel (TreeModel[] models) { - this.models = models; + private DelegatingTreeModel(TreeModel[] models) { + this.models = models; } - - /** + + /** * Returns the root node of the tree or null, if the tree is empty. * * @return the root node of the tree or null */ @Override - public Object getRoot () { - return models [0].getRoot (); + public Object getRoot() { + return models[0].getRoot(); } - /** + /** * Returns children for given parent on given indexes. * - * @param parent a parent of returned nodes - * @param from a start index - * @param to a end index + * @param parent a parent of returned nodes + * @param from a start index + * @param to a end index * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type * - * @return children for given parent on given indexes + * @return children for given parent on given indexes */ @Override - public Object[] getChildren (Object node, int from, int to) - throws UnknownTypeException { - TreeModel model = classNameToModel.get ( - node.getClass ().getName () + public Object[] getChildren(Object node, int from, int to) + throws UnknownTypeException { + TreeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getChildren (node, from, to); + return model.getChildren(node, from, to); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - Object[] v = models [i].getChildren (node, from, to); - classNameToModel.put (node.getClass ().getName (), models [i]); + Object[] v = models[i].getChildren(node, from, to); + classNameToModel.put(node.getClass().getName(), models[i]); return v; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); - } + throw new UnknownTypeException(node); + } /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf * @since 1.1 */ @Override - public int getChildrenCount (Object node) - throws UnknownTypeException { - TreeModel model = (TreeModel) classNameToModel.get ( - node.getClass ().getName () + public int getChildrenCount(Object node) + throws UnknownTypeException { + TreeModel model = (TreeModel) classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getChildrenCount (node); + return model.getChildrenCount(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - int result = models [i].getChildrenCount (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + int result = models[i].getChildrenCount(node); + classNameToModel.put(node.getClass().getName(), models[i]); return result; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); - } + throw new UnknownTypeException(node); + } /** * Returns true if node is leaf. - * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * @return true if node is leaf + * + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * @return true if node is leaf */ @Override - public boolean isLeaf (Object node) throws UnknownTypeException { - TreeModel model = classNameToModel.get ( - node.getClass ().getName () + public boolean isLeaf(Object node) throws UnknownTypeException { + TreeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.isLeaf (node); + return model.isLeaf(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - boolean result = models [i].isLeaf (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean result = models[i].isLeaf(node); + classNameToModel.put(node.getClass().getName(), models[i]); return result; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } @Override public boolean canReorder(Object parent) throws UnknownTypeException { UnknownTypeException uex = null; - TreeModel model = classNameToModel.get ( - parent.getClass ().getName () + TreeModel model = classNameToModel.get( + parent.getClass().getName() ); if (model != null) { if (model instanceof ReorderableTreeModel) { try { - return ((ReorderableTreeModel) model).canReorder (parent); + return ((ReorderableTreeModel) model).canReorder(parent); } catch (UnknownTypeException e) { uex = e; } @@ -1892,7 +1905,7 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ReorderableTreeModel) { try { - boolean cr = ((ReorderableTreeModel) models [i]).canReorder (parent); + boolean cr = ((ReorderableTreeModel) models[i]).canReorder(parent); //classNameToModel.put (parent.getClass ().getName (), models [i]); return cr; } catch (UnknownTypeException e) { @@ -1907,19 +1920,19 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (parent); + throw new UnknownTypeException(parent); } } @Override public void reorder(Object parent, int[] perm) throws UnknownTypeException { - TreeModel model = (TreeModel) classNameToModel.get ( - parent.getClass ().getName () + TreeModel model = (TreeModel) classNameToModel.get( + parent.getClass().getName() ); if (model instanceof ReorderableTreeModel) { try { ((ReorderableTreeModel) model).reorder(parent, perm); - return ; + return; } catch (UnknownTypeException e) { } } @@ -1929,24 +1942,24 @@ try { ((ReorderableTreeModel) models[i]).reorder(parent, perm); //classNameToModel.put (parent.getClass ().getName (), models [i]); - return ; + return; } catch (UnknownTypeException e) { } } } - throw new UnknownTypeException (parent); + throw new UnknownTypeException(parent); } - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].addModelListener (l); + models[i].addModelListener(l); } } @@ -1955,61 +1968,61 @@ * * @param l the listener to add */ - void addModelListener (ModelListener l, Set modelsListenersAddedTo) { + void addModelListener(ModelListener l, Set modelsListenersAddedTo) { int i, k = models.length; for (i = 0; i < k; i++) { - TreeModel m = models [i]; + TreeModel m = models[i]; if (!modelsListenersAddedTo.add(m)) { continue; } if (m instanceof DelegatingTreeModel) { ((DelegatingTreeModel) m).addModelListener(l, modelsListenersAddedTo); } else { - m.addModelListener (l); + m.addModelListener(l); } } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].removeModelListener (l); + models[i].removeModelListener(l); } } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } } - + private final static class CompoundTablePropertyEditorsModel implements TablePropertyEditorsModel { - + private TablePropertyEditorsModel model; private TablePropertyEditorsModelFilter filter; - + CompoundTablePropertyEditorsModel(TablePropertyEditorsModel model, TablePropertyEditorsModelFilter filter) { this.model = model; this.filter = filter; @@ -2019,107 +2032,104 @@ public PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException { return filter.getPropertyEditor(model, node, columnID); } - + @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - public String toString (String n) { + public String toString(String n) { if (model instanceof CompoundTablePropertyEditorsModel) { - return n + filter + "\n" + - ((CompoundTablePropertyEditorsModel) model).toString (n + " "); + return n + filter + "\n" + + ((CompoundTablePropertyEditorsModel) model).toString(n + " "); } if (model instanceof DelegatingTablePropertyEditorsModel) { - return n + filter + "\n" + - ((DelegatingTablePropertyEditorsModel) model).toString (n + " "); + return n + filter + "\n" + + ((DelegatingTablePropertyEditorsModel) model).toString(n + " "); } - return n + filter + "\n" + - n + " " + model; + return n + filter + "\n" + + n + " " + model; } } - + /** - * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} - * for given NodeActionsProvider and + * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for given + * NodeActionsProvider and * {@link org.netbeans.spi.viewmodel.NodeActionsProviderFilter}. - * - * @author Jan Jancura + * + * @author Jan Jancura */ - private final static class CompoundNodeActionsProvider - implements NodeActionsProvider { - + private final static class CompoundNodeActionsProvider + implements NodeActionsProvider { private NodeActionsProvider model; private NodeActionsProviderFilter filter; - /** - * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} - * for given NodeActionsProvider and + * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for + * given NodeActionsProvider and * {@link org.netbeans.spi.viewmodel.NodeActionsProviderFilter}. */ - CompoundNodeActionsProvider ( - NodeActionsProvider model, - NodeActionsProviderFilter filter + CompoundNodeActionsProvider( + NodeActionsProvider model, + NodeActionsProviderFilter filter ) { this.model = model; this.filter = filter; } - + /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider - * implementation is not able to resolve actions - * for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public void performDefaultAction (Object node) - throws UnknownTypeException { - filter.performDefaultAction (model, node); + public void performDefaultAction(Object node) + throws UnknownTypeException { + filter.performDefaultAction(model, node); } /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public Action[] getActions (Object node) - throws UnknownTypeException { - return filter.getActions (model, node); + public Action[] getActions(Object node) + throws UnknownTypeException { + return filter.getActions(model, node); } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { if (model instanceof CompoundNodeActionsProvider) { - return n + filter + "\n" + - ((CompoundNodeActionsProvider) model).toString (n + " "); + return n + filter + "\n" + + ((CompoundNodeActionsProvider) model).toString(n + " "); } if (model instanceof DelegatingNodeActionsProvider) { - return n + filter + "\n" + - ((DelegatingNodeActionsProvider) model).toString (n + " "); + return n + filter + "\n" + + ((DelegatingNodeActionsProvider) model).toString(n + " "); } - return n + filter + "\n" + - n + " " + model; + return n + filter + "\n" + + n + " " + model; } } - + private final static class CompoundTreeExpansionModel implements TreeExpansionModel, ModelListener { - + private TreeExpansionModel expansionModel; private TreeExpansionModelFilter expansionFilter; - + private final Collection modelListeners = new HashSet(); - + CompoundTreeExpansionModel(TreeExpansionModel expansionModel, TreeExpansionModelFilter expansionFilter) { this.expansionModel = expansionModel; this.expansionFilter = expansionFilter; @@ -2141,33 +2151,33 @@ expansionModel.nodeCollapsed(node); expansionFilter.nodeCollapsed(node); } - - /** + + /** * Registers given listener. - * + * * @param l the listener to add */ - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { synchronized (modelListeners) { if (modelListeners.isEmpty()) { - expansionFilter.addModelListener (this); + expansionFilter.addModelListener(this); //model.addModelListener (this); } modelListeners.add(l); } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { synchronized (modelListeners) { modelListeners.remove(l); removeLonelyModelRootChangelisteners(modelListeners); if (modelListeners.isEmpty()) { - expansionFilter.removeModelListener (this); + expansionFilter.removeModelListener(this); //model.removeModelListener (this); } } @@ -2177,26 +2187,27 @@ public void modelChanged(ModelEvent event) { if (event instanceof ModelEvent.NodeChanged && (event.getSource() instanceof NodeModel || event.getSource() instanceof NodeModelFilter)) { // CompoundNodeModel.modelChanged() takes this. - return ; + return; } - if (event instanceof ModelEvent.TableValueChanged && - (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { + if (event instanceof ModelEvent.TableValueChanged + && (event.getSource() instanceof TableModel || event.getSource() instanceof TableModelFilter)) { // CompoundTableModel.modelChanged() takes this. - return ; + return; } ModelEvent newEvent = translateEvent(event, this); Collection listeners; synchronized (modelListeners) { listeners = new ArrayList(modelListeners); } - for (Iterator it = listeners.iterator(); it.hasNext(); ) { + for (Iterator it = listeners.iterator(); it.hasNext();) { it.next().modelChanged(newEvent); } } - + } - private final static class CompoundAsynchronousModel implements AsynchronousModel { + private final static class CompoundAsynchronousModel implements AsynchronousModel { + private AsynchronousModel asynchModel; private AsynchronousModelFilter asynchModelFilter; @@ -2213,138 +2224,146 @@ } /** - * Creates one {@link org.netbeans.spi.viewmodel.TableModel} - * from given list of TableModels. DelegatingTableModel asks all underlaying - * models for each concrete parameter, and returns first returned value. + * Creates one {@link org.netbeans.spi.viewmodel.TableModel} from given + * list of TableModels. DelegatingTableModel asks all underlaying models for + * each concrete parameter, and returns first returned value. * - * @author Jan Jancura + * @author Jan Jancura */ private final static class DelegatingTableModel implements TableModel, TableHTMLModel { private TableModel[] models; - private HashMap classNameToModel = new HashMap(); - + private HashMap classNameToModel = new HashMap<>(); /** - * Creates new instance of DelegatingTableModel for given list of + * Creates new instance of DelegatingTableModel for given list of * TableModels. * * @param models a list of TableModels */ - DelegatingTableModel (List models) { - this (convert (models)); + DelegatingTableModel(List models) { + this(convert(models)); } - private static TableModel[] convert (List l) { - TableModel[] models = new TableModel [l.size ()]; - return l.toArray (models); + private static TableModel[] convert(List l) { + TableModel[] models = new TableModel[l.size()]; + return l.toArray(models); } /** - * Creates new instance of DelegatingTableModel for given array of + * Creates new instance of DelegatingTableModel for given array of * TableModels. * * @param models a array of TableModels */ - DelegatingTableModel (TableModel[] models) { - this.models = models; + DelegatingTableModel(TableModel[] models) { + this.models = models; } /** - * Returns value to be displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Returns value to be displayed in column columnID and row + * node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { + * + * @TreeModel#getChildren}. * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return value of variable representing given position in tree table. */ @Override - public Object getValueAt (Object node, String columnID) - throws UnknownTypeException { - TableModel model = classNameToModel.get ( - node.getClass ().getName () + public Object getValueAt(Object node, String columnID) + throws UnknownTypeException { + TableModel model = classNameToModel.get( + node.getClass().getName() ); - if (model != null) { + if (model != null) { try { - return model.getValueAt (node, columnID); + return model.getValueAt(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - Object v = models [i].getValueAt (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + Object v = models[i].getValueAt(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return v; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); - } + throw new UnknownTypeException(node); + } /** - * Returns true if value displayed in column columnID - * and row node is read only. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Returns true if value displayed in column columnID and + * row node is read only. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { + * + * @TreeModel#getChildren}. * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return true if variable on given position is read only */ @Override - public boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException { - TableModel model = classNameToModel.get ( - node.getClass ().getName () + public boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException { + TableModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.isReadOnly (node, columnID); + return model.isReadOnly(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - boolean ro = models [i].isReadOnly (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean ro = models[i].isReadOnly(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return ro; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } /** - * Changes a value displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@TreeModel#getChildren}. + * Changes a value displayed in column columnID and row + * node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from { + * + * @TreeModel#getChildren}. * - * @param node a object returned from {@TreeModel#getChildren} for this row + * @param node a object returned from { + * @TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} * @param value a new value of variable on given position - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type */ @Override - public void setValueAt (Object node, String columnID, Object value) - throws UnknownTypeException { - TableModel model = classNameToModel.get ( - node.getClass ().getName () + public void setValueAt(Object node, String columnID, Object value) + throws UnknownTypeException { + TableModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - model.setValueAt (node, columnID, value); + model.setValueAt(node, columnID, value); return; } catch (UnknownTypeException e) { } @@ -2352,25 +2371,25 @@ int i, k = models.length; for (i = 0; i < k; i++) { try { - models [i].setValueAt (node, columnID, value); - classNameToModel.put (node.getClass ().getName (), models [i]); + models[i].setValueAt(node, columnID, value); + classNameToModel.put(node.getClass().getName(), models[i]); return; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].addModelListener (l); + models[i].addModelListener(l); } } @@ -2379,66 +2398,65 @@ * * @param l the listener to add */ - void addModelListener (ModelListener l, Set modelsListenersAddedTo) { + void addModelListener(ModelListener l, Set modelsListenersAddedTo) { int i, k = models.length; for (i = 0; i < k; i++) { - TableModel m = models [i]; + TableModel m = models[i]; if (!modelsListenersAddedTo.add(m)) { continue; } if (m instanceof DelegatingTableModel) { ((DelegatingTableModel) m).addModelListener(l, modelsListenersAddedTo); } else { - m.addModelListener (l); + m.addModelListener(l); } } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].removeModelListener (l); + models[i].removeModelListener(l); } } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } - - // HTML extension: + // HTML extension: private boolean defaultHasHTMLValueAt() { return false; } - + @Override public boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException { UnknownTypeException uex = null; - TableModel model = classNameToModel.get ( - node.getClass ().getName () + TableModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof TableHTMLModel) { @@ -2456,8 +2474,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof TableHTMLModel) { try { - boolean has = ((TableHTMLModel) models [i]).hasHTMLValueAt(node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean has = ((TableHTMLModel) models[i]).hasHTMLValueAt(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return has; } catch (UnknownTypeException e) { uex = e; @@ -2471,15 +2489,15 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException { UnknownTypeException uex = null; - TableModel model = classNameToModel.get ( - node.getClass ().getName () + TableModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof TableHTMLModel) { @@ -2497,8 +2515,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof TableHTMLModel) { try { - String htmlValue = ((TableHTMLModel) models [i]).getHTMLValueAt(node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + String htmlValue = ((TableHTMLModel) models[i]).getHTMLValueAt(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return htmlValue; } catch (UnknownTypeException e) { uex = e; @@ -2512,35 +2530,35 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } } /** - * Creates one {@link org.netbeans.spi.viewmodel.TableRendererModel} - * from given list of TableRendererModel. DelegatingTableRendererModel asks all underlaying - * models for each concrete parameter, and returns first returned value. + * Creates one {@link org.netbeans.spi.viewmodel.TableRendererModel} from + * given list of TableRendererModel. DelegatingTableRendererModel asks all + * underlaying models for each concrete parameter, and returns first + * returned value. */ private final static class DelegatingTableRendererModel implements TableRendererModel { private TableRendererModel[] models; private HashMap classNameToModel = new HashMap(); - /** * Creates new instance of DelegatingTableModel for given list of * TableModels. * * @param models a list of TableModels */ - DelegatingTableRendererModel (List models) { - this (convert (models)); + DelegatingTableRendererModel(List models) { + this(convert(models)); } - private static TableRendererModel[] convert (List l) { - TableRendererModel[] models = new TableRendererModel [l.size ()]; - return l.toArray (models); + private static TableRendererModel[] convert(List l) { + TableRendererModel[] models = new TableRendererModel[l.size()]; + return l.toArray(models); } /** @@ -2549,112 +2567,112 @@ * * @param models a array of TableModels */ - DelegatingTableRendererModel (TableRendererModel[] models) { + DelegatingTableRendererModel(TableRendererModel[] models) { this.models = models; } @Override public boolean canRenderCell(Object node, String columnID) throws UnknownTypeException { - TableRendererModel model = classNameToModel.get ( - node.getClass ().getName () + TableRendererModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.canRenderCell (node, columnID); + return model.canRenderCell(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - boolean cr = models [i].canRenderCell (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean cr = models[i].canRenderCell(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return cr; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } @Override public TableCellRenderer getCellRenderer(Object node, String columnID) throws UnknownTypeException { - TableRendererModel model = classNameToModel.get ( - node.getClass ().getName () + TableRendererModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getCellRenderer (node, columnID); + return model.getCellRenderer(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - TableCellRenderer cr = models [i].getCellRenderer (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + TableCellRenderer cr = models[i].getCellRenderer(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return cr; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } @Override public boolean canEditCell(Object node, String columnID) throws UnknownTypeException { - TableRendererModel model = classNameToModel.get ( - node.getClass ().getName () + TableRendererModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.canEditCell (node, columnID); + return model.canEditCell(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - boolean ce = models [i].canEditCell (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean ce = models[i].canEditCell(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return ce; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } @Override public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException { - TableRendererModel model = classNameToModel.get ( - node.getClass ().getName () + TableRendererModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getCellEditor (node, columnID); + return model.getCellEditor(node, columnID); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - TableCellEditor ce = models [i].getCellEditor (node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + TableCellEditor ce = models[i].getCellEditor(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return ce; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - + /** * Registers given listener. * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].addModelListener (l); + models[i].addModelListener(l); } } @@ -2663,17 +2681,17 @@ * * @param l the listener to add */ - void addModelListener (ModelListener l, Set modelsListenersAddedTo) { + void addModelListener(ModelListener l, Set modelsListenersAddedTo) { int i, k = models.length; for (i = 0; i < k; i++) { - TableRendererModel m = models [i]; + TableRendererModel m = models[i]; if (!modelsListenersAddedTo.add(m)) { continue; } if (m instanceof DelegatingTableRendererModel) { ((DelegatingTableRendererModel) m).addModelListener(l, modelsListenersAddedTo); } else { - m.addModelListener (l); + m.addModelListener(l); } } } @@ -2684,50 +2702,50 @@ * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].removeModelListener (l); + models[i].removeModelListener(l); } } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - public String toString (String n) { + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } } - + private final static class DelegatingTablePropertyEditorsModel implements TablePropertyEditorsModel { - + private TablePropertyEditorsModel[] models; private HashMap classNameToModel = new HashMap(); - + DelegatingTablePropertyEditorsModel(List models) { this(convert(models)); } - + private static TablePropertyEditorsModel[] convert(List l) { TablePropertyEditorsModel[] models = new TablePropertyEditorsModel[l.size()]; return l.toArray(models); } - + DelegatingTablePropertyEditorsModel(TablePropertyEditorsModel[] models) { this.models = models; } @@ -2748,8 +2766,8 @@ int i, k = models.length; for (i = 0; i < k; i++) { try { - PropertyEditor pe = models [i].getPropertyEditor(node, columnID); - classNameToModel.put (node.getClass ().getName (), models [i]); + PropertyEditor pe = models[i].getPropertyEditor(node, columnID); + classNameToModel.put(node.getClass().getName(), models[i]); return pe; } catch (UnknownTypeException e) { utex = e; @@ -2761,68 +2779,67 @@ if (utex != null) { throw utex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - public String toString (String n) { + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } } /** - * Creates one {@link org.netbeans.spi.viewmodel.TableModel} - * from given list of TableModels. DelegatingTableModel asks all underlaying - * models for each concrete parameter, and returns first returned value. + * Creates one {@link org.netbeans.spi.viewmodel.TableModel} from given + * list of TableModels. DelegatingTableModel asks all underlaying models for + * each concrete parameter, and returns first returned value. * - * @author Jan Jancura + * @author Jan Jancura */ private final static class DelegatingTreeExpansionModel implements TreeExpansionModel { private TreeExpansionModel[] models; private HashMap classNameToModel = new HashMap(); - /** - * Creates new instance of DelegatingTableModel for given list of + * Creates new instance of DelegatingTableModel for given list of * TableModels. * * @param models a list of TableModels */ - DelegatingTreeExpansionModel (List models) { - this (convert (models)); + DelegatingTreeExpansionModel(List models) { + this(convert(models)); } - private static TreeExpansionModel[] convert (List l) { - TreeExpansionModel[] models = new TreeExpansionModel [l.size()]; - return l.toArray (models); + private static TreeExpansionModel[] convert(List l) { + TreeExpansionModel[] models = new TreeExpansionModel[l.size()]; + return l.toArray(models); } /** - * Creates new instance of DelegatingTableModel for given array of + * Creates new instance of DelegatingTableModel for given array of * TableModels. * * @param models a array of TableModels */ - private DelegatingTreeExpansionModel (TreeExpansionModel[] models) { - this.models = models; + private DelegatingTreeExpansionModel(TreeExpansionModel[] models) { + this.models = models; } /** @@ -2832,30 +2849,29 @@ * @return default state (collapsed, expanded) of given node */ @Override - public boolean isExpanded (Object node) - throws UnknownTypeException { - TreeExpansionModel model = - classNameToModel.get ( - node.getClass ().getName () - ); + public boolean isExpanded(Object node) + throws UnknownTypeException { + TreeExpansionModel model + = classNameToModel.get( + node.getClass().getName() + ); if (model != null) { try { - return model.isExpanded (node); + return model.isExpanded(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - boolean result = models [i].isExpanded (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean result = models[i].isExpanded(node); + classNameToModel.put(node.getClass().getName(), models[i]); return result; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); - } - + throw new UnknownTypeException(node); + } /** * Called when given node is expanded. @@ -2863,12 +2879,12 @@ * @param node a expanded node */ @Override - public void nodeExpanded (Object node) { + public void nodeExpanded(Object node) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].nodeExpanded (node); + models[i].nodeExpanded(node); } - } + } /** * Called when given node is collapsed. @@ -2876,47 +2892,47 @@ * @param node a collapsed node */ @Override - public void nodeCollapsed (Object node) { + public void nodeCollapsed(Object node) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].nodeCollapsed (node); + models[i].nodeCollapsed(node); } - } + } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } } private static class DefaultTreeExpansionModel implements TreeExpansionModel { - + private Reference cmRef; private CompoundModel oldCM; - + public DefaultTreeExpansionModel() { } - + private DefaultTreeExpansionModel(CompoundModel oldCM) { this.oldCM = oldCM; } - + /** * Defines default state (collapsed, expanded) of given node. * @@ -2924,8 +2940,8 @@ * @return default state (collapsed, expanded) of given node */ @Override - public boolean isExpanded (Object node) - throws UnknownTypeException { + public boolean isExpanded(Object node) + throws UnknownTypeException { CompoundModel cm = cmRef.get(); if (cm == null) { return false; @@ -2939,10 +2955,10 @@ * @param node a expanded node */ @Override - public void nodeExpanded (Object node) { + public void nodeExpanded(Object node) { CompoundModel cm = cmRef.get(); if (cm == null) { - return ; + return; } DefaultTreeExpansionManager.get(cm).setExpanded(node); } @@ -2953,10 +2969,10 @@ * @param node a collapsed node */ @Override - public void nodeCollapsed (Object node) { + public void nodeCollapsed(Object node) { CompoundModel cm = cmRef.get(); if (cm == null) { - return ; + return; } DefaultTreeExpansionManager.get(cm).setCollapsed(node); } @@ -2968,7 +2984,7 @@ } cmRef = new WeakReference(cm); } - + private DefaultTreeExpansionModel cloneForNewModel() { return new DefaultTreeExpansionModel(cmRef.get()); } @@ -2986,52 +3002,51 @@ return AsynchronousModelFilter.CURRENT_THREAD; } } - + } /** - * Creates one {@link org.netbeans.spi.viewmodel.NodeModel} - * from given list of NodeModels. DelegatingNodeModel asks all underlaying - * models for each concrete parameter, and returns first returned value. + * Creates one {@link org.netbeans.spi.viewmodel.NodeModel} from given list + * of NodeModels. DelegatingNodeModel asks all underlaying models for each + * concrete parameter, and returns first returned value. * - * @author Jan Jancura + * @author Jan Jancura */ private static final class DelegatingNodeModel implements SuperNodeModel { private NodeModel[] models; - private HashMap classNameToModel = new HashMap(); - + private HashMap classNameToModel = new HashMap<>(); /** - * Creates new instance of DelegatingNodeModel for given list of + * Creates new instance of DelegatingNodeModel for given list of * NodeModels. * * @param models a list of NodeModels */ - DelegatingNodeModel ( - List models + DelegatingNodeModel( + List models ) { - this (convert (models)); + this(convert(models)); } - private static NodeModel[] convert (List l) { - NodeModel[] models = new NodeModel [l.size ()]; - return l.toArray (models); + private static NodeModel[] convert(List l) { + NodeModel[] models = new NodeModel[l.size()]; + return l.toArray(models); } /** - * Creates new instance of DelegatingNodeModel for given array of + * Creates new instance of DelegatingNodeModel for given array of * NodeModels. * * @param models a array of NodeModels */ - DelegatingNodeModel ( - NodeModel[] models + DelegatingNodeModel( + NodeModel[] models ) { this.models = models; } - + NodeModel[] getModels() { return models; } @@ -3039,106 +3054,106 @@ /** * Returns display name for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve display name for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve display name for given node type + * @return display name for given node */ @Override - public String getDisplayName (Object node) - throws UnknownTypeException { - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + public String getDisplayName(Object node) + throws UnknownTypeException { + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getDisplayName (node); + return model.getDisplayName(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - String dn = models [i].getDisplayName (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + String dn = models[i].getDisplayName(node); + classNameToModel.put(node.getClass().getName(), models[i]); return dn; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } /** * Returns tool tip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tool tip for given node type - * @return tool tip for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve tool tip for given node type + * @return tool tip for given node */ @Override - public String getShortDescription (Object node) - throws UnknownTypeException { - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + public String getShortDescription(Object node) + throws UnknownTypeException { + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getShortDescription (node); + return model.getShortDescription(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - String dn = models [i].getShortDescription (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + String dn = models[i].getShortDescription(node); + classNameToModel.put(node.getClass().getName(), models[i]); return dn; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve icon for given node type + * @return icon for given node */ @Override - public String getIconBase (Object node) - throws UnknownTypeException { - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + public String getIconBase(Object node) + throws UnknownTypeException { + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getIconBase (node); + return model.getIconBase(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - String dn = models [i].getIconBase (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + String dn = models[i].getIconBase(node); + classNameToModel.put(node.getClass().getName(), models[i]); return dn; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].addModelListener (l); + models[i].addModelListener(l); } } @@ -3147,69 +3162,68 @@ * * @param l the listener to add */ - void addModelListener (ModelListener l, Set modelsListenersAddedTo) { + void addModelListener(ModelListener l, Set modelsListenersAddedTo) { int i, k = models.length; for (i = 0; i < k; i++) { - NodeModel m = models [i]; + NodeModel m = models[i]; if (!modelsListenersAddedTo.add(m)) { continue; } if (m instanceof DelegatingNodeModel) { ((DelegatingNodeModel) m).addModelListener(l, modelsListenersAddedTo); } else { - m.addModelListener (l); + m.addModelListener(l); } } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { int i, k = models.length; for (i = 0; i < k; i++) { - models [i].removeModelListener (l); + models[i].removeModelListener(l); } } @Override - public String toString () { - return toString (" "); + public String toString() { + return toString(" "); } - - public String toString (String n) { + + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } - + // Extensions: - private boolean defaultCanRename() { return false; } - + private boolean defaultCanCopy() { return false; } - + private boolean defaultCanCut() { return false; } - + private Transferable defaultClipboardCopy() throws IOException { return null; } @@ -3227,7 +3241,7 @@ } private PasteType defaultGetDropType(Transferable t, int action, - int index) { + int index) { return null; } @@ -3238,13 +3252,13 @@ @Override public boolean canRename(Object node) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).canRename (node); + return ((ExtendedNodeModel) model).canRename(node); } catch (UnknownTypeException e) { uex = e; } @@ -3257,8 +3271,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - boolean cr = ((ExtendedNodeModel) models [i]).canRename (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean cr = ((ExtendedNodeModel) models[i]).canRename(node); + classNameToModel.put(node.getClass().getName(), models[i]); return cr; } catch (UnknownTypeException e) { uex = e; @@ -3272,20 +3286,20 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public boolean canCopy(Object node) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).canCopy (node); + return ((ExtendedNodeModel) model).canCopy(node); } catch (UnknownTypeException e) { uex = e; } @@ -3298,8 +3312,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - boolean cr = ((ExtendedNodeModel) models [i]).canCopy (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean cr = ((ExtendedNodeModel) models[i]).canCopy(node); + classNameToModel.put(node.getClass().getName(), models[i]); return cr; } catch (UnknownTypeException e) { uex = e; @@ -3313,20 +3327,20 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public boolean canCut(Object node) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).canCut (node); + return ((ExtendedNodeModel) model).canCut(node); } catch (UnknownTypeException e) { uex = e; } @@ -3339,8 +3353,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - boolean cr = ((ExtendedNodeModel) models [i]).canCut (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + boolean cr = ((ExtendedNodeModel) models[i]).canCut(node); + classNameToModel.put(node.getClass().getName(), models[i]); return cr; } catch (UnknownTypeException e) { uex = e; @@ -3354,21 +3368,21 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public Transferable clipboardCopy(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).clipboardCopy (node); + return ((ExtendedNodeModel) model).clipboardCopy(node); } catch (UnknownTypeException e) { uex = e; } @@ -3381,8 +3395,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - Transferable t = ((ExtendedNodeModel) models [i]).clipboardCopy (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + Transferable t = ((ExtendedNodeModel) models[i]).clipboardCopy(node); + classNameToModel.put(node.getClass().getName(), models[i]); return t; } catch (UnknownTypeException e) { uex = e; @@ -3396,21 +3410,21 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public Transferable clipboardCut(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).clipboardCut (node); + return ((ExtendedNodeModel) model).clipboardCut(node); } catch (UnknownTypeException e) { uex = e; } @@ -3423,8 +3437,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - Transferable t = ((ExtendedNodeModel) models [i]).clipboardCut (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + Transferable t = ((ExtendedNodeModel) models[i]).clipboardCut(node); + classNameToModel.put(node.getClass().getName(), models[i]); return t; } catch (UnknownTypeException e) { uex = e; @@ -3438,7 +3452,7 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @@ -3466,15 +3480,15 @@ @Override public Transferable drag(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = (NodeModel) classNameToModel.get ( - node.getClass ().getName () + NodeModel model = (NodeModel) classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof DnDNodeModel) { try { - return ((DnDNodeModel) model).drag (node); + return ((DnDNodeModel) model).drag(node); } catch (UnknownTypeException e) { uex = e; } @@ -3487,8 +3501,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof DnDNodeModel) { try { - Transferable t = ((DnDNodeModel) models [i]).drag (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + Transferable t = ((DnDNodeModel) models[i]).drag(node); + classNameToModel.put(node.getClass().getName(), models[i]); return t; } catch (UnknownTypeException e) { uex = e; @@ -3502,20 +3516,20 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public PasteType[] getPasteTypes(Object node, Transferable t) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - return ((ExtendedNodeModel) model).getPasteTypes (node, t); + return ((ExtendedNodeModel) model).getPasteTypes(node, t); } catch (UnknownTypeException e) { uex = e; } @@ -3528,8 +3542,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - PasteType[] p = ((ExtendedNodeModel) models [i]).getPasteTypes (node, t); - classNameToModel.put (node.getClass ().getName (), models [i]); + PasteType[] p = ((ExtendedNodeModel) models[i]).getPasteTypes(node, t); + classNameToModel.put(node.getClass().getName(), models[i]); return p; } catch (UnknownTypeException e) { uex = e; @@ -3543,21 +3557,21 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public PasteType getDropType(Object node, Transferable t, int action, - int index) throws UnknownTypeException { + int index) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = (NodeModel) classNameToModel.get ( - node.getClass ().getName () + NodeModel model = (NodeModel) classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof DnDNodeModel) { try { - return ((DnDNodeModel) model).getDropType (node, t, action, index); + return ((DnDNodeModel) model).getDropType(node, t, action, index); } catch (UnknownTypeException e) { uex = e; } @@ -3570,8 +3584,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof DnDNodeModel) { try { - PasteType p = ((DnDNodeModel) models [i]).getDropType (node, t, action, index); - classNameToModel.put (node.getClass ().getName (), models [i]); + PasteType p = ((DnDNodeModel) models[i]).getDropType(node, t, action, index); + classNameToModel.put(node.getClass().getName(), models[i]); return p; } catch (UnknownTypeException e) { uex = e; @@ -3585,27 +3599,27 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public void setName(Object node, String name) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { if (model instanceof ExtendedNodeModel) { try { - ((ExtendedNodeModel) model).setName (node, name); - return ; + ((ExtendedNodeModel) model).setName(node, name); + return; } catch (UnknownTypeException e) { uex = e; } } else { defaultSetName(name); - return ; + return; } } int i, k = models.length; @@ -3613,9 +3627,9 @@ for (i = 0; i < k; i++) { if (models[i] instanceof ExtendedNodeModel) { try { - ((ExtendedNodeModel) models [i]).setName (node, name); - classNameToModel.put (node.getClass ().getName (), models [i]); - return ; + ((ExtendedNodeModel) models[i]).setName(node, name); + classNameToModel.put(node.getClass().getName(), models[i]); + return; } catch (UnknownTypeException e) { uex = e; } @@ -3624,25 +3638,25 @@ } if (!isExtended) { defaultSetName(name); - return ; + return; } if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @Override public String getIconBaseWithExtension(Object node) throws UnknownTypeException { UnknownTypeException uex = null; - NodeModel model = classNameToModel.get ( - node.getClass ().getName () + NodeModel model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { if (model instanceof ExtendedNodeModel) { - return ((ExtendedNodeModel) model).getIconBaseWithExtension (node); + return ((ExtendedNodeModel) model).getIconBaseWithExtension(node); } else { String base = model.getIconBase(node); if (base != null) { @@ -3660,7 +3674,7 @@ try { String ib; if (models[i] instanceof ExtendedNodeModel) { - ib = ((ExtendedNodeModel) models [i]).getIconBaseWithExtension (node); + ib = ((ExtendedNodeModel) models[i]).getIconBaseWithExtension(node); } else { String base = models[i].getIconBase(node); if (base != null) { @@ -3669,7 +3683,7 @@ ib = null; } } - classNameToModel.put (node.getClass ().getName (), models [i]); + classNameToModel.put(node.getClass().getName(), models[i]); return ib; } catch (UnknownTypeException e) { uex = e; @@ -3678,9 +3692,9 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - + } @Override @@ -3691,7 +3705,7 @@ for (i = 0; i < k; i++) { if (models[i] instanceof CheckNodeModel) { try { - Boolean checkable = ((CheckNodeModel) models [i]).isCheckable(node); + Boolean checkable = ((CheckNodeModel) models[i]).isCheckable(node); return checkable; } catch (UnknownTypeException e) { uex = e; @@ -3705,7 +3719,7 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @@ -3716,7 +3730,7 @@ for (i = 0; i < k; i++) { if (models[i] instanceof CheckNodeModel) { try { - boolean checkEnabled = ((CheckNodeModel) models [i]).isCheckEnabled(node); + boolean checkEnabled = ((CheckNodeModel) models[i]).isCheckEnabled(node); return checkEnabled; } catch (UnknownTypeException e) { uex = e; @@ -3738,7 +3752,7 @@ for (i = 0; i < k; i++) { if (models[i] instanceof CheckNodeModel) { try { - Boolean selected = ((CheckNodeModel) models [i]).isSelected(node); + Boolean selected = ((CheckNodeModel) models[i]).isSelected(node); return selected; } catch (UnknownTypeException e) { uex = e; @@ -3752,7 +3766,7 @@ if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } @@ -3764,8 +3778,8 @@ for (i = 0; i < k; i++) { if (models[i] instanceof CheckNodeModel) { try { - ((CheckNodeModel) models [i]).setSelected (node, selected); - return ; + ((CheckNodeModel) models[i]).setSelected(node, selected); + return; } catch (UnknownTypeException e) { uex = e; } @@ -3773,56 +3787,109 @@ } } if (!isChecked) { - Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model "+this)); - return ; + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + this)); + return; } if (uex != null) { throw uex; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } + @Override + public void setSelected(Object... nodes) throws UnknownTypeException { + UnknownTypeException uex = null; + int i, k = models.length; + boolean isChecked = false; + for (i = 0; i < k; i++) { + if (models[i] instanceof CheckNodeModel) { + try { + ((CheckNodeModel) models[i]).setSelected(nodes); + return; + } catch (UnknownTypeException e) { + uex = e; + } + isChecked = true; + } + } + if (!isChecked) { + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + this)); + return; + } + if (uex != null) { + throw uex; + } else { + throw new UnknownTypeException(nodes); + } + } + + @Override + public void setUnselected(Object... nodes) throws UnknownTypeException { + UnknownTypeException uex = null; + int i, k = models.length; + boolean isChecked = false; + for (i = 0; i < k; i++) { + if (models[i] instanceof CheckNodeModel) { + try { + ((CheckNodeModel) models[i]).setUnselected(nodes); + return; + } catch (UnknownTypeException e) { + uex = e; + } + isChecked = true; + } + } + if (!isChecked) { + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + this)); + return; + } + if (uex != null) { + throw uex; + } else { + throw new UnknownTypeException(nodes); + } + } } /** * Empty implementation of {@link org.netbeans.spi.viewmodel.TreeModel}. * - * @author Jan Jancura + * @author Jan Jancura */ private static final class EmptyTreeModel implements TreeModel { - /** + /** * Returns {@link org.netbeans.spi.viewmodel.TreeModel#ROOT}. * * @return {@link org.netbeans.spi.viewmodel.TreeModel#ROOT} */ @Override - public Object getRoot () { + public Object getRoot() { return ROOT; } - /** + /** * Returns empty array. * * @return empty array */ @Override - public Object[] getChildren (Object parent, int from, int to) { - return new Object [0]; + public Object[] getChildren(Object parent, int from, int to) { + return new Object[0]; } - + /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf */ @Override - public int getChildrenCount (Object node) { + public int getChildrenCount(Object node) { return 0; } @@ -3832,303 +3899,305 @@ * @return false */ @Override - public boolean isLeaf (Object node) { + public boolean isLeaf(Object node) { return false; } - /** + /** * Do nothing. * * @param l the listener to be added */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { } - /** + /** * Do nothing. * * @param l the listener to be removed */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { } } /** * Empty implementation of {@link org.netbeans.spi.viewmodel.NodeModel}. * - * @author Jan Jancura + * @author Jan Jancura */ private static final class EmptyNodeModel implements NodeModel { /** * Returns display name for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve display name for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve display name for given node type + * @return display name for given node */ @Override - public String getDisplayName (Object node) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public String getDisplayName(Object node) + throws UnknownTypeException { + throw new UnknownTypeException(node); } /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve icon for given node type + * @return icon for given node */ @Override - public String getIconBase (Object node) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public String getIconBase(Object node) + throws UnknownTypeException { + throw new UnknownTypeException(node); } /** * Returns tool tip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tool tip for given node type - * @return tool tip for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve tool tip for given node type + * @return tool tip for given node */ @Override - public String getShortDescription (Object node) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public String getShortDescription(Object node) + throws UnknownTypeException { + throw new UnknownTypeException(node); } - /** + /** * Do nothing. * * @param l the listener to be added */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { } - /** + /** * Do nothing. * * @param l the listener to be removed */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { } } /** * Empty implemntation of {@link org.netbeans.spi.viewmodel.TableModel}. * - * @author Jan Jancura + * @author Jan Jancura */ private static final class EmptyTableModel implements TableModel { - + /** - * Returns value to be displayed in column columnID - * and row identified by node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren}. - * - * @param node a object returned from - * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren} for this row + * Returns value to be displayed in column columnID and row + * identified by node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from {@link org.netbeans.spi.viewmodel.TreeModel#getChildren}. + * + * @param node a object returned from + * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren} for this + * row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return value of variable representing given position in tree table. */ @Override - public Object getValueAt (Object node, String columnID) throws - UnknownTypeException { - throw new UnknownTypeException (node); + public Object getValueAt(Object node, String columnID) throws + UnknownTypeException { + throw new UnknownTypeException(node); } /** - * Returns true if value displayed in column columnID - * and row node is read only. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@link TreeModel#getChildren}. + * Returns true if value displayed in column columnID and + * row node is read only. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from {@link TreeModel#getChildren}. * - * @param node a object returned from {@link TreeModel#getChildren} for this row + * @param node a object returned from {@link TreeModel#getChildren} for + * this row * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type * * @return true if variable on given position is read only */ @Override - public boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException { - throw new UnknownTypeException (node); + public boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException { + throw new UnknownTypeException(node); } /** - * Changes a value displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from - * {@link TreeModel#getChildren}. + * Changes a value displayed in column columnID and row + * node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned + * from {@link TreeModel#getChildren}. * - * @param node a object returned from {@link TreeModel#getChildren} for this row + * @param node a object returned from {@link TreeModel#getChildren} for + * this row * @param columnID a id of column defined by {@link ColumnModel#getID} * @param value a new value of variable on given position - * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * @throws UnknownTypeException if there is no TableModel defined for + * given parameter type */ @Override - public void setValueAt (Object node, String columnID, Object value) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public void setValueAt(Object node, String columnID, Object value) + throws UnknownTypeException { + throw new UnknownTypeException(node); } - - /** + + /** * Do nothing. * * @param l the listener to be added */ @Override - public void addModelListener (ModelListener l) { + public void addModelListener(ModelListener l) { } - /** + /** * Do nothing. * * @param l the listener to be removed */ @Override - public void removeModelListener (ModelListener l) { + public void removeModelListener(ModelListener l) { } } /** * Empty implementation of {@link org.netbeans.spi.viewmodel.TableModel}. * - * @author Jan Jancura + * @author Jan Jancura */ - private static final class EmptyNodeActionsProvider implements - NodeActionsProvider { - + private static final class EmptyNodeActionsProvider implements + NodeActionsProvider { + /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public void performDefaultAction (Object node) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public void performDefaultAction(Object node) + throws UnknownTypeException { + throw new UnknownTypeException(node); } /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public Action[] getActions (Object node) - throws UnknownTypeException { - throw new UnknownTypeException (node); + public Action[] getActions(Object node) + throws UnknownTypeException { + throw new UnknownTypeException(node); } } - + /** - * Creates one {@link org.netbeans.spi.viewmodel.NodeActionsProvider} - * from given list of NodeActionsProviders. DelegatingNodeActionsProvider asks all - * underlaying models for each concrete parameter, and returns first + * Creates one {@link org.netbeans.spi.viewmodel.NodeActionsProvider} from + * given list of NodeActionsProviders. DelegatingNodeActionsProvider asks + * all underlaying models for each concrete parameter, and returns first * returned value. * - * @author Jan Jancura + * @author Jan Jancura */ static final class DelegatingNodeActionsProvider implements NodeActionsProvider { private NodeActionsProvider[] models; private HashMap classNameToModel = new HashMap(); - /** - * Creates new instance of DelegatingNodeActionsProvider for given list of - * NodeActionsProvider. + * Creates new instance of DelegatingNodeActionsProvider for given list + * of NodeActionsProvider. * * @param models a list of NodeActionsProvider */ - public DelegatingNodeActionsProvider ( - List models + public DelegatingNodeActionsProvider( + List models ) { - this (convert (models)); + this(convert(models)); } - private static NodeActionsProvider[] convert (List l) { - NodeActionsProvider[] models = new NodeActionsProvider [l.size ()]; - return l.toArray (models); + private static NodeActionsProvider[] convert(List l) { + NodeActionsProvider[] models = new NodeActionsProvider[l.size()]; + return l.toArray(models); } /** - * Creates new instance of DelegatingNodeActionsProvider for given array of - * NodeActionsProvider. + * Creates new instance of DelegatingNodeActionsProvider for given array + * of NodeActionsProvider. * * @param models a array of NodeActionsProvider */ - public DelegatingNodeActionsProvider (NodeActionsProvider[] models) { + public DelegatingNodeActionsProvider(NodeActionsProvider[] models) { this.models = models; } /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public Action[] getActions (Object node) - throws UnknownTypeException { - NodeActionsProvider model = classNameToModel.get ( - node.getClass ().getName () + public Action[] getActions(Object node) + throws UnknownTypeException { + NodeActionsProvider model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - return model.getActions (node); + return model.getActions(node); } catch (UnknownTypeException e) { } } int i, k = models.length; for (i = 0; i < k; i++) { try { - Action[] dn = models [i].getActions (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + Action[] dn = models[i].getActions(node); + classNameToModel.put(node.getClass().getName(), models[i]); return dn; } catch (UnknownTypeException e) { } } if (k == 0) { - return new Action[] {}; + return new Action[]{}; } else { - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } } /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public void performDefaultAction (Object node) throws UnknownTypeException { - NodeActionsProvider model = classNameToModel.get ( - node.getClass ().getName () + public void performDefaultAction(Object node) throws UnknownTypeException { + NodeActionsProvider model = classNameToModel.get( + node.getClass().getName() ); if (model != null) { try { - model.performDefaultAction (node); + model.performDefaultAction(node); return; } catch (UnknownTypeException e) { } @@ -4136,78 +4205,79 @@ int i, k = models.length; for (i = 0; i < k; i++) { try { - models [i].performDefaultAction (node); - classNameToModel.put (node.getClass ().getName (), models [i]); + models[i].performDefaultAction(node); + classNameToModel.put(node.getClass().getName(), models[i]); return; } catch (UnknownTypeException e) { } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } @Override - public String toString () { - return super.toString () + "\n" + toString (" "); + public String toString() { + return super.toString() + "\n" + toString(" "); } - - public String toString (String n) { + + public String toString(String n) { int i, k = models.length - 1; if (k == -1) { return ""; } - StringBuffer sb = new StringBuffer (); + StringBuffer sb = new StringBuffer(); for (i = 0; i < k; i++) { - sb.append (n); - sb.append (models [i]); - sb.append ('\n'); - } - sb.append (n); - sb.append (models [i]); - return new String (sb); + sb.append(n); + sb.append(models[i]); + sb.append('\n'); + } + sb.append(n); + sb.append(models[i]); + return new String(sb); } } - + /** * Tree expansion control. + * * @since 1.15 */ public static abstract class TreeFeatures { - + /** * Returns true if given node is expanded. * * @param node a node to be checked * @return true if given node is expanded */ - public abstract boolean isExpanded (Object node); - + public abstract boolean isExpanded(Object node); + /** * Expands given list of nodes. * * @param node a list of nodes to be expanded */ - public abstract void expandNode (Object node); - + public abstract void expandNode(Object node); + /** * Collapses given node. * * @param node a node to be expanded */ - public abstract void collapseNode (Object node); - + public abstract void collapseNode(Object node); + } - + /** * Implements set of tree view features. */ private static final class DefaultTreeFeatures extends TreeFeatures { - + private JComponent view; - - private DefaultTreeFeatures (JComponent view) { + + private DefaultTreeFeatures(JComponent view) { this.view = view; } - + /** * Returns true if given node is expanded. * @@ -4215,10 +4285,10 @@ * @return true if given node is expanded */ @Override - public boolean isExpanded ( - Object node + public boolean isExpanded( + Object node ) { - return ((OutlineTable) view).isExpanded (node); + return ((OutlineTable) view).isExpanded(node); } /** @@ -4227,10 +4297,10 @@ * @param node a list of nodes to be expanded */ @Override - public void expandNode ( - Object node + public void expandNode( + Object node ) { - ((OutlineTable) view).expandNode (node); + ((OutlineTable) view).expandNode(node); } /** @@ -4239,10 +4309,10 @@ * @param node a node to be expanded */ @Override - public void collapseNode ( - Object node + public void collapseNode( + Object node ) { - ((OutlineTable) view).collapseNode (node); + ((OutlineTable) view).collapseNode(node); } } @@ -4250,43 +4320,46 @@ * This model encapsulates all currently supported models. * * @see Models#createCompoundModel - * @author Jan Jancura + * @author Jan Jancura */ public static final class CompoundModel implements ReorderableTreeModel, - ExtendedNodeModel, - CheckNodeModel, - DnDNodeModel, - NodeActionsProvider, - TableHTMLModel, - TreeExpansionModel, - TableRendererModel, - TablePropertyEditorsModel { + ExtendedNodeModel, + CheckNodeModel, + DnDNodeModel, + NodeActionsProvider, + TableHTMLModel, + TreeExpansionModel, + TableRendererModel, + TablePropertyEditorsModel, + IconNodeModel, + LookupNodeModel { private ReorderableTreeModel treeModel; private ExtendedNodeModel nodeModel; private CheckNodeModel cnodeModel; - private DnDNodeModel dndNodeModel; + private DnDNodeModel dndNodeModel; private NodeActionsProvider nodeActionsProvider; - private ColumnModel[] columnModels; - private TableHTMLModel tableModel; + private ColumnModel[] columnModels; + private TableHTMLModel tableModel; private TableRendererModel tableRendererModel; private TablePropertyEditorsModel tablePropertyEditorsModel; private TreeExpansionModel treeExpansionModel; private AsynchronousModel asynchModel; + private IconNodeModel iconNodeModel; + private LookupNodeModel lookupNodeModel; - private CompoundModel mainSubModel; + private CompoundModel mainSubModel; private CompoundModel[] subModels; private TreeModelFilter subModelsFilter; private MessageFormat treeNodeDisplayFormat; - + // // New field, setter/getter for propertiesHelpID, which is used // for property sheet help private String propertiesHelpID = null; // - - // init .................................................................... + // init .................................................................... /** * Creates a new instance of {@link CompoundModel} for given models. * @@ -4295,22 +4368,24 @@ * @param nodeActionsProvider a node actions provider to delegate on * @param nodeActionsProvider a columns model to delegate on */ - private CompoundModel ( - ReorderableTreeModel treeModel, - TreeExpansionModel treeExpansionModel, - ExtendedNodeModel nodeModel, - NodeActionsProvider nodeActionsProvider, - List columnModels, - TableHTMLModel tableModel, - AsynchronousModel asynchModel, - TableRendererModel tableRendererModel, - TablePropertyEditorsModel tablePropertyEditorsModel, - String propertiesHelpID + private CompoundModel( + ReorderableTreeModel treeModel, + TreeExpansionModel treeExpansionModel, + ExtendedNodeModel nodeModel, + NodeActionsProvider nodeActionsProvider, + List columnModels, + TableHTMLModel tableModel, + AsynchronousModel asynchModel, + TableRendererModel tableRendererModel, + TablePropertyEditorsModel tablePropertyEditorsModel, + IconNodeModel iconNodeModel, + LookupNodeModel lookupNodeModel, + String propertiesHelpID ) { - if (treeModel == null || nodeModel == null || tableModel == null || - nodeActionsProvider == null) { - - throw new NullPointerException (); + if (treeModel == null || nodeModel == null || tableModel == null + || nodeActionsProvider == null) { + + throw new NullPointerException(); } /*if (columnModels == null && tableModel == null && tableRendererModel == null) { isTree = true; @@ -4331,27 +4406,29 @@ this.tableRendererModel = tableRendererModel; this.tablePropertyEditorsModel = tablePropertyEditorsModel; this.nodeActionsProvider = nodeActionsProvider; - this.columnModels = columnModels.toArray ( - new ColumnModel [columnModels.size ()] + this.columnModels = columnModels.toArray( + new ColumnModel[columnModels.size()] ); this.asynchModel = asynchModel; + this.iconNodeModel = iconNodeModel; + this.lookupNodeModel = lookupNodeModel; this.propertiesHelpID = propertiesHelpID; } private CompoundModel(CompoundModel mainSubModel, - CompoundModel[] models, - TreeModelFilter treeFilter, - String propertiesHelpID) { + CompoundModel[] models, + TreeModelFilter treeFilter, + String propertiesHelpID) { this.mainSubModel = mainSubModel; this.subModels = models; this.subModelsFilter = treeFilter; this.propertiesHelpID = propertiesHelpID; } - + void setTreeNodeDisplayFormat(MessageFormat treeNodeDisplayFormat) { this.treeNodeDisplayFormat = treeNodeDisplayFormat; } - + MessageFormat getTreeNodeDisplayFormat() { if (isHyperModel()) { return mainSubModel.getTreeNodeDisplayFormat(); @@ -4359,19 +4436,18 @@ return treeNodeDisplayFormat; } } - + /*boolean isTree() { return columnModels == null; }*/ - /*CompoundModel[] getSubModels() { + /*CompoundModel[] getSubModels() { return subModels; } TreeModelFilter getSubModelsFilter() { return subModelsFilter; }*/ - boolean isHyperModel() { return subModels != null; } @@ -4386,8 +4462,9 @@ // /** * Get a help ID for this model. - * @return The help ID defined for the properties sheets, - * or null. + * + * @return The help ID defined for the properties sheets, or + * null. * @since 1.7 */ public String getHelpId() { @@ -4396,30 +4473,29 @@ // // TreeModel ............................................................... - - /** + /** * Returns the root node of the tree or null, if the tree is empty. * * @return the root node of the tree or null */ @Override - public Object getRoot () { - return treeModel.getRoot (); + public Object getRoot() { + return treeModel.getRoot(); } - /** + /** * Returns children for given parent on given indexes. * - * @param parent a parent of returned nodes - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type + * @param parent a parent of returned nodes + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type * - * @return children for given parent on given indexes + * @return children for given parent on given indexes */ @Override - public Object[] getChildren (Object parent, int from, int to) - throws UnknownTypeException { - Object[] ch = treeModel.getChildren (parent, from, to); + public Object[] getChildren(Object parent, int from, int to) + throws UnknownTypeException { + Object[] ch = treeModel.getChildren(parent, from, to); //System.err.println("Children for node '"+parent+"' are '"+java.util.Arrays.asList(ch)+"'"); //System.err.println("Model = "+this); return ch; @@ -4427,32 +4503,31 @@ /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf */ @Override - public int getChildrenCount (Object node) throws UnknownTypeException { - return treeModel.getChildrenCount (node); + public int getChildrenCount(Object node) throws UnknownTypeException { + return treeModel.getChildrenCount(node); } /** * Returns true if node is leaf. - * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * @return true if node is leaf + * + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * @return true if node is leaf */ @Override - public boolean isLeaf (Object node) throws UnknownTypeException { - return treeModel.isLeaf (node); + public boolean isLeaf(Object node) throws UnknownTypeException { + return treeModel.isLeaf(node); } // ReorderableTreeModel ............................................................... - @Override public boolean canReorder(Object parent) throws UnknownTypeException { return treeModel.canReorder(parent); @@ -4464,16 +4539,15 @@ } // NodeModel ............................................................... - /** * Returns display name for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve display name for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve display name for given node type + * @return display name for given node */ @Override - public String getDisplayName (Object node) throws UnknownTypeException { + public String getDisplayName(Object node) throws UnknownTypeException { if (nodeModel instanceof DelegatingNodeModel) { NodeModel[] subModels = ((DelegatingNodeModel) nodeModel).getModels(); if (subModels.length == 0) { @@ -4488,7 +4562,7 @@ return ""; // Nothing when there are no models } } - String dn = nodeModel.getDisplayName (node); + String dn = nodeModel.getDisplayName(node); //System.err.println("DisplayName for node '"+node+"' is: '"+dn+"'"); //System.err.println("Model = "+this); return dn; @@ -4497,13 +4571,13 @@ /** * Returns tool tip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tool tip for given node type - * @return tool tip for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve tool tip for given node type + * @return tool tip for given node */ @Override - public String getShortDescription (Object node) - throws UnknownTypeException { + public String getShortDescription(Object node) + throws UnknownTypeException { if (nodeModel instanceof DelegatingNodeModel) { NodeModel[] subModels = ((DelegatingNodeModel) nodeModel).getModels(); if (subModels.length == 0) { @@ -4517,95 +4591,111 @@ } } } - return nodeModel.getShortDescription (node); + return nodeModel.getShortDescription(node); + } + + @Override + public Image getIcon(Object node, int type) throws UnknownTypeException { + if (iconNodeModel != null) { + return iconNodeModel.getIcon(node, type); + } + return null; + } + + @Override + public Image getOpenedIcon(Object node, int type) throws UnknownTypeException { + if (iconNodeModel != null) { + return iconNodeModel.getOpenedIcon(node, type); + } + return null; + } + + @Override + public Lookup getLookup(Object node) throws UnknownTypeException { + if (lookupNodeModel != null) { + return lookupNodeModel.getLookup(node); + } + return Lookup.EMPTY; } /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve icon for given node type + * @return icon for given node */ @Override - public String getIconBase (Object node) - throws UnknownTypeException { + public String getIconBase(Object node) + throws UnknownTypeException { if (nodeModel instanceof DelegatingNodeModel) { NodeModel[] subModels = ((DelegatingNodeModel) nodeModel).getModels(); if (subModels.length == 0) { return null; // Nothing when there are no models } } - String ib = nodeModel.getIconBase (node); + String ib = nodeModel.getIconBase(node); //System.err.println("IconBase for node '"+node+"' is '"+ib+"'"); //System.err.println("Model = "+this); return ib; } - // NodeActionsProvider ..................................................... - /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public void performDefaultAction (Object node) throws UnknownTypeException { - nodeActionsProvider.performDefaultAction (node); + public void performDefaultAction(Object node) throws UnknownTypeException { + nodeActionsProvider.performDefaultAction(node); } /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ @Override - public Action[] getActions (Object node) throws UnknownTypeException { - return nodeActionsProvider.getActions (node); + public Action[] getActions(Object node) throws UnknownTypeException { + return nodeActionsProvider.getActions(node); } - // ColumnsModel ............................................................ - /** - * Returns sorted array of + * Returns sorted array of * {@link org.netbeans.spi.viewmodel.ColumnModel}s. * * @return sorted array of ColumnModels */ - public ColumnModel[] getColumns () { + public ColumnModel[] getColumns() { return columnModels; } - // TableModel .............................................................. - @Override - public Object getValueAt (Object node, String columnID) throws - UnknownTypeException { - return tableModel.getValueAt (node, columnID); + public Object getValueAt(Object node, String columnID) throws + UnknownTypeException { + return tableModel.getValueAt(node, columnID); } @Override - public boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException { - return tableModel.isReadOnly (node, columnID); + public boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException { + return tableModel.isReadOnly(node, columnID); } @Override - public void setValueAt (Object node, String columnID, Object value) throws - UnknownTypeException { - tableModel.setValueAt (node, columnID, value); + public void setValueAt(Object node, String columnID, Object value) throws + UnknownTypeException { + tableModel.setValueAt(node, columnID, value); } - // TreeExpansionModel ...................................................... - /** * Defines default state (collapsed, expanded) of given node. * @@ -4613,11 +4703,11 @@ * @return default state (collapsed, expanded) of given node */ @Override - public boolean isExpanded (Object node) throws UnknownTypeException { + public boolean isExpanded(Object node) throws UnknownTypeException { if (treeExpansionModel == null) { return false; } - return treeExpansionModel.isExpanded (node); + return treeExpansionModel.isExpanded(node); } /** @@ -4626,9 +4716,9 @@ * @param node a expanded node */ @Override - public void nodeExpanded (Object node) { + public void nodeExpanded(Object node) { if (treeExpansionModel != null) { - treeExpansionModel.nodeExpanded (node); + treeExpansionModel.nodeExpanded(node); } } @@ -4638,41 +4728,39 @@ * @param node a collapsed node */ @Override - public void nodeCollapsed (Object node) { + public void nodeCollapsed(Object node) { if (treeExpansionModel != null) { - treeExpansionModel.nodeCollapsed (node); + treeExpansionModel.nodeCollapsed(node); } } - // listeners ............................................................... - - /** + /** * Registers given listener. - * + * * @param l the listener to add */ @Override - public void addModelListener (ModelListener l) { - Set modelsListenersAddedTo = new HashSet(); + public void addModelListener(ModelListener l) { + Set modelsListenersAddedTo = new HashSet<>(); if (treeModel instanceof DelegatingTreeModel) { ((DelegatingTreeModel) treeModel).addModelListener(l, modelsListenersAddedTo); } else { - treeModel.addModelListener (l); + treeModel.addModelListener(l); modelsListenersAddedTo.add(treeModel); } if (nodeModel != treeModel && !modelsListenersAddedTo.contains(nodeModel)) { if (nodeModel instanceof DelegatingNodeModel) { ((DelegatingNodeModel) nodeModel).addModelListener(l, modelsListenersAddedTo); } else { - nodeModel.addModelListener (l); + nodeModel.addModelListener(l); } } if (tableModel != treeModel && tableModel != nodeModel && !modelsListenersAddedTo.contains(tableModel)) { if (tableModel instanceof DelegatingTableModel) { ((DelegatingTableModel) tableModel).addModelListener(l, modelsListenersAddedTo); } else { - tableModel.addModelListener (l); + tableModel.addModelListener(l); } } if (treeExpansionModel instanceof CompoundTreeExpansionModel) { @@ -4680,19 +4768,19 @@ } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ @Override - public void removeModelListener (ModelListener l) { - treeModel.removeModelListener (l); + public void removeModelListener(ModelListener l) { + treeModel.removeModelListener(l); if (nodeModel != treeModel) { - nodeModel.removeModelListener (l); + nodeModel.removeModelListener(l); } if (tableModel != treeModel && tableModel != nodeModel) { - tableModel.removeModelListener (l); + tableModel.removeModelListener(l); } if (treeExpansionModel instanceof CompoundTreeExpansionModel) { ((CompoundTreeExpansionModel) treeExpansionModel).removeModelListener(l); @@ -4700,7 +4788,7 @@ } @Override - public String toString () { + public String toString() { /*String str = super.toString () + "\n TreeModel = " + treeModel + "\n NodeModel = " + nodeModel + @@ -4716,16 +4804,15 @@ if (str.indexOf("VariablesTableModel") > 0) { return "CompoundModel [VARIABLES]"; }*/ - return super.toString () + - "\n TreeModel = " + treeModel + - "\n NodeModel = " + nodeModel + - "\n TableModel = " + tableModel + - "\n NodeActionsProvider = " + nodeActionsProvider + - "\n ColumnsModel = " + java.util.Arrays.asList(columnModels); + return super.toString() + + "\n TreeModel = " + treeModel + + "\n NodeModel = " + nodeModel + + "\n TableModel = " + tableModel + + "\n NodeActionsProvider = " + nodeActionsProvider + + "\n ColumnsModel = " + java.util.Arrays.asList(columnModels); } - + // ExtendedNodeModel - @Override public boolean canRename(Object node) throws UnknownTypeException { return nodeModel.canRename(node); @@ -4743,13 +4830,13 @@ @Override public Transferable clipboardCopy(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { return nodeModel.clipboardCopy(node); } @Override public Transferable clipboardCut(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { return nodeModel.clipboardCut(node); } @@ -4773,7 +4860,7 @@ @Override public Transferable drag(Object node) throws IOException, - UnknownTypeException { + UnknownTypeException { if (dndNodeModel != null) { return dndNodeModel.drag(node); } else { @@ -4788,7 +4875,7 @@ @Override public PasteType getDropType(Object node, Transferable t, int action, - int index) throws UnknownTypeException { + int index) throws UnknownTypeException { if (dndNodeModel != null) { return dndNodeModel.getDropType(node, t, action, index); } else { @@ -4841,18 +4928,34 @@ if (cnodeModel != null) { cnodeModel.setSelected(node, selected); } else { - Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model "+nodeModel)); + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + nodeModel)); } } - // AsynchronousModel + @Override + public void setSelected(Object... nodes) throws UnknownTypeException { + if (cnodeModel != null) { + cnodeModel.setSelected(nodes); + } else { + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + nodeModel)); + } + } + + @Override + public void setUnselected(Object... nodes) throws UnknownTypeException { + if (cnodeModel != null) { + cnodeModel.setUnselected(nodes); + } else { + Exceptions.printStackTrace(new IllegalStateException("Can not set selected state to model " + nodeModel)); + } + } + // AsynchronousModel public Executor asynchronous(CALL asynchCall, Object node) throws UnknownTypeException { return asynchModel.asynchronous(asynchCall, node); } // TableRendererModel - @Override public boolean canRenderCell(Object node, String columnID) throws UnknownTypeException { if (tableRendererModel != null) { @@ -4888,9 +4991,8 @@ return null; } } - - // TableHTMLModel + // TableHTMLModel @Override public boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException { return tableModel.hasHTMLValueAt(node, columnID); @@ -4900,9 +5002,8 @@ public String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException { return tableModel.getHTMLValueAt(node, columnID); } - - // TablePropertyEditorsModel + // TablePropertyEditorsModel @Override public PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException { if (tablePropertyEditorsModel != null) { @@ -4911,44 +5012,44 @@ return null; } } - - } private static final class ModelLists extends Object { - public List treeModels = Collections.emptyList(); - public List treeModelFilters = Collections.emptyList(); - public List treeExpansionModels = Collections.emptyList(); - public List treeExpansionModelFilters = Collections.emptyList(); - public List nodeModels = Collections.emptyList(); - public List nodeModelFilters = Collections.emptyList(); - public List tableModels = Collections.emptyList(); - public List tableModelFilters = Collections.emptyList(); - public List nodeActionsProviders = Collections.emptyList(); + public List treeModels = Collections.emptyList(); + public List treeModelFilters = Collections.emptyList(); + public List treeExpansionModels = Collections.emptyList(); + public List treeExpansionModelFilters = Collections.emptyList(); + public List nodeModels = Collections.emptyList(); + public List nodeModelFilters = Collections.emptyList(); + public List tableModels = Collections.emptyList(); + public List tableModelFilters = Collections.emptyList(); + public List nodeActionsProviders = Collections.emptyList(); public List nodeActionsProviderFilters = Collections.emptyList(); - public List columnModels = Collections.emptyList(); + public List columnModels = Collections.emptyList(); //public List asynchModels = Collections.emptyList(); - public List asynchModelFilters = Collections.emptyList(); - public List tableRendererModels = Collections.emptyList(); - public List tableRendererModelFilters = Collections.emptyList(); - public List tableHtmlModels = Collections.emptyList(); - public List tableHtmlModelFilters = Collections.emptyList(); + public List asynchModelFilters = Collections.emptyList(); + public List tableRendererModels = Collections.emptyList(); + public List tableRendererModelFilters = Collections.emptyList(); + public List tableHtmlModels = Collections.emptyList(); + public List tableHtmlModelFilters = Collections.emptyList(); public List tablePropertyEditorsModels = Collections.emptyList(); public List tablePropertyEditorsModelFilters = Collections.emptyList(); + public IconNodeModel iconNodeModel = null; + public LookupNodeModel lookupNodeModel = null; public void addOtherModels(List otherModels) { - Iterator it = otherModels.iterator (); - while (it.hasNext ()) { - Object model = it.next (); - boolean first = model.getClass ().getName ().endsWith ("First"); + Iterator it = otherModels.iterator(); + while (it.hasNext()) { + Object model = it.next(); + boolean first = model.getClass().getName().endsWith("First"); if (model instanceof TreeModel && !treeModels.contains((TreeModel) model)) { - treeModels = new ArrayList(treeModels); + treeModels = new ArrayList<>(treeModels); treeModels.add((TreeModel) model); } if (model instanceof TreeModelFilter && !treeModelFilters.contains((TreeModelFilter) model)) { - treeModelFilters = new ArrayList(treeModelFilters); + treeModelFilters = new ArrayList<>(treeModelFilters); if (first) { treeModelFilters.add((TreeModelFilter) model); } else { @@ -4956,11 +5057,11 @@ } } if (model instanceof TreeExpansionModel && !treeExpansionModels.contains((TreeExpansionModel) model)) { - treeExpansionModels = new ArrayList(treeExpansionModels); + treeExpansionModels = new ArrayList<>(treeExpansionModels); treeExpansionModels.add((TreeExpansionModel) model); } if (model instanceof TreeExpansionModelFilter && !treeExpansionModelFilters.contains((TreeExpansionModelFilter) model)) { - treeExpansionModelFilters = new ArrayList(treeExpansionModelFilters); + treeExpansionModelFilters = new ArrayList<>(treeExpansionModelFilters); if (first) { treeExpansionModelFilters.add((TreeExpansionModelFilter) model); } else { @@ -4968,11 +5069,11 @@ } } if (model instanceof NodeModel && !nodeModels.contains((NodeModel) model)) { - nodeModels = new ArrayList(nodeModels); + nodeModels = new ArrayList<>(nodeModels); nodeModels.add((NodeModel) model); } if (model instanceof NodeModelFilter && !nodeModelFilters.contains((NodeModelFilter) model)) { - nodeModelFilters = new ArrayList(nodeModelFilters); + nodeModelFilters = new ArrayList<>(nodeModelFilters); if (first) { nodeModelFilters.add((NodeModelFilter) model); } else { @@ -4980,11 +5081,11 @@ } } if (model instanceof TableModel && !tableModels.contains((TableModel) model)) { - tableModels = new ArrayList(tableModels); + tableModels = new ArrayList<>(tableModels); tableModels.add((TableModel) model); } if (model instanceof TableModelFilter && !tableModelFilters.contains((TableModelFilter) model)) { - tableModelFilters = new ArrayList(tableModelFilters); + tableModelFilters = new ArrayList<>(tableModelFilters); if (first) { tableModelFilters.add((TableModelFilter) model); } else { @@ -4992,11 +5093,11 @@ } } if (model instanceof TableRendererModel && !tableRendererModels.contains((TableRendererModel) model)) { - tableRendererModels = new ArrayList(tableRendererModels); + tableRendererModels = new ArrayList<>(tableRendererModels); tableRendererModels.add((TableRendererModel) model); } if (model instanceof TableRendererModelFilter && !tableRendererModelFilters.contains((TableRendererModelFilter) model)) { - tableRendererModelFilters = new ArrayList(tableRendererModelFilters); + tableRendererModelFilters = new ArrayList<>(tableRendererModelFilters); if (first) { tableRendererModelFilters.add((TableRendererModelFilter) model); } else { @@ -5004,11 +5105,11 @@ } } if (model instanceof TableHTMLModel && !tableHtmlModels.contains((TableHTMLModel) model)) { - tableHtmlModels = new ArrayList(tableHtmlModels); + tableHtmlModels = new ArrayList<>(tableHtmlModels); tableHtmlModels.add((TableHTMLModel) model); } if (model instanceof TableHTMLModelFilter && !tableHtmlModelFilters.contains((TableHTMLModelFilter) model)) { - tableHtmlModelFilters = new ArrayList(tableHtmlModelFilters); + tableHtmlModelFilters = new ArrayList<>(tableHtmlModelFilters); if (first) { tableHtmlModelFilters.add((TableHTMLModelFilter) model); } else { @@ -5016,11 +5117,11 @@ } } if (model instanceof TablePropertyEditorsModel && !tablePropertyEditorsModels.contains((TablePropertyEditorsModel) model)) { - tablePropertyEditorsModels = new ArrayList(tablePropertyEditorsModels); + tablePropertyEditorsModels = new ArrayList<>(tablePropertyEditorsModels); tablePropertyEditorsModels.add((TablePropertyEditorsModel) model); } if (model instanceof TablePropertyEditorsModelFilter && !tablePropertyEditorsModelFilters.contains((TablePropertyEditorsModelFilter) model)) { - tablePropertyEditorsModelFilters = new ArrayList(tablePropertyEditorsModelFilters); + tablePropertyEditorsModelFilters = new ArrayList<>(tablePropertyEditorsModelFilters); if (first) { tablePropertyEditorsModelFilters.add((TablePropertyEditorsModelFilter) model); } else { @@ -5028,11 +5129,11 @@ } } if (model instanceof NodeActionsProvider && !nodeActionsProviders.contains((NodeActionsProvider) model)) { - nodeActionsProviders = new ArrayList(nodeActionsProviders); + nodeActionsProviders = new ArrayList<>(nodeActionsProviders); nodeActionsProviders.add((NodeActionsProvider) model); } if (model instanceof NodeActionsProviderFilter && !nodeActionsProviderFilters.contains((NodeActionsProviderFilter) model)) { - nodeActionsProviderFilters = new ArrayList(nodeActionsProviderFilters); + nodeActionsProviderFilters = new ArrayList<>(nodeActionsProviderFilters); if (first) { nodeActionsProviderFilters.add((NodeActionsProviderFilter) model); } else { @@ -5044,7 +5145,7 @@ asynchModels.add((AsynchronousModel) model); }*/ if (model instanceof AsynchronousModelFilter && !asynchModelFilters.contains((AsynchronousModelFilter) model)) { - asynchModelFilters = new ArrayList(asynchModelFilters); + asynchModelFilters = new ArrayList<>(asynchModelFilters); if (first) { asynchModelFilters.add((AsynchronousModelFilter) model); } else { @@ -5053,9 +5154,16 @@ } if (model instanceof ColumnModel && !columnModels.contains((ColumnModel) model)) { - columnModels = new ArrayList(columnModels); + columnModels = new ArrayList<>(columnModels); columnModels.add((ColumnModel) model); } + + if (model instanceof IconNodeModel) { + iconNodeModel = (IconNodeModel) model; + } + if (model instanceof LookupNodeModel) { + lookupNodeModel = (LookupNodeModel) model; + } } } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProviderFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProviderFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProviderFilter.java 2016-02-04 02:55:43.096100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProviderFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,55 +41,51 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import javax.swing.Action; - /** - * Filters actions provided by some original {@link NodeActionsProvider}. - * It can be used to add some new actions to nodes pop-up menu, remove - * some actions or redefine behaviour of some actions. + * Filters actions provided by some original {@link NodeActionsProvider}. It can + * be used to add some new actions to nodes pop-up menu, remove some actions or + * redefine behaviour of some actions. * - * @author Jan Jancura + * @author Jan Jancura */ public interface NodeActionsProviderFilter extends Model { - /** * Performs default action for given node. You should not throw * UnknownTypeException directly from this method! * - * @throws UnknownTypeException this exception can be thrown from - * original.performDefaultAction (...) method call only! + * @throws UnknownTypeException this exception can be thrown from + * original.performDefaultAction (...) method call only! */ - public abstract void performDefaultAction ( - NodeActionsProvider original, - Object node + public abstract void performDefaultAction( + NodeActionsProvider original, + Object node ) throws UnknownTypeException; - + /** - * Returns set of actions for given node. You should not throw UnknownTypeException - * directly from this method! + * Returns set of actions for given node. You should not throw + * UnknownTypeException directly from this method! * - * @throws UnknownTypeException this exception can be thrown from - * original.getActions (...) method call only! - * @return set of actions for given node + * @throws UnknownTypeException this exception can be thrown from + * original.getActions (...) method call only! + * @return set of actions for given node */ - public abstract Action[] getActions ( - NodeActionsProvider original, - Object node + public abstract Action[] getActions( + NodeActionsProvider original, + Object node ) throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ // public abstract void addModelListener (ModelListener l); - - /** + /** * Unregisters given listener. * * @param l the listener to remove diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProvider.java spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProvider.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProvider.java 2016-02-04 02:55:43.095100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeActionsProvider.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,49 +41,45 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import javax.swing.Action; - /** - * Provides actions and default action for some type of objects. - * Designed to be used with {@link TreeModel}. + * Provides actions and default action for some type of objects. Designed to be + * used with {@link TreeModel}. * - * @author Jan Jancura + * @author Jan Jancura */ public interface NodeActionsProvider extends Model { - /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider implementation + * is not able to resolve actions for given node type + * @return display name for given node */ - public abstract void performDefaultAction (Object node) - throws UnknownTypeException; - + public abstract void performDefaultAction(Object node) + throws UnknownTypeException; + /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider implementation + * is not able to resolve actions for given node type + * @return display name for given node */ - public abstract Action[] getActions (Object node) - throws UnknownTypeException; + public abstract Action[] getActions(Object node) + throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ // public abstract void addModelListener (ModelListener l); - - /** + /** * Unregisters given listener. * * @param l the listener to remove diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModelFilter.java 2016-02-04 02:55:43.096100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModelFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,63 +41,60 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - /** * Filters content of some existing {@link NodeModel}. You can change display * name, tooltip, or icon for some existing object here. * - * @author Jan Jancura + * @author Jan Jancura */ public interface NodeModelFilter extends Model { /** - * Returns filterred display name for given node. You should not - * throw UnknownTypeException directly from this method! + * Returns filterred display name for given node. You should not throw + * UnknownTypeException directly from this method! * - * @throws UnknownTypeException this exception can be thrown from - * original.getDisplayName (...) method call only! - * @return display name for given node + * @throws UnknownTypeException this exception can be thrown from + * original.getDisplayName (...) method call only! + * @return display name for given node */ - public abstract String getDisplayName (NodeModel original, Object node) - throws UnknownTypeException; - + public abstract String getDisplayName(NodeModel original, Object node) + throws UnknownTypeException; + /** - * Returns filterred icon for given node. You should not throw + * Returns filterred icon for given node. You should not throw * UnknownTypeException directly from this method! * - * @throws UnknownTypeException this exception can be thrown from - * original.getIconBase (...) method call only! - * @return icon for given node + * @throws UnknownTypeException this exception can be thrown from + * original.getIconBase (...) method call only! + * @return icon for given node */ - public abstract String getIconBase (NodeModel original, Object node) - throws UnknownTypeException; - + public abstract String getIconBase(NodeModel original, Object node) + throws UnknownTypeException; + /** - * Returns filterred tooltip for given node. You should not throw + * Returns filterred tooltip for given node. You should not throw * UnknownTypeException directly from this method! * - * @throws UnknownTypeException this exception can be thrown from - * original.getShortDescription (...) method call only! - * @return tooltip for given node + * @throws UnknownTypeException this exception can be thrown from + * original.getShortDescription (...) method call only! + * @return tooltip for given node */ - public abstract String getShortDescription (NodeModel original, Object node) - throws UnknownTypeException; + public abstract String getShortDescription(NodeModel original, Object node) + throws UnknownTypeException; - - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModel.java 2016-02-04 02:55:43.096100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/NodeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,57 +41,55 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - /** - * Provides display name, icon and tool tip value for some type of objects. + * Provides display name, icon and tooltip value for some type of objects. * Designed to be used with {@link TreeModel}. * - * @author Jan Jancura + * @author Jan Jancura */ public interface NodeModel extends Model { /** * Returns display name for given node. * - * @return display name for given node + * @return display name for given node */ - public abstract String getDisplayName (Object node) - throws UnknownTypeException; + public abstract String getDisplayName(Object node) + throws UnknownTypeException; /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node + * @throws UnknownTypeException if this NodeModel implementation is not able + * to resolve icon for given node type + * @return icon for given node */ - public abstract String getIconBase (Object node) - throws UnknownTypeException; - + public abstract String getIconBase(Object node) + throws UnknownTypeException; + /** - * Returns tool tip for given node. + * Returns tooltip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tool tip for given node type - * @return tool tip for given node + * @throws UnknownTypeException if this NodeModel implementation is not able + * to resolve tooltip for given node type + * @return tooltip for given node */ - public abstract String getShortDescription (Object node) - throws UnknownTypeException; + public abstract String getShortDescription(Object node) + throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/package.html spi.viewmodel/src/org/netbeans/spi/viewmodel/package.html --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/package.html 2016-02-04 02:55:43.107100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/package.html 2016-11-03 07:23:29.837689369 +0100 @@ -1,116 +1,116 @@ - - - - View Model API - - - - -Defines API for sharing of Tree Table View. This API has been designed -for sharing Debugger Views (like Callstack View) among different -modules. But it does not depends on debugger itself.
-

Main features:

-
    -
  • One TreeView, or TreeTableView can be shared among different -modules. Different modules can add different types of nodes to one view.
  • -
  • Hierarchy produced by one module can be changed by another one.
    -
  • -
  • Allows to split UI and implementation to different modules.
  • -
  • Performance and memory consumption of this model should be much -better than Node based models.
  • -
  • You do not need one instance of some class (Node) per one node -visible in view. And you do not need one class per one node type.
    -
  • -
-

How to use View Model API
-

-Following example shows how to use viewmodel API to create simple files -view.
-

Step 1.

-In the first step we should create plain tree model (TreeModel).
-
public class TreeModelImpl implements TreeModel {
+ + + View Model API + + + + + Defines API for sharing of Tree Table View. This API has been designed + for sharing Debugger Views (like Callstack View) among different + modules. But it does not depends on debugger itself.
+

Main features:

+
    +
  • One TreeView, or TreeTableView can be shared among different + modules. Different modules can add different types of nodes to one view.
  • +
  • Hierarchy produced by one module can be changed by another one.
    +
  • +
  • Allows to split UI and implementation to different modules.
  • +
  • Performance and memory consumption of this model should be much + better than Node based models.
  • +
  • You do not need one instance of some class (Node) per one node + visible in view. And you do not need one class per one node type.
    +
  • +
+

How to use View Model API
+

+ Following example shows how to use viewmodel API to create simple files + view.
+

Step 1.

+ In the first step we should create plain tree model (TreeModel).
+
public class TreeModelImpl implements TreeModel {
Tree Model Example 1
public Object getRoot () {
return ROOT;
}

public Object[] getChildren (Object parent, int from, int to) {
if (parent == ROOT)
return File.listRoots ();
return ((File) parent).listFiles ();
}

public boolean isLeaf (Object node) {
if (node == ROOT)
return false;
return ((File) node).isFile ();
}
}
-And create a TreeView for this model: -
    JComponent treeView = Models.createView (
Models.createCompoundModel (
Arrays.asList (new Model[] {
new TreeModelImpl (), // TreeModel
new ArrayList () // list of ColumnModel s
})
)
);
-

Step 2.

-NodeModel implementation can define name, icon and tooltip for tree -nodes produced by TreeModel.
-
public class NodeModelImpl implements NodeModel {    JComponent treeView = Models.createView (
Models.createCompoundModel (
Arrays.asList (new Model[] {
new TreeModelImpl (), // TreeModel
new ArrayList () // list of ColumnModel s
})
)
);
+

Step 2.

+ NodeModel implementation can define name, icon and tooltip for tree + nodes produced by TreeModel.
+
public class NodeModelImpl implements NodeModel {Tree Model Example 2

public String getDisplayName (Object node) {
if (node == ROOT) return "Name";
String name = ((File) node).getName ();
if (name.length () < 1) return ((File) node).getAbsolutePath ();
return name;
}

public String getIconBase (Object node) {
if (node == ROOT) return "folder";
if (((File) node).isDirectory ()) return "folder";
return "file";
}

public String getShortDescription (Object node) {
if (node == ROOT) return "Name";
return ((File) node).getAbsolutePath ();
}
}
-

Step 3.

-NodeActionsProvider defines set of Actions for each node, and default -action..
-
public class NodeActionsProviderImpl implements NodeActionsProvider {

public Action[] getActions (final Object node) {
return new Action [] {
new AbstractAction ("Open") {
public void actionPerformed (ActionEvent e) {
performDefaultAction (node);
}
},
new AbstractAction ("Delete") {
public void actionPerformed (ActionEvent e) {
((File) node).delete ();
}
}
};
}

public void performDefaultAction (Object node) {
try {
JFrame f = new JFrame ("View");
f.getContentPane ().add (new JEditorPane (((File) node).toURL ()));
f.pack ();
f.show ();
} catch (Exception e) {
e.printStackTrace();
}
}
}
-
-
Tree Model Example 3
-
-

Step 4.

-TableModel and ColumnModel adds support for additional columns to tree -view.
-
public class TableModelImpl implements TableModel {


public Object getValueAt (Object node, String columnID) {
try {
if (node == ROOT) return null;
if (columnID.equals ("sizeID")) {
if (((File) node).isDirectory ()) return "<dir>";
return "" + new FileInputStream ((File) node).getChannel ().size ();
}
} catch (Exception e) {
e.printStackTrace ();
}
return "";
}

public boolean isReadOnly (Object node, String columnID) {
return true;
}

public void setValueAt (Object node, String columnID, Object value) {
}
}
-And initialization of columns looks like:
-
    ArrayList columns = new ArrayList ();Step 3.
+        NodeActionsProvider defines set of Actions for each node, and default
+        action..
+
public class NodeActionsProviderImpl implements NodeActionsProvider {

public Action[] getActions (final Object node) {
return new Action [] {
new AbstractAction ("Open") {
public void actionPerformed (ActionEvent e) {
performDefaultAction (node);
}
},
new AbstractAction ("Delete") {
public void actionPerformed (ActionEvent e) {
((File) node).delete ();
}
}
};
}

public void performDefaultAction (Object node) {
try {
JFrame f = new JFrame ("View");
f.getContentPane ().add (new JEditorPane (((File) node).toURL ()));
f.pack ();
f.show ();
} catch (Exception e) {
e.printStackTrace();
}
}
}
+
+
Tree Model Example 3
+
+

Step 4.

+ TableModel and ColumnModel adds support for additional columns to tree + view.
+
public class TableModelImpl implements TableModel {


public Object getValueAt (Object node, String columnID) {
try {
if (node == ROOT) return null;
if (columnID.equals ("sizeID")) {
if (((File) node).isDirectory ()) return "<dir>";
return "" + new FileInputStream ((File) node).getChannel ().size ();
}
} catch (Exception e) {
e.printStackTrace ();
}
return "";
}

public boolean isReadOnly (Object node, String columnID) {
return true;
}

public void setValueAt (Object node, String columnID, Object value) {
}
}
+ And initialization of columns looks like:
+
    ArrayList columns = new ArrayList ();Tree Model Example 4
columns.add (new ColumnModel () {
public String getID () { return "sizeID"; }
public String getDisplayName () { return "size"; }
public Class getType () { return String.class; }
});
JComponent treeTableView = Models.createView (
Models.createCompoundModel (
Arrays.asList (new Model[] {
new TreeModelImpl (), // TreeModel
new NodeModelImpl (), // NodeModel
new TableModelImpl (), // TableModel
new NodeActionsProviderImpl (), // NodeActionsProvider
columns // list of ColumnModel s
})
)
);

-
-
-
-

How to use Filters

-We can use filters to modify content of tree table view created in our -example.
-
    -
  • TreeModelFilter: this -filter can be used to hide fome files, to add some virtual filesystems, -to add content of zip files to original tree, and so on.
  • -
  • NodeModelFilter: can be -used to change names, icons or tooltips for existing files.
  • -
  • TableModelFilter: can be -used to modify content of columns.
  • -
  • NodeActionsProviderFilter: -can be used to add a new actions to pup-up menus, of to redefine -default action.
  • -
-All these actions can be done in some external module.
-
- +
+
+
+

How to use Filters

+ We can use filters to modify content of tree table view created in our + example.
+
    +
  • TreeModelFilter: this + filter can be used to hide fome files, to add some virtual filesystems, + to add content of zip files to original tree, and so on.
  • +
  • NodeModelFilter: can be + used to change names, icons or tooltips for existing files.
  • +
  • TableModelFilter: can be + used to modify content of columns.
  • +
  • NodeActionsProviderFilter: + can be used to add a new actions to pup-up menus, of to redefine + default action.
  • +
+ All these actions can be done in some external module.
+
+ diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModelFilter.java 2016-02-04 02:55:43.097100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModelFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -39,13 +39,12 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; /** - * Filters an original tree data model that supports reordering - * of child nodes. The created {@link org.openide.nodes.Node} will contain - * an implementation of {@link org.openide.nodes.Index} in it's lookup if + * Filters an original tree data model that supports reordering of child nodes. + * The created {@link org.openide.nodes.Node} will contain an implementation of + * {@link org.openide.nodes.Index} in it's lookup if * {@link #canReorder(org.netbeans.spi.viewmodel.ReorderableTreeModel, java.lang.Object)} * returns true. * @@ -56,25 +55,27 @@ /** * Provide if this filter implementation can reorder children nodes. + * * @param original The original ReorderableTreeModel * @param parent The parent node of children that are test for reorder - * @return true if this model can handle reordering of children, - * false otherwise - * @throws UnknownTypeException if this model implementation is not - * able to decide the reorder capability for given node type + * @return true if this model can handle reordering of + * children, false otherwise + * @throws UnknownTypeException if this model implementation is not able to + * decide the reorder capability for given node type */ public boolean canReorder(ReorderableTreeModel original, Object parent) throws UnknownTypeException; /** * Reorder children nodes with a given permutation. + * * @param parent The parent node of children that are being reordered - * @param perm permutation with the length of current child nodes. The permutation - * lists the new positions of the original nodes, that is, for nodes - * [A,B,C,D] and permutation [0,3,1,2], the final - * order would be [A,C,D,B]. + * @param perm permutation with the length of current child nodes. The + * permutation lists the new positions of the original nodes, that is, for + * nodes [A,B,C,D] and permutation [0,3,1,2], the + * final order would be [A,C,D,B]. * @throws IllegalArgumentException if the permutation is not valid - * @throws UnknownTypeException if this model implementation is not - * able to perform the reorder for given node type + * @throws UnknownTypeException if this model implementation is not able to + * perform the reorder for given node type */ public void reorder(ReorderableTreeModel original, Object parent, int[] perm) throws UnknownTypeException; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModel.java 2016-02-04 02:55:43.097100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/ReorderableTreeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -39,17 +39,16 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; /** - * Data model for tree that supports reordering - * of child nodes. The created {@link org.openide.nodes.Node} will contain - * an implementation of {@link org.openide.nodes.Index} in it's lookup - * if {@link #canReorder(java.lang.Object)} returns true. + * Data model for tree that supports reordering of child nodes. The created + * {@link org.openide.nodes.Node} will contain an implementation of + * {@link org.openide.nodes.Index} in it's lookup if + * {@link #canReorder(java.lang.Object)} returns true. *

- * When used together with {@link DnDNodeModel}, children can be reordered - * by Drag and Drop. + * When used together with {@link DnDNodeModel}, children can be reordered by + * Drag and Drop. * * @author Martin Entlicher * @since 1.25 @@ -58,24 +57,26 @@ /** * Provide if this model implementation can reorder children nodes. + * * @param parent The parent node of children that are test for reorder - * @return true if this model can handle reordering of children, - * false otherwise - * @throws UnknownTypeException if this model implementation is not - * able to decide the reorder capability for given node type + * @return true if this model can handle reordering of + * children, false otherwise + * @throws UnknownTypeException if this model implementation is not able to + * decide the reorder capability for given node type */ public boolean canReorder(Object parent) throws UnknownTypeException; /** * Reorder children nodes with a given permutation. + * * @param parent The parent node of children that are being reordered - * @param perm permutation with the length of current child nodes. The permutation - * lists the new positions of the original nodes, that is, for nodes - * [A,B,C,D] and permutation [0,3,1,2], the final - * order would be [A,C,D,B]. + * @param perm permutation with the length of current child nodes. The + * permutation lists the new positions of the original nodes, that is, for + * nodes [A,B,C,D] and permutation [0,3,1,2], the + * final order would be [A,C,D,B]. * @throws IllegalArgumentException if the permutation is not valid - * @throws UnknownTypeException if this model implementation is not - * able to perform the reorder for given node type + * @throws UnknownTypeException if this model implementation is not able to + * perform the reorder for given node type */ public void reorder(Object parent, int[] perm) throws UnknownTypeException; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionChangedListener.java spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionChangedListener.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionChangedListener.java 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionChangedListener.java 2016-11-03 07:23:29.835689349 +0100 @@ -0,0 +1,83 @@ +// +/*COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +* +* 1. Definitions. +* 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications. +* 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. +* 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. +* 1.4. "Executable" means the Covered Software in any form other than Source Code. +* 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License. +* 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. +* 1.7. "License" means this document. +* 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. +* 1.9 "Modifications" means the Source Code and Executable form of any of the following: +* A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; +* B. Any new file that contains any part of the Original Software or previous Modification; or +* C. Any new file that is contributed or otherwise made available under the terms of this License. +* 1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License. +* 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. +* 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. +* 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. +* 2. License Grants. +* 2.1. The Initial Developer Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). +* (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. +* (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. +* 2.2. Contributor Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). +* (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. +* (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. +* 3. Distribution Obligations. +* 3.1. Availability of Source Code. +* Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. +* 3.2. Modifications. +* The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. +* 3.3. Required Notices. +* You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. +* 3.4. Application of Additional Terms. +* You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients� rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. +* 3.5. Distribution of Executable Versions. +* You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient�s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. +* 3.6. Larger Works. +* You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. +* 4. Versions of the License. +* 4.1. New Versions. +* Oracle Corp. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. +* 4.2. Effect of New Versions. +* You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. +* 4.3. Modified Versions. +* When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. +* 5. DISCLAIMER OF WARRANTY. +* COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +* 6. TERMINATION. +* 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. +* 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. +* 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. +* 7. LIMITATION OF LIABILITY. +* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. +* 8. U.S. GOVERNMENT END USERS. +* The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. +* 9. MISCELLANEOUS. +* This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction�s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys� fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. +* 10. RESPONSIBILITY FOR CLAIMS. +* As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. +* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +* The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. + */ +// +package org.netbeans.spi.viewmodel; + +import java.util.Set; + +/** + * + * @author matteo + */ +public interface SelectionChangedListener { + + void selectionChanged(Set selection); +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionModel.java 1970-01-01 01:00:00.000000000 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/SelectionModel.java 2016-11-03 07:23:29.838689379 +0100 @@ -0,0 +1,89 @@ +// +/*COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +* +* 1. Definitions. +* 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications. +* 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. +* 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. +* 1.4. "Executable" means the Covered Software in any form other than Source Code. +* 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License. +* 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. +* 1.7. "License" means this document. +* 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. +* 1.9 "Modifications" means the Source Code and Executable form of any of the following: +* A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; +* B. Any new file that contains any part of the Original Software or previous Modification; or +* C. Any new file that is contributed or otherwise made available under the terms of this License. +* 1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License. +* 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. +* 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. +* 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. +* 2. License Grants. +* 2.1. The Initial Developer Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). +* (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. +* (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. +* 2.2. Contributor Grant. +* Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: +* (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and +* (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). +* (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. +* (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. +* 3. Distribution Obligations. +* 3.1. Availability of Source Code. +* Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. +* 3.2. Modifications. +* The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. +* 3.3. Required Notices. +* You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. +* 3.4. Application of Additional Terms. +* You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients� rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. +* 3.5. Distribution of Executable Versions. +* You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient�s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. +* 3.6. Larger Works. +* You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. +* 4. Versions of the License. +* 4.1. New Versions. +* Oracle Corp. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. +* 4.2. Effect of New Versions. +* You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. +* 4.3. Modified Versions. +* When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. +* 5. DISCLAIMER OF WARRANTY. +* COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +* 6. TERMINATION. +* 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. +* 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. +* 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. +* 7. LIMITATION OF LIABILITY. +* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. +* 8. U.S. GOVERNMENT END USERS. +* The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. +* 9. MISCELLANEOUS. +* This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction�s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys� fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. +* 10. RESPONSIBILITY FOR CLAIMS. +* As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. +* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) +* The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. + */ +// +package org.netbeans.spi.viewmodel; + +import java.util.Set; + +/** + * + * @author matteo + */ +public interface SelectionModel extends Model { + + void addSelectionChangeListener(SelectionChangedListener l); + + void removeSelectionChangeListener(SelectionChangedListener l); + + Set getSelection(); + + void setSelection(Set wellsSelection); +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SuperNodeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/SuperNodeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/SuperNodeModel.java 2016-02-04 02:55:43.098100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/SuperNodeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -39,12 +39,11 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.spi.viewmodel; /** - * NodeModel covering all known extensions. - * Not public API, created for implementation purpose only. + * NodeModel covering all known extensions. Not public API, created for + * implementation purpose only. * * @author Martin Entlicher */ diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModelFilter.java 2016-02-04 02:55:43.098100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModelFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -42,61 +42,65 @@ package org.netbeans.spi.viewmodel; /** - * Use this to separate value and the HTML value. - * Implement this filter to override the behavior of any registered {@link TableHTMLModel}s. - * + * Use this to separate value and the HTML value. Implement this filter to + * override the behavior of any registered {@link TableHTMLModel}s. + * * @author Martin Entlicher * @since 1.42 * @see TableHTMLModel */ public interface TableHTMLModelFilter extends Model { - + /** - * Test if the model has a HTML value. - * For backward compatibility, if it returns false, - * HTML value is is taken from the String value, if it contains some. - * If this is not desired, return true here and null from + * Test if the model has a HTML value. For backward compatibility, if it + * returns false, HTML value is is taken from the String value, + * if it contains some. If this is not desired, return true here and null + * from * {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)}. + * * @param original The original {@link TableHTMLModel} - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return true if there is some HTML value to be returned - * from {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)}, - * false otherwise. - * When false is returned, - * {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)} - * is not called. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type + * @return true if there is some HTML value to be returned from + * {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)}, + * false otherwise. When false is returned, + * {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)} + * is not called. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type */ boolean hasHTMLValueAt(TableHTMLModel original, Object node, String columnID) throws UnknownTypeException; - + /** * Get the HTML value. - * + * * @param original The original {@link TableHTMLModel} - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return The HTML value, or null when no HTML value is provided. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type - * @see #hasHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String) + * @return The HTML value, or null when no HTML value is + * provided. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type + * @see #hasHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, + * java.lang.Object, java.lang.String) */ String getHTMLValueAt(TableHTMLModel original, Object node, String columnID) throws UnknownTypeException; - + /** * Registers given listener. * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModel.java 2016-02-04 02:55:43.098100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -42,47 +42,49 @@ package org.netbeans.spi.viewmodel; /** - * Use this to separate value and the HTML value. - * When displaying a property value, then if the value is a String and if it contains - * a HTML code, it's automatically rendered as HTML. The HTML code is then - * stripped out to get the raw value. - * If this is not desired or if it's necessary to provide a value and HTML code - * that differs from each other, implement this model. - * + * Use this to separate value and the HTML value. When displaying a property + * value, then if the value is a String and if it contains a HTML code, it's + * automatically rendered as HTML. The HTML code is then stripped out to get the + * raw value. If this is not desired or if it's necessary to provide a value and + * HTML code that differs from each other, implement this model. + * * @author Martin Entlicher * @since 1.42 * @see TableHTMLModelFilter */ public interface TableHTMLModel extends TableModel { - + /** - * Test if the model has a HTML value. - * For backward compatibility, if it returns false, - * HTML value is is taken from the String value, if it contains some. - * If this is not desired, return true here and null from - * {@link #getHTMLValueAt(java.lang.Object, java.lang.String)}. - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * Test if the model has a HTML value. For backward compatibility, if it + * returns false, HTML value is is taken from the String value, + * if it contains some. If this is not desired, return true here and null + * from {@link #getHTMLValueAt(java.lang.Object, java.lang.String)}. + * + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return true if there is some HTML value to be returned - * from {@link #getHTMLValueAt(java.lang.Object, java.lang.String)}, - * false otherwise. - * When false is returned, - * {@link #getHTMLValueAt(java.lang.Object, java.lang.String)} is not called. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type + * @return true if there is some HTML value to be returned from + * {@link #getHTMLValueAt(java.lang.Object, java.lang.String)}, + * false otherwise. When false is returned, + * {@link #getHTMLValueAt(java.lang.Object, java.lang.String)} is not + * called. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type */ boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException; - + /** * Get the HTML value. - * - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return The HTML value, or null when no HTML value is provided. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type + * @return The HTML value, or null when no HTML value is + * provided. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type * @see #hasHTMLValueAt(java.lang.Object, java.lang.String) */ String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException; diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModelFilter.java 2016-02-04 02:55:43.099100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModelFilter.java 2016-11-03 07:23:29.836689359 +0100 @@ -41,96 +41,91 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; -import java.beans.PropertyEditor; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; - - /** - * Allows to filter content of some existing {@link TableModel}. You can add - * a new column, remmove some existing one, or change content of some existing + * Allows to filter content of some existing {@link TableModel}. You can add a + * new column, remmove some existing one, or change content of some existing * column. * - * @author Jan Jancura + * @author Jan Jancura */ public interface TableModelFilter extends Model { - /** * Returns filterred value to be displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from + * and row node. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned from * {@link TreeModel#getChildren}. You should not throw UnknownTypeException * directly from this method! * - * @param original the original table model - * @param node a object returned from {@link TreeModel#getChildren} for this row - * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException this exception can be thrown from - * original.getValueAt (...) method call only! + * @param original the original table model + * @param node a object returned from {@link TreeModel#getChildren} for this + * row + * @param columnID a id of column defined by {@link ColumnModel#getID} + * @throws UnknownTypeException this exception can be thrown from + * original.getValueAt (...) method call only! * * @return value of variable representing given position in tree table. */ - public abstract Object getValueAt ( - TableModel original, - Object node, - String columnID + public abstract Object getValueAt( + TableModel original, + Object node, + String columnID ) throws UnknownTypeException; - + /** - * Filters original isReadOnly value from given table model. You should - * not throw UnknownTypeException - * directly from this method! + * Filters original isReadOnly value from given table model. You should not + * throw UnknownTypeException directly from this method! * - * @param original the original table model - * @param node a object returned from {@link TreeModel#getChildren} for this row - * @param columnID a id of column defined by {@link ColumnModel#getID} - * @throws UnknownTypeException this exception can be thrown from - * original.isReadOnly (...) method call only! + * @param original the original table model + * @param node a object returned from {@link TreeModel#getChildren} for this + * row + * @param columnID a id of column defined by {@link ColumnModel#getID} + * @throws UnknownTypeException this exception can be thrown from + * original.isReadOnly (...) method call only! * * @return true if variable on given position is read only */ - public abstract boolean isReadOnly ( - TableModel original, - Object node, - String columnID + public abstract boolean isReadOnly( + TableModel original, + Object node, + String columnID ) throws UnknownTypeException; - + /** - * Changes a value displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from + * Changes a value displayed in column columnID and row + * node. Column ID is defined in by {@link ColumnModel#getID}, + * and rows are defined by values returned from * {@link TreeModel#getChildren}. You should not throw UnknownTypeException * directly from this method! * - * @param original the original table model - * @param node a object returned from {@link TreeModel#getChildren} for this row - * @param columnID a id of column defined by {@link ColumnModel#getID} - * @param value a new value of variable on given position - * @throws UnknownTypeException this exception can be thrown from - * original.setValueAt (...) method call only! + * @param original the original table model + * @param node a object returned from {@link TreeModel#getChildren} for this + * row + * @param columnID a id of column defined by {@link ColumnModel#getID} + * @param value a new value of variable on given position + * @throws UnknownTypeException this exception can be thrown from + * original.setValueAt (...) method call only! */ - public abstract void setValueAt ( - TableModel original, - Object node, - String columnID, - Object value + public abstract void setValueAt( + TableModel original, + Object node, + String columnID, + Object value ) throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModel.java 2016-02-04 02:55:43.099100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,77 +41,76 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - /** * Adds support for columns to basic {@link TreeModel}. * - * @author Jan Jancura + * @author Jan Jancura */ public interface TableModel extends Model { - /** - * Returns value to be displayed in column columnID - * and row identified by node. Column ID is defined in by + * Returns value to be displayed in column columnID and row + * identified by node. Column ID is defined in by * {@link ColumnModel#getID}, and rows are defined by values returned from * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren}. * - * @param node a object returned from - * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren} for this row + * @param node a object returned from + * {@link org.netbeans.spi.viewmodel.TreeModel#getChildren} for this row * @param columnID a id of column defined by {@link ColumnModel#getID} * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * parameter type * * @return value of variable representing given position in tree table. */ - public abstract Object getValueAt (Object node, String columnID) throws - UnknownTypeException; - + public abstract Object getValueAt(Object node, String columnID) throws + UnknownTypeException; + /** - * Returns true if value displayed in column columnID - * and row node is read only. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from + * Returns true if value displayed in column columnID and row + * node is read only. Column ID is defined in by + * {@link ColumnModel#getID}, and rows are defined by values returned from * {@link TreeModel#getChildren}. * - * @param node a object returned from {@link TreeModel#getChildren} for this row + * @param node a object returned from {@link TreeModel#getChildren} for this + * row * @param columnID a id of column defined by {@link ColumnModel#getID} * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * parameter type * * @return true if variable on given position is read only */ - public abstract boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException; - + public abstract boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException; + /** - * Changes a value displayed in column columnID - * and row node. Column ID is defined in by - * {@link ColumnModel#getID}, and rows are defined by values returned from + * Changes a value displayed in column columnID and row + * node. Column ID is defined in by {@link ColumnModel#getID}, + * and rows are defined by values returned from * {@link TreeModel#getChildren}. * - * @param node a object returned from {@link TreeModel#getChildren} for this row + * @param node a object returned from {@link TreeModel#getChildren} for this + * row * @param columnID a id of column defined by {@link ColumnModel#getID} * @param value a new value of variable on given position * @throws UnknownTypeException if there is no TableModel defined for given - * parameter type + * parameter type */ - public abstract void setValueAt (Object node, String columnID, Object value) - throws UnknownTypeException; + public abstract void setValueAt(Object node, String columnID, Object value) + throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModelFilter.java 2016-02-04 02:55:43.100100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModelFilter.java 2016-11-03 07:23:29.837689369 +0100 @@ -45,26 +45,29 @@ /** * Use this to provide different property editors for different table cells. - * Implement this filter to override the behavior of any registered {@link TablePropertyEditorsModel}s. + * Implement this filter to override the behavior of any registered + * {@link TablePropertyEditorsModel}s. * * @author Martin Entlicher * @since 1.42 * @see TablePropertyEditorsModel */ public interface TablePropertyEditorsModelFilter extends Model { - + /** * Get the property editor for the given table cell. - * + * * @param original The original {@link TablePropertyEditorsModel} - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return The property editor or null to use the column default one. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type + * @return The property editor or null to use the column + * default one. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type */ PropertyEditor getPropertyEditor(TablePropertyEditorsModel original, - Object node, String columnID) throws UnknownTypeException; - + Object node, String columnID) throws UnknownTypeException; + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModel.java 2016-02-04 02:55:43.100100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -45,23 +45,25 @@ /** * Use this to provide different property editors for different table cells. - * + * * @author Martin Entlicher * @since 1.42 * @see TablePropertyEditorsModelFilter */ public interface TablePropertyEditorsModel extends Model { - + /** * Get the property editor for the given table cell. - * - * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) } - * for this row + * + * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) + * } + * for this row * @param columnID an id of column defined by {@link ColumnModel#getID()} - * @return The property editor or null to use the column default one. - * @throws UnknownTypeException if there is nothing to be provided for the given - * parameter type + * @return The property editor or null to use the column + * default one. + * @throws UnknownTypeException if there is nothing to be provided for the + * given parameter type */ PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException; - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModelFilter.java 2016-02-04 02:55:43.101100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModelFilter.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,15 +41,15 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; /** - * Model filter that can override custom cell renderer and cell editor for table cells. - * + * Model filter that can override custom cell renderer and cell editor for table + * cells. + * * @author Martin Entlicher * @since 1.28 */ @@ -57,44 +57,54 @@ /** * Test whether this renderer can render the given cell. + * * @param original The original table cell renderer implementation * @param node Tree node representing the row * @param columnID The column name - * @return true if the implementation can render the given cell, false otherwise - * @throws UnknownTypeException If the implementation can not decide whether to render the given cell. + * @return true if the implementation can render the given + * cell, false otherwise + * @throws UnknownTypeException If the implementation can not decide whether + * to render the given cell. */ public boolean canRenderCell(TableRendererModel original, Object node, String columnID) throws UnknownTypeException; /** * Get the renderer of the given cell + * * @param original The original table cell renderer implementation * @param node Tree node representing the row * @param columnID The column name * @return The cell renderer - * @throws UnknownTypeException If the implementation can not render the given cell. + * @throws UnknownTypeException If the implementation can not render the + * given cell. */ public TableCellRenderer getCellRenderer(TableRendererModel original, Object node, String columnID) throws UnknownTypeException; /** * Test whether this renderer can edit the given cell. + * * @param original The original table cell renderer implementation * @param node Tree node representing the row * @param columnID The column name - * @return true if the implementation can edit the given cell, false otherwise - * @throws UnknownTypeException If the implementation can not decide whether to edit the given cell. + * @return true if the implementation can edit the given cell, + * false otherwise + * @throws UnknownTypeException If the implementation can not decide whether + * to edit the given cell. */ public boolean canEditCell(TableRendererModel original, Object node, String columnID) throws UnknownTypeException; /** * Get the editor of the given cell + * * @param original The original table cell renderer implementation * @param node Tree node representing the row * @param columnID The column name * @return The cell editor - * @throws UnknownTypeException If the implementation can not edit the given cell. + * @throws UnknownTypeException If the implementation can not edit the given + * cell. */ public TableCellEditor getCellEditor(TableRendererModel original, Object node, String columnID) throws UnknownTypeException; @@ -104,12 +114,12 @@ * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModel.java 2016-02-04 02:55:43.100100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TableRendererModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; import javax.swing.table.TableCellEditor; @@ -49,7 +48,7 @@ /** * Model that provides custom cell renderer and cell editor for table cells. - * + * * @author Martin Entlicher * @since 1.28 */ @@ -57,37 +56,47 @@ /** * Test whether this renderer can render the given cell. + * * @param node Tree node representing the row * @param columnID The column name - * @return true if the implementation can render the given cell, false otherwise - * @throws UnknownTypeException If the implementation can not decide whether to render the given cell. + * @return true if the implementation can render the given + * cell, false otherwise + * @throws UnknownTypeException If the implementation can not decide whether + * to render the given cell. */ public boolean canRenderCell(Object node, String columnID) throws UnknownTypeException; /** * Get the renderer of the given cell + * * @param node Tree node representing the row * @param columnID The column name * @return The cell renderer - * @throws UnknownTypeException If the implementation can not render the given cell. + * @throws UnknownTypeException If the implementation can not render the + * given cell. */ public TableCellRenderer getCellRenderer(Object node, String columnID) throws UnknownTypeException; /** * Test whether this renderer can edit the given cell. + * * @param node Tree node representing the row * @param columnID The column name - * @return true if the implementation can edit the given cell, false otherwise - * @throws UnknownTypeException If the implementation can not decide whether to edit the given cell. + * @return true if the implementation can edit the given cell, + * false otherwise + * @throws UnknownTypeException If the implementation can not decide whether + * to edit the given cell. */ public boolean canEditCell(Object node, String columnID) throws UnknownTypeException; /** * Get the editor of the given cell + * * @param node Tree node representing the row * @param columnID The column name * @return The cell editor - * @throws UnknownTypeException If the implementation can not edit the given cell. + * @throws UnknownTypeException If the implementation can not edit the given + * cell. */ public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException; @@ -96,12 +105,12 @@ * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModelFilter.java 2016-02-04 02:55:43.101100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModelFilter.java 2016-11-03 07:23:29.838689379 +0100 @@ -41,16 +41,14 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - /** * This model filter controlls expansion, collapsion of nodes in tree view, and - * defindes default expand state for all node in it. It may delegate to the supplied - * TreeExpansionModel. + * defindes default expand state for all node in it. It may delegate to the + * supplied TreeExpansionModel. * - * @author Martin Entlicher + * @author Martin Entlicher * @since 1.15 */ public interface TreeExpansionModelFilter extends Model { @@ -61,34 +59,34 @@ * @param node a node * @return default state (collapsed, expanded) of given node */ - public abstract boolean isExpanded (TreeExpansionModel original, Object node) - throws UnknownTypeException; + public abstract boolean isExpanded(TreeExpansionModel original, Object node) + throws UnknownTypeException; /** * Called when given node is expanded. * * @param node a expanded node */ - public abstract void nodeExpanded (Object node); - + public abstract void nodeExpanded(Object node); + /** * Called when given node is collapsed. * * @param node a collapsed node */ - public abstract void nodeCollapsed (Object node); - - /** + public abstract void nodeCollapsed(Object node); + + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModel.java 2016-02-04 02:55:43.101100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeExpansionModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,15 +41,13 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - /** * This model controlls expansion, collapsion of nodes in tree view, and * defindes default expand state for all node in it. * - * @author Jan Jancura + * @author Jan Jancura */ public interface TreeExpansionModel extends Model { @@ -59,20 +57,20 @@ * @param node a node * @return default state (collapsed, expanded) of given node */ - public abstract boolean isExpanded (Object node) - throws UnknownTypeException; + public abstract boolean isExpanded(Object node) + throws UnknownTypeException; /** * Called when given node is expanded. * * @param node a expanded node */ - public abstract void nodeExpanded (Object node); - + public abstract void nodeExpanded(Object node); + /** * Called when given node is collapsed. * * @param node a collapsed node */ - public abstract void nodeCollapsed (Object node); + public abstract void nodeCollapsed(Object node); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModelFilter.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModelFilter.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModelFilter.java 2016-02-04 02:55:43.103100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModelFilter.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,89 +41,84 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - - /** * Filters content of some original tree of nodes (represented by * {@link TreeModel}). * - * @author Jan Jancura + * @author Jan Jancura */ public interface TreeModelFilter extends Model { - /** * Returns filtered root of hierarchy. * - * @param original the original tree model - * @return filtered root of hierarchy + * @param original the original tree model + * @return filtered root of hierarchy */ - public abstract Object getRoot (TreeModel original); + public abstract Object getRoot(TreeModel original); /** - * Returns filtered children for given parent on given indexes. - * Typically you should get original nodes - * (original.getChildren (...)), and modify them, or return - * it without modifications. You should not throw UnknownTypeException - * directly from this method! + * Returns filtered children for given parent on given indexes. Typically + * you should get original nodes (original.getChildren (...)), + * and modify them, or return it without modifications. You should not throw + * UnknownTypeException directly from this method! + * + * @param original the original tree model + * @param parent a parent of returned nodes + * @throws UnknownTypeException this exception can be thrown from + * original.getChildren (...) method call only! * - * @param original the original tree model - * @param parent a parent of returned nodes - * @throws UnknownTypeException this exception can be thrown from - * original.getChildren (...) method call only! - * - * @return children for given parent on given indexes - */ - public abstract Object[] getChildren ( - TreeModel original, - Object parent, - int from, - int to + * @return children for given parent on given indexes + */ + public abstract Object[] getChildren( + TreeModel original, + Object parent, + int from, + int to ) throws UnknownTypeException; - + /** - * Returns number of filtered children for given node. - * - * @param original the original tree model - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * - * @return true if node is leaf - */ - public abstract int getChildrenCount ( - TreeModel original, - Object node + * Returns number of filterred children for given node. + * + * @param original the original tree model + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not able + * to resolve children for given node type + * + * @return true if node is leaf + */ + public abstract int getChildrenCount( + TreeModel original, + Object node ) throws UnknownTypeException; - + /** * Returns true if node is leaf. You should not throw UnknownTypeException * directly from this method! - * - * @param original the original tree model - * @throws UnknownTypeException this exception can be thrown from - * original.isLeaf (...) method call only! - * @return true if node is leaf - */ - public abstract boolean isLeaf ( - TreeModel original, - Object node + * + * @param original the original tree model + * @throws UnknownTypeException this exception can be thrown from + * original.isLeaf (...) method call only! + * @return true if node is leaf + */ + public abstract boolean isLeaf( + TreeModel original, + Object node ) throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java 2016-02-04 02:55:43.102100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,22 +41,18 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; - - /** * Defines data model for tree. * - * @author Jan Jancura + * @author Jan Jancura */ public interface TreeModel extends Model { /** - * Constant for root node. This root node should be used if root node - * does not represent any valuable information and should not be visible in - * tree. + * Constant for root node. This root node should be used if root node does + * not represent any valuable information and should not be visible in tree. */ public static final String ROOT = "Root"; @@ -65,71 +61,71 @@ * * @return the root node of the tree or null */ - public abstract Object getRoot (); - - /** + public abstract Object getRoot(); + + /** * Returns children for given parent on given indexes.

- * This method works in pair with {@link #getChildrenCount}, the to - * parameter is up to the value that is returned from {@link #getChildrenCount}. - * If the list of children varies over time, the implementation code - * needs to pay attention to bounds and check the from and - * to parameters, especially if {@link #getChildrenCount} - * returns Integer.MAX_VALUE. Caching of the children between - * {@link #getChildrenCount} and {@link #getChildren} can be used as well, - * if necessary. - * - * @param parent a parent of returned nodes - * @param from a start index - * @param to a end index + * This method works in pair with {@link #getChildrenCount}, the + * to parameter is up to the value that is returned from + * {@link #getChildrenCount}. If the list of children varies over time, the + * implementation code needs to pay attention to bounds and check the + * from and to parameters, especially if + * {@link #getChildrenCount} returns Integer.MAX_VALUE. Caching + * of the children between {@link #getChildrenCount} and + * {@link #getChildren} can be used as well, if necessary. + * + * @param parent a parent of returned nodes + * @param from a start index + * @param to a end index * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type + * @throws UnknownTypeException if this TreeModel implementation is not able + * to resolve children for given node type * - * @return children for given parent on given indexes + * @return children for given parent on given indexes * @see #getChildrenCount */ - public abstract Object[] getChildren (Object parent, int from, int to) - throws UnknownTypeException; - + public abstract Object[] getChildren(Object parent, int from, int to) + throws UnknownTypeException; + /** * Returns true if node is leaf. - * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * @return true if node is leaf + * + * @throws UnknownTypeException if this TreeModel implementation is not able + * to resolve dchildren for given node type + * @return true if node is leaf */ - public abstract boolean isLeaf (Object node) throws UnknownTypeException; - + public abstract boolean isLeaf(Object node) throws UnknownTypeException; + /** * Returns the number of children for given node.

- * This method works in pair with {@link #getChildren}, which gets - * this returned value (or less) as the to parameter. This method - * is always called before a call to {@link #getChildren}. This method can + * This method works in pair with {@link #getChildren}, which gets this + * returned value (or less) as the to parameter. This method is + * always called before a call to {@link #getChildren}. This method can * return e.g. Integer.MAX_VALUE when all children should be * loaded. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return the children count + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not able + * to resolve children for given node type + * + * @return the children count * @since 1.1 * @see #getChildren */ - public abstract int getChildrenCount (Object node) - throws UnknownTypeException; + public abstract int getChildrenCount(Object node) + throws UnknownTypeException; - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public abstract void addModelListener (ModelListener l); + public abstract void addModelListener(ModelListener l); - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public abstract void removeModelListener (ModelListener l); + public abstract void removeModelListener(ModelListener l); } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/UnknownTypeException.java spi.viewmodel/src/org/netbeans/spi/viewmodel/UnknownTypeException.java --- /home/enrico/Lavoro/releases/spi.viewmodel/src/org/netbeans/spi/viewmodel/UnknownTypeException.java 2016-02-04 02:55:43.103100097 +0100 +++ spi.viewmodel/src/org/netbeans/spi/viewmodel/UnknownTypeException.java 2016-11-03 07:23:29.837689369 +0100 @@ -41,25 +41,24 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.spi.viewmodel; /** - * Used by various data models if data model is asked to resolve node - * of unknown type. + * Used by various data models if data model is asked to resolve node of unknown + * type. * - * @author Jan Jancura + * @author Jan Jancura */ public class UnknownTypeException extends Exception { - private Object node; + private final Object node; /** * Creates a new instance of exception for given node. * * @param node a node of unknown type */ - public UnknownTypeException (Object node) { + public UnknownTypeException(Object node) { this.node = node; } @@ -67,6 +66,5 @@ public String getMessage() { return node.toString() + " [" + node.getClass() + ']'; // NOI18N } - -} +} diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/AsynchronousTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/AsynchronousTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/AsynchronousTest.java 2016-02-04 02:55:43.108100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/AsynchronousTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.beans.BeanInfo; @@ -57,7 +56,6 @@ import org.netbeans.junit.NbTestCase; import org.netbeans.spi.viewmodel.AsynchronousModelFilter; import org.netbeans.spi.viewmodel.AsynchronousModelFilter.CALL; -import org.netbeans.spi.viewmodel.Model; import org.netbeans.spi.viewmodel.Models; import org.netbeans.spi.viewmodel.UnknownTypeException; import org.openide.nodes.Node; @@ -72,22 +70,22 @@ */ public class AsynchronousTest extends NbTestCase { - private static final Set SYNCHRONOUS_METHODS = Collections.unmodifiableSet(new HashSet( - Arrays.asList( "isLeaf", // TreeModel - "getIconBase", "canCopy", "canCut", "canRename", // NodeModel - "clipboardCopy", "clipboardCut", "getPasteTypes", "getIconBaseWithExtension", // ExtendedNodeModel - "isReadOnly" ))); // TableModel + private static final Set SYNCHRONOUS_METHODS = Collections.unmodifiableSet(new HashSet<>( + Arrays.asList("isLeaf", // TreeModel + "getIconBase", "canCopy", "canCut", "canRename", // NodeModel + "clipboardCopy", "clipboardCut", "getPasteTypes", "getIconBaseWithExtension", // ExtendedNodeModel + "isReadOnly"))); // TableModel public AsynchronousTest(String s) { super(s); } public void testDefaultThreadingAccess() throws Exception { - Map defaultRPs = new HashMap(); + Map defaultRPs = new HashMap<>(); defaultRPs.put(CALL.CHILDREN, AsynchronousModelFilter.DEFAULT); defaultRPs.put(CALL.VALUE, AsynchronousModelFilter.DEFAULT); - Map defaultMethodThreads = new HashMap(); + Map defaultMethodThreads = new HashMap<>(); AWTChecker awtc = new AWTChecker(); for (String methodName : SYNCHRONOUS_METHODS) { defaultMethodThreads.put(methodName, awtc); @@ -99,8 +97,8 @@ defaultMethodThreads.put("getChildren", rpc); defaultMethodThreads.put("getChildrenCount", rpc); defaultMethodThreads.put("getValueAt", rpc); - CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[] { "a", "b", "c" }, 2, defaultMethodThreads); - ArrayList l = new ArrayList (); + CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[]{"a", "b", "c"}, 2, defaultMethodThreads); + ArrayList l = new ArrayList(); l.add(cm); l.addAll(Arrays.asList(cm.createColumns())); final Models.CompoundModel mcm = Models.createCompoundModel(l); @@ -111,9 +109,9 @@ public void testSynchronousAccess() throws Exception { AWTChecker awtc = new AWTChecker(); - CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[] { "a", "b", "c" }, 2, new ConstantCheckersMap(awtc)); + CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[]{"a", "b", "c"}, 2, new ConstantCheckersMap(awtc)); SynchronousModelImpl sm = new SynchronousModelImpl(); - ArrayList l = new ArrayList (); + ArrayList l = new ArrayList(); l.add(cm); l.addAll(Arrays.asList(cm.createColumns())); l.add(sm); @@ -125,9 +123,9 @@ public void testDefaultRPAccess() throws Exception { RPChecker rpc = new RPChecker((RequestProcessor) AsynchronousModelFilter.DEFAULT); - CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[] { "a", "b", "c" }, 2, new ConstantCheckersMap(rpc)); + CheckCallingThreadModel cm = new CheckCallingThreadModel(new String[]{"a", "b", "c"}, 2, new ConstantCheckersMap(rpc)); DefaultRPModelImpl drpm = new DefaultRPModelImpl(); - ArrayList l = new ArrayList (); + ArrayList l = new ArrayList(); l.add(cm); l.addAll(Arrays.asList(cm.createColumns())); l.add(drpm); @@ -145,9 +143,10 @@ this.mcm = mcm; } + @Override public void run() { OutlineTable tt = (OutlineTable) Models.createView(mcm); - Node root = tt.getExplorerManager ().getRootContext (); + Node root = tt.getExplorerManager().getRootContext(); root.getChildren().getNodes(); root.getHtmlDisplayName(); @@ -204,6 +203,7 @@ private static final class AWTChecker implements ThreadChecker { + @Override public boolean isInCorrectThread() { return SwingUtilities.isEventDispatchThread(); } @@ -212,12 +212,13 @@ private static final class RPChecker implements ThreadChecker { - private RequestProcessor rp; + private final RequestProcessor rp; public RPChecker(RequestProcessor rp) { this.rp = rp; } + @Override public boolean isInCorrectThread() { return rp.isRequestProcessorThread(); } @@ -232,14 +233,27 @@ this.tc = tc; } - public int size() { return Integer.MAX_VALUE; } + @Override + public int size() { + return Integer.MAX_VALUE; + } - public boolean isEmpty() { return false; } + @Override + public boolean isEmpty() { + return false; + } - public boolean containsKey(Object key) { return true; } + @Override + public boolean containsKey(Object key) { + return true; + } - public boolean containsValue(Object value) { return value == tc; } + @Override + public boolean containsValue(Object value) { + return value == tc; + } + @Override public Object get(Object key) { if (SYNCHRONOUS_METHODS.contains(key)) { return new AWTChecker(); @@ -247,29 +261,50 @@ return tc; } - public Object put(Object key, Object value) { throw new UnsupportedOperationException("N/A"); } + @Override + public Object put(Object key, Object value) { + throw new UnsupportedOperationException("N/A"); + } - public Object remove(Object key) { throw new UnsupportedOperationException("N/A"); } + @Override + public Object remove(Object key) { + throw new UnsupportedOperationException("N/A"); + } - public void putAll(Map t) { throw new UnsupportedOperationException("N/A"); } + @Override + public void putAll(Map t) { + throw new UnsupportedOperationException("N/A"); + } - public void clear() { throw new UnsupportedOperationException("N/A"); } + @Override + public void clear() { + throw new UnsupportedOperationException("N/A"); + } - public Set keySet() { throw new UnsupportedOperationException("N/A"); } + @Override + public Set keySet() { + throw new UnsupportedOperationException("N/A"); + } - public Collection values() { return Collections.singleton(tc); } + @Override + public Collection values() { + return Collections.singleton(tc); + } - public Set entrySet() { throw new UnsupportedOperationException("N/A"); } + @Override + public Set entrySet() { + throw new UnsupportedOperationException("N/A"); + } } private static class CheckCallingThreadModel extends CountedModel { private final Map threadCheckers; - private final Map failedMethods = new HashMap(); + private final Map failedMethods = new HashMap<>(); public CheckCallingThreadModel(String[] children, int depth, - Map threadCheckers) { + Map threadCheckers) { super(children, depth); this.threadCheckers = threadCheckers; } @@ -295,14 +330,16 @@ private static class SynchronousModelImpl implements AsynchronousModelFilter { + @Override public Executor asynchronous(Executor original, CALL asynchCall, Object node) throws UnknownTypeException { return AsynchronousModelFilter.CURRENT_THREAD; } - + } private static class DefaultRPModelImpl implements AsynchronousModelFilter { + @Override public Executor asynchronous(Executor original, CALL asynchCall, Object node) throws UnknownTypeException { return AsynchronousModelFilter.DEFAULT; } @@ -311,12 +348,13 @@ private static class CustomRPModelImpl implements AsynchronousModelFilter { - private Map rps; - + private final Map rps; + public CustomRPModelImpl(Map rps) { this.rps = rps; } + @Override public Executor asynchronous(Executor original, CALL asynchCall, Object node) throws UnknownTypeException { RequestProcessor rp = (RequestProcessor) rps.get(asynchCall); if (rp != null) { diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/BasicTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/BasicTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/BasicTest.java 2016-02-04 02:55:43.108100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/BasicTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.awt.event.ActionEvent; @@ -54,35 +53,40 @@ import java.util.Set; import javax.swing.AbstractAction; import javax.swing.Action; - import javax.swing.SwingUtilities; import org.netbeans.junit.NbTestCase; - -import org.netbeans.spi.viewmodel.*; - +import org.netbeans.spi.viewmodel.ColumnModel; +import org.netbeans.spi.viewmodel.ModelEvent; +import org.netbeans.spi.viewmodel.ModelListener; +import org.netbeans.spi.viewmodel.Models; +import org.netbeans.spi.viewmodel.NodeActionsProvider; +import org.netbeans.spi.viewmodel.NodeModel; +import org.netbeans.spi.viewmodel.TableModel; +import org.netbeans.spi.viewmodel.TreeExpansionModel; +import org.netbeans.spi.viewmodel.TreeModel; +import org.netbeans.spi.viewmodel.UnknownTypeException; import org.openide.nodes.Node; import org.openide.util.Exceptions; import org.openide.util.RequestProcessor; - - /** * Tests the JPDABreakpointEvent.resume() functionality. * * @author Maros Sandor, Jan Jancura */ -public class BasicTest extends NbTestCase { +public class BasicTest extends NbTestCase { - private String helpID = "A test help ID"; // NOI18N + private final String helpID = "A test help ID"; // NOI18N - public BasicTest (String s) { - super (s); + public BasicTest(String s) { + super(s); } static OutlineTable createView(final Models.CompoundModel mcm) { - final OutlineTable[] ttPtr = new OutlineTable[] { null }; + final OutlineTable[] ttPtr = new OutlineTable[]{null}; try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { ttPtr[0] = (OutlineTable) Models.createView(mcm); } @@ -96,65 +100,68 @@ return ttPtr[0]; } - public void testBasic () throws Exception { - ArrayList l = new ArrayList (); - CompoundModel cm = new CompoundModel (); - l.add (cm); + public void testBasic() throws Exception { + ArrayList l = new ArrayList(); + CompoundModel cm = new CompoundModel(); + l.add(cm); Models.CompoundModel mcm = Models.createCompoundModel(l, helpID); OutlineTable tt = createView(mcm); RequestProcessor rp = tt.currentTreeModelRoot.getRootNode().getRequestProcessor(); cm.setRPUsed(rp); - waitFinished (rp); - Node n = tt.getExplorerManager (). - getRootContext (); - checkNode (n, "", rp); - if (cm.exception != null) - cm.exception.printStackTrace (); - assertNull ("Threading problem", cm.exception); + waitFinished(rp); + Node n = tt.getExplorerManager(). + getRootContext(); + checkNode(n, "", rp); + if (cm.exception != null) { + cm.exception.printStackTrace(); + } + assertNull("Threading problem", cm.exception); // TODO: Expansion test does not work - probably written in a bad way... //assertEquals ("nodeExpanded notification number", 3, cm.expandedTest.size ()); //assertEquals ("nodeExpanded ", cm.toBeExpandedTest, cm.expandedTest); assertEquals(n.getValue("propertiesHelpID"), helpID); } - - private void checkNode (Node n, String name, RequestProcessor rp) { + + private void checkNode(Node n, String name, RequestProcessor rp) { // init //assertEquals (null, n.getShortDescription ()); - Node[] ns = n.getChildren ().getNodes (); - waitFinished (rp); - - ns = n.getChildren ().getNodes (); - if (name.length () < 4) { - assertEquals (name, 3, ns.length); - checkNode (ns [0], name + "a", rp); - checkNode (ns [1], name + "b", rp); - checkNode (ns [2], name + "c", rp); - } else - assertEquals (ns.length, 0); - - if (name.length () > 0) { + Node[] ns = n.getChildren().getNodes(); + waitFinished(rp); + + ns = n.getChildren().getNodes(); + if (name.length() < 4) { + assertEquals(name, 3, ns.length); + checkNode(ns[0], name + "a", rp); + checkNode(ns[1], name + "b", rp); + checkNode(ns[2], name + "c", rp); + } else { + assertEquals(ns.length, 0); + } + + if (name.length() > 0) { //assertEquals (name, n.getName ()); - n.getDisplayName (); - String sd = n.getShortDescription (); - n.getActions (false); - waitFinished (rp); - assertEquals (name, n.getDisplayName ()); - assertEquals (name + "WWW", sd); - assertEquals (1, n.getActions (false).length); + n.getDisplayName(); + String sd = n.getShortDescription(); + n.getActions(false); + waitFinished(rp); + assertEquals(name, n.getDisplayName()); + assertEquals(name + "WWW", sd); + assertEquals(1, n.getActions(false).length); } } - static void waitFinished (RequestProcessor rp) { - rp.post (new Runnable () { - public void run () {} - }).waitFinished (); + static void waitFinished(RequestProcessor rp) { + rp.post(new Runnable() { + @Override + public void run() { + } + }).waitFinished(); } - - + public void testMnemonics() throws Exception { - ArrayList l = new ArrayList (); - CompoundModel cm = new CompoundModel (); - l.add (cm); + ArrayList l = new ArrayList(); + CompoundModel cm = new CompoundModel(); + l.add(cm); TestColumnModel tcm = new TestColumnModel(); l.add(tcm); Models.CompoundModel mcm = Models.createCompoundModel(l); @@ -162,284 +169,304 @@ cm.setRPUsed(tt.currentTreeModelRoot.getRootNode().getRequestProcessor()); Node.Property[] columns = tt.columns; assertEquals(2, columns.length); - assertEquals(new Character('e'), columns[1].getValue("ColumnMnemonicCharTTV")); + assertEquals('e', columns[1].getValue("ColumnMnemonicCharTTV")); } - - public static class CompoundModel implements TreeModel, - NodeModel, NodeActionsProvider, TableModel, TreeExpansionModel { - - - private final Set listeners = new HashSet(); - + + public static class CompoundModel implements TreeModel, + NodeModel, NodeActionsProvider, TableModel, TreeExpansionModel { + + private final Set listeners = new HashSet<>(); + private Throwable exception; - private Map callNumbers = new HashMap (); - + private final Map callNumbers = new HashMap(); + private RequestProcessor rp; void setRPUsed(RequestProcessor rp) { this.rp = rp; } - protected synchronized void addCall (String methodName, Object node) { - Map m = (Map) callNumbers.get (methodName); - if (m == null) - callNumbers.put (methodName, m = new HashMap ()); - if (m.containsKey (node)) { + protected synchronized void addCall(String methodName, Object node) { + Map m = (Map) callNumbers.get(methodName); + if (m == null) { + callNumbers.put(methodName, m = new HashMap()); + } + if (m.containsKey(node)) { Object info = m.get(node); if (info instanceof Exception) { - System.err.println ("Second call of " + methodName + " method for the same node " + node); + System.err.println("Second call of " + methodName + " method for the same node " + node); System.err.println("First was at:"); ((Exception) info).printStackTrace(); System.err.println("Second is:"); Thread.dumpStack(); - m.put (node, new Integer(2)); + m.put(node, 2); } else { - int numCalls = ((Integer) info).intValue() + 1; - System.err.println (numCalls+". call of " + methodName + " method for the same node " + node); + int numCalls = ((Integer) info) + 1; + System.err.println(numCalls + ". call of " + methodName + " method for the same node " + node); Thread.dumpStack(); - m.put (node, new Integer(numCalls)); + m.put(node, numCalls); } } else { - m.put (node, new Exception()); + m.put(node, new Exception()); } } - void checkThread () { + void checkThread() { try { - assertTrue ("The right thread", rp.isRequestProcessorThread ()); + assertTrue("The right thread", rp.isRequestProcessorThread()); } catch (Throwable t) { exception = t; } /*; - Thread t = Thread.currentThread (); - if ( t.getClass ().getName ().startsWith - (RequestProcessor.class.getName ()) - ) exception = new Exception (); + Thread t = Thread.currentThread (); + if ( t.getClass ().getName ().startsWith + (RequestProcessor.class.getName ()) + ) exception = new Exception (); */ } // TreeModel ............................................................... - - /** + /** * Returns the root node of the tree or null, if the tree is empty. * * @return the root node of the tree or null */ - public Object getRoot () { + @Override + public Object getRoot() { //addCall ("getRoot", null); return ROOT; } - /** + /** * Returns children for given parent on given indexes. * - * @param parent a parent of returned nodes - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve dchildren for given node type - * - * @return children for given parent on given indexes - */ - public Object[] getChildren (Object parent, int from, int to) - throws UnknownTypeException { - addCall ("getChildren", parent); - if (parent == ROOT) - return new Object[] {"a", "b", "c"}; - if (parent instanceof String) - return new Object[] {parent + "a", parent + "b", parent + "c"}; - throw new UnknownTypeException (parent); + * @param parent a parent of returned nodes + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve dchildren for given node type + * + * @return children for given parent on given indexes + */ + @Override + public Object[] getChildren(Object parent, int from, int to) + throws UnknownTypeException { + addCall("getChildren", parent); + if (parent == ROOT) { + return new Object[]{"a", "b", "c"}; + } + if (parent instanceof String) { + return new Object[]{parent + "a", parent + "b", parent + "c"}; + } + throw new UnknownTypeException(parent); } /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type - * - * @return true if node is leaf - */ - public int getChildrenCount (Object node) throws UnknownTypeException { - addCall ("getChildrenCount", node); - if (node == ROOT) + * + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf + */ + @Override + public int getChildrenCount(Object node) throws UnknownTypeException { + addCall("getChildrenCount", node); + if (node == ROOT) { return 3; - if (node instanceof String) + } + if (node instanceof String) { return 3; - throw new UnknownTypeException (node); + } + throw new UnknownTypeException(node); } /** * Returns true if node is leaf. - * - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve dchildren for given node type - * @return true if node is leaf - */ - public boolean isLeaf (Object node) throws UnknownTypeException { - addCall ("isLeaf", node); - if (node == ROOT) + * + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve dchildren for given node type + * @return true if node is leaf + */ + @Override + public boolean isLeaf(Object node) throws UnknownTypeException { + addCall("isLeaf", node); + if (node == ROOT) { return false; - if (node instanceof String) - return ((String) node).length () > 3; - throw new UnknownTypeException (node); + } + if (node instanceof String) { + return ((String) node).length() > 3; + } + throw new UnknownTypeException(node); } - // NodeModel ........................................................... - /** * Returns display name for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve display name for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve display name for given node type + * @return display name for given node */ - public String getDisplayName (Object node) throws UnknownTypeException { - addCall ("getDisplayName", node); + @Override + public String getDisplayName(Object node) throws UnknownTypeException { + addCall("getDisplayName", node); //checkThread (); - if (node instanceof String) + if (node instanceof String) { return (String) node; - throw new UnknownTypeException (node); + } + throw new UnknownTypeException(node); } /** * Returns tooltip for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve tooltip for given node type - * @return tooltip for given node - */ - public String getShortDescription (Object node) - throws UnknownTypeException { - addCall ("getShortDescription", node); + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve tooltip for given node type + * @return tooltip for given node + */ + @Override + public String getShortDescription(Object node) + throws UnknownTypeException { + addCall("getShortDescription", node); //checkThread (); Short description is called on AWT! How else we could display a tooltip? - if (node == ROOT) + if (node == ROOT) { return ""; - if (node instanceof String) + } + if (node instanceof String) { return node + "WWW"; - throw new UnknownTypeException (node); + } + throw new UnknownTypeException(node); } /** * Returns icon for given node. * - * @throws UnknownTypeException if this NodeModel implementation is not - * able to resolve icon for given node type - * @return icon for given node - */ - public String getIconBase (Object node) - throws UnknownTypeException { - addCall ("getIconBase", node); + * @throws UnknownTypeException if this NodeModel implementation is not + * able to resolve icon for given node type + * @return icon for given node + */ + @Override + public String getIconBase(Object node) + throws UnknownTypeException { + addCall("getIconBase", node); //checkThread (); - if (node instanceof String) + if (node instanceof String) { return node + "XXX"; - throw new UnknownTypeException (node); + } + throw new UnknownTypeException(node); } - // NodeActionsProvider ..................................................... - /** * Performs default action for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ - public void performDefaultAction (Object node) throws UnknownTypeException { + @Override + public void performDefaultAction(Object node) throws UnknownTypeException { } /** * Returns set of actions for given node. * - * @throws UnknownTypeException if this NodeActionsProvider implementation - * is not able to resolve actions for given node type - * @return display name for given node + * @throws UnknownTypeException if this NodeActionsProvider + * implementation is not able to resolve actions for given node type + * @return display name for given node */ - public Action[] getActions (Object node) throws UnknownTypeException { + @Override + public Action[] getActions(Object node) throws UnknownTypeException { //checkThread (); - if (node == ROOT) - return new Action [0]; - if (node instanceof String) - return new Action[] { - new AbstractAction ((String) node) { - public void actionPerformed (ActionEvent ev) { - + if (node == ROOT) { + return new Action[0]; + } + if (node instanceof String) { + return new Action[]{ + new AbstractAction((String) node) { + @Override + public void actionPerformed(ActionEvent ev) { + } - }, - }; - throw new UnknownTypeException (node); + },}; + } + throw new UnknownTypeException(node); } - // ColumnsModel ............................................................ - /** - * Returns sorted array of + * Returns sorted array of * {@link org.netbeans.spi.viewmodel.ColumnModel}s. * * @return sorted array of ColumnModels */ - public ColumnModel[] getColumns () { - return new ColumnModel [0]; + public ColumnModel[] getColumns() { + return new ColumnModel[0]; } - // TableModel .............................................................. - - public Object getValueAt (Object node, String columnID) throws - UnknownTypeException { - addCall ("getValueAt", node); - checkThread (); + @Override + public Object getValueAt(Object node, String columnID) throws + UnknownTypeException { + addCall("getValueAt", node); + checkThread(); if (node instanceof String) { - if (columnID.equals ("1")) + if (columnID.equals("1")) { return node + "1"; - if (columnID.equals ("2")) + } + if (columnID.equals("2")) { return node + "2"; + } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - public boolean isReadOnly (Object node, String columnID) throws - UnknownTypeException { - addCall ("isReadOnly", node); - checkThread (); + @Override + public boolean isReadOnly(Object node, String columnID) throws + UnknownTypeException { + addCall("isReadOnly", node); + checkThread(); if (node instanceof String) { - if (columnID.equals ("1")) + if (columnID.equals("1")) { return true; - if (columnID.equals ("2")) + } + if (columnID.equals("2")) { return true; + } } - throw new UnknownTypeException (node); + throw new UnknownTypeException(node); } - public void setValueAt (Object node, String columnID, Object value) throws - UnknownTypeException { - throw new UnknownTypeException (node); + @Override + public void setValueAt(Object node, String columnID, Object value) throws + UnknownTypeException { + throw new UnknownTypeException(node); } - // TreeExpansionModel ...................................................... + private final Set toBeExpandedTest = new HashSet(); + private final Set expandedTest = new HashSet(); - private Set toBeExpandedTest = new HashSet (); - private Set expandedTest = new HashSet (); { - toBeExpandedTest.add (getRoot()); - toBeExpandedTest.add ("a"); - toBeExpandedTest.add ("ab"); - toBeExpandedTest.add ("abc"); + toBeExpandedTest.add(getRoot()); + toBeExpandedTest.add("a"); + toBeExpandedTest.add("ab"); + toBeExpandedTest.add("abc"); } - + /** * Defines default state (collapsed, expanded) of given node. * * @param node a node * @return default state (collapsed, expanded) of given node */ - public boolean isExpanded (Object node) throws UnknownTypeException { - if (node instanceof String) - return toBeExpandedTest.contains (node); - throw new UnknownTypeException (node); + @Override + public boolean isExpanded(Object node) throws UnknownTypeException { + if (node instanceof String) { + return toBeExpandedTest.contains(node); + } + throw new UnknownTypeException(node); } /** @@ -447,12 +474,13 @@ * * @param node a expanded node */ - public void nodeExpanded (Object node) { - if (!toBeExpandedTest.contains (node)) { + @Override + public void nodeExpanded(Object node) { + if (!toBeExpandedTest.contains(node)) { System.err.println("This node should not be expanded: " + node); Thread.dumpStack(); } - expandedTest.add (node); + expandedTest.add(node); } /** @@ -460,72 +488,78 @@ * * @param node a collapsed node */ - public void nodeCollapsed (Object node) { + @Override + public void nodeCollapsed(Object node) { System.err.println("nodeCollapsed " + node); Thread.dumpStack(); } - // listeners ............................................................... - - /** + /** * Registers given listener. - * + * * @param l the listener to add */ - public void addModelListener (ModelListener l) { + @Override + public void addModelListener(ModelListener l) { synchronized (listeners) { - listeners.add (l); + listeners.add(l); } } - /** + /** * Unregisters given listener. * * @param l the listener to remove */ - public void removeModelListener (ModelListener l) { + @Override + public void removeModelListener(ModelListener l) { synchronized (listeners) { - listeners.remove (l); + listeners.remove(l); } } - - public void fire () { + + public void fire() { List v; synchronized (listeners) { - v = new ArrayList(listeners); + v = new ArrayList<>(listeners); + } + int i, k = v.size(); + for (i = 0; i < k; i++) { + ((ModelListener) v.get(i)).modelChanged(null); } - int i, k = v.size (); - for (i = 0; i < k; i++) - ((ModelListener) v.get (i)).modelChanged (null); } - - public void fire (ModelEvent event) { + + public void fire(ModelEvent event) { List v; synchronized (listeners) { - v = new ArrayList(listeners); + v = new ArrayList<>(listeners); } - int i, k = v.size (); + int i, k = v.size(); for (i = 0; i < k; i++) { - ((ModelListener) v.get (i)).modelChanged (event); + ((ModelListener) v.get(i)).modelChanged(event); } } } - + private static class TestColumnModel extends ColumnModel { + + @Override public Class getType() { return String.class; } + @Override public String getDisplayName() { return "Test"; } @Override public Character getDisplayedMnemonic() { - return new Character('e'); + return 'e'; } + @Override public String getID() { return "xx"; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/CountedModel.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/CountedModel.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/CountedModel.java 2016-02-04 02:55:43.109100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/CountedModel.java 2016-11-03 07:23:29.833689329 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.awt.datatransfer.Transferable; @@ -76,11 +75,11 @@ private final String[] rootChildren; private final int depth; - private final Map cachedChildren = new HashMap(); - private final List listeners = new ArrayList(); - private final Map selectedNodes = new HashMap(); - private final Map> changedValues = new HashMap>(); - private final Set countedCalls = new HashSet(); + private final Map cachedChildren = new HashMap<>(); + private final List listeners = new ArrayList<>(); + private final Map selectedNodes = new HashMap<>(); + private final Map> changedValues = new HashMap<>(); + private final Set countedCalls = new HashSet<>(); public CountedModel(String[] children, int depth) { rootChildren = children; @@ -88,17 +87,18 @@ } public ColumnModel[] createColumns() { - return new ColumnModel[] { + return new ColumnModel[]{ new CountedColumn(COLUMN_LC), new CountedColumn(COLUMN_UC), - new CountedColumn(COLUMN_BYTES), - }; + new CountedColumn(COLUMN_BYTES),}; } + @Override public Object getRoot() { return ROOT; } + @Override public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException { //System.err.println("\n\nget CHILDREN("+this+", on "+parent); //System.err.println(" counted calls before = "+getCountedCalls("getChildren", parent)+"\n\n"); @@ -119,19 +119,22 @@ } } + @Override public boolean isLeaf(Object node) throws UnknownTypeException { countCall("isLeaf", node); String s = (String) node; int d = 0; - for (int i = 0; (i = s.indexOf('/', i+1)) > 0; d++) ; + for (int i = 0; (i = s.indexOf('/', i + 1)) > 0; d++) ; return d >= depth; } + @Override public int getChildrenCount(Object node) throws UnknownTypeException { countCall("getChildrenCount", node); return rootChildren.length; } + @Override public void addModelListener(ModelListener l) { //System.err.println(this+".addModelListener("+l+")"); //Thread.dumpStack(); @@ -141,6 +144,7 @@ //System.err.println(" listeners = "+listeners); } + @Override public void removeModelListener(ModelListener l) { //System.err.println(this+".removeModelListener("+l+")"); //Thread.dumpStack(); @@ -150,80 +154,112 @@ //System.err.println(" listeners = "+listeners); } + @Override public boolean canRename(Object node) throws UnknownTypeException { countCall("canRename", node); return true; } + @Override public boolean canCopy(Object node) throws UnknownTypeException { countCall("canCopy", node); return true; } + @Override public boolean canCut(Object node) throws UnknownTypeException { countCall("canCut", node); return true; } + @Override public Transferable clipboardCopy(Object node) throws IOException, UnknownTypeException { countCall("clipboardCopy", node); return null; } + @Override public Transferable clipboardCut(Object node) throws IOException, UnknownTypeException { countCall("clipboardCut", node); return null; } + @Override public PasteType[] getPasteTypes(Object node, Transferable t) throws UnknownTypeException { countCall("getPasteTypes", node, t); - return new PasteType[] {}; + return new PasteType[]{}; } + @Override public void setName(Object node, String name) throws UnknownTypeException { countCall("setName", node, name); } + @Override public String getIconBaseWithExtension(Object node) throws UnknownTypeException { countCall("getIconBaseWithExtension", node); return null; } + @Override public String getDisplayName(Object node) throws UnknownTypeException { countCall("getDisplayName", node); return node.toString().replace('/', '-'); } + @Override public String getIconBase(Object node) throws UnknownTypeException { countCall("getIconBase", node); return null; } + @Override public String getShortDescription(Object node) throws UnknownTypeException { countCall("getShortDescription", node); return node.toString() + " => " + node.toString().replace('/', '-'); } + @Override public boolean isCheckable(Object node) throws UnknownTypeException { countCall("isCheckable", node); return true; } + @Override public boolean isCheckEnabled(Object node) throws UnknownTypeException { countCall("isCheckEnabled", node); return true; } + @Override public Boolean isSelected(Object node) throws UnknownTypeException { countCall("isSelected", node); return selectedNodes.containsKey(node) && selectedNodes.get(node); } + @Override public void setSelected(Object node, Boolean selected) throws UnknownTypeException { countCall("setSelected", node); selectedNodes.put(node, selected); } + @Override + public void setSelected(Object... nodes) throws UnknownTypeException { + countCall("setSelected", nodes); + for (Object node : nodes) { + selectedNodes.put(node, true); + } + } + + @Override + public void setUnselected(Object... nodes) throws UnknownTypeException { + countCall("setUnselected", nodes); + for (Object node : nodes) { + selectedNodes.put(node, false); + } + } + + @Override public Object getValueAt(Object node, String columnID) throws UnknownTypeException { countCall("getValueAt", node, columnID); Map values = changedValues.get(node); @@ -242,19 +278,21 @@ if (columnID.equals(COLUMN_BYTES)) { return Arrays.toString(node.toString().getBytes()); } - throw new UnknownTypeException(node+".getValue("+columnID+")"); + throw new UnknownTypeException(node + ".getValue(" + columnID + ")"); } + @Override public boolean isReadOnly(Object node, String columnID) throws UnknownTypeException { countCall("isReadOnly", node, columnID); return false; } + @Override public void setValueAt(Object node, String columnID, Object value) throws UnknownTypeException { countCall("setValueAt", node, columnID, value); Map values = changedValues.get(node); if (values == null) { - values = new HashMap(); + values = new HashMap<>(); changedValues.put(node, values); } values.put(columnID, value); @@ -290,13 +328,13 @@ } public CountedCall[] getCountedCalls(String methodName) { - List ccs = new ArrayList(); + List ccs = new ArrayList<>(); for (CountedCall cc : countedCalls) { if (methodName.equals(cc.methodName)) { ccs.add(cc); } } - return ccs.toArray(new CountedCall[] {}); + return ccs.toArray(new CountedCall[]{}); } public CountedCall getCountedCalls(String methodName, Object... params) { @@ -310,14 +348,14 @@ @Override public String toString() { - return this.getClass().getSimpleName()+"("+Arrays.toString(rootChildren)+")"; + return this.getClass().getSimpleName() + "(" + Arrays.toString(rootChildren) + ")"; } static class CountedCall { private final String methodName; private final Object[] params; - private final List calls = new ArrayList(); + private final List calls = new ArrayList<>(); CountedCall(String methodName, Object... params) { this.methodName = methodName; @@ -334,7 +372,7 @@ } Throwable[] callStacks() { - return calls.toArray(new Throwable[] {}); + return calls.toArray(new Throwable[]{}); } @Override @@ -359,23 +397,24 @@ @Override public String toString() { - String str = "CountedCall("+methodName+", "+Arrays.toString(params)+") called "+numCalls()+" times.\n"; + String str = "CountedCall(" + methodName + ", " + Arrays.toString(params) + ") called " + numCalls() + " times.\n"; for (int i = 0; i < calls.size(); i++) { Throwable t = calls.get(i); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.flush(); - str = str + " " + (i+1) + ".: " + sw.toString() + "\n"; + str = str + " " + (i + 1) + ".: " + sw.toString() + "\n"; } return str; } - private static class Counter extends Exception {} + private static class Counter extends Exception { + } } static class CountedColumn extends ColumnModel { - + private final String id; public CountedColumn(String id) { @@ -389,13 +428,13 @@ @Override public String getDisplayName() { - return "Column "+id; + return "Column " + id; } @Override public Class getType() { return String.class; } - + } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/HyperModelSingleAccessTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/HyperModelSingleAccessTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/HyperModelSingleAccessTest.java 2016-02-04 02:55:43.110100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/HyperModelSingleAccessTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.ArrayList; @@ -53,7 +52,7 @@ /** * Tests that hyper compund models are accessed just once when events are fired. - * + * * @author Martin Entlicher */ public class HyperModelSingleAccessTest extends NbTestCase { @@ -62,33 +61,33 @@ private CountedModel cm2; private Node root; - public HyperModelSingleAccessTest (String s) { - super (s); + public HyperModelSingleAccessTest(String s) { + super(s); } private void setUpTwoModels() { - cm1 = new CountedModel(new String[] { "1", "2", "3" }, 2); - cm2 = new CountedModel(new String[] { "a", "b", "c" }, 2); + cm1 = new CountedModel(new String[]{"1", "2", "3"}, 2); + cm2 = new CountedModel(new String[]{"a", "b", "c"}, 2); - ArrayList l = new ArrayList (); + ArrayList l = new ArrayList(); l.add(cm1); l.addAll(Arrays.asList(cm1.createColumns())); Models.CompoundModel mcm1 = Models.createCompoundModel(l); - l = new ArrayList (); + l = new ArrayList(); l.add(cm2); l.addAll(Arrays.asList(cm2.createColumns())); Models.CompoundModel mcm2 = Models.createCompoundModel(l); - l = new ArrayList (); + l = new ArrayList(); l.add(mcm1); l.add(mcm2); Models.CompoundModel mcmh = Models.createCompoundModel(l); OutlineTable tt = BasicTest.createView(mcmh); - + RequestProcessor rp = tt.currentTreeModelRoot.getRootNode().getRequestProcessor(); - BasicTest.waitFinished (rp); + BasicTest.waitFinished(rp); - root = tt.getExplorerManager ().getRootContext (); + root = tt.getExplorerManager().getRootContext(); } public void testChildren() { @@ -96,41 +95,48 @@ root.getChildren().getNodes(); try { Thread.sleep(1000); - } catch (InterruptedException iex) {} - assertEquals("Children refreshed too much: "+cm1.getMaxCountedCall(), 1, cm1.getMaxCountedCall().numCalls()); - assertEquals("Children refreshed too much: "+cm2.getMaxCountedCall(), 1, cm2.getMaxCountedCall().numCalls()); + } catch (InterruptedException iex) { + } + assertEquals("Children refreshed too much: " + cm1.getMaxCountedCall(), 1, cm1.getMaxCountedCall().numCalls()); + assertEquals("Children refreshed too much: " + cm2.getMaxCountedCall(), 1, cm2.getMaxCountedCall().numCalls()); cm1.fireModelChangeEvent(new ModelEvent.TreeChanged(TreeModel.ROOT)); try { Thread.sleep(500); - } catch (InterruptedException iex) {} + } catch (InterruptedException iex) { + } root.getChildren().getNodes(); try { Thread.sleep(500); - } catch (InterruptedException iex) {} - assertEquals("Children refreshed too much: "+cm1.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); - assertEquals("Children refreshed too much: "+cm2.getCountedCalls("getChildren", TreeModel.ROOT), 1, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + } catch (InterruptedException iex) { + } + assertEquals("Children refreshed too much: " + cm1.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + assertEquals("Children refreshed too much: " + cm2.getCountedCalls("getChildren", TreeModel.ROOT), 1, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); //System.err.println("\n\n\nNEW REFRESH of "+cm2+" ... \n\n\n"); cm2.fireModelChangeEvent(new ModelEvent.TreeChanged(TreeModel.ROOT)); try { Thread.sleep(500); - } catch (InterruptedException iex) {} + } catch (InterruptedException iex) { + } root.getChildren().getNodes(); try { Thread.sleep(500); - } catch (InterruptedException iex) {} - assertEquals("Children refreshed too much: "+cm1.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); - assertEquals("Children refreshed too much: "+cm2.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + } catch (InterruptedException iex) { + } + assertEquals("Children refreshed too much: " + cm1.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + assertEquals("Children refreshed too much: " + cm2.getCountedCalls("getChildren", TreeModel.ROOT), 2, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); cm1.fireModelChangeEvent(new ModelEvent.TreeChanged(TreeModel.ROOT)); cm2.fireModelChangeEvent(new ModelEvent.TreeChanged(TreeModel.ROOT)); try { Thread.sleep(500); - } catch (InterruptedException iex) {} + } catch (InterruptedException iex) { + } root.getChildren().getNodes(); try { Thread.sleep(500); - } catch (InterruptedException iex) {} - assertEquals("Children refreshed too much: "+cm1.getCountedCalls("getChildren", TreeModel.ROOT), 3, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); - assertEquals("Children refreshed too much: "+cm2.getCountedCalls("getChildren", TreeModel.ROOT), 3, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + } catch (InterruptedException iex) { + } + assertEquals("Children refreshed too much: " + cm1.getCountedCalls("getChildren", TreeModel.ROOT), 3, cm1.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); + assertEquals("Children refreshed too much: " + cm2.getCountedCalls("getChildren", TreeModel.ROOT), 3, cm2.getCountedCalls("getChildren", TreeModel.ROOT).numCalls()); } - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ModelEventTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ModelEventTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ModelEventTest.java 2016-02-04 02:55:43.110100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ModelEventTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -41,84 +41,87 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Vector; import javax.swing.SwingUtilities; - import org.netbeans.junit.NbTestCase; - -import org.netbeans.spi.viewmodel.*; - +import org.netbeans.spi.viewmodel.ModelEvent; +import org.netbeans.spi.viewmodel.Models; +import org.netbeans.spi.viewmodel.UnknownTypeException; import org.openide.nodes.Node; import org.openide.nodes.NodeListener; - - /** * */ -public class ModelEventTest extends NbTestCase implements NodeListener { +public class ModelEventTest extends NbTestCase implements NodeListener { BasicTest.CompoundModel cm; Node n; volatile Object event; Vector propEvents = new Vector(); - public ModelEventTest (String s) { - super (s); + public ModelEventTest(String s) { + super(s); } - + @Override protected void setUp() throws Exception { super.setUp(); - ArrayList l = new ArrayList (); - cm = new CompoundModel1 (); - l.add (cm); - OutlineTable tt = BasicTest.createView(Models.createCompoundModel (l)); - BasicTest.waitFinished (tt.currentTreeModelRoot.getRootNode().getRequestProcessor()); - n = tt.getExplorerManager ().getRootContext (); + ArrayList l = new ArrayList(); + cm = new CompoundModel1(); + l.add(cm); + OutlineTable tt = BasicTest.createView(Models.createCompoundModel(l)); + BasicTest.waitFinished(tt.currentTreeModelRoot.getRootNode().getRequestProcessor()); + n = tt.getExplorerManager().getRootContext(); n.addNodeListener(this); } + @Override public void childrenAdded(org.openide.nodes.NodeMemberEvent ev) { assertNull("Already fired", event); event = ev; } + @Override public void childrenRemoved(org.openide.nodes.NodeMemberEvent ev) { assertNull("Already fired", event); event = ev; } + @Override public void childrenReordered(org.openide.nodes.NodeReorderEvent ev) { assertNull("Already fired", event); event = ev; } + @Override public void nodeDestroyed(org.openide.nodes.NodeEvent ev) { assertNull("Already fired", event); event = ev; } + @Override public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent) { propEvents.add(propertyChangeEvent.getPropertyName()); /* - System.out.println("propertyChangeEvent = "+propertyChangeEvent); - assertNull("Already fired", event); - event = propertyChangeEvent; + System.out.println("propertyChangeEvent = "+propertyChangeEvent); + assertNull("Already fired", event); + event = propertyChangeEvent; */ } - + public void testDisplayName() { ModelEvent e = new ModelEvent.NodeChanged(this, "Root", ModelEvent.NodeChanged.DISPLAY_NAME_MASK); cm.fire(e); try { - SwingUtilities.invokeAndWait (new Runnable () { - public void run () {} + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + } }); } catch (InterruptedException iex) { fail(iex.toString()); @@ -133,8 +136,10 @@ ModelEvent e = new ModelEvent.NodeChanged(this, "Root", ModelEvent.NodeChanged.ICON_MASK); cm.fire(e); try { - SwingUtilities.invokeAndWait (new Runnable () { - public void run () {} + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + } }); } catch (InterruptedException iex) { fail(iex.toString()); @@ -148,8 +153,10 @@ ModelEvent e = new ModelEvent.NodeChanged(this, "Root", ModelEvent.NodeChanged.SHORT_DESCRIPTION_MASK); cm.fire(e); try { - SwingUtilities.invokeAndWait (new Runnable () { - public void run () {} + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + } }); } catch (InterruptedException iex) { fail(iex.toString()); @@ -162,76 +169,75 @@ public void testChildren() { n.getChildren().getNodes(); /* - ModelEvent e = new ModelEvent.NodeChanged(this, "Root", ModelEvent.NodeChanged.CHILDREN_MASK); - cm.fire(e); - try { - SwingUtilities.invokeAndWait (new Runnable () { - public void run () {} - }); - } catch (InterruptedException iex) { - fail(iex.toString()); - } catch (InvocationTargetException itex) { - fail(itex.toString()); - } - //assertTrue("Short Description was not fired", propEvents.contains(Node.PROP_)); - assertNotNull("Children were not fired", this.event); + ModelEvent e = new ModelEvent.NodeChanged(this, "Root", ModelEvent.NodeChanged.CHILDREN_MASK); + cm.fire(e); + try { + SwingUtilities.invokeAndWait (new Runnable () { + public void run () {} + }); + } catch (InterruptedException iex) { + fail(iex.toString()); + } catch (InvocationTargetException itex) { + fail(itex.toString()); + } + //assertTrue("Short Description was not fired", propEvents.contains(Node.PROP_)); + assertNotNull("Children were not fired", this.event); */ } public final class CompoundModel1 extends BasicTest.CompoundModel { - + int dn = 0; int ib = 0; int sd = 0; int cc = 0; - + @Override - protected void addCall (String methodName, Object node) { + protected void addCall(String methodName, Object node) { // Ignore multiple calls } // init .................................................................... - @Override - public String getDisplayName (Object node) throws UnknownTypeException { + public String getDisplayName(Object node) throws UnknownTypeException { String dns = super.getDisplayName(node); dns += (dn++); return dns; } - + @Override - public String getIconBase (Object node) throws UnknownTypeException { + public String getIconBase(Object node) throws UnknownTypeException { String ibs = super.getIconBase(node); ibs += (ib++); return ibs; } - + @Override - public String getShortDescription (Object node) throws UnknownTypeException { + public String getShortDescription(Object node) throws UnknownTypeException { String sds = super.getShortDescription(node); sds += (sd++); return sds; } - + /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf */ @Override - public synchronized int getChildrenCount (Object node) throws UnknownTypeException { - return super.getChildrenCount (node) + (cc++); + public synchronized int getChildrenCount(Object node) throws UnknownTypeException { + return super.getChildrenCount(node) + (cc++); } - + @Override - public Object[] getChildren (Object parent, int from, int to) throws UnknownTypeException { + public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException { //System.err.println("CompoundModel1.getChildren("+parent+", "+from+", "+to+")"); //Thread.dumpStack(); - addCall ("getChildren", parent); + addCall("getChildren", parent); Object[] ch = new Object[3 + (cc - 1)]; if (parent == ROOT) { for (int i = 0; i < ch.length; i++) { @@ -247,7 +253,7 @@ } return ch; } - throw new UnknownTypeException (parent); + throw new UnknownTypeException(parent); } } } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/MultiFiringTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/MultiFiringTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/MultiFiringTest.java 2016-02-04 02:55:43.110100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/MultiFiringTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.ArrayList; @@ -64,8 +63,8 @@ private BasicTest.CompoundModel m; private volatile int changed = 0; - public MultiFiringTest (String s) { - super (s); + public MultiFiringTest(String s) { + super(s); } @Override @@ -75,61 +74,96 @@ } private void setUpBasicModel() { - ArrayList l = new ArrayList (); - m = new BasicTest.CompoundModel (); - l.add (m); - Models.CompoundModel cm = Models.createCompoundModel (l); + ArrayList l = new ArrayList(); + m = new BasicTest.CompoundModel(); + l.add(m); + Models.CompoundModel cm = Models.createCompoundModel(l); //BasicTest.waitFinished (tt.currentTreeModelRoot.getRootNode().getRequestProcessor()); //n = tt.getExplorerManager ().getRootContext (); cm.addModelListener(this); } private void setUpComplexModel() { - ArrayList l = new ArrayList (); - m = new BasicTest.CompoundModel (); - l.add (m); - l.add (new NodeModelFilter() { + ArrayList l = new ArrayList(); + m = new BasicTest.CompoundModel(); + l.add(m); + l.add(new NodeModelFilter() { + @Override public String getDisplayName(NodeModel original, Object node) throws UnknownTypeException { return original.getDisplayName(node); } + + @Override public String getIconBase(NodeModel original, Object node) throws UnknownTypeException { return original.getIconBase(node); } + + @Override public String getShortDescription(NodeModel original, Object node) throws UnknownTypeException { return original.getShortDescription(node); } - public void addModelListener(ModelListener l) {} - public void removeModelListener(ModelListener l) {} + + @Override + public void addModelListener(ModelListener l) { + } + + @Override + public void removeModelListener(ModelListener l) { + } }); - l.add (new TreeModelFilter() { + l.add(new TreeModelFilter() { + @Override public Object getRoot(TreeModel original) { return original.getRoot(); } + + @Override public Object[] getChildren(TreeModel original, Object parent, int from, int to) throws UnknownTypeException { return original.getChildren(parent, from, to); } + + @Override public int getChildrenCount(TreeModel original, Object node) throws UnknownTypeException { return Integer.MAX_VALUE; } + + @Override public boolean isLeaf(TreeModel original, Object node) throws UnknownTypeException { return original.isLeaf(node); } - public void addModelListener(ModelListener l) {} - public void removeModelListener(ModelListener l) {} + + @Override + public void addModelListener(ModelListener l) { + } + + @Override + public void removeModelListener(ModelListener l) { + } }); - l.add (new TableModelFilter() { + l.add(new TableModelFilter() { + @Override public Object getValueAt(TableModel original, Object node, String columnID) throws UnknownTypeException { return original.getValueAt(node, columnID); } + + @Override public boolean isReadOnly(TableModel original, Object node, String columnID) throws UnknownTypeException { return original.isReadOnly(node, columnID); } + + @Override public void setValueAt(TableModel original, Object node, String columnID, Object value) throws UnknownTypeException { } - public void addModelListener(ModelListener l) {} - public void removeModelListener(ModelListener l) {} + + @Override + public void addModelListener(ModelListener l) { + } + + @Override + public void removeModelListener(ModelListener l) { + } }); - Models.CompoundModel cm = Models.createCompoundModel (l); + Models.CompoundModel cm = Models.createCompoundModel(l); cm.addModelListener(this); } @@ -141,7 +175,7 @@ public void testBasicModelTableSingleFiring() { setUpBasicModel(); - m.fire(new ModelEvent.TableValueChanged(m, "a", null)); + m.fire(new ModelEvent.TableValueChanged(m, "a")); assertEquals("Firing occurred", 1, changed); } @@ -159,7 +193,7 @@ public void testComplexModelTableSingleFiring() { setUpComplexModel(); - m.fire(new ModelEvent.TableValueChanged(m, "a", null)); + m.fire(new ModelEvent.TableValueChanged(m, "a")); assertEquals("Firing occurred", 1, changed); } @@ -169,6 +203,7 @@ assertEquals("Firing occurred", 1, changed); } + @Override public void modelChanged(ModelEvent event) { changed++; } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ReorderableTreeModelTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ReorderableTreeModelTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ReorderableTreeModelTest.java 2016-02-04 02:55:43.111100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/ReorderableTreeModelTest.java 2016-11-03 07:23:29.832689319 +0100 @@ -39,19 +39,16 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.util.ArrayList; import java.util.Arrays; import org.netbeans.junit.NbTestCase; import org.netbeans.spi.viewmodel.Model; -import org.netbeans.spi.viewmodel.ModelEvent; import org.netbeans.spi.viewmodel.ModelListener; import org.netbeans.spi.viewmodel.Models; import org.netbeans.spi.viewmodel.NodeModel; import org.netbeans.spi.viewmodel.ReorderableTreeModel; -import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.UnknownTypeException; import org.openide.nodes.Index; import org.openide.nodes.Node; @@ -59,29 +56,29 @@ /** * Tests that reorderable model produces node with Index implementation - * + * * @author Martin Entlicher */ public class ReorderableTreeModelTest extends NbTestCase { private Node root; - public ReorderableTreeModelTest (String s) { - super (s); + public ReorderableTreeModelTest(String s) { + super(s); } private void setUpModel() { Model m = new ReorderableModelImpl(); - ArrayList l = new ArrayList (); + ArrayList l = new ArrayList(); l.add(m); Models.CompoundModel mcm = Models.createCompoundModel(l); OutlineTable tt = BasicTest.createView(mcm); - + RequestProcessor rp = tt.currentTreeModelRoot.getRootNode().getRequestProcessor(); - BasicTest.waitFinished (rp); + BasicTest.waitFinished(rp); - root = tt.getExplorerManager ().getRootContext (); + root = tt.getExplorerManager().getRootContext(); } public void testChildrenReorder() { @@ -94,16 +91,16 @@ assertEquals(2, ch1.length); indexImpl = ch1[1].getLookup().lookup(Index.class); - assertNull(ch1[1]+ " must not provide Index, it is not reordeable!", indexImpl); + assertNull(ch1[1] + " must not provide Index, it is not reordeable!", indexImpl); indexImpl = ch1[0].getLookup().lookup(Index.class); - assertNotNull(ch1[0]+ " must provide Index, it is reordeable!", indexImpl); + assertNotNull(ch1[0] + " must provide Index, it is reordeable!", indexImpl); - indexImpl.reorder(new int[] { 2, 0, 1, 4, 3 }); + indexImpl.reorder(new int[]{2, 0, 1, 4, 3}); // => "3", "1", "2", "5", "4" - String[] reorderedNames = new String[] { "2", "3", "1", "5", "4" }; + String[] reorderedNames = new String[]{"2", "3", "1", "5", "4"}; Node[] reorderedNodes = ch1[0].getChildren().getNodes(); assertEquals(reorderedNames.length, reorderedNodes.length); - String nodes = "Nodes = "+Arrays.toString(reorderedNodes); + String nodes = "Nodes = " + Arrays.toString(reorderedNodes); for (int i = 0; i < reorderedNodes.length; i++) { assertEquals(nodes, reorderedNames[i], reorderedNodes[i].getDisplayName()); } @@ -114,20 +111,22 @@ private static final String CAN_REORDER = "canReorder"; private static final String CAN_NOT_REORDER = "canNotReorder"; - private final String[] childrenReordered = new String[] { "1", "2", "3", "4", "5" }; + private final String[] childrenReordered = new String[]{"1", "2", "3", "4", "5"}; + @Override public boolean canReorder(Object parent) throws UnknownTypeException { return /*ROOT == parent ||*/ CAN_REORDER.equals(parent); } + @Override public void reorder(Object parent, int[] perm) throws UnknownTypeException { //System.err.println("reorder("+parent+", "+Arrays.toString(perm)+")"); //Thread.dumpStack(); - if (!(/*ROOT == parent ||*/ CAN_REORDER.equals(parent))) { - throw new IllegalStateException("reorder called on "+parent); + if (!(/*ROOT == parent ||*/CAN_REORDER.equals(parent))) { + throw new IllegalStateException("reorder called on " + parent); } if (perm.length != childrenReordered.length) { - throw new IllegalArgumentException("Permutation of length "+perm.length+", but have "+childrenReordered.length+" children."); + throw new IllegalArgumentException("Permutation of length " + perm.length + ", but have " + childrenReordered.length + " children."); } checkPermutation(perm); String[] ch = childrenReordered.clone(); @@ -143,60 +142,69 @@ for (int i = 0; i < max; i++) { int p = permutation[i]; if (p >= max) { - throw new IllegalArgumentException("Permutation "+Arrays.toString(permutation)+" is not a valid permutation, it contains element "+p+", which is bigger than the length of the permutation."); + throw new IllegalArgumentException("Permutation " + Arrays.toString(permutation) + " is not a valid permutation, it contains element " + p + ", which is bigger than the length of the permutation."); } if (p < 0) { - throw new IllegalArgumentException("Permutation "+Arrays.toString(permutation)+" is not a valid permutation, it contains element "+p+", which is negative."); + throw new IllegalArgumentException("Permutation " + Arrays.toString(permutation) + " is not a valid permutation, it contains element " + p + ", which is negative."); } if (check[p] != 0) { - throw new IllegalArgumentException("Permutation "+Arrays.toString(permutation)+" is not a valid permutation, it contains element "+p+" twice or more times."); + throw new IllegalArgumentException("Permutation " + Arrays.toString(permutation) + " is not a valid permutation, it contains element " + p + " twice or more times."); } check[p] = 1; } } + @Override public Object getRoot() { return ROOT; } + @Override public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException { if (ROOT == parent) { - return new String[] { CAN_REORDER, CAN_NOT_REORDER }; + return new String[]{CAN_REORDER, CAN_NOT_REORDER}; } else if (CAN_REORDER.equals(parent)) { return childrenReordered; } else if (CAN_NOT_REORDER.equals(parent)) { - return new String[] { "a", "b", "c", "d", "e" }; + return new String[]{"a", "b", "c", "d", "e"}; } else { - return new Object[] {}; + return new Object[]{}; } } + @Override public boolean isLeaf(Object node) throws UnknownTypeException { return ((String) node).length() == 1; } + @Override public int getChildrenCount(Object node) throws UnknownTypeException { return Integer.MAX_VALUE; } + @Override public void addModelListener(ModelListener l) { } + @Override public void removeModelListener(ModelListener l) { } + @Override public String getDisplayName(Object node) throws UnknownTypeException { return (String) node; } + @Override public String getIconBase(Object node) throws UnknownTypeException { return null; } + @Override public String getShortDescription(Object node) throws UnknownTypeException { - return node+" of "+getClass().getSimpleName(); + return node + " of " + getClass().getSimpleName(); } - + } - + } diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/TableRendererTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/TableRendererTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/TableRendererTest.java 2016-02-04 02:55:43.112100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/TableRendererTest.java 2016-11-03 07:23:29.832689319 +0100 @@ -39,7 +39,6 @@ * * Portions Copyrighted 2009 Sun Microsystems, Inc. */ - package org.netbeans.modules.viewmodel; import java.awt.BorderLayout; @@ -52,7 +51,6 @@ import java.util.ArrayList; import java.util.EventObject; import java.util.List; -import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JTextField; @@ -87,11 +85,10 @@ super(name); } - private void setUpModel() { Model mr = new TableRendererModelImpl(); - ArrayList l = new ArrayList (); + ArrayList l = new ArrayList(); l.add(mr); l.add(new ColumnModelImpl("col1")); l.add(new ColumnModelImpl("col2")); @@ -99,7 +96,7 @@ OutlineTable tt = BasicTest.createView(mcm); RequestProcessor rp = tt.currentTreeModelRoot.getRootNode().getRequestProcessor(); - BasicTest.waitFinished (rp); + BasicTest.waitFinished(rp); this.ot = tt; //root = tt.getExplorerManager ().getRootContext (); @@ -116,18 +113,18 @@ f.setSize(600, 500); f.setVisible(true); //while (f.isVisible()) { - try { - Thread.sleep(333); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - } + try { + Thread.sleep(333); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } //} - - System.out.println("table rows = "+t.getRowCount()); + + System.out.println("table rows = " + t.getRowCount()); TableCellRenderer tcr = t.getCellRenderer(0, 0); Component c = tcr.getTableCellRendererComponent(t, null, true, true, 0, 0); //System.err.println("c = "+c); - assertTrue("Renderer component = "+c, c instanceof RendererComponent); + assertTrue("Renderer component = " + c, c instanceof RendererComponent); assertEquals("Renderer of 0:DN", ((RendererComponent) c).getText()); tcr = t.getCellRenderer(0, 1); @@ -140,11 +137,11 @@ tcr = t.getCellRenderer(1, 0); c = tcr.getTableCellRendererComponent(t, null, true, true, 1, 0); - assertFalse("Renderer component = "+c, c instanceof RendererComponent); + assertFalse("Renderer component = " + c, c instanceof RendererComponent); tcr = t.getCellRenderer(1, 1); c = tcr.getTableCellRendererComponent(t, null, true, true, 1, 1); - assertFalse("Renderer component = "+c, c instanceof RendererComponent); + assertFalse("Renderer component = " + c, c instanceof RendererComponent); tcr = t.getCellRenderer(2, 1); c = tcr.getTableCellRendererComponent(t, null, true, true, 2, 1); @@ -170,67 +167,67 @@ f.setSize(600, 500); f.setVisible(true); //while (f.isVisible()) { - try { - Thread.sleep(333); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - } + try { + Thread.sleep(333); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } //} - System.out.println("table rows = "+t.getRowCount()); + System.out.println("table rows = " + t.getRowCount()); TableCellEditor tce = t.getCellEditor(0, 0); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 0))); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 0))); //assertTrue(t+"is not editable.", t.isCellEditable(0, 0)); Component c = tce.getTableCellEditorComponent(t, null, true, 0, 0); //System.err.println("c = "+c); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 0:DN", ((EditorComponent) c).getText()); tce = t.getCellEditor(0, 1); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 1))); - assertTrue(t+"is not editable.", t.isCellEditable(0, 1)); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 1))); + assertTrue(t + "is not editable.", t.isCellEditable(0, 1)); c = tce.getTableCellEditorComponent(t, null, true, 0, 1); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 0:col1", ((EditorComponent) c).getText()); tce = t.getCellEditor(0, 2); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 2))); - assertTrue(t+"is not editable.", t.isCellEditable(0, 2)); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 2))); + assertTrue(t + "is not editable.", t.isCellEditable(0, 2)); c = tce.getTableCellEditorComponent(t, null, true, 0, 2); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 0:col2", ((EditorComponent) c).getText()); tce = t.getCellEditor(1, 0); - assertFalse(tce+"is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 0))); - assertFalse(t+"is editable.", t.isCellEditable(1, 0)); + assertFalse(tce + "is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 0))); + assertFalse(t + "is editable.", t.isCellEditable(1, 0)); c = tce.getTableCellEditorComponent(t, null, true, 1, 0); - assertFalse("Editor component = "+c, c instanceof EditorComponent); + assertFalse("Editor component = " + c, c instanceof EditorComponent); tce = t.getCellEditor(1, 2); - assertFalse(tce+"is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 2))); - assertFalse(t+"is editable.", t.isCellEditable(1, 2)); + assertFalse(tce + "is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 2))); + assertFalse(t + "is editable.", t.isCellEditable(1, 2)); c = tce.getTableCellEditorComponent(t, null, true, 1, 2); - assertFalse("Editor component = "+c, c instanceof EditorComponent); + assertFalse("Editor component = " + c, c instanceof EditorComponent); tce = t.getCellEditor(3, 1); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 3, 1))); - assertTrue(t+"is not editable.", t.isCellEditable(3, 1)); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 3, 1))); + assertTrue(t + "is not editable.", t.isCellEditable(3, 1)); c = tce.getTableCellEditorComponent(t, null, true, 3, 1); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 3:col1", ((EditorComponent) c).getText()); tce = t.getCellEditor(6, 0); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 6, 0))); - assertTrue(t+"is not editable.", t.isCellEditable(6, 0)); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 6, 0))); + assertTrue(t + "is not editable.", t.isCellEditable(6, 0)); c = tce.getTableCellEditorComponent(t, null, true, 6, 0); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 6:DN", ((EditorComponent) c).getText()); tce = t.getCellEditor(9, 2); - assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 9, 2))); - assertTrue(t+"is not editable.", t.isCellEditable(9, 2)); + assertTrue(tce + "is not editable.", tce.isCellEditable(getMouseClickAt(t, 9, 2))); + assertTrue(t + "is not editable.", t.isCellEditable(9, 2)); c = tce.getTableCellEditorComponent(t, null, true, 9, 2); - assertTrue("Editor component = "+c, c instanceof EditorComponent); + assertTrue("Editor component = " + c, c instanceof EditorComponent); assertEquals("Editor of 9:col2", ((EditorComponent) c).getText()); } @@ -245,31 +242,31 @@ f.setSize(600, 500); f.setVisible(true); //while (f.isVisible()) { - try { - Thread.sleep(333); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - } + try { + Thread.sleep(333); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } //} MouseEvent event = getMouseClickAt(t, 0, 0); String tipText = t.getToolTipText(event); JToolTip tip = t.createToolTip(); tip.setTipText(tipText); - assertTrue("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent); + assertTrue("Bad ToolTip class: " + tip, tip instanceof RendererComponent.ToolTipComponent); assertEquals("ToolTip for Renderer of 0:DN", tip.getTipText()); event = getMouseClickAt(t, 1, 1); tipText = t.getToolTipText(event); tip = t.createToolTip(); tip.setTipText(tipText); - assertFalse("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent); + assertFalse("Bad ToolTip class: " + tip, tip instanceof RendererComponent.ToolTipComponent); event = getMouseClickAt(t, 2, 2); tipText = t.getToolTipText(event); tip = t.createToolTip(); tip.setTipText(tipText); - assertTrue("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent); + assertTrue("Bad ToolTip class: " + tip, tip instanceof RendererComponent.ToolTipComponent); assertEquals("ToolTip for Renderer of 2:col2", tip.getTipText()); } @@ -281,7 +278,7 @@ private static class RendererComponent extends JLabel { - private String s; + private final String s; public RendererComponent(String s) { super(s); @@ -290,7 +287,7 @@ @Override public String getToolTipText() { - return "ToolTip for "+s; + return "ToolTip for " + s; } @Override @@ -299,15 +296,15 @@ } private static class ToolTipComponent extends JToolTip { - + } } private static final class CellRendererImpl implements TableCellRenderer { - private Object node; - private String columnID; + private final Object node; + private final String columnID; public CellRendererImpl(Object node, String columnID) { this.node = node; @@ -321,15 +318,16 @@ public String getColumnID() { return columnID; } - + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - return new RendererComponent("Renderer of "+node.toString()+":"+columnID); + return new RendererComponent("Renderer of " + node.toString() + ":" + columnID); } - + } private static class EditorComponent extends JTextField { + public EditorComponent(String s) { super(s); } @@ -337,8 +335,8 @@ private static final class CellEditorImpl implements TableCellEditor { - private Object node; - private String columnID; + private final Object node; + private final String columnID; public CellEditorImpl(Object node, String columnID) { this.node = node; @@ -355,7 +353,7 @@ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - return new EditorComponent("Editor of "+node.toString()+":"+columnID); + return new EditorComponent("Editor of " + node.toString() + ":" + columnID); } @Override @@ -374,8 +372,8 @@ int col = table.columnAtPoint(p); Rectangle rect = table.getCellRect(row, col, true); p.translate(-rect.x, -rect.y); - System.out.println("isCellEditable("+anEvent+")"); - System.out.println("Point "+p+"in rectangle "+rect); + System.out.println("isCellEditable(" + anEvent + ")"); + System.out.println("Point " + p + "in rectangle " + rect); if (p.x > rect.width - 24) { // last 24 points not editable return false; @@ -411,10 +409,9 @@ private static final class TableRendererModelImpl implements TableRendererModel, TreeModel, TableModel, ExtendedNodeModel { - private List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); // TableRendererModel - @Override public boolean canRenderCell(Object node, String columnID) throws UnknownTypeException { return Integer.parseInt((String) node) % 2 == 0; // Use this renderer for even rows only. @@ -423,7 +420,7 @@ @Override public TableCellRenderer getCellRenderer(Object node, String columnID) throws UnknownTypeException { if (!(Integer.parseInt((String) node) % 2 == 0)) { - throw new IllegalStateException("Trying to get renderer even if we can not provide it node = "+node); + throw new IllegalStateException("Trying to get renderer even if we can not provide it node = " + node); } return new CellRendererImpl(node, columnID); } @@ -436,7 +433,7 @@ @Override public TableCellEditor getCellEditor(Object node, String columnID) throws UnknownTypeException { if (!(Integer.parseInt((String) node) % 3 == 0)) { - throw new IllegalStateException("Trying to get editor even if we can not provide it node = "+node); + throw new IllegalStateException("Trying to get editor even if we can not provide it node = " + node); } return new CellEditorImpl(node, columnID); } @@ -452,7 +449,6 @@ } // TreeModel - @Override public Object getRoot() { return ROOT; @@ -461,7 +457,7 @@ @Override public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException { if (ROOT.equals(parent)) { - return new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + return new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; } throw new UnknownTypeException(parent); } @@ -477,7 +473,6 @@ } // TableModel - @Override public Object getValueAt(Object node, String columnID) throws UnknownTypeException { return ((String) node) + " " + columnID; @@ -505,7 +500,7 @@ @Override public String getShortDescription(Object node) throws UnknownTypeException { - return "Short Description of "+node; + return "Short Description of " + node; } @Override @@ -535,7 +530,7 @@ @Override public PasteType[] getPasteTypes(Object node, Transferable t) throws UnknownTypeException { - return new PasteType[] {}; + return new PasteType[]{}; } @Override @@ -547,12 +542,12 @@ public String getIconBaseWithExtension(Object node) throws UnknownTypeException { return null; } - + } private static class ColumnModelImpl extends ColumnModel { - private String id; + private final String id; ColumnModelImpl(String id) { this.id = id; @@ -565,7 +560,7 @@ @Override public String getDisplayName() { - return "Test Column "+id; + return "Test Column " + id; } @Override diff -ruN /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/YardaTest.java spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/YardaTest.java --- /home/enrico/Lavoro/releases/spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/YardaTest.java 2016-02-04 02:55:43.112100097 +0100 +++ spi.viewmodel/test/unit/src/org/netbeans/modules/viewmodel/YardaTest.java 2016-11-03 07:23:29.833689329 +0100 @@ -41,79 +41,77 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.viewmodel; import java.util.ArrayList; - import java.util.List; import org.netbeans.junit.NbTestCase; - -import org.netbeans.spi.viewmodel.*; - +import org.netbeans.spi.viewmodel.ModelEvent; +import org.netbeans.spi.viewmodel.Models; +import org.netbeans.spi.viewmodel.UnknownTypeException; import org.openide.nodes.Node; - - /** * Tests the JPDABreakpointEvent.resume() functionality. * * @author Maros Sandor, Jan Jancura */ -public class YardaTest extends NbTestCase { - +public class YardaTest extends NbTestCase { - public YardaTest (String s) { - super (s); + public YardaTest(String s) { + super(s); } - public void testSubsequentRequest () throws Exception { - doColeasingSimulation (0); + public void testSubsequentRequest() throws Exception { + doColeasingSimulation(0); } - public void testColeasingOfRequests () throws Exception { - doColeasingSimulation (1); + + public void testColeasingOfRequests() throws Exception { + doColeasingSimulation(1); } - - private void doColeasingSimulation (int type) throws Exception { - ArrayList l = new ArrayList (); - CompoundModel1 cm1 = new CompoundModel1 (); - l.add (cm1); - OutlineTable tt = BasicTest.createView(Models.createCompoundModel (l)); - Node n = tt.getExplorerManager (). - getRootContext (); + + private void doColeasingSimulation(int type) throws Exception { + ArrayList l = new ArrayList(); + CompoundModel1 cm1 = new CompoundModel1(); + l.add(cm1); + OutlineTable tt = BasicTest.createView(Models.createCompoundModel(l)); + Node n = tt.getExplorerManager(). + getRootContext(); synchronized (cm1) { - n.getChildren ().getNodes (); - cm1.wait (1000); + n.getChildren().getNodes(); + cm1.wait(1000); if (cm1.count > 1) { cm1.stackTraces.toString(); } - assertEquals ("Model caled", 1, cm1.count); - cm1.fire (new ModelEvent.TreeChanged(cm1.getRoot())); - n.getChildren ().getNodes (); - + assertEquals("Model caled", 1, cm1.count); + cm1.fire(new ModelEvent.TreeChanged(cm1.getRoot())); + n.getChildren().getNodes(); + if (type == 1) { - cm1.fire (new ModelEvent.TreeChanged(cm1.getRoot())); - n.getChildren ().getNodes (); + cm1.fire(new ModelEvent.TreeChanged(cm1.getRoot())); + n.getChildren().getNodes(); } - - cm1.notifyAll (); + + cm1.notifyAll(); } Thread.yield(); Thread.sleep(1000); - tt.currentTreeModelRoot.getRootNode().getRequestProcessor().post (new Runnable () { - public void run () {} - }).waitFinished (); + tt.currentTreeModelRoot.getRootNode().getRequestProcessor().post(new Runnable() { + @Override + public void run() { + } + }).waitFinished(); //System.err.println("Child = "+n.getChildren().getNodes()[0]); // TODO: Broken, there's a Please wait... node! - assertEquals ("Computation has finished in RP", 3, n.getChildren ().getNodes ().length); + assertEquals("Computation has finished in RP", 3, n.getChildren().getNodes().length); if (cm1.count > 2) { cm1.stackTraces.toString(); } - assertEquals ("Model caled", 2, cm1.count); + assertEquals("Model caled", 2, cm1.count); } - + public final class CompoundModel1 extends BasicTest.CompoundModel { - + public int count = 0; public List stackTraces = new ArrayList() { @@ -121,7 +119,7 @@ public String toString() { for (int i = 0; i < size(); i++) { Throwable o = get(i); - System.err.println((i+1)+" call:"); + System.err.println((i + 1) + " call:"); o.printStackTrace(); } return ""; @@ -129,31 +127,29 @@ }; - // init .................................................................... - /** * Returns number of children for given node. - * - * @param node the parent node - * @throws UnknownTypeException if this TreeModel implementation is not - * able to resolve children for given node type * - * @return true if node is leaf + * @param node the parent node + * @throws UnknownTypeException if this TreeModel implementation is not + * able to resolve children for given node type + * + * @return true if node is leaf */ @Override - public synchronized int getChildrenCount (Object node) throws UnknownTypeException { + public synchronized int getChildrenCount(Object node) throws UnknownTypeException { count++; stackTraces.add(new Exception().fillInStackTrace()); - notify (); + notify(); /* - try { - wait (2000); // We must not wait here, otherwise we get a "Please wait..." node - } catch (InterruptedException ex) { - ex.printStackTrace(); - } + try { + wait (2000); // We must not wait here, otherwise we get a "Please wait..." node + } catch (InterruptedException ex) { + ex.printStackTrace(); + } */ - return super.getChildrenCount (node); + return super.getChildrenCount(node); } @Override @@ -166,6 +162,5 @@ return false; } - } }