Java Code Examples for org.eclipse.swt.custom.StyledText#getSelectionText()
The following examples show how to use
org.eclipse.swt.custom.StyledText#getSelectionText() .
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: FindReplaceDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 替换 ; */ private void doReplace() { CellRegion activeCellRegion = ActiveCellRegion.getActiveCellRegion(); if (activeCellRegion == null) { return; } StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getTargetStyledEditor(); if(cellEditor != null){ StyledText text = cellEditor.getSegmentViewer().getTextWidget(); String sleText = text.getSelectionText(); String findStr = cmbFind.getText(); if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) { findStr = findStr.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n"); findStr = findStr.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B"); findStr = findStr.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B"); } if( sleText != null && sleText.toLowerCase().equals(findStr.toLowerCase())){ Point p = text.getSelection(); text.replaceTextRange(p.x, p.y - p.x, cmbReplace.getText()); } } }
Example 2
Source File: FindReplaceDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 替换 ; */ private void doReplace() { CellRegion activeCellRegion = ActiveCellRegion.getActiveCellRegion(); if (activeCellRegion == null) { return; } StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getTargetStyledEditor(); if(cellEditor != null){ StyledText text = cellEditor.getSegmentViewer().getTextWidget(); String sleText = text.getSelectionText(); if( sleText != null && sleText.toLowerCase().equals(cmbFind.getText().toLowerCase())){ Point p = text.getSelection(); text.replaceTextRange(p.x, p.y - p.x, cmbReplace.getText()); } } }
Example 3
Source File: XLIFFEditorActionHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void runWithEvent(Event event) { if (viewer != null && !viewer.getTextWidget().isDisposed()) { StyledTextCellEditor editor = HsMultiActiveCellEditor.getFocusCellEditor(); boolean isSrc = false; if (editor != null && editor.getCellType().equals(NatTableConstant.SOURCE)) { isSrc = true; } StyledText styledText = viewer.getTextWidget(); String text = styledText.getText(); String selectionText = styledText.getSelectionText(); // 当选择源文时,要判断是否是删除所有源文 if (isSrc) { if (selectionText != null && text != null && text.equals(selectionText)) { MessageDialog.openInformation(viewer.getTextWidget().getShell(), Messages.getString("editor.XLIFFEditorActionHandler.msgTitle"), Messages.getString("editor.XLIFFEditorActionHandler.msg")); return; } } viewer.doOperation(ITextOperationTarget.DELETE); updateActionsEnableState(); return; } if (deleteAction != null) { deleteAction.runWithEvent(event); return; } }
Example 4
Source File: ExecuteQueryAction.java From mat-calcite-plugin with Apache License 2.0 | 5 votes |
private String getSelectedQuery() { StyledText queryString = pane.getQueryString(); String query = queryString.getSelectionText(); if ("".equals(query)) //$NON-NLS-1$ { query = queryString.getText(); } // Temporary workaround for https://issues.apache.org/jira/browse/CALCITE-459 query = query + queryString.getLineDelimiter(); return query; }
Example 5
Source File: XLIFFEditorActionHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void runWithEvent(Event event) { if (viewer != null && !viewer.getTextWidget().isDisposed()) { StyledTextCellEditor editor = HsMultiActiveCellEditor.getFocusCellEditor(); boolean isSrc = false; if (editor != null && editor.getCellType().equals(NatTableConstant.SOURCE)) { isSrc = true; } StyledText styledText = viewer.getTextWidget(); String text = styledText.getText(); String selectionText = styledText.getSelectionText(); // 当选择源文时,要判断是否是删除所有源文 if (isSrc) { if (selectionText != null && text != null && text.equals(selectionText)) { MessageDialog.openInformation(viewer.getTextWidget().getShell(), Messages.getString("editor.XLIFFEditorActionHandler.msgTitle"), Messages.getString("editor.XLIFFEditorActionHandler.msg")); return; } } viewer.doOperation(ITextOperationTarget.DELETE); updateActionsEnableState(); return; } if (deleteAction != null) { deleteAction.runWithEvent(event); return; } }
Example 6
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Insert a text string into the text area * * @param text */ protected void insertText( String text ) { StyledText textWidget = expressionViewer.getTextWidget( ); if ( !textWidget.isEnabled( ) ) { return; } int selectionStart = textWidget.getSelection( ).x; if ( text.equalsIgnoreCase( "x++" ) ) //$NON-NLS-1$ { text = textWidget.getSelectionText( ) + "++";//$NON-NLS-1$ } else if ( text.equalsIgnoreCase( "x--" ) )//$NON-NLS-1$ { text = textWidget.getSelectionText( ) + "--";//$NON-NLS-1$ } else if ( text.equalsIgnoreCase( "++x" ) )//$NON-NLS-1$ { text = "++" + textWidget.getSelectionText( );//$NON-NLS-1$ } else if ( text.equalsIgnoreCase( "--x" ) )//$NON-NLS-1$ { text = "--" + textWidget.getSelectionText( );//$NON-NLS-1$ } textWidget.insert( text ); textWidget.setSelection( selectionStart + text.length( ) ); textWidget.setFocus( ); if ( text.endsWith( "()" ) ) //$NON-NLS-1$ { textWidget.setCaretOffset( textWidget.getCaretOffset( ) - 1 ); // Move } }