Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358785 - [WorkingSets] Index out of Bounds exception when setting empty workingsets array in WorkingSetConfigurationBlock
Summary: [WorkingSets] Index out of Bounds exception when setting empty workingsets ar...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-23 18:17 EDT by Kris De Volder CLA
Modified: 2020-01-27 01:43 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kris De Volder CLA 2011-09-23 18:17:04 EDT
Build Identifier: org.eclipse.ui.workbench_3.7.0.I20110519-0100

WorkingSetConfigurationBlock from org.eclipse.ui.dialogs throws following exception when passing a zero-length array to setSelectedWorkingSets.

I suspect the error will only happen if the setSelectedWorkingSets method is called after the combo has been instantiated.

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4263)
	at org.eclipse.swt.SWT.error(SWT.java:4197)
	at org.eclipse.swt.SWT.error(SWT.java:4168)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:466)
	at org.eclipse.swt.widgets.Combo.getItem(Combo.java:868)
	at org.eclipse.ui.dialogs.WorkingSetConfigurationBlock.updateSelectedWorkingSets(WorkingSetConfigurationBlock.java:412)
	at org.eclipse.ui.dialogs.WorkingSetConfigurationBlock.setWorkingSets(WorkingSetConfigurationBlock.java:191)
	at com.springsource.sts.gradle.ui.wizards.WorkingSetGroup.setSelectedWorkingSets(WorkingSetGroup.java:72)
	at com.springsource.sts.gradle.ui.wizards.GradleImportWizardPageOne$DefaultsSetter.restoreDefaults(GradleImportWizardPageOne.java:634)


Reproducible: Always
Comment 1 Rüdiger Herrmann CLA 2015-08-12 09:52:52 EDT
I also run in to this bug and would like to amend that the exception also occurs when passing a non-empty array of working sets to setSelectedWorkingSets().

With this snippet, the bug can be reproduced:

  @Test
  public void testWorkingSetConfigurationBlockBug() {
    String type = "org.eclipse.ui.resourceWorkingSetPage";
    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    IWorkingSet workingSet = workingSetManager.createWorkingSet( "ws", new IAdaptable[ 0 ] );
    workingSet.setId( type );
    workingSetManager.addWorkingSet( workingSet );
    Shell shell = new Shell();

    WorkingSetConfigurationBlock workingSetBlock = new WorkingSetConfigurationBlock( new String[] { type }, new DialogSettings( "settings" ) );
    workingSetBlock.createContent( shell );
    workingSetBlock.setWorkingSets( new IWorkingSet[] { workingSet } );

    assertArrayEquals( new IWorkingSet[] { workingSet }, workingSetBlock.getSelectedWorkingSets() );
  }
Comment 2 Eclipse Genie CLA 2020-01-27 01:43:35 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.