/** */ public void releaseFromRead() { if (!isShared()) { // this.document.releaseStyleSheets(); // this.document.releaseDocumentType(); } super.releaseFromRead(); }
/** * This function returns true if there are other references to the * underlying model. */ public boolean isShared() { return (getStyleSheetType() == EXTERNAL) && super.isShared(); }
/** */ public void releaseFromEdit() { if (!isShared()) { // this.document.releaseStyleSheets(); // this.document.releaseDocumentType(); } super.releaseFromEdit(); }
public void uninitializeFactoryRegistry(FactoryRegistry registry) { Assert.isNotNull(registry); // ISSUE: should these factories be released? Or just // removed from this registry, because we are getting ready to // re-add them? INodeAdapterFactory factory = null; if (!registry.contains(DocumentTypeAdapter.class)) { factory = registry.getFactoryFor(DocumentTypeAdapter.class); factory.release(); registry.removeFactory(factory); } if (!registry.contains(ModelParserAdapter.class)) { factory = registry.getFactoryFor(ModelParserAdapter.class); factory.release(); registry.removeFactory(factory); } if (!registry.contains(IStyleSelectorAdapter.class)) { factory = registry.getFactoryFor(IStyleSelectorAdapter.class); factory.release(); registry.removeFactory(factory); } if (!registry.contains(IStyleSheetAdapter.class)) { factory = registry.getFactoryFor(IStyleSheetAdapter.class); factory.release(); registry.removeFactory(factory); } }
/** * setStructuredDocument method * * @param structuredDocument */ public void setStructuredDocument(IStructuredDocument structuredDocument) { IStructuredDocument oldStructuredDocument = super.getStructuredDocument(); if (structuredDocument == oldStructuredDocument) return; // nothing to do if (oldStructuredDocument != null) oldStructuredDocument.removeDocumentChangingListener(this); super.setStructuredDocument(structuredDocument); if (structuredDocument != null) { internalSetNewDocument(structuredDocument); structuredDocument.addDocumentChangingListener(this); } }
protected void preLoadAdapt(IStructuredModel structuredModel) { super.preLoadAdapt(structuredModel); IDOMModel domModel = (IDOMModel) structuredModel; // if there is a model in the adapter, this will adapt it to // first node. After that the PropagatingAdater spreads over the // children being // created. Each time that happends, a side effect is to // also "spread" sprecific registered adapters, // they two can propigate is needed. ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); if (Debug.debugNotificationAndEvents) { PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory()); } }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if ((oldInput != null) && (oldInput instanceof IStructuredModel)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) oldInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.removeListener(viewer); } } if ((newInput != null) && (newInput instanceof IStructuredModel)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) newInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.addListener(viewer); } } } }
public IStructuredDocument getStructuredDocument() { IStructuredDocument structuredDocument = null; structuredDocument = super.getStructuredDocument(); if (structuredDocument != null) return structuredDocument; // the first time Assert.isNotNull(getModelHandler()); structuredDocument = (IStructuredDocument) getModelHandler().getDocumentLoader().createNewStructuredDocument(); setStructuredDocument(structuredDocument); return structuredDocument; }
public Object getAdapter(Class adapter) { if (Document.class.equals(adapter)) return getDocument(); return super.getAdapter(adapter); }
public void aboutToReinitializeModel() { XMLModelNotifier notifier = getModelNotifier(); notifier.cancelPending(); super.aboutToReinitializeModel(); }
/** * This API allows clients to declare that they are about to make a * "large" change to the model. This change might be in terms of content * or it might be in terms of the model id or base location. * * Note that in the case of embedded calls, notification to listners is * sent only once. * * Note that the client who is making these changes has the responsibility * to restore the models state once finished with the changes. See * getMemento and restoreState. * * The method isModelStateChanging can be used by a client to determine if * the model is already in a change sequence. */ public void aboutToChangeModel() { super.aboutToChangeModel(); // technically, no need to call beginChanging so often, // since aboutToChangeModel can be nested. // but will leave as is for this release. // see modelChanged, and be sure stays coordinated there. getModelNotifier().beginChanging(); }
public void processPreModelEvent(ModelLifecycleEvent event) { if (!isSaving) { if (event.getType() == ModelLifecycleEvent.MODEL_SAVED) { ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) resource.getResourceSet()).getSynchronizer(); IFile aFile = WorkbenchResourceHelper.getFile(resource); synchronizer.preSave(aFile); } } }
public IStructuredModel reinitialize(IStructuredModel model) { EmbeddedTypeHandler oldHandler = null; EmbeddedTypeHandler newHandler = null; Object reinitStateData = model.getReinitializeStateData(); if (reinitStateData instanceof EmbeddedTypeStateData) { EmbeddedTypeStateData oldStateData = (EmbeddedTypeStateData) reinitStateData; oldHandler = oldStateData.getOldHandler(); newHandler = oldStateData.getNewHandler(); // note. We should already have the new handler in the model's // (documents) adapters, // so need need to use the old one to undo the old state data reInitializeEmbeddedType(model, oldHandler, newHandler); } else { // for language ... we someday MIGHT have to do something // here, but for now, we don't have any model-side language // sensitive adapters. } return super.reinitialize(model); }
/** * */ public void beginRecording(Object requester, String label, String description) { getStyleNotifier().beginRecording(); Node node = getOwnerDOMNode(); if (node != null && node instanceof IDOMNode) { IStructuredModel model = ((IDOMNode) node).getModel(); if (model != null) { model.beginRecording(requester, label, description); return; } } super.beginRecording(requester, label, description); }
/** * */ public void endRecording(Object requester) { Node node = getOwnerDOMNode(); if (node != null && node instanceof IDOMNode) { IStructuredModel model = ((IDOMNode) node).getModel(); if (model != null) { model.endRecording(requester); return; } } super.endRecording(requester); getStyleNotifier().endRecording(); }
public IStructuredModel createModel(IStructuredModel oldModel) { IStructuredModel model = super.createModel(oldModel); // For JSPs, the ModelQueryAdapter must be "attached" to the document // before content is set in the model, so taglib initization can // take place. // In this "clone model" case, we create a ModelQuery adapter // create a new instance from the old data. Note: I think this // "forced fit" only works here since the implimentaiton of // ModelQueryAdatper does not // have to be released. ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(model); if (modelQueryAdapter == null) { modelQueryAdapter = getModelQueryAdapter(oldModel); IDOMDocument document = ((IDOMModel) model).getDocument(); document.addAdapter(new JSPModelQueryAdapterImpl(modelQueryAdapter.getCMDocumentCache(), modelQueryAdapter.getModelQuery(), modelQueryAdapter.getIdResolver())); } return model; }
public void setStructuredDocument(IStructuredDocument newStructuredDocument) { IStructuredDocument oldStructuredDocument = super.getStructuredDocument(); if (newStructuredDocument == oldStructuredDocument) return; // noting to do if (oldStructuredDocument != null) oldStructuredDocument.removeDocumentChangingListener(this); super.setStructuredDocument(newStructuredDocument); if (newStructuredDocument != null) { if (newStructuredDocument.getLength() > 0) { newModel(new NewDocumentEvent(newStructuredDocument, this)); } newStructuredDocument.addDocumentChangingListener(this); } }
protected void preLoadAdapt(IStructuredModel structuredModel) { super.preLoadAdapt(structuredModel); // DMW: just added this preload on 8/16/2002 // I noticed the ProagatingAdapterFactory was being added, // that that the ProagatingAdapterAdapter was not being // preload adapted -- I'm assuing it ALWAYS has to be. IDOMModel domModel = (IDOMModel) structuredModel; // if there is a model in the adapter, this will adapt it to // first node. After that the PropagatingAdater spreads over the // children being // created. Each time that happends, a side effect is to // also "spread" sprecific registered adapters, // they two can propigate is needed. ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); if (Debug.debugNotificationAndEvents) { PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory()); } }
/** * */ public void releaseFromRead() { closeImported(); if (getStyleSheetType() == EXTERNAL) { super.releaseFromRead(); } }
/** * */ public void releaseFromEdit() { closeImported(); if (getStyleSheetType() == EXTERNAL) { super.releaseFromEdit(); } }