Java Netbeans - Desktop Application Architecture

42
java.sun.com/javaone/sf | 2004 JavaOne SM Conference | Session TS-1694 1 How to Simplify Building Rich Clients in the JavaProgramming Language Jaroslav Tulach, Sun Microsystems Rich Unger, Nuance André Eickler, Nokia

description

netbeans

Transcript of Java Netbeans - Desktop Application Architecture

Page 1: Java Netbeans - Desktop Application Architecture

java.sun.com/javaone/sf

| 2004 JavaOneSM

Conference | Session TS-16941

How to Simplify Building Rich Clients in the Java™ Programming Language

Jaroslav Tulach, Sun MicrosystemsRich Unger, NuanceAndré Eickler, Nokia

Page 2: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16942

Write Rich Desktop Apps While Saving Time and Money

Learn how to write and assemble rich client Java™ technology-based desktop applications while reusing many developer-years invested in development of the NetBeans™ platform

Page 3: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16943

Agenda

• The need for rich desktop clients• Benefits of modular architecture• Branding and customization• Case Study—V-Builder─ Reusing existing components

• Case Study—NetAct desktop─ NetBeans platform as an ideal

J2EE™ platform client

Page 4: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16944

• Web will not do it all─ Real-time

interaction (dealing, monitoring)

─ Integration withOS (sound, etc.)

• 100% Java technology counts─ Ease of administration and distribution─ Plain JFC/Swing may be too plain

• NetBeans Platform ─ The engine behind NetBeans IDE

The Need for Rich Desktop Clients

Page 5: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16945

DemoSmall Introduction to NetBeansIDE and Platform

5

Page 6: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16946

Costs Savings

• Avoid reinventing the wheel─ Windowing, Menu, Toolbars, etc.─ Modularization, Branding, Localization

• Concentrate on guts only─ Write business logic, reuse the framework

• Assemble Applications from Components─ A lot of existing components on netbeans.org─ Designed in modular way

The advantages of reusing NetBeans platform

Page 7: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16947

Modularity of Components

• Discipline: Developers write cleaner code• Final assembly of application is independent• Solutions tailored to customer needs• Much tighter UI tasks flow

Its importance for good UI application

Appl

icat

ion

Appl

icat

ion

Appl

icat

ion

Mod

ule

Mod

ule

Mod

ule

Mod

ule

Mod

ule

Platform

= UI task flow

Page 8: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16948

Modularity in NetBeansModify your application to be NetBeans IDE module

Manifest-Version: 1.0OpenIDE-Module: org.netbeans.modules.text/1OpenIDE-Module-Specification-Version: 1.13

• Module is any JAR file with enhanced manifest

• What is this good for?─ Identification of each library─ Version specification─ Dependencies

Page 9: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-16949

Modularity in NetBeansDependencies between modulesOpenIDE-Module-Specification-Version: 1.13OpenIDE-Module-Provides: EditorImplOpenIDE-Module-Module-Dependencies: org.netbeans.api.spellchecker/1 > 1.3,

org.netbeans.core > 4.32OpenIDE-Module-Requires: SpellImpl

• Types of modules─ Regular─ Autoload─ Eager

Page 10: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169410

Modularity in NetBeansModule Enablement and ClassLoader Hierarchy

org.netbeans.core

org.netbeans.api.spellchecker/1

org.netbeans.modules.text/1Provides: EditorImplRequires: SpellImpl

Autoload

org.netbeans.spellimplProvides: SpellImpl

• Dependencies influence runtime classpath• A module can turn other modules on

Page 11: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169411

Cooperation of Modules

• Menu, toolbar elements─ Get merged together by the NetBeans framework

• Windows layout• Registration solved by Layers

Composition of UI Elements

<folder name="Menu" > <folder name="File" > <file name="Open.instance" > <attr instanceCreate= "org.openide.actions.OpenAction" /> </file> </folder></folder>

Page 12: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169412

Cooperation of Modules Composition of Menu

Windows, Toolbars, etc. work in the same way

<folder name="Menu/File"> <file name="NewProject.instance" /> <file name="ImportProject.instance" /> <file name="Separator.instance" /> <file name="OpenProject.instance" /> <file name="OpenRecent.instance" /> <file name="CloseProject.instance" /></folder>

<folder name="Menu/File"> <file name="NewFile.instance" /> <file name="Open.instance" /></folder>

<folder name="Menu/File"> <attr name="NewProject.instance/NewFile.instance" boolvalue="true" /> <attr name="NewFile.instance/ImportProject.instance" boolvalue="true" /> <attr name="OpenProject.instance/Open.instance" /> <attr name="Open.instance/OpenRecent.instance" /></folder>

Page 13: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169413

Cooperation of Modules

• A module owns a Window, another an action• Windows can have associated Context• Selected window defines the global context• UI Elements update its state according to it• What is inside context?─ Anything important (javax.swing.Document, etc.)

• What operations context need to support?─ Changes of its content─ Observability

Exposing module state

Page 14: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169414

Cooperation of Modules

class MyWindow extends org.openide.windows.TopComponent { private JEditorPane pane;

public org.openide.util.Lookup getLookup () { return Lookups.singleton(pane.getDocument())}

}

Exposing Window State

Page 15: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169415

Cooperation of Modules

import org.openide.util.Utilities;class MyInsertAction extends AbstractAction { public void actionPerformed (ActionEvent ev) { Lookup lkp = Utilities.actionGlobalContext(); Document doc = lkp.lookup (Document.class); if (doc != null) { doc.insertString (0, null, "Hello world!"); } }} In similar way one can listen to changes in Lookup using LookupListener.

Querying and Listening to State

Page 16: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169416

Cooperation of Modules

• Presentation of tree hierarchies─ Not only tree view, but many others

• Each Node has its own context─ Can be queried and observed

• Modules can contribute to the hierarchy

Generic Viewer—Explorer

Page 17: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169417

Branding and Customization

• Sun products are branded, L10N and A11Y• Customization by selection of modules• Overriding or masking resources─ <file name="Open.instance" />─ <file name="Open.instance_hidden" />

Page 18: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169418

Rich Unger

The Need for Rich Desktop ClientsBenefits of Modular ArchitectureBranding and CustomizationCase Study—V-BuilderCase Study—NetAct Desktop

Page 19: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169419

What Is V-Builder?

• Design telephone conversations between a human and a computer

• Edit many file types─ Call-flow design─ Prompt (.wav)─ Grammar (linguistic regular expression)─ VoiceXML

• Run the application using vocal or textual interactions

Voice User Interface (VUI) IDE

Page 20: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169420

What Is V-Builder?

Page 21: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169421

Challenges

• 5 developers• IDEs not our core competency─ VUI experts, not GUI experts

• High customer expectations─ Source control─ Syntax coloring/completion─ Easy enough for non-programmers (and yet, speech

recognition is very complicated)

Page 22: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169422

Solution:

Netbeans Platform Gives You

Free Stuff

Page 23: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169423

Source Control (VCS)

• Use org.openide.filesystems.FileObject instead of java.io.File─ Similar API─ Wraps access in redirection layer

• Free support for multiple sourcecontrol systems─ CVS─ Subversion─ SourceSafe─ ClearCase─ PVCS

Page 24: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169424

XML EditorDeclare a new MIME typeVoiceXMLDataLoader.java:protected MultiDataObject createMultiObject (FileObject primaryFile) { return new XMLDataObject(primaryFile, this);}protected FileObject findPrimaryFile(FileObject fo) { if (fo.isFolder()) return null; if (fo.getMIMEType().equals( "application/voicexml+xml")) return fo; return null;}

Page 25: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169425

XML Editor

Page 26: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169426

Source Editor

• Declare an org.netbeans.editor.Syntax subclass (for completion and coloring)

• Add an EditorSupport cookie

GSL Files—a text file with a unique syntax

Page 27: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169427

Context-Sensitive Help

public HelpCtx getHelpCtx() { return new HelpCtx(MyClass.class);}

Uses JavaHelpTM API

Page 28: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169428

Other Stuff...

• Update Center• Templates• Wizards• Task list• ANSI terminal• ... And on, and on...

Page 29: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169429

DemoNuance V-Builder

Page 30: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169430

André Eickler

The Need for Rich Desktop ClientsBenefits of Modular ArchitectureBranding and CustomizationCase Study—V-BuilderCase Study—NetAct Desktop

Page 31: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169431

What Is NetAct?

• Manages thousands of network elements, tens of network element types, tens of vendors

• Contains configuration, monitoring, reporting, planning, ...

Nokia’s product for managing mobile networks

MSC/VLR

SS7Network

Border Gateway

SGSN

GGSN

Lawful InterceptionGateway (LIG)

Charging GatewayGPRS

backbone

CC&B

NMS

Operator Services

HLR/AuCEIR/SMSC

Inter-PLMNnetwork

BTS BSC

ApplicationServers

Mobile ISP

router/firewall

router/firewall

Corporate Customer

ApplicationServers

Internet

MSC/VLR

SS7Network

Border Gateway

SGSN

GGSN

Lawful InterceptionGateway (LIG)

Charging GatewayGPRS

backbone

CC&B

NMS

Operator Services

HLR/AuCEIR/SMSC

Inter-PLMNnetwork

Inter-PLMNnetwork

BTSBTS BSCBSC

ApplicationServers

Mobile ISP

router/firewall

ApplicationServers

Mobile ISP

router/firewall

router/firewall

Corporate Customer

ApplicationServers

router/firewall

Corporate Customer

ApplicationServers

InternetInternet

Page 32: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169432

What Are NetAct’s UI Challenges?

• More than 70 user interface applicationsin Nokia’s product (plus other vendor’s applications)

• Daily management procedures easilyinvolve ten or more graphical tools

• Procedures vary largely betweennetwork operators

Seamless integration of large numbersof management tools

Page 33: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169433

What Is NetAct’s Solution?

• NetBeans Platform─ Module concept, window system, ...─ JFC/Swing compatibility (porting existing

Uis, third-party software)

• J2EE platform client support─ Java Web Start software support─ ...

• Navigation goodies─ ExtensibleNode─ Bookmarks

NetAct Desktop = NetBeans + J2EE + Navigation

Page 34: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169434

Screenshot

Page 35: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169435

Java Web Start Software Support

• Module discovery servlet─ Find all deployed NetBeans modules on a server─ Dynamically generate JNLP file

• Classpath workaround─ Java Web Start breaks NetBeans’ module system

by making all downloaded classes visible─ All files in module jars get prefixed by a directory

to make them “invisible”─E.g., class "org.netbeans.api.enode.ExtensibleNode"

becomes "enode/org/netbeans/api/enode/ExtensibleNode.class"

─ Special classloader resolves access to classes

Integration with NetBeans module system

http://installer.netbeans.org/docs/jnlpInstaller2.html

Page 36: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169436

Extensible Node

• Modules declare actions offered forparticular nodes as part of their Layer file:

• Other modules can use ExtensibleNode to display popup menus with all declared actions─ E.g., network elements displayed in

any module will offer the “reset” action

Simple pluggable navigation feature

http://openidex.netbeans.org/source/browse/openidex/enode/

<folder name="ExtensibleNode" > <folder name="Actions" > <folder name="Network Element"> <file name= "com-nokia-oss-ResetAction.instance"/> </folder> </folder></folder>

Page 37: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169437

Bookmarks

• Forward/backward navigation between tool states

Web-style navigation for NetBeans platform

http://contrib.netbeans.org/source/browse/contrib/bookmarks/

public interface NavigationEvent { public void restoreState(); public TopComponent getTopComponent();}

Page 38: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169438

Bookmarks

• Bookmarking tool states as keyboard shortcut, “Bookmarks” menu, toolbar entries

public interface BookmarkProvider { public Bookmark createBookmark();}public interface Bookmark extends Presenter.Menu, Presenter.Toolbar { public String getName(); public void invoke();}

Page 39: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169439

DemoNetAct Desktop

39

Page 40: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169440

NetBeans Has All You Need to Efficiently Develop Integrated Rich Clients

Visit http://www.netbeans.orgVisit http://www.nuance.comVisit http://www.nokia.com

The NetBeans Day Tuesday in Yerba Buena Theater

Meet NetBeans on BOFs and sessionsBuilding Great Looking Swing Apps, 1237

Wednesday 11:00 AMWhat’s New With NetBeans IDE?, 3204

Wednesday 9:45 AM Integrating Ant and NetBeans, 1598

Wednesday 8:30 PMMeet the NetBeans™ Development Team, 2730

Wednesday 7:30 PMGet free stuff from the Nokia booth, 1415

Page 41: Java Netbeans - Desktop Application Architecture

| 2004 JavaOneSM

Conference | Session TS-169441

Q&AAndré Eickler, NokiaJaroslav Tulach, Sun MicrosystemsRich Unger, Nuance

Page 42: Java Netbeans - Desktop Application Architecture

java.sun.com/javaone/sf

| 2004 JavaOneSM

Conference | Session TS-169442

How to Simplify Building Rich Clients in the Java™ Programming Language

Jaroslav Tulach, Sun MicrosystemsRich Unger, NuanceAndré Eickler, Nokia