public static DesignComponent getCommandListener(DesignDocument document, TypeID listenerType) { DesignComponent controllersCategory = getCategoryComponent(document, ControllersCategoryCD.TYPEID); List<DesignComponent> list = DocumentSupport.gatherSubComponentsOfType(controllersCategory, listenerType); if (list.isEmpty()) { DesignComponent commandListener = document.createComponent(listenerType); controllersCategory.addComponent(commandListener); return commandListener; } assert list.size() == 1; return list.get(0); }
private void writeAnimatedTilesToImageResourceDC(DesignComponent dcImgRes, ImageResource imageResource) { for (AnimatedTile at : imageResource.getAnimatedTiles()) { DesignComponent dcAnimTile = designIdMap.get(at); if (dcAnimTile == null) { assert (!dcImgRes.getComponents().contains(dcAnimTile)); dcAnimTile = this.createAnimatedTileDCFromAnimatedTile(at); dcImgRes.addComponent(dcAnimTile); designIdMap.put(at, dcAnimTile); } } }
public static DesignComponent addTiledLayer(DesignDocument document) { //HINT -- here show a dialog to select an image DesignComponent rootComponent = document.getRootComponent(); DesignComponent tiledLayer = document.createComponent(TiledLayerCD.TYPEID); rootComponent.addComponent(tiledLayer); // TODO - initialize tiled layer return tiledLayer; }
@Override public void redo () throws CannotRedoException { super.redo (); if (oldParent != null) oldParent.removeComponent (child); if (newParent != null) newParent.addComponent (child); }
public static DesignComponent addSprite(DesignDocument document) { DesignComponent rootComponent = document.getRootComponent(); DesignComponent sprite = document.createComponent(SpriteCD.TYPEID); rootComponent.addComponent(sprite); // TODO - initialize sprite return sprite; }
@Override public void undo () throws CannotUndoException { super.undo (); if (newParent != null) newParent.removeComponent (child); if (oldParent != null) oldParent.addComponent (child); }
public static DesignComponent getCategoryComponent(DesignDocument document, TypeID categoryType) { List<DesignComponent> list = DocumentSupport.gatherSubComponentsOfType(document.getRootComponent(), categoryType); if (list.size () == 0 && document.getTransactionManager ().isWriteAccess ()) { DesignComponent categoryComponent = document.createComponent (categoryType); document.getRootComponent ().addComponent (categoryComponent); return categoryComponent; } assert list.size() == 1; return list.get(0); }
public void run() { DesignDocument doc = document; DesignComponent imgResDC = createImageResourceDCFromImageResource(imageResource); designIdMap.put(imageResource, imgResDC); changeMap.put(doc.getRootComponent().getComponentID(), imageResource.getName()); imageResource.addImageResourceListener(GameController.this); doc.getRootComponent().addComponent(imgResDC); } });
@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); }
@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); }
public void run() { DesignComponent sceneDC = createSceneDCFromScene(doc, designIdMap, scene); designIdMap.put(scene, sceneDC); changeMap.put(doc.getRootComponent().getComponentID(), scene.getName()); scene.addSceneListener(GameController.this); scene.addPropertyChangeListener(GameController.this); doc.getRootComponent().addComponent(sceneDC); } });
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); }
public static DesignComponent createIndex(DesignComponent indexableDataSet, String instanceName) { DesignComponent index = indexableDataSet.getDocument().createComponent(IndexableDataSetIndexCD.TYPEID); index.writeProperty(ClassCD.PROP_INSTANCE_NAME, InstanceNameResolver.createFromSuggested(index, instanceName)); //NOI18N indexableDataSet.addComponent(index); return index; }
public void run() { DesignDocument doc = document; DesignComponent tiledLayerDC = createTiledLayerDCFromTiledLayer(doc, designIdMap, tiledLayer); changeMap.put(doc.getRootComponent().getComponentID(), tiledLayer.getName()); tiledLayer.addTiledLayerListener(GameController.this); tiledLayer.addPropertyChangeListener(GameController.this); doc.getRootComponent().addComponent(tiledLayerDC); } });
@Override public final ComponentProducer.Result accept (ComponentProducer producer, AcceptSuggestion suggestion) { DesignDocument document = getComponent().getDocument(); DesignComponent resource = producer.createComponent(document).getMainComponent(); MidpDocumentSupport.getCategoryComponent(document, ResourcesCategoryCD.TYPEID).addComponent(resource); getComponent().writeProperty(typesMap.get(currentType), PropertyValue.createComponentReference(resource)); return new ComponentProducer.Result(resource); }
public static DesignComponent attachCommandToItem(DesignComponent item, DesignComponent command) { DesignComponent itemCommandEventSource = command.getDocument().createComponent(ItemCommandEventSourceCD.TYPEID); itemCommandEventSource.writeProperty(ItemCommandEventSourceCD.PROP_COMMAND, PropertyValue.createComponentReference(command)); itemCommandEventSource.writeProperty(ItemCommandEventSourceCD.PROP_ITEM, PropertyValue.createComponentReference(item)); MidpArraySupport.append(item, ItemCD.PROP_COMMANDS, itemCommandEventSource); item.addComponent(itemCommandEventSource); return itemCommandEventSource; }
protected void actionPerformed () { DesignDocument document = getComponent ().getDocument (); DesignComponent resources = MidpDocumentSupport.getCategoryComponent (document, ResourcesCategoryCD.TYPEID); DesignComponent ticker = document.createComponent (TickerCD.TYPEID); resources.addComponent (ticker); getComponent ().writeProperty (DisplayableCD.PROP_TICKER, PropertyValue.createComponentReference (ticker)); }
protected void createConnector(DesignComponent dataSet, String propertyName) { DesignComponent connector = dataSet.getDocument().createComponent(DataSetConnectorCD.TYPEID); connector.writeProperty(DataSetConnectorCD.PROP_BINDED_PROPERTY, MidpTypes.createStringValue(propertyName)); connector.writeProperty(DataSetConnectorCD.PROP_COMPONENT_ID, MidpTypes.createLongValue(getComponent().getComponentID())); dataSet.addComponent(connector); getComponent().resetToDefault(propertyName); } }
@Override public final ComponentProducer.Result accept (ComponentProducer producer, AcceptSuggestion suggestion) { DesignComponent item = getComponent (); DesignDocument document = item.getDocument (); DesignComponent command = producer.createComponent (document).getMainComponent (); MidpDocumentSupport.getCategoryComponent (document, CommandsCategoryCD.TYPEID).addComponent (command); DesignComponent source = document.createComponent (ItemCommandEventSourceCD.TYPEID); MidpDocumentSupport.addEventSource (item, ItemCD.PROP_COMMANDS, source); source.writeProperty (ItemCommandEventSourceCD.PROP_ITEM, PropertyValue.createComponentReference (item)); source.writeProperty (ItemCommandEventSourceCD.PROP_COMMAND, PropertyValue.createComponentReference (command)); return new ComponentProducer.Result (item); }
@Override public final ComponentProducer.Result accept (ComponentProducer producer, AcceptSuggestion suggestion) { DesignComponent displayable = getComponent(); DesignDocument document = displayable.getDocument(); DesignComponent command = producer.createComponent(document).getMainComponent(); MidpDocumentSupport.getCategoryComponent(document, CommandsCategoryCD.TYPEID).addComponent(command); DesignComponent source = document.createComponent(CommandEventSourceCD.TYPEID); MidpDocumentSupport.addEventSource(displayable, DisplayableCD.PROP_COMMANDS, source); source.writeProperty(CommandEventSourceCD.PROP_DISPLAYABLE, PropertyValue.createComponentReference(displayable)); source.writeProperty(CommandEventSourceCD.PROP_COMMAND, PropertyValue.createComponentReference(command)); return new ComponentProducer.Result (source); }