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);
}
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;
}
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);
}
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;
}
Aggregations