Search in sources :

Example 1 with IADTEditorInput

use of org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method initializeGraphicalViewer.

protected void initializeGraphicalViewer() {
    RootContentEditPart root = new RootContentEditPart();
    if (!(getEditorInput() instanceof IADTEditorInput)) {
        root.setModel(model);
    }
    graphicalViewer.setContents(root);
}
Also used : IADTEditorInput(org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)

Example 2 with IADTEditorInput

use of org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method buildModel.

public IModel buildModel() {
    try {
        IEditorInput editorInput = getEditorInput();
        // If the input schema is from the WSDL Editor, then use that inline schema
        if (editorInput instanceof IADTEditorInput) {
            xsdSchema = ((IADTEditorInput) editorInput).getSchema();
            if (xsdSchema != null)
                model = (IModel) XSDAdapterFactory.getInstance().adapt(xsdSchema);
        }
        Document document = null;
        IDocument doc = structuredTextEditor.getDocumentProvider().getDocument(getEditorInput());
        if (doc instanceof IStructuredDocument) {
            IStructuredModel model = null;
            try {
                // TODO: for StorageEditorInputs, should be forRead
                model = StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
                if (model == null) {
                    model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) doc);
                }
                document = ((IDOMModel) model).getDocument();
            } finally {
                if (model != null) {
                    model.releaseFromEdit();
                }
            }
        }
        Assert.isNotNull(document);
        if (model != null)
            return model;
        xsdSchema = XSDModelAdapter.lookupOrCreateSchema(document);
        model = (IModel) XSDAdapterFactory.getInstance().adapt(xsdSchema);
    } catch (Exception e) {
    }
    // }
    return model;
}
Also used : IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) IADTEditorInput(org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IDocument(org.eclipse.jface.text.IDocument) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

IADTEditorInput (org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput)2 IDocument (org.eclipse.jface.text.IDocument)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)1 RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)1 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)1 Document (org.w3c.dom.Document)1