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);
}
}
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);
}
}
}
}
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);
}
}
Aggregations