/** * Creates a property value representing an array value. * @param componentType the type id of held objects (not array type id) * @param array the list of property values that represent the array of values in the design time * @return the property value */ public static PropertyValue createArray(TypeID componentType, List<PropertyValue> array) { assert componentType != null; assert array != null; assert createArrayAssert(array, componentType); PropertyValue val = new PropertyValue(Kind.ARRAY); val.type = componentType.getArrayType(); val.array = Collections.unmodifiableList(new ArrayList<PropertyValue>(array)); return val; }
public void run () { for (ComponentDescriptor descriptor : registry.getComponentDescriptors ()) { TypeID thisType = descriptor.getTypeDescriptor ().getThisType (); String string = thisType.getString (); if (! checkForJavaIdentifierCompliant (string)) continue; if (! registry.isInHierarchy (ClassCD.TYPEID, thisType) || ClassCD.TYPEID.equals (thisType)) continue; registryMap.put (string, descriptor); } } });
public static String getSuggestedMainName(TypeID type) { String instanceName = type.getString(); int index = instanceName.lastIndexOf('.'); // NOI18N if (index >= 0) instanceName = instanceName.substring(index + 1); if (type.getDimension() > 0) instanceName += ARRAY_SUFFIX; if (instanceName.length () <= 0) instanceName = "object"; // NOI18N char[] chars = instanceName.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (Character.isUpperCase(chars[i])) { if (i == 0) chars[i] = Character.toLowerCase(chars[i]); else if (i + 1 < chars.length) { if (Character.isUpperCase(chars[i+1])) chars[i] = Character.toLowerCase(chars[i]); else break; } else chars[i] = Character.toLowerCase(chars[i]); } else break; } } return new String (chars); }
public MidpComponentProducer(TypeID typeID, PaletteDescriptor paletteDescriptor) { super(typeID.toString(), typeID, paletteDescriptor); }
static EnumDescriptor getDescriptor (String projectType, TypeID type) { assert Debug.isFriend (PropertyValue.class); assert type.getKind () == TypeID.Kind.ENUM; assert type.getDimension () == 0; for (EnumDescriptorFactory factory : factoriesLookupResult.allInstances ()) { if (projectType == null || ! projectType.equals (factory.getProjectType ())) continue; EnumDescriptor descriptor = factory.getDescriptorForTypeIDString (type.getString ()); if (descriptor != null) return descriptor; } throw Debug.error ("No EnumDescriptorFactory found", type); // NOI18N }
/** * Creates a property value representing a primitive value. * @param descriptor the primitive descriptor * @param type the non-array type id that is primitive * @param value the object that represents the value in the design time * @return the property value */ public static PropertyValue createValue(PrimitiveDescriptor descriptor, TypeID type, Object value) { assert descriptor != null; assert type != null; assert type.getKind() == TypeID.Kind.PRIMITIVE; assert type.getDimension() == 0; assert value != null; assert descriptor.isValidInstance(value); PropertyValue val = new PropertyValue(Kind.VALUE); val.descriptor = descriptor; val.type = type; val.value = value; return val; }
public EnumDescriptor getDescriptorForTypeIDString (String string) { if (MidpTypes.TYPEID_ALERT_TYPE.getString ().equals (string)) return MidpEnumDescriptor.alertTypePD; //TODO return null; }
public static PropertyValue remove (PropertyValue array, DesignComponent itemToRemove) { ArrayList<PropertyValue> list = new ArrayList<PropertyValue> (array.getArray ()); Iterator<PropertyValue> iterator = list.iterator (); while (iterator.hasNext ()) { PropertyValue value = iterator.next (); if (value.getComponent ().equals (itemToRemove)) iterator.remove (); } array = PropertyValue.createArray (array.getType ().getComponentType (), list); return array; }
if (element.getUID() == 0) { Debug.warning("Missing ComponentDescriptor in registry ", element.getTypeID()); // NOI18N errorHandler.addError("{0} {1}", DESCRIPTOR_MISSING_ERROR, element.getTypeID().toString()); //NOI18N continue; } else { Debug.warning("Missing ComponentDescriptor in registry ", element.getTypeID()); // NOI18N errorHandler.addWarning("{0} {1}", DESCRIPTOR_MISSING_ERROR, element.getTypeID().toString()); //NOI18N continue; TypeID typeid = TypeID.createFrom(getAttributeValue(propertyNode, DocumentSave.TYPEID_ATTR)); String serialized = getAttributeValue(propertyNode, DocumentSave.VALUE_ATTR); propertyElements.add(PropertyElement.create(propertyName, typeid, serialized));
/** * Creates a new instance from an encoded string representation of type id. * @param string the encoded string */ public static TypeID createFrom (String string) { return string != null ? new TypeID (string) : null; }
static PropertyValue createComponentReferenceCore(DesignComponent component) { assert Debug.isFriend(DesignComponent.class, "<init>"); // NOI18N assert component != null; TypeID type = component.getType(); assert type.getKind() == TypeID.Kind.COMPONENT; PropertyValue val = new PropertyValue(Kind.REFERENCE); val.type = type; val.component = component; return val; }
private static void collectStructure(Collection<ComponentElement> componentElements, Node node, long parent, DocumentErrorHandler errorHandler) { String id = getAttributeValue(node, DocumentSave.COMPONENTID_ATTR); if (id == null) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < node.getAttributes().getLength(); i++) { sb.append(" "); //NOI18N sb.append(node.getAttributes().item(i)); } errorHandler.addError(NbBundle.getMessage(DocumentLoad.class, "MSG_Wrong_argument") + sb.toString()); //NOI18N return; } long componentid = -1; try { componentid = Long.parseLong(id); } catch (NumberFormatException ex) { errorHandler.addError("{0} {1}", NbBundle.getMessage(DocumentLoad.class, "MSG_Wrong_argument_value"), id); //NOI18N return; } TypeID typeid = TypeID.createFrom(getAttributeValue(node, DocumentSave.TYPEID_ATTR)); componentElements.add(ComponentElement.create(parent, componentid, typeid, node)); Node[] children = getChildNode(node); for (Node child : children) { if (isComponentNode(child)) { collectStructure(componentElements, child, componentid, errorHandler); } } }
case ARRAY: { TypeID type = value.getType (); int dimension = type.getDimension (); boolean newLines = dimension > 1; List<PropertyValue> array = value.getArray ();
public DataSetProducer() { super("javax.microedition.lcdui.Canvas", //NOI18N DataSetCD.TYPEID.toString(), DataSetCD.TYPEID, new PaletteDescriptor(MidpPaletteProvider.CATEGORY_DATABINDING, NbBundle.getMessage(DataSetAbstractProducer.class, "DISP_DataSet"),//NOI18N NbBundle.getMessage(DataSetAbstractProducer.class, "TTIP_DataSet"), //NOI18N DataSetAbstractCD.ICON_PATH, DataSetAbstractCD.LARGE_ICON_PATH)); }
static PrimitiveDescriptor getDescriptor (String projectType, TypeID type) { assert Debug.isFriend (PropertyValue.class); assert type.getKind () == TypeID.Kind.PRIMITIVE; assert type.getDimension () == 0; for (PrimitiveDescriptorFactory factory : factoriesLookupResult.allInstances ()) { if (projectType == null || ! projectType.equals (factory.getProjectType ())) continue; PrimitiveDescriptor descriptor = factory.getDescriptorForTypeIDString (type.getString ()); if (descriptor != null) return descriptor; } Debug.warning ("No PrimitiveDescriptorFactory found", type); // NOI18N return null; }
DesignComponent(DesignDocument document, long componentID, ComponentDescriptor componentDescriptor) { assert Debug.isFriend(DesignDocument.class, "createRawComponent"); // NOI18N this.document = document; this.componentID = componentID; this.type = componentDescriptor.getTypeDescriptor().getThisType(); assert type.getKind() == TypeID.Kind.COMPONENT && type.getDimension() == 0; children = new ArrayList<DesignComponent> (); properties = new HashMap<String, PropertyValue> (); defaultProperties = new HashMap<String, PropertyValue> (); referencePropertyValue = PropertyValue.createComponentReferenceCore(this); presenters = Lookup.EMPTY; setComponentDescriptor(componentDescriptor, false); }