当前位置: 首页>>代码示例>>Java>>正文


Java ITextEditor类代码示例

本文整理汇总了Java中org.eclipse.ui.texteditor.ITextEditor的典型用法代码示例。如果您正苦于以下问题:Java ITextEditor类的具体用法?Java ITextEditor怎么用?Java ITextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ITextEditor类属于org.eclipse.ui.texteditor包,在下文中一共展示了ITextEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetLinkedBookmarksInMultipageEditor

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
@Test
public void testGetLinkedBookmarksInMultipageEditor() throws Exception {
	// Given
	importProjectFromTemplate("testGetLinkedBookmarksInMultipageEditor", "commons-cli");
	Bookmark bookmark = bookmark("pom.xml")
			.withProperty(PROP_WORKSPACE_PATH, "/testGetLinkedBookmarksInMultipageEditor/pom.xml")
			.withProperty(PROP_LINE_NUMBER, "10").build();
	addBookmark(rootFolderId, bookmark);
	waitUntil("Cannot find marker", () -> bookmarksMarkers.findMarker(bookmark.getId(), null));

	// When
	IEditorPart editorPart = openEditor(new Path("/testGetLinkedBookmarksInMultipageEditor/pom.xml"));
	// that's why we require org.eclipse.m2e.editor in MANIFEST.MF
	assertThat(editorPart).isInstanceOf(MultiPageEditorPart.class);
	ITextEditor textEditor = getTextEditor(editorPart);
	selectAndReveal(textEditor, getOffset(textEditor, 10));
	List<Bookmark> bookmarks = operation.getLinkedBookmarks(textEditor, getSelection(textEditor));

	// Then
	assertEquals(1, bookmarks.size());
	assertEquals(bookmark, bookmarks.get(0));
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:23,代码来源:GetLinkedBookmarksOperationTest.java

示例2: editorOpened

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
private void editorOpened(IEditorPart part) {
	if (part instanceof ITextEditor) {
		ITextViewer textViewer = (ITextViewer) part.getAdapter(ITextOperationTarget.class);
		if (textViewer != null) {
			ICodeLensController controller = codeLensControllers.get(part);
			if (controller == null) {
				ITextEditor textEditor = (ITextEditor) part;
				controller = CodeLensControllerRegistry.getInstance().create(textEditor);
				if (controller != null) {
					controller.setProgressMonitor(new NullProgressMonitor());
					codeLensControllers.put(textEditor, controller);
					//controller.install();
				}
			}
		}
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:18,代码来源:EditorTracker.java

示例3: resolveCodeLens

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
@Override
public CompletableFuture<ICodeLens> resolveCodeLens(ICodeLensContext context, ICodeLens codeLens,
		IProgressMonitor monitor) {
	ITextEditor textEditor = ((IEditorCodeLensContext) context).getTextEditor();

	LSPDocumentInfo info = null;
	Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor(
			LSPEclipseUtils.getDocument((ITextEditor) textEditor),
			capabilities -> capabilities.getCodeLensProvider() != null
					&& capabilities.getCodeLensProvider().isResolveProvider());
	if (!infos.isEmpty()) {
		info = infos.iterator().next();
	} else {
		info = null;
	}
	if (info != null) {
		LSPCodeLens lscl = ((LSPCodeLens) codeLens);
		CodeLens unresolved = lscl.getCl();
		return info.getLanguageClient().getTextDocumentService().resolveCodeLens(unresolved).thenApply(resolved -> {
			lscl.update(resolved);
			return lscl;
		});
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:26,代码来源:LSPCodeLensProvider.java

示例4: setActivePage

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
public void setActivePage(IEditorPart part) {
	if (activeEditorPart == part)
		return;

	activeEditorPart = part;

	IActionBars actionBars = getActionBars();
	if (actionBars != null) {

		ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor, ITextEditorActionConstants.DELETE));
		actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ITextEditorActionConstants.UNDO));
		actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ITextEditorActionConstants.REDO));
		actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction(editor, ITextEditorActionConstants.CUT));
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), getAction(editor, ITextEditorActionConstants.COPY));
		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), getAction(editor, ITextEditorActionConstants.PASTE));
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ITextEditorActionConstants.SELECT_ALL));
		actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ITextEditorActionConstants.FIND));
		actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId()));
		actionBars.updateActionBars();
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:24,代码来源:CompDefEditorContributor.java

示例5: run

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
@Override
public void run() {
    if (isEnabled()) {
        try {
            ITextEditor editor = (ITextEditor) IDE.openEditor(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
                    segment.getParentFile(), EDITOR.SQL, true);
            editor.setHighlightRange(segment.offset, segment.length, true);
            editor.selectAndReveal(segment.offset, segment.length);
        } catch (PartInitException e) {
            Log.log(e);
            ExceptionNotifier.notifyDefault(Messages.PgNavigatorActionProvider_failed_to_open_editor, e);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:16,代码来源:NavigatorOutlineActionProvider.java

示例6: saveOpenTmpSqlEditor

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的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);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:FileUtilsUi.java

示例7: getCurrentEditorCurrentWord

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
public static String getCurrentEditorCurrentWord(WordSelectionType wordSelectionType) {
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

	/* Extrait l'éditeur courant. */
	ITextEditor editor = (ITextEditor) activePage.getActiveEditor();
	if (editor == null) {
		return null;
	}

	/* Extrait la sélection courante. */
	ITextSelection selection = (ITextSelection) activePage.getSelection();
	if (selection == null) {
		return null;
	}

	/* Extrait le document courant. */
	IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());

	/* Extrait le mot sélectionné. */
	ITextSelection currentWordSelection = DocumentUtils.findCurrentWord(document, selection, wordSelectionType);
	if (currentWordSelection == null) {
		return null;
	}

	return currentWordSelection.getText();
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:27,代码来源:UiUtils.java

示例8: toggleLineBreakpoints

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
	ITextEditor textEditor = getEditor(part);
	if (textEditor != null) {
		IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
		ITextSelection textSelection = (ITextSelection) selection;
		int lineNumber = textSelection.getStartLine();
		IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager()
				.getBreakpoints(DSPPlugin.ID_DSP_DEBUG_MODEL);
		for (int i = 0; i < breakpoints.length; i++) {
			IBreakpoint breakpoint = breakpoints[i];
			if (breakpoint instanceof ILineBreakpoint && resource.equals(breakpoint.getMarker().getResource())) {
				if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
					// remove
					breakpoint.delete();
					return;
				}
			}
		}
		// create line breakpoint (doc line numbers start at 0)
		DSPLineBreakpoint lineBreakpoint = new DSPLineBreakpoint(resource, lineNumber + 1);
		DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
	}
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:25,代码来源:DSPBreakpointAdapter.java

示例9: resolveSyncCodeLens

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
@Override
protected ICodeLens resolveSyncCodeLens(ICodeLensContext context, ICodeLens codeLens, IProgressMonitor monitor) {
	ITextEditor textEditor = ((IEditorCodeLensContext) context).getTextEditor();
	IFile file = EditorUtils.getFile(textEditor);
	if (file == null) {
		return null;
	}
	EditorConfigCodeLens cl = (EditorConfigCodeLens) codeLens;
	CountSectionPatternVisitor visitor = new CountSectionPatternVisitor(cl.getSection());
	try {
		file.getParent().accept(visitor, IResource.NONE);
		cl.update(visitor.getNbFiles() + " files match");
	} catch (CoreException e) {
		cl.update(e.getMessage());
	}
	return cl;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:18,代码来源:EditorConfigCodeLensProvider.java

示例10: contributeToPreferenceStore

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
public static IPreferenceStore contributeToPreferenceStore(ITextEditor textEditor,
		IPreferenceStore preferenceStore) {
	try {
		// Get old store
		IPreferenceStore oldStore = getPreferenceStore(textEditor);
		// Create chained store with preference store to add
		IPreferenceStore newStore = new ChainedPreferenceStore(
				new IPreferenceStore[] { preferenceStore, oldStore });
		// Update the text editor with new preference store
		setPreferenceStoreOfTextEditor(textEditor, newStore);
		// Update the source viewer configuration with new preference store
		setPreferenceStoreOfSourceViewerConfiguration(textEditor, newStore);
		return newStore;

	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}

}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:21,代码来源:PreferenceStoreHelper.java

示例11: attach

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
/**
 * Attaches a coverage annotation model for the given editor if the editor can
 * be annotated. Does nothing if the model is already attached.
 *
 * @param editor
 *          Editor to attach a annotation model to
 */
public static void attach(ITextEditor editor) {
  IDocumentProvider provider = editor.getDocumentProvider();
  // there may be text editors without document providers (SF #1725100)
  if (provider == null)
    return;
  IAnnotationModel model = provider.getAnnotationModel(editor
      .getEditorInput());
  if (!(model instanceof IAnnotationModelExtension))
    return;
  IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;

  IDocument document = provider.getDocument(editor.getEditorInput());

  CoverageAnnotationModel coveragemodel = (CoverageAnnotationModel) modelex
      .getAnnotationModel(KEY);
  if (coveragemodel == null) {
    coveragemodel = new CoverageAnnotationModel(editor, document);
    modelex.addAnnotationModel(KEY, coveragemodel);
  }
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:28,代码来源:CoverageAnnotationModel.java

示例12: createReferencingErrorMarkers

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
/**
 * Creates warning markers for undefined references. 
 * 
 * @param editor The editor to add the errors to
 * @param errors The errors to add as instances of <code>DocumentReference</code>
 */
public void createReferencingErrorMarkers(ITextEditor editor, List<DocumentReference> errors) {
    
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (resource == null) return;
    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    
    for (DocumentReference msg : errors) {
        try {
            int beginOffset = document.getLineOffset(msg.getLine() - 1) + msg.getPos();
            
            Map<String, ? super Object> map = new HashMap<String, Object>();
            map.put(IMarker.LINE_NUMBER, Integer.valueOf(msg.getLine()));
            map.put(IMarker.CHAR_START, Integer.valueOf(beginOffset));
            map.put(IMarker.CHAR_END, Integer.valueOf(beginOffset + msg.getLength()));
            map.put(IMarker.MESSAGE, "Key " + msg.getKey() + " is undefined");
            map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING));
            
            MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM);
        } catch (CoreException ce) {
            TexlipsePlugin.log("Creating marker", ce);
        } catch (BadLocationException ble) {
            TexlipsePlugin.log("Creating marker", ble);
        }
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:32,代码来源:MarkerHandler.java

示例13: clearErrorMarkers

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
/**
 * Delete all error markers from the currently open file.
 * 
 * @param editor The editor to clear the markers from
 */
public void clearErrorMarkers(ITextEditor editor) {
	// talk about ugly code...
    // TODO if this case occurs, then the user has probably not correctly created a project
    // -> we should somehow inform the user
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (resource == null) return;

    try {
        // TODO what should we clear and when?
        // regular problems == parsing errors
        resource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_INFINITE);
        // builder markers == build problems (don't clean them)
        //resource.deleteMarkers(TexlipseBuilder.MARKER_TYPE, false, IResource.DEPTH_INFINITE);
        // don't clear spelling errors
    } catch (CoreException e) {
        TexlipsePlugin.log("Deleting error markers", e);
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:24,代码来源:MarkerHandler.java

示例14: TexSelections

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
/**
 * Takes a text editor as a parameter and sets variables 
 * to correspond selection features.
 * 
 * @param textEditor The currenct text editor
 */
public TexSelections(ITextEditor textEditor) {
     
    // Get the document
    this.document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
    this.editor = textEditor;
    
    // Get the selection
    this.textSelection = (ITextSelection) this.editor.getSelectionProvider().getSelection();
  
    this.startLineIndex = this.textSelection.getStartLine();
    this.endLineIndex = this.textSelection.getEndLine();
    this.selLength = this.textSelection.getLength();

    // Store selection information
    select();
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:23,代码来源:TexSelections.java

示例15: run

import org.eclipse.ui.texteditor.ITextEditor; //导入依赖的package包/类
/**
    * Run the spell check action.
    * @param action the action
 */
public void run(IAction action) {
       
       if (targetEditor == null) {
           return;
       }
       if (!(targetEditor instanceof ITextEditor)) {
           return;
       }
       
       ITextEditor textEditor = (ITextEditor) targetEditor;
       IEditorInput input = textEditor.getEditorInput();
       
       IFile file = ((FileEditorInput) input).getFile();
       
       SpellChecker.checkSpelling(textEditor.getDocumentProvider().getDocument(input), file);
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:21,代码来源:SpellCheckAction.java


注:本文中的org.eclipse.ui.texteditor.ITextEditor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。