Java Code Examples for org.eclipse.search.ui.text.FileTextSearchScope#newSearchScope()

The following examples show how to use org.eclipse.search.ui.text.FileTextSearchScope#newSearchScope() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModulaSearchPage.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public FileTextSearchScope createTextSearchScope() {
    // Setup search scope
    switch (container.getSelectedScope()) {
        case ISearchPageContainer.WORKSPACE_SCOPE:
            return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
        case ISearchPageContainer.SELECTION_SCOPE:
            return getSelectedResourcesScope();
        case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
            return getEnclosingProjectScope();
        case ISearchPageContainer.WORKING_SET_SCOPE:
            IWorkingSet[] workingSets= container.getSelectedWorkingSets();
            return FileTextSearchScope.newSearchScope(workingSets, new String[]{"*"}, false); //$NON-NLS-1$
        default:
            // unknown scope
            return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
    }
}
 
Example 2
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
public FileTextSearchScope createTextSearchScope() {
  // Setup search scope
  switch (getContainer().getSelectedScope()) {
    case ISearchPageContainer.WORKSPACE_SCOPE:
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
    case ISearchPageContainer.SELECTION_SCOPE:
      return getSelectedResourcesScope();
    case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
      return getEnclosingProjectScope();
    case ISearchPageContainer.WORKING_SET_SCOPE:
      IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
      return FileTextSearchScope.newSearchScope(workingSets, getExtensions(), false);
    default:
      // unknown scope
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
  }
}
 
Example 3
Source File: SearchWholeWordInProjectAction.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public FileTextSearchScope getScope() {
	IFile activeIFile = WorkbenchUtils.getActiveFile();
	if (activeIFile != null) {
		return FileTextSearchScope.newSearchScope(
				new IResource[] { activeIFile.getProject() },
				new String[] { "*.*" }, false); //$NON-NLS-1$
	}
	else{
		return FileTextSearchScope.newWorkspaceScope(new String[]{"*.*"}, false); //$NON-NLS-1$
	}
}
 
Example 4
Source File: ModulaSearchPage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private FileTextSearchScope getEnclosingProjectScope() {
    String[] enclosingProjectName= container.getSelectedProjectNames();
    if (enclosingProjectName == null) {
        return FileTextSearchScope.newWorkspaceScope(new String[]{"*"}, false); //$NON-NLS-1$
    }

    IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
    IResource[] res= new IResource[enclosingProjectName.length];
    for (int i= 0; i < res.length; i++) {
        res[i]= root.getProject(enclosingProjectName[i]);
    }

    return FileTextSearchScope.newSearchScope(res, new String[]{"*"}, false); //$NON-NLS-1$
}
 
Example 5
Source File: OccurHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	// TODO Auto-generated method stub
	IResource file = getCurrentResource(editor);
	if (file != null) {
		return FileTextSearchScope.newSearchScope(new IResource[]{file}, new String[]{((IFile)file).getName()}, false);
	} else {
		return super.getInputObject(editor);
	}
}
 
Example 6
Source File: TagsProjectHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set up project search scope
 * 
 * @see com.mulgasoft.emacsplus.commands.TagsSearchHandler#getInputObject(org.eclipse.ui.texteditor.ITextEditor)
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	IProject project= getCurrentProject(editor);
	if (project != null) {
		return FileTextSearchScope.newSearchScope(new IProject[] { project }, new String[0], false);			
	} else {
		return super.getInputObject(editor);
	}
}
 
Example 7
Source File: TagsSetHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set up working set scope, if present, else workspace
 * 
 * @see com.mulgasoft.emacsplus.commands.TagsSearchHandler#getInputObject(org.eclipse.ui.texteditor.ITextEditor)
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	IWorkingSet set = (wset != null ? wset : getWorkingSet(editor));
	if (set != null) {
		return FileTextSearchScope.newSearchScope(new IWorkingSet[] { set }, new String[0], false);			
	} else {
		return super.getInputObject(editor);
	}
}
 
Example 8
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private FileTextSearchScope getEnclosingProjectScope() {
  String[] enclosingProjectName = getContainer().getSelectedProjectNames();
  if (enclosingProjectName == null) {
    return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
  }

  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  IResource[] res = new IResource[enclosingProjectName.length];
  for (int i = 0; i < res.length; i++) {
    res[i] = root.getProject(enclosingProjectName[i]);
  }

  return FileTextSearchScope.newSearchScope(res, getExtensions(), false);
}