Java Code Examples for org.eclipse.swt.custom.StyledText#setData()
The following examples show how to use
org.eclipse.swt.custom.StyledText#setData() .
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: GamlEditorDragAndDropHandler.java From gama with GNU General Public License v3.0 | 6 votes |
protected void uninstall() { if (getViewer() == null || !fIsTextDragAndDropInstalled) { return; } final IDragAndDropService dndService = editor.getSite().getService(IDragAndDropService.class); if (dndService == null) { return; } final StyledText st = getStyledText(); dndService.removeMergedDropTarget(st); final DragSource dragSource = (DragSource) st.getData(DND.DRAG_SOURCE_KEY); if (dragSource != null) { dragSource.dispose(); st.setData(DND.DRAG_SOURCE_KEY, null); } fIsTextDragAndDropInstalled = false; }
Example 2
Source File: StyledTextXtextAdapter.java From statecharts with Eclipse Public License 1.0 | 4 votes |
public void adapt(StyledText styledText, boolean decorate) { this.styledText = styledText; // perform initialization of fake resource context updateFakeResourceContext(); // connect Xtext document to fake resource initXtextDocument(getFakeResourceContext()); // connect xtext document to xtext source viewer this.sourceviewer = createXtextSourceViewer(); this.decorationSupport = createSourceViewerDecorationSupport(); configureSourceViewerDecorationSupport(getDecorationSupport()); // install semantic highlighting support installHighlightingHelper(); this.validationJob = createValidationJob(); getXtextDocument().setValidationJob(getValidationJob()); styledText.setData(StyledTextXtextAdapter.class.getCanonicalName(), this); final IContentAssistant contentAssistant = getXtextSourceviewer().getContentAssistant(); final CompletionProposalAdapter completionProposalAdapter = new CompletionProposalAdapter(styledText, contentAssistant, KeyStroke.getInstance(SWT.CTRL, SWT.SPACE), null); if ((styledText.getStyle() & SWT.SINGLE) != 0) { // The regular key down event is too late (after popup is closed). // when using the StyledText.VerifyKey event (3005), we get the // event early enough! styledText.addListener(3005, new Listener() { @Override public void handleEvent(Event event) { if (event.character == SWT.CR && !completionProposalAdapter.isProposalPopupOpen()) { Event selectionEvent = new Event(); selectionEvent.type = SWT.DefaultSelection; selectionEvent.widget = event.widget; for (Listener l : event.widget.getListeners(SWT.DefaultSelection)) { l.handleEvent(selectionEvent); } } } }); } // Register focus tracker for evaluating the active focus control in // core expression IFocusService service = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class); service.addFocusTracker(styledText, StyledText.class.getCanonicalName()); if (decorate) { // add JDT Style code completion hint decoration this.decoration = createContentAssistDecoration(styledText); } initSelectionProvider(); }