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); } }); }
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 (); } } }
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 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(); } }
synchronized void refreshDescriptorRegistry() { if (activeDocument == null || activeDocument.get() == null) { return; } String projectType = activeDocument.get().getDocumentInterface().getProjectType(); ComponentSerializationSupport.refreshDescriptorRegistry(projectType); }
/** * @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; }
/** * Creates an instance of document. * @param documentInterface the documentInterface interface */ public DesignDocument (DocumentInterface documentInterface) { this.documentInterface = documentInterface; descriptorRegistry = DescriptorRegistry.getDescriptorRegistry (documentInterface.getProjectType (), documentInterface.getProjectID ()); listenerManager = new ListenerManager (this); transactionManager = new TransactionManager (this, descriptorRegistry, listenerManager); uid2components = new HashMap<Long, TimedWeakReference> (100); componentIDCounter = 0; selectedComponents = Collections.emptySet (); descriptorRegistry.addRegistryListener (new DescriptorRegistryListener() { public void descriptorRegistryUpdated () { updateDescriptorReferences (); } }); }
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; }
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); } } }
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()); } } }); }
public static PaletteController getPaletteController (DesignDocument document) { return PaletteMap.getInstance ().getPaletteKitForProjectType (document.getDocumentInterface ().getProjectType ()).getPaletteController (); }
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); }
String projectID = activeDocument.get().getDocumentInterface().getProjectID(); String projectType = activeDocument.get().getDocumentInterface().getProjectType(); final DescriptorRegistry registry = DescriptorRegistry.getDescriptorRegistry(projectType, projectID);
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(); } }
String projectID = activeDocument.get().getDocumentInterface().getProjectID(); String projectType = activeDocument.get().getDocumentInterface().getProjectType();
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();
final String projectID = doc.getDocumentInterface().getProjectID(); final String projectType = doc.getDocumentInterface().getProjectType(); final List<ComponentProducer> producers = new ArrayList<ComponentProducer>();
/** * 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; }
Collection<FileObject> collection = resolver.getResourceRoots(project, document.getDocumentInterface().getProjectType()); if (collection == null) continue;
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; }