Chapter 8. Editors

JBDS is supplied with a huge range of various editors for different file types.

8.1. Editors Features

JBoss Developer Studio has powerful editor features that help you easily navigate within your application and make use of content and code assist no matter what project file (jsp, xhtml, xml, css, etc.) you are working on.

8.1.1. OpenOn

OpenOn let's you easily navigate through your project without using the Package Explorer view (project tree). With OpenOn, you can simply click on a reference to another file and that file will be opened.

OpenOn is available for the following files:

  • XML files

  • JSP/XHTML Pages

  • Java files

8.1.1.1. XML Files

Press and hold down the Ctrl key. As you move the mouse cursor over different file references in the file, they display an underline. When you have the mouse cursor over the name of the file you want to open, click and the file will open in its own editor. In this example the managed bean NameBean will open.

NameBean Managed Bean

Figure 8.1. NameBean Managed Bean


This is the result of using OpenOn

NameBean Java Class

Figure 8.2. NameBean Java Class


You can also try OpenOn with defined attributes.

OpenOn With Defined Attributes

Figure 8.3. OpenOn With Defined Attributes


You can also open any JSP pages.

JSP Page OpenOn

Figure 8.4. JSP Page OpenOn


8.1.1.2. JSP Pages

OpenOn is also very useful in JSP pages. It will allow you to quickly jump to the reference instead of having to hunt around in the project structure.

You can easily open the imported property files.

OpenOn With Imported Property Files

Figure 8.5. OpenOn With Imported Property Files


Use OpenOn to open a CSS file used with a JSP page:

OpenOn With CSS File

Figure 8.6. OpenOn With CSS File


Open managed beans:

OpenOn With Maneaged Beans

Figure 8.7. OpenOn With Maneaged Beans


For JSP files in a JSF project, you can also easily open the navigation rules by applying OpenOn to the JSF tag for the navigation outcome:

OpenOn With JSF Tag

Figure 8.8. OpenOn With JSF Tag


8.1.2. Code Assist and Dynamic Code Assist (based on project data)

8.1.2.1. Content Assist Features

8.1.2.1.1. Content Assist

Content assist is available when working with

  • Seam project files

  • JSF project files

  • Struts project files

  • JSP files

8.1.2.1.2. JSF Project Files

When working with JSF project in JBoss Developer Studio, you can use various Content Assist features while developing:

  • Content Assist for XML, JSP and JSF configuration files

  • Content Assist based on project data

  • Content Assist with graphical JSF editor

8.1.2.1.2.1. Content Assist for XML, JSP and JSF configuration files

At any point when working with any XML, JSP and JSF configuration files Content Assist is available to help you. Simply type Ctrl-Space to see what is available.

Content Assist for JSF configuration file:

Content Assist in JSF Configuration File

Figure 8.9. Content Assist in JSF Configuration File


Content Assist for JSF JSP file:

Content Assist in JSP File

Figure 8.10. Content Assist in JSP File


Content Assist for other JSF XML project files (web.xml shown):

Content Assist in web.xml File

Figure 8.11. Content Assist in web.xml File


8.1.2.1.2.2. Content Assist Based on Project Data

JBoss Developer Studio takes Content Assist to the next level. Studio will constantly scan your project and you will be able to insert code into the JSP page from your project that includes:

  • Values from Property files

  • "Managed beans" attributes and methods

  • Navigation Rule Outcomes

  • JSF variables (context, request etc...)

The first screenshot shows how to insert message from a Properties files. You simply put the cursor inside the "value" attribute and press Ctrl-Space . JBoss Developer Studio will scan your project and show a list of possible values to insert.

Inserting Message

Figure 8.12. Inserting Message


In the following screen shot we are inserting a "Managed bean" attribute value. Again, by simply clicking Ctrl-Space , JBoss Developer Studio will show a list of all possible values that you can insert:

Once you select a Managed bean, it will show you a list of all available attributes for the selected Managed bean (userBean).

Attributes List

Figure 8.13. Attributes List


Code Assist based on project data will also prompt you for navigation rules that exist in your JSF configuration file.

Code Assist

Figure 8.14. Code Assist


8.1.2.1.2.3. Content Assist within Tree JSF Editor

JBoss Developer Studio also provides Content Assist when working within the Tree JSF configuration editor. Just click Ctrl-Space .

Content Assist in Tree JSF Configuration Editor

Figure 8.15. Content Assist in Tree JSF Configuration Editor


If a field contains right class name and you click a link near the field you will come to the file with this class otherwise a new Java Class dialog will be shown:

New Java Class

Figure 8.16. New Java Class


If you entered an incorrect name in the field error markers will be shown for field labels and tree items:

Error Markers

Figure 8.17. Error Markers


  • To add a new property to a managed bean expand Managed Beans and select <name_of_bean>

  • Click Add button in the Properties panel

  • In the dialog Add Property define a new property. From here also you can generate setters and getters methods:

Create New Property

Figure 8.18. Create New Property


Here you can also add an additional navigation rule to the faces-config.xml file.

  • Select Navigation Rules

  • Click Add button

  • In the dialog Add Rule define a view and give a name to the rule. Click Finish:

Add New Navigation Rule

Figure 8.19. Add New Navigation Rule


8.1.2.1.3. Struts Project Files
8.1.2.1.3.1. Content Assist for Struts Configuration File
Struts Content Assist

Figure 8.20. Struts Content Assist


8.1.2.1.3.2. Content Assist for Struts JSP File
Struts JSP Content Assist

Figure 8.21. Struts JSP Content Assist


8.1.2.1.4. JSP Pages
8.1.2.1.4.1. Content Assist for JSF Tags

JBDS provides full code completion for JSF tags:

JSF Tags Content Assist

Figure 8.22. JSF Tags Content Assist


When the tag is selected the required attributes, if there any, are already inserted and the cursor is located to the first attribute. As this point you can ask for attribute proposals.

Attributes Content Assist

Figure 8.23. Attributes Content Assist


8.1.2.1.4.2. Content Assist for JSTL Tags
JSTL Tags Content Assist

Figure 8.24. JSTL Tags Content Assist


8.1.2.1.4.3. Content Assist for HTML Tags

Content assist for HTML tags has the same mechanism as for JSF tags:

HTML Tags Content Assist

Figure 8.25. HTML Tags Content Assist


You can use as well attributes proposals for HTML tags:

HTML Tags Content Assist

Figure 8.26. HTML Tags Content Assist


8.1.2.1.4.4. Content Assist for JavaScript Tags
JavaScript Tags Content Assist

Figure 8.27. JavaScript Tags Content Assist


8.1.2.1.4.5. Content Assist within JSF Configuration Editor
Content Assist in JSF Configuration Editor

Figure 8.28. Content Assist in JSF Configuration Editor


8.1.2.1.5. Content Assist for Rich Faces components

JBDS indeed provides code completion for Rich Faces framework components. All you have to do is to install Rich Faces libraries into your project. See here how to install.

Content Assist for Rich Faces Components

Figure 8.29. Content Assist for Rich Faces Components


  • To insert a Rich Faces component on a page expand JBoss Rich Faces group on the palette

  • Click on some component

  • Put the needed attributes in the Insert Tag dialog and click Finish button

    Insert Tag

    Figure 8.30. Insert Tag


The Rich Faces tag will be inserted on your page displayed in source and visual modes:

Rich Faces Component

Figure 8.31. Rich Faces Component


8.1.2.2. Adding dynamic code assist to custom components that were added to JBoss Tools Palette

Here is what you need to do to add project based code assist to a custom component added in JBoss Developer Studio:

  1. Create a new xml file in <JBDS_home>studio/eclipse/plugins/org.jboss.tools.common.kb_***/schemas/tld/ . For example call it JeniaFaces.xml. The file should be written according to <JBDS_home>/studio/eclipse/plugins/org.jboss.tools.common.kb/kb.jar/org/jboss/tools/common/kb/kb-schema_1.0.dtd

Here is how you set what is available for code assist:

  • Adds code assist for JSF pre-defined objects, such as value= "#{param}" :


<AttributeType ...>
       <proposal type="jsfVariables"/>
</AttributeType>
  • Adds bundle resource (property file) code assist:


<AttributeType ...>
       <proposal type="bundleProperty"/>
</AttributeType>
  • Adds managed bean property code assist:


<AttributeType ...>
       <proposal type="beanProperty"/>
</AttributeType>
  • Adds managed bean property but with a specified type:


<AttributeType ...>
       <proposal type="beanProperty">
          <param name="type" value="java.lang.Boolean"/>
       </proposal>
</AttributeType>
  • Adds managed bean method with a signature:


<AttributeType ...>
       <proposal type="beanMethodBySignature">
          <param name="paramType" value="javax.faces.context.FacesContext"/>
          <param name="paramType" value="javax.faces.component.UIComponent"/>
          <param name="paramType" value="java.lang.Object"/>
          <param name="returnType" value="void"/>
       </proposal>
</AttributeType>
  1. Add information on your xml file in <JBDS_home>/studio/eclipse/plugins/org.jboss.common.kb_***/plugin.xml



         <tld
            jsf="true"
            name="Jenia Faces"
            schema-location="schemas/tld/myJSF.xml"
            uri="http://www.jenia.org/jsf/dataTools"/>
    
  1. Restart Eclipse. You should now have code assist for the component.

8.1.3. Full Control over Source Files - Synchronized Source and Visual Editing

JBoss Developer Studio offers the flexibility to edit any files in either source or extra visual modes at the same time.

The project is yours and so is the source. JBoss Developer Studio provides you many different graphical editors to speed your application development. At the same time, you always have full control over all project source files. Any changes you make in the source view, will immediately appear in the graphical view.

The JSF configuration file editor has three views: Diagram, Tree and Source. All views are synchronized, you can edit the file in any view.

Diagram View

Figure 8.32. Diagram View


Tree View

Figure 8.33. Tree View


Source View

Figure 8.34. Source View


The same applies to all other JBoss Developer Studio editors.

Web XML editor is shown. Web XML editor has a graphical view (Tree) and source (Source).

Tree View

Figure 8.35. Tree View


Source View

Figure 8.36. Source View


JBoss Developer Studio TLD file editor shown in Tree view. At any point you can edit the source by going switching to Source view.

Tree Editor

Figure 8.37. Tree Editor


Source Editor

Figure 8.38. Source Editor


The Struts configuration file editor has three views: Diagram, Tree and Source. All views are synchronized, you can edit the file in any view.

Struts Diagram View

Figure 8.39. Struts Diagram View


Source view. Any changes here will immediately appear in all other views.

Struts Source View

Figure 8.40. Struts Source View


8.2. Visual Page Editor

JBoss Developer Studio comes with a powerful and customizable Visual Page Editor (VPE). You can use the Visual Page Editor to develop an application using any technology: JSF, Struts, JSP, HTML and others.

Current VPE version has four tabs: Visual/Source, Visual, Source and Preview.

Split screen design with instant synchronization between source and visual views:

Visual/Source View

Figure 8.41. Visual/Source View


You can also switch to pure Visual design:

Visual View

Figure 8.42. Visual View


Or work just in Source view. Note that selection bar is now available not only in Visual mode but also in Source one:

Source View

Figure 8.43. Source View


No matter what view you select, you get full integration with Properties and Outline views:

Properties And Outline Views

Figure 8.44. Properties And Outline Views


Preview mode is read-only, it only shows how the page will look like in a browser.

Preview Mode

Figure 8.45. Preview Mode


Use the graphical toolbar to add inline styling to any tag.

Graphical Toolbar

Figure 8.46. Graphical Toolbar


With just a click or drag-and-drop insert any tags from the palette on to the page you are editing.

Inserting Tags From Palette

Figure 8.47. Inserting Tags From Palette


8.2.1.1. Advanced Settings

There are three buttons on the Visual Page Editor left side:

Visual Page Editor Buttons

Figure 8.48. Visual Page Editor Buttons


  • Preferences

Provides quick access to Visual Page Editor preferences.

Visual Page Editor Preferences Window

Figure 8.49. Visual Page Editor Preferences Window


  • Refresh

Refresh displaying information with this button.

  • Page Design Options

This button leads to page design options.

Page Design Options

Figure 8.50. Page Design Options


This dialog let's you set resources which are usually only resolved in runtime. To set a stylesheet, click Add (for CSS File Path section) and add your stylesheet. It works when CSS is defined on your page in the following way:

Code:


<link rel="stylesheet" type="text/css"  href="#{facesContext.externalContext.requestContextPath}/style.css"/>

This will work fine in runtime, but the Visual Page Editor doesn't know what requestContextPath in design time is.

The next section (URI), let's you add URI taglibs if you are using includes so that the editor knows where to find the tag libraries.

The first two sections let you define actual runtime folders. Here is an example.

Let's say you have the following project structure:


WebContent/
  pages/
    img/
       a.gif
    header.jsp
  main.jsp

header.jsp content:


My Header
<img src="img/a.gif"/>

main.jsp:


<jsp:include page="pages/header.jsp" />

When you open main.jsp in Visual Page Editor, it will not be able to resolve the image from the header, however, it will work fine in runtime. To fix this in design time, click the Page Design Options button and set Actual Run-Time Relative Folder to <project>WebContent > pages and you will see the image appear.

  • Hide Selection bar

By clicking on the component in Visual view or selecting a code snippet in Source mode you can see the tags tree. If you want to hide the selection bar, use the "Hide Selection Bar" button on the lower right side.

Selection Bar

Figure 8.51. Selection Bar


8.2.2. Setup notes for Linux

8.2.2.1. How to Start the Visual Page Editor under Linux

Linux users may need to do the following to get the Visual Editor to work correctly on their machines.

The Visual Page Editor requires the library libstdc++.so.5. This library is contained in the compat-libstdc++-33.i386 package.

  • To install this package on Fedora Core or Red Hat Enterprise Linux run the following command:

    yum install compat-libstdc++-33.i386
  • On any other rpm based distributions download libstdc++.so.5 and run the following command:

    rpm -Uvh compat-libstdc++-33.i386
  • On Debian based distributives run the following command:

    apt-get install compat-libstdc++-33.i386

In case you have the library installed and you still have issue with starting the visual page editor then close all browser views/editors and leave one visual page editor open and restart eclipse. This should force a load of the right XULRunner viewer.

8.2.3. JSP syntax validation

When working in JBoss Tools JSP editor you are constantly provided with feedback and contextual error checking as you type.

8.2.4. JSP Page Preview

JBoss Developer Studio comes with JSP design-time preview features. When designing JSP pages you can easily preview how they will look during runtime. You can even attach your stylesheet to the preview.

JSP preview is available for:

  • Struts Pages

  • JSF Pages

The preview features are available with Visual Page Editor.

8.3. More Editors

Besides Visual Page Editor JBDS provides editors for editing project files of any types: properties, TLD, web.xml, tiles, and so on.

8.3.1. Graphical Properties Editor

The Properties editor allows you to work in two different modes and also supports unicode characters.

To create a new properties file, in the Package Explorer view, select New > Properties File from the right-click context menu on the folder where you want to create the file.

Selecting Properties File

Figure 8.52. Selecting Properties File


You can edit the file using a table-oriented "Properties" viewer:

"Properties" Viewer

Figure 8.53. "Properties" Viewer


You can also use a Source viewer for editing the file:

Source Viewer

Figure 8.54. Source Viewer


8.3.2. Graphical TLD Editor

The TLD editor comes with same features you will find in all other JBoss Developer Studio editors:

  • Graphical and source edit modes

  • Validation and error checking

8.3.2.1. Tree view

Tree View

Figure 8.55. Tree View


8.3.2.2. Source view

You can easily switch from Tree to Source by selecting the Source tab at the bottom of the editor.

Source View

Figure 8.56. Source View


You can easily add a new tag:

Adding a New Tag

Figure 8.57. Adding a New Tag


You can also easily add a new attribute to an existing tag:

Adding a New Attribute

Figure 8.58. Adding a New Attribute


Content assist is available when editing the file using the Source viewer:

Content Assist

Figure 8.59. Content Assist


In the Source viewer, if at any point a tag is incorrect or incomplete, an error will be indicated next to the line and also in the Problems view below.

Error Reporting

Figure 8.60. Error Reporting


8.3.3. Graphical Web Application File (web.xml) Editor

The Web Application File editor comes with the same features you will find in all other JBoss Developer Studio editors:

  • Graphical and source edit modes

  • Validation and error checking

8.3.3.1. Tree View

Tree View

Figure 8.61. Tree View


You can add any new elements right in the Tree viewer:

Adding New Elements

Figure 8.62. Adding New Elements


8.3.3.2. Source View

Switch to the Source viewer to edit the web.xml file by hand at any time:

Source View

Figure 8.63. Source View


8.3.3.3. Content Assist

Content assist is available in the Source viewer. Simply click CTRL-Space anywhere in the file.

Content Assist

Figure 8.64. Content Assist


8.3.3.4. Errors Checking and Validation

If errors occur anywhere in the file, small red dots will appear next to the lines where the errors occurred. Also, note that the file is marked by a small x in the Package Explorer view.

Errors Reporting

Figure 8.65. Errors Reporting


8.3.4. Graphical Tiles Files Editor

8.3.4.1. Graphical Editor For Tiles Files

The Tiles configuration file editor has three main viewers (modes): Tree (shown), Diagram and Source. The modes can be selected via the tabs at the bottom of the editor. Any changes made in one mode are immediately visible when you switch to any other mode.

When working in Source view, you always have all following features available:

  • Content Assist

  • Open On Selection

8.3.4.2. Create New Tiles File

To create a new Tiles files, right click any folder and select New > Tiles Files :

Creating New Tiles File

Figure 8.66. Creating New Tiles File


8.3.4.3. Tree View

In the Tree mode, the different elements of the Tiles file are organized into functional categories on the left-hand side and a form for editing the properties of currently selected items on the right-hand side.

Tree View

Figure 8.67. Tree View


To edit the file, simply right click any node and select among the available actions:

Editing in Tiles Editor

Figure 8.68. Editing in Tiles Editor


8.3.4.4. Diagram View

The Diagram mode is shown below:

Diagram View

Figure 8.69. Diagram View


To create new definition, simply right click anywhere in the diagram:

Creating New Definition

Figure 8.70. Creating New Definition


You can also use the Diagram toolbar to make editing easier:

Diagram Toolbar

Figure 8.71. Diagram Toolbar


8.3.4.5. Source

The Tiles editor also comes with a Source view that gives you full control over the source. Any changes here will immediately appear in when you switch to any of the other viewers.

Source View

Figure 8.72. Source View


Content assist is available in the Source mode.

Content Assist

Figure 8.73. Content Assist


Any errors are immediately reported as shown below:

Error Reporting

Figure 8.74. Error Reporting


You can also use the Outline view together with the editor's Source mode. Selecting any node in the Outline view will jump to that place in the source:

Outline View

Figure 8.75. Outline View


8.3.5. Graphical Editor for Struts Validation Files

JBoss Developer Studio comes with a visual validation editor. To create a new validation file, right click any folder and select File > Validation File from the context menu.

Creating Validation File

Figure 8.76. Creating Validation File


The validation editor works through a number of viewers.

The Formsets viewer shows forms and their elements for which to define validation rules:

Formsets Viewer

Figure 8.77. Formsets Viewer


The Constants viewer lets you set constant values for your validation rules:

Constants viewer

Figure 8.78. Constants viewer


The validation file also can be viewed in a Tree viewer:

Tree Viewer

Figure 8.79. Tree Viewer


At any point you have full control over the source by switching to the Source viewer. Any editing in this viewer will immediately be available in the other viewers of this editor.

Source Viewer

Figure 8.80. Source Viewer


You can also open your own custom or Struts-standard validation-rules.xml file.

The Validators viewer shows the validation rules for a selected validator. You can of course add your own rules.

Validation Rules

Figure 8.81. Validation Rules


Here are the validation rules shown in the Source viewer.

Validation Rules in Source Viewer

Figure 8.82. Validation Rules in Source Viewer


8.3.6. Spring IDE

JBoss Developer Studio bundles a Spring Framework editor from Spring IDE for Eclipse. Visit this site for the latest versions and documentation.

You can add a Spring Project Nature to an existing project by right-clicking on the project and selecting Adding Spring Project Nature from the context menu:

Adding Spring Project Nature

Figure 8.83. Adding Spring Project Nature


If you need to remove it you should select Remove Spring Project Nature from the context menu of your project.

Once the Nature is added, a Spring project will be decorated with a small "S" in the Package Explorer view.

Project with Spring Nature

Figure 8.84. Project with Spring Nature


To add a Spring Configuration File with bean definitions open Properties dialog from the context menu of your project. Then select Spring > Beans Support on the left side.

Spring Beans

Figure 8.85. Spring Beans


Click on Add button to choose the corresponding Spring Configuration File.

Adding Configuration Files

Figure 8.86. Adding Configuration Files


The added file will also be marked by an "S" in the Package Explorer view.

To activate the Spring Explorer view, select Window > Show View... > Other and then Spring > Spring Explorer .

Selecting Spring Beans View

Figure 8.87. Selecting Spring Beans View


This view shows a read-only outline view of the Spring Bean Configuration File.

8.3.7. CSS Editor

The CSS editor comes with the same features you will find in all other JBoss Developer Studio editors.

  • Content assist

  • Validation and error checking

With the CSS (Cascading Style Sheet) editor, you can take advantage of code prompting:

CSS Editor

Figure 8.88. CSS Editor


And you can also use the Properties view next to the editor to edit existing stylesheet declaration properties:

Properties View

Figure 8.89. Properties View


8.3.8. JavaScript Editor

The JavaScript editor includes a Preview viewer and a Source viewer. In the Source viewer, you can use code assist:

JavaScript Editor

Figure 8.90. JavaScript Editor


You can also use the Source viewer with the Outline view to navigate around the file:

Source Viewer

Figure 8.91. Source Viewer


8.3.9. XSD Editor

JBoss Developer Studio comes with an XSD Editor for XML Schema files. This editor comes from the Web Tools Project (WTP) (see WTP Getting Started).

To create a new XSD file, right-click a folder in the Package Explorer view, select New > Other... from the context menu and then select XML > XML Schema in the dialog box.

Creating New XSD file

Figure 8.92. Creating New XSD file


The XSD Editor includes two viewers for working on the file, a Design viewer and a Source viewer:

Source Viewer

Figure 8.93. Source Viewer


In the Design viewer, you can drill down on an element by double-clicking on it:

Design Viewer

Figure 8.94. Design Viewer


Various edit options are available when you right-click an element in the diagram:

Edit Options

Figure 8.95. Edit Options


You can also use the Properties view to edit a selected element:

Properties View

Figure 8.96. Properties View


You can also use a Source viewer for the file. In this viewer, along with direct editing of the source code, you can also edit the file by using the Properties view on the right:

Source Viewer

Figure 8.97. Source Viewer


8.3.10. Support for XML Schema

JBoss Developer Studio fully supports XML files based on schemas as well as DTDs:

XML File

Figure 8.98. XML File