void selectComponentsHappened (Collection<DesignComponent> oldSelection, Collection<DesignComponent> newSelection) { assert Debug.isFriend (DesignDocument.class, "setSelectedComponents"); // NOI18N assert assertEventAllowed; listenerManager.setSelectionChanged (); undoableEditHappened (new SelectionEdit (document, oldSelection, newSelection)); }
@Override public Result postInitialize (DesignDocument document, DesignComponent ifCallPoint) { DesignComponent trueCase = document.createComponent (IfTrueEventSourceCD.TYPEID); ifCallPoint.addComponent (trueCase); ifCallPoint.writeProperty (IfPointCD.PROP_TRUE, PropertyValue.createComponentReference (trueCase)); DesignComponent falseCase = document.createComponent (IfFalseEventSourceCD.TYPEID); ifCallPoint.addComponent (falseCase); ifCallPoint.writeProperty (IfPointCD.PROP_FALSE, PropertyValue.createComponentReference (falseCase)); return new Result (ifCallPoint, trueCase, falseCase); }
/** * Checks whether a specified component is referenced from the main tree of components under document root. * @param referenceComponent the reference component * @return true, if the reference component is referenced */ public static boolean isComponentReferencedInRootTree (DesignComponent referenceComponent) { assert referenceComponent != null; return isComponentReferencedInRootTree (referenceComponent.getDocument ().getRootComponent (), referenceComponent); }
private boolean removeGauge(DesignComponent ac) { DesignComponent gauge = ac.readProperty(AlertCD.PROP_INDICATOR).getComponent(); if (gauge == null) { ac.writeProperty(AlertCD.PROP_INDICATOR, NULL_VALUE); PropertyEditorAlertIndicator.super.setValue(NULL_VALUE); return false; } ac.writeProperty(AlertCD.PROP_INDICATOR, PropertyValue.createNull()); ac.getDocument().deleteComponent(gauge); PropertyEditorAlertIndicator.super.setValue(NULL_VALUE); return false; }
public static String resolveDisplayName (DesignComponent component) { PropertyValue value = component.readProperty (ClassCD.PROP_INSTANCE_NAME); if (value.getKind () == PropertyValue.Kind.VALUE && MidpTypes.TYPEID_JAVA_LANG_STRING.equals (value.getType ())) return (String) value.getPrimitiveValue (); Debug.warning("Invalid instance name ", value, "for component", component); // NOI18N return null; }
public String getEditableName (DesignComponent component) { DesignComponent refComponent = component.readProperty(PROP_COMMAND).getComponent(); if (refComponent == null || refComponent.readProperty(ClassCD.PROP_INSTANCE_NAME) == null) { Debug.warning("EventSource referenced " + component.toString() + " is null "); //NOI18N return null; } String name = (String) refComponent.readProperty(ClassCD.PROP_INSTANCE_NAME).getPrimitiveValue (); return name; }
private static void selectComponent(final DesignComponent selectedCommandSource) { final DesignDocument document = selectedCommandSource.getDocument(); document.getTransactionManager().writeAccess(new Runnable() { public void run() { document.setSelectedComponents(null, Collections.singleton(selectedCommandSource)); } }); }
private static String createDataSetName(String name, DesignComponent c) { DescriptorRegistry registry = c.getDocument().getDescriptorRegistry(); if (registry.isInHierarchy(IndexableDataAbstractSetCD.TYPEID, c.getType())) { name = name + " " + INDEXABLE; //NOI18N } else if (registry.isInHierarchy(DataSetAbstractCD.TYPEID, c.getType())) { name = name + " " + DATASET; //NOI18N } return name; }
private static void collectUsedReferences (HashSet<DesignComponent> referencedComponents, DesignComponent component) { ComponentDescriptor descriptor = component.getComponentDescriptor (); Collection<PropertyDescriptor> propertyDescriptors = descriptor.getPropertyDescriptors (); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (! propertyDescriptor.isUseForSerialization ()) continue; PropertyValue propertyValue = component.readProperty (propertyDescriptor.getName ()); Debug.collectAllComponentReferences (propertyValue, referencedComponents); } }
public static void addEventSource(DesignComponent component, String propertyName, DesignComponent eventSource) { component.addComponent(eventSource); PropertyValue sources = component.readProperty(propertyName); sources = PropertyValueSupport.addArrayValue(sources, PropertyValue.createComponentReference(eventSource)); component.writeProperty(propertyName, sources); }
@Override final void setNotifyDetached (DesignComponent component) { super.setNotifyDetached (component); if (listener != null) component.getDocument ().getListenerManager ().removeDesignListener (listener); state = State.REMOVING_DEPENDENCIES; notifyDetached (component); state = State.DISABLED; }
public String getEditableName(DesignComponent component) { if (component == null) throw Debug.error ("Component cannot be null"); // NOI18N return (String) component.readProperty(ClassCD.PROP_INSTANCE_NAME).getPrimitiveValue(); }
public void run() { for (String propertyName : propertyNames) { PropertyValue pv = component.readProperty(propertyName); if (PropertyValue.Kind.USERCODE.equals(pv.getKind())) { isUC[0] = true; break; } } } });
static ComponentProducer createDefault (ComponentDescriptor descriptor) { PaletteDescriptor paletteDescriptor = descriptor.getPaletteDescriptor (); TypeID typeid = descriptor.getTypeDescriptor ().getThisType (); if (paletteDescriptor == null) return null; return new ComponentProducer (typeid.toString (), typeid, paletteDescriptor) { public Boolean checkValidity(DesignDocument document, boolean useCachedValue) { return true; } }; }
void parentChangeHappened (DesignComponent previousParent, DesignComponent parent, DesignComponent child) { assert Debug.isFriend (DesignComponent.class, "addComponent") || Debug.isFriend (DesignComponent.class, "removeComponent"); // NOI18N assert assertEventAllowed; listenerManager.addAffectedComponentHierarchy (previousParent); listenerManager.addAffectedComponentHierarchy (parent); listenerManager.addAffectedComponentHierarchy (child); undoableEditHappened (new SetParentEdit (previousParent, parent, child)); }
void writePropertyHappened (DesignComponent component, String propertyName, PropertyValue oldValue, PropertyValue newValue) { assert Debug.isFriend (DesignComponent.class, "writeProperty"); // NOI18N assert assertEventAllowed; listenerManager.addAffectedDesignComponent (component, propertyName, oldValue); undoableEditHappened (new WritePropertyEdit (component, propertyName, oldValue, newValue)); }
protected synchronized void insideActionPerformed(final DesignComponent unusedCommandComponent) { final DesignDocument document = unusedCommandComponent.getDocument(); document.getTransactionManager().writeAccess(new Runnable() { public void run() { selectedCommandSource = MidpDocumentSupport.attachCommandToDisplayable(getComponent(), unusedCommandComponent); } }); selectComponent(selectedCommandSource); selectedCommandSource = null; } };
protected boolean isAcceptDenied (DesignComponent targetComponent, TypeID acceptingTypeID) { DescriptorRegistry registry = targetComponent.getDocument().getDescriptorRegistry(); if (registry.isInHierarchy (ListEventHandlerCD.TYPEID, acceptingTypeID)) { if (! registry.isInHierarchy (CommandEventSourceCD.TYPEID, targetComponent.getType ()) || targetComponent.getParentComponent () == null || ! registry.isInHierarchy (ListCD.TYPEID, targetComponent.getParentComponent ().getType ())) return true; } return false; }
@Override public Result postInitialize (DesignDocument document, DesignComponent entryPoint) { DesignComponent eventSource = document.createComponent (EntryStartEventSourceCD.TYPEID); entryPoint.addComponent (eventSource); entryPoint.writeProperty (EntryPointCD.PROP_START, PropertyValue.createComponentReference (eventSource)); return new Result (entryPoint, eventSource); }
protected synchronized void insideActionPerformed(final DesignComponent unusedCommandComponent) { final DesignDocument document = unusedCommandComponent.getDocument(); document.getTransactionManager().writeAccess(new Runnable() { public void run() { selectedCommandSource = MidpDocumentSupport.attachCommandToItem(getComponent(), unusedCommandComponent); } }); selectComponent(selectedCommandSource); selectedCommandSource = null; } };