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 Action[] getImportActions() { if (activeDocument == null || activeDocument.get() == null) { return null; } String projectType = activeDocument.get().getDocumentInterface().getProjectType(); Collection<? extends PaletteProvider> providers = Lookup.getDefault().lookupAll(PaletteProvider.class); ArrayList<Action> actions = new ArrayList<Action>(); for (PaletteProvider paletteProvider : providers) { List<? extends Action> list = paletteProvider.getActions(projectType); if (list != null) { actions.addAll(list); } } return actions.toArray(new Action[actions.size()]); }
public void resetModelModifiedStatus (DesignDocument document) { if (this.document == null && document != null) { this.document = document; this.documentState = document.getListenerManager ().getDocumentState (); } }
public static DesignComponent addSprite(DesignDocument document) { DesignComponent rootComponent = document.getRootComponent(); DesignComponent sprite = document.createComponent(SpriteCD.TYPEID); rootComponent.addComponent(sprite); // TODO - initialize sprite return sprite; }
public void run () { activatedDocument.getListenerManager ().addDesignListener (selectionListener = new SelectionDesignListener (activatedDocument), FILTER_SELECTION); fireActiveComponentsChanged (activatedDocument.getSelectedComponents ()); } });
/** * Returns a component descriptor. * @return the compatible descriptor, null if not assigned */ public ComponentDescriptor getComponentDescriptor() { assert document.getTransactionManager().isAccess(); return componentDescriptor; }
private static Collection<DesignComponent> gatherAllComponentsToDelete (DesignDocument document, Collection<DesignComponent> baseComponents) { HashSet<DesignComponent> componentsToDelete = new HashSet<DesignComponent> (baseComponents); Collection<DesignComponent> componentsToDeleteUm = Collections.unmodifiableCollection (componentsToDelete); while (findNewlyRequired (document.getRootComponent (), componentsToDelete, componentsToDeleteUm)) ; return componentsToDelete; }
/** * This method should be called for notifying others that the presenter changed its data. * <p/> * Note: This method could be called from designChanged and presenterChanged method only. */ protected final void firePresenterChanged () { DesignComponent component = getComponent (); assert component != null; DesignDocument document = component.getDocument (); assert document != null; assert document.getTransactionManager ().isWriteAccess (); assert state == State.FIRING_PRESENTER_CHANGED; document.getListenerManager ().firePresenterChanged (this); }
loadingDocument.setPreferredComponentID(componentid); if (loadingDocument.getDescriptorRegistry().getComponentDescriptor(element.getTypeID()) == null) { if (element.getUID() == 0) { Debug.warning("Missing ComponentDescriptor in registry ", element.getTypeID()); // NOI18N return; DesignComponent component = loadingDocument.createRawComponent(element.getTypeID()); assert component.getComponentID() == componentid; assert component.getComponentDescriptor() != null; DesignComponent parent = loadingDocument.getComponentByUID(parentuid); DesignComponent component = loadingDocument.getComponentByUID(element.getUID()); if (component == null) { continue; DesignComponent component = loadingDocument.getComponentByUID(element.getUID()); if (component == null) { continue; DesignComponent componentByUID = loadingDocument.getComponentByUID(0); if (componentByUID != null) { loadingDocument.setRootComponent(componentByUID);
public void run() { if (true) { //add all components in the document DesignComponent root = designDocument.getRootComponent(); GameController.this.modelComponent(root); GameController.this.registerListeners(designIdMap.keySet().toArray()); DesignEventFilter f = new DesignEventFilter(); f.setGlobal(true); f.addComponentFilter(root, true); designDocument.getListenerManager().addDesignListener(GameController.this, f); } } });
public DesignComponent createReuseEventHandler (DesignComponent eventSource, DesignComponent currentEventHandler, DesignComponent targetComponent) { if (currentEventHandler == null || ! getComponent ().getDocument ().getDescriptorRegistry ().isInHierarchy (CallPointEventHandlerCD.TYPEID, currentEventHandler.getType ())) currentEventHandler = getComponent ().getDocument ().createComponent (CallPointEventHandlerCD.TYPEID); currentEventHandler.writeProperty (CallPointEventHandlerCD.PROP_CALL_POINT, PropertyValue.createComponentReference (targetComponent)); return currentEventHandler; } };
public void designChanged (DesignEvent event) { fireActiveComponentsChanged (document.getSelectedComponents ()); } }
public static void save (DataObjectContext context, DesignDocument savingDocument) { Document xml = XMLUtil.createDocument (XML_ROOT_NODE, null, null, null);// TODO - NS, DTD Node xmlRootNode = xml.getFirstChild (); setAttribute (xml, xmlRootNode, VERSION_ATTR, VERSION_VALUE_1); String projectType = savingDocument.getDocumentInterface ().getProjectType (); setAttribute (xml, xmlRootNode, PROP_PROJECT_TYPE, projectType); Node node = xml.createElement (DOCUMENT_NODE); setAttribute (xml, node, VERSION_ATTR, ProjectTypeInfo.getProjectTypeInfoFor (projectType).getDocumentVersion ()); checkDocumentValidity (savingDocument); saveComponent (xml, node, savingDocument.getRootComponent ()); xmlRootNode.appendChild (node); for (DataSerializer serializer : customDataSerializers.allInstances ()) { Node data = serializer.serializeData (context, savingDocument, xml); if (data != null) xml.getFirstChild ().appendChild (data); } try { writeDocument (IOSupport.getDesignFile (context), xml); } catch (IOException e) { throw Debug.error (e); } }
private void reportComponentProperty (DefaultListModel list, DesignComponent component, String propertyName) { DescriptorRegistry registry = component.getDocument ().getDescriptorRegistry (); if (registry.isInHierarchy (ItemCD.TYPEID, component.getType ())) { if (ItemCD.PROP_ITEM_COMMAND_LISTENER.equals (propertyName)) return; if (ItemCD.PROP_COMMANDS.equals (propertyName)) { list.addElement (NbBundle.getMessage(Midp1CompliantAnalyzer.class, "MSG_ItemsCommandsNotAllowed", InfoPresenter.getHtmlDisplayName (component))); // NOI18N return; } } list.addElement (NbBundle.getMessage(Midp1CompliantAnalyzer.class, "MSG_IncompatiblePropertyValue", propertyName, InfoPresenter.getHtmlDisplayName (component))); // NOI18N }
public void run() { for (Object selected : selectedElements) { if (! (selected instanceof Long)) continue; DesignComponent resource = document.getComponentByUID((Long) selected); if (resource != null) DeleteSupport.invokeDirectUserDeletion (document, Collections.singleton (resource), false); ((DefaultListModel) resourcesList.getModel()).removeElement(selected); } } });
/** * Creates a new component using a component descriptor with specified typeid. * <p> * Note: It does not add the component into a tree, you have to do it manually. * @param componentType the component typeid * @return the new component */ public DesignComponent createComponent (TypeID componentType) { DesignComponent component = createRawComponent (componentType); assert component != null; performComponentPostInit (component, component.getComponentDescriptor ()); PostInitializeProcessor.postInitializeComponent(getDocumentInterface().getProjectType(), component); return component; }
if (document.getComponentByUID(componentID) == null) { throw new IllegalArgumentException("No component for given serilezed value"); // NOI18N return createComponentReference(document.getComponentByUID(componentID)); PrimitiveDescriptor descriptor = PrimitiveDescriptorFactoryRegistry.getDescriptor(document.getDocumentInterface().getProjectType(), type); if (descriptor == null) { throw new IllegalArgumentException(); EnumDescriptor descriptor = EnumDescriptorFactoryRegistry.getDescriptor(document.getDocumentInterface().getProjectType(), type); if (descriptor == null) { throw new IllegalArgumentException();
public void run() { if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == MouseEvent.CTRL_DOWN_MASK) { // invert selection Collection<DesignComponent> currentSelection = doc.getSelectedComponents(); newSelection.addAll(currentSelection); if (currentSelection.contains(component)) { newSelection.remove(component); } else { newSelection.add(component); } } else { newSelection.add(component); } doc.setSelectedComponents(ScreenViewController.SCREEN_ID, newSelection); } });
public boolean isInside(InspectorFolderPath path, InspectorFolder folder, DesignComponent component) { int parentIndex = path.getPath().size() - 1; Long parentComponentID = path.getPath().get(parentIndex).getComponentID(); if (parentComponentID != null ) { DesignComponent parentComponent = component.getDocument().getComponentByUID(parentComponentID); if (! parentComponent.getComponents().contains(component)) return false; for (TypeID typeID : typeIDs) { if ( component.getDocument().getDescriptorRegistry().isInHierarchy(typeID, parentComponent.getType())) return true; } } return false; }
public void run() { if (document == null) { return; } document.setSelectedComponents(ScreenViewController.SCREEN_ID, Collections.<DesignComponent>emptySet()); } }