private boolean hasHTMLFeature(IDOMDocument document) { DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class); if (adapter == null) return false; return adapter.hasFeature(HTMLDocumentTypeConstants.HTML); }
private ModelParserAdapter getParserAdapter() { return (ModelParserAdapter) this.model.getDocument().getAdapterFor(ModelParserAdapter.class); }
/** * Utility to check the model is HTML family or not */ static private boolean isHTMLFamily(IStructuredModel model) { if (model instanceof IDOMModel) { IDOMDocument document = ((IDOMModel) model).getDocument(); DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class); if (adapter != null) return adapter.hasFeature(HTMLDocumentTypeConstants.HTML); } return false; }
private static String getRootTagName(Document document) { DocumentTypeAdapter adapter = (DocumentTypeAdapter) ((IDOMDocument) document).getAdapterFor(DocumentTypeAdapter.class); if (adapter != null) { DocumentType docType = adapter.getDocumentType(); if (docType != null) { return docType.getName(); } } return HTML40Namespace.ElementName.HTML; } }
/** * @param label * @param document */ public DesignerCommand(String label, IDOMDocument document) { super(label); this._model = document.getModel(); EditPart part = (EditPart) document.getAdapterFor(EditPart.class); if (part != null) { this._viewer = (IHTMLGraphicalViewer) part.getViewer(); } } /**
private IDocumentPageVariableAdapter getDocumentAdapter( INodeNotifier notifier) { if (notifier instanceof IDOMNode) { IDOMModel model = ((IDOMNode) notifier).getModel(); if (model != null) { IDOMDocument document = model.getDocument(); if (document != null) { return (IDocumentPageVariableAdapter) document .getAdapterFor(IDocumentPageVariableAdapter.class); } } } return null; }
protected void setLanguageInPageDirective(IStructuredModel newModel) { if (newModel instanceof IDOMModel) { IDOMDocument document = ((IDOMModel) newModel).getDocument(); PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) document.getAdapterFor(PageDirectiveAdapter.class); String language = getLanguage(newModel); pageDirectiveAdapter.setLanguage(language); } }
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { // we should only be added to page directives, so if we see a page directive // change, we need to check its attributes, and notify the PageDirectiveAdapter when // certain ones chane, so it can make its "centralized" decisions. if (notifier instanceof IDOMNode) { switch (eventType) { case INodeNotifier.CHANGE : if (changedFeature instanceof AttrImpl) { AttrImpl attribute = (AttrImpl) changedFeature; String name = attribute.getName(); if (name.equals("contentType")) { //$NON-NLS-1$ // using concrete class below, since "changed" is something of an internal method PageDirectiveAdapterImpl pageDirectiveAdapter = (PageDirectiveAdapterImpl) ((IDOMDocument) targetElement.getOwnerDocument()).getAdapterFor(PageDirectiveAdapter.class); pageDirectiveAdapter.changedContentType(((IndexedRegion) targetElement).getStartOffset(), (String) newValue); } if (name.equals("language")) { //$NON-NLS-1$ //$NON-NLS-2$ // using concrete class below, since "changed" is something of an internal method PageDirectiveAdapterImpl pageDirectiveAdapter = (PageDirectiveAdapterImpl) ((IDOMDocument) targetElement.getOwnerDocument()).getAdapterFor(PageDirectiveAdapter.class); pageDirectiveAdapter.changedLanguage(((IndexedRegion) targetElement).getStartOffset(), (String) newValue); } } break; case INodeNotifier.REMOVE : //System.out.println("removed"+new Date().toString()); break; default : break; } } }
/** * Constructor for PageDirectiveWatcherImpl. */ public PageDirectiveWatcherImpl(IDOMElement target) { super(); targetElement = target; String contentTypeValue = target.getAttribute("contentType"); //$NON-NLS-1$ if (contentTypeValue != null) { // using concrete class below, since "changed" is something of an internal method PageDirectiveAdapterImpl pageDirectiveAdapter = (PageDirectiveAdapterImpl) ((IDOMDocument) targetElement.getOwnerDocument()).getAdapterFor(PageDirectiveAdapter.class); pageDirectiveAdapter.changedContentType(((IndexedRegion) targetElement).getStartOffset(), contentTypeValue); } String languageValue = target.getAttribute("language"); //$NON-NLS-1$ if (languageValue != null) { // using concrete class below, since "changed" is something of an internal method PageDirectiveAdapterImpl pageDirectiveAdapter = (PageDirectiveAdapterImpl) ((IDOMDocument) targetElement.getOwnerDocument()).getAdapterFor(PageDirectiveAdapter.class); pageDirectiveAdapter.changedLanguage(((IndexedRegion) targetElement).getStartOffset(), languageValue); } }
void performValidation(IFile f, IReporter reporter, IStructuredModel model) { if (model instanceof IDOMModel) { IDOMModel domModel = (IDOMModel) model; ModelHandlerForJSP.ensureTranslationAdapterFactory(domModel); IDOMDocument xmlDoc = domModel.getDocument(); JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); IJSPTranslation translation = translationAdapter.getJSPTranslation(); if (!reporter.isCancelled()) { translation.setProblemCollectingActive(true); translation.reconcileCompilationUnit(); List problems = translation.getProblems(); // add new messages for (int i = 0; i < problems.size() && !reporter.isCancelled(); i++) { IMessage m = createMessageFromProblem((IProblem) problems.get(i), f, translation, domModel.getStructuredDocument()); if (m != null) reporter.addMessage(fMessageOriginator, m); } } } }
public JSPTranslationExtension getTranslation() { if (fTranslation == null) { IDOMModel xmlModel = (IDOMModel) getModelManager().getExistingModelForRead(fDocument); ModelHandlerForJSP.ensureTranslationAdapterFactory(xmlModel); try { IDOMDocument xmlDoc = xmlModel.getDocument(); JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (translationAdapter != null) fTranslation = translationAdapter.getJSPTranslation(); } finally { if (xmlModel != null) { xmlModel.releaseFromRead(); } } } return fTranslation; }
Object obj = ((IDOMModel) getModel()).getDocument().getAdapterFor( IDocumentPageVariableAdapter.class); if (obj instanceof IPageVariablesProvider) {
setupAdapterFactory(xmlModel); IDOMDocument doc = xmlModel.getDocument(); JSPTranslationAdapter adapter = (JSPTranslationAdapter) doc.getAdapterFor(IJSPTranslation.class); translation = adapter.getJSPTranslation();
ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class); CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node); if (elementDeclaration != null) {
IStructuredDocument structuredDocument = model.getStructuredDocument(); IDOMDocument document = domModel.getDocument(); PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) document.getAdapterFor(PageDirectiveAdapter.class);
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) document.getAdapterFor(PageDirectiveAdapter.class);
Object obj = doc.getAdapterFor(IDocumentPageVariableAdapter.class); if (obj instanceof IPageVariablesProvider) { ((IPageVariablesProvider) obj).refresh();
ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class); CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node); if ((elementDeclaration == null) || (elementDeclaration.getContentType() != CMElementDeclaration.EMPTY)) {
IDOMDocument doc = ((IDOMModel) model).getDocument(); PropagatingAdapter adapter = (PropagatingAdapter) doc .getAdapterFor(PropagatingAdapter.class); if (adapter != null) { INodeAdapterFactory factory = RefresherFactory.getInstance();