use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class AdapterFactoryProviderForJSP method addPropagatingAdapters.
protected void addPropagatingAdapters(IStructuredModel structuredModel) {
if (structuredModel instanceof IDOMModel) {
IDOMModel xmlModel = (IDOMModel) structuredModel;
IDOMDocument document = xmlModel.getDocument();
PropagatingAdapter propagatingAdapter = (PropagatingAdapter) document.getAdapterFor(PropagatingAdapter.class);
if (propagatingAdapter != null) {
// what to do?
}
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class XMLJavaHyperlinkDetector method isJspJavaContent.
private boolean isJspJavaContent(IDocument document, IRegion region) {
JSPTranslation translation = null;
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (model instanceof IDOMModel) {
IDOMModel xmlModel = (IDOMModel) model;
if (xmlModel != null) {
final IDOMDocument xmlDoc = xmlModel.getDocument();
final JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
if (adapter != null) {
translation = adapter.getJSPTranslation();
if (translation != null) {
int javaOffset = translation.getJavaOffset(region.getOffset());
if (javaOffset > -1) {
return true;
}
}
}
}
}
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return false;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class JSPJavaSelectionProvider method getSelection.
static IJavaElement[] getSelection(ITextEditor textEditor) {
IJavaElement[] elements = null;
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
ISelection selection = textEditor.getSelectionProvider().getSelection();
if (selection instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection) selection;
// get the JSP translation object for this editor's document
IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
try {
if (model instanceof IDOMModel) {
IDOMModel xmlModel = (IDOMModel) model;
IDOMDocument xmlDoc = xmlModel.getDocument();
JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
if (adapter != null) {
JSPTranslation translation = adapter.getJSPTranslation();
elements = translation.getElementsFromJspRange(textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength());
}
}
} finally {
if (model != null)
model.releaseFromRead();
}
}
if (elements == null) {
elements = new IJavaElement[0];
}
return elements;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class TestFormatUtility method testInlineNode.
public void testInlineNode() {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
IDOMDocument document = model.getDocument();
HTMLFormattingUtil util = new HTMLFormattingUtil();
assertTrue("Anchor tag must be inline", util.isInline(document.createElement("a")));
assertFalse("Div tag must not be inline", util.isInline(document.createElement("div")));
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class BUG124835SetStyleAttributeValueTest method testSetAttributeValue.
/**
* Tests setting some css attribute values including setting the same
* value several times for different attributes
*/
public void testSetAttributeValue() {
final String ABSOLUTE = "absolute";
final String ONE = "1";
final String PX = "50px";
IDOMModel model = FileUtil.createHTMLModel();
try {
IDOMDocument doc = model.getDocument();
Element element = doc.createElement(HTML40Namespace.ElementName.DIV);
element.setAttribute(HTML40Namespace.ATTR_NAME_ID, "Layer0");
element.setAttribute(HTML40Namespace.ATTR_NAME_STYLE, "");
setInlineStyle(element, PropCMProperty.P_POSITION, ABSOLUTE);
setInlineStyle(element, PropCMProperty.P_Z_INDEX, ONE);
setInlineStyle(element, PropCMProperty.P_WIDTH, PX);
setInlineStyle(element, PropCMProperty.P_HEIGHT, PX);
setInlineStyle(element, PropCMProperty.P_TOP, PX);
setInlineStyle(element, PropCMProperty.P_LEFT, PX);
assertEquals(ABSOLUTE, getInlineStyle(element, PropCMProperty.P_POSITION));
assertEquals(ONE, getInlineStyle(element, PropCMProperty.P_Z_INDEX));
assertEquals(PX, getInlineStyle(element, PropCMProperty.P_WIDTH));
assertEquals(PX, getInlineStyle(element, PropCMProperty.P_HEIGHT));
assertEquals(PX, getInlineStyle(element, PropCMProperty.P_TOP));
assertEquals(PX, getInlineStyle(element, PropCMProperty.P_LEFT));
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
}
Aggregations