Bug 337141 Recursive part activation warnings fired from photo demo
!ENTRY org.eclipse.e4.ui.workbench 2 0 2011-02-14 11:37:24.765 !MESSAGE Blocked recursive attempt to activate part !STACK 0 java.lang.IllegalStateException at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:95) at org.eclipse.e4.demo.e4photo.Preview.setFocus(Preview.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:203) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101) at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:77) at org.eclipse.e4.demo.e4photo.Preview.setFocus(Preview.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:203) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:508) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:477) at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:105) at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$3.handleEvent(ContributedPartRenderer.java:210) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
examples/org.eclipse.e4.demo.e4photo/src/org/eclipse/e4/demo/e4photo/Preview.java
public void run() {
						parentSize.setValue(newSize);
					}
				});
			}
		});
	}
	@Inject @Optional
	public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) final IFile input) {
		bgRealm.asyncExec(new Runnable() {
			public void run() {
				inputFile.setValue(input);
			}
		});
	}
	
	@Focus
	void setFocus() {
		parent.setFocus();
	}
	private Point getBestSize(int originalX, int originalY, int maxX, int maxY) {
		double widthRatio = (double) originalX / (double) maxX;
		double heightRatio = (double) originalY / (double) maxY;
		double bestRatio = widthRatio > heightRatio ? widthRatio : heightRatio;
		int newWidth = (int) ((double) originalX / bestRatio) - (frameWidth * 2);
		int newHeight = (int) ((double) originalY / bestRatio)  - (topImageMargin + bottomImageMargin + (frameWidth * 2));
		return new Point(newWidth, newHeight);
	}
}