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


Java ITextOperationTarget类代码示例

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


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

示例1: ClipboardOperationAction

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
/**
 * Creates the action.
 * @param bundle the resource bundle
 * @param prefix a prefix to be prepended to the various resource keys
 *   (described in <code>ResourceAction</code> constructor), or
 *   <code>null</code> if none
 * @param editor the text editor
 * @param operationCode the operation code
 */
public ClipboardOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) {
	super(bundle, prefix, editor);
	fOperationCode= operationCode;

	if (operationCode == ITextOperationTarget.CUT) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
	} else if (operationCode == ITextOperationTarget.COPY) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
	} else if (operationCode == ITextOperationTarget.PASTE) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
	} else {
		Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
	}
	update();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:ClipboardOperationAction.java

示例2: editorOpened

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的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: AstManager

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
/**
 * Constructor. Loads the AST and sets up the StyledText to automatically
 * reload after certain events.
 * @param editor IEditorPart which owns the following StyledText.
 * @param styledText StyledText to which this AST pertains.
 */
public AstManager(IEditorPart editor, StyledText styledText) {
    try {
        editorPath = ((IFileEditorInput) editor.getEditorInput()).getFile()
                .getFullPath().toFile().getCanonicalPath();
    } catch (IOException e) {
        // ignore IOErrors while constructing path
        editorPath = "?";
    }
    this.editor = editor;
    this.styledText = styledText;
    //This is the only why I know to get the ProjectionViewer. Perhaps there is better way. ~Ben
    ITextOperationTarget t = (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
    if(t instanceof ProjectionViewer) projectionViewer = (ProjectionViewer)t;
    hookupAutoReload();
    reload();
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:23,代码来源:AstManager.java

示例4: showTokenHighLights

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
public void showTokenHighLights(){
  	showTokenHighlights = !showTokenHighlights;
  	if(activeEditor == null) return;
if(!tokenHighlighters.containsKey(activeEditor)){
	StyledText styledText = (StyledText) activeEditor.getAdapter(Control.class);
	if(styledText != null){
		ITextOperationTarget t = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
		if(t instanceof ProjectionViewer){
			ProjectionViewer projectionViewer = (ProjectionViewer)t;
			tokenHighlighters.put(activeEditor, new TokenHighlighter(styledText, showTokenHighlights, projectionViewer));
		}
	}
}
  	for(TokenHighlighter tokenHighlighter: tokenHighlighters.values()){
  		tokenHighlighter.setShow(showTokenHighlights);
  	}
  }
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:18,代码来源:ITrace.java

示例5: createContentAssistActionHandler

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
private ActionHandler createContentAssistActionHandler(
		final ITextOperationTarget textOperationTarget) {
	Action proposalAction = new Action() {
		@Override
		public void run() {
			if (textOperationTarget
					.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
					&& getTextWidget().isFocusControl())
				textOperationTarget
						.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		}
	};
	proposalAction
			.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
	return new ActionHandler(proposalAction);
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:17,代码来源:SpellcheckableMessageArea.java

示例6: handleVerifyKeyPressed

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
private void handleVerifyKeyPressed(VerifyEvent event) {
	if (!event.doit)
		return;

	if (event.stateMask != SWT.MOD1)
		return;

	switch (event.character) {
	case ' ':
		fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		event.doit = false;
		break;

	// CTRL-Z
	case 'z' - 'a' + 1:
		fPatternEditor.doOperation(ITextOperationTarget.UNDO);
		event.doit = false;
		break;
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:21,代码来源:EditTemplateDialog.java

示例7: run

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
@Override
public void run() {
	try {
		// Move offset to the line of the annotation, if necessary
		IDocument document = getDocument();
		int annotationLine = ruler.getLineOfLastMouseButtonActivity();
		int annotationLineOffet = document.getLineOffset(annotationLine);
		Point currentSelection = textEditor.getInternalSourceViewer().getSelectedRange();
		int currentLine = document.getLineOfOffset(currentSelection.x);
		if (currentLine != annotationLine)
			textEditor.getInternalSourceViewer().setSelectedRange(annotationLineOffet, 0);
	
		// show QuickFix dialog
		ITextOperationTarget operation = (ITextOperationTarget) textEditor.getAdapter(ITextOperationTarget.class);
		final int opCode = ISourceViewer.QUICK_ASSIST;
		if (operation != null && operation.canDoOperation(opCode))
			operation.doOperation(opCode);
	} catch (BadLocationException e) {
		// Ignore -> do nothing
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:XtextMarkerRulerAction.java

示例8: apply

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
@Override
public void apply(final ITextViewer viewer, char trigger, int stateMask, int offset)
{
	super.apply(viewer, trigger, stateMask, offset);
	// HACK pop CA back up if user selected a folder, but do it on a delay so that the folder
	// proposal insertion can finish properly (like updating selection/offset)
	if (viewer instanceof ITextOperationTarget && isDirectory)
	{
		UIUtils.getDisplay().asyncExec(new Runnable()
		{
			public void run()
			{
				if (((ITextOperationTarget) viewer).canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
				{
					((ITextOperationTarget) viewer).doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
				}
			}
		});
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:HTMLContentAssistProcessor.java

示例9: executeCommand

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
public static CommandResult executeCommand(CommandElement command, InvocationType invocationType,
		ITextEditor textEditor)
{
	ITextViewer textViewer = null;
	if (textEditor != null)
	{
		// FIXME This is pretty bad here. What we want is the ISourceViewer of the editor (which is a subinterface
		// of ITextViewer). It just happens that sourceViewer.getTextOperationTarget returns self in this case.
		Object adapter = textEditor.getAdapter(ITextOperationTarget.class);
		if (adapter instanceof ITextViewer)
		{
			textViewer = (ITextViewer) adapter;
		}
	}
	return executeCommand(command, invocationType, textViewer, textEditor);
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:17,代码来源:CommandExecutionUtils.java

示例10: runWithEvent

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
@Override
public void runWithEvent(Event event) {
	if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
		((OverrideIndicatorManager.OverrideIndicator)fAnnotation).open();
		return;
	}

	if (fHasCorrection) {
		ITextOperationTarget operation= (ITextOperationTarget) fTextEditor.getAdapter(ITextOperationTarget.class);
		final int opCode= ISourceViewer.QUICK_ASSIST;
		if (operation != null && operation.canDoOperation(opCode)) {
			fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
			operation.doOperation(opCode);
		}
		return;
	}

	super.run();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:JavaSelectAnnotationRulerAction.java

示例11: copy

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	XLiffTextTransfer hsTextTransfer = XLiffTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(Utils.getLineSeparator(), "\n");
	plainText = plainText.replaceAll(Constants.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(Constants.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(Constants.SPACE_CHARACTER + "", " ");
	plainText = plainText.replaceAll("\u200B", "");
	clipboard.clearContents();
	Object[] data = new Object[] { PATTERN.matcher(plainText).replaceAll(""), plainText };
	Transfer[] types = new Transfer[] { plainTextTransfer, hsTextTransfer };

	clipboard.setContents(data, types, DND.CLIPBOARD);
	clipboard.dispose();
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:SegmentViewer.java

示例12: copy

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	HSTextTransfer hsTextTransfer = HSTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(System.getProperty("line.separator"), "\n");
	plainText = plainText.replaceAll(TmxEditorConstanst.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(TmxEditorConstanst.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(TmxEditorConstanst.SPACE_CHARACTER + "", " ");
	plainText = plainText.replaceAll("\u200B", "");
	clipboard.clearContents();
	Object[] data = new Object[] { PATTERN.matcher(plainText).replaceAll(""), plainText };
	Transfer[] types = new Transfer[] { plainTextTransfer, hsTextTransfer };

	clipboard.setContents(data, types);
	clipboard.dispose();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:25,代码来源:CellEditorTextViewer.java

示例13: restoreTextLocation

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
public void restoreTextLocation() {

		if (!restoreCursorLocation) {
			return;
		}

		restoreCursorLocation = false;

		ITextOperationTarget target = (ITextOperationTarget) this.getAdapter(ITextOperationTarget.class);
		if (!(target instanceof ITextViewer)) {
			return ;
		}
		ITextViewer textViewer = (ITextViewer) target;
		if (nodes != null && nodes.size() > nodePosition) {
			Node node = nodes.get(nodePosition);
			if (node != null) {
				int textLocation = node.getPosition().getOffset() + nodePositionOffset;
				textViewer.getTextWidget().setSelection(textLocation);
			}
		}
	}
 
开发者ID:winture,项目名称:wt-studio,代码行数:22,代码来源:JsonTextEditor.java

示例14: pageChanged

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
@Override
public void pageChanged(PageChangedEvent event) {
	Object selectedPage = event.getSelectedPage();
	if (seenPages.contains(selectedPage))
		return;
	
	seenPages.add(selectedPage);
	if (selectedPage instanceof AbstractTextEditor) {
		IEditorPart editorPart = (IEditorPart) selectedPage;
		IProject project = plugin.getProjectForEditor(editorPart.getEditorInput());
		if (plugin.getIgnoreProjectsList().contains(project.getName()))
			return;
		ISourceViewer sourceViewer = (ISourceViewer) editorPart.getAdapter(ITextOperationTarget.class);
		sourceViewer.getDocument().addDocumentListener(new DocumentListener());
	}
}
 
开发者ID:ChangeOrientedProgrammingEnvironment,项目名称:eclipseRecorder,代码行数:17,代码来源:MultiEditorPageChangedListener.java

示例15: createControl

import org.eclipse.jface.text.ITextOperationTarget; //导入依赖的package包/类
@Override
protected void createControl(Composite parent, int styles) {
  super.createControl(parent, styles);
  final StyledText styledText = getTextWidget();

  IMenuListener menuListener = new IMenuListener() {
    @Override
    public void menuAboutToShow(IMenuManager menu) {
      Action copyAction = createAction(ITextOperationTarget.COPY, IWorkbenchCommandConstants.EDIT_COPY);
      copyAction.setText(WorkbenchMessages.Workbench_copy);
      copyAction.setToolTipText(WorkbenchMessages.Workbench_copyToolTip);
      ISharedImages sharedImages = AppUtils.getActiveWorkbenchWindow().getWorkbench().getSharedImages();
      copyAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
      copyAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
      menu.add(copyAction);
    }
  };

  MenuManager manager = new MenuManager(CONTEXT_MENU_ID, CONTEXT_MENU_ID);
  manager.setRemoveAllWhenShown(true);
  Menu contextMenu = manager.createContextMenu(styledText);
  styledText.setMenu(contextMenu);
  manager.addMenuListener(menuListener);
}
 
开发者ID:agusevas,项目名称:logan,代码行数:25,代码来源:SearchResultViewer.java


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