Search in sources :

Example 1 with IWorkingSetSelectionDialog

use of org.eclipse.ui.dialogs.IWorkingSetSelectionDialog in project eclipse.platform.text by eclipse.

the class FindInWorkingSetActionDelegate method createQuery.

@Override
protected ISearchQuery createQuery(TextSearchQueryProvider provider, String searchForString) throws CoreException {
    IWorkbenchPage page = getWorkbenchPage();
    if (page != null) {
        IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
        IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(page.getWorkbenchWindow().getShell(), true);
        if (dialog.open() == Window.OK) {
            IWorkingSet[] workingSets = dialog.getSelection();
            if (workingSets != null) {
                return provider.createQuery(searchForString, workingSets);
            }
        }
    }
    throw new OperationCanceledException();
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSetSelectionDialog(org.eclipse.ui.dialogs.IWorkingSetSelectionDialog) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 2 with IWorkingSetSelectionDialog

use of org.eclipse.ui.dialogs.IWorkingSetSelectionDialog in project eclipse.platform.text by eclipse.

the class ScopePart method handleChooseWorkingSet.

private boolean handleChooseWorkingSet() {
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(fUseSelection.getShell(), true);
    if (fWorkingSets != null)
        dialog.setSelection(fWorkingSets);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getSelection();
        if (result.length > 0) {
            setSelectedWorkingSets((IWorkingSet[]) result);
            return true;
        }
        // $NON-NLS-1$
        fWorkingSetText.setText("");
        fWorkingSets = null;
        if (fScope == ISearchPageContainer.WORKING_SET_SCOPE)
            setSelectedScope(ISearchPageContainer.WORKSPACE_SCOPE);
        return false;
    }
    if (fWorkingSets != null) {
        // test if selected working set has been removed
        int i = 0;
        while (i < fWorkingSets.length) {
            IWorkingSet workingSet = fWorkingSets[i];
            if (!workingSet.isAggregateWorkingSet() && workingSetManager.getWorkingSet(workingSet.getName()) == null)
                break;
            i++;
        }
        if (i < fWorkingSets.length) {
            // $NON-NLS-1$
            fWorkingSetText.setText("");
            fWorkingSets = null;
            updateSearchPageContainerActionPerformedEnablement();
        }
    }
    return false;
}
Also used : IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSetSelectionDialog(org.eclipse.ui.dialogs.IWorkingSetSelectionDialog) IWorkingSet(org.eclipse.ui.IWorkingSet)

Aggregations

IWorkingSet (org.eclipse.ui.IWorkingSet)2 IWorkingSetManager (org.eclipse.ui.IWorkingSetManager)2 IWorkingSetSelectionDialog (org.eclipse.ui.dialogs.IWorkingSetSelectionDialog)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1