use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class FileUtil method createModel.
public static ICSSModel createModel() {
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
// $NON-NLS-1$
model = modelManager.getModelForEdit("test" + uniqueNum++ + ".css", new NullInputStream(), null);
// always use the same line delimiter for these tests, regardless
// of plaform or preference settings
model.getStructuredDocument().setLineDelimiter(commonEOL);
} catch (Exception e) {
e.printStackTrace();
}
return (ICSSModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class ViewerTestHTML method setupViewerForNew.
/**
* Set up source viewer with a new document & configure it
*/
void setupViewerForNew() {
// if was following selection, stop
stopFollowSelection();
IModelManager modelManager = StructuredModelManager.getModelManager();
IDocument doc = modelManager.createStructuredDocumentFor(ContentTypeIdForHTML.ContentTypeID_HTML);
doc.set(DEFAULT_VIEWER_CONTENTS);
fSourceViewer.setDocument(doc);
// need to reconfigure after set document just so highlighter works
fSourceViewer.configure(fConfig);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestStructuredPartitionerHTML method getPartitionTest.
/**
* Retrieves the single partition at the given offset for the given file, using the
* default partitioner for that file type. This test allows for verifying the zero-length
* partitioning behavior.
*
* @param filename
* @param offset
* @return ITypedRegion
* @throws IOException
* @throws BadLocationException
*/
protected ITypedRegion getPartitionTest(String filename, int offset) throws IOException, BadLocationException {
IModelManager modelManager = StructuredModelManager.getModelManager();
InputStream inStream = getClass().getResourceAsStream(filename);
IStructuredModel model = modelManager.getModelForEdit(filename, inStream, null);
IStructuredDocument structuredDocument = model.getStructuredDocument();
partitions = null;
ITypedRegion partition = structuredDocument.getPartition(offset);
if (DEBUG_PRINT_RESULT) {
String contents = null;
System.out.println("\nfilename: " + filename);
try {
contents = structuredDocument.get(partition.getOffset(), partition.getLength());
} catch (BadLocationException e) {
contents = "*error*";
}
System.out.println(partition + " [" + StringUtils.escape(contents) + "]");
}
model.releaseFromEdit();
inStream.close();
return partition;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class ModelTest method createXMLModel.
public static IDOMModel createXMLModel() {
// return new XMLModelImpl();
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
// assertTrue("modelManager must not be null", modelManager !=
// null);
model = modelManager.getModelForEdit("test.xml", new NullInputStream(), null);
// always use the same line delimiter for these tests, regardless
// of
// plaform or preference settings
model.getStructuredDocument().setLineDelimiter(TestWriter.commonEOL);
} catch (Exception e) {
e.printStackTrace();
}
// null);
return (IDOMModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestJSPContentFormatter method getModelForEdit.
/**
* must release model (from edit) after
*
* @param filename
* relative to this class (TestFormatProcessorCSS)
*/
private IStructuredModel getModelForEdit(final String filename) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
assertTrue("unable to find file: " + filename, file.exists());
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForEdit(file);
} catch (CoreException ce) {
ce.printStackTrace();
} catch (IOException io) {
io.printStackTrace();
}
return model;
}
Aggregations