NetBeans the Definitive User Guide phần 3 pot

64 400 0
NetBeans the Definitive User Guide phần 3 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Figure 6.8. Ant Help page Chapter 6. Compilation and Execution Services 106 You can add other elements to your build script from the Explorer. For each node, simply right-click and select Add from the context menu, and a list of valid tags should appear. Configuring the Ant Module Chapter 6. Compilation and Execution Services 107 The Ant module is configurable via property sheets in the Options window, with global settings accessible at Building->Ant Settings. Table 6.7 explains the properties for the Ant settings node. The module also creates two compilation services and an execution service—Ant Script Compilation, Indirect Ant Compilation, and Ant Script Execution. All compilation services implement Build, Clean, and Compile actions. The Ant compilation services have properties that can be configured to define the actions by executing targets in an Ant build script. For example, in the Options window see Building->Compiler Types->Ant Script Compilation. Notice the Build Target(s) property. Its default setting is clean, all. The targets are executed from left to right. If a source object uses Ant Script Compilation, then selecting the Build action from the object's context menu results in executing the clean target, followed by the all target in the Ant build script. See Table 6.8. The Indirect Ant Compilation compiler service is useful when you wish to call an Ant script while compiling another file. For example, it could be used to call the compile target in an Ant script when compiling a Java file. The Indirect Ant Compilation has the very same properties as the Ant Compiler with the addition of a property to specify the Ant script that defines the necessary targets to invoke. The Ant Executor found in the Options window at Debugging and Executing->Execution Types->Ant Script Execution defines targets to run when an Ant script is executed. The default target of the Ant script is executed if no target is de- fined here. Executing and Compiling With Ant Scripts By default, double-clicking an Ant build script should run the default target of that script. To run a specific target, you can right-click on the target's node and select Execute from the context menu. The output from the Ant script should appear in the Output tab. There is usually no need to define compilation for Ant script as you can simply execute the compile target declared in the script. However, if you set the Compiler property to the Ant compiler service then you could select Build or Compile from the Build menu and the respective targets will be executed. Why Use Ant? NetBeans already has compilation and execution services for all the object types that are supported for development. Why not just use the services that are provided? The short answer is, if you're happy without Ant, then don't use Ant. If you only build and execute single classes or small projects, then you probably don't need the flexibility that a build tool like Ant offers. But if you're involved in a large project, especially a project that has needs complex and unique actions to be performed many times during the course of development, then look to Ant for a powerful, easy to use, easy to configure tool. For example, this book was developed by several authors working remotely with Linux, Solaris and Windows comput- ers with shared access to a CVS repository for storing the drafts of chapters, source examples, and related material. The text was written in DocBook XML, which the authors and editors needed to validate and transform into HTML or PDF frequently. We created an Ant build script to perform the tasks. As the project progressed and the variety of tasks ex- panded, the build script grew to accomodate the needs. A simple CVS update automatically brought the enhanced build script into each author's environment. Without CVS and Ant, there would have been many more emails and phone calls asking how to do common tasks. With these tools, we have been able to keep our focus on the project goals. Chapter 6. Compilation and Execution Services 108 Chapter 7. Customizing the environment Table of Contents TheSetupWizard 109 GeneralNetBeansSettings 109 ModuleInstallation 112 UpdateCenter 112 TheToolsOptionsDialog 113 ConfiguringToolbars 114 ConfiguringMenus 116 ConfiguringEditors 117 ObjectTypeAssociations 117 EditorSettings 118 Commandlineoptions 126 Modules 128 InstallingModules 128 Enablingand DisablingModules 131 The NetBeans IDE offers a highly customizeable environment through wizards and serializable options. In this chapter you will learn how to customize your IDE environment. We will look at the following areas of customization: • The Setup Wizard • Toolbars • Menus • Editors • Modules The Setup Wizard The Setup Wizards allows you to quickly configure your IDE with some general settings required for everyday use. It is especially useful after an initial install of the IDE and is usually launched the first time you run NetBeans. To use the Setup Wizard any time after the initial launch select Tools->Setup Wizard from the menu bar. General NetBeans Settings Figure 7.1. The first pane of the Setup Wizard Chapter 7. Customizing the environment 109 The first pane of the Setup Wizard, shown in Figure 7.1, allows you to configure a proxy server, a window mode, and an HTML browser. The proxy server settings will be used for all the network and Internet needs of the IDE such as acquiring information for AutoUpdate from a remote Update Center. Your network administrator should be able to supply you with the server and port information of your proxy server. You will generally only need these settings if you are using the IDE behind a firewall. The window mode setting is used to determine the type of windowing interface NetBeans should use. There are gener- ally two types of interfaces: SDI, or Single Document Interface , and MDI, or Multiple Document Interface . Ignoring the word "Document", the main difference between the two interfaces is that in SDI mode, the IDE has no main win- dow, and each workspace has its own window, whereas in MDI mode, all the windows are managed by a single win- dow known as the Main Frame. Your choice of a window mode depends on your taste. They both have their advan- tages. In SDI mode the proliferation of windows for every document and workspace can be quite messy and annoying. The one benifit is that screen size per window can be maximized. In MDI mode there is one window and everything else is a child of that window. This makes window management very easy and agreeable with the programmer who al- ready has twelve other applications opened. The one caveat is that since MDI child windows share space with a parent window, they cannot be maximized to take advantage of the entire screen area. This can be especially annoying with an editor window displaying Java source. It's often convenient to minimize scrolling by showing as much text as possible. Microsoft Windows users may favor MDI mode because many Windows applications are MDI, including the DevStu- dio IDE. The differences of the two modes do not necessarily form a fork in the road, and neither of the two can be considered "the road less traveled". This is because the IDE lets you have the best of both worlds. In NetBeans, windows can be Chapter 7. Customizing the environment 110 docked into one another. Windows - also referred to as frames - can also be made into separate windows, regardless of the mode you chose. This is an advanced level of customization for the NetBeans IDE, but remains simple to accom- plish. For example, if you chose MDI mode from the Setup Wizard, but would like your editor to be displayed as a sep- arate window so that you could take advantage of more screen real estate, simply open a Java file; once the editor is opened select Window->Frame Resides ->As Separate Window from the menu bar. You should now see the editor in a separate window. Conversely, if you preferred to dock the editor window, back Window->Frame Resides->As Separate Window into the main frame, you would select Window->Frame Resides->In IDE Desktop. You can also chose to combine multiple windows via docking. For example, to add the filesystem explorer to the left side of an editor win- dow set the focus to the filesystem explorer, select Window+->Dock View Into->Source Editor-> Left . Figure 7.2 shows an editor window with a filesystem explorer docked on the left. Figure 7.2. An editor window with a filesystem explorer docked on the left The Web Browser selection is used for all the IDE's browsing needs such as Javadoc searching and JSP previewing. NetBeans comes with the ICE Browser embedded. This will usually be sufficient for all your needs and provides the tightest integration with the IDE, however it lacks the feature rich capabilities of some commercial browsers and in that case you may wish to select an external browser for default HTML browsing. If you choose an external browser, you will have to configure it later by selecting Tools->Options and then expand the web browsers node. Chapter 7. Customizing the environment 111 Module Installation Figure 7.3. The second pane of the Setup Wizard The second pane of the Setup Wizard (see Figure 7.3) allows you to configure which modules will be used by the IDE at runtime. The modules are shown in a table along with their enabled status (true\false), version number, and descrip- tion. Upon startup, the IDE will attempt to load each of the enabled modules. This process becomes slower with the number and complexity of the installed modules. Memory usage is also a consideration since all modules are issued their own classloader and run simultaneously in memory. For these reasons it may not be desirable to enable every pos- sible module. To disable a module, simply select "false" under the enabled column of that module's entry. Update Center Figure 7.4. The third pane of the Setup Wizard Chapter 7. Customizing the environment 112 The third pane of the Setup Wizard, shown in Figure 7.4, allows you to configure the Update Center connection for the IDE's Auto Update tool. The Auto Update tool connects to an Update Center to acquire modules and core components for installation. You can configure Auto Update to be automatically invoked on a recurring schedule, or you can manu- ally invoke it any time by selecting Tools->Update Center from the menu bar. The ToolsOptions Dialog Most NetBeans global or project level settings can be managed in the dialog invoked when you pull down Op- Tools->tions dialog. The components in this dialog represent the vast array of configurable settings in the IDE. The components are organized in the left pane of this dialog in a tree of nodes. Each node represents a specific configura- tion component while the folders represent categories by which the components are grouped by. When you select a component its properties will appear in the left pane in a table that is known as the property sheet. Property sheets consist of two cells. A property name cell and a property value cell. Typically the property value cell is to the right of the property name cell. You can change a component's settings by changing the data in its property value cell. Some property value cells allow you to enter plain text. Others, such as true/false properties will have a combo box of valid entries. Some value cells may require data that is not easily entered as text and will prompt you to use a special property editor. When the option to use a property editor is available, an ellipsis ( ) will appear in the rightmost end of the cell when you click on it. Clicking on this ellipsis will launch the property editor for that cell. Cell's that require Color values frequently provide property editors that allow you to choose colors from a pallete. Some settings you change you may wish to change globally. Other settings changes you may wish to apply only to the project you have open. Fortunately, NetBeans provides a means to specify the scope of a Tools Options setting. Chapter 7. Customizing the environment 113 In the figure below, we have circled a very small and important button! This button which bears two left angle brackets, or "arrows" (<<) as its emblem is called the Show Levels button. If you click it, a new panel "unfolds" into the options listing and you are offered three choices for the level of settings per- sistence which can be applied on a per-setting basis, as shown in the figure below. The three choices for settings persistence are as follows: • Default means "keep the default settings shipped with NetBeans and don't allow the user to apply any changes." Of course, if you change your mind, you can always remove this persistence and allow yourself to change the given setting. It's just a safety net. • Project means settings changes are applied to the current project only. Any other project will retain the settings it was left with until they are changed while that project is open. • User means all changes apply to all projects for that user. You can click the Show Levels button again to fold back this settings persistence panel so that it's out of your way. Configuring Toolbars Toolbars are similar to menus. They are panels consisting of image buttons that are mapped to a specific task. Each but- ton on a toolbar will usually have a brief text description, commonly called a tooltip, and there may also be a sequence of keys associated with a button known as its shortcut key. The IDE comes preconfigured with several toolbars that would most likely be sufficient for everyday development tasks. If the preconfigured toolbars do not meet your needs you can always modify them, or create entirely new ones, to perform your custom tasks. In the NetBeans IDE, each toolbar button is tied to an Action. You may think of an action as a task. For example Cut, Paste, and Copy are all actions. Most of the IDE's actions are pre-packaged, while others are provided by third party modules. To begin configuring toolbars select Tools->Options and then go to IDE Configuration->Look and Feel->Toolbars. Figure 7.5 shows the toolbar options. Chapter 7. Customizing the environment 114 Figure 7.5. Toolbar options These options allow you to edit and delete existing toolbars, or create your own. You can add new buttons to an exist- ing toolbar by copying and pasting actions. For example, to add a new button to the Build toolbar for compiling you would perform the following steps: 1. Expand the Build toolbarnode. 2. Expand Actions->Build, right click on the Compile node, and select Copy from the context menu. 3. Right-click on the Build toolbar node and select Paste->Copy from the context menu. You can also rearrange the ordering of toolbar buttons. To change the button order on a particular toolbar, right-click on its node and select "Change Order" from the context menu. You will be presented with the dialog box shown in Fig- ure 7.6. Use the "Move Up" and "Move Down" buttons to reorder each toolbar button's position. The toolbar button at the top of the list will appear first from the left on the toolbar. Figure 7.6. Changing the toolbar button order Chapter 7. Customizing the environment 115 [...]... 133 The How, When and Why of CVS in NetBeans 135 When to use CVS 135 Where to get a client 135 How does NetBeans interact with CVS? 135 Using Generic VCS 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... click on the button in the Font box and then click on the ellipsis that appears You should see a dialog box similar to the one shown in Figure 7.11 In the first list you select the Font name The second list allows you to configure the syle of the font For this example you would select Bold Italic from that list The third list allows you to select the font size Once you're done configuring the font... and color properties The Default element should be at the top of the list To change the background from the white default to a light yellow (the color of a sticky pad for instance), select the default syntax element and click on the button in the "Background Color" box and then click on the ellipsis that appears You should see a dialog box like the one shown in Figure 7.10 This is the color picker dialog... compiling the java file When you create a class from a Swing-based template, a form file is created, which is an XML file describing the composition of the visual component which the user is creating NetBeans Explorer displays the composition of the class in great detail, but doesn't specifically reveal that there are often three files behind the Explorer's rendition — the java file, the class file and the. .. installed, select the module's node in left list box then click on the arrow point129 Chapter 7 Customizing the environment ing to the right, or to the "Include To Install" list box You can select multiple modules by holding the Ctrl key while selecting and use the same arrow to chose those modules for installation The other arrow button pointing to the right allows you to select all the modules for... to the one shown in Figure 7.8 The predefined actions are shown in the List box and can be sorted by Name or Action (the internal action name) To add a new binding, first select an action from the list and then click on the Add button In the dialog box that appears, enter the key sequence that will cause the IDE to invoke the action For meta keys such as Control and Alt, you will need to hold on the. .. Customizing the environment Editing and Executing Macros After a macro is saved, it becomes one of the properties of the editor in which it was recorded The macro we wrote in the previous section will be available to any source file opened with the Java editor To modify the macro we can edit it through the macro property found in the property sheet for the particular editor Click on the Macros cell to edit the. .. you create to the repository at the time you create them Read on in this chapter to see how you add new files and packages to the repository How do I manipulate my NetBeans project directly with CVS outside of NetBeans? If you go to perform CVS operations on a source tree which is mounted in NetBeans, either at the command line or via some GUI tool other than NetBeans, it is best to close NetBeans while... cell to edit the property and click on the ellipsis You should see a dialog box similar to that shown in Figure 7. 13 Select the macro you wish to edit from the table and click on the Edit button to change the name or macro expansion Figure 7. 13 Editing macros 125 Chapter 7 Customizing the environment To execute the macro, type the keyboard shortcut anywhere in the editor For this example we used Ctrl+Alt+0,... from Use the first pallette to select the light shade of yellow As an alternative, instead of clicking on the ellipsis and using the color picker, you could type in the RGB color code in the edit box The RGB color code for this shade of yellow is 255,255,204 Figure 7.9 The fonts and colors editor 120 Chapter 7 Customizing the environment Figure 7.10 The color picker 121 Chapter 7 Customizing the environment . Tools->Options and then expand the web browsers node. Chapter 7. Customizing the environment 111 Module Installation Figure 7 .3. The second pane of the Setup Wizard The second pane of the Setup Wizard. install of the IDE and is usually launched the first time you run NetBeans. To use the Setup Wizard any time after the initial launch select Tools->Setup Wizard from the menu bar. General NetBeans. execute the compile target declared in the script. However, if you set the Compiler property to the Ant compiler service then you could select Build or Compile from the Build menu and the respective

Ngày đăng: 12/08/2014, 21:20

Từ khóa liên quan

Mục lục

  • NetBeans in a Nutshell

    • 6Compilation and Execution Services

      • Building With Ant

        • Configuring the Ant Module

        • Executing and Compiling With Ant Scripts

        • Why Use Ant?

        • 7Customizing the environment

          • The Setup Wizard

            • General NetBeans Settings

            • Module Installation

            • Update Center

            • Configuring Toolbars

            • Configuring Menus

            • Configuring Editors

              • Object Type Associations

              • Editor Settings

                • Global Key Bindings (Shortcut Keys)

                • Fonts and Colors

                • Macros

                  • Recording and Saving Macros

                  • Editing and Executing Macros

                  • Indentation Engines

                  • Command line options

                  • Modules

                    • Installing Modules

                      • Installing From The Web

                      • Installing Manually Downloaded NBM Files

                      • Enabling and Disabling Modules

                      • 8Using Source Control (CVS)

                        • What is CVS?

                        • The How, When and Why of CVS in NetBeans

                          • When to use CVS

Tài liệu cùng người dùng

Tài liệu liên quan