Search in sources :

Example 1 with TextPropertyDescriptor

use of org.eclipse.ui.views.properties.TextPropertyDescriptor in project sling by apache.

the class ModifiableProperties method getPropertyDescriptors.

@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
    final Map<String, IPropertyDescriptor> conversionMap = new HashMap<>();
    for (Entry<String, String> entry : properties.entrySet()) {
        TextPropertyDescriptor pd = new JcrTextPropertyDescriptor(entry, entry.getKey());
        conversionMap.put(entry.getKey(), pd);
    }
    final List<String> propertiesOrderCopy = new LinkedList<>(propertiesOrder);
    final String jcrPrimaryType = "jcr:primaryType";
    if (!properties.containsKey(jcrPrimaryType)) {
        Map<String, String> pseudoMap = new HashMap<>();
        pseudoMap.put(jcrPrimaryType, node.getPrimaryType());
        final TextPropertyDescriptor pseudoPd = new JcrTextPropertyDescriptor(pseudoMap.entrySet().iterator().next(), jcrPrimaryType);
        propertiesOrderCopy.add(0, jcrPrimaryType);
        conversionMap.put(jcrPrimaryType, pseudoPd);
    }
    IPropertyDescriptor[] result = new IPropertyDescriptor[conversionMap.size()];
    for (int i = 0; i < result.length; i++) {
        String aPropertyName = propertiesOrderCopy.get(i);
        result[i] = conversionMap.get(aPropertyName);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) LinkedList(java.util.LinkedList)

Example 2 with TextPropertyDescriptor

use of org.eclipse.ui.views.properties.TextPropertyDescriptor in project webtools.sourceediting by eclipse.

the class XMLTableTreePropertyDescriptorFactory method createAttributePropertyDescriptor.

public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) {
    IPropertyDescriptor result = null;
    String attributeName = attr.getName();
    ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument());
    CMAttributeDeclaration ad = null;
    if (mq != null) {
        ad = mq.getCMAttributeDeclaration(attr);
    }
    if (ad != null) {
        result = createPropertyDescriptorHelper(attributeName, attr.getOwnerElement(), ad);
    }
    if (result == null) {
        result = new TextPropertyDescriptor(attributeName, attributeName);
    }
    return result;
}
Also used : ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor)

Example 3 with TextPropertyDescriptor

use of org.eclipse.ui.views.properties.TextPropertyDescriptor in project webtools.sourceediting by eclipse.

the class XMLPropertySource method createTextPropertyDescriptor.

private IPropertyDescriptor createTextPropertyDescriptor(CMAttributeDeclaration attrDecl, Attr attr) {
    String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
    TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrName, attrName);
    descriptor.setCategory(getCategory(attrDecl, attr));
    descriptor.setDescription(attrName);
    if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) {
        descriptor.setFilterFlags(new String[] { IPropertySheetEntry.FILTER_ID_EXPERT });
    }
    return descriptor;
}
Also used : TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor)

Example 4 with TextPropertyDescriptor

use of org.eclipse.ui.views.properties.TextPropertyDescriptor in project knime-core by knime.

the class NodeContainerProperties method getDescriptors.

/**
 * @return see {@link #getPropertyDescriptors()}
 */
protected IPropertyDescriptor[] getDescriptors() {
    ArrayList<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
    // iterate through all settings in the config
    for (Enumeration<TreeNode> it = m_settings.children(); it.hasMoreElements(); ) {
        AbstractConfigEntry prop = (AbstractConfigEntry) it.nextElement();
        // the id should be globally unique
        String hierID = m_prefix.isEmpty() ? prop.getKey() : m_prefix + CONFIG_SEPARATOR + prop.getKey();
        if (prop instanceof Config) {
            // sub-config
            descriptors.add(new PropertyDescriptor(hierID, prop.getKey()));
        } else {
            // all settings are displayed as string
            String typeName = prop.getType().name().substring(1);
            // we don't have a label yet
            String label = prop.getKey() + " (" + typeName + ")";
            switch(prop.getType()) {
                // if cases are changed here, setPropertyValue must be adapted
                case xboolean:
                case xbyte:
                case xchar:
                case xdouble:
                case xfloat:
                case xint:
                case xlong:
                case xshort:
                case xstring:
                    // editable types
                    descriptors.add(new TextPropertyDescriptor(hierID, label));
                    break;
                default:
                    descriptors.add(new PropertyDescriptor(hierID, label));
                    break;
            }
        }
    }
    return descriptors.toArray(new IPropertyDescriptor[descriptors.size()]);
}
Also used : AbstractConfigEntry(org.knime.core.node.config.base.AbstractConfigEntry) PropertyDescriptor(org.eclipse.ui.views.properties.PropertyDescriptor) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) TreeNode(javax.swing.tree.TreeNode) Config(org.knime.core.node.config.Config) ArrayList(java.util.ArrayList) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor)

Example 5 with TextPropertyDescriptor

use of org.eclipse.ui.views.properties.TextPropertyDescriptor in project webtools.sourceediting by eclipse.

the class XMLTableTreePropertyDescriptorFactory method createTextPropertyDescriptor.

public IPropertyDescriptor createTextPropertyDescriptor(Text text) {
    IPropertyDescriptor result = null;
    Node parentNode = text.getParentNode();
    if ((parentNode != null) && (parentNode.getNodeType() == Node.ELEMENT_NODE)) {
        Element parentElement = (Element) parentNode;
        ModelQuery mq = ModelQueryUtil.getModelQuery(text.getOwnerDocument());
        CMElementDeclaration ed = null;
        if (mq != null) {
            ed = mq.getCMElementDeclaration(parentElement);
        }
        if (ed != null) {
            result = createPropertyDescriptorHelper(HACK, parentElement, ed);
        } else {
            result = createDefaultPropertyDescriptor(parentElement.getNodeName());
        }
    }
    if (result == null) {
        result = new TextPropertyDescriptor(HACK, HACK);
    }
    return result;
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Node(org.w3c.dom.Node) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) Element(org.w3c.dom.Element) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor)

Aggregations

TextPropertyDescriptor (org.eclipse.ui.views.properties.TextPropertyDescriptor)9 IPropertyDescriptor (org.eclipse.ui.views.properties.IPropertyDescriptor)7 ArrayList (java.util.ArrayList)3 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)3 List (java.util.List)2 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)2 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 TreeNode (javax.swing.tree.TreeNode)1 PropertyDescriptor (org.eclipse.ui.views.properties.PropertyDescriptor)1 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)1 CMNamedNodeMapImpl (org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl)1 ExporterProperty (org.hibernate.eclipse.console.model.impl.ExporterProperty)1 Config (org.knime.core.node.config.Config)1 AbstractConfigEntry (org.knime.core.node.config.base.AbstractConfigEntry)1 Attr (org.w3c.dom.Attr)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1