Example usage for org.eclipse.jface.bindings.keys.formatting KeyFormatterFactory setDefault

List of usage examples for org.eclipse.jface.bindings.keys.formatting KeyFormatterFactory setDefault

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys.formatting KeyFormatterFactory setDefault.

Prototype

public static final void setDefault(final IKeyFormatter defaultKeyFormatter) 

Source Link

Document

Sets the default key formatter.

Usage

From source file:org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.java

License:Open Source License

/**
 * Initialize a part renderer from the extension point.
 * /*from  ww w.jav a  2  s  .  c  o  m*/
 * @param context
 *            the context for the part factories
 */
@PostConstruct
void initialize(IEclipseContext context) {
    this.appContext = context;

    // initialize the correct key-binding display formatter
    KeyFormatterFactory.setDefault(SWTKeySupport.getKeyFormatterForPlatform());

    // Add the renderer to the context
    context.set(IPresentationEngine.class.getName(), this);

    IRendererFactory factory = null;
    IContributionFactory contribFactory = context.get(IContributionFactory.class);
    try {
        factory = (IRendererFactory) contribFactory.create(factoryUrl, context);
    } catch (Exception e) {
        logger.warn(e, "Could not create rendering factory");
    }

    // Try to load the default one
    if (factory == null) {
        try {
            factory = (IRendererFactory) contribFactory.create(defaultFactoryUrl, context);
        } catch (Exception e) {
            logger.error(e, "Could not create default rendering factory");
        }
    }

    if (factory == null) {
        throw new IllegalStateException("Could not create any rendering factory. Aborting ...");
    }

    curFactory = factory;
    context.set(IRendererFactory.class, curFactory);

    // Hook up the widget life-cycle subscriber
    if (eventBroker != null) {
        eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, toBeRenderedHandler);
        eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, visibilityHandler);
        eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, childrenHandler);
        eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, windowsHandler);
        eventBroker.subscribe(UIEvents.Perspective.TOPIC_WINDOWS, windowsHandler);
        eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, trimHandler);
    }
}

From source file:org.eclipse.rcptt.tesla.ui.Q7KeyFormatter.java

License:Open Source License

public static void installQ7Formatter() {
    KeyFormatterFactory.setDefault(new Q7KeyFormatter());
    IWorkbench workbench = PlatformUI.getWorkbench();
    for (IWorkbenchWindow w : workbench.getWorkbenchWindows()) {
        if (!(w instanceof WorkbenchWindow))
            continue;

        final WorkbenchWindow ww = (WorkbenchWindow) w;
        final Shell shell = ww.getShell();
        final CoolBarManager coolBarManager = ww.getCoolBarManager();

        if (shell != null && coolBarManager != null)
            shell.getDisplay().syncExec(new Runnable() {
                public void run() {
                    try {
                        shell.setLayoutDeferred(true);
                        IContributionItem[] items = coolBarManager.getItems();
                        coolBarManager.setItems(new IContributionItem[0]);
                        coolBarManager.setItems(items);
                    } finally {
                        shell.setLayoutDeferred(false);
                    }/*from   w  ww.  j  a  va2 s .  c o m*/
                }
            });
    }
}