Search in sources :

Example 1 with ContextSearchAction

use of org.jkiss.dbeaver.ui.actions.common.ContextSearchAction in project dbeaver by serge-rider.

the class EntityEditorContributor method registerSearchActions.

public static void registerSearchActions(IEditorPart activeEditor) {
    if (activeEditor == null) {
        return;
    }
    IActionBars actionBars = activeEditor.getEditorSite().getActionBars();
    if (activeEditor instanceof ISearchContextProvider) {
        ISearchContextProvider provider = (ISearchContextProvider) activeEditor;
        if (provider.isSearchPossible()) {
            ContextSearchAction findAction = new ContextSearchAction(provider, ISearchContextProvider.SearchType.NONE);
            findAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
            actionBars.setGlobalActionHandler(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE, findAction);
            ContextSearchAction findNextAction = new ContextSearchAction(provider, ISearchContextProvider.SearchType.NEXT);
            findNextAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_NEXT);
            actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.FIND_NEXT, findNextAction);
            ContextSearchAction findPrevAction = new ContextSearchAction(provider, ISearchContextProvider.SearchType.PREVIOUS);
            findPrevAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS);
            actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.FIND_PREVIOUS, findPrevAction);
        }
    } else {
        actionBars.setGlobalActionHandler(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE, null);
        actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.FIND_NEXT, null);
        actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.FIND_PREVIOUS, null);
    }
    actionBars.updateActionBars();
}
Also used : ISearchContextProvider(org.jkiss.dbeaver.ui.ISearchContextProvider) ContextSearchAction(org.jkiss.dbeaver.ui.actions.common.ContextSearchAction) IActionBars(org.eclipse.ui.IActionBars)

Aggregations

IActionBars (org.eclipse.ui.IActionBars)1 ISearchContextProvider (org.jkiss.dbeaver.ui.ISearchContextProvider)1 ContextSearchAction (org.jkiss.dbeaver.ui.actions.common.ContextSearchAction)1