Search in sources :

Example 11 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project erlide_eclipse by erlang.

the class ImplementorsSearchGroup method fillContextMenu.

@Override
public void fillContextMenu(final IMenuManager manager) {
    final MenuManager erlangSearchMM = new MenuManager(getName(), IContextMenuConstants.GROUP_SEARCH);
    addAction(fFindImplementorsAction, erlangSearchMM);
    addAction(fFindImplementorsInProjectAction, erlangSearchMM);
    erlangSearchMM.add(new Separator());
    for (final IWorkingSet[] i : SearchUtil.getLRUWorkingSets().getSorted()) {
        addWorkingSetAction(i, erlangSearchMM);
    }
    addAction(fFindImplementorsInWorkingSetAction, erlangSearchMM);
    if (!erlangSearchMM.isEmpty()) {
        manager.appendToGroup(fGroupId, erlangSearchMM);
    }
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 12 with IWorkingSet

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

the class WorkingSets method getAssignedWorkingSets.

/**
 * Returns all working sets the element directly belongs to. Returns empty
 * collection if the element does not belong to any working set. The order of
 * returned working sets is not specified.
 *
 * @since 1.5
 */
public static List<IWorkingSet> getAssignedWorkingSets(IResource element) {
    List<IWorkingSet> list = new ArrayList<>();
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    for (IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
        for (IAdaptable adaptable : workingSet.getElements()) {
            if (adaptable.getAdapter(IResource.class) == element) {
                list.add(workingSet);
            }
        }
    }
    return list;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ArrayList(java.util.ArrayList) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet) IResource(org.eclipse.core.resources.IResource)

Example 13 with IWorkingSet

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

the class SelectionUtil method getSelectedWorkingSet.

public static IWorkingSet getSelectedWorkingSet(IStructuredSelection selection) {
    Object element = selection == null ? null : selection.getFirstElement();
    if (element == null) {
        return null;
    }
    IWorkingSet workingSet = getType(element, IWorkingSet.class);
    if (workingSet != null) {
        return workingSet;
    }
    IResource resource = getType(element, IResource.class);
    if (resource != null) {
        return WorkingSets.getAssignedWorkingSet(resource.getProject());
    }
    return null;
// IResource resource = getType(element, IResource.class);
// if(resource != null) {
// return getWorkingSet(resource);
// }
// IPackageFragmentRoot fragment = getType(element, IPackageFragmentRoot.class);
// if(fragment != null) {
// IJavaProject javaProject = fragment.getJavaProject();
// if(javaProject != null) {
// IResource resource = getType(javaProject, IResource.class);
// if(resource != null) {
// return getWorkingSet(resource.getProject());
// }
// }
// }
}
Also used : IWorkingSet(org.eclipse.ui.IWorkingSet) IResource(org.eclipse.core.resources.IResource)

Example 14 with IWorkingSet

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

the class WorkingSetCustomPart method init.

@Override
protected void init() {
    super.init();
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ISelectionService service = (ISelectionService) activeWorkbenchWindow.getSelectionService();
    ISelection selection = service.getSelection();
    if (selection instanceof IStructuredSelection) {
        final IWorkingSet workingSet = SelectionUtil.getSelectedWorkingSet((IStructuredSelection) selection);
        if (workingSet != null) {
            _workingSets.add(workingSet);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 15 with IWorkingSet

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

the class WorkingSetGroup method _getWorkingSets.

private Set<IWorkingSet> _getWorkingSets() {
    Set<IWorkingSet> workingSets = new HashSet<>();
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    for (IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
        if (!workingSet.isEmpty()) {
            IAdaptable[] elements = workingSet.getElements();
            IResource resource = (IResource) elements[0].getAdapter(IResource.class);
            if (resource != null) {
                workingSets.add(workingSet);
            }
        } else {
            if (_working_set_ids.contains(workingSet.getId())) {
                workingSets.add(workingSet);
            }
        }
    }
    return workingSets;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

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