Search in sources :

Example 1 with BindingService

use of org.eclipse.ui.internal.keys.BindingService in project netxms by netxms.

the class MobileApplicationWorkbenchWindowAdvisor method postWindowCreate.

/* (non-Javadoc)
	 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowCreate()
	 */
@Override
public void postWindowCreate() {
    super.postWindowCreate();
    BindingService service = (BindingService) getWindowConfigurer().getWindow().getWorkbench().getService(IBindingService.class);
    BindingManager bindingManager = service.getBindingManager();
    try {
        // $NON-NLS-1$
        bindingManager.setActiveScheme(service.getScheme("org.netxms.ui.eclipse.defaultKeyBinding"));
    } catch (NotDefinedException e) {
        e.printStackTrace();
    }
    final Shell shell = getWindowConfigurer().getWindow().getShell();
    shell.setMaximized(true);
    for (Control ctrl : shell.getChildren()) {
        // $NON-NLS-1$
        ctrl.setData(RWT.CUSTOM_VARIANT, "gray");
        if (ctrl instanceof CBanner) {
            for (Control cc : ((CBanner) ctrl).getChildren()) // $NON-NLS-1$
            cc.setData(RWT.CUSTOM_VARIANT, "gray");
        } else if (// $NON-NLS-1$
        ctrl.getClass().getName().equals("org.eclipse.swt.widgets.Composite")) {
            for (Control cc : ((Composite) ctrl).getChildren()) // $NON-NLS-1$
            cc.setData(RWT.CUSTOM_VARIANT, "gray");
        }
    }
    // $NON-NLS-1$
    shell.getMenuBar().setData(RWT.CUSTOM_VARIANT, "menuBar");
}
Also used : BindingManager(org.eclipse.jface.bindings.BindingManager) Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) CBanner(org.eclipse.swt.custom.CBanner) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 2 with BindingService

use of org.eclipse.ui.internal.keys.BindingService in project translationstudio8 by heartsome.

the class KeyController2 method filterDupliteBind.

@SuppressWarnings("restriction")
public void filterDupliteBind() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
    BindingService service = (BindingService) bindingService;
    BindingManager bindingManager = service.getBindingManager();
    //service.getBindingManager().
    Binding[] bindings = bindingManager.getBindings();
    List<Binding> bindTemp = new ArrayList<Binding>();
    List<String> ids = new ArrayList<String>();
    for (Binding bind : bindings) {
        if (null == bind) {
            continue;
        }
        ParameterizedCommand command = bind.getParameterizedCommand();
        if (null == command) {
            continue;
        }
        String id = command.getId();
        if (!ids.contains(id)) {
            ids.add(id);
            bindTemp.add(bind);
        }
    }
    bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()]));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) BindingManager(org.eclipse.jface.bindings.BindingManager) KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Example 3 with BindingService

use of org.eclipse.ui.internal.keys.BindingService in project translationstudio8 by heartsome.

the class KeyAssistHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
    BindingService service = (BindingService) bindingService;
    ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings()));
    List<String> lstRemove = Constants.lstRemove;
    Iterator<Binding> it = lstBinding.iterator();
    while (it.hasNext()) {
        Binding binding = it.next();
        ParameterizedCommand pCommand = binding.getParameterizedCommand();
        if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) {
            it.remove();
        }
    }
    service.getKeyboard().openKeyAssistShell(lstBinding);
    return null;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Example 4 with BindingService

use of org.eclipse.ui.internal.keys.BindingService in project netxms by netxms.

the class ApplicationWorkbenchWindowAdvisor method postWindowCreate.

/* (non-Javadoc)
	 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowCreate()
	 */
@Override
public void postWindowCreate() {
    super.postWindowCreate();
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    // Changes the page title at runtime
    JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
    if (executor != null) {
        StringBuilder js = new StringBuilder();
        // $NON-NLS-1$
        js.append("document.title = ");
        js.append("\"");
        js.append(BrandingManager.getInstance().getProductName());
        js.append(" - [");
        js.append(session.getUserName());
        js.append("@");
        js.append(session.getServerAddress());
        js.append("]");
        js.append("\"");
        executor.execute(js.toString());
    }
    BindingService service = (BindingService) getWindowConfigurer().getWindow().getWorkbench().getService(IBindingService.class);
    BindingManager bindingManager = service.getBindingManager();
    try {
        // $NON-NLS-1$
        bindingManager.setActiveScheme(service.getScheme("org.netxms.ui.eclipse.defaultKeyBinding"));
    } catch (NotDefinedException e) {
        e.printStackTrace();
    }
    final Shell shell = getWindowConfigurer().getWindow().getShell();
    shell.setMaximized(true);
    for (Control ctrl : shell.getChildren()) {
        // $NON-NLS-1$
        ctrl.setData(RWT.CUSTOM_VARIANT, "gray");
        if (ctrl instanceof CBanner) {
            for (Control cc : ((CBanner) ctrl).getChildren()) // $NON-NLS-1$
            cc.setData(RWT.CUSTOM_VARIANT, "gray");
        } else if (// $NON-NLS-1$
        ctrl.getClass().getName().equals("org.eclipse.swt.widgets.Composite")) {
            for (Control cc : ((Composite) ctrl).getChildren()) // $NON-NLS-1$
            cc.setData(RWT.CUSTOM_VARIANT, "gray");
        }
    }
    Menu menuBar = shell.getMenuBar();
    if (menuBar != null)
        // $NON-NLS-1$
        menuBar.setData(RWT.CUSTOM_VARIANT, "menuBar");
}
Also used : BindingManager(org.eclipse.jface.bindings.BindingManager) Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) NXCSession(org.netxms.client.NXCSession) BindingService(org.eclipse.ui.internal.keys.BindingService) IBindingService(org.eclipse.ui.keys.IBindingService) CBanner(org.eclipse.swt.custom.CBanner) JavaScriptExecutor(org.eclipse.rap.rwt.client.service.JavaScriptExecutor) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) Menu(org.eclipse.swt.widgets.Menu) IBindingService(org.eclipse.ui.keys.IBindingService)

Aggregations

BindingService (org.eclipse.ui.internal.keys.BindingService)4 IBindingService (org.eclipse.ui.keys.IBindingService)4 BindingManager (org.eclipse.jface.bindings.BindingManager)3 ArrayList (java.util.ArrayList)2 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)2 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)2 Binding (org.eclipse.jface.bindings.Binding)2 CBanner (org.eclipse.swt.custom.CBanner)2 Control (org.eclipse.swt.widgets.Control)2 Shell (org.eclipse.swt.widgets.Shell)2 IWorkbench (org.eclipse.ui.IWorkbench)2 KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)1 JavaScriptExecutor (org.eclipse.rap.rwt.client.service.JavaScriptExecutor)1 Menu (org.eclipse.swt.widgets.Menu)1 NXCSession (org.netxms.client.NXCSession)1