static String getAttributeValue (Node node, String attr) { try { if (node != null) { NamedNodeMap map = node.getAttributes (); if (map != null) { node = map.getNamedItem (attr); if (node != null) return node.getNodeValue (); } } } catch (DOMException e) { Debug.warning (e); } return null; }
public ListElementEventSourceCategoryPC(TypeID typeID) { if (typeID == null) throw Debug.error ("Argument typID cant be null"); //NOI18N this.typeID = typeID; }
/** * Returns data object interface for specified data object. * DataObject must implement DataObjectInterface. * @param dataObject the data object * @return the data object interface */ public static DataObjectInterface getDataObjectInteface(DataObject dataObject) { if (!(dataObject instanceof DataObjectInterface)) { throw Debug.illegalArgument("DataObject does not implement DataObjectInterface", dataObject); // NOI18N } return (DataObjectInterface) dataObject; }
void collectAllComponentReferences(Collection<DesignComponent> references) { assert Debug.isFriend(DesignComponent.class, "writeProperty") || Debug.isFriend(DesignComponent.class, "setComponentDescriptor") || Debug.isFriend(PropertyValue.class, "collectAllComponentReferences") || Debug.isFriend(Debug.class, "collectAllComponentReferences"); // NOI18N switch (kind) { case USERCODE: case NULL: case VALUE: case ENUM: return; case REFERENCE: references.add(component); return; case ARRAY: if (type.getKind() == TypeID.Kind.COMPONENT) { for (PropertyValue propertyValue : array) { propertyValue.collectAllComponentReferences(references); } } return; } Debug.error("Invalid state", this); // NOI18N }
public static String loadProjectType(DataObjectContext context) { final Node rootNode; try { rootNode = getRootNode(IOSupport.getDesignFile(context)); if (rootNode == null) { Debug.warning("Mobility: Root not not fould"); // NOI18N return ""; //NOI18N } } catch (IOException e) { throw Debug.error(e); } return getAttributeValue(rootNode, DocumentSave.PROP_PROJECT_TYPE); } }
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; }
public String getDisplayName (DesignComponent component, NameType nameType) { switch (nameType) { case PRIMARY: return displayName; case SECONDARY: return typeName; case TERTIARY: return toolTip; default: throw Debug.illegalState (); } }
@Override public Collection<DesignComponent> getChildren() { PropertyValue itemsValue = getComponent().readProperty(FormCD.PROP_ITEMS); ArrayList<DesignComponent> items = new ArrayList<DesignComponent>(); Debug.collectAllComponentReferences(itemsValue, items); return items; }
void setNotifyAttached (DesignComponent component) { assert Debug.isFriend (ListenerManager.class, "addComponentDescriptorChanged") || Debug.isFriend (DynamicPresenter.class, "setNotifyAttached"); // NOI18N assert this.contentComponent == null && component != null; this.contentComponent = component; }
boolean isAffected (DesignDocument document, DesignEvent event) { assert Debug.isFriend (ListenerManager.class, "fireEventCore") || Debug.isFriend (DesignEventFilter.class, "isAffected"); // NOI18N Debug.collectAllComponentReferences (value, item.components = new HashSet<DesignComponent> ());
private static boolean isComponentReferencedInRootTree (DesignComponent treeComponent, DesignComponent referenceComponent) { ArrayList<DesignComponent> referenced = new ArrayList<DesignComponent> (); ComponentDescriptor descriptor = treeComponent.getComponentDescriptor (); if (descriptor != null) { for (PropertyDescriptor propertyDescriptor : descriptor.getPropertyDescriptors ()) { PropertyValue propertyValue = treeComponent.readProperty (propertyDescriptor.getName ()); referenced.clear (); Debug.collectAllComponentReferences (propertyValue, referenced); if (referenced.contains (referenceComponent)) return true; } } for (DesignComponent child : treeComponent.getComponents ()) if (isComponentReferencedInRootTree (child, referenceComponent)) return true; return false; }
public static boolean load(DataObjectContext context, DesignDocument loadingDocument, DocumentErrorHandler errorHandler) { final Node rootNode; try { rootNode = getRootNode(IOSupport.getDesignFile(context)); } catch (IOException e) { throw Debug.error(e); } if (rootNode == null) { Debug.warning("Mobility: Root not not fould"); // NOI18N return false; } if (!DocumentSave.VERSION_VALUE_1.equals(getAttributeValue(rootNode, DocumentSave.VERSION_ATTR))) { Debug.warning("Invalid version of VisualDesign"); // NOI18N errorHandler.addWarning(WRONG_VERSION_ERROR); return false; } return loadVersion1(context, loadingDocument, rootNode, errorHandler); }
protected void delete() { throw Debug.illegalState(); } };
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 }
@Override public Collection<DesignComponent> getChildren() { PropertyValue elementsValue = getComponent().readProperty(ListCD.PROP_ELEMENTS); List<DesignComponent> elements = new ArrayList<DesignComponent>(); Debug.collectAllComponentReferences(elementsValue, elements); return elements; }
TransactionManager (DesignDocument document, DescriptorRegistry descriptorRegistry, ListenerManager listenerManager) { assert Debug.isFriend (DesignDocument.class, "<init>"); // NOI18N this.document = document; this.descriptorRegistry = descriptorRegistry; this.listenerManager = listenerManager; }
static String getAttributeValue (Node node, String attr) { try { if (node != null) { NamedNodeMap map = node.getAttributes (); if (map != null) { node = map.getNamedItem (attr); if (node != null) return node.getNodeValue (); } } } catch (DOMException e) { Debug.warning (e); } return null; }
public ComponentsCategoryPC(TypeID typeID) { if (typeID == null) throw Debug.error ("Argument typID cant be null"); //NOI18N this.typeID = typeID; }
public void createConnection (FlowPinDescriptor sourcePin, FlowDescriptor target) { throw Debug.illegalState (); // TODO // MidpDocumentSupport.updateEventHandlerFromTarget (getComponent (), target != null ? target.getRepresentedComponent () : null); }
/** * This method allows to create all Custom Editor UI element at the moment when it is really need it. * In getCustomEditor method. To make this method work you need to also override * * @param type * @param newComponentAsText * @param noneComponentAsText * @param userCodeLabel * @param databinding */ private PropertyEditorResource(TypeID type, String newComponentAsText, String noneComponentAsText, String userCodeLabel, boolean databinding) { super(userCodeLabel); this.databinding = databinding; if (newComponentAsText == null || noneComponentAsText == null) { throw Debug.illegalArgument("Argument can not be null"); //NOI18N } if (newComponentAsText.equals(noneComponentAsText)) { throw Debug.illegalArgument("Arguments can not be equal"); //NOI18N } this.componentTypeID = type; this.newComponentAsText = newComponentAsText; this.noneComponentAsText = noneComponentAsText; createdComponents = new HashMap<String, DesignComponent>(); }