Java Code Examples for org.eclipse.jface.text.ITextOperationTarget#COPY
The following examples show how to use
org.eclipse.jface.text.ITextOperationTarget#COPY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportsAwareClipboardAction.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * 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. May not be <code>null</code>. * @param operationCode * the operation code */ public ImportsAwareClipboardAction(ResourceBundle bundle, String prefix, ITextEditor editor, final int operationCode) { super(bundle, prefix, editor); this.operationCode = 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(); }
Example 2
Source File: ClipboardOperationAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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(); }
Example 3
Source File: SegmentViewer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 执行复制时对标记的处理,复制后在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(); }
Example 4
Source File: CellEditorTextViewer.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 执行复制时对标记的处理,复制后在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(); }
Example 5
Source File: SegmentViewer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 重载此方法,实现粘贴、复制前对标记的处理。<br> * 已经移出了 默认的复制、粘贴事件键绑定, 参考{@link CellEditorTextViewer#initListener()} * @see org.eclipse.jface.text.TextViewer#doOperation(int) */ @Override public void doOperation(int operation) { if (operation == ITextOperationTarget.PASTE) { parse(); return; } if (operation == ITextOperationTarget.COPY) { copy(); return; } super.doOperation(operation); }
Example 6
Source File: CellEditorTextViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 重载此方法,实现粘贴、复制前对标记的处理。<br> * 已经移出了 默认的复制、粘贴事件键绑定, 参考{@link CellEditorTextViewer#initListener()} * @see org.eclipse.jface.text.TextViewer#doOperation(int) */ @Override public void doOperation(int operation) { if (operation == ITextOperationTarget.PASTE) { parse(); return; } if (operation == ITextOperationTarget.COPY) { copy(); return; } super.doOperation(operation); }
Example 7
Source File: ImportsAwareClipboardAction.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private boolean isModifyOperation() { return operationCode != ITextOperationTarget.COPY; }
Example 8
Source File: EditTemplateDialog.java From typescript.java with MIT License | 4 votes |
private void initializeActions() { TextViewerAction action = new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_undo); fGlobalActions.put(ITextEditorActionConstants.UNDO, action); action = new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_cut); fGlobalActions.put(ITextEditorActionConstants.CUT, action); action = new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_copy); fGlobalActions.put(ITextEditorActionConstants.COPY, action); action = new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_paste); fGlobalActions.put(ITextEditorActionConstants.PASTE, action); action = new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_select_all); fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action); action = new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS); action.setText(JSDTTypeScriptUIMessages.EditTemplateDialog_content_assist); fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$ fSelectionActions.add(ITextEditorActionConstants.CUT); fSelectionActions.add(ITextEditorActionConstants.COPY); fSelectionActions.add(ITextEditorActionConstants.PASTE); // create context menu MenuManager manager = new MenuManager(null, null); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); StyledText text = fPatternEditor.getTextWidget(); Menu menu = manager.createContextMenu(text); text.setMenu(menu); }
Example 9
Source File: ClipboardOperationAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private boolean isReadOnlyOperation() { return fOperationCode == ITextOperationTarget.COPY; }