Search in sources :

Example 1 with IWorkingSetManager

use of org.eclipse.ui.IWorkingSetManager 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 2 with IWorkingSetManager

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

the class WorkingSetActionProvider method setWorkingSet.

/**
	 * Set current active working set.
	 * 
	 * @param workingSet
	 *            working set to be activated, may be <code>null</code>
	 */
protected void setWorkingSet(IWorkingSet workingSet) {
    this.workingSet = workingSet;
    emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty();
    ignoreFilterChangeEvents = true;
    try {
        workingSetActionGroup.setWorkingSet(workingSet);
    } finally {
        ignoreFilterChangeEvents = false;
    }
    if (viewer != null) {
        setWorkingSetFilter(workingSet);
        if (workingSet == null || emptyWorkingSet || !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS)) {
            if (viewer.getInput() != originalViewerInput) {
                viewer.setInput(originalViewerInput);
            } else {
                viewer.refresh();
            }
        } else {
            if (!workingSet.isAggregateWorkingSet()) {
                IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
                viewer.setInput(workingSetManager.createAggregateWorkingSet("", "", //$NON-NLS-1$ //$NON-NLS-2$
                new IWorkingSet[] { workingSet }));
            } else {
                viewer.setInput(workingSet);
            }
        }
    }
}
Also used : IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSet(org.eclipse.ui.IWorkingSet)

Example 3 with IWorkingSetManager

use of org.eclipse.ui.IWorkingSetManager in project bndtools by bndtools.

the class WorkingSetTracker method doWorkingSets.

static void doWorkingSets(final Project model, final IProject targetProject) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkingSetManager workingSetManager = workbench.getWorkingSetManager();
    String mergeProperties = model.mergeProperties("-workingset");
    if (mergeProperties == null)
        return;
    Parameters memberShips = new Parameters(mergeProperties);
    IWorkingSet[] allWorkingSets = workingSetManager.getAllWorkingSets();
    for (IWorkingSet currentWorkingSet : allWorkingSets) {
        Attrs attrs = memberShips.remove(currentWorkingSet.getName());
        boolean shouldBeMember = attrs != null && Processor.isTrue(attrs.get("member", "true"));
        IAdaptable[] elements = currentWorkingSet.getElements();
        List<IAdaptable> members = new ExtList<>(elements);
        boolean foundProjectInCurrentWorkingSet = false;
        for (Iterator<IAdaptable> it = members.iterator(); it.hasNext(); ) {
            IAdaptable member = it.next();
            if (member.getAdapter(IProject.class) == targetProject) {
                foundProjectInCurrentWorkingSet = true;
                if (!shouldBeMember) {
                    it.remove();
                }
            }
        }
        if (!foundProjectInCurrentWorkingSet && shouldBeMember) {
            members.add(targetProject);
        }
        if (elements.length != members.size()) {
            updateWorkingSet(currentWorkingSet, members);
        }
    }
    for (final Entry<String, Attrs> e : memberShips.entrySet()) {
        String name = e.getKey();
        boolean isMember = Processor.isTrue(e.getValue().get("member", "true"));
        if (!isMember)
            continue;
        if (!JAVAID_P.matcher(name).matches()) {
            SetLocation error = model.warning("Invalid working set name '%s'. Must use pattern of Java identifier", name);
            error.file(model.getPropertiesFile().getAbsolutePath());
            error.header("-workingset");
            continue;
        }
        IAdaptable[] members = new IAdaptable[1];
        members[0] = targetProject;
        IWorkingSet newWorkingSet = workingSetManager.createWorkingSet(name, members);
        newWorkingSet.setId("org.eclipse.jdt.ui.JavaWorkingSetPage");
        newWorkingSet.setLabel(null);
        workingSetManager.addWorkingSet(newWorkingSet);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) Parameters(aQute.bnd.header.Parameters) ExtList(aQute.lib.collections.ExtList) Attrs(aQute.bnd.header.Attrs) IProject(org.eclipse.core.resources.IProject) IWorkbench(org.eclipse.ui.IWorkbench) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) SetLocation(aQute.service.reporter.Reporter.SetLocation) IWorkingSet(org.eclipse.ui.IWorkingSet)

Aggregations

IWorkingSet (org.eclipse.ui.IWorkingSet)3 IWorkingSetManager (org.eclipse.ui.IWorkingSetManager)3 Attrs (aQute.bnd.header.Attrs)1 Parameters (aQute.bnd.header.Parameters)1 ExtList (aQute.lib.collections.ExtList)1 SetLocation (aQute.service.reporter.Reporter.SetLocation)1 IProject (org.eclipse.core.resources.IProject)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IWorkbench (org.eclipse.ui.IWorkbench)1