Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369866

Summary: New label for part -> StringIndexOutOfBoundsException in StackRenderer
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Brian de Alwis <bsd>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bsd, Lars.Vogel, pwebster
Version: 4.2   
Target Milestone: 4.2 M6   
Hardware: All   
OS: All   
Whiteboard:

Description Lars Vogel CLA 2012-01-26 16:05:08 EST
If I define a part without label and set it to dirty I get a StringIndexOutOfBoundsException in StackRenderer.

Example:

package com.exmaple.e4.playground3.parts;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.eclipse.e4.ui.di.Persist;
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class MySavePart {

	@Inject
	MDirtyable dirty;

	@PostConstruct
	public void createUi(Composite parent) {
		Button button = new Button(parent, SWT.PUSH);
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				dirty.setDirty(true);
			}
		});
	}

	@Persist
	public void save() {
		System.out.println("Saving data");
		// Save the data
		// ...
		// Now set the dirty flag to false
		dirty.setDirty(false);
	}

}

Stack:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(String.java:694)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.updateTab(StackRenderer.java:343)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$2.handleEvent(StackRenderer.java:305)
Comment 1 Brian de Alwis CLA 2012-01-27 17:14:22 EST
Fixed in master (commit e5edf9f)
Comment 2 Lars Vogel CLA 2012-01-27 17:16:21 EST
Thanks!