Search in sources :

Example 36 with IWorkingSet

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

the class ReferencesSearchGroup method fillContextMenu.

@Override
public void fillContextMenu(final IMenuManager manager) {
    final MenuManager erlangSearchMM = new MenuManager(getName(), IContextMenuConstants.GROUP_SEARCH);
    addAction(fFindReferencesAction, erlangSearchMM);
    addAction(fFindReferencesInProjectAction, erlangSearchMM);
    erlangSearchMM.add(new Separator());
    for (final IWorkingSet[] i : SearchUtil.getLRUWorkingSets().getSorted()) {
        addWorkingSetAction(i, erlangSearchMM);
    }
    addAction(fFindReferencesInWorkingSetAction, 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 37 with IWorkingSet

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

the class AdvancedFixCopyrightAction method addResource.

private void addResource(Object element, ArrayList<IResource> resources) {
    if (element instanceof IResource) {
        resources.add((IResource) element);
    } else if (element instanceof IWorkingSet) {
        IWorkingSet ws = (IWorkingSet) element;
        IAdaptable[] elements = ws.getElements();
        for (int i = 0; i < elements.length; i++) addResource(elements[i], resources);
    } else if (element instanceof IAdaptable) {
        IAdaptable a = (IAdaptable) element;
        addResource(a.getAdapter(IResource.class), resources);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IResource(org.eclipse.core.resources.IResource) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 38 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project webtools.sourceediting by eclipse.

the class NewProjectDataModelFacetWizard method postPerformFinish.

/**
 * <p>
 * Invoked after the user has clicked the "Finish" button of the wizard. The default
 * implementation will attempt to update the final perspective to the value specified by
 * { @link #getFinalPerspectiveID() }
 * </p>
 *
 * @throws InvocationTargetException
 *
 * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizard#postPerformFinish()
 */
protected void postPerformFinish() throws InvocationTargetException {
    String projName = getProjectName();
    IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
    IWorkbench workbench = WSTWebUIPlugin.getDefault().getWorkbench();
    // add to the selected working sets
    if (newProject != null && beginingPages != null && beginingPages.length > 0 && beginingPages[0] instanceof DataModelFacetCreationWizardPage) {
        DataModelFacetCreationWizardPage mainPage = (DataModelFacetCreationWizardPage) beginingPages[0];
        IWorkingSet[] workingSets = mainPage.getSelectedWorkingSets();
        workbench.getWorkingSetManager().addToWorkingSets(newProject, workingSets);
    }
    // open the "final" perspective
    if (getFinalPerspectiveID() != null && getFinalPerspectiveID().length() > 0) {
        final IConfigurationElement element = new DelegateConfigurationElement(configurationElement) {

            @Override
            public String getAttribute(String aName) {
                if (aName.equals("finalPerspective")) {
                    // $NON-NLS-1$
                    return getFinalPerspectiveID();
                }
                return super.getAttribute(aName);
            }
        };
        BasicNewProjectResourceWizard.updatePerspective(element);
    } else
        BasicNewProjectResourceWizard.updatePerspective(configurationElement);
    // select and reveal
    BasicNewResourceWizard.selectAndReveal(newProject, workbench.getActiveWorkbenchWindow());
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) DelegateConfigurationElement(org.eclipse.wst.web.internal.DelegateConfigurationElement) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IProject(org.eclipse.core.resources.IProject) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 39 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project webtools.sourceediting by eclipse.

the class FindReferencesInWorkingSetAction method run.

public void run() {
    IWorkingSet[] workingSets = queryWorkingSets();
    if (workingSets == null || workingSets.length == 0)
        // The user chooses nothing, no point to continue.
        return;
    String pattern = "";
    XSDNamedComponent component = getXSDNamedComponent();
    IFile file = getCurrentFile();
    if (file != null && component != null) {
        QualifiedName metaName = determineMetaName(component);
        QualifiedName elementQName = new QualifiedName(component.getTargetNamespace(), component.getName());
        // Create a scope from the selected working sets
        WorkingSetSearchScope scope = new WorkingSetSearchScope();
        for (int i = 0; i < workingSets.length; i++) {
            IAdaptable[] elements = workingSets[i].getElements();
            scope.addAWorkingSetToScope(elements);
        }
        String scopeDescription = "Working Set";
        XSDSearchQuery searchQuery = new XSDSearchQuery(pattern, file, elementQName, metaName, XSDSearchQuery.LIMIT_TO_REFERENCES, scope, scopeDescription);
        NewSearchUI.activateSearchResultView();
        NewSearchUI.runQueryInBackground(searchQuery);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) IFile(org.eclipse.core.resources.IFile) WorkingSetSearchScope(org.eclipse.wst.common.core.search.scope.WorkingSetSearchScope) QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) IWorkingSet(org.eclipse.ui.IWorkingSet) XSDSearchQuery(org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)

Example 40 with IWorkingSet

use of org.eclipse.ui.IWorkingSet in project webtools.sourceediting by eclipse.

the class FindReferencesInWorkingSetAction method queryWorkingSets.

/**
 * Calls a dialog asking the user to choose the working Sets he wants
 * to do the search on
 * @return
 */
public static IWorkingSet[] queryWorkingSets() {
    Shell shell = XSDEditorPlugin.getShell();
    if (shell == null)
        return null;
    IWorkingSetSelectionDialog dialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, true);
    if (dialog.open() == Window.OK) {
        IWorkingSet[] workingSets = dialog.getSelection();
        if (workingSets.length > 0)
            return workingSets;
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IWorkingSetSelectionDialog(org.eclipse.ui.dialogs.IWorkingSetSelectionDialog) 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