public void widgetSelected( SelectionEvent event ) { if ( styledText.getSelectionCount() == styledText.getCharCount() ) { bFullSelection = true; try { event.wait( 2 ); } catch ( Exception e ) { // Ignore errors } } }
private void printKeyValue(final StyledText styledText,String key, String value) { value += styledText.getLineDelimiter(); StyleRange style = getKeyStyle(); style.start = styledText.getCharCount(); style.length = key.length(); styledText.append(key); styledText.setStyleRange(style); styledText.setCaretOffset(styledText.getCharCount()); styledText.showSelection(); StyleRange style1 = getValueStyle(); style1.start = styledText.getCharCount(); style1.length = value.length(); styledText.append(value); styledText.setStyleRange(style1); styledText.setCaretOffset(styledText.getCharCount()); styledText.showSelection(); }
public void dragOver( DropTargetEvent e ) { styledText.setFocus(); Point location = xParent.getDisplay().map( null, styledText, e.x, e.y ); location.x = Math.max( 0, location.x ); location.y = Math.max( 0, location.y ); try { int offset = styledText.getOffsetAtLocation( new Point( location.x, location.y ) ); styledText.setCaretOffset( offset ); } catch ( IllegalArgumentException ex ) { int maxOffset = styledText.getCharCount(); Point maxLocation = styledText.getLocationAtOffset( maxOffset ); if ( location.y >= maxLocation.y ) { if ( location.x >= maxLocation.x ) { styledText.setCaretOffset( maxOffset ); } else { int offset = styledText.getOffsetAtLocation( new Point( location.x, maxLocation.y ) ); styledText.setCaretOffset( offset ); } } else { styledText.setCaretOffset( maxOffset ); } } }
private void redo() { if ( redoStack.size() > 0 ) { UndoRedoStack urs = redoStack.remove( 0 ); if ( undoStack.size() == MAX_STACK_SIZE ) { undoStack.remove( undoStack.size() - 1 ); } UndoRedoStack rro = new UndoRedoStack( urs.getCursorPosition(), urs.getReplacedText(), styledText.getText(), urs .getEventLength(), urs.getType() ); bFullSelection = false; styledText.setText( urs.getReplacedText() ); if ( urs.getType() == UndoRedoStack.INSERT ) { styledText.setCaretOffset( urs.getCursorPosition() ); } else if ( urs.getType() == UndoRedoStack.DELETE ) { styledText.setCaretOffset( urs.getCursorPosition() + urs.getEventLength() ); styledText.setSelection( urs.getCursorPosition(), urs.getCursorPosition() + urs.getEventLength() ); if ( styledText.getSelectionCount() == styledText.getCharCount() ) { bFullSelection = true; } } undoStack.add( 0, rro ); } }
private void undo() { if ( undoStack.size() > 0 ) { UndoRedoStack urs = undoStack.remove( 0 ); if ( redoStack.size() == MAX_STACK_SIZE ) { redoStack.remove( redoStack.size() - 1 ); } UndoRedoStack rro = new UndoRedoStack( urs.getCursorPosition(), urs.getReplacedText(), styledText.getText(), urs .getEventLength(), urs.getType() ); bFullSelection = false; styledText.setText( urs.getReplacedText() ); if ( urs.getType() == UndoRedoStack.INSERT ) { styledText.setCaretOffset( urs.getCursorPosition() ); } else if ( urs.getType() == UndoRedoStack.DELETE ) { styledText.setCaretOffset( urs.getCursorPosition() + urs.getEventLength() ); styledText.setSelection( urs.getCursorPosition(), urs.getCursorPosition() + urs.getEventLength() ); if ( styledText.getSelectionCount() == styledText.getCharCount() ) { bFullSelection = true; } } redoStack.add( 0, rro ); } }
@Override public void getCharacterCount(AccessibleTextEvent e) { e.count = StyledText.this.getCharCount(); } @Override
@Override public boolean hasContents() { return fText.getCharCount() > 0; }
@Override public boolean hasContents() { return fText.getCharCount() > 0; }
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } public void getSelection(AccessibleTextEvent e) {
public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } public void getCharacterCount(AccessibleTextEvent e) {
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
public void lineGetBackground(LineBackgroundEvent event) { StyledText text = getTextWidget(); if (event.lineOffset < text.getCharCount()) { StyleRange style = text .getStyleRangeAtOffset(event.lineOffset); if (style instanceof DiffStyleRange) event.lineBackground = ((DiffStyleRange) style).lineBackground; } } });
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
@Override public void mouseScrolled(MouseEvent e) { int caretOffset = fMinimapTextWidget.getOffsetAtPoint(new Point(0, fTopIndexY)); int lineIndex = fMinimapTextWidget.getLineAtOffset(caretOffset); if (e.count > 0) { lineIndex = Math.max(0, lineIndex - NB_LINES_SCROLL); } else { lineIndex = Math.min(fMinimapTextWidget.getCharCount(), lineIndex + NB_LINES_SCROLL); } caretOffset = fMinimapTextWidget.getOffsetAtLine(lineIndex); fMinimapTextWidget.setCaretOffset(caretOffset); }
public boolean isValidWidgetOffset(int widgetOffset) { if (fContentAssistSubjectControl != null) { IDocument document= fContentAssistSubjectControl.getDocument(); return (widgetOffset >= 0 && widgetOffset <= document.getLength()); } return (widgetOffset >= 0 && widgetOffset <= fViewer.getTextWidget().getCharCount()); }
public void setVisible(boolean visible) { super.setVisible(visible); value.setText(pattern.getLexicalValue()); value.setCaretOffset(value.getCharCount()); }