use of org.eclipse.ui.IWorkingSet in project eclipse.platform.text by eclipse.
the class ScopePart method saveState.
/**
* Saves the last recently used working sets,
* if any.
*/
private void saveState() {
if (fWorkingSets != null && fWorkingSets.length > 0) {
String[] existingWorkingSetNames = new String[fWorkingSets.length];
for (int i = 0; i < fWorkingSets.length; i++) {
IWorkingSet curr = fWorkingSets[i];
// use empty name for aggregateWS
// $NON-NLS-1$
existingWorkingSetNames[i] = curr.isAggregateWorkingSet() ? "" : curr.getName();
}
fSettingsStore.put(STORE_LRU_WORKING_SET_NAMES, existingWorkingSetNames);
}
}
use of org.eclipse.ui.IWorkingSet in project eclipse.platform.text by eclipse.
the class ScopePart method selectedResourcesFromContainer.
public static List<IResource> selectedResourcesFromContainer(ISearchPageContainer container) {
if (container == null)
return Collections.emptyList();
ISelection selection = container.getSelection();
List<IResource> resources = new ArrayList<>();
if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
if (container.getActiveEditorInput() != null) {
resources.add(container.getActiveEditorInput().getAdapter(IFile.class));
}
return resources;
}
Iterator<?> iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
Object curr = iter.next();
if (curr instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) curr;
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
continue;
}
IAdaptable[] elements = workingSet.getElements();
for (IAdaptable element : elements) {
IResource resource = element.getAdapter(IResource.class);
if (resource != null && resource.isAccessible()) {
resources.add(resource);
}
}
} else if (curr instanceof LineElement) {
IResource resource = ((LineElement) curr).getParent();
if (resource != null && resource.isAccessible())
resources.add(resource);
} else if (curr instanceof IAdaptable) {
IResource resource = ((IAdaptable) curr).getAdapter(IResource.class);
if (resource != null && resource.isAccessible()) {
resources.add(resource);
}
}
}
return resources;
}
use of org.eclipse.ui.IWorkingSet in project linuxtools by eclipse.
the class RPMNewProject method createProject.
protected void createProject(IProgressMonitor monitor) throws CoreException {
RPMProjectCreator rpmProjectCreator = new RPMProjectCreator(namePage.getSelectedLayout());
IProject project = rpmProjectCreator.create(namePage.getProjectName(), namePage.getLocationPath(), monitor);
// Add new project to working sets, if requested
IWorkingSet[] workingSets = namePage.getWorkingSets();
if (workingSets.length > 0) {
PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(project, workingSets);
}
}
use of org.eclipse.ui.IWorkingSet in project erlide_eclipse by erlang.
the class FilteredModulesSelectionDialog method fillViewMenu.
@Override
protected void fillViewMenu(final IMenuManager menuManager) {
super.fillViewMenu(menuManager);
workingSetFilterActionGroup = new WorkingSetFilterActionGroup(getShell(), new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
final String property = event.getProperty();
if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
IWorkingSet workingSet = (IWorkingSet) event.getNewValue();
if (workingSet != null && !(workingSet.isAggregateWorkingSet() && workingSet.isEmpty())) {
workingSetFilter.setWorkingSet(workingSet);
setSubtitle(workingSet.getLabel());
} else {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
final IWorkbenchPage page = window.getActivePage();
workingSet = page.getAggregateWorkingSet();
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
workingSet = null;
}
}
workingSetFilter.setWorkingSet(workingSet);
setSubtitle(null);
}
scheduleRefresh();
}
}
});
menuManager.add(new Separator());
workingSetFilterActionGroup.fillContextMenu(menuManager);
}
use of org.eclipse.ui.IWorkingSet in project erlide_eclipse by erlang.
the class SearchUtil method workingSetLabels.
private static String workingSetLabels(final IWorkingSet[] workingSets, final String s, final String surround) {
final StringBuilder sb = new StringBuilder(s);
int i = 0;
for (final IWorkingSet ws : workingSets) {
sb.append(surround).append(ws.getLabel()).append(surround).append(", ");
i++;
if (i == 2) {
break;
}
}
if (workingSets.length > 2) {
return sb.append("... ").toString();
}
return sb.substring(0, sb.length() - 2);
}
Aggregations