public static FileObject getFileObjectFromImageComponent(DesignComponent imageComponent) { if (imageComponent == null) { return null; } PropertyValue value = imageComponent.readProperty(ImageCD.PROP_RESOURCE_PATH); String imagePath = null; if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { imagePath = MidpTypes.getString(imageComponent.readProperty(ImageCD.PROP_RESOURCE_PATH)); } if (imagePath == null) { return null; } DesignDocument document = imageComponent.getDocument(); Map<FileObject, FileObject> fileMap = MidpProjectSupport.getFileObjectsForRelativeResourcePath(document, imagePath); if (fileMap == null || !fileMap.keySet().iterator().hasNext()) { return null; } FileObject imageFileObject = fileMap.keySet().iterator().next(); if (imageFileObject != null) { return imageFileObject; } Debug.warning("Resource path property in", imageComponent, "contains incorrect value"); // NOI18N return null; }
/** * Loads icon using resourcePath property from given image design component * * @param imageComponent image design component * @return icon */ public static Icon getIconFromImageComponent(DesignComponent imageComponent) { if (imageComponent == null) { return null; } PropertyValue value = imageComponent.readProperty(ImageCD.PROP_RESOURCE_PATH); String imagePath = null; if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { imagePath = MidpTypes.getString(imageComponent.readProperty(ImageCD.PROP_RESOURCE_PATH)); } if (imagePath == null) { return null; } DesignDocument document = imageComponent.getDocument(); Map<FileObject, FileObject> fileMap = MidpProjectSupport.getFileObjectsForRelativeResourcePath(document, imagePath); if (fileMap == null || fileMap.keySet().iterator().hasNext() == false) { return null; } FileObject imageFileObject = fileMap.keySet().iterator().next(); if (imageFileObject != null) { return resolveImageForRoot(imageFileObject, imagePath); } Debug.warning("Resource path property in", imageComponent, "contains incorrect value"); // NOI18N return null; }
public static PropertyValue removeArrayValue (PropertyValue array, int index) { assert array != null; assert array.getKind ().equals (PropertyValue.Kind.ARRAY); ArrayList<PropertyValue> values = new ArrayList<PropertyValue> (array.getArray ()); values.remove (index); return PropertyValue.createArray (array.getType ().getComponentType (), values); }
public void reload(ScreenDeviceInfo deviceInfo) { PropertyValue value = getComponent().getParentComponent().readProperty(ChoiceGroupCD.PROP_CHOICE_TYPE); int type; if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { type = MidpTypes.getInteger(value); } else { String path = null; value = getComponent().readProperty(ChoiceElementCD.PROP_IMAGE); if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { DesignComponent imageComponent = value.getComponent(); if (imageComponent != null) { if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { DesignComponent font = value.getComponent(); label.setFont(ScreenSupport.getFont(deviceInfo, font));
return; if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { type = MidpTypes.getInteger(value); } else { String path = null; value = getComponent().readProperty(ChoiceElementCD.PROP_IMAGE); if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { imageComponent = value.getComponent(); if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { DesignComponent font = value.getComponent(); label.setFont(ScreenSupport.getFont(deviceInfo, font));
if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { int appearanceMode = MidpTypes.getInteger(value); label.setBorder(appearanceMode == ItemCD.VALUE_BUTTON ? BorderFactory.createRaisedBevelBorder() : null); if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { DesignComponent font = value.getComponent(); label.setFont(ScreenSupport.getFont(deviceInfo, font));
if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { kindCode = MidpTypes.getInteger(value); } else { if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { faceCode = MidpTypes.getInteger(value); } else { if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { styleCode = MidpTypes.getInteger(value); } else { if (!PropertyValue.Kind.USERCODE.equals(value.getKind())) { sizeCode = MidpTypes.getInteger(value); } else {
public static PropertyValue removeArrayValue (PropertyValue array, PropertyValue value) { assert array != null && value != null; assert array.getKind ().equals (PropertyValue.Kind.ARRAY); ArrayList<PropertyValue> values = new ArrayList<PropertyValue> (array.getArray ()); values.remove (value); return PropertyValue.createArray (array.getType ().getComponentType (), values); }
public void run() { for (String propertyName : propertyNames) { PropertyValue pv = component.readProperty(propertyName); if (PropertyValue.Kind.USERCODE.equals(pv.getKind())) { isUC[0] = true; break; } } } });
public static PropertyValue setArrayValue (PropertyValue array, int index, PropertyValue value) { assert array != null && value != null; assert array.getKind ().equals (PropertyValue.Kind.ARRAY); TypeID componentType = array.getType ().getComponentType (); assert value.isCompatible (componentType); ArrayList<PropertyValue> values = new ArrayList<PropertyValue> (array.getArray ()); values.set (index, value); return PropertyValue.createArray (componentType, values); }
public static PropertyValue addArrayValue (PropertyValue array, int index, PropertyValue value) { assert array != null && value != null; assert array.getKind ().equals (PropertyValue.Kind.ARRAY); TypeID componentType = array.getType ().getComponentType (); assert value.isCompatible (componentType); ArrayList<PropertyValue> values = new ArrayList<PropertyValue> (array.getArray ()); values.add (index, value); return PropertyValue.createArray (componentType, values); }
public static PropertyValue addArrayValue (PropertyValue array, PropertyValue value) { assert array != null && value != null; assert array.getKind ().equals (PropertyValue.Kind.ARRAY); TypeID componentType = array.getType ().getComponentType (); assert value.isCompatible (componentType); ArrayList<PropertyValue> values = new ArrayList<PropertyValue> (array.getArray ()); values.add (value); return PropertyValue.createArray (componentType, values); }
public void run() { List<String> propertyNames = element.getPropertyValueNames(); for (String propertyName : propertyNames) { PropertyValue pv = component.readProperty(propertyName); if (PropertyValue.Kind.USERCODE.equals(pv.getKind())) { component.writeProperty(propertyName, component.getComponentDescriptor().getPropertyDescriptor(propertyName).getDefaultValue()); } } } });