Java Code Examples for org.openide.nodes.Node#Property

The following examples show how to use org.openide.nodes.Node#Property . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   File: Property.java    License: Apache License 2.0 6 votes vote down vote up
/** Waits for property with given name in specified property sheet.
 * @param propSheetOper PropertySheetOperator where to find property.
 * @param name property display name
 */
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final String name) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object param) {
                Node.Property property = null;
                JTableOperator table = propSheetOper.tblSheet();
                for(int row=0;row<table.getRowCount();row++) {
                    if(table.getValueAt(row, 1) instanceof Node.Property) {
                        property = (Node.Property)table.getValueAt(row, 1);
                        if(propSheetOper.getComparator().equals(property.getDisplayName(), name)) {
                            return property;
                        }
                    }
                }
                return null;
            }
            public String getDescription() {
                return("Wait property "+name);
            }
        });
        return (Node.Property)waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
}
 
Example 2
Source Project: netbeans   File: UpdateResultsTable.java    License: Apache License 2.0 6 votes vote down vote up
public int compare(Object o1, Object o2) {
    Node.Property p1 = (Node.Property) o1;
    Node.Property p2 = (Node.Property) o2;
    String sk1 = (String) p1.getValue("sortkey"); // NOI18N
    if (sk1 != null) {
        String sk2 = (String) p2.getValue("sortkey"); // NOI18N
        return sk1.compareToIgnoreCase(sk2);
    } else {
        try {
            String s1 = (String) p1.getValue();
            String s2 = (String) p2.getValue();
            return s1.compareToIgnoreCase(s2);
        } catch (Exception e) {
            Subversion.LOG.log(Level.SEVERE, null, e);
            return 0;
        }
    }
}
 
Example 3
Source Project: netbeans   File: PropertiesRowModel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueFor(Object node, int column) {
    Node n = Visualizer.findNode(node);
    if (n == null) {
        throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + node + " of class " + node.getClass().getName());
    }
    PropertyChangeListener cacheEntry = nodesListenersCache.get (n);
    if (cacheEntry == null) {
        PropertyChangeListener p = WeakListeners.propertyChange(pcl, n);
        nodesListenersCache.put(n, p);
        n.addPropertyChangeListener(p);
        NodeListener l = WeakListeners.create(NodeListener.class, nl, n);
        n.addNodeListener(l);
    }
    Node.Property theRealProperty = getPropertyFor(n, prop[column]);
    return theRealProperty;
}
 
Example 4
Source Project: netbeans   File: GridBagManager.java    License: Apache License 2.0 5 votes vote down vote up
private void setProperty(Component component, String propertyName, Object value) {
    Node.Property property = getProperty(component, propertyName);
    try {
        property.setValue(value);
    } catch (IllegalAccessException iaex) {
        FormUtils.LOGGER.log(Level.WARNING, iaex.getMessage(), iaex);
    } catch (InvocationTargetException itex) {
        FormUtils.LOGGER.log(Level.WARNING, itex.getMessage(), itex);
    }
}
 
Example 5
Source Project: netbeans   File: RendererDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
private void changeProperty(final RendererPropertyDisplayer ren, final Node.Property newProp) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ren.setProperty(newProp);
        }
    });
}
 
Example 6
Source Project: netbeans   File: EditableDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
private void changeProperty(final PropertyDisplayer_Mutable ren, final Node.Property newProp) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ren.setProperty(newProp);
        }
    });
}
 
Example 7
Source Project: netbeans   File: FormUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static void copyPropertyAttrs(Node.Property sourceProp, Node.Property targetProp, String[] attrs) {
    for (String attr : attrs) {
        Object value = sourceProp.getValue(attr);
        if (value != null) {
            targetProp.setValue(attr, value);
        }
    }
}
 
Example 8
Source Project: netbeans   File: FileTreeViewImpl.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupColumns() {
    Node.Property [] properties = new Node.Property[2];
    properties[0] = new ColumnDescriptor<>(GitStatusNodeImpl.GitStatusProperty.NAME, String.class, GitStatusNode.GitStatusProperty.DISPLAY_NAME, GitStatusNode.GitStatusProperty.DESCRIPTION);
    properties[1] = new ColumnDescriptor<>(GitStatusNodeImpl.PathProperty.NAME, String.class, VCSStatusNode.PathProperty.DISPLAY_NAME, VCSStatusNode.PathProperty.DESCRIPTION);
    view.setProperties(properties);
    view.getOutline().setRenderDataProvider(createRenderProvider());
}
 
Example 9
Source Project: netbeans   File: JavaNode.java    License: Apache License 2.0 5 votes vote down vote up
private Node.Property createNameProperty () {
    Node.Property p = new PropertySupport.ReadWrite<String> (
            DataObject.PROP_NAME,
            String.class,
            getMessage (DataObject.class, "PROP_name"),
            getMessage (DataObject.class, "HINT_name")
            ) {
        public String getValue () {
            return JavaNode.this.getName();
        }
        @Override
        public Object getValue(String key) {
            if ("suppressCustomEditor".equals (key)) { //NOI18N
                return Boolean.TRUE;
            } else {
                return super.getValue (key);
            }
        }
        public void setValue(String val) throws IllegalAccessException,
                IllegalArgumentException, InvocationTargetException {
            if (!canWrite())
                throw new IllegalAccessException();
            JavaNode.this.setName(val);
        }
        @Override
        public boolean canWrite() {
            return JavaNode.this.canRename();
        }
        
    };
    
    return p;
}
 
Example 10
Source Project: netbeans   File: PropertiesEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void attachEnv(PropertyEnv env) {
    FeatureDescriptor d = env.getFeatureDescriptor();
    if (d instanceof Node.Property) {
        canWrite = ((Node.Property) d).canWrite();
    }
}
 
Example 11
Source Project: netbeans   File: PropertyPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** The constructor all the other constructors call */
private PropertyPanel(Node.Property p, int preferences, PropertyModel mdl) {
    if (p == null) {
        prop = ModelProperty.toProperty(mdl);
    } else {
        prop = p;
    }

    this.preferences = preferences;
    initializing = true;
    setModel(mdl);
    initializing = false;
    setOpaque(true);

    if (!GraphicsEnvironment.isHeadless()) {
        //for debugging, allow CTRL-. to dump the state to stderr
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "dump"
        );
    }
    getActionMap().put(
        "dump",
        new AbstractAction() { //NOI18N
            public void actionPerformed(ActionEvent ae) {
                System.err.println(""); //NOI18N
                System.err.println(PropertyPanel.this);
                System.err.println(""); //NOI18N
            }
        }
    );

    //#44226 - Unpretty, but this allows the TreeTableView to invoke a custom editor dialog when
    //necessary - with the TTV rewrite, all cell editor infrastructure will be moved to
    //org.netbeans.modules.openide.explorer, and they will simply share editor classes.  Since that
    //involves an API change (some package private methods of PropertyEnv need to be accessible to
    //the editor classes), this will have to wait for after 4.0 - Tim
    getActionMap().put("invokeCustomEditor", new CustomEditorProxyAction()); //NOI18N

    PropertyPanelBridge.register(this, new BridgeAccessor(this));
}
 
Example 12
Source Project: netbeans   File: NbClassPathEditor.java    License: Apache License 2.0 5 votes vote down vote up
public void attachEnv(PropertyEnv env) {
    FeatureDescriptor desc = env.getFeatureDescriptor();
    if (desc instanceof Node.Property){
        Node.Property prop = (Node.Property)desc;
        editable = prop.canWrite();
    }
}
 
Example 13
Source Project: netbeans   File: NodeTableModel.java    License: Apache License 2.0 4 votes vote down vote up
/** Getter for column class.
 * @param column table column index
 * @return  <code>Node.Property.class</code>
 */
@Override
public Class getColumnClass(int column) {
    return Node.Property.class;
}
 
Example 14
Source Project: netbeans   File: FormCodeSupport.java    License: Apache License 2.0 4 votes vote down vote up
public static CodeExpressionOrigin createOrigin(Node.Property property) {
    if (property instanceof FormProperty)
        return new FormPropertyValueOrigin((FormProperty)property);
    else
        return new PropertyValueOrigin(property);
}
 
Example 15
Source Project: netbeans   File: NodePropertyModel.java    License: Apache License 2.0 4 votes vote down vote up
/** Construct simple model instance.
 * @param property proeprty to work with
 * @param beans array of beans(nodes) to which belong the property
 */
public NodePropertyModel(Node.Property property, Object[] beans) {
    this.prop = property;
    this.beans = beans;
}
 
Example 16
Source Project: netbeans   File: PropertiesRowModel.java    License: Apache License 2.0 4 votes vote down vote up
public void setProperties(Node.Property[] newProperties) {
    prop = newProperties;
    names = new String [prop.length];
    descs = new String [prop.length];
}
 
Example 17
Source Project: netbeans   File: HistoryFileView.java    License: Apache License 2.0 4 votes vote down vote up
String getDisplayValue(Node.Property p) throws IllegalAccessException, InvocationTargetException {
    TableEntry value = (TableEntry) p.getValue();
    return value != null ? value.getDisplayValue() : ""; // NOI18N
}
 
Example 18
Source Project: netbeans   File: OutlineTable.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Set list of models.
 * Columns are taken from the first model. Children are listed
 * @param models
 */
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...
     * the expansion is performed in TreeModelNode.TreeModelChildren.applyChildren()
     */
    } finally {
        isSettingModelUp = false;
    }
}
 
Example 19
Source Project: netbeans   File: RendererDisplayerTest.java    License: Apache License 2.0 4 votes vote down vote up
public void addProp(Node.Property p) {
    props.put(p);
    this.firePropertyChange(PROP_PROPERTY_SETS, null, null);
    this.firePropertySetsChange(null, null);
}
 
Example 20
Source Project: netbeans   File: WildflyManagerNode.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
    if (properties == null) {
        properties = Sheet.createPropertiesSet();
        sheet.put(properties);
    }
    final InstanceProperties ip = getDeploymentManager().getInstanceProperties();

    Node.Property property = new PropertySupport.ReadWrite(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_DISPLAY_NAME"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_DISPLAY_NAME"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_DISPLAY_NAME")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_DISPLAY_NAME);
                }

        @Override
                public void setValue(Object val) {
                    ip.setProperty(WildflyPluginProperties.PROPERTY_DISPLAY_NAME, (String) val);
                }
            };

    properties.put(property);

    // servewr name
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_NAME"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_NAME"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_SERVER_NAME")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_SERVER);
                }
            };
    properties.put(property);

    //server location
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_PATH"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_PATH"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_SERVER_PATH")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_SERVER_DIR);
                }
            };
    properties.put(property);

    //host
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_HOST"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_HOST"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_HOST")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_HOST);
                }
            };
    properties.put(property);

    //port
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_PORT"), //NOI18N
            Integer.TYPE,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_PORT"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_PORT")) {
        @Override
                public Object getValue() {
                    return new Integer(ip.getProperty(WildflyPluginProperties.PROPERTY_PORT));
                }
            };
    properties.put(property);

    return sheet;
}