1 19 20 package org.netbeans.modules.scripting.php.dbginterface; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import org.netbeans.modules.scripting.php.dbginterface.api.VariableNode; 25 import org.netbeans.spi.viewmodel.NodeModel; 26 import org.netbeans.spi.viewmodel.NodeModelFilter; 27 import org.netbeans.spi.viewmodel.TableModel; 28 import org.netbeans.spi.viewmodel.TableModelFilter; 29 import org.netbeans.spi.viewmodel.TreeModel; 30 import org.netbeans.spi.viewmodel.TreeModelFilter; 31 import org.netbeans.spi.viewmodel.UnknownTypeException; 32 33 37 public class VariablesModelFilter extends ModelSupport 38 implements TreeModelFilter, TableModelFilter, NodeModelFilter { 39 40 private static boolean [] filterMap = { 42 true, true, true, true, true, true, false }; 50 51 public static boolean [] getFilterSettings() { 52 boolean [] copy = new boolean [filterMap.length]; 54 System.arraycopy(filterMap, 0, copy, 0, filterMap.length); 55 return copy; 56 } 57 58 public static void setFilters(final boolean [] newFilterMap) { 59 filterMap = new boolean [filterMap.length]; 61 System.arraycopy(newFilterMap, 0, filterMap, 0, Math.min(filterMap.length, newFilterMap.length)); 62 } 63 64 public Object getRoot(TreeModel original) { 68 return original.getRoot(); 69 } 70 71 public Object [] getChildren(TreeModel original, Object parent, int from, int to) throws UnknownTypeException { 72 Object [] originalChildren = original.getChildren(parent, from, to); 73 List <Object > filteredChildren = new ArrayList <Object >(originalChildren.length); 74 for(int i = 0; i < originalChildren.length; i++) { 75 if(originalChildren[i] != null) { 76 if(originalChildren[i] instanceof VariableNode) { 77 if(filterMap[((VariableNode) originalChildren[i]).getType()]) { 78 filteredChildren.add(originalChildren[i]); 79 } 80 } else { 81 filteredChildren.add(originalChildren[i]); 82 } 83 } 84 } 85 return filteredChildren.toArray(new Object [filteredChildren.size()]); 86 } 87 88 public boolean isLeaf(TreeModel original, Object node) throws UnknownTypeException { 89 return original.isLeaf(node); 90 } 91 92 public int getChildrenCount(TreeModel original, Object node) throws UnknownTypeException { 93 return original.getChildrenCount(node); 94 } 95 96 public Object getValueAt(TableModel original, Object node, String columnID) throws UnknownTypeException { 100 return original.getValueAt(node, columnID); 101 } 102 103 public boolean isReadOnly(TableModel original, Object node, String columnID) throws UnknownTypeException { 104 return original.isReadOnly(node, columnID); 105 } 106 107 public void setValueAt(TableModel original, Object node, String columnID, Object value) throws UnknownTypeException { 108 original.setValueAt(node, columnID, value); 109 } 110 111 public String getDisplayName(NodeModel original, Object node) throws UnknownTypeException { 115 return original.getDisplayName(node); 116 } 117 118 public String getIconBase(NodeModel original, Object node) throws UnknownTypeException { 119 return original.getIconBase(node); 120 } 121 122 public String getShortDescription(NodeModel original, Object node) throws UnknownTypeException { 123 return original.getShortDescription(node); 124 } 125 } 126 | Popular Tags |