Академический Документы
Профессиональный Документы
Культура Документы
About Me
Eclipse Committer
e4
Platform UI
EMF
Eclipse 4
Application
Platform
EAP-Tooling
e4
XWT
EAP
EAP-Tooling
Eclipse Project
XWT
Platform-UI
EAP
JDT
EAP-Tooling
PDE
Eclipse Project
XWT
Platform-UI 3.x
EAP
Platform-UI 4.x
EAP-Tooling
JDT
PDE
Eclipse Project
Platform-UI 3.x
XWT
EAP
Platform-UI 4.x
EAP-Tooling
JDT
PDE
Eclipse Project
Platform-UI 3.x
XWT
EAP
Platform-UI 4.x
EAP-Tooling
JDT
Eclipse Project
Platform-UI 3.x
XWT
EAP
Platform-UI 4.x
EAP-Tooling
JDT
PDE
Eclipse 4.1 SDK
Eclipse Project
XWT
JDT
EAP
PDE
EAP-Tooling
Eclipse Project
XWT
JDT
PDE
EAP-Tooling
Eclipse Project
XWT
JDT
PDE
EAP-Tooling
file:/C:/e4_workshop/software/2.7/
file:/C:/e4_workshop/software/e4-R-0.11-201106201631/
Application.java
Various *Advisor.java
Windows
Menus / Toolbars
None UI structures
Addons
BindingContexts
Commands + Handlers
EMF
Storage-Format (xmi)
XML
Select Finish
javax.inject.Inject;
org.eclipse.e4.ui.di.Focus;
org.eclipse.swt.SWT;
org.eclipse.swt.layout.FillLayout;
org.eclipse.swt.widgets.Composite;
org.eclipse.swt.widgets.Label;
App
Core-Business-Logic
EAP - SWT
Framework
Services
DI-Container
Workbench Model
Eclipse 4 Application Platform
OSGi (Equinox)
JRE
EMF
Understanding DI
Advantages
Easier to test
Understanding DI
Advantages (continued)
Disadvantages
Harder to debug
Understanding DI
public class IconViewPart extends ViewPart {
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
this.viewer = new GalleryTreeViewer(parent, SWT.MULTI | SWT.V_SCROLL);
this.workspace = ResourcesPlugin.getWorkspace();
this.workspace.addResourceChangeListener(resourceListener);
this.selectionListener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
setFolder(selection);
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
public void dispose() {
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(selectionListener);
this.workspace.removeResourceChangeListener(resourceListener);
super.dispose();
}
public void setFocus() {
viewer.getControl().setFocus();
}
}
Donnerstag, 07. Juli 2011
Understanding DI
public class IconViewPart extends ViewPart {
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
this.viewer = new GalleryTreeViewer(parent, SWT.MULTI | SWT.V_SCROLL);
this.workspace = ResourcesPlugin.getWorkspace();
this.workspace.addResourceChangeListener(resourceListener);
this.selectionListener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
setFolder(selection);
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
public void dispose() {
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(selectionListener);
this.workspace.removeResourceChangeListener(resourceListener);
super.dispose();
}
public void setFocus() {
viewer.getControl().setFocus();
}
}
Donnerstag, 07. Juli 2011
Understanding DI
DI - Standards
Eclipse Extensions
org.eclipse.e4.core.di: @Optional
Understanding DI
public class MyAppInstance {
// Field injection
@Inject
private IGreetingService service;
// Constructor injection
@Inject
public MyAppInstance(IGreetingService service) {
}
// PostConstruct Method injection
@PostConstruct
public void init(IGreetingService service) {
}
// Method injection
@Inject
public void setService(IGreetingService service) {
}
}
Donnerstag, 07. Juli 2011
Understanding DI
Constructor Injection
Field Injection
Method Injection
@PostConstruct
@PreDestroy
Understanding DI
IEclipseContext
IEclipseContext#set/get
Understanding DI - an example
DI Example Application
Annotation Bundles
javax.inject
Annotation Bundles
javax.annotation
@PreDestroy: Called the before the context that created the object
gets disposed
Annotation Bundles
org.eclipse.e4.core.di
Annotation Bundles
org.eclipse.e4.core.di.extensions
Annotation Bundles
org.eclipse.e4.ui.di
Registered through DS
property:
name: service.context.key
Custom DI-Annotations
Registered via DS
service: org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier
property:
name: dependency.injection.annotation