Bug 12596 exception on saving dirty editors
20020328 Log: Tue Apr 02 14:42:49 GMT+02:00 2002 4 org.eclipse.jdt.ui 1 Internal Error java.lang.reflect.InvocationTargetException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.RangeCheck(ArrayList.java(Compiled Code)) at java.util.ArrayList.get(ArrayList.java(Compiled Code)) at org.eclipse.jdt.internal.ui.reorg.ReorgDestinationAction$1.run (ReorgDestinationAction.java:199) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.ui.reorg.ReorgDestinationAction.ensureSaved (ReorgDestinationAction.java:168) at org.eclipse.jdt.internal.ui.reorg.ReorgDestinationAction.run (ReorgDestinationAction.java:80) at org.eclipse.jdt.internal.ui.reorg.JdtCopyAction.run (JdtCopyAction.java:58) at org.eclipse.jdt.internal.ui.reorg.PasteResourcesFromClipboardAction.pasteResourc es(PasteResourcesFromClipboardAction.java:60) at org.eclipse.jdt.internal.ui.reorg.PasteResourcesFromClipboardAction.run (PasteResourcesFromClipboardAction.java:53) at org.eclipse.jdt.internal.ui.reorg.DualReorgAction.run (DualReorgAction.java:49) at org.eclipse.jface.action.Action.runWithEvent(Action.java:590) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:738) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:196) at org.eclipse.core.launcher.Main.run(Main.java:555) at org.eclipse.core.launcher.Main.main(Main.java:396)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/reorg/ReorgDestinationAction.java
};
		ElementTreeSelectionDialog dialog= createDestinationSelectionDialog(JavaPlugin.getActiveWorkbenchShell(), 
																																	 new DestinationRenderer(JavaElementLabelProvider.SHOW_SMALL_ICONS	),
																																	 cp,
																																	 refactoring);
		dialog.setTitle(getActionName());
		dialog.setValidator(new ReorgSelectionValidator(refactoring));
		dialog.addFilter(new ContainerFilter(refactoring));
		dialog.setSorter(new JavaElementSorter());
		dialog.setMessage(getDestinationDialogMessage());
		dialog.setSize(60, 18);
		dialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
		dialog.setInitialSelection(computeCommonParent(refactoring.getElementsToReorg()));
		
		if (dialog.open() != dialog.CANCEL)
			return dialog.getFirstResult();
		return null;
	}
		
	ElementTreeSelectionDialog createDestinationSelectionDialog(Shell parent, ILabelProvider labelProvider, JavaElementContentProvider cp, ReorgRefactoring refactoring){
		return new ElementTreeSelectionDialog(parent, labelProvider, cp);
	}
	
	private static Object computeCommonParent(List elements){
		if (elements.isEmpty())
			return null;
		Object parent= elements.get(0);
		for (Iterator iter= elements.iterator(); iter.hasNext(); ){
			parent= computeCommonParent(parent, iter.next());
		}