Search in sources :

Example 1 with DTDFile

use of org.eclipse.wst.dtd.core.internal.emf.DTDFile in project webtools.sourceediting by eclipse.

the class DTDExternalEntityImpl method setEntityReferencedFromAnotherFile.

/**
 * @generated This field/method will be replaced during code generation.
 */
public void setEntityReferencedFromAnotherFile(DTDFile newEntityReferencedFromAnotherFile) {
    DTDFile oldEntityReferencedFromAnotherFile = entityReferencedFromAnotherFile;
    entityReferencedFromAnotherFile = newEntityReferencedFromAnotherFile;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, DTDPackage.DTD_EXTERNAL_ENTITY__ENTITY_REFERENCED_FROM_ANOTHER_FILE, oldEntityReferencedFromAnotherFile, entityReferencedFromAnotherFile));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Example 2 with DTDFile

use of org.eclipse.wst.dtd.core.internal.emf.DTDFile in project webtools.sourceediting by eclipse.

the class DTDResourceImpl method save.

public void save(OutputStream os, Object options) throws Exception {
    if (contents != null) {
        Iterator i = contents.iterator();
        while (i.hasNext()) {
            Object obj = i.next();
            if (obj instanceof DTDFile) {
                try {
                    DTDPrinter printer = new DTDPrinter(true);
                    printer.visitDTDFile((DTDFile) obj);
                    String s = printer.getBuffer().toString();
                    os.write(s.getBytes());
                    // Reset the dirty flag after the resource is saved
                    setModified(false);
                } catch (Exception e) {
                }
                break;
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) DTDObject(org.eclipse.wst.dtd.core.internal.emf.DTDObject) EObject(org.eclipse.emf.ecore.EObject) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Example 3 with DTDFile

use of org.eclipse.wst.dtd.core.internal.emf.DTDFile in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method updateSystemID.

/**
 * The SystemID attribute is set to whatever the user enters e.g.
 * com/ibm/b2b/xmimodels/xxx.dtd.xmi
 *
 * In the unparse() method, parse out the DTD file name from the classpath
 * name. e.g. returns xxx.dtd
 */
private void updateSystemID(DTDExternalEntity extEntity, EntityDecl entityDecl) {
    String systemId = entityDecl.getSystemId();
    String publicId = entityDecl.getPublicId();
    if (systemId != null) {
        URIResolver idResolver = URIResolverPlugin.createResolver();
        String uri = idResolver.resolve(dtd.getName(), publicId, systemId);
        ExternalDTDModel ed = dtdUtil.getExternalDTDModel(resources, uri);
        if (ed != null) {
            DTDFile referenceDtdFile = ed.getExternalDTDFile();
            extEntity.setEntityReferencedFromAnotherFile(referenceDtdFile);
            extEntity.setSystemID(systemId);
        } else {
            if (entityDecl.getErrorMessage() == null) {
                ErrorMessage dtdError = new ErrorMessage();
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                dtdError.setErrorMessage(DTDCoreMessages._ERROR_INCL_FILE_LOAD_FAILURE + " '" + systemId + "'");
                addErrorMessage(dtdError, extEntity.getDTDEntity());
            }
            if (systemId != null) {
                extEntity.setSystemID(systemId);
            } else {
                // $NON-NLS-1$
                extEntity.setSystemID("");
            }
        }
    } else // end of if ()
    {
        // set the system id to be ""
        // $NON-NLS-1$
        extEntity.setSystemID("");
    }
}
Also used : URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver) ErrorMessage(org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Example 4 with DTDFile

use of org.eclipse.wst.dtd.core.internal.emf.DTDFile in project webtools.sourceediting by eclipse.

the class DTDElementImpl method getReferences.

// returns all references in the same DTDFile that reference this element
public Collection getReferences() {
    DTDFile file = getDTDFile();
    final Collection result = new ArrayList();
    DTDVisitor visitRefs = new DTDVisitor() {

        public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
            if (elementReferenceContent.getReferencedElement() == DTDElementImpl.this) {
                result.add(elementReferenceContent);
            }
        // end of if ()
        }
    };
    visitRefs.visitDTDFile(file);
    return result;
}
Also used : DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) ArrayList(java.util.ArrayList) Collection(java.util.Collection) DTDVisitor(org.eclipse.wst.dtd.core.internal.emf.util.DTDVisitor) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Example 5 with DTDFile

use of org.eclipse.wst.dtd.core.internal.emf.DTDFile in project webtools.sourceediting by eclipse.

the class DTDImpl method buildCMDocument.

public static CMDocument buildCMDocument(String uri) {
    DTDFile dtdFile = buildDTDModel(uri);
    CMDocument cmDocument = (CMDocument) getAdapter(dtdFile);
    return cmDocument;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Aggregations

DTDFile (org.eclipse.wst.dtd.core.internal.emf.DTDFile)9 Iterator (java.util.Iterator)4 DTDObject (org.eclipse.wst.dtd.core.internal.emf.DTDObject)3 Collection (java.util.Collection)2 EObject (org.eclipse.emf.ecore.EObject)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EList (org.eclipse.emf.common.util.EList)1 URI (org.eclipse.emf.common.util.URI)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 URIResolver (org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver)1 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)1 DTDElementReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent)1 DTDEntity (org.eclipse.wst.dtd.core.internal.emf.DTDEntity)1 DTDUtil (org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil)1 DTDVisitor (org.eclipse.wst.dtd.core.internal.emf.util.DTDVisitor)1 ErrorMessage (org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage)1