org.eclipse.swt.custom.ExtendedModifyEvent Java Examples
The following examples show how to use
org.eclipse.swt.custom.ExtendedModifyEvent.
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: EnhancedTextField.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public void modifyText(ExtendedModifyEvent event){ if (ranges != null) { int pos = event.start; int len = event.length; String text = event.replacedText; int diff = len - text.length(); for (Samdas.Range r : ranges) { int spos = r.getPos(); if (updateXRefMode) { if (spos > pos) { r.setPos(spos + diff); } } else { if (spos >= pos) { r.setPos(spos + diff); } } } } }
Example #2
Source File: SpringConfigurationStyledText.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public void modifyText(ExtendedModifyEvent event) { /* * every changes should be record into undo list * (except the change is caused by redo/undo action) */ addUndoList(event); /* * update the styles */ updateStyledRanges(event); /* * auto completion */ int start = event.start; int length = event.length; String textRange = getTextRange(start, length); String previousChar = null; if(start-1>0){ previousChar = getTextRange(start-1, 1); } if("/".equals(textRange) && "<".equals(previousChar) && !isCommentBlock(start-1)){ String openedTag = searchNearestOpenedTag(start-2); if(openedTag != null && !openedTag.isEmpty()){ replaceTextRange(start+length, 0 , openedTag); setSelection(start + event.length + openedTag.length()); } } }
Example #3
Source File: SpringConfigurationStyledText.java From tesb-studio-se with Apache License 2.0 | 5 votes |
private void updateStyledRanges(ExtendedModifyEvent event) { StyledText st = (StyledText) event.widget; int start = event.start; int length = event.length; String replacedText = event.replacedText; String textRange = st.getTextRange(start, length); /* * if no real change * then return */ if ("".equals(textRange.trim()) && "".equals(replacedText.trim())) { return; } List<StyleRange> styles = new ArrayList<StyleRange>(); scanner.setRange(st.getText()); int token = scanner.nextToken(); while (token != EOF) { int startOffset = scanner.getStartOffset(); int tokenLength = scanner.getLength(); String tokenText = st.getTextRange(startOffset, tokenLength).trim(); for (String s : fgKeywords) { if (s.equals(tokenText)) { token = KEY; break; } } Color color = getColor(token); StyleRange style = new StyleRange(startOffset, tokenLength, color, null); if (token == KEY) { style.fontStyle = SWT.BOLD; } styles.add(style); token = scanner.nextToken(); } st.setStyleRanges(styles.toArray(new StyleRange[0])); }
Example #4
Source File: SpringConfigurationStyledText.java From tesb-studio-se with Apache License 2.0 | 5 votes |
private void addUndoList(ExtendedModifyEvent event) { if(fromUndoRedo ){ return; } StyledText st = (StyledText) event.widget; String currText = st.getText(); String newText = currText.substring(event.start, event.start + event.length); if (undoStack.size() == MAX_STACK_SIZE) { undoStack.remove(undoStack.size() - 1); } undoStack.add(0, new UndoRedoModel(newText, event.start, event.length, event.replacedText)); }
Example #5
Source File: ScriptConsoleViewer.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Constructor. * * @param parent parent for the styled text * @param style style to be used */ public ScriptConsoleStyledText(Composite parent, int style) { super(parent, style); /** * The StyledText will change the caretOffset that we've updated during the modifications, * so, the verify and the extended modify listener will keep track if it actually does * that and will reset the caret to the position we actually added it. * * Feels like a hack but I couldn't find a better way to do it. */ addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { internalCaretSet = -1; } }); /** * Set it to the location we've set it to be. */ addExtendedModifyListener(new ExtendedModifyListener() { @Override public void modifyText(ExtendedModifyEvent event) { if (internalCaretSet != -1) { if (internalCaretSet != getCaretOffset()) { setCaretOffset(internalCaretSet); } internalCaretSet = -1; } } }); initDragDrop(); handleDeletePreviousWord = new HandleDeletePreviousWord(); handleLineStartAction = new HandleLineStartAction(); }
Example #6
Source File: SyntaxHighlighter.java From RepDev with GNU General Public License v3.0 | 4 votes |
public void modifyText(ExtendedModifyEvent e) { parser.textModified(e.start, e.length, e.replacedText); }
Example #7
Source File: VerticalIndentGuidesPainter.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void modifyText(ExtendedModifyEvent event) { this.currClientArea = null; //will force redrawing everything askFullRedraw = true; }