introduction to the netbeans platform
TRANSCRIPT
![Page 1: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/1.jpg)
1
Introduction to the NetBeans Platform
Institute for System SoftwareJohannes Kepler University Linz, Austriahttp://ssw.jku.at
Thomas [email protected]
![Page 2: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/2.jpg)
2
NetBeans
● IDE (Java, C/C++, PHP, JavaScript, Groovy, Ruby, ...)
● Rich Client Platform
● Only Java (Swing)
● Supported by Sun Microsystems
Important Concepts:
● Modules
● Filesystem
● Lookup
● Nodes and Actions
![Page 3: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/3.jpg)
3
Sources of Information
● NetBeans source code (http://www.netbeans.org/downloads/zip.html)
● API Javadoc (http://bits.netbeans.org/dev/javadoc/index.html)
● Planet NetBeans (http://planetnetbeans.org/de/index.html)
● Numerous NetBeans bloggers (e.g. http://blogs.sun.com/geertjan/)
![Page 4: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/4.jpg)
4
NetBeansApplication
Architecture (1)
NetBeans Platform
Swing / JDK
Java VM
NetBeans IDE
![Page 5: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/5.jpg)
5
Architecture (2)
Swing / JDK
Java VM
NetBeansApplication
NetBeans Platform
NetBeans IDE
![Page 6: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/6.jpg)
6
Deployment
Swing / JDK
Java VM
NetBeansApplication
NetBeans Platform
NetBeans IDE
● Standalone: Deployment including required platform / IDE modules
● Plugin: Deployment only with user-defined modules
![Page 7: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/7.jpg)
7
Module System
META-INF/manifest.mflayer.xmlMETA-INF/services/**.classBundle.properties
Module A (= JAR File)
...
Module B
Module Suite (= Deployment Unit)
...
Module C
● Well-defined module dependencies
● Lazy loading / Unloading
● layer.xml for declarative registrations (file system)
● Bundle.properties for internationalization
![Page 8: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/8.jpg)
8
Information Hiding
Public API
Module B
Implementation
Module A
Public packages are explicitely defined in manifest.mf (project.xml).
![Page 9: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/9.jpg)
9
Module Dependencies
Module A
Module B
Module C
No circles!
Modules can only use classes of modules they explicitely depend on.
![Page 10: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/10.jpg)
10
Window System
Window Mode
Singleton TopComponent
Global actions
TopComponentwith multiple instances
![Page 11: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/11.jpg)
11
File System (1)
Module A Module B Result
+ =+ ...
X
Y
a b
X
Y
c
Z
d a b
X
Y
c
Z
d
● Declarative specifications of virtual folders and files
● File system is union of file systems of all current modules
![Page 12: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/12.jpg)
12
File System (2)
<filesystem>
<folder name="Actions"> <folder name="Window"> <file name="TestAction.instance"> <attr name="displayName" value="Test"/> </file> </folder> </folder>
<folder name="Menu"> <folder name="Window"> <file name="TestAction.shadow"> <attr name="originalFile" stringvalue="Actions/Window/sample-TestAction.instance"/> </file> </folder> </folder>
<folder name="Windows2"> <folder name="Components"> <file name="TopComponent.settings" url="TopComponentSettings.xml"/> </folder> </folder>
</filesystem>
Reference to Java class
Reference to other file
Reference to physical file
Use .instance_hidden to hide existing entries
![Page 13: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/13.jpg)
13
File System (3)
ROOT
Actions Menu Window2
TestAction.instance
Java ClassTestAction
displayName=“Test“
TestAction.shadow TestTopComponent.settings
FileTopComponentSettings.xml
![Page 14: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/14.jpg)
14
Lookup System
Lookuplookup all instances of X.class
x1, x2
InstanceContent content = new InstanceContent();Lookup lookup = new AbstractLookup(content); Collection<? extends Integer> result;result = lookup.lookupAll(Integer.class); // empty listcontent.add(2);content.add(3);result = lookup.lookupAll(Integer.class); // {2, 3}content.add("vier");result = lookup.lookupAll(Integer.class); // {2, 3}Collection c = lookup.lookupAll(Object.class); // {2, 3, "vier"}content.remove(3);result = lookup.lookupAll(Integer.class); // {2}
x1 y x2 a
Container of Java object instances
![Page 15: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/15.jpg)
15
Lookup Example Usage
SaveAction Editor
give me a SaveCookie
s
s == null ?
yes
disable action
no
enable action
on action invocation:
call s.save()
interface SaveCookie { void save();}
![Page 16: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/16.jpg)
16
Proxy Lookups
Lookup Lookup
Lookup
Lookup
is union of
delegates to one of
Frequently used lookups in NetBeans
● Lookup.getDefault() is the global lookup
● Utilities.actionsGlobalContext() delegates to lookup of current active window
● Lookup of a view (e.g. ListView, TreeView) delegates to lookup of current selected item
![Page 17: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/17.jpg)
17
Dependency Removal
UpperCaseFilterWordEngine
TextFilter
TextFilter filter = Lookup.getDefault().lookup(TextFilter.class);String s = filter.process("test");
at.ssw.UpperCaseFilter
File META-INF/services/at.ssw.TextFilter
![Page 18: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/18.jpg)
18
Lookup Listening
Lookup.Result<Integer> result = lookup.lookupResult(Integer.class);result.addLookupListener(new MyLookupListener());
class MyLookupListener {
public void resultChanged(LookupEvent e) {
Lookup.Result<Integer> result = (Lookup.Result<Integer>)e.getSource(); System.out.println("Lookup changed!"); for (Integer i : result.allInstances()) { System.out.println(i); } }
}
![Page 19: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/19.jpg)
19
Explorer and Nodes API
TopComponent
ExplorerManager
TreeTableView
Node
Children
![Page 20: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/20.jpg)
20
JavaBeans● Specification of a JavaBean
- via special public Java methods (Introspection)
- via BeanInfo object
● JavaBeans expose Properties and Events
● Persistence
![Page 21: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/21.jpg)
21
Nodes and Actions (1)
Node Action
? extends Cookie
provides in lookup asks for
![Page 22: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/22.jpg)
22
Nodes and Actions (2)Action
Lookup Utilities.actionsGlobalContext
Lookup of active top component
Lookup of ExplorerManager
Lookup of selected Nodes
Node
accesses
delegates
delegates
delegates
is provided by
![Page 23: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/23.jpg)
23
Backward Compability (1)
IEditorPart
ISaveablePart
AbstractTextEditor
MyTextEditor
MyTopComponent
SaveCookie
SaveAction SaveAction
Introducing a new
method in save
interface? SaveCookieImpl
Introducing a new
method in save
interface?
extends
provides
uses uses
![Page 24: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/24.jpg)
24
Backward Compability (2)
IEditorPart
ISaveablePart
AbstractTextEditor
MyTextEditor
SaveAction2
IEditorPart2
ISaveablePart2
AbstractTextEditor2
cannot extend both!
SaveAction
![Page 25: Introduction to the NetBeans Platform](https://reader031.vdocument.in/reader031/viewer/2022012921/61c8ff614a25bd1b5c43a699/html5/thumbnails/25.jpg)
25
Backward Compability (3)
MyTopComponent
SaveCookie
SaveAction
SaveCookieImpl
SaveCookie2
SaveAction2
SaveCookieImpl2
can provide both!