Search in sources :

Example 16 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project liferay-ide by liferay.

the class WorkingSetGroup method selectWorkingSets.

public boolean selectWorkingSets(List<IWorkingSet> workingSets) {
    Set<IWorkingSet> defaultSets = _getWorkingSets();
    _workingsetComboViewer.setInput(defaultSets);
    if (ListUtil.isNotEmpty(workingSets)) {
        if (workingSets.size() == 1) {
            IWorkingSet workingSet = workingSets.get(0);
            if (defaultSets.contains(workingSet)) {
                _workingsetComboViewer.setSelection(new StructuredSelection(workingSet));
            }
        } else {
            _workingsetComboViewer.add(workingSets);
            _workingsetComboViewer.setSelection(new StructuredSelection((Object) workingSets));
        }
        return true;
    }
    return false;
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 17 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project liferay-ide by liferay.

the class WorkingSetGroup method updateConfiguration.

protected void updateConfiguration() {
    if (addToWorkingSetButton.getSelection()) {
        IStructuredSelection selection = (IStructuredSelection) _workingsetComboViewer.getSelection();
        Object o = selection.getFirstElement();
        if (o != null) {
            _workingSets.clear();
            if (o instanceof IWorkingSet) {
                _workingSets.add((IWorkingSet) o);
            } else if (o instanceof List<?>) {
                @SuppressWarnings("unchecked") List<IWorkingSet> l = (List<IWorkingSet>) o;
                _workingSets.addAll(l);
            }
        }
    }
}
Also used : List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 18 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project eclipse-cs by checkstyle.

the class AbstractStatsView method focusSelectionChanged.

/**
 * Invoked on selection changes within the workspace.
 *
 * @param part
 *          the workbench part the selection occurred
 * @param selection
 *          the selection
 */
private void focusSelectionChanged(IWorkbenchPart part, ISelection selection) {
    List<IResource> resources = new ArrayList<IResource>();
    if (part instanceof IEditorPart) {
        IEditorPart editor = (IEditorPart) part;
        IFile file = getFile(editor.getEditorInput());
        if (file != null) {
            resources.add(file);
        }
    } else {
        if (selection instanceof IStructuredSelection) {
            for (Iterator<?> iterator = ((IStructuredSelection) selection).iterator(); iterator.hasNext(); ) {
                Object object = iterator.next();
                if (object instanceof IWorkingSet) {
                    IWorkingSet workingSet = (IWorkingSet) object;
                    IAdaptable[] elements = workingSet.getElements();
                    for (int i = 0; i < elements.length; i++) {
                        considerAdaptable(elements[i], resources);
                    }
                } else if (object instanceof IAdaptable) {
                    considerAdaptable((IAdaptable) object, resources);
                }
            }
        }
    }
    IResource[] focusedResources = new IResource[resources.size()];
    resources.toArray(focusedResources);
    // check if update necessary -> if so then update
    boolean updateNeeded = updateNeeded(mFocusedResources, focusedResources);
    if (updateNeeded) {
        mFocusedResources = focusedResources;
        getFilter().setFocusResource(focusedResources);
        refresh();
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IResource(org.eclipse.core.resources.IResource) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 19 with IWorkingSet

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

the class GitRepositoriesViewTest method removeWorkingSet.

private void removeWorkingSet(String name) {
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    IWorkingSet workingSet = workingSetManager.getWorkingSet(name);
    if (workingSet != null)
        workingSetManager.removeWorkingSet(workingSet);
}
Also used : IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 20 with IWorkingSet

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

the class GitRepositoriesViewTest method assertProjectInWorkingSet.

private void assertProjectInWorkingSet(String workingSetName, String projectName) {
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    IWorkingSet workingSet = workingSetManager.getWorkingSet(workingSetName);
    IAdaptable[] elements = workingSet.getElements();
    assertEquals("Wrong number of projects in working set", 1, elements.length);
    IProject project = Utils.getAdapter(elements[0], IProject.class);
    assertEquals("Wrong project in working set", projectName, project.getName());
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet) IProject(org.eclipse.core.resources.IProject)

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