Search in sources :

Example 1 with IWorkingSet

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

the class WorkingSetsContentProvider method inputChanged.

public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    if (newInput instanceof IWorkingSet) {
        IWorkingSet rootSet = (IWorkingSet) newInput;
        helper = new WorkingSetHelper(rootSet);
    }
}
Also used : IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 2 with IWorkingSet

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

the class ProjectExplorer method getFrameToolTipText.

/**
	 * Returns the tool tip text for the given element.
	 * 
	 * @param element
	 *            the element
	 * @return the tooltip
	 * @noreference
	 */
public String getFrameToolTipText(Object element) {
    String result;
    if (!(element instanceof IResource)) {
        if (element instanceof IAggregateWorkingSet) {
            result = WorkbenchNavigatorMessages.resources_ProjectExplorerPart_workingSetModel;
        } else if (element instanceof IWorkingSet) {
            result = ((IWorkingSet) element).getLabel();
        } else {
            result = super.getFrameToolTipText(element);
        }
    } else {
        IPath path = ((IResource) element).getFullPath();
        if (path.isRoot()) {
            result = WorkbenchNavigatorMessages.resources_ProjectExplorerPart_workspace;
        } else {
            result = path.makeRelative().toString();
        }
    }
    if (rootMode == PROJECTS) {
        if (workingSetLabel == null)
            return result;
        if (result.length() == 0)
            return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip, new String[] { workingSetLabel });
        return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip2, new String[] { result, workingSetLabel });
    }
    // be null.
    if (element != null && !(element instanceof IWorkingSet) && getCommonViewer() != null) {
        FrameList frameList = getCommonViewer().getFrameList();
        // Happens during initialization
        if (frameList == null)
            return result;
        int index = frameList.getCurrentIndex();
        IWorkingSet ws = null;
        while (index >= 0) {
            Frame frame = frameList.getFrame(index);
            if (frame instanceof TreeFrame) {
                Object input = ((TreeFrame) frame).getInput();
                if (input instanceof IWorkingSet && !(input instanceof IAggregateWorkingSet)) {
                    ws = (IWorkingSet) input;
                    break;
                }
            }
            index--;
        }
        if (ws != null) {
            return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip3, new String[] { ws.getLabel(), result });
        }
        return result;
    }
    return result;
}
Also used : TreeFrame(org.eclipse.ui.internal.navigator.framelist.TreeFrame) Frame(org.eclipse.ui.internal.navigator.framelist.Frame) IPath(org.eclipse.core.runtime.IPath) IAggregateWorkingSet(org.eclipse.ui.IAggregateWorkingSet) FrameList(org.eclipse.ui.internal.navigator.framelist.FrameList) TreeFrame(org.eclipse.ui.internal.navigator.framelist.TreeFrame) IResource(org.eclipse.core.resources.IResource) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 3 with IWorkingSet

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

the class WorkingSetActionProvider method initWorkingSetFilter.

/**
	 * Restores the working set filter from the persistence store.
	 */
protected void initWorkingSetFilter(String workingSetName) {
    IWorkingSet workingSet = null;
    if (workingSetName != null && workingSetName.length() > 0) {
        IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
        workingSet = workingSetManager.getWorkingSet(workingSetName);
    } else if (PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) {
        // use the window set by default if the global preference is set
        workingSet = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getAggregateWorkingSet();
    }
    if (workingSet != null) {
        setWorkingSet(workingSet);
    }
}
Also used : IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 4 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project xtext-eclipse by eclipse.

the class MultiOrganizeImportsHandler method collectRelevantFiles.

private void collectRelevantFiles(Object element, Multimap<IProject, IFile> result) {
    try {
        if (element instanceof IJavaElement) {
            IJavaElement elem = (IJavaElement) element;
            if (elem.exists()) {
                switch(elem.getElementType()) {
                    case IJavaElement.PACKAGE_FRAGMENT:
                        collectRelevantFiles((IPackageFragment) elem, result);
                        break;
                    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                        collectRelevantFiles((IPackageFragmentRoot) elem, result);
                        break;
                    case IJavaElement.JAVA_PROJECT:
                        IPackageFragmentRoot[] roots;
                        roots = ((IJavaProject) elem).getPackageFragmentRoots();
                        for (int k = 0; k < roots.length; k++) {
                            collectRelevantFiles(roots[k], result);
                        }
                        break;
                }
            }
        } else if (element instanceof LogicalPackage) {
            IPackageFragment[] packageFragments = ((LogicalPackage) element).getFragments();
            for (int k = 0; k < packageFragments.length; k++) {
                IPackageFragment pack = packageFragments[k];
                if (pack.exists()) {
                    collectRelevantFiles(pack, result);
                }
            }
        } else if (element instanceof IWorkingSet) {
            IWorkingSet workingSet = (IWorkingSet) element;
            IAdaptable[] elements = workingSet.getElements();
            for (int j = 0; j < elements.length; j++) {
                collectRelevantFiles(elements[j], result);
            }
        } else if (element instanceof IFile) {
            collectIFiles(result, new Object[] { element });
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IAdaptable(org.eclipse.core.runtime.IAdaptable) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) JavaModelException(org.eclipse.jdt.core.JavaModelException) IFile(org.eclipse.core.resources.IFile) LogicalPackage(org.eclipse.jdt.internal.ui.browsing.LogicalPackage) IWorkingSet(org.eclipse.ui.IWorkingSet) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 5 with IWorkingSet

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

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