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

The following examples show how to use org.openide.nodes.Node#PropertySet . 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: GridDesigner.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Node.PropertySet[] getPropertySets() {
    for (Node.PropertySet pSet : super.getPropertySets()) {
        String name = pSet.getName();
        if ("layout".equals(name)) { // NOI18N
            final Node.PropertySet set = pSet;
            String displayName = NbBundle.getMessage(GridDesigner.class, "GridDesigner.layoutConstraints"); // NOI18N
            return new Node.PropertySet[] {new PropertySet(set.getName(), displayName, set.getShortDescription()) {
                @Override
                public Property<?>[] getProperties() {
                    return set.getProperties();
                }
            }};
        }
    }
    return new Node.PropertySet[0];
}
 
Example 2
Source Project: netbeans   File: FormI18nSupport.java    License: Apache License 2.0 6 votes vote down vote up
public boolean hasNext() {
    if (!ready) {
        if (first || (++propIndex == properties.length)) {
            if (first) {
                propSets = comp.getProperties();
                first = false;
            }
            while (++propSetIndex != propSets.length) {
                Node.PropertySet propSet;
                if (isFormPropSet(propSet = propSets[propSetIndex])
                        && ((properties = propSet.getProperties()).length != 0)) {
                    propIndex = 0;
                    break;
                }
            }
            if (propSetIndex == propSets.length) {
                exhausted = true;
            }
        }
        ready = true;
    }
    return !exhausted;
}
 
Example 3
Source Project: netbeans   File: NodeTableModel.java    License: Apache License 2.0 6 votes vote down vote up
/** Returns node property if found in nodes property sets. Could be overriden to
 * return property which is not in nodes property sets.
 * @param node represents single row
 * @param prop represents column
 * @return nodes property
 */
protected Property getPropertyFor(Node node, Property prop) {
    Node.PropertySet[] propSets = node.getPropertySets();

    for (int i = 0; i < propSets.length; i++) {
        Node.Property[] props = propSets[i].getProperties();

        for (int j = 0; j < props.length; j++) {
            if (prop.equals(props[j])) {
                return props[j];
            }
        }
    }

    return null;
}
 
Example 4
public void testGetJavaInitializationString() throws Exception {
    ExPropertyEditor editor = new IndexedPropertyEditor();
    PropertyEnv env = new PropertyEnv();
    Node.Property<?> prop = null;
    Bean bean = new Bean();
    bean.setStuff(new Stuff[] {new Stuff(1), new Stuff(2)});
    for (Node.PropertySet s : new BeanNode<Bean>(bean).getPropertySets()) {
        for (Node.Property<?> p : s.getProperties()) {
            if (p.getName().equals("stuff")) {
                prop = p;
                break;
            }
        }
    }
    assertNotNull(prop);
    assertTrue(prop instanceof Node.IndexedProperty<?,?>);
    editor.setValue(bean.getStuff());
    env.setFeatureDescriptor(prop);
    editor.attachEnv(env);
    String n = Stuff.class.getCanonicalName();
    assertEquals("new" + n + "[]{new" + n + "(1),new" + n + "(2)}", editor.getJavaInitializationString().replaceAll("\\s+", ""));
}
 
Example 5
Source Project: netbeans   File: NodeTableModel.java    License: Apache License 2.0 6 votes vote down vote up
/** Returns node property if found in nodes property sets. Could be overriden to
 * return property which is not in nodes property sets.
 * @param node represents single row
 * @param prop represents column
 * @return nodes property
 */
protected Property getPropertyFor(Node node, Property prop) {
    Node.PropertySet[] propSets = node.getPropertySets();

    for (int i = 0; i < propSets.length; i++) {
        Node.Property[] props = propSets[i].getProperties();

        for (int j = 0; j < props.length; j++) {
            if (prop.equals(props[j])) {
                return props[j];
            }
        }
    }

    return null;
}
 
Example 6
Source Project: netbeans   File: DataShadowTest.java    License: Apache License 2.0 6 votes vote down vote up
private static Node.Property findProperty (Node n, String name) {
    Node.PropertySet[] arr = n.getPropertySets ();
    StringBuffer names = new StringBuffer ();
    
    String prefix = "";
    for (int i = 0; i < arr.length; i++) {
        Node.PropertySet set = arr[i];
        Node.Property[] properties = set.getProperties ();
        for (int j = 0; j < properties.length; j++) {
            Node.Property p = properties[j];
            if (name.equals (p.getName ())) {
                return p;
            }
            names.append (prefix);
            names.append (p.getName ());
            prefix = ", ";
        }
    }
    
    fail ("Cannot find property \"" + name + "\" in node " + n + " it has only " + names + " propeties.");
    return null;
}
 
Example 7
Source Project: netbeans   File: HtmlDataNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets custom Node.PropertySet[] to this node.
 * 
 * {@link #firePropertySetsChange(org.openide.nodes.Node.PropertySet[], org.openide.nodes.Node.PropertySet[])} is called afterwards.
 * 
 * @since 1.46
 * @param sets the custom property sets or null if the default property sets should be used.
 */
public void setPropertySets(Node.PropertySet[] sets) {
    Node.PropertySet[] old = customPropertySet != null ? customPropertySet : getPropertySets();
    Node.PropertySet[] neww = sets != null ? sets : getPropertySets();
    
    customPropertySet = sets;
    
    firePropertySetsChange(old, neww);
}
 
Example 8
Source Project: netbeans   File: MetaLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void createPropertySets(java.util.List<Node.PropertySet> propSets) {
    super.createPropertySets(propSets);

    // RADComponent provides also Code Generation properties for which
    // we have no use here (yet) - so we remove them now
    for (int i=0, n=propSets.size(); i < n; i++) {
        Node.PropertySet propSet = propSets.get(i);
        if (!"properties".equals(propSet.getName()) // NOI18N
                && !"properties2".equals(propSet.getName())) { // NOI18N
            propSets.remove(i);
            i--;  n--;
        }
    }
}
 
Example 9
Source Project: netbeans   File: PropertiesRowModel.java    License: Apache License 2.0 5 votes vote down vote up
protected Node.Property getPropertyFor(Node node, Node.Property prop) {
    Node.PropertySet[] propSets = node.getPropertySets();

    for (int i = 0; i < propSets.length; i++) {
        Node.Property[] props = propSets[i].getProperties();

        for (int j = 0; j < props.length; j++) {
            if (prop.equals(props[j])) {
                return props[j];
            }
        }
    }

    return null;
}
 
Example 10
Source Project: netbeans   File: PSheet.java    License: Apache License 2.0 5 votes vote down vote up
public Object getTabbedContainerSelection() {
    JComponent tabbed = findTabbedContainer();

    if (tabbed != null) {
        Object o = TabbedContainerBridge.getDefault().getSelectedItem(tabbed);

        if (o instanceof Node.PropertySet[]) { //won't be first time

            return o;
        }
    }

    return null;
}
 
Example 11
Source Project: netbeans   File: NodeSelector.java    License: Apache License 2.0 5 votes vote down vote up
public Node.PropertySet[] getPropertySets() {
    if (propSheet == null) {
        propSheet = Sheet.createDefault();
        Sheet.Set nodePropertySet = propSheet.get(Sheet.PROPERTIES);
        
        if (grammarQuery != null && hintContext != null) {
            Node.Property[] nodeProperties = grammarQuery.getProperties(hintContext);
            if (nodeProperties != null && nodeProperties.length > 0) {
                // The GrammarQuery controls the properties
                nodePropertySet.put(nodeProperties);
                return propSheet.toArray();
            }
        }
        
        // By default, we try to create properties from the attributes of the
        // selected element.
        org.w3c.dom.Element attributeOwningElem = null;
        if (hintContext != null) {
            if (hintContext.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
                attributeOwningElem = (org.w3c.dom.Element)hintContext;
            } else if (hintContext.getNodeType() == org.w3c.dom.Node.ATTRIBUTE_NODE) {
                attributeOwningElem = (org.w3c.dom.Element)((org.w3c.dom.Attr)hintContext).getOwnerElement();
            }
        }
        
        if (attributeOwningElem != null) {
            // We have a selected element that might have attributes
            org.w3c.dom.NamedNodeMap attributes = attributeOwningElem.getAttributes();
            for (int ind = 0; ind < attributes.getLength(); ind++) {
                org.w3c.dom.Node node = attributes.item(ind);
                nodePropertySet.put(new AttributeProperty(attributeOwningElem, node.getNodeName()));
            }
            
        }
    }
    
    return propSheet.toArray();
}
 
Example 12
Source Project: netbeans   File: PropertiesAction.java    License: Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupPresenter() {
    JMenuItem prop = new Actions.MenuItem(this, false);

    Action customizeAction = SystemAction.get(CustomizeAction.class);

    // Retrieve context sensitive action instance if possible.
    if (lookup != null) {
        customizeAction = ((ContextAwareAction) customizeAction).createContextAwareInstance(lookup);
    }

    if (customizeAction.isEnabled()) {
        JInlineMenu mi = new JInlineMenu();
        mi.setMenuItems(new JMenuItem[] { new Actions.MenuItem(customizeAction, false), prop });

        return mi;
    } else {
        for (Node n : nodes()) {
            for (Node.PropertySet ps : n.getPropertySets()) {
                if (ps.getProperties().length > 0) {
                    // OK, we have something to show!
                    return prop;
                }
            }
        }
        // else nothing to show, so show nothing
        return new JInlineMenu();
    }
}
 
Example 13
Source Project: netbeans   File: AbstractLayoutSupport.java    License: Apache License 2.0 4 votes vote down vote up
/** This method provides properties of the supported layout - if it is
 * a JavaBean class implementing LayoutManager. The properties are obtained
 * from the BeanInfo of the layout manager. Note these are not properties
 * of individual components constraints.
 * @return properties of supported layout
 */
@Override
public Node.PropertySet[] getPropertySets() {
    Node.PropertySet[] propertySets;

    FormProperty[] properties = getProperties();
    if (properties == null) {
        propertySets = metaLayout != null ?
                           metaLayout.getProperties() : null;
    }
    else { // a subclass provides special properties
        propertySets = new Node.PropertySet[1];
        propertySets[0] = new Node.PropertySet(
            "properties", // NOI18N
            FormUtils.getBundleString("CTL_PropertiesTab"), // NOI18N
            FormUtils.getBundleString("CTL_PropertiesTabHint")) // NOI18N
        {
            @Override
            public Node.Property[] getProperties() {
                return AbstractLayoutSupport.this.getProperties();
            }
        };
    }

    if (propertySets != null) {
        java.util.List<Node.Property> allPropsList = new ArrayList<Node.Property>();
        for (int i=0; i < propertySets.length; i++) {
            Node.Property[] props = propertySets[i].getProperties();
            for (int j=0; j < props.length; j++)
                if (props[j] instanceof FormProperty)
                    allPropsList.add(props[j]);
        }
        allProperties = new FormProperty[allPropsList.size()];
        allPropsList.toArray(allProperties);
    }
    else {
        allProperties = new FormProperty[0];
        propertySets = new Node.PropertySet[0];
    }

    return propertySets;
}
 
Example 14
Source Project: netbeans   File: CategoryNode.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Node.PropertySet[] getPropertySets() {
    return NO_PROPERTIES;
}
 
Example 15
Source Project: netbeans   File: TemplatesPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public PropertySet[] getPropertySets () {
    return new Node.PropertySet [] { createTemplateProperties (this) };
}
 
Example 16
Source Project: netbeans   File: EditActionTest.java    License: Apache License 2.0 4 votes vote down vote up
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 17
Source Project: netbeans   File: OpenActionTest.java    License: Apache License 2.0 4 votes vote down vote up
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 18
Source Project: netbeans   File: PrintActionTest.java    License: Apache License 2.0 4 votes vote down vote up
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 19
Source Project: netbeans   File: PhysicalView.java    License: Apache License 2.0 4 votes vote down vote up
@Override public Node.PropertySet[] getPropertySets() {
    return new Node.PropertySet[0];
}
 
Example 20
Source Project: netbeans   File: PaletteItemNode.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Node.PropertySet[] getPropertySets() {
    return NO_PROPERTIES;
}