org.eclipse.ui.IAggregateWorkingSet Java Examples

The following examples show how to use org.eclipse.ui.IAggregateWorkingSet. 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: ResourceUtils.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * @param wset
 *            non null working set
 * @return non null set with work items, which may be empty
 */
public static Set<WorkItem> getResources(IWorkingSet wset) {
    Set<WorkItem> set = new HashSet<>();
    boolean aggregateWorkingSet = wset.isAggregateWorkingSet();
    // IAggregateWorkingSet was introduced in Eclipse 3.5
    if (aggregateWorkingSet && wset instanceof IAggregateWorkingSet) {
        IAggregateWorkingSet aggr = (IAggregateWorkingSet) wset;
        IWorkingSet[] sets = aggr.getComponents();
        for (IWorkingSet iWorkingSet : sets) {
            set.addAll(getResources(iWorkingSet));
        }
    } else {
        IAdaptable[] elements = wset.getElements();
        for (IAdaptable iAdaptable : elements) {
            WorkItem item = getWorkItem(iAdaptable);
            if (item != null) {
                set.add(item);
            }
        }
    }
    return set;
}
 
Example #2
Source File: ProjectExplorer.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The superclass does not deal with the content description, handle it
 * here.
 * 
 * @noreference
 */
public void updateTitle() {
	super.updateTitle();
	Object input = getCommonViewer().getInput();

	if (input == null || input instanceof IAggregateWorkingSet) {
		setContentDescription(""); //$NON-NLS-1$
		return;
	}

	if (!(input instanceof IResource)) {
		if (input instanceof IAdaptable) {
			IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
					.getAdapter(IWorkbenchAdapter.class);
			if (wbadapter != null) {
				setContentDescription(wbadapter.getLabel(input));
				return;
			}
		}
		setContentDescription(input.toString());
		return;
	}

	IResource res = (IResource) input;
	setContentDescription(res.getName());
}
 
Example #3
Source File: ProjectExplorer.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The superclass does not deal with the content description, handle it
 * here.
 * 
 * @noreference
 */
public void updateTitle() {
	super.updateTitle();
	Object input = getCommonViewer().getInput();

	if (input == null || input instanceof IAggregateWorkingSet) {
		setContentDescription(""); //$NON-NLS-1$
		return;
	}

	if (!(input instanceof IResource)) {
		if (input instanceof IAdaptable) {
			IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
					.getAdapter(IWorkbenchAdapter.class);
			if (wbadapter != null) {
				setContentDescription(wbadapter.getLabel(input));
				return;
			}
		}
		setContentDescription(input.toString());
		return;
	}

	IResource res = (IResource) input;
	setContentDescription(res.getName());
}
 
Example #4
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	
	if (ignoreFilterChangeEvents)
		return;
	
	IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();

	setWorkingSet(newWorkingSet);
	if (newWorkingSet != null) {
		if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
			contentService.getActivationService().activateExtensions(
					new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
			contentService.getActivationService().persistExtensionActivations();
		}
		if (newWorkingSet.isAggregateWorkingSet()) {
			IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
			IWorkingSet[] comps = agWs.getComponents();
			if (comps.length > 1) {
				viewer.getCommonNavigator().setWorkingSetLabel(
						WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
			} else if (comps.length > 0) {
				viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
			} else {
				viewer.getCommonNavigator().setWorkingSetLabel(null);
			}
		} else
			viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
	} else {
		viewer.getCommonNavigator().setWorkingSetLabel(null);
	}

	viewer.getFrameList().reset();
}
 
Example #5
Source File: WorkingSetsContentProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object[] getChildren(Object parentElement) {
	if (parentElement instanceof IWorkingSet) {
		IWorkingSet workingSet = (IWorkingSet) parentElement;
		if (workingSet.isAggregateWorkingSet() && projectExplorer != null) {
			switch (projectExplorer.getRootMode()) {
				case ProjectExplorer.WORKING_SETS :
					return ((IAggregateWorkingSet) workingSet).getComponents();
				case ProjectExplorer.PROJECTS :
					return getWorkingSetElements(workingSet);
			}
		}
		return getWorkingSetElements(workingSet);
	}
	return NO_CHILDREN;
}
 
Example #6
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	
	if (ignoreFilterChangeEvents)
		return;
	
	IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();

	setWorkingSet(newWorkingSet);
	if (newWorkingSet != null) {
		if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
			contentService.getActivationService().activateExtensions(
					new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
			contentService.getActivationService().persistExtensionActivations();
		}
		if (newWorkingSet.isAggregateWorkingSet()) {
			IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
			IWorkingSet[] comps = agWs.getComponents();
			if (comps.length > 1) {
				viewer.getCommonNavigator().setWorkingSetLabel(
						WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
			} else if (comps.length > 0) {
				viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
			} else {
				viewer.getCommonNavigator().setWorkingSetLabel(null);
			}
		} else
			viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
	} else {
		viewer.getCommonNavigator().setWorkingSetLabel(null);
	}

	viewer.getFrameList().reset();
}
 
Example #7
Source File: WorkingSetsContentProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object[] getChildren(Object parentElement) {
	if (parentElement instanceof IWorkingSet) {
		IWorkingSet workingSet = (IWorkingSet) parentElement;
		if (workingSet.isAggregateWorkingSet() && projectExplorer != null) {
			switch (projectExplorer.getRootMode()) {
				case ProjectExplorer.WORKING_SETS :
					return ((IAggregateWorkingSet) workingSet).getComponents();
				case ProjectExplorer.PROJECTS :
					return getWorkingSetElements(workingSet);
			}
		}
		return getWorkingSetElements(workingSet);
	}
	return NO_CHILDREN;
}