类org.eclipse.ui.swt.IFocusService源码实例Demo

下面列出了怎么用org.eclipse.ui.swt.IFocusService的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: statecharts   文件: StyledTextXtextAdapter.java
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();
}
 
 类所在包
 同包方法