NetBeans: the Definitive Guide

harmonyashamedΛογισμικό & κατασκευή λογ/κού

5 Ιουν 2012 (πριν από 5 χρόνια και 3 μήνες)

2.383 εμφανίσεις

NetBeans:the Definitive Guide
Table of Contents
NetBeans ina Nutshell................................................................................................................................................
1.Introduction....................................................................................................................................................
Is NetBeans For You?..............................................................................................................................1
Is This Book For You?.............................................................................................................................2
NetBeansandJava...................................................................................................................................2
What are Java Beans?.....................................................................................................................2
The Core Concept of NetBeans......................................................................................................3
NetBeans as the"Visual JDK".................................................................................................................4
All The Usual Features...................................................................................................................4
NetBeans as a tools platform...................................................................................................................5
NetBeans as an open source community..................................................................................................6
ASteady Streamof Creativity........................................................................................................6
Don't Be Cross That This Book Is Cross-Platform........................................................................6
Contents of the Accompanying Sources..................................................................................................7
Licensing of the Code Examples in this Book.........................................................................................7
Writing Conventions in this Book...........................................................................................................7
CommentsandQuestions.........................................................................................................................7
Acknowledgments....................................................................................................................................8
Reviewers.......................................................................................................................................8
SimeonGreene...............................................................................................................................8
VaughnSpurlin...............................................................................................................................9
JackWoehr.....................................................................................................................................9
JesseGlick......................................................................................................................................9
TimBoudreau.................................................................................................................................10
2.Getting and Installing the IDE.......................................................................................................................
PlatformsandRequirements....................................................................................................................11
What are the systemrequirements to run NetBeans?.....................................................................11
Getting and Installing a JDK....................................................................................................................12
The Java Development Kit.............................................................................................................12
Relationship of JDKto JRE...........................................................................................................13
ObtainingtheJDK..........................................................................................................................13
WhichIDEDistribution?.........................................................................................................................14
InstallingBinaryDistributions.................................................................................................................15
Building the IDEfromSource (Simple builds).......................................................................................16
What you'll need to build the IDE..................................................................................................16
Setting up and performing the build...............................................................................................17
Where dideverythinggo?..............................................................................................................18
Howdo I install a newly built version of NetBeans?.....................................................................18
RunningtheIDE......................................................................................................................................19
Minimalenvironment.....................................................................................................................19
HowtoLaunchNetBeans...............................................................................................................20
MultipleNetBeansusers.................................................................................................................21
Troubleshooting..............................................................................................................................22
Updatingthe IDEAutomatically.............................................................................................................25
TheUpdateCenter..........................................................................................................................25
Configuringthe Update Center......................................................................................................26
SetupWizard..................................................................................................................................27
You're nowrunningNetBeans.................................................................................................................27
3.Concepts andParadigms................................................................................................................................
NetBeans and the Java abstract model of computing..............................................................................29
Explorer....................................................................................................................................................30
Objects in the UI are represented by NetBeans nodes...................................................................30
Data objects,nodes,and the concept of actions and properties.....................................................31
Tabs in the Explorer and their purposes.........................................................................................38
NodeParadigms..............................................................................................................................44
Sometimes Explorer Gets Behind the Times..................................................................................47
Filesystems andthe CLASSPATH.................................................................................................48
CreatingPackages andClasses................................................................................................................52
CreatingPackages..........................................................................................................................52
CreatingClasses.............................................................................................................................52
Services....................................................................................................................................................55
Compilerservices...........................................................................................................................55
Executionservices..........................................................................................................................57
Debuggingservices........................................................................................................................57
Workspaces..............................................................................................................................................58
Editing............................................................................................................................................59
GUIEditing....................................................................................................................................59
Browsing.........................................................................................................................................59
Running..........................................................................................................................................59
Debugging......................................................................................................................................59
Persistenceacrosssessions.............................................................................................................59
Using multiple instances of Explorer in different workspaces.......................................................60
Using multiple instances of the Source Editor in different workspaces.........................................60
ProjectManagement................................................................................................................................60
Managingmultipleprojects............................................................................................................61
Managing project builds using Ant................................................................................................62
ObjectBrowser........................................................................................................................................63
Summary..................................................................................................................................................66
4.Working with the Source Editor....................................................................................................................
Why learn a neweditor?..........................................................................................................................68
Openingthe Source Editor.......................................................................................................................68
Contextmenus..........................................................................................................................................69
Closingthe Source Editor........................................................................................................................69
Codecompletion......................................................................................................................................69
Using (and Not Using) NetBeans Source Editor Code Completion...............................................70
Updating the parser database to include newclasses.....................................................................71
Abbreviations.................................................................................................................................73
Editorcolorings........................................................................................................................................74
Shortcuts...................................................................................................................................................75
Wordmatching.........................................................................................................................................76
Indentation engines and code formatting.................................................................................................77
Automaticedits........................................................................................................................................77
Other Editor Functionality.......................................................................................................................78
Creating,editing,compiling and running a simple example...................................................................79
More on Customizing the Source Editor..................................................................................................82
5.Debugging......................................................................................................................................................
DebuggerTypes.......................................................................................................................................83
BreakpointTypes.....................................................................................................................................84
Addingandremovingbreakpoints...........................................................................................................85
Settingwatches........................................................................................................................................89
StartingtheDebugger..............................................................................................................................89
TheDebugger Window............................................................................................................................90
TheVariablesView.................................................................................................................................92
Remote DebugginginNetBeans..............................................................................................................93
Howtodebugremotely..................................................................................................................93
Caveats...........................................................................................................................................95
Advancedfeatures..........................................................................................................................96
6.Compilation and Execution Services.............................................................................................................
Using CustomCompilation and Execution Services...............................................................................97
Creating and Customizing Internal Compilation Services.............................................................97
Creating and Customizing External Compilation Services............................................................98
The Internal ExecutionService......................................................................................................103
Creating and Customizing External Execution Services................................................................103
Associating Services With Java Files......................................................................................................104
Setting Default Services for Java Files...........................................................................................104
Setting Services for Specific Files..................................................................................................104
BuildingWithAnt....................................................................................................................................104
Creatinga BuildScript...................................................................................................................104
Configuringthe Ant Module..........................................................................................................107
Executing and Compiling With Ant Scripts...................................................................................108
WhyUseAnt?................................................................................................................................108
7.Customizingthe environment........................................................................................................................
TheSetupWizard.....................................................................................................................................109
General NetBeansSettings.............................................................................................................109
ModuleInstallation.........................................................................................................................112
UpdateCenter.................................................................................................................................112
TheToolsOptionsDialog.........................................................................................................................113
ConfiguringToolbars...............................................................................................................................114
ConfiguringMenus..................................................................................................................................116
ConfiguringEditors..................................................................................................................................117
Object TypeAssociations...............................................................................................................117
EditorSettings................................................................................................................................118
Commandlineoptions.............................................................................................................................126
Modules....................................................................................................................................................128
InstallingModules..........................................................................................................................128
EnablingandDisablingModules...................................................................................................131
8.Using Source Control (CVS).........................................................................................................................
What isCVS?...........................................................................................................................................133
The How,When and Why of CVS in NetBeans......................................................................................135
Whentouse CVS...........................................................................................................................135
Where to get a client.......................................................................................................................135
Howdoes NetBeans interact with CVS?........................................................................................135
UsingGenericVCS........................................................................................................................136
Using Command-Line CVS Support versus Built-in CVS............................................................136
What parts of my project does CVS within NetBeans save?.........................................................137
Does NetBeans automatically add newfiles and packages I create to the repository?..................137
Howdo I manipulate my NetBeans project directly with CVS outside of NetBeans?..................137
MountingCVSsources............................................................................................................................138
ExploringVersionedSources...................................................................................................................138
Performing common CVS operations within the IDE.............................................................................139
Checkout/Get..................................................................................................................................140
Checkin/Commit.............................................................................................................................141
AddandImport...............................................................................................................................141
Log..................................................................................................................................................142
Diff.................................................................................................................................................143
Update.............................................................................................................................................144
UnexpectedResults..................................................................................................................................144
Spurious[Local] Designation.........................................................................................................144
WhenAddingdirectories................................................................................................................145
WhenAddingbinaryfiles..............................................................................................................145
Uncommon CVSoperations within the IDE............................................................................................145
Branching,MergingandTagging...................................................................................................146
NetBeans CVS and the Secure Shell (SSH)...................................................................................146
Mounting and Customizing a Generic Versioning System......................................................................146
OneFinal Tip...........................................................................................................................................149
9.GUI Building.................................................................................................................................................
Howto create a GUI frame or panel........................................................................................................151
Howto add components to a GUI container............................................................................................155
Configuring components with the Component Inspector........................................................................156
Buildingmenus........................................................................................................................................157
Howto change and configure a container's Layout.................................................................................157
WorkingwithBorders..............................................................................................................................158
Accessibility.............................................................................................................................................158
Copyinga Source Object.........................................................................................................................159
TheConnectionWizard...........................................................................................................................159
TheGridBagLayout Customizer..............................................................................................................161
Addingevent handlers.............................................................................................................................164
Using the Code Generation Properties.....................................................................................................166
NetBeans made a mistake in code generation,what are the workarounds?.............................................168
ContainerswithinContainers...................................................................................................................171
BuildingComplexGUIs..........................................................................................................................171
10.JavaBeans...................................................................................................................................................
Why Should I Make Beans?.....................................................................................................................173
CreatingJavaBeans.................................................................................................................................173
Creatinga GUI Component............................................................................................................174
Converting a GUI Component into a Bean....................................................................................176
Adding an Event Set to a Bean.......................................................................................................179
Generatinga BeanInfoClass..........................................................................................................181
Addinga Design-Time Icon...........................................................................................................183
ComponentPalette...................................................................................................................................183
Adding a Category to the Component Palette................................................................................183
Adding a Bean to the Component Palette.......................................................................................184
Component PaletteProblems.........................................................................................................185
11.UsingJavadoc..............................................................................................................................................
Javadoc Support inNetBeans..................................................................................................................186
Mounting Javadocs in the Javadoc Repository........................................................................................186
The Javadoc SearchTool.........................................................................................................................187
Creatingyour ownJavadoc......................................................................................................................190
The AutoComment Tool................................................................................................................190
JavadocGeneration........................................................................................................................193
12.WorkingwithXML.....................................................................................................................................
InstallingXMLSupport...........................................................................................................................196
Overview..................................................................................................................................................197
Templates.......................................................................................................................................197
BrowsingandEditing.....................................................................................................................197
GeneratingDocumentation.............................................................................................................197
AccessingwithJava.......................................................................................................................197
Where's XMLSchema Support?....................................................................................................198
XMLEditors—Tree Editor and Text Editor............................................................................................198
BeyondEditingXML...............................................................................................................................201
CheckingandValidatingXML......................................................................................................201
Settingthe Node View....................................................................................................................202
Generating Separate DTDfromExisting XML.............................................................................203
Generating Documentation to Help Humans Understand XML....................................................204
GeneratingCSSfromDTD............................................................................................................206
Generating Java Classes to Handle XML................................................................................................206
Generating a SAXDocument Handler...........................................................................................206
Generating a DOMTree Scanner...................................................................................................209
13.DevelopingWebApplications.....................................................................................................................
Why the IDESupports Web Application Development..........................................................................214
Howthe IDEProvides Web Application Support...................................................................................214
Creatinga WebApplication.....................................................................................................................214
TheFilesystemsView....................................................................................................................216
The WebProject View...................................................................................................................217
Working with JSPand HTMLfiles.........................................................................................................218
AdvancedWebApplications Features.....................................................................................................221
ExecutingWebApplications..........................................................................................................221
WorkingwithServlets....................................................................................................................222
Packaging and Deploying Web Apps......................................................................................................223
DeployingWebApps.....................................................................................................................224
ConfiguringTomcat.......................................................................................................................224
A.Resources......................................................................................................................................................
CVSResources........................................................................................................................................227
CVSHome.......................................................................................................................................227
GNU/BSD/Other OperatingSystems.............................................................................................227
CVSGUI Clients............................................................................................................................228
JavaEnvironments...................................................................................................................................228
JavaTools................................................................................................................................................228
ApacheSoftwareFoundation.........................................................................................................229
Secure Shell (SSH) Resources.................................................................................................................229
Cygwinfor Windows...............................................................................................................................229
Newsgroups andMailingLists................................................................................................................230
WebSites.................................................................................................................................................230
Organization of main NetBeans website........................................................................................230
Mirrors............................................................................................................................................230
SunSites.........................................................................................................................................230
Open source projects coded using NetBeans which include NetBeans design forms in the distribution
...................................................................................................................................................................231
Java-oriented IDE's other than NetBeans.................................................................................................231
Bibliography......................................................................................................................................................
ExtendingNetBeans....................................................................................................................................................
Foreword—byJamesGosling...........................................................................................................................
1.Introduction....................................................................................................................................................
Who Should Read this Book?..................................................................................................................249
What’s Different about NetBeans?..........................................................................................................250
The Core and the Open APIs...................................................................................................................250
TheLicense....................................................................................................................................251
Open-Source...................................................................................................................................252
The netbeans.orgWebSite.............................................................................................................252
NetBeans for BeanCounters....................................................................................................................254
Getting and Installing the Open APIs Support Module...........................................................................255
LifeisChange..........................................................................................................................................256
Source code for the examples..................................................................................................................256
2.Historyof NetBeans......................................................................................................................................
HumbleBeginnings..................................................................................................................................257
First Successes,First Costs......................................................................................................................258
SunMeetsNetBeans................................................................................................................................259
Open-Source,Fire-Drill Style..................................................................................................................260
NetBeansToday.......................................................................................................................................260
3.Understanding the NetBeans APIs................................................................................................................
DesignPhilosophyof NetBeans..............................................................................................................261
Abstracting the Abstractions—the Open APIs...............................................................................262
Modularity......................................................................................................................................262
Hierarchy,Files andNodes............................................................................................................263
Everythingis a File—Virtually......................................................................................................263
Mapping Files to Java Objects.......................................................................................................264
TheSystemFilesystem...................................................................................................................265
ModuleLayers................................................................................................................................265
Layers in the SystemFilesystem....................................................................................................266
Exploringthe SystemFilesystem...................................................................................................267
Data Objects—Wrappers for Persistent Data.................................................................................270
NetBeansandJavaBeans................................................................................................................270
Nodes—the Applicationas Hierarchy............................................................................................270
Presenting Nodes to the User—Explorer.......................................................................................271
User-LevelCustomization.......................................................................................................................273
Nodes in Action—Customizing the IDEwithout Writing Code....................................................275
Modules—Overview................................................................................................................................278
HowModules AddFunctionality...................................................................................................278
HowModules Install Virtual FilesystemLayers............................................................................279
What Modules CanDo...................................................................................................................279
DisablingModules..........................................................................................................................280
An Illustration—NetBeans with No Modules at All......................................................................280
Interacting with the IDEthrough Internal Execution...............................................................................281
Setting the Status Bar Text.............................................................................................................282
Settingthe Current Workspace.......................................................................................................283
4.The OpenAPIs..............................................................................................................................................
The IDE’s Architecture and the APIs......................................................................................................284
APIs versus Core versus Modules...........................................................................................................285
Service Provider Interfaces and Client APIs............................................................................................286
Overviewof the APIs and Their Purposes...............................................................................................286
Modules..........................................................................................................................................287
Lookup and the Services API.........................................................................................................294
Nodes..............................................................................................................................................296
Datasystems....................................................................................................................................299
Explorer..........................................................................................................................................299
Actions............................................................................................................................................304
Options...........................................................................................................................................305
Compiler.........................................................................................................................................305
Editor..............................................................................................................................................306
WindowingSystem........................................................................................................................307
Cookies...........................................................................................................................................309
Execution........................................................................................................................................310
JavaHierarchy................................................................................................................................310
Filesystems.....................................................................................................................................311
Modules,JARs,and Class Loaders..........................................................................................................312
Threading,Deadlocks,and Howto Avoid Them....................................................................................317
5.Developing Modules—the NewModule Wizard..........................................................................................
TheHelloWorldModule..........................................................................................................................319
Creating a Module Using the NewModule Wizard.......................................................................319
TheSourceFiles.............................................................................................................................320
6.Internals of the Running IDE.........................................................................................................................
TheActivatedNode(s).............................................................................................................................323
Cookies.....................................................................................................................................................324
APeek under the Hood—Examining the Activated Nodes with the CurrentNodeViewer.....................325
Touring NetBeans with the Bean Browser..............................................................................................325
Data Objects,Nodes and Cookies............................................................................................................327
Filesystems andthe Repository................................................................................................................327
Services....................................................................................................................................................328
Lookup.....................................................................................................................................................329
Options.....................................................................................................................................................330
UIComponents........................................................................................................................................331
TopComponents,Modes andWorkspaces.....................................................................................331
Actions............................................................................................................................................336
Presenters........................................................................................................................................337
CustomPropertyEditors................................................................................................................337
Localization..............................................................................................................................................337
Wizards....................................................................................................................................................338
Jumping-offPlaces...................................................................................................................................338
Special Folders in the SystemFilesystem................................................................................................339
7.Creating the QuickPanel Module...................................................................................................................
Abstractions Covered in this Chapter......................................................................................................342
Creating the Project Files Drop-Down.....................................................................................................343
FilterNode—Filtering Which Children of a Node are Displayed............................................................347
Creatingthe Methods Drop-Down...........................................................................................................349
Improvingthe Methods Drop-Down........................................................................................................350
CreatingtheModule.................................................................................................................................353
Creating a Container GUI Component...........................................................................................354
CreatingtheShowQuickPanelAction.............................................................................................354
Creating the XMLFilesystemLayer..............................................................................................355
Creating and Populating the Module JAR......................................................................................356
Building and Testing the Module...................................................................................................356
ALittleHomework..................................................................................................................................357
8.AMail-BasedFilesystem..............................................................................................................................
Building a Mail Reader in the NetBeans Paradigm.................................................................................358
Implementing MailFileSystemUsing AbstractFileSystemand JavaMail...............................................359
Creating a NewAbstractFileSystemImplementation....................................................................359
Mail Filesystem:AbstractFileSystem.Info.....................................................................................360
Mail Filesystem:AbstractFileSystem.List.....................................................................................361
Mail Filesystem:AbstractFileSystem.Change...............................................................................362
Mail Filesystem:AbstractFileSystem.Attr.....................................................................................363
Other Parts of AbstractFileSystem.................................................................................................363
Creating Folder Objects for Attachments................................................................................................366
Using FileSystem.Status Annotations to Mark Unread Messages...........................................................367
BeanInfo—DisplayingFilesystemProperties..........................................................................................369
Using the Wizard Framework to Set Up Mail Accounts.........................................................................371
CreatingWizardClasses.................................................................................................................371
The IMAPMail Server Template Wizard......................................................................................372
9.Creating the User Interface for the Mail Client.............................................................................................
Creating a DataLoader for Messages.......................................................................................................381
Displaying and Editing Simple Messages and Unnamed Attachments..........................................382
HandlingMultipart Messages.........................................................................................................386
Creating a Threaded Mail ViewUsing Filter Nodes...............................................................................387
Making a Basic Mail View.............................................................................................................388
Making a Threaded Mail Viewas an Alternative..........................................................................394
Creatinga Mail Workspace......................................................................................................................400
10.Score File Support.......................................................................................................................................
Overview—Functionalitytobe Implemented..........................................................................................406
Creating the Minicomposer Module—First Things.................................................................................406
CreatingtheManifest.....................................................................................................................406
CreatingtheLayer..........................................................................................................................407
Creating a JARFile Using Ant.......................................................................................................408
Creating a UniFileLoader and MultiDataObject for *.score Files...........................................................408
Creating an Editor Support for Scores.....................................................................................................411
Creating a Fixed ExecCookie to Play Scores...........................................................................................414
Creatinga Simple Template.....................................................................................................................417
11.Creating a Structural Viewof the Score......................................................................................................
Creating a ScoreCookie to Represent a Sequence of Notes.....................................................................419
Examples of State-Based Supports in the NetBeans APIs.............................................................420
CreatingaScoreSupport..........................................................................................................................421
Why a Document is Used...............................................................................................................421
Implementationof ScoreSupport....................................................................................................422
Lifecycle of the Score..............................................................................................................................426
AnOpenSupport......................................................................................................................................426
CreatinganOpenCookie Implementation......................................................................................427
Showing a GUI Viewof the ScoreCookie.....................................................................................429
Indicating Parse Errors on the Node........................................................................................................433
12.CompilingScores.........................................................................................................................................
What Does NetBeans Mean by “Compilation”?......................................................................................437
Creatingthe Compilers Themselves........................................................................................................437
Creating and Using the Compiler Cookie................................................................................................441
Displaying an Out-of-Date Badge on Score Icons...................................................................................445
13.ExecutingScores.........................................................................................................................................
Execution Service Types—Internal and External....................................................................................448
Creating the.au Player Executor..............................................................................................................448
TheInternal Player.........................................................................................................................449
TheExternal Player........................................................................................................................451
Registering the Players as Services................................................................................................454
Creating Player Configuration Support (ExecSupport)...........................................................................457
Creating a SystemOption for the Default Executor.................................................................................461
14.Better Score Support in the Explorer...........................................................................................................
The ClipLengthProperty........................................................................................................................467
Clearing the Cache and Firing Changes.........................................................................................469
Adding the Property to the Property Sheet.....................................................................................470
Representing Notes as Subnodes Using Children.Keys...........................................................................470
Using Keys to Model Children.......................................................................................................471
Being Lazy and Cleaning Up.........................................................................................................473
CreatingtheSubnodes....................................................................................................................474
Attaching the Children to the Parent..............................................................................................475
Permitting Subnodes to be Renamed or Deleted.....................................................................................476
Deletionof Notes............................................................................................................................476
Renamingof Notes.........................................................................................................................477
Permitting Subnodes to be Added............................................................................................................479
Making Read/Write Properties on Subnodes...........................................................................................481
ReorderingSubnodes...............................................................................................................................484
Data Transfer—Cut,Copy,and Paste of Notes and Sequences...............................................................489
Overviewof the Transferables.......................................................................................................490
CuttingandCopying.......................................................................................................................491
Pasting............................................................................................................................................492
Drag&Drop...................................................................................................................................495
Converting Score#Text,Text#Score,Several Scores#One......................................................495
15.Tuning Modules for Performance &Memory Footprint.............................................................................
Startup Performance vs.Runtime Performance.......................................................................................501
OperatingPrinciples.................................................................................................................................501
“Nobody Will Ever Use My Module”............................................................................................501
What Does My Module Really Need to Do on Startup?................................................................501
What are the Critical Paths?...........................................................................................................502
Techniques...............................................................................................................................................503
LazyInitialization...........................................................................................................................503
AvoidStaticInitializers..................................................................................................................503
Avoid ModuleInstall Classes—Use XMLLayers Instead.............................................................504
Partial Loading Considerations—InstanceCookie and InstanceDataObject..................................505
Use URLs Instead of CDATASections in XMLLayers...............................................................505
Reduce the Number of Classes You Create...................................................................................505
GUI Components—Wait for addNotify()......................................................................................505
Using the addNotify() and removeNotify() Pattern Where Exposed by Non-GUI Classes...........506
Use Weak and Soft References for Objects which May Not be Needed Forever..........................506
UseWeakListener..........................................................................................................................508
AvoidExcessive Event Firing........................................................................................................508
AvoidOveruse of Threads..............................................................................................................508
BatchingEvents..............................................................................................................................509
SwingPerformance........................................................................................................................509
16.Producing Modules (Packaging &Distribution).........................................................................................
Versioning................................................................................................................................................511
Version Numbers and What They Mean........................................................................................511
SpecifyingDependencies...............................................................................................................512
ManagingInter-ModuleDependencies..........................................................................................513
UpgradingUser Settings..........................................................................................................................516
Settings History and Physical Format............................................................................................517
Upgrade Scenarios for Settings......................................................................................................518
What Happens When a Module is Disabled?.................................................................................520
User Development Data.................................................................................................................521
BundlingExtensionLibraries..................................................................................................................521
ReferencingLibraries withClass-Path...........................................................................................522
UsingAutoloadLibraryModules...................................................................................................523
Ad-Hoc Resources and Module Installer Validation......................................................................525
InternationalizationandAccessibility......................................................................................................526
I18NandL10N...............................................................................................................................526
A11Y..............................................................................................................................................528
JavaHelp—WritingandDistributing.......................................................................................................529
Creatinga HelpSet.........................................................................................................................529
Adding a Help Set to NetBeans......................................................................................................531
AddingContext Help......................................................................................................................534
SeparatingHelpfromCode............................................................................................................535
SupportingUser-Level Java APIs............................................................................................................535
Supplyinga Parser Database..........................................................................................................535
BundlingJavadoc...........................................................................................................................536
Adding to the Default Classpath.....................................................................................................537
Templates.......................................................................................................................................538
BeanInstallation.............................................................................................................................539
Creating the Module JARFile within the IDE........................................................................................540
Creating a Build Script Using Ant...........................................................................................................540
Producingthe.nbmFile...........................................................................................................................541
Publishing Using the Update Center........................................................................................................543
Using ErrorManager to Log Problems.....................................................................................................545
Testing......................................................................................................................................................547
17.Building Your Distribution of NetBeans.....................................................................................................
Do You Need Your Own Distribution?...................................................................................................549
Licensing..................................................................................................................................................550
SelectingaBaseline.................................................................................................................................550
GettingtheSources..................................................................................................................................551
Howto Customize the Build Process to Add Your Modules..................................................................552
Adding Modules to a “Stock” Distribution..............................................................................................553
CreatingPreconfiguredSettings..............................................................................................................555
Branding...................................................................................................................................................555
Implementing Branding on a Distribution......................................................................................556
Simple Branding:Text Strings and Images....................................................................................557
Configuration Branding:Menu Bar,Workspaces,…....................................................................558
AdvancedBranding:PatchingBehavior........................................................................................564
A.ATour of Existing Modules to Use and Learn From...................................................................................
Modules that Expose Functionality Your Module Might Need...............................................................569
TheXMLModules.........................................................................................................................569
TheEditor.......................................................................................................................................570
Version Control—the VCSCore Module......................................................................................570
RemoteFS.......................................................................................................................................571
TheAnt Module.............................................................................................................................571
TheJavaModule............................................................................................................................571
DebuggerCore................................................................................................................................572
J2EEServer....................................................................................................................................572
FormEditor....................................................................................................................................572
HTTPServer Module.....................................................................................................................572
ClassfileReader Module................................................................................................................572
The Metadata Repository—a Whole Host of APIs........................................................................572
Socket-Based Editor Support—the External Editor Module..........................................................573
Incidental APIs,Utilities and Extensions................................................................................................573
TheUtilitiesModule.......................................................................................................................573
API Extensions(openidex).............................................................................................................573
Modules which Make Good Examples for Things You May Need to Implement..................................574
Annotations and Dynamic Editor Tool Tips—the Ant Module and the Debugger Core Module
.........................................................................................................................................................574
Adding Information to the Viewof Java Sources—the Beans Module.........................................574
Adding a Debugger Type—the Applet Module.............................................................................574
Multiplexing DataObjects,and Complex Cut/Copy/Paste Support—the Properties Module........574
Working with Network Protocols to Access Files—JavaCVS and RemoteFS..............................574
Domain-Specific XMLSupport—the Tomcat and Ant Modules..................................................575
Stretching the Limits—the Web Modules......................................................................................575
Complex Syntax Coloring—the JSPModule.................................................................................575
Multi-Stage Compilation—the JSP,RMI,and CORBAModules.................................................575
Bridging to an Entirely Different Build System—the Ant and Makefile Modules........................575
Use of the Compiler Infrastructure for Non-Compilation Tasks—the JARPackager Module.....576
Execution—the Applet and JSP/Servlet Modules..........................................................................576
CustomHyperlinking in the Output Window—the Ant Module...................................................576
Specifying Windows,Workspaces and Components Using XML—the Core Window System
and the FormEditor Module..........................................................................................................576
Complex Work with MIMEResolvers and Multi-File DataObjects—the CPP Module................577
Cut/Copy/Paste—Data Transfer Support for Complex Elements—the Ant and Java Modules
.........................................................................................................................................................577
Interconversion between Different Types of Clipboard Contents—JNDI,CORBA,and RMI.....577
Integrating Other Programming Languages—the C++/Fortran,Scripting,and WebL Modules
.........................................................................................................................................................577
Fancy Footwork with Nodes—the Java Module............................................................................578
Adding Nodes to the Runtime Tab in the Explorer—the RMI,CORBA,JNDI,and Database
ExplorerModules...........................................................................................................................578
The Bare Essentials of Non-Data-Driven Nodes—the SystemProperties Module.......................578
Wizards—the CORBA,Java and NewModule Wizard Modules.................................................578
Embedding Property Panels into Wizards—the Java Module.......................................................578
Complex Explorer Views—the Debugger Core Module...............................................................578
Enabling/Disabling Sets of Actions based on Context—the VCS Core Module...........................579
B.Useful UtilityClasses....................................................................................................................................
XMLUtilities...........................................................................................................................................580
org.openide.xml.XMLUtil..............................................................................................................580
org.openide.xml.EntityCatalog.......................................................................................................580
Visual Components and Extensions to Standard Swing Components.....................................................580
LookupImplementations.........................................................................................................................581
Threading.................................................................................................................................................581
Miscellaneous Utility Classes in org.openide.util....................................................................................581
SerializationHelpers................................................................................................................................582
C.FuturePlans...................................................................................................................................................
DeclarativeInstantiation..........................................................................................................................583
UniformLookup......................................................................................................................................583
DatasystemsII..........................................................................................................................................584
TheLooksAPI.........................................................................................................................................584
DeclarativeActions..................................................................................................................................585
Deprecation of IDE-Specific Functionality in the Open APIs.................................................................585
TheMetadataRepository.........................................................................................................................585
Standards Employed by the MDR..................................................................................................586
ProjectSupport.........................................................................................................................................587
D.Working with Open-Source and NetBeans...................................................................................................
Practices...................................................................................................................................................589
Governance.....................................................................................................................................589
Consensus.......................................................................................................................................590
HowtoGet Involved......................................................................................................................595
The Lifecycle of Module Development.........................................................................................600
Resources.................................................................................................................................................602
CVS(Concurrent VersioningSystem)...........................................................................................602
Projects...........................................................................................................................................602
MailingLists...................................................................................................................................602
Issuezilla.........................................................................................................................................603
Interacting Effectively on Mailing Lists..................................................................................................604
E.Additional Modules and Where to Find Them..............................................................................................
Open-Source Modules Available via the Update Center.........................................................................606
The Modules Marketplace on Flashline...................................................................................................606
IDEs that are Distributions of the NetBeans IDE....................................................................................608
Open-Source Application Projects Based on NetBeans..........................................................................609
Commercial Applications Built on the NetBeans Platform.....................................................................609
Commercial Modules Available for NetBeans........................................................................................610
Should You Create Your Own Update Server?.......................................................................................612
Glossary.............................................................................................................................................................
NetBeans in a Nutshell
NetBeans in a Nutshell
Copyright ©2001,2002 O’Reilly &Associates,Inc.
Warning
This is a DRAFT IN PROGRESS and should not be distributed freely!Except with special permission,only O’Reilly employees,authors,
and reviewers should be reading this manuscript at this stage.
Table of Contents
1.Introduction.............................................................................................................................................................
Is NetBeans For You?..............................................................................................................................1
Is This Book For You?.............................................................................................................................2
NetBeansandJava...................................................................................................................................2
What are Java Beans?.....................................................................................................................2
The Core Concept of NetBeans......................................................................................................3
NetBeans as the"Visual JDK".................................................................................................................4
All The Usual Features...................................................................................................................4
NetBeans as a tools platform...................................................................................................................5
NetBeans as an open source community..................................................................................................6
ASteady Streamof Creativity........................................................................................................6
Don't Be Cross That This Book Is Cross-Platform........................................................................6
Contents of the Accompanying Sources..................................................................................................7
Licensing of the Code Examples in this Book.........................................................................................7
Writing Conventions in this Book...........................................................................................................7
CommentsandQuestions.........................................................................................................................7
Acknowledgments....................................................................................................................................8
Reviewers.......................................................................................................................................8
SimeonGreene...............................................................................................................................8
VaughnSpurlin...............................................................................................................................9
JackWoehr.....................................................................................................................................9
JesseGlick......................................................................................................................................9
TimBoudreau.................................................................................................................................10
2.Getting and Installing the IDE................................................................................................................................
PlatformsandRequirements....................................................................................................................11
What are the systemrequirements to run NetBeans?.....................................................................11
Getting and Installing a JDK....................................................................................................................12
The Java Development Kit.............................................................................................................12
Relationship of JDKto JRE...........................................................................................................13
ObtainingtheJDK..........................................................................................................................13
WhichIDEDistribution?.........................................................................................................................14
InstallingBinaryDistributions.................................................................................................................15
Building the IDEfromSource (Simple builds).......................................................................................16
What you'll need to build the IDE..................................................................................................16
Setting up and performing the build...............................................................................................17
Where dideverythinggo?..............................................................................................................18
Howdo I install a newly built version of NetBeans?.....................................................................18
RunningtheIDE......................................................................................................................................19
Minimalenvironment.....................................................................................................................19
HowtoLaunchNetBeans...............................................................................................................20
MultipleNetBeansusers.................................................................................................................21
Troubleshooting..............................................................................................................................22
Updatingthe IDEAutomatically.............................................................................................................25
TheUpdateCenter..........................................................................................................................25
Configuringthe Update Center......................................................................................................26
SetupWizard..................................................................................................................................27
You're nowrunningNetBeans.................................................................................................................27
3.Concepts andParadigms.........................................................................................................................................
NetBeans and the Java abstract model of computing..............................................................................29
Explorer....................................................................................................................................................30
Objects in the UI are represented by NetBeans nodes...................................................................30
Data objects,nodes,and the concept of actions and properties.....................................................31
Tabs in the Explorer and their purposes.........................................................................................38
NodeParadigms..............................................................................................................................44
Sometimes Explorer Gets Behind the Times..................................................................................47
Filesystems andthe CLASSPATH.................................................................................................48
CreatingPackages andClasses................................................................................................................52
CreatingPackages..........................................................................................................................52
CreatingClasses.............................................................................................................................52
Services....................................................................................................................................................55
Compilerservices...........................................................................................................................55
Executionservices..........................................................................................................................57
Debuggingservices........................................................................................................................57
Workspaces..............................................................................................................................................58
Editing............................................................................................................................................59
GUIEditing....................................................................................................................................59
Browsing.........................................................................................................................................59
Running..........................................................................................................................................59
Debugging......................................................................................................................................59
Persistenceacrosssessions.............................................................................................................59
Using multiple instances of Explorer in different workspaces.......................................................60
Using multiple instances of the Source Editor in different workspaces.........................................60
ProjectManagement................................................................................................................................60
Managingmultipleprojects............................................................................................................61
Managing project builds using Ant................................................................................................62
ObjectBrowser........................................................................................................................................63
Summary..................................................................................................................................................66
4.Working with the Source Editor..............................................................................................................................
Why learn a neweditor?..........................................................................................................................68
Openingthe Source Editor.......................................................................................................................68