org.eclipse.ui.swt.IFocusService Java Examples
The following examples show how to use
org.eclipse.ui.swt.IFocusService.
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: 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(); }