Java Code Examples for org.eclipse.ui.IWorkingSetManager#getWorkingSet()

The following examples show how to use org.eclipse.ui.IWorkingSetManager#getWorkingSet() . 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: BugContentProvider.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void initWorkingSet(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) {
        setCurrentWorkingSet(workingSet);
    }
}
 
Example 2
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 3
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 4
Source File: GlobalRefreshResourceSelectionPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void initializeScopingHint() {
	String working_sets = settings.get(STORE_WORKING_SETS);
	if (working_sets == null) {
		participantScope.setSelection(true);
		updateParticipantScope();
	} else {
		StringTokenizer st = new StringTokenizer(working_sets, " ,"); //$NON-NLS-1$
		ArrayList ws = new ArrayList();
		while (st.hasMoreTokens()) {
			String workingSetName = st.nextToken();
			if (workingSetName != null && workingSetName.equals("") == false) { //$NON-NLS-1$
				IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
				IWorkingSet workingSet = workingSetManager.getWorkingSet(workingSetName);
				if (workingSet != null) {
					ws.add(workingSet);
				}
			}
		}
		if(! ws.isEmpty()) {
			this.workingSets = (IWorkingSet[]) ws.toArray(new IWorkingSet[ws.size()]);
			updateWorkingSetScope();
			updateWorkingSetLabel();			
			participantScope.setSelection(false);
			selectedResourcesScope.setSelection(false);
			workingSetScope.setSelection(true);
		}
	}
}
 
Example 5
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static SearchPatternData create(IDialogSettings settings) {
  String textPattern = settings.get("textPattern"); //$NON-NLS-1$
  String[] wsIds = settings.getArray("workingSets"); //$NON-NLS-1$
  IWorkingSet[] workingSets = null;
  if (wsIds != null && wsIds.length > 0) {
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    workingSets = new IWorkingSet[wsIds.length];
    for (int i = 0; workingSets != null && i < wsIds.length; i++) {
      workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]);
      if (workingSets[i] == null) {
        workingSets = null;
      }
    }
  }
  String[] fileNamePatterns = settings.getArray("fileNamePatterns"); //$NON-NLS-1$
  if (fileNamePatterns == null) {
    fileNamePatterns = new String[0];
  }
  try {
    int scope = settings.getInt("scope"); //$NON-NLS-1$
    boolean isRegExSearch = settings.getBoolean("isRegExSearch"); //$NON-NLS-1$
    boolean ignoreCase = settings.getBoolean("ignoreCase"); //$NON-NLS-1$

    return new SearchPatternData(textPattern, !ignoreCase, isRegExSearch, fileNamePatterns,
        scope, workingSets);
  } catch (NumberFormatException e) {
    return null;
  }
}
 
Example 6
Source File: WorkingSetsUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 4 votes vote down vote up
public static void organizeWorkingSetsFromExtensionDirectories(IProgressMonitor monitor) {

		IWorkbench workbench = PlatformUI.getWorkbench();
		IWorkingSetManager manager = workbench.getWorkingSetManager();

		Map<String, Set<IProject>> extToProjectMap = new HashMap<String, Set<IProject>>();

		IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
		monitor.beginTask("Creating Working Sets", allProjects.length);
		int projectsProcessed = 0;
		for (IProject project : allProjects) {
			// projects to ignore
			if (project.getName().equals("RemoteSystemsTempFiles") || project.getName().equals("platform") || project.getName().equals("config"))
			{ 
				continue;
			}
			File directory = project.getLocation().toFile().getParentFile();
			String directoryName = directory.getName();
			if (!extToProjectMap.containsKey(directoryName)) {
				extToProjectMap.put(directoryName, new HashSet<IProject>());
				extToProjectMap.get(directoryName).add(ResourcesPlugin.getWorkspace().getRoot().getProject("platform"));
				extToProjectMap.get(directoryName).add(ResourcesPlugin.getWorkspace().getRoot().getProject("config"));
			}
			extToProjectMap.get(directoryName).add(project);
			projectsProcessed++;
			monitor.worked(projectsProcessed);
		}
		monitor.done();

		// now create the working sets
		for (Entry<String, Set<IProject>> entry : extToProjectMap.entrySet()) {
			IWorkingSet existingWorkingSet = manager.getWorkingSet(entry.getKey());
			IProject[] projectsArray = entry.getValue().toArray(new IProject[entry.getValue().size()]);
			if (existingWorkingSet == null) {
				IWorkingSet workingSet = manager.createWorkingSet(entry.getKey(), projectsArray);
				manager.addWorkingSet(workingSet);
			} else {
				// Already got a Working Set with this name
				existingWorkingSet.setElements(projectsArray);
			}
		}
	}
 
Example 7
Source File: JavaSearchPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static SearchPatternData create(IDialogSettings settings) {
	String pattern= settings.get("pattern"); //$NON-NLS-1$
	if (pattern.length() == 0) {
		return null;
	}
	IJavaElement elem= null;
	String handleId= settings.get("javaElement"); //$NON-NLS-1$
	if (handleId != null && handleId.length() > 0) {
		IJavaElement restored= JavaCore.create(handleId);
		if (restored != null && isSearchableType(restored) && restored.exists()) {
			elem= restored;
		}
	}
	String[] wsIds= settings.getArray("workingSets"); //$NON-NLS-1$
	IWorkingSet[] workingSets= null;
	if (wsIds != null && wsIds.length > 0) {
		IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
		workingSets= new IWorkingSet[wsIds.length];
		for (int i= 0; workingSets != null && i < wsIds.length; i++) {
			workingSets[i]= workingSetManager.getWorkingSet(wsIds[i]);
			if (workingSets[i] == null) {
				workingSets= null;
			}
		}
	}

	try {
		int searchFor= settings.getInt("searchFor"); //$NON-NLS-1$
		int scope= settings.getInt("scope"); //$NON-NLS-1$
		int limitTo= settings.getInt("limitTo"); //$NON-NLS-1$

		int matchLocations= 0;
		if (settings.get("matchLocations") != null) { //$NON-NLS-1$
			matchLocations= settings.getInt("matchLocations"); //$NON-NLS-1$
		}

		boolean isCaseSensitive= settings.getBoolean("isCaseSensitive"); //$NON-NLS-1$

		int includeMask;
		if (settings.get("includeMask") != null) { //$NON-NLS-1$
			includeMask= settings.getInt("includeMask"); //$NON-NLS-1$
		} else {
			includeMask= JavaSearchScopeFactory.NO_JRE;
			if (settings.get("includeJRE") == null ? forceIncludeAll(limitTo, elem) : settings.getBoolean("includeJRE")) {  //$NON-NLS-1$ //$NON-NLS-2$
				includeMask= JavaSearchScopeFactory.ALL;
			}
		}
		return new SearchPatternData(searchFor, limitTo, matchLocations, pattern, isCaseSensitive, elem, scope, workingSets, includeMask);
	} catch (NumberFormatException e) {
		return null;
	}
}