public int getCaretOffset() { StructuredTextViewer stv = fTextEditor.getTextViewer(); if ((stv != null) && (stv.getTextWidget() != null) && !stv.getTextWidget().isDisposed()) { return stv.widgetOffset2ModelOffset(stv.getTextWidget().getCaretOffset()); } return 0; }
public void doExecute() { _textEditor.getTextViewer().getTextWidget().insert((String) _data); }
public int getOffset(StructuredTextEditor textEditor, Point location) { StyledText text = textEditor.getTextViewer().getTextWidget(); return text.getOffsetAtLocation(location); }
public void changeCaret(StructuredTextEditor textEditor, boolean reset) { if (reset) { StyledText text = textEditor.getTextViewer().getTextWidget(); text.setCursor(new Cursor(null, SWT.CURSOR_IBEAM)); } }
protected boolean statusCheckOk() { try { StyledText text = _editor.getHTMLEditor().getTextEditor() .getTextViewer().getTextWidget(); if (text == null || text.isDisposed()) { return false; } return true; } catch (NullPointerException ex) { return false; } }
public void drop(DropTargetEvent event) { StyledText text = null; if (_textEditor.getTextViewer() != null) { text = _textEditor.getTextViewer().getTextWidget(); } text.setCaretOffset(_location); Command command = getCommand(event); if (command == null) { return; } command.execute(); }
public int showCaret(StructuredTextEditor textEditor, int location) { StyledText text = textEditor.getTextViewer().getTextWidget(); text.setCursor(SharedCursors.CURSOR_TREE_ADD); text.setCaretOffset(location); if (!text.isFocusControl()) { text.setFocus(); } return text.getCaretOffset(); }
public void mouseMove(MouseEvent event) { Object object = getPaletteObject(); StyledText text = null; if (_textEditor.getTextViewer() != null) { text = _textEditor.getTextViewer().getTextWidget(); } else { return; } if (object == null) { // set to default cusror text.setCursor(null); return; } Point p = new Point(event.x, event.y); p = _textEditor.getTextViewer().getTextWidget().toDisplay(p); SourceViewerDragDropHelper.getInstance().updateCaret(_textEditor, p); _location = text.getCaretOffset(); _location = SourceViewerDragDropHelper.getInstance().getValidLocation( _textEditor, _location); _location = SourceViewerDragDropHelper.getInstance().showCaret( _textEditor, _location); }
SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) { SourceViewer viewer = null; String contentTypeID = ContentTypeIdForXML.ContentTypeID_XML; viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); ((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(viewerConfiguration); viewer.setDocument(document); return viewer; }
DesignerSourceMouseTrackAdapter adapter = new DesignerSourceMouseTrackAdapter( _textEditor, getEditDomain()); _textEditor.getTextViewer().getTextWidget().addMouseListener( adapter); _textEditor.getTextViewer().getTextWidget().addMouseMoveListener( adapter); } catch (PartInitException exception) {
/** * Creates, configures and returns a source viewer to present the template * pattern on the preference page. Clients may override to provide a * custom source viewer featuring e.g. syntax coloring. * * @param parent * the parent control * @return a configured source viewer */ private SourceViewer createViewer(Composite parent) { SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXML(); public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return baseConfiguration.getConfiguredContentTypes(sourceViewer); } public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); } }; SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); ((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(sourceViewerConfiguration); viewer.setDocument(document); return viewer; }
private int getDropOffset(StructuredTextEditor ste, Point pt) { StyledText st = ste.getTextViewer().getTextWidget(); int offset = st.getCaretOffset(); try {
public void dragOver(DropTargetEvent event) { StyledText text = null; if (_textEditor.getTextViewer() != null) { text = _textEditor.getTextViewer().getTextWidget(); if (TemplateTransfer.getInstance().isSupportedType( event.currentDataType)) { if (_textEditor.getTextViewer() != null) { Point p = new Point(event.x, event.y); SourceViewerDragDropHelper.getInstance().updateCaret( _textEditor, p); _location = text.getCaretOffset(); if (TemplateTransfer.getInstance().isSupportedType( event.currentDataType)) { _location = SourceViewerDragDropHelper.getInstance() .getValidLocation(_textEditor, _location); } SourceViewerDragDropHelper.getInstance().showCaret( _textEditor, _location); } } else if (TextTransfer.getInstance().isSupportedType( event.currentDataType)) { super.dragOver(event); _location = text.getCaretOffset(); } } }