org.openide.nodes.Node.Property Java Examples
The following examples show how to use
org.openide.nodes.Node.Property.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanNodeBug21285.java From netbeans with Apache License 2.0 | 6 votes |
/** Regression test to reproduce bug #21858. */ public void testBadBean() throws Exception { BeanNode bn = new BeanNode( new BadBeanHidden() ); Node.PropertySet ps[] = bn.getPropertySets(); try { for (int i = 0; i < ps.length; i++) { Set<Property> props = new HashSet<Property>( Arrays.asList(ps[i].getProperties())); } } catch ( NullPointerException e ) { assertTrue( "The NullPointerException thrown", false ); } assertTrue( true ); }
Example #2
Source File: OutlineView.java From netbeans with Apache License 2.0 | 6 votes |
/** * Remove the first property column for properties named <code>name</code> * @param name The <i>programmatic</i> name of the Property, i.e. the * return value of <code>Property.getName()</code> * * @return true if a column was removed * @since 6.25 */ public final boolean removePropertyColumn(String name) { Parameters.notNull("name", name); //NOI18N Property[] props = rowModel.getProperties(); List<Property> nue = new LinkedList<Property>(Arrays.asList(props)); boolean found = false; for (Iterator<Property> i=nue.iterator(); i.hasNext();) { Property p = i.next(); if (name.equals(p.getName())) { found = true; i.remove(); break; } } if (found) { props = nue.toArray(new Property[props.length - 1]); setProperties (props, false); } return found; }
Example #3
Source File: OutlineOperatorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testNodes() throws Exception { TopComponentOperator tcoVariables = new TopComponentOperator("Variables"); TopComponentOperator tcoBreakpoints = new TopComponentOperator("Breakpoints"); TopComponentOperator tcoWatches = new TopComponentOperator( Bundle.getString("org.netbeans.modules.debugger.ui.views.Bundle", "CTL_Watches_view")); OutlineOperator lrOO = new OutlineOperator(tcoWatches); lrOO.getRootNode("test").expand(); lrOO.getRootNode("test", 1).expand(); OutlineNode lrNode = lrOO.getRootNode("test", 2); lrNode.expand(); OutlineNode lrNewNode = new OutlineNode(lrNode, "test"); new Action(null, Bundle.getStringTrimmed("org.netbeans.modules.debugger.jpda.ui.actions.Bundle", "CTL_CreateVariable")).performPopup(lrNewNode); OutlineNode lrFixedWatch = lrOO.getRootNode("test"); int lnNodeRow = lrOO.getLocationForPath(lrNewNode.getTreePath()).y; int lnFixedRow = lrOO.getLocationForPath(lrFixedWatch.getTreePath()).y; Property lrNodeProperty = (Property) lrOO.getValueAt(lnNodeRow, 2); Property lrFixedProperty = (Property) lrOO.getValueAt(lnFixedRow, 2); assertTrue("Values of the original node and the fixed watch do not match!", lrNodeProperty.getValue().toString().equals(lrFixedProperty.getValue().toString())); }
Example #4
Source File: TableSheet.java From netbeans with Apache License 2.0 | 6 votes |
/** Allows to subclasses initialize table * @param t */ private void initializeTable() { table.setModel(tableModel); tableCell = new TableSheetCell(tableModel); table.setDefaultRenderer(Node.Property.class, tableCell); table.setDefaultEditor(Node.Property.class, tableCell); table.getTableHeader().setDefaultRenderer(tableCell); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getTableHeader().setReorderingAllowed(false); if (UIManager.getColor("Panel.background") != null) { // NOI18N table.setBackground(UIManager.getColor("Panel.background")); // NOI18N table.setSelectionBackground(UIManager.getColor("Panel.background")); // NOI18N } }
Example #5
Source File: SheetTableModel.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { if (columnIndex == 0) { throw new IllegalArgumentException("Cannot set property names."); } try { FeatureDescriptor fd = model.getFeatureDescriptor(rowIndex); if (fd instanceof Property) { Property p = (Property) fd; p.setValue(aValue); } else { throw new IllegalArgumentException( "Index " + Integer.toString(rowIndex) + Integer.toString(columnIndex) + " does not represent a property. " ); //NOI18N } } catch (IllegalAccessException iae) { Logger.getLogger(SheetTableModel.class.getName()).log(Level.WARNING, null, iae); } catch (java.lang.reflect.InvocationTargetException ite) { Logger.getLogger(SheetTableModel.class.getName()).log(Level.WARNING, null, ite); } }
Example #6
Source File: SheetTableModel.java From netbeans with Apache License 2.0 | 6 votes |
@Override public boolean isCellEditable(int rowIndex, int columnIndex) { //if column is 0, it's the property name - can't edit that if (columnIndex == 0) { return false; } if (columnIndex == 1) { FeatureDescriptor fd = model.getFeatureDescriptor(rowIndex); //no worries, editCellAt() will expand it and return before //this method is called if (fd instanceof PropertySet) { return false; } return ((Property) fd).canWrite(); } throw new IllegalArgumentException( "Illegal row/column: " + Integer.toString(rowIndex) + Integer.toString(columnIndex) ); //NOI18N }
Example #7
Source File: PropertiesActionTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testEnableOnNotNullProperties () throws Exception { PropertySet [] s = new PropertySet [] { new PropertySet () { public Property[] getProperties () { Property p = new Property<String>(String.class) { public boolean canRead () { return true; } public boolean canWrite () { return true; } public String getValue() { return null; } public void setValue(String val) {} }; return new Property [] { p }; } } }; testEnable (s); }
Example #8
Source File: TreeTableViewMemoryLeak2Test.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void run() { // create panel (implementing ExplorerManager.Provider) with TTV MyPanel panel = new MyPanel(); panel.setLayout(new GridLayout(1, 2)); ttv = new TreeTableView(); ttv.setProperties(new Property[]{fakeProp}); fakeProp = null; panel.add(ttv); // set root and keep the same root panel.setExplorerManagerRoot(root); ttv.expandNode(root); //cleare property and root ttv.setProperties(new Property[0]); panel.setExplorerManagerRoot(Node.EMPTY); }
Example #9
Source File: SheetTable.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected Transferable createTransferable(JComponent c) { if (c instanceof SheetTable) { SheetTable table = (SheetTable) c; FeatureDescriptor fd = table.getSelection(); if (fd == null) { return null; } String res = fd.getDisplayName(); if (fd instanceof Node.Property) { Node.Property prop = (Node.Property) fd; res += ("\t" + PropUtils.getPropertyEditor(prop).getAsText()); } return new SheetTableTransferable(res); } return null; }
Example #10
Source File: SheetTable.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent ae) { int i = getSelectedRow(); if (i != -1) { FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(i); if (fd instanceof Property) { java.beans.PropertyEditor ped = PropUtils.getPropertyEditor((Property) fd); System.err.println(ped.getClass().getName()); } else { System.err.println("PropertySets - no editor"); //NOI18N } } else { System.err.println("No selection"); //NOI18N } }
Example #11
Source File: PropUtils.java From netbeans with Apache License 2.0 | 6 votes |
@Override public int compare(Node.Property l, Node.Property r) { Class t1 = l.getValueType(); Class t2 = r.getValueType(); String s1 = (t1 != null) ? t1.getName() : ""; //NOI18N String s2 = (t2 != null) ? t2.getName() : ""; //NOI18N int s = s1.compareToIgnoreCase(s2); if (s != 0) { return s; } s1 = l.getDisplayName(); s2 = r.getDisplayName(); return s1.compareToIgnoreCase(s2); }
Example #12
Source File: OutlineTable.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { TableColumn[] columns = (TableColumn[]) evt.getNewValue(); if (columns == null) { if (currentTreeModelRoot != null && !isSettingModelUp) { // Refreshing a set up table, need to save the column widths saveWidths(); } tableColumns = null; } else if (!ignoreCreateDefaultColumnsFromModel) { // Update the columns after they are reset: Property[] properties = treeTable.getProperties(); if (properties != null) { updateTableColumns(properties, columns); } } }
Example #13
Source File: NodeTableModel.java From netbeans with Apache License 2.0 | 5 votes |
/** * If true, column is currently used for sorting * @param Index to the array of all properties (the column may not be visible) */ boolean isSortingColumnEx(int column) { Property p = allPropertyColumns[column].getProperty(); Object o = p.getValue(ATTR_SORTING_COLUMN); if ((o != null) && o instanceof Boolean) { return ((Boolean) o).booleanValue(); } return false; }
Example #14
Source File: OutlineTable.java From netbeans with Apache License 2.0 | 5 votes |
private int getColumnOrder(Node.Property column) { Integer order = (Integer) column.getValue(Column.PROP_ORDER_NUMBER); if (order == null) { return -1; } else { return order.intValue(); } }
Example #15
Source File: PropertySetModelImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void setComparator(Comparator<Node.Property> c) { if (c != comparator) { firePendingChange(true); comparator = c; fds.clear(); init(); fireChange(true); } }
Example #16
Source File: ModelProperty.java From netbeans with Apache License 2.0 | 5 votes |
/** Used in case of 1 element array */ static Property findProperty(Node n, String name) throws NullPointerException { PropertySet[] ps = n.getPropertySets(); for (int j = 0; j < ps.length; j++) { Property p = findProperty(ps[j], name); if (p != null) { return p; } } return null; }
Example #17
Source File: NodeTableModel.java From netbeans with Apache License 2.0 | 5 votes |
boolean isSortOrderDescending() { if (sortColumn == -1) { return false; } Property p = allPropertyColumns[sortColumn].getProperty(); Object o = p.getValue(ATTR_DESCENDING_ORDER); if ((o != null) && o instanceof Boolean) { return ((Boolean) o).booleanValue(); } return false; }
Example #18
Source File: BrokenDataShadow.java From netbeans with Apache License 2.0 | 5 votes |
/** Modifies the sheet set to contain name of property and name of * original object. */ private void modifySheetSet (Sheet.Set ss) { Property p = ss.remove (DataObject.PROP_NAME); if (p != null) { p = new PropertySupport.Name (this); ss.put (p); p = new Name (); ss.put (p); } }
Example #19
Source File: TableSheetCell.java From netbeans with Apache License 2.0 | 5 votes |
private FocusedPropertyPanel getRenderer(Property p, Node n) { TTVEnvBridge bridge = TTVEnvBridge.getInstance(this); bridge.setCurrentBeans(new Node[] { n }); if (renderer == null) { renderer = new FocusedPropertyPanel(p, PropertyPanel.PREF_READ_ONLY | PropertyPanel.PREF_TABLEUI); renderer.putClientProperty("beanBridgeIdentifier", this); //NOI18N } renderer.setProperty(p); renderer.putClientProperty("flat", Boolean.TRUE); return renderer; }
Example #20
Source File: NodeTableModel.java From netbeans with Apache License 2.0 | 5 votes |
/** * If true, column property should be comparable - allows sorting * @param column Index to the array of all properties */ boolean isComparableColumnEx(int column) { Property p = allPropertyColumns[column].getProperty(); Object o = p.getValue(ATTR_COMPARABLE_COLUMN); if ((o != null) && o instanceof Boolean) { return ((Boolean) o).booleanValue(); } return false; }
Example #21
Source File: TableSheetCell.java From netbeans with Apache License 2.0 | 5 votes |
private PropertyPanel getEditor(Property p, Node n) { int prefs = PropertyPanel.PREF_TABLEUI; TTVEnvBridge bridge = TTVEnvBridge.getInstance(this); //workaround for issue 38132 - use env bridge to pass the //node to propertypanel so it can call PropertyEnv.setBeans() //with it. The sad thing is almost nobody uses PropertyEnv.getBeans(), //but we have to do it for all cases. bridge.setCurrentBeans(new Node[] { n }); if (editor == null) { editor = new PropertyPanel(p, prefs); editor.putClientProperty("flat", Boolean.TRUE); //NOI18N editor.putClientProperty("beanBridgeIdentifier", this); //NOI18N editor.setProperty(p); return editor; } editor.setProperty(p); //Okay, the property panel has already grabbed the beans, clear //them so no references are held. return editor; }
Example #22
Source File: PinWatchValueProvider.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({"# {0} - the watched expression", "PropEditDisplayName=Value of {0}"}) private Action getPropertyEditorAction(final PropertyEditor pe, final ObjectVariable var, final ValueListeners vl, final String expression) { Property property = new PropertySupport.ReadWrite(expression, null, Bundle.PropEditDisplayName(expression), Bundle.PropEditDisplayName(expression)) { @Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return var; } @Override public void setValue(final Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { RP.post(new Runnable() { @Override public void run() { try { vl.watchEv.setFromMirrorObject(val); vl.watchEv.setEvaluated(null); updateValueFrom(vl.watchEv); } catch (InvalidObjectException ex) { NotifyDescriptor msg = new NotifyDescriptor.Message(ex.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(msg); } } }); vl.value = getEvaluatingText(); vl.valueOnly = null; } @Override public PropertyEditor getPropertyEditor() { return pe; } }; PropertyPanel pp = new PropertyPanel(property); return pp.getActionMap().get("invokeCustomEditor"); // NOI18N }
Example #23
Source File: PropUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Just a helper method which delegates to shallBeRDVEnabled(Node.Property). */ static boolean shallBeRDVEnabled(FeatureDescriptor fd) { if ((fd != null) && fd instanceof Node.Property) { return shallBeRDVEnabled((Node.Property) fd); } return false; }
Example #24
Source File: ReusablePropertyModel.java From netbeans with Apache License 2.0 | 5 votes |
public PropertyEditor getPropertyEditor() { Node.Property p = getProperty(); // #52179: PropUtils.isExternallyEdited(p) - don't affect just // externally edited properties or their current changes will be lost // due to the firing PropertyChangeEvents to theirs UI counterpart return PropUtils.getPropertyEditor(p, !PropUtils.isExternallyEdited(p)); }
Example #25
Source File: SheetCell.java From netbeans with Apache License 2.0 | 5 votes |
private PropertyPanel getEditor(Property p, Node n) { int prefs = PropertyPanel.PREF_TABLEUI; TTVEnvBridge bridge = TTVEnvBridge.getInstance(this); //workaround for issue 38132 - use env bridge to pass the //node to propertypanel so it can call PropertyEnv.setBeans() //with it. The sad thing is almost nobody uses PropertyEnv.getBeans(), //but we have to do it for all cases. bridge.setCurrentBeans(new Node[] {n}); if (editor == null) { editor = new PropertyPanel(p, prefs); editor.putClientProperty("flat", Boolean.TRUE); //NOI18N editor.putClientProperty("beanBridgeIdentifier", this); //NOI18N //Intentionally set the property again so it will look up the //bean bridge editor.setProperty(p); return editor; } editor.setProperty(p); //Okay, the property panel has already grabbed the beans, clear //them so no references are held. return editor; }
Example #26
Source File: SheetCell.java From netbeans with Apache License 2.0 | 5 votes |
private FocusedPropertyPanel getRenderer (Property p, Node n) { TTVEnvBridge bridge = TTVEnvBridge.getInstance(this); bridge.setCurrentBeans(new Node[] {n}); if (renderer == null) { renderer = new FocusedPropertyPanel(p, PropertyPanel.PREF_READ_ONLY | PropertyPanel.PREF_TABLEUI); renderer.putClientProperty("beanBridgeIdentifier", this); //NOI18N } renderer.setProperty(p); renderer.putClientProperty("flat",Boolean.TRUE); return renderer; }
Example #27
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
private boolean openCustomEditor(ActionEvent e) { if (getSelectedRowCount() != 1 || getSelectedColumnCount() != 1) { return false; } int row = getSelectedRow(); if (row < 0) return false; int column = getSelectedColumn(); if (column < 0) return false; Object o = getValueAt(row, column); if (!(o instanceof Node.Property)) { return false; } Node.Property p = (Node.Property) o; if (!Boolean.TRUE.equals(p.getValue("suppressCustomEditor"))) { //NOI18N PropertyPanel panel = new PropertyPanel(p); @SuppressWarnings("deprecation") PropertyEditor ed = panel.getPropertyEditor(); if ((ed != null) && ed.supportsCustomEditor()) { Action act = panel.getActionMap().get("invokeCustomEditor"); //NOI18N if (act != null) { act.actionPerformed(null); return true; } } } return false; }
Example #28
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
/** * Set all of the non-tree columns property names and display names. * * @param namesAndDisplayNames An array, divisible by 2, of * programmatic name, display name, programmatic name, display name... * @since 6.25 */ public final void setPropertyColumns(String... namesAndDisplayNames) { if (namesAndDisplayNames.length % 2 != 0) { throw new IllegalArgumentException("Odd number of names and " + //NOI18N "display names: " + Arrays.asList(namesAndDisplayNames)); //NOI18N } Property[] props = new Property[namesAndDisplayNames.length / 2]; for (int i = 0; i < namesAndDisplayNames.length; i+=2) { props[i / 2] = new PrototypeProperty (namesAndDisplayNames[i], namesAndDisplayNames[i+1]); } setProperties (props, true); }
Example #29
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
/** * Set the description (table header tooltip) for the property column * representing properties that have the passed programmatic (not display) * name, or for the tree column. * * @param columnName The programmatic name (Property.getName()) of the * column, or name of the tree column * @param description Tooltip text for the column header for that column */ public final void setPropertyColumnDescription(String columnName, String description) { Parameters.notNull ("columnName", columnName); //NOI18N Property[] props = rowModel.getProperties(); for (Property p : props) { if (columnName.equals(p.getName())) { p.setShortDescription(description); } } if (columnName.equals(model.getColumnName(0))) { outline.setNodesColumnDescription(description); } }
Example #30
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
private void setProperties(Node.Property[] newProperties, boolean doCleanColumns) { if (doCleanColumns) { TableColumnModel tcm = outline.getColumnModel(); if (tcm instanceof ETableColumnModel) { ((ETableColumnModel) tcm).clean(); } } rowModel.setProperties(newProperties); outline.tableChanged(null); }