use of org.eclipse.ui.IWorkingSet in project n4js by eclipse.
the class ManualAssociationAwareWorkingSetManager method deleteEclipseResourcesWorkingSets.
/**
* Deletes all Eclipse based working sets that belong to the 'Resources' working set type.
*/
private void deleteEclipseResourcesWorkingSets() {
// Discard the Eclipse based working set manager state by deleting all 'Resources' working sets.
final Iterator<IWorkingSet> itr = getAllEclipseResourceWorkingSetsIterator();
final IWorkingSetManager manager = getWorkbench().getWorkingSetManager();
while (itr.hasNext()) {
final IWorkingSet next = itr.next();
manager.removeWorkingSet(next);
}
}
use of org.eclipse.ui.IWorkingSet in project n4js by eclipse.
the class ManualAssociationAwareWorkingSetManager method getAllEclipseResourceWorkingSetsIterator.
/**
* Returns with an iterator of all existing Eclipse based {@link IWorkingSet working sets} that belong to the
* 'Resources' type. Includes all visible and hidden working sets.
*
* @return an iterator to all Eclipse based working sets form the 'Resources' type.
*/
private Iterator<IWorkingSet> getAllEclipseResourceWorkingSetsIterator() {
final IWorkingSetManager manager = getWorkbench().getWorkingSetManager();
final Iterable<IWorkingSet> allWorkingSets = asList(manager.getAllWorkingSets());
return from(allWorkingSets).filter(RESOURCE_WORKING_SETS).iterator();
}
use of org.eclipse.ui.IWorkingSet in project liferay-ide by liferay.
the class BaseProjectWizard method addToWorkingSets.
protected void addToWorkingSets(IProject newProject) throws Exception {
if (newProject != null) {
List<WizardPagePart> wizardPages = part().getPages();
WizardPagePart wizardPagePart = wizardPages.get(0);
for (final FormComponentPart formPart : wizardPagePart.children().all()) {
if (formPart instanceof WorkingSetCustomPart) {
final WorkingSetCustomPart workingSetPart = (WorkingSetCustomPart) formPart;
final IWorkingSet[] workingSets = workingSetPart.getWorkingSets();
if (ListUtil.isNotEmpty(workingSets)) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
workingSetManager.addToWorkingSets(newProject, workingSets);
}
}
}
}
}
use of org.eclipse.ui.IWorkingSet in project liferay-ide by liferay.
the class WorkingSets method getWorkingSets.
public static String[] getWorkingSets() {
List<String> workingSets = new ArrayList<>();
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
for (IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
if (workingSet.isVisible()) {
workingSets.add(workingSet.getName());
}
}
return workingSets.toArray(new String[workingSets.size()]);
}
use of org.eclipse.ui.IWorkingSet in project liferay-ide by liferay.
the class WorkingSetGroup method _createControl.
private void _createControl(Composite container) {
addToWorkingSetButton = new Button(container, SWT.CHECK);
GridData gd_addToWorkingSetButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
gd_addToWorkingSetButton.verticalIndent = 12;
addToWorkingSetButton.setLayoutData(gd_addToWorkingSetButton);
addToWorkingSetButton.setSelection(true);
addToWorkingSetButton.setData("name", "addToWorkingSetButton");
addToWorkingSetButton.setText("Add project to working set");
addToWorkingSetButton.setSelection(false);
final Label workingsetLabel = new Label(container, SWT.NONE);
GridData gd_workingsetLabel = new GridData();
gd_workingsetLabel.horizontalIndent = 10;
workingsetLabel.setLayoutData(gd_workingsetLabel);
workingsetLabel.setEnabled(false);
workingsetLabel.setData("name", "workingsetLabel");
workingsetLabel.setText("Working set:");
Combo workingsetCombo = new Combo(container, SWT.READ_ONLY);
workingsetCombo.setEnabled(false);
workingsetCombo.setData("name", "workingsetCombo");
workingsetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
_workingsetComboViewer = new ComboViewer(workingsetCombo);
_workingsetComboViewer.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public Object[] getElements(Object input) {
if (input instanceof IWorkingSet[]) {
return (IWorkingSet[]) input;
} else if (input instanceof List<?>) {
return new Object[] { input };
} else if (input instanceof Set<?>) {
return ((Set<?>) input).toArray();
}
return new IWorkingSet[0];
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
_workingsetComboViewer.setLabelProvider(new LabelProvider() {
public void dispose() {
_images.dispose();
super.dispose();
}
@SuppressWarnings("deprecation")
public Image getImage(Object element) {
if (element instanceof IWorkingSet) {
ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImage();
if (imageDescriptor != null) {
try {
return (Image) _images.create(imageDescriptor);
} catch (DeviceResourceException dre) {
return null;
}
}
}
return super.getImage(element);
}
public String getText(Object element) {
if (element instanceof IWorkingSet) {
return ((IWorkingSet) element).getLabel();
} else if (element instanceof List<?>) {
StringBuffer sb = new StringBuffer();
for (Object o : (List<?>) element) {
if (o instanceof IWorkingSet) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(((IWorkingSet) o).getLabel());
}
}
return sb.toString();
}
return super.getText(element);
}
private ResourceManager _images = new LocalResourceManager(JFaceResources.getResources());
});
_workingsetComboViewer.setComparator(new ViewerComparator());
final Button newWorkingSetButton = new Button(container, SWT.NONE);
newWorkingSetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
newWorkingSetButton.setData("name", "configureButton");
newWorkingSetButton.setText("More...");
newWorkingSetButton.setEnabled(false);
newWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(_shell, true, _working_set_ids.toArray(new String[0]));
if (dialog.open() == Window.OK) {
IWorkingSet[] workingSets = dialog.getSelection();
selectWorkingSets(Arrays.asList(workingSets));
}
}
});
if (selectWorkingSets(_workingSets)) {
addToWorkingSetButton.setSelection(true);
workingsetLabel.setEnabled(true);
_workingsetComboViewer.getCombo().setEnabled(true);
newWorkingSetButton.setEnabled(true);
}
addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
workingsetLabel.setEnabled(addToWorkingingSet);
_workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
newWorkingSetButton.setEnabled(addToWorkingingSet);
if (addToWorkingingSet) {
updateConfiguration();
} else {
_workingSets.clear();
}
}
});
_workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateConfiguration();
}
});
}
Aggregations