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()]); }
synchronized void refreshDescriptorRegistry() { if (activeDocument == null || activeDocument.get() == null) { return; } String projectType = activeDocument.get().getDocumentInterface().getProjectType(); ComponentSerializationSupport.refreshDescriptorRegistry(projectType); }
synchronized void clean() { if (activeDocument == null || activeDocument.get() == null) { return; } String projectID = activeDocument.get().getDocumentInterface().getProjectID(); String projectType = activeDocument.get().getDocumentInterface().getProjectType(); final DescriptorRegistry registry = DescriptorRegistry.getDescriptorRegistry(projectType, projectID); registry.readAccess(new Runnable() { public void run() { List<ComponentProducer> list = registry.getComponentProducers(); Map<String, ComponentProducer> producers = new HashMap<String, ComponentProducer>(list.size()); for (ComponentProducer producer : list) { producers.put(producer.getProducerID(), producer); } cleanCore(producers); } }); }
public void activeDocumentChanged(DesignDocument deactivatedDocument, DesignDocument activatedDocument) { if (activatedDocument == null) { return; } String oldProjectID = activeProjectID; activeProjectID = activatedDocument.getDocumentInterface().getProjectID(); boolean isProjectIDChanged = !activeProjectID.equals(oldProjectID); if (isProjectIDChanged) { MidpJavaSupport.getCache(activatedDocument).updateCacheInternally(); } }
/** * @return instance of JavaClassNameResolver for given DesignDocument, creates it * if doesn't exist */ public synchronized static MidpJavaSupport getCache(DesignDocument document) { if (instanceMap == null) { instanceMap = new HashMap<String, MidpJavaSupport>(1); validationRP = new RequestProcessor("VMD MIDP ClassPath validation"); // NOI18N } String projectID = document.getDocumentInterface().getProjectID(); MidpJavaSupport instance = instanceMap.get(projectID); if (instance == null) { instance = new MidpJavaSupport(document); instanceMap.put(projectID, instance); } return instance; }
synchronized void init() { if (activeDocument == null || activeDocument.get() == null) { return; } if (requiresPaletteInit.getAndSet(true)) { return; } final String projectID = activeDocument.get().getDocumentInterface().getProjectID(); final String projectType = activeDocument.get().getDocumentInterface().getProjectType(); final DescriptorRegistry registry = DescriptorRegistry.getDescriptorRegistry(projectType, projectID); registry.readAccess(new Runnable() { public void run() { while (requiresPaletteInit.getAndSet(false)) { Collection<? extends PaletteProvider> providers = lookupResult.allInstances(); for (PaletteProvider provider : providers) { if (provider != null) { provider.initPaletteCategories(projectType); } } initCore(registry.getComponentProducers()); } } }); }
private boolean checkValidityByDeserializers (DesignDocument document) { String projectType = document.getDocumentInterface ().getProjectType (); for (ProducerDeserializer deserializer : result.allInstances ()) if (projectType.equals (deserializer.getProjectType ())) if (! deserializer.checkValidity (document, this)) return false; return true; }
String projectID = activeDocument.get().getDocumentInterface().getProjectID(); String projectType = activeDocument.get().getDocumentInterface().getProjectType(); final DescriptorRegistry registry = DescriptorRegistry.getDescriptorRegistry(projectType, projectID);
private void writeAccessRootEnd () { assertEventAllowed = false; DesignEvent event = null; try { if (rollback) rollbackCore (); event = listenerManager.fireEvent (); } finally { try { if (useUndoManager) { if (discardAllEdits) document.getDocumentInterface ().discardAllEdits (); else if (transactionEdit != null) { transactionEdit.end (); document.getDocumentInterface ().undoableEditHappened (transactionEdit); } } } finally { notRootLevelWriteAccess = false; if (event != null && event.isStructureChanged ()) document.getDocumentInterface ().notifyModified (); } } }
/** * Returns a data object context for specified document * @param document the design document * @return the data object context */ // TODO - should be hidden - used by ProjectUtils.getDataObjectContextForDocument method only public static synchronized DataObjectContext getDataObjectContextForDocumentInterface(DesignDocument document) { assert Debug.isFriend(ProjectUtils.class, "getDataObjectContextForDocument"); // NOI18N DocumentInterface documentInterface = document.getDocumentInterface(); for (DataObject dataObject : serializers.keySet()) { if (dataObject == null) { continue; } DocumentSerializer documentSerializer = getDocumentSerializer(dataObject); // TODO - use direct access to serializers field if (documentSerializer.hasDocumentInterface(documentInterface)) { return getDataObjectContext(dataObject); } } return null; }
public static PaletteController getPaletteController (DesignDocument document) { return PaletteMap.getInstance ().getPaletteKitForProjectType (document.getDocumentInterface ().getProjectType ()).getPaletteController (); }
final String projectID = doc.getDocumentInterface().getProjectID(); final String projectType = doc.getDocumentInterface().getProjectType(); final List<ComponentProducer> producers = new ArrayList<ComponentProducer>();
private void registerClassPathListener(DesignDocument document) { final Project project = ProjectUtils.getProject(document); final ClasspathInfo info = getClasspathInfo(project); if (info == null) { return; } String projID = document.getDocumentInterface().getProjectID(); if (!registeredProjects.contains(projID)) { Task<CompilationController> ct = new ListenerCancellableTask(info); try { JavaSource.create(info).runUserActionTask(ct, true); registeredProjects.add(projID); } catch (IOException ex) { Debug.warning(ex); } } }
private void updatePalette(DesignDocument document, boolean isProjectIDChanged) { if (isProjectIDChanged) { for (WeakReference<PaletteKit> kitReference : kitMap.values()) { PaletteKit kit = kitReference.get(); if (kit != null) { kit.clearNodesStateCache(); } } } if (document == null) { return; } WeakReference<PaletteKit> kitReference = kitMap.get(document.getDocumentInterface().getProjectType()); if (kitReference == null) { return; } PaletteKit kit = kitReference.get(); if (kit == null) { return; } kit.setActiveDocument(document); if (isProjectIDChanged) { scheduleUpdateAfteCPScanned(document, kit); } else { kit.init(); } }
/** * 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; }
public void activeDocumentChanged(DesignDocument deactivatedDocument, DesignDocument activatedDocument) { if (activatedDocument == null) { return; } DescriptorRegistry currentRegistry = activatedDocument.getDescriptorRegistry(); if (registeredRegistry != currentRegistry) { if (registeredRegistry != null) { registeredRegistry.removeRegistryListener(this); } registeredRegistry = currentRegistry; if (registeredRegistry != null) { registeredRegistry.addRegistryListener(this); } } String oldProjectID; synchronized (this) { oldProjectID = activeProjectID; activeProjectID = activatedDocument.getDocumentInterface().getProjectID(); } boolean isProjectIDChanged = !activeProjectID.equals(oldProjectID); if (isProjectIDChanged) { registerClassPathListener(activatedDocument); } updatePalette(activatedDocument, isProjectIDChanged); }
public static Transferable createTransferable (DesignDocument document, Lookup item) { ExTransferable transferable = ExTransferable.create (ExTransferable.EMPTY); PaletteMap.getInstance ().getPaletteKitForProjectType (document.getDocumentInterface ().getProjectType ()).getDndHandler ().customize (transferable, item); return transferable; }
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); } }
PresentersProcessor.postProcessDescriptor (document.getDocumentInterface ().getProjectType (), document, componentDescriptor, temp); presenters = Lookups.fixed(temp.toArray());
public void run() { if (propertyEditor != null && propertyEditor.isExecuteInsideWriteTransactionUsed()) { if (! propertyEditor.executeInsideWriteTransaction()) return; } for (String propertyName : values.getPropertyNames()) { if (values.getValue(propertyName) instanceof PropertyValue) { component.writeProperty(propertyName, (PropertyValue) values.getValue(propertyName)); continue; } if (values.getValue(propertyName) == null) component.writeProperty(propertyName, PropertyValue.createNull()); else if (values.getValue(propertyName) instanceof DesignComponent) { component.writeProperty(propertyName, PropertyValue.createComponentReference((DesignComponent) values.getValue(propertyName))); } else { component.writeProperty(propertyName, PropertyValue.createValue(component.getDocument().getDocumentInterface().getProjectType(), getComponentTypeID(component,propertyName) , values.getValue(propertyName))); } } } });