Search in sources :

Example 26 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project che by eclipse.

the class JavaSearchScopeFactory method createJavaSearchScope.

public IJavaSearchScope createJavaSearchScope(IWorkingSet[] workingSets, int includeMask) {
    if (workingSets == null || workingSets.length < 1)
        return EMPTY_SCOPE;
    Set<IJavaElement> javaElements = new HashSet<IJavaElement>(workingSets.length * 10);
    for (int i = 0; i < workingSets.length; i++) {
        IWorkingSet workingSet = workingSets[i];
        if (workingSet.isEmpty() && workingSet.isAggregateWorkingSet()) {
            return createWorkspaceScope(includeMask);
        }
        addJavaElements(javaElements, workingSet);
    }
    return createJavaSearchScope(javaElements, includeMask);
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IWorkingSet(org.eclipse.ui.IWorkingSet) HashSet(java.util.HashSet)

Example 27 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project translationstudio8 by heartsome.

the class WorkingSetActionProvider method setWorkingSet.

/**
	 * Set current active working set.
	 * 
	 * @param workingSet
	 *            working set to be activated, may be <code>null</code>
	 */
protected void setWorkingSet(IWorkingSet workingSet) {
    this.workingSet = workingSet;
    emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty();
    ignoreFilterChangeEvents = true;
    try {
        workingSetActionGroup.setWorkingSet(workingSet);
    } finally {
        ignoreFilterChangeEvents = false;
    }
    if (viewer != null) {
        setWorkingSetFilter(workingSet);
        if (workingSet == null || emptyWorkingSet || !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS)) {
            if (viewer.getInput() != originalViewerInput) {
                viewer.setInput(originalViewerInput);
            } else {
                viewer.refresh();
            }
        } else {
            if (!workingSet.isAggregateWorkingSet()) {
                IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
                viewer.setInput(workingSetManager.createAggregateWorkingSet("", "", //$NON-NLS-1$ //$NON-NLS-2$
                new IWorkingSet[] { workingSet }));
            } else {
                viewer.setInput(workingSet);
            }
        }
    }
}
Also used : IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 28 with IWorkingSet

use of org.eclipse.ui.IWorkingSet 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)

Example 29 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project eclipse.platform.text by eclipse.

the class ScopePart method setSelectedWorkingSets.

/**
 * Sets the selected working set for this part.
 * This method must only be called on a created part.
 *
 * @param workingSets the working set to be selected
 */
public void setSelectedWorkingSets(IWorkingSet[] workingSets) {
    Assert.isNotNull(workingSets);
    setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
    fWorkingSets = null;
    Set<IWorkingSet> existingWorkingSets = new HashSet<>(workingSets.length);
    for (IWorkingSet workingSet2 : workingSets) {
        String name = workingSet2.getName();
        IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
        if (workingSet != null)
            existingWorkingSets.add(workingSet);
    }
    if (!existingWorkingSets.isEmpty())
        fWorkingSets = existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
    saveState();
    if (fWorkingSetText != null)
        fWorkingSetText.setText(toString(fWorkingSets));
}
Also used : IWorkingSet(org.eclipse.ui.IWorkingSet) HashSet(java.util.HashSet)

Example 30 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project eclipse.platform.text by eclipse.

the class ScopePart method toString.

public static String toString(IWorkingSet[] workingSets) {
    // $NON-NLS-1$
    String result = "";
    if (workingSets != null && workingSets.length > 0) {
        Arrays.sort(workingSets, new WorkingSetComparator());
        boolean firstFound = false;
        for (IWorkingSet workingSet : workingSets) {
            String workingSetName = workingSet.getLabel();
            if (firstFound)
                result = Messages.format(SearchMessages.ScopePart_workingSetConcatenation, new String[] { result, workingSetName });
            else {
                result = workingSetName;
                firstFound = true;
            }
        }
    }
    return result;
}
Also used : IWorkingSet(org.eclipse.ui.IWorkingSet)

Aggregations

IWorkingSet (org.eclipse.ui.IWorkingSet)54 IWorkingSetManager (org.eclipse.ui.IWorkingSetManager)17 IAdaptable (org.eclipse.core.runtime.IAdaptable)15 IResource (org.eclipse.core.resources.IResource)10 IProject (org.eclipse.core.resources.IProject)9 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)8 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 IWorkingSetSelectionDialog (org.eclipse.ui.dialogs.IWorkingSetSelectionDialog)5 List (java.util.List)4 CoreException (org.eclipse.core.runtime.CoreException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 ISelection (org.eclipse.jface.viewers.ISelection)3 IWorkbench (org.eclipse.ui.IWorkbench)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Set (java.util.Set)2 IProjectDescription (org.eclipse.core.resources.IProjectDescription)2