本文整理汇总了Java中org.eclipse.ui.editors.text.TextFileDocumentProvider类的典型用法代码示例。如果您正苦于以下问题:Java TextFileDocumentProvider类的具体用法?Java TextFileDocumentProvider怎么用?Java TextFileDocumentProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextFileDocumentProvider类属于org.eclipse.ui.editors.text包,在下文中一共展示了TextFileDocumentProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDocument
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* Obtains the document of a file.
* @param file the file
* @return the document of the file, or <code>null</code> if none
*/
public static IDocument getDocument(IFile file) {
if (file == null) {
return null;
}
try {
TextFileDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(file);
IDocument doc = provider.getDocument(file);
provider.disconnect(file);
return doc;
} catch (CoreException e) {
e.printStackTrace();
}
return null;
}
示例2: saveOpenTmpSqlEditor
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* Saves the content as a temp-file, opens it using SQL-editor
* and ensures that UTF-8 is used for everything.
*/
public static void saveOpenTmpSqlEditor(String content, String filenamePrefix) throws IOException, CoreException {
Log.log(Log.LOG_INFO, "Creating file " + filenamePrefix); //$NON-NLS-1$
Path path = Files.createTempFile(filenamePrefix + '_', ".sql"); //$NON-NLS-1$
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(path.toFile());
IEditorInput input = new FileStoreEditorInput(externalFile);
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, EDITOR.SQL);
if (part instanceof ITextEditor) {
IDocumentProvider prov = ((ITextEditor) part).getDocumentProvider();
if (prov instanceof TextFileDocumentProvider) {
((TextFileDocumentProvider) prov).setEncoding(input, ApgdiffConsts.UTF_8);
prov.resetDocument(input);
}
}
}
示例3: createMarkers
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* Créé les marqueurs du fichier courant.
*/
private void createMarkers() {
try {
/* Obtient le document. */
TextFileDocumentProvider documentProvider = new TextFileDocumentProvider();
documentProvider.connect(file);
document = documentProvider.getDocument(file);
/* Analyse le document. */
checkKspDocument();
/* Libère le document. */
documentProvider.disconnect(file);
} catch (CoreException e) {
ErrorUtils.handle(e);
}
}
示例4: getPosition
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
public static Position getPosition(IFile file, TextSpan textSpan) throws BadLocationException {
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
ITextFileBuffer buffer = bufferManager.getTextFileBuffer(file.getLocation(), LocationKind.IFILE);
if (buffer != null) {
return getPosition(buffer.getDocument(), textSpan);
}
IDocumentProvider provider = new TextFileDocumentProvider();
try {
provider.connect(file);
IDocument document = provider.getDocument(file);
if (document != null) {
return getPosition(document, textSpan);
}
} catch (CoreException e) {
} finally {
provider.disconnect(file);
}
return null;
}
示例5: getContentType
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
@Override
public String getContentType()
{
try
{
IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
.getContentType(getEditorInput());
if (contentType != null)
{
IContentType baseType = contentType.getBaseType();
if (baseType != null && IXMLConstants.CONTENT_TYPE_XML.equals(baseType.getId()))
{
return contentType.getId();
}
}
}
catch (Exception e)
{
}
return IXMLConstants.CONTENT_TYPE_XML;
}
示例6: getContentType
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
public String getContentType()
{
try
{
IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
.getContentType(getEditorInput());
if (contentType != null)
{
return contentType.getId();
}
}
catch (Exception e)
{
IdeLog.logError(CommonEditorPlugin.getDefault(), e);
}
return null;
}
示例7: validate
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
IDocument document = null;
// get document
try {
final IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(resource);
document = provider.getDocument(resource);
provider.disconnect(resource);
} catch (CoreException e) {
e.printStackTrace();
}
ValidationResult result = new ValidationResult();
if (document != null) {
// validate definitions names
List<ElementRegion> definitionNameRegions = tilesXmlParser
.getDefinitionNameRegions(document);
validateRegions(resource, document, result, definitionNameRegions,
DUP_DEFINITION_MESSAGE_TEXT, IMarker.SEVERITY_WARNING);
}
return result;
}
示例8: createDocumentProvider
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
private IDocumentProvider createDocumentProvider(IEditorInput input2) {
// System.out.println(input2.getClass().toString());
if (input2 instanceof IFileEditorInput) {
return new NCLDocumentProvider();
} else if (input2 instanceof IURIEditorInput) {
NCLTextDocumentProvider docProvider = new NCLTextDocumentProvider();
return docProvider;
} else {
return new TextFileDocumentProvider();
}
}
示例9: mustSaveDirtyEditor
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
private static boolean mustSaveDirtyEditor(IEditorPart ep, IEditorInput input, boolean saveUnknownEditors) {
/*
* Goal: save all editors that could interfere with refactoring operations.
*
* Always save all editors for compilation units that are not working copies.
* (Leaving them dirty would cause problems, since the file buffer could have been
* modified but the Java model is not reconciled.)
*
* If <code>saveUnknownEditors</code> is <code>true</code>, save all editors
* whose implementation is probably not based on file buffers.
*/
IResource resource= (IResource) input.getAdapter(IResource.class);
if (resource == null)
return saveUnknownEditors;
IJavaElement javaElement= JavaCore.create(resource);
if (javaElement instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit) javaElement;
if (!cu.isWorkingCopy()) {
return true;
}
}
if (! (ep instanceof ITextEditor))
return saveUnknownEditors;
ITextEditor textEditor= (ITextEditor) ep;
IDocumentProvider documentProvider= textEditor.getDocumentProvider();
if (! (documentProvider instanceof TextFileDocumentProvider))
return saveUnknownEditors;
return false;
}
示例10: InstallOptionsEditorInput
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* @throws CoreException
*
*/
public InstallOptionsEditorInput(IFileEditorInput input)
{
super(input.getFile());
mInput = input;
mDocumentProvider = new TextFileDocumentProvider();
}
示例11: getAdapter
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter)
{
if(adapter == TextFileDocumentProvider.class) {
return mDocumentProvider;
}
return mInput.getAdapter(adapter);
}
示例12: NCLTextDocumentProvider
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* Creates a new properties file document provider and sets up the parent
* chain.
*/
public NCLTextDocumentProvider() {
IDocumentProvider provider = new TextFileDocumentProvider(
new NCLDocumentProvider());
setParentDocumentProvider(provider);
}
示例13: getDocumentProvider
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
public TextFileDocumentProvider getDocumentProvider()
{
return mDocumentProvider;
}
示例14: FileProvider
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
/**
* Créé une nouvelle instance de FileProvider.
*
* @param file Fichier.
* @param project Projet.
* @param javaProject Projet Java.
* @param documentProvider Fournisseur de document.
*/
public FileProvider(IFile file, IProject project, IJavaProject javaProject, TextFileDocumentProvider documentProvider) {
this.file = file;
this.project = project;
this.javaProject = javaProject;
this.documentProvider = documentProvider;
}
示例15: addMarkers
import org.eclipse.ui.editors.text.TextFileDocumentProvider; //导入依赖的package包/类
private void addMarkers(Set<String> deletedKeys) throws Exception {
targetFile.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
if (deletedKeys == null || deletedKeys.isEmpty()) {
//do nothing
return;
}
IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(targetFile);
IDocument targetFileDocument = provider.getDocument(targetFile);
FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(targetFileDocument);
for (String deletedkey: deletedKeys) {
IRegion region = adapter.find(0, deletedkey, true, false, false, false);
IMarker marker = targetFile.createMarker(IMarker.PROBLEM);
int lineNumber = targetFileDocument.getLineOfOffset(region.getOffset());
if (marker.exists()) {
marker.setAttribute(IMarker.MESSAGE, "Property might not be used within mule configs.");
marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber + 1);
marker.setAttribute(IMarker.CHAR_START, region.getOffset());
marker.setAttribute(IMarker.CHAR_END, region.getOffset() + region.getLength());
}
}
provider.disconnect(targetFile);
}