Search in sources :

Example 11 with IBindingService

use of org.eclipse.ui.keys.IBindingService in project eclipse.platform.text by eclipse.

the class ContentAssistHandler method installCueLabelProvider.

/**
 * Create and install the {@link LabelProvider} for fContentAssistSubjectAdapter.
 */
private void installCueLabelProvider() {
    ILabelProvider labelProvider = new LabelProvider() {

        @Override
        public String getText(Object element) {
            IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
            TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
            if (activeBindings.length == 0)
                return ContentAssistMessages.ContentAssistHandler_contentAssistAvailable;
            return NLSUtility.format(ContentAssistMessages.ContentAssistHandler_contentAssistAvailableWithKeyBinding, activeBindings[0].format());
        }
    };
    fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider);
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 12 with IBindingService

use of org.eclipse.ui.keys.IBindingService in project eclipse.platform.text by eclipse.

the class TextFileDocumentProvider method getStatus.

@Override
public IStatus getStatus(Object element) {
    FileInfo info = fFileInfoMap.get(element);
    if (info == null)
        return ((IDocumentProviderExtension) getParentProvider()).getStatus(element);
    IStatus status = info.fTextFileBuffer.getStatus();
    if (status.getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) {
        String message = status.getMessage();
        IBindingService bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
        String keySequence = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.FILE_REFRESH);
        if (keySequence != null)
            message = message + NLSUtility.format(TextEditorMessages.TextFileDocumentProvider_error_outOfSyncHintWithKeyBinding, keySequence);
        else
            message = message + TextEditorMessages.TextFileDocumentProvider_error_outOfSyncHint;
        return new Status(status.getSeverity(), status.getPlugin(), status.getCode(), message, status.getException());
    }
    // Ensure that we don't open an empty document for an non-existent IFile
    if (status.getSeverity() != IStatus.ERROR && element instanceof IFileEditorInput) {
        IFile file = FileBuffers.getWorkspaceFileAtLocation(info.fTextFileBuffer.getLocation());
        if (file == null || !file.exists()) {
            String message = NLSUtility.format(TextEditorMessages.TextFileDocumentProvider_error_doesNotExist, ((IFileEditorInput) element).getFile().getFullPath());
            return new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IResourceStatus.RESOURCE_NOT_FOUND, message, null);
        }
    }
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 13 with IBindingService

use of org.eclipse.ui.keys.IBindingService in project eclipse.platform.text by eclipse.

the class SearchView method getShowInMenuLabel.

private String getShowInMenuLabel() {
    String keyBinding = null;
    IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
    if (bindingService != null)
        keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU);
    if (keyBinding == null)
        // $NON-NLS-1$
        keyBinding = "";
    return NLS.bind(SearchMessages.SearchView_showIn_menu, keyBinding);
}
Also used : IBindingService(org.eclipse.ui.keys.IBindingService)

Example 14 with IBindingService

use of org.eclipse.ui.keys.IBindingService in project knime-core by knime.

the class AbstractNodeAction method getHotkey.

/**
 * @param commandID from the org.knime.workbench.editor/plugin.xml which links the action to the the label/shortcut sequence
 * @return shortcut sequence or empty string if no shortcut sequence is available
 */
public String getHotkey(final String commandID) {
    IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
    if (bindingService == null) {
        return "";
    }
    String hotkey = bindingService.getBestActiveBindingFormattedFor(commandID);
    return (hotkey == null) ? "" : hotkey;
}
Also used : IBindingService(org.eclipse.ui.keys.IBindingService)

Aggregations

IBindingService (org.eclipse.ui.keys.IBindingService)14 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)3 Binding (org.eclipse.jface.bindings.Binding)3 IWorkbench (org.eclipse.ui.IWorkbench)3 ArrayList (java.util.ArrayList)2 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 BindingManager (org.eclipse.jface.bindings.BindingManager)2 Scheme (org.eclipse.jface.bindings.Scheme)2 TriggerSequence (org.eclipse.jface.bindings.TriggerSequence)2 BindingService (org.eclipse.ui.internal.keys.BindingService)2 ContextType (com.reprezen.swagedit.core.assist.contexts.ContextType)1 Command (org.eclipse.core.commands.Command)1 CommandManager (org.eclipse.core.commands.CommandManager)1 ContextManager (org.eclipse.core.commands.contexts.ContextManager)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFile (org.eclipse.core.resources.IFile)1 IResourceStatus (org.eclipse.core.resources.IResourceStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1