Search in sources :

Example 1 with IContentProposalListener2

use of org.eclipse.jface.fieldassist.IContentProposalListener2 in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationAssist method initListeners.

private void initListeners() {
    assistText.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.stateMask == SWT.NONE) {
                if (e.keyCode == SWT.ESC) {
                    disposeAssistText();
                } else if (e.keyCode == SWT.CR) {
                    acceptProposal();
                }
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
        }
    });
    assistText.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!(contentProposalAdapter.isProposalPopupOpen())) {
                disposeAssistText();
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });
    contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {

        @Override
        public void proposalPopupOpened(ContentProposalAdapter adapter) {
        }

        @Override
        public void proposalPopupClosed(ContentProposalAdapter adapter) {
            if (assistText != null && !assistText.isFocusControl()) {
                disposeAssistText();
            }
        }
    });
    contentProposalAdapter.addContentProposalListener(new IContentProposalListener() {

        @Override
        public void proposalAccepted(IContentProposal proposal) {
            acceptProposal();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) KeyListener(org.eclipse.swt.events.KeyListener) IContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) IContentProposalListener2(org.eclipse.jface.fieldassist.IContentProposalListener2) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Aggregations

ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)1 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)1 IContentProposalListener (org.eclipse.jface.fieldassist.IContentProposalListener)1 IContentProposalListener2 (org.eclipse.jface.fieldassist.IContentProposalListener2)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 KeyListener (org.eclipse.swt.events.KeyListener)1