Example usage for org.eclipse.jface.bindings.keys KeySequence getInstance

List of usage examples for org.eclipse.jface.bindings.keys KeySequence getInstance

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys KeySequence getInstance.

Prototype

public static final KeySequence getInstance() 

Source Link

Document

Gets an instance of KeySequence.

Usage

From source file:com.aptana.scripting.keybindings.internal.KeyBindingState.java

License:Open Source License

/**
 * Constructs a new instance of <code>KeyBindingState</code> with an empty key sequence, set to reset fully.
 *
 * @param workbenchToNotify// www  .j  a  v a  2s  .com
 *            The workbench that this state should keep advised of changes to the key binding state; must not be
 *            <code>null</code>.
 */
KeyBindingState(IWorkbench workbenchToNotify) {
    currentSequence = KeySequence.getInstance();
    workbench = workbenchToNotify;
    associatedWindow = workbench.getActiveWorkbenchWindow();
}

From source file:com.aptana.scripting.keybindings.internal.KeyBindingState.java

License:Open Source License

/**
 * <p>/*from   www.  jav a2 s.co  m*/
 * Resets the state based on the current properties. If the state is to collapse fully or if there are no key
 * strokes, then it sets the state to have an empty key sequence. Otherwise, it leaves the first key stroke in the
 * sequence.
 * </p>
 * <p>
 * The workbench's status lines are updated, if appropriate.
 * </p>
 */
void reset() {
    currentSequence = KeySequence.getInstance();
}

From source file:com.mousefeed.eclipse.ActionActionDescGenerator.java

License:Open Source License

/**
 * Scans bindings for the action.//from   w  w w  .  ja  va 2  s . c  om
 * 
 * @param action
 *            the action to scan bindings for. Assumed not <code>null</code>
 *            .
 * @return the accelerator from the action trigger sequence.
 *         <code>null</code> if the binding was not found.
 */
@SuppressWarnings("rawtypes")
private String scanBindings(final IAction action) {
    final KeySequence keySequence = KeySequence.getInstance();
    // In eclipse 4 BindingService#getPartialMatches() doesn't call the
    // BindingManager any more leading to an ArrayIndexOutOfBoundsException
    // due to bad code quality. Only for this reason, mousefeed needs to
    // perform a direct call on the BindingManager now.
    if (bindingService instanceof BindingService) {
        final BindingService theBindingService = (BindingService) bindingService;
        final Map matches = theBindingService.getBindingManager().getPartialMatches(keySequence);

        final Class<? extends IAction> actionClass = action.getClass();
        for (Object o : matches.keySet()) {
            final TriggerSequence triggerSequence = (TriggerSequence) o;
            final Binding binding = (Binding) matches.get(triggerSequence);
            final Command command = binding.getParameterizedCommand().getCommand();
            final IHandler handler = getCommandHandler(command);
            if (!(handler instanceof ActionHandler)) {
                continue;
            }

            if (isCommandEnabled(command)) {
                final String accelerator = getFromBindingData(action, actionClass, triggerSequence, handler);
                if (accelerator != null) {
                    return accelerator;
                }
            }
        }
    }
    return null;
}

From source file:descent.internal.ui.text.java.ContentAssistProcessor.java

License:Open Source License

public ContentAssistProcessor(ContentAssistant assistant, String partition) {
    Assert.isNotNull(partition);/*w  w w .  j av a2 s.com*/
    Assert.isNotNull(assistant);
    fPartition = partition;
    fCategories = CompletionProposalComputerRegistry.getDefault().getProposalCategories();
    fAssistant = assistant;
    fAssistant.addCompletionListener(new ICompletionListener() {

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionStarted(org.eclipse.jface.text.contentassist.ContentAssistEvent)
         */
        public void assistSessionStarted(ContentAssistEvent event) {
            if (event.processor != ContentAssistProcessor.this)
                return;

            fIterationGesture = getIterationGesture();
            KeySequence binding = getIterationBinding();

            // this may show the warning dialog if all categories are disabled
            fCategoryIteration = getCategoryIteration();
            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                CompletionProposalCategory cat = (CompletionProposalCategory) it.next();
                cat.sessionStarted();
            }

            fRepetition = 0;
            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;

                if (fCategoryIteration.size() == 1) {
                    extension.setRepeatedInvocationMode(false);
                    extension.setShowEmptyList(false);
                } else {
                    extension.setRepeatedInvocationMode(true);
                    extension.setStatusLineVisible(true);
                    extension.setStatusMessage(createIterationMessage());
                    extension.setShowEmptyList(true);
                    if (extension instanceof IContentAssistantExtension3) {
                        IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                        ((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
                    }
                }

            }
        }

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionEnded(org.eclipse.jface.text.contentassist.ContentAssistEvent)
         */
        public void assistSessionEnded(ContentAssistEvent event) {
            if (event.processor != ContentAssistProcessor.this)
                return;

            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                CompletionProposalCategory cat = (CompletionProposalCategory) it.next();
                cat.sessionEnded();
            }

            fCategoryIteration = null;
            fRepetition = -1;
            fIterationGesture = null;
            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
                extension.setShowEmptyList(false);
                extension.setRepeatedInvocationMode(false);
                extension.setStatusLineVisible(false);
                if (extension instanceof IContentAssistantExtension3) {
                    IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                    ((ContentAssistant) ext3).setRepeatedInvocationTrigger(KeySequence.getInstance());
                }
            }
        }

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#selectionChanged(org.eclipse.jface.text.contentassist.ICompletionProposal, boolean)
         */
        public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
        }

    });
}

From source file:org.cfeclipse.cfml.editors.contentassist.CFEPrimaryAssist.java

License:Open Source License

/**
 * @param sourceViewer /*from  www. java2  s. c  o m*/
 * @param assistant 
 * 
 */
public CFEPrimaryAssist(ISourceViewer sourceViewer, ContentAssistant assistant) {
    super();
    fContentAssistant = assistant;
    fSourceViewer = sourceViewer;
    generateAutoActivationChars();
    // content assist category cycling
    fContentAssistant.addCompletionListener(new ICompletionListener() {
        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionStarted(org.eclipse.jface.text.contentassist.ContentAssistEvent)
         */
        public void assistSessionStarted(ContentAssistEvent event) {
            if (event.processor != CFEPrimaryAssist.this)
                return;
            fIterationGesture = getIterationGesture();
            KeySequence binding = getIterationBinding();

            // this may show the warning dialog if all categories are disabled
            fCategoryIteration = getCategoryIteration();
            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                IAssistContributor cat = (IAssistContributor) it.next();
                cat.sessionStarted();
            }
            //System.out.println("catItSize "+fCategoryIteration.size());
            fRepetition = 0;
            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;

                if (fCategoryIteration.size() == 1) {
                    extension.setRepeatedInvocationMode(false);
                    extension.setShowEmptyList(false);
                } else {
                    extension.setRepeatedInvocationMode(true);
                    extension.setStatusLineVisible(true);
                    extension.setStatusMessage(createIterationMessage());
                    extension.setShowEmptyList(true);
                    if (extension instanceof IContentAssistantExtension3) {
                        IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                        ((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
                    }
                }

            }
        }

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionEnded(org.eclipse.jface.text.contentassist.ContentAssistEvent)
         */
        public void assistSessionEnded(ContentAssistEvent event) {
            if (event.processor != CFEPrimaryAssist.this)
                return;
            fCategoryIteration = null;
            fState = null;
            fRepetition = -1;
            fIterationGesture = null;
            if (fCategories == null) {
                return;
            }
            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                IAssistContributor cat = (IAssistContributor) it.next();
                cat.sessionEnded();
            }

            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
                extension.setShowEmptyList(false);
                extension.setRepeatedInvocationMode(false);
                extension.setStatusLineVisible(false);
                if (extension instanceof IContentAssistantExtension3) {
                    IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                    ((ContentAssistant) ext3).setRepeatedInvocationTrigger(KeySequence.getInstance());
                }
            }
        }

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#selectionChanged(org.eclipse.jface.text.contentassist.ICompletionProposal, boolean)
         */
        public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
        }

    });
    setRootAssistorsToCategories();
}

From source file:org.eclipse.dltk.mod.ui.text.completion.ContentAssistProcessor.java

License:Open Source License

public ContentAssistProcessor(ContentAssistant assistant, String partition) {
    Assert.isNotNull(partition);//from  ww w.  j  ava  2s. co m
    Assert.isNotNull(assistant);

    fPartition = partition;
    fCategories = CompletionProposalComputerRegistry.getDefault().getProposalCategories();
    fAssistant = assistant;
    fAssistant.addCompletionListener(new ICompletionListener() {

        public void assistSessionStarted(ContentAssistEvent event) {
            if (event.processor != ContentAssistProcessor.this)
                return;

            fIterationGesture = getIterationGesture();
            KeySequence binding = getIterationBinding();

            // this may show the warning dialog if all categories are
            // disabled
            fCategoryIteration = getCategoryIteration();
            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                CompletionProposalCategory cat = (CompletionProposalCategory) it.next();
                cat.sessionStarted();
            }

            fRepetition = 0;
            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;

                if (fCategoryIteration.size() == 1) {
                    extension.setRepeatedInvocationMode(false);
                    extension.setShowEmptyList(false);
                } else {
                    extension.setRepeatedInvocationMode(true);
                    extension.setStatusLineVisible(true);
                    extension.setStatusMessage(createIterationMessage());
                    extension.setShowEmptyList(true);
                    if (extension instanceof IContentAssistantExtension3) {
                        IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                        ((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
                    }
                }

            }
        }

        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionEnded(org.eclipse.jface.text.contentassist.ContentAssistEvent)
         */
        public void assistSessionEnded(ContentAssistEvent event) {
            if (event.processor != ContentAssistProcessor.this)
                return;

            for (Iterator it = fCategories.iterator(); it.hasNext();) {
                CompletionProposalCategory cat = (CompletionProposalCategory) it.next();
                cat.sessionEnded();
            }

            fCategoryIteration = null;
            fRepetition = -1;
            fIterationGesture = null;
            if (event.assistant instanceof IContentAssistantExtension2) {
                IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
                extension.setShowEmptyList(false);
                extension.setRepeatedInvocationMode(false);
                extension.setStatusLineVisible(false);
                if (extension instanceof IContentAssistantExtension3) {
                    IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
                    ((ContentAssistant) ext3).setRepeatedInvocationTrigger(KeySequence.getInstance());
                }
            }
        }

        public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
        }

    });
}

From source file:org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.java

License:Open Source License

private void resetState(boolean clearRememberedState) {
    startTime = Long.MAX_VALUE;//from   ww w .j  a v a  2s . c  o  m
    state = KeySequence.getInstance();
    closeMultiKeyAssistShell();
    if (keyAssistDialog != null && clearRememberedState) {
        keyAssistDialog.clearRememberedState();
    }
}

From source file:org.eclipse.e4.ui.keybinding.tests.Bug42024Test.java

License:Open Source License

/**
 * Tests that a zero-length stroke can be inserted into the KeySequenceText --
 * regardless of whether the stroke limit is some positive integer or
 * infinite./*from   w ww  .ja  v  a 2s. c o  m*/
 */
public void testZeroStroke() {
    KeySequence zeroStrokeSequence = KeySequence.getInstance();

    // Test with a limit of four.
    text.setKeyStrokeLimit(4);
    text.setKeySequence(zeroStrokeSequence);
    assertEquals("Limit of four changed zero stroke sequence.", zeroStrokeSequence, text.getKeySequence()); //$NON-NLS-1$

    // Test with an infinite limit.
    text.setKeyStrokeLimit(KeySequenceText.INFINITE);
    text.setKeySequence(zeroStrokeSequence);
    assertEquals("Infinite limit changed zero stroke sequence.", zeroStrokeSequence, text.getKeySequence()); //$NON-NLS-1$
}

From source file:org.eclipse.ui.internal.keys.BindingService.java

License:Open Source License

public TriggerSequence getBuffer() {
    if (dispatcher == null) {
        return KeySequence.getInstance();
    }
    return dispatcher.getBuffer();
}

From source file:org.eclipse.ui.internal.keys.KeyBindingState.java

License:Open Source License

/**
 * <p>//  w w  w  .  j  a v a  2  s . co m
 * Resets the state based on the current properties. If the state is to
 * collapse fully or if there are no key strokes, then it sets the state to
 * have an empty key sequence. Otherwise, it leaves the first key stroke in
 * the sequence.
 * </p>
 * <p>
 * The workbench's status lines are updated, if appropriate.
 * </p>
 */
void reset() {
    currentSequence = KeySequence.getInstance();
    updateStatusLines();
}