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

The following are Jave code examples for showing how to use PropertySet of the org.openide.nodes.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: GridDesigner.java   Source Code and License Vote up 6 votes
@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
Project: incubator-netbeans   File: NodeTableModel.java   Source Code and License Vote up 6 votes
/** 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 3
Project: incubator-netbeans   File: PropertiesFlushTest.java   Source Code and License Vote up 6 votes
public Node.PropertySet[] getPropertySets() {
    if (sets == null) {
        System.err.println("Create sheet");
        Sheet sheet = new Sheet();
        // Make sure there is a "Properties" set:
        Sheet.Set props = sheet.get(Sheet.PROPERTIES);
        props = Sheet.createPropertiesSet();
        sheet.put(props);
        TProperty tp = new TProperty("property", true);
        props.put(tp);
        if (firstTime) {
            props.put(new TProperty("second", true));
            System.err.println("first time");
            firstTime = false;
        } else {
            System.err.println("Second  time");
        }
        sets = sheet.toArray();
    }
    return sets;
}
 
Example 4
Project: incubator-netbeans   File: IndexedPropertyEditorTest.java   Source Code and License Vote up 6 votes
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
Project: incubator-netbeans   File: NodeTableModel.java   Source Code and License Vote up 6 votes
/** 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
Project: incubator-netbeans   File: FormI18nSupport.java   Source Code and License Vote up 6 votes
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 7
Project: incubator-netbeans   File: DataShadowTest.java   Source Code and License Vote up 6 votes
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 8
Project: incubator-netbeans   File: HtmlDataNode.java   Source Code and License Vote up 5 votes
/**
 * 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 9
Project: incubator-netbeans   File: MetaLayout.java   Source Code and License Vote up 5 votes
@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 10
Project: incubator-netbeans   File: TreeTableView.java   Source Code and License Vote up 5 votes
private Node.Property getNodeProperty(Node node, Node.Property prop) {
    Node.PropertySet[] propsets = node.getPropertySets();

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

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

    return null;
}
 
Example 11
Project: incubator-netbeans   File: PSheet.java   Source Code and License Vote up 5 votes
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 12
Project: incubator-netbeans   File: NodeSelector.java   Source Code and License Vote up 5 votes
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 13
Project: incubator-netbeans   File: PropertiesAction.java   Source Code and License Vote up 5 votes
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 14
Project: incubator-netbeans   File: AbstractLayoutSupport.java   Source Code and License Vote up 4 votes
/** 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 15
Project: incubator-netbeans   File: PrintActionTest.java   Source Code and License Vote up 4 votes
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 16
Project: incubator-netbeans   File: OpenActionTest.java   Source Code and License Vote up 4 votes
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 17
Project: incubator-netbeans   File: PhysicalView.java   Source Code and License Vote up 4 votes
@Override public Node.PropertySet[] getPropertySets() {
    return new Node.PropertySet[0];
}
 
Example 18
Project: incubator-netbeans   File: PaletteItemNode.java   Source Code and License Vote up 4 votes
@Override
public Node.PropertySet[] getPropertySets() {
    return NO_PROPERTIES;
}
 
Example 19
Project: incubator-netbeans   File: EditActionTest.java   Source Code and License Vote up 4 votes
public Node.PropertySet[] getPropertySets() { 
    return null; 
}
 
Example 20
Project: incubator-netbeans   File: TemplatesPanel.java   Source Code and License Vote up 4 votes
@Override
public PropertySet[] getPropertySets () {
    return new Node.PropertySet [] { createTemplateProperties (this) };
}