How can I disable Quick Access TextField in Eclipse RCP Application

只谈情不闲聊 提交于 2019-12-22 17:20:13

问题


today I changed my Eclipse IDE from 3.7 to 4.2 and my plugin-project has a new feature in the Statusbar of the UI called QuickAccess. But I dont need it, so how can I disable this feature, because the position of my button bar has changed...


回答1:


Go to Help --> Install New Software https://raw.github.com/atlanto/eclipse-4.x-filler/master/pdt_tools.eclipse-4.x-filler.update/

Install that Plugin and Restart the Eclipse. Quick Access automatically hide. or else you have an option to hide Window --> Hide Quick Access.




回答2:


For all who have the same problem, it seems that this new feature is hardcoded and can't be disabled :/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=362420




回答3:


Here's a post that shows a way to hide it with CSS. Verified with Eclipse 4.3




回答4:


Lars Vogel just reported in his blog post "Porting Eclipse 3.x RCP application to Eclipse 4.4 – now without QuickAccess box":

Bug 411821 ([QuickAccess] Contribute SearchField through a fragment or other means) is now solved.
Thanks to René Brandstetter:

If a RCP app doesn't provide the QuickAccess element in its model, than it will not be visible. So the default is no QuickAcces, easy enough? :)

See the commit 839ee2 for more details

Provide the "QuickAccess" via a e4 application model fragment inside of the "org.eclipse.ui.ide.application".
This removes the "QuickAccess" search field from every none "org.eclipse.ui.ide.application".




回答5:


You could also hide it and make it work comparable to how it used to work in Eclipse3.7: when user presses ctrl+3 Quick Access functionality pops up (In Eclipse4.3 the ctrl+3 shortcut is still available).

Example of code you could add to your implementation of WorkbenchWindowAdvisor (for Eclipse4.3 rcp application)

private IHandlerActivation quickAccessHandlerActivation;

@Override
public void postWindowOpen() {
    hideQuickAccess();
}

private void hideQuickAccess() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    setQuickAccessVisible(window, false);

    final IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
    quickAccessHandlerActivation = service.activateHandler(QUICK_ACCESS_COMMAND_ID, new CustomQuickAccessHandler());
}

private void setQuickAccessVisible(IWorkbenchWindow window, boolean visible) {
    if (window instanceof WorkbenchWindow) {
        MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();

        for (MTrimElement element : topTrim.getChildren()) {
            if (QUICK_ACCESS_ELEMENT_ID.equals(element.getElementId())) {
                element.setVisible(visible);
                if (visible) {
                    Composite control = (Composite) element.getWidget();
                    control.getChildren()[0].addFocusListener(new QuickAccessFocusListener());
                }
                break;
            }
        }
    }
}

private class QuickAccessFocusListener implements FocusListener {

    @Override
    public void focusGained(FocusEvent e) {
        //not interested
    }

    @Override
    public void focusLost(FocusEvent e) {
        ((Control) e.widget).removeFocusListener(this);
        hideQuickAccess();
    }

}

private class CustomQuickAccessHandler extends AbstractHandler {
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        final IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
        setQuickAccessVisible(window, true);
        if (quickAccessHandlerActivation != null) {
            service.deactivateHandler(quickAccessHandlerActivation);

            try {
                return service.executeCommand(QUICK_ACCESS_COMMAND_ID, null);
            } catch (NotDefinedException e) {

            } catch (NotEnabledException e) {

            } catch (NotHandledException e) {

            }
        }

        return null;
    }

}


来源:https://stackoverflow.com/questions/11296122/how-can-i-disable-quick-access-textfield-in-eclipse-rcp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!