Anyone can Reconstruction
Abstract: Eclipse provides a powerful set of automatic reconfiguration (refactoring) functions, which interludes in other functions, so you can rename the Java element, mobile and packet type, create a specific type interface will be nested category into the top category, as well as from the old methods of code fragments removed Analysis of the new method. You are familiar with the Eclipse reconstruction tools, the hands of a good way to increase productivity. In this paper, Overview of the Eclipse Reconstruction, and through an example of the use of these methods and reasons.
Why remodeling?
Reconstruction is in the process function does not change under the premise of changing its structure. Reconstruction is a powerful technology, but the need to implement more carefullyæ‰è¡Œ. The main risk is that we may inadvertently introduce some mistakes, especially in the case of manual reconfiguration. This triggered a dangerous technology on the Reconstruction of the general criticism: When the code will not collapse when Why should we change it?
You need to code may be the reasons for the Reconstruction of the following: legends of the reason is that: the need for a succession of old products and the development of age-old code, or suddenly encounter these codes. The initial development team has been dead. We must increase the creation of a new version of the new software, but they have been unable to understand the code. New development team to work day and night, and then deciphering the code mapping code, a lot of planning and design, people will be the code division to pieces. After many tribulations, all these things are in accordance with the requirements of the new version of the reparations. This is the heroic story of the reconstruction, almost no one in the experience of those living on after such stories.
There is also a realistic situation is a new item added to the demand, the need for design changes. As is because, in the initial planning process for carelessness, or due to the iterative development process (such as Agile development, or test-driven development) in the development process for intentional introduction into the needs of both the substantive and not distinction. This remodeling of a much smaller, generally involving its content through the introduction of an abstract class or interface type changes to the inheritance relationship, and a partition and re-organization, and so on.
Reconstruction of the last reason is that when there can be automatically reconfigurable tool can be used for a pre-generated code shortcuts - like if you are unable to determine how to spell a word, we can use a spelling This tool check the importation of words. For example, you can use this method of generating prosaic Reconstruction getter and setter methods, once familiar with this kind of tool, it can save you a lot of time.
Eclipse tool for the Reconstruction of a hero has no intention of Reconstruction - this scale for almost no tools - but whether or not use Agile development, the Eclipse tool for the average programmer to amend the work in the code impossible to measure the value of . After all, as long as the operation of any complexity can be automatic, and can be a less depressed. Eclipse to achieve as long as you know what kind of remodeling tools, and their understanding of the application, your productivity will be greatly improved.
Of the code to reduce the risk of damage, there are two important ways. The first method is the code for a complete and thorough unit testing: both before and after reconstruction must pass this test. The second method is to use automated tools to carry out reconstruction, for instance, the reconstruction of Eclipse.
Will be thoroughly tested and integrated automation reconstruction will be more effective, such remodeling it from a mysterious art has become a useful tool for the day-to-day. In order to add new functions or improve the maintainability of the code, we can not affect the original code in the function on the basis of quickly and safely change its structure. This capability will design and develop your code greatly influence the way, even if you do not combine their official Approach to have no relationship.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Eclipse of the type of reconstruction
Reconstruction of Eclipse tools can be divided into three categories (Below is the order of these tools Refactoring menu in the order):
- Re-naming of the code as well as the code changes the physical structure, including property, variables, as well as interface to rename category, there are categories such as mobile and packet.
- Changes in the code of a logical structure, including nested anonymous for the type of change will be nested class into the top category, according to specific categories to create interfaces, as well as from a class or method will be moved to the sub-categories or attributes Father category.
- Change a category within the code, including local variables into a category of properties, a method selected will be part of the code into an independent, as well as properties generate getter and setter methods.
Several tools can not be fully reconstructed into three types, in particular Change Method Signature, but in this paper or this tool will be included in the third category. Apart from such exceptions, this paper the following sections are in accordance with the above order to discuss reconstruction Eclipse tools.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Physical restructuring and renaming
Obviously, even if you did not have any particular tool can also rename the file system is a mobile document or documents, but if the operation is targeting Java source code files, you will need to edit many of the documents, including the import or update package statement. A similar, with a text editor to search and replace functions can be easily addressed to the category, methods and re-named variables, but this time we must be very careful, because different classes may have names similar to the method or variable ; If the project from start to finish inspection of all the documents to ensure that every thing's logo and revising the correctness, it can be really boring.
Rename and the Eclipse tools can be very clever Move in the entire project completed by the middle of such changes, without the need for user intervention. This is because the Eclipse can understand the semantic code, which can be identified on a particular method, variable or class name are cited. Simplify this task to ensure that, like the names of variables and clear instructions to its use.
We often can be found code name is not appropriate or easily misunderstood, because the code with the original design features vary. For example, in a document to find a specific word in the procedure may be extended to the Web page URL access through InputStream operation. If the input flow initially called the file, then it should amend its name to reflect its new, more general characteristics, say sourceStream. Developers often fail to successfully amend these names, because the process is very confusing and dull. This, of course, the next one will be forced to operate on these categories of developers confused.
Elements of Java to a re-naming, should simply from the Package Explorer view click on the elements, or from Java source code for the selected elements in the document, and then select menu items Refactor> Rename. In the dialog box, enter a new name, and then choose whether or not to Eclipse also need to change the name of the application. The actual show the exact contents of your choice and the types of elements. For example, if you select the attributes of getter and setter methods, then it can be updated at the same time the names of these methods, to reflect the new attributes. Figure 1 shows a simple example.
Like all the Eclipse reconstruction operation, when you specify to the implementation of all the necessary information after the remodeling, you can click the Preview button, and a dialog box in contrast to what Eclipse intend to change, you can reject or confirm respectively every document affected by the changes in each one. If you have the correct execution of Eclipse have confidence in the ability to change it, you can only press the OK button. Obviously, if you are not sure what has been done remodeling in the end things, you would like to preview what will be, but the Rename and Move such a simple remodeling, usually do not have the necessary preview.
Move operation and Rename very similar: you choose a Java elements (usually a), designated for a new position, and whether the need to update the definition used. You can then choose Preview inspection changes, or select OK immediate implementation of reconstruction, as shown in Figure 2.
In some platforms (especially Windows), you can also Package Explorer view through simple drag-and-drop method of the package or from one folder to another folder or packet. All references will be automatically updated.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Redefinition of the relationship between the
Eclipse of the Reconstruction of a large number of tools that enable you to automatically change the relationship between the categories. Reconstruction of these tools do not provide the Eclipse other tools so common, but of great value because they can perform very complex task. It can be said that the time when they are useful, will be very useful.
Anonymous and upgrading of nested class
Convert Anonymous Class (conversion anonymous) and Convert Nested Type (conversion nested) two more similar Reconstruction Method, which will be a category of its current move to contain the scope of this category.
Anonymous is a grammatical category Sketch marker, which enables you to the need to achieve a certain abstract class or interface to create a local instance of the class, without the need to provide explicit type name. For example, in the creation of the user interface sniffers, they often use anonymous category. 1 in the list, in other assumptions Bag is the definition of a local interface, which states the two approaches, get () and set ().
List 1. Bag category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class BagExample (void processMessage (String msg) (new Bag Bag bag = () (Object o; public Object get () (return o;) public void set (Object o) (this.o = o;)); bag . set (msg); MessagePipe pipe = new MessagePipe (); pipe.send (bag);))
</ Td> </ tr> </ table>
When the anonymous class become great, the code difficult to read the time, you should consider this type become anonymous in the strict sense; to maintain encapsulation (in other words, it is hidden, making do not have to know It external category do not know it), you should make it a nested class, rather than the top category. You can be anonymous in this type of internal click, and then select Refactor> Convert Anonymous Class to Nested on it. When a confirmation dialog box, enter a name for this category, such as BagImpl, then select OK or Preview. In this way, such as the code becomes a list of 2 shows the situation.
List 2. After remodeling category Bag
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class BagExample (private final class BagImpl implements Bag (Object o; public Object get () (return o;) public void set (Object o) (this.o = o;)) void processMessage (String msg) (Bag bag = new BagImpl (); bag.set (msg); MessagePipe pipe = new MessagePipe (); pipe.send (bag);))
</ Td> </ tr> </ table>
When you want to use a certain other category nested class, Convert Nested Type to Top Level very useful. For example, you can use one type of object, like the above category as BagImpl. If you decide later in a number of categories should be shared between the data, then reconstruction operations can be nested from the creation of a new category of documents. You can source selected categories highlighted in the document name (or in the Outline view click on the category name), then select Refactor> Convert Nested Type to Top Level, thereby bringing about Reconstruction.
Reconstruction of this case require you to provide a name loaded. Reconstruction tools will be provided, the proposed names, such as example, you can accept this name. The name on the meaning clear in a moment. Click OK, it will become the outer BagExample category list 3 shows the victims.
List 3. After Reconstruction of the Bag
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class BagExample (void processMessage (String msg) (Bag bag = new BagImpl (this); bag.set (msg); MessagePipe pipe = new MessagePipe (); pipe.send (bag);))
</ Td> </ tr> </ table>
Please note that when a category is nested class when it can be to visit their members of the outer class. In order to retain this function, remodeling process will be put into a category BagExample examples that nested on the previous category. This is required before you enter the name of the instance variables. At the same time created this instance variables used to set the constructor function. Reconstruction of the process to create a new category 4 BagImpl as shown in the list.
List 4. BagImpl category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Final class BagImpl implements Bag (private final BagExample example; / ** * * @ paramBagExample / BagImpl (BagExample example) = (this.example example; / / TODO Auto-generated constructor stub) Object o; public Object get () (return o;) public void set (Object o) (this.o = o;))
</ Td> </ tr> </ table>
If you have the same situation with this example, do not retain BagExample visit, you can safely delete the instance variables and the constructor function will be BagExample category code without changing the default constructor function parameters.
Inheritance, in the category of Mobile
There are also two remodeling tools, and Push Down Pull Up, respectively, to achieve the type of the methods or attributes from one category to move to the father of her son type or category. Suppose you have an abstract entitled Vehicle category, as defined list of 5 below.
5 list. Abstract Vehicle category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public abstract class Vehicle (protected int passengers; protected String motor; public int getPassengers () (return passengers;) public void setPassengers (int i) (passengers = i;) public String getMotor () (return motor;) public void setMotor ( String string) (motor = string;))
</ Td> </ tr> </ table>
You have a Vehicle sub-categories, called Automobile category, as shown in the list 6.
List 6. Category Automobile
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Automobile extends Vehicle (private String make; private String model; public String getMake () (return make;) public String getModel () (return model;) public void setMake (String string) (make = string;) public void setModel (String string) (model = string;))
</ Td> </ tr> </ table>
Please note that the attribute is a Vehicle motor. If you know that you will always deal only with the car, then just do so; but if you will allow a rowing or anything like that, then you need to motor attributes from the decentralization of Automobile Vehicle category. To that end, you can select the motor Outline view, and then select Refactor> Push Down.
Eclipse is very smart, it knows that you can not always simply a mobile attribute itself, it is also provided Add Required button, but in Eclipse 2.1, this function did not always work correctly. You need to test to see all this depends on whether the method attribute blame to the next level. In this case, there are two such methods, that is associated with the motor getter and setter methods, as shown in Figure 3.
In accordance with the OK button, motor and property getMotor () and setMotor () method will be moved to the Automobile category. 7 shows the list in this category Automobile Reconstruction after the case.
List 7. After remodeling Automobile category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Automobile extends Vehicle (private String make; private String model; protected String motor; public String getMake () (return make;) public String getModel () (return model;) public void setMake (String string) (make = string; ) public void setModel (String string) (model = string;) public String getMotor () (return motor;) public void setMotor (String string) (motor = string;))
</ Td> </ tr> </ table>
Pull Up Reconstruction and Push Down almost the same, of course, Pull Up is a class of members from his father moved in the category, rather than sub-category. If you later change your mind, or decided to motor back to the Vehicle category, then you would probably use this reconstruction. You also need to be reminded, we must determine whether you choose all the necessary members.
Automobile class members with motor, which means that if you create another sub-category, for example, Bus, you also need to motor (and related methods) into the Bus category. There is a method can be said that such relations, namely, the creation of a named Motorized interface, Automobile and Bus to realize this interface, but do not realize RowBoat.
Motorized interface to create the simplest way is to use the Extract Interface Automobile Reconstruction. For this reason, you can choose Automobile Outline view, and then from the menu select Refactor> Extract Interface. You can pop up the dialog box, select the interface you want included in the method shown in Figure 4.
Click OK, to create a good interface, such as the list of 8 below.
8 list. Motorized Interface
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public interface Motorized (public abstract String getMotor (); public abstract void setMotor (String string);)
</ Td> </ tr> </ table>
At the same time, the Automobile category statement also look into the following:
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Automobile extends Vehicle implements Motorized
</ Td> </ tr> </ table>
Father of use
Reconstruction of this type of tool is the last one User Supertyp Where Possible. Imagine a used car Xizhang management applications. It has the use of Automobile type of object. If you want to deal with all types of transport, then you can use this reconstruction will be all right Automobile citations have become the Vehicle references (see Figure 5). If you use instanceof operator in the code implementing any type of inspection, you will need to decide in these areas covered by the father of the original type or category, and then select the first option, "Use the selected supertype in 'instanceof' expressions" .
Father of the use of such demand in the Java language often occurs, especially in the use of a Factory Method mode of circumstances. This pattern typical of the ways is to create an abstract class, which create a static method (), this method is to achieve a return of the abstract category of a specific target. If the need to create specific object depends on the type of realization of the details, and calls for achieving the details of the case are not interested, you can use this model.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Change of the internal code
Reconstruction is the largest category of internal code to achieve the reorganization of the reconstruction. Reconstruction in all the methods, only the introduction of these methods allows you to remove or intermediate variables, according to the original method of code to create new methods, as well as attributes to create getter and setter methods.
Extraction and embedded
Some Extract reconstruction method is the beginning of the word: Extract Method, Extract Local Variable and Extract Constants. The first Extract Method means you may have guessed, and it's based on your chosen method of the creation of a new code. We list in that category of eight main () method as an example. It first made a command line option values, if any - the beginning of the D options, it will be in their name - in the form of the value stored in a Properties object.
8 list. Main ()
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Import java.util.Properties; import java.util.StringTokenizer; public class StartApp (public static void main (String [] args) (Properties props = new Properties (); for (int i = 0; i <args.length; i + +) (if (args [i]. startsWith ( "-D")) (String s = args [i]. substring (2); StringTokenizer st = new StringTokenizer (s, "="); if (st.countTokens () == 2) (props.setProperty (st.nextToken (), st.nextToken ());))) / / ...)) continue
</ Td> </ tr> </ table>
Will be part of the code from one of the ways out and put in another way, there are two reasons. The first reason is that this approach is too long, and completed more than two entirely different logic operations. (We do not know that the above main () method to deal with the things, but from the view of the evidence available now, this is not an extract from which the grounds.) Another reason is that there is a clear logic code, This code reuse can be other ways. For example, at certain times, you find yourself in many different ways in the preparation of the same repeat a few lines of code. It may be a need for reconstruction, but unless we really need this part of reusable code, or you may not execute very Reconstruction.
Suppose you also need a place in the analysis of other - of right, and put it in the Properties object, then you can and will contain the following statement StringTokenizer if Statements This code extracted. To that end, you can highlight selected this code, and then from the menu select Refactor> Extract Method. You need input method name, here addProperty input, and verify the parameters of the two methods, Properties prop and Strings. 9 shows a list extracted from Eclipse addProp () method after the class situation.
List 9. Extracted from the addProp ()
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Import java.util.Properties; import java.util.StringTokenizer; public class Extract (public static void main (String [] args) (Properties props = new Properties (); for (int i = 0; i <args.length; i + +) (if (args [i]. startsWith ( "-D")) (String s = args [i]. substring (2); addProp (props, s);))) private static void addProp (Properties props, String s) (StringTokenizer st = new StringTokenizer (s, "="); if (st.countTokens () == 2) (props.setProperty (st.nextToken (), st.nextToken ());)))
</ Td> </ tr> </ table>
Extract Local Variable reconstruction be used directly remove a section of the expression, then this expression first assignment to a local variables. Then use that expression in the original use of this variable. For example, in the above method, you can highlight the selected st.nextToken () call first, and then select Refactor> Extract Local Variable. You will be prompted for a variable name, the importation of key here. Please note that there is one will be selected expression for all local variables are replaced by the application of the new options. This option is usually applied, but here nextToken () method does not apply, because this method (apparently) in each of the call at all times to return to a different value. Confirm this option not selected. See Figure 6.
Next, in the second call st.nextToken () local repeated remodeling, this time the call is a new local variables value. This list shows the 10 twice after Reconstruction code situation.
List 10. Reconstruction after the code
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Private static void addProp (Properties props, String s) (StringTokenizer st = new StringTokenizer (s, "="); if (st.countTokens () == 2) (String key = st.nextToken (); String value = st . nextToken (); props.setProperty (key, value);))
</ Td> </ tr> </ table>
In this way there are several benefits of the introduction of variables. First, by providing a meaningful expression to the names of the implementation of the code can be made more clear mandate. Second, the code debugging much easier because we can easily check expression of the return of value. Finally, a variable can be used in the replacement of the same expression of a number of examples of circumstances, the efficiency will be greatly enhanced.
Extract Constant and Extract Local Variable similar, but you must choose static constant expression, it will be remodeling tools into the final static constants. This will be hard-coded in the number of strings and removed from the code when the very useful. For example, in the above code, we use "- D" command-line options to define who - value right. First "- D" to highlight selected, select Refactor> Extract Constant, then enter the name of DEFINE as constants. Reconstruction after the code as shown in the list 11:
List 11. Reconstruction after the code
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Extract (private static final String DEFINE = "D-"; public static void main (String [] args) (Properties props = new Properties (); for (int i = 0; i <args.length; i + +) ( if (args [i]. startsWith (DEFINE)) (String s = args [i]. substring (2); addProp (props, s);))) / / ...
</ Td> </ tr> </ table>
For each of the Extract … kind of reconstruction, there are corresponding Inline … Reconstruction, the Executive contrary operation. For example, if you highlight selected variables in the code above s, select Refactor> Inline …, and then click OK, Eclipse will be calling addProp () when used directly args [i]. Substring (2) of this expression, as follows:
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
If (args [i]. StartsWith (DEFINE)) (addProp (props, args [i]. Substring (2));)
</ Td> </ tr> </ table>
Such than more efficient use of temporary variables, the code has become even more briefly, as the code is easy to read or vague, depending on your viewpoint on the. But generally speaking, no such embedded Reconstruction worth recommending place.
You can replace the variable expression embedded with the same method, a method chosen to highlight, or static final constants, and then from the menu select Refactor> Inline …, Eclipse will replace method code Method Invocation, or the constant use of the replacement value of the constant use.
Packaging attributes
Usually, we believe that the internal structure of objects will be exposed is a bad practice. This is exactly Vehicle categories and sub-categories have protected or private property, and with public setter and getter methods to attribute the reasons for the visit. These methods can be used in two different ways automatically generated.
The first generation of these methods way is to use the Source> Generate Getter and Setter menu. This will display a dialog box, which contains all outstanding exist getter and setter methods. But because this approach does not use new methods to update these attributes are cited, as there is no reconstruction; when necessary, you must use their own completion of the work of updating. This approach can save a lot of time, but preferably at the beginning of the creation, or to add a new category to attribute the use of the time, because they did not exist when the property used, so there is no need to amend other code .
The second generation getter and setter methods is the way a selected attribute, and then from the menu select Refactor> Encapsulate Field. This way one can only attribute to a generation getter and setter methods, but with the Source> Generate Getter and Setter On the contrary, will be used to change the attributes of the new method of paired call.
For example, we can first create a new version of Jane Automobile category, as shown in the list 12.
List 12. Simple Automobile category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Automobile extends Vehicle (public String make; public String model;)
</ Td> </ tr> </ table>
Next, create a category of the Automobile examples of the category, and direct access to make attributes, such as shown in the list 13.
List 13. Example of the Automobile
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class AutomobileTest (public void race () (Automobilecar1 = new Automobile (); car1.make = "Austin Healy"; car1.model = "Sprite" / / ...))
</ Td> </ tr> </ table>
Packaging now make attributes. To highlight selected attribute name, and then select Refactor> Encapsulate Field. In the pop-up dialog box input getter and setter methods name - If you expected, the default method is the name getMake () and setMake (). You can also choose with this property in the same category method is direct access to the attributes, or as other types of methods that use these visits. (There are some people who are inclined to use these two methods of a certain kind, but by chance in such circumstances you choose a way which did not, because of Automobile not make attributes are cited.)
Click OK, make the Automobile category would become the property of private property, and also has a getMake () and setMake () method.
>
List 14. After remodeling Automobile category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class Automobile extends Vehicle (private String make; public String model; public void setMake (String make) = (this.make make;) public String getMake () (return make;))
</ Td> </ tr> </ table>
AutomobileTest category must also be updated to use the new access methods, such as shown in the list of 15.
> List of 15. AutomobileTest category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class AutomobileTest (public void race () (Automobilecar1 = new Automobile (); car1.setMake ( "Austin Healy"); car1.model = "Sprite" / / ...))
</ Td> </ tr> </ table>
Change the method signature
This paper presents the final reconstruction is the most difficult to use: Change Method Signature (change method signature). This method features obvious - change method parameters, and return values of that type. And a call for such a change this method of code or other means would have any effect on, it would not be so obvious. There is no such a Rubik's cube. If the code change in the method of remodeling triggered internal problems - undefined variable, or type does not match - Reconstruction of operation will mark these issues. You can choose to accept reconstruction, later corrected these problems, or cancel reconstruction. If this reconstruction in other ways in the lead, directly overlook these problems, you must personally in the reconstruction after the revision.
To clarify this point, consider the list of 16 listed in the classes and methods.
List 16. MethodSigExample category
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public class MethodSigExample (public int test (String s, int i) (int x = i + s.length (); return x;))
</ Td> </ tr> </ table>
Above this type of test () method is another type of method invocation, as shown in the list 17.
List 17. CallTest method
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public void callTest () (MethodSigExample eg = new MethodSigExample (); int r = eg.test ( "hello", 10);)
</ Td> </ tr> </ table>
In the first category to highlight selected test, and then select Refactor> Change Method Signature. You will see the dialog box shown in Figure 8.
The first option is to change the method of visibility. In this case, the change will be the private or protected so that the second category of callTest () method will not be able to visit this method has. (If these two different categories in the package, will visit the methods set default values will lead to such a problem.) Eclipse during Reconstruction when these issues will not be marked, you have only to choose the appropriate value .
Below is an option to change the return value type. If the return value to float, which will not be marked as wrong, because test () method returns the sentence will be automatically converted into int float. Even so, in the second category of callTest () method can also cause problems because not float into int. You need to test () return value to int, or will callTest () in the r to float.
If the first parameter of type int from a String, then have to consider the same issue. In the process of reconstruction in these issues will be identified because they will be in the reconstruction method of internal source of the problem: no way int length (). If, however, by turning it into a StringBuffer, the problem is not marked, because StringBuffer indeed has a length method (). Of course, this will be callTest () method has caused problems because it calls test () when a String or to transfer any more.
Mentioned earlier, triggered a problem in the reconstruction of the circumstances, regardless of whether the problems were identified, one by one you can to correct these problems to continue. Another way is to amend these first mistake. If you plan to remove the parameters i no longer needed, it may be the first to carry out reconstruction methods used to delete it. This deletion parameters of the process even more smoothly.
Finally a need to explain what is Default Value Options. This option only applies to the value added method signature parameters of the situation. If, for example, we have added a parameter of type String, called n parameters, the default values for the world, then callTest () method call in the test () code to look into the following:
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public void callTest () (MethodSigExample eg = new MethodSigExample (); int r = eg.test ( "hello", 10, "world");)
</ Td> </ tr> </ table>
In this the Change Method Signature remodeling seemingly terrible discussion, which we do not hide the problem, but it has not been mentioned, this reconstruction is a very powerful tool, it can save a lot of time, usually you must carefully plan will be able to successfully use it.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Concluding remarks
Eclipse provides the tools to reconstruction simple, familiar with these tools will help you improve efficiency. Agile development methods using iterative process of increase, it was necessary to rely on technology to change the remodeling and expansion of the design process. But even if you did not use a formal request remodeling, the Eclipse tools or remodeling in general can modify the code to provide time-saving method. If you spend some time with these tools, then they can be used when there is the situation in which you will be able to realize that the time spent is worth it.
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
About the author <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="3"> </ td> </ tr> <tr align = " left "valign =" top "> <td>
</ Td> <td> </ td> <td width="100%">
David Gallardo on Studio B is a writer, he is an independent software consultant and writer, international expertise for software, Java Web applications and database development. He has been a professional software engineer with 15 years, he has many operating systems, programming languages and network protocols experience. He recently e-commerce companies in a BtoB TradeAccess, Inc database and international leadership development. Prior to this, he was Lotus Development Corporation's International Product Development Group senior engineer, is responsible for Lotus products (including Domino) to provide Unicode and international language support for cross-platform development. David is Eclipse In Action: A Guide for Java Developers (2003) co-author of the book. David@gallardo.org through contact with David.
</ Td> </ tr> </ table>
<table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
↑ Back
I choose as the main Eclipse IDE
Abstract: Eclipse as my main IDE
During this period of time has been using Eclipse to develop some JAVA program, a very good feeling. Eclipse is not my choice JAVA development of the first IDE, I still feel that the original use of JBuilder much better than Eclipse. Until now, or indeed JBuilder Eclipse convenient than many. JBuilder to install as long as all the components are in place, even Struts, ProGuard these third-party tools are commonly used with the. The Eclipse is needed to find their own plug-ins, and then configure up. But right now I still feel more like the reason for this is that Eclipse Eclipse plug-ins is very convenient development, installation ease.
Eclipse itself is activated more than JBuilder minor, and the disk space occupied by relatively small. Eclipse compared to other direct JDK development, there is a good start JVM is significantly faster, probably because it started when Eclipse has launched a JVM on the reasons for it.
Eclipse is free and cross-platform, which enables us to Linux, Unix under development can be carried out smoothly. And also under Linux is no good Java development IDE, or even good C / C + + IDE, Eclipse and I think it is a good choice. CDT through plug-ins, can be competent Eclipse C / C + + IDE work. Moreover, the major Refactor Eclipse also to the characteristics of the C / C + + IDE in. Windows in the Microsoft Visual C + + are not supported by Refactor can easily achieve in the Eclipse CDT.
Many Linux, Unix has always been expert in the use of any IDE disdain for development, that too IDE development of a fool, only a fool to use the IDE. In fact, this is a wrong idea, IDE as an auxiliary tool, from program development to the present, has been developed for so many years, it is surely a matter of the role of. IDE far faster rate of development in a procedural language itself pace of development. Direct use of the compiler program gcc.exe, cl.exe, can be completed the work can be completed using the same IDE, and IDE to complete the work and direct the use of compiler and editor it is very difficult. Especially in the Debug debugging time, IDE to provide the same ease of development efficiency. Also Refactor this point, if it is only a short procedure, it can also manually, but if is a big project, the IDE Refactor not, I am afraid more than 100 times greater workload. Now the actual development process, Refactor is extremely important.
Many Linux, Unix experts said fools of the IDE too, would restrict the freedom of procedures. And Eclipse as a free plug-in the IDE, I would think of the rich development of the freedom of programmers. For joked example, the development of programmers would like to listen to MP3 time, we can own the mp3 development of a plug-in to Eclipse, Eclipse so there will be a mp3 player function. When programmers want to develop written procedures on other people's machines debugging, we can own the development of a plug-in debugging based on P2P. In short, Eclipse is a plug-spelled from the IDE, it can be said that is a workplace. If you like, you can increase your Eclipse features and unlimited fun. This is exactly what I now like Eclipse for it.
Finally, the final one of the advantages of Eclipse is free.
↑ Back
New eclipse (roller2.1.1) project and the release of success
Abstract: New eclipse (roller2.1.1) project and the release of success
Need the original jar anti-compiler package, and rollerbeans.jar rollerweb.jar
Question 1: Under the lack of src, package org.roller.presentation.forms;
Question 2: src hbm the lack of relevant documents, from the jar, copied to the pojo src, do not forget that a separate document HitCountData.hbm.xml hbm business under the package.
Question 3: version.properties placed in the root classes, version.properties rollerbeans.jar from under the root directory
Question 4: roller.tld on the WEB-INF root directory can be. This document can be rollerweb.jar \ META-INF \ tlds under.
Of course the premise is able to provide direct roller2.1.1 deployment of the app so that it can go up. Then, it is - in the source code works in the eclipse of the above problems will be encountered. If there are any problems, please refer to roller.log generally in the application server logs directory. This can eclipse to change roller source, and then changes, release…………
GOOD LUCK.
Msn: yun15291li@hotmail.com
↑ Back
Agile Java Development - with Spring, Hibernate and Eclipse today to participate in the corporate training
Abstract: Agile Java Development - with Spring, Hibernate and Eclipse today to participate in the corporate training
First, the training is not very interested in this, then in at noon today found in the company outlook side, there is a publicity posters, some of my colleagues around watching. - On this momentum, I should also participate in ah. Fortunately, although the registration deadline passed, but the academy mm or very willing to allow me to participate in the.
Upon entering the Chamber, first of all, see a gray hair of the elderly in India. This is the speech of the heroine, Anil Hemrajani, is the theme of this lecture the author of the same name books. On the specific circumstances See http://www.amazon.com/gp/product/0672328968/103-6877596-0981453?v=glance&n=283155, he also brought three of the departments presented to the academy, borrowed time to look at.
Speech or good results, at least let me just start this java people can understand. His English is very standard than most Indians to the English standards of many. Always maintain the entire speech in the general description of a number of technical, and did not get in depth. Of course, only two hours of little depth. Specific speech too late entries recorded Fortunately, the Internet found Anil Hemrajani speech in Hong Kong doing the same entry in the paste out here.
After listening to the speech after I feel that the time is the spring and hibernate also learn alright. Eclipse is indeed very useful, but I also used to write the PHP eclipse, it was only know eclipse IBM spent $ 40 million and then bought revenue. From that point on, IBM has done a really great thing. Anil Hemrajani In his speech, mentioned in the course of the class and Adobe Flex Ajax, which is a message bar, or the understanding of the need to spend a little time to understand what the.
Last more than two hours, the end of the lecture. The time is very accurate, and in the end is a veteran. I also gave applause to the speakers.
↑ Back
Eclipse 3.2 M6 released
Abstract: Eclipse 3.2 M6 released
March 31, Eclipse 3.2 release of the M6, which is the final version 3.2 release version of a milestone. Immediately we will be able to see a 3.2. Really very cool.
3.2M6 compared to 3.2 M5 is very, very great progress, regardless of speed or performance are the core part of the Vice-raising ..
New features can view the display of official documents: P
Eclipse 3.2 M6 - New and Noteworthy
The following briefly switched from Alex Blewitt's blog:
- Callisto update site built-in (at least, for the platform; not for the SDK though)
- API-aware refactorings (leave deprecated stubs in place for renamed methods)
- Improvements to CleanUp wizard
- Category support (Java feature 6)
- Java code formatter can run in standalone mode
- Plugins can now contribute to other plugin's extension points
- SWT tree and table now supports custom cell renders to allow multi-line text and images (yes, we know that Swing had that for ages …
- Cheat sheets can have commands and links added
- HTML help documents can be migrated to XHTML
- RSS feed in the Welcome page for network-connected hosts
- High contrast mode for people with visual impairments (or impossibly high resolutions :-)
- Proxy support for CVS connections
- And of course, you can now open manifest files from the project, even if it's not in the new - and-noteworthy ;-)
We can experience faster to download the new version of 1,10:)
↑ Back
PHP IDE, Visual Studio or Eclipse?
Abstract: PHP IDE, Visual Studio or Eclipse?
Each programmer has its own technical route preferences. Some like MS platform is the most commonly used VC, VB, Delphi,. NET, SQL Server and others like * nix, like open-source, cross-platform like can be written procedures, used the C / C + +, Java, PHP, MysQL, Oracle, and so on. There are a lot of the technical line is more than two cross.
As different preferences, everyone in the choice of development tools, vary widely. There are many excellent IDE platform also supports multiple languages, such as Visual Studio, Eclipse. This raises a question: If two IDE at the same time support the development of a language, you choose which IDE? You like each language or were using different development tools?
Technology preferences will choose a great impact, but I personally Henlan accordance with the habits of the best IDE unified, eliminating re-learn the new IDE time. Procedures such as I usually run under Linux, I familiar with the Java and PHP, then I will certainly choose a cross-platform, and support the development of Java and PHP IDE ( "Eclipse Subversion + + + PHPEclipse TortoiseSVN"). Although the interpretation of PHP implementation, and did not require compiler. But if we edit, debug, and integrate release of the development and a great advantage. This is, the majority of PHP editor is not enough, and often need to do a lot of set-up to his call external procedures more trouble. Such as EditPlus, my favorite one editor.
Today saw a news VS.php PHP tools to Visual Studio 2005 to increase revenue, Oh, PHP development has one more choice. Not suitable for me, and I can be a few hundred years VS. However, there may be many people will actually be put.
Who is interested to try it:)
↑ Back
Eclipse Forms: fat client doing pretty UI (translation, Part III)
Abstract: Eclipse Forms: fat client doing pretty UI (translation, Part III)
Senior components (Complex controls)
Eclipse Forms provides four senior components, so you can build beautiful UI
Expandable composite
There is a page in the general function is to let you have the ability to take part of the content of the sites with a button
ExpandableComposite ec = toolkit.createExpandableComposite \ N
This composite accept some style parameters to control the performance of its acts \ N
ExpandableComposite have a responsibility to tackle the button component and title \ N our view now looks like this: \ n? \ N Expandable composite used an internal layout, the layout \ N
Paragraphs (Section) This composite accept some style parameters to control the performance of its acts ExpandableComposite have a responsibility to tackle the button component and title Our view now looks like this: Expandable composite used an internal layout, the layout Paragraphs (Section) \ N The following code example and almost expandable composite code:
Section section \ u003d toolkit.createSection (form.getBody () \ n Section.DESCRIPTION | Section \ N Photo hyperlinks (Image hyperlink) \ N
Below is a picture with hyperlinks examples: \ N \ n Photo 14: Eclipse welcome in the form pages \ nForm nForm text components to label (labels), hyperlinks, pictures and TableWrapLayout Attention to the picture, hyperlinks and text is how mixed. Here use a separate labels and hyperlinks component is a very difficult \ N
In all modes, form text components can identify a string or input streams (input stream). \ N
"1]); / / The following code example and almost expandable composite code:
Section section = toolkit.createSection (form.getBody (), Section.DESCRIPTION | Section This time, we spent TWISTIE style, add a description and requested title bar. This view should look like this: Photo hyperlinks (Image hyperlink) Below is a picture with hyperlinks examples: Photo 14: Eclipse welcome page form Form text components of the label (labels), hyperlinks, pictures and TableWrapLayout Attention to the picture, hyperlinks and text is how mixed. Here use a separate labels and hyperlinks component is a very difficult In all modes, form text components can identify a string or input streams (input stream). D ([ "mb", "Recognition ordinary text (labels mode) \ N URLs will be automatically converted into hyperlinks URL is converted to links. Parcel of this link is part of the text of the \ N ", 0]); D ([" ce "]); D ([" ms "," 220a "]); / / identification ordinary text (labels mode) URLs will be automatically converted into hyperlinks URL is converted to links. Parcel of this link is part of the text of the ↑ Back Abstract: In the prior Eclipse IDE, Java development tools geared primarily to Swing (Java graphical tools), then it is difficult for them with a Microsoft Visual Studio compete Below I will be related to the development of some important classification, as compared to the current two most representative of the development tools, to look at each one of them who is classified to some more powerful. 1, the core development environment Comparison: syntax highlighting, error prevention, code refactoring, code Assistance (code assist), compile, run, debug Winner: Eclipse Eclipse is a powerful monster. It is incredibly smart code Assistance (code assist), the rich code refactoring functions, error prevention and the "code amendment" proposal, but also has a very powerful debugger, it can be said in every function are defeated Visual Studio. Both Visual Studio 2005 or Visual Studio Express, known as a very good Integrated Development Environment (IDE), in support of all the features of Eclipse, it also supports many. However, in Visual Studio in the absence of a function, like the Eclipse as strong and professional. Therefore, in this category, I put positioning Eclipse winner. 2, the comprehensive development Comparison Project: database, system integration, web deployment Winners: Visual Studio I know, I feel like in this category deceptive because Vistual Studio support and only Windows-based products used in conjunction with, but Visual Studio with these products with the so perfect, I must admit that from Microsoft's Visual Studio occupy an advantage. Created in Visual Studio SQL Server support BizTalk, or C # ASP.NET solution so easy, integrated so well, the differences between the products as completely as transparent. Eclipse and his business partners also have a very good model of development in order to achieve mutual support, although they can also used in conjunction with a relatively good, but not so seamless in Visual Studio. 3, source control and configuration management (SCM) As a class above, Visual Studio in this regard to make it easier to achieve. He can run on Windows and the majority of the tools used in conjunction with other vendors with their good support. However, with almost all the Eclipse platform to support all the vendors supporting the use of SCM, and with the very good. The most important is that it can be and the two may be the most important open-source SCM related products fully integrated, Subversion and CVS, the two tools have been thousands of open source projects and commercial use, I have no reason to not to declare: Winner: Eclipse 4, and software quality testing Test to guarantee the quality of software development has a very important role in the Eclipse built-in support for the JUnit unit testing, system testing and the development of the first code error prevention is an essential function of the Eclipse platform. It built on the JUnit (including JUnit 4 or TestNG plugin) support, making test very easy and very natural. Eclipse is also very good at detecting potential errors (such as self assigning class properties in setter methods), code format and repair recommendations. However, in the Web services testing, more than Eclipse Visual Studio, Visual Studio Web services test is very easy and simple, this is the tool of my favourite one of the functions of, even in its free version of the Express version also supports the feature. Winner: Eclipse 5, build and deploy This is a more difficult judgement. . NET as a framework to deploy more easily than J2EE, but also compared to the work of our difficulties, it is difficult to compare the process of the deployment of these two tools. Because Eclipse built-in tools to create ANT support, and based on the "hot" category loaded with the deployment of the support, so the deployment can be very good J2EE applications. However, the deployment of Visual Studio capacity you need not worry about the same fundamental, it can completely control target deployment server, may be IIS, SQL Server or BizTalk. Winner: Drawn The winner: Eclipse Eclipse so strong that the industry in any other IDE tools can pose threats, including Visual Studio. Experienced programmers in the use of the Eclipse, will be a feeling: IDE can be interoperable with its intention. In all respects, this is a developer for the development of tools developers. Visual Studio is also very good, it is a very great and efficient tool, it is a. NET development of the perfect tool. Obviously, Microsoft has made the greatest efforts for the past. NET developers to provide a very efficient and very intuitive development tools. Even, the free version of the Visual Studio Express version is also very impressive. However, due to have been such a huge developer community feedback to the development of open-source information and the selfless contributions of Eclipse obviously has taken the first step, IDE actually redefined the concept of the traditional IDE into a stronger, more intelligent realm to enable it to develop itself into a process of thinking continuation and expansion. So I chose Eclipse as a final victor. Abstract: Eclipse Download Eclipse Download Lomboz J2EE plug-in, the development of JSP, EJB 1.MyEclipse J2EE plug-in development and support SERVLET / JSP / EJB / database manipulation 2.Properties Editor java edit the properties file, and can automatically archiving format for Unicode 3.Colorer Take for hundreds of types of documents by syntax coloring 4.XMLBuddy edit the xml file 5.Code Folding adding a number of folding function code (more than eclipse onboard) 6.Easy Explorer visit selected from the eclipse in the file, directory of the folder 7.Fat Jar plug-in bundles can be easily packaged the completion of various tasks can include external packages such as 8.RegEx Test test is the regular expression 9.JasperAssistant statements Plugin (strong, and money) 10.Jigloo GUI Builder JAVA the GUI editing plug-ins 11.Profiler performance tracking, measurement tools, can be tracked, monitored, BS procedures 12.AdvanQas provide if / else statements, and other conditions of the quick tips and help (automatically changes the structure, etc.) 13.Log4E Log4j plug-ins, and Log4j provide various related tasks, such as method of adding a logger, etc. 14.VSSPlugin VSS Plugin 15.Implementors Jump to provide a method of achieving class, rather than to the function (saleable!) 16.Call Hierarchy that a method call level (which methods were transferred, the transfer of the method) 17.EclipseTidy inspection and formatted HTML / XML documents 18.Checkclipse check code style, the wording of the norms 19.Hibernate Synchronizer Hibernate plug-ins, such as automatic mapping 20.VeloEclipse Velocity Plugin 21.EditorList convenient list of all open Editor 22.MemoryManager memory occupancy rate surveillance 23.swt-designer java plug-in GUI 24.TomcatPlugin support Tomcat Plugin 25.XML Viewer 26.quantum database plug-ins 27.Dbedit database plug-ins 28.clay.core database visualization plug-ins 29.hiberclipse hibernate Plugin 30.struts-console Struts plug-ins 31.easystruts Struts plug-ins 32.veloedit Velocity Plugin Plugin code finishing 33.jalopy 34.JDepend Packet Analysis 35.Spring IDE Spring Plugin 36.doclipse can generate code tips xdoclet ↑ Back Abstract: No matter what language you use GUI application development, interactive user input collection mechanisms are essential. Eclipse belonging to the development of the project JFace provided in the toolbox of a group of powerful user interface components, developers can easily separate application in the use of these components. JFace toolbox in one of the more interesting components of the guide support. JFace guides and the standard toolbox window small parts (Standard Widget Toolkit, SWT), the other user interface components combine to provide a flexible mechanism for the systematic collection of data and implementation of user input validation. The past, the development of highly interactive with Java client-side applications procedures so that these applications look like this-like applications and can use this machine as operating procedures, such as the idea of the Holy Grail (Holy Grail) as difficult elusive. With the emergence of Eclipse projects, developers began to create authentic simulation of the application of Java applications. Although the traditional sense that Eclipse project is the open-source Java integrated development environment (IDE), but the scope of the project should be much broader. In fact, the eclipse.org Home, Eclipse has been described as "… a universal tool platform - is an open extensible IDE, it can do anything, and not for a particular area." Eclipse platform in the development period, the project produced two user interface toolbox: SWT and JFace. SWT provides a platform-independent API, the operating system API and the window of the plane is tightly integrated environment. The toolkit enables developers do not have to face in the use of Java abstract window toolkit (Abstract Window Toolkit, AWT), or a basic Java (Java Foundation Classes, JFC) in many aspects of the design and realization of the need for balance. JFace Toolkit is platform-independent API, and SWT can be interoperable. The library provides a Group upon group of aides and practical procedure, which allows developers SWT in the user interface to simplify many common tasks. Despite the development of the sample code in this article use the Eclipse, but the article itself demonstrates how independent applications in the context of the use of JFace wizard. Eclipse related projects for more information or background knowledge, please refer to the back of this reference. Address Book application
See how to use the code and JFace toolbox before realizing details, let us look in this example the use and application structure. This paper contains is a simple application of memory in the address book, it allows users to add personal address book contacts. The application contains a component from the two JFace guides, each page contains a description of the domain-specific contacts. Users can use maps shown in Table 1 to navigate contact lists. As shown in Figure 2, New Contact wizard for users to create new contacts. Like Eclipse projects, the SWT library and JFace beginning designed to support a variety of operating systems and the environment. For the demonstration of these cross-platform capabilities, which has included examples of independent application package, in order to Microsoft Windows and Linux. <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Environmental requirements
You can find a reference and download this paper used in the code. To test Address Book applications, your environment must meet the following minimum requirements: Although Ant has been very carefully constructed script that can be cross-platform use, but still only in Microsoft Windows XP and Red Hat Linux 8 operating system testing and validation personal address book applications. Let us from the installation and set-up code samples let us begin. <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Construction and installation address book applications
Construction to install and address book application, please complete the following steps: If you meet the needs of the environment and configuration is correct, then you should see the contents of this similar to the following: List 1. Building Address Book application </ Td> </ tr> </ table> <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Wizard use JFace
Since we have introduced the SWT and JFace the basis of knowledge and address book application's behavior, let us examine how to use JFace wizard. Since the purpose of this paper is to introduce JFace wizard, and therefore did not provide information about how to create an independent application program more background information. In the table on how to use outside of Eclipse SWT / JFace components more information and background knowledge, please refer to Adrian Van Emmenis by three part series of articles (see reference to access link). In the address book application, processing List 2 of the code for a user to open a guide for the targets and methods. List 2. NewContactAction category </ Td> </ tr> </ table>
Let us step by step on this code: <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Wizard achieve JFace
In the address book applications to create List 3. ContactWizard category method of addPages </ Td> </ tr> </ table>
List 4. ContactWizard category method of performFinish </ Td> </ tr> </ table>
5 shows a list of 5 list. ContactWizard category </ Td> </ tr> </ table> <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Implementation JFace WizardPage
List 6. BasicContactPage category method of createControl </ Td> </ tr> </ table>
List 7. Deal with the importation of such verification methods dialogChanged and updateStatus </ Td> </ tr> </ table> <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Address Book applications running
To test Address Book application and operating procedures, please complete the following steps: <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> Concluding remarks
Through the introduction of SWT / JFace user interface toolkit, Eclipse project eventually to provide Java developers to create a highly interactive client-application method. JFace wizard such as the use of components to study how to use the code to create at least collect user input flexible mechanisms is really excited. Examples of address book application provides a framework for building and packing, you can use the framework to create their own independent SWT / JFace applications. <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle"> About the author <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="3"> </ td> </ tr> <tr align = " left "valign =" top "> <td>
</ Td> <td> </ td> <td width="100%">
Jeff Gunther Intalgent Technologies is the general manager and co-founder, the company is emerging software products and solutions provider, and its products and solutions using Java 2 Enterprise Edition and Lotus Notes / Domino platform. Jeff from the early "Mosaic" (the first Internet Web browser) to the era before the appearance of the Internet industry to join. He has all aspects of the software life cycle of professional experience, including Java/J2EE, DHTML, XML / XSLT, database design and the special handheld device software development professional experience. Jeff.gunther @ intalgent.com through contact with him. </ Td> </ tr> </ table> <table Border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> ↑ Back
Figure 11: a contraction of expandable composite examples \ n
When you click on the heading "+", stretching out and display composite Client: \ n \ n Figure 12: expandable composite was extending the state \ n
Eclipse Forms custom components is one of the most versatile Section
1. Segregation (Separator) - one can create under the heading of the separator
2. Description (Description) - under the heading optional description.
3. Column heading (Title bar) - under the heading in a column heading (Note separator and the title, "1]); //(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT
Figure 11: a contraction of expandable composite examples when you click on the title of "+", stretching out and display composite Client: Figure 12: expandable composite was extending the state
Eclipse Forms custom components is one of the most versatile Section
1. Segregation (Separator) - one can create under the heading of the separator
2. Description (Description) - under the heading optional description.
3. Column heading (Title bar) - under the heading in a column heading (Note separator and heading D ([ "mb", "
This time, we spent TWISTIE style, add a description and requested title bar. This view should look like this: \ n? \ N
Figure 13: a title bar and can be described in the section stretching \ n
Hyperlinks picture is super-sub-category links, links in the text above it adds a picture. This unusual combination of a very meaningful
? \ N \ n Photo 15: A mixture of text, pictures and hyperlinks example of the complexity Eclipse form \ n
Recognition of the ordinary parcels text recognition ordinary text, but if the beginning of the text to http:// hyperlinks to show identification as HTML text of the same language
Figure 13: title bar and a description of the section may be extended
Hyperlinks picture is super-sub-category links, links in the text above it adds a picture. This unusual combination of a very meaningful
Photo 15: A mixture of text, pictures and hyperlinks example of the complexity Eclipse form
Recognition of the ordinary parcels text recognition ordinary text, but if the beginning of the text to http:// hyperlinks to show identification as HTML text of the same language
FormText formText \ u003d toolkit.createFormText (form.getBody (), true);
? Td \ u003d new TableWrapData (TableWrapData.FILL);
? Td.colspan \ u003d 2;
? FormText.setLayoutData (td);
? String text \ u003d "Here is some plain text for the text to render."; \ N
? FormText.setText (text, false, false);
The second parameter set to false, which means we do not have analytical html tags
Now we will add a text of the hyperlink, and the first three parameters set true:
FormText formText \ u003d toolkit.createFormText (form.getBody (), true);
? Td \ u003d new TableWrapData (TableWrapData.FILL);
? Td.colspan \ u003d 2;
? FormText. SetLayoutData (td); \ n
? String text \ u003d "Here is some plain text for the text to render" +
? This text is at http://www.eclipse.org web site. ";
? FormText. SetText (text, false, true); \ n
If we look at our view, is this: \ n? \ N
Figure 16: Form text components will be automatically converted into URL hyperlink \ n
Because the form text hyperlinks to identify components, it used to receive before us sniffers. Created when the toolkit, the toolkit will form text hyperlinks group settings as a new hyperlink settings.
FormText formText = toolkit.createFormText (form.getBody (), true);
Td = new TableWrapData (TableWrapData.FILL);
Td.colspan = 2;
FormText.setLayoutData (td);
String text = "Here is some plain text for the text to render.";
FormText.setText (text, false, false);
The second parameter set to false, which means we do not have analytical html tags
Now we will add a text of the hyperlink, and the first three parameters set true:
FormText formText = toolkit.createFormText (form.getBody (), true);
Td = new TableWrapData (TableWrapData.FILL);
Td.colspan = 2;
FormText. SetLayoutData (td);
String text = "Here is some plain text for the text to render" +
This text is at http://www.eclipse.org web site. ";
FormText. SetText (text, false, true);
If we look at our view, is this:
Figure 16: Form text URL components will be automatically converted into hyperlinks
Because the form text hyperlinks to identify components, it used to receive before us sniffers. Created when the toolkit, the toolkit will form text hyperlinks group settings as a new hyperlink settings. Tools King war:. NET PK J2EE
Editor: Eclipse and Visual Studio 2005
Appeared before the Eclipse IDE, Java development tools geared primarily to Swing (Java graphical tools), then it is difficult for them with a Microsoft Visual Studio compete, but the emergence of Eclipse IDE radically changed the situation.
↑ Back Eclipse Download
EMF, GEF - Graphical Editor Framework, UML2, VE - Visual Editor are here to download
Http://www.eclipse.org/downloads/index.php
Http://forge.objectweb.org/projects/lomboz
Http://www.myeclipseide.com
Http://propedit.sourceforge.jp/index_en.html
Http://colorer.sourceforge.net/
Http://www.xmlbuddy.com
Http://www.coffee-bytes.com/servlet/PlatformSupport
Http://easystruts.sourceforge.net/
Http://fjep.sourceforge.net/
Http://brosinski.com/stephan/archives/000028.php
Http://www.jasperassistant.com/
Http://cloudgarden.com/jigloo/
Http://sourceforge.net/projects/eclipsecolorer/
Http://eclipsecolorer.sourceforge.net/advanqas/index.html
Http://log4e.jayefem.de/index.php/Main_Page
Http://sourceforge.net/projects/vssplugin
Http://eclipse-tools.sourceforge.net/implementors/
Http://eclipse-tools.sourceforge.net/call-hierarchy/index.html
Http://eclipsetidy.sourceforge.net/
Http://www.mvmsoft.de/content/plugins/checkclipse/checkclipse.htm
Http://www.binamics.com/hibernatesync/
Http://propsorter.sourceforge.net/
Http://editorlist.sourceforge.net/
Http://cloudgarden.com/memorymanager/
Http://www.swt-designer.com/
Http://www.sysdeo.com/eclipse/tomcatPlugin.html
Http://tabaquismo.freehosting.net/ignacio/eclipse/xmlview/index.html
Http://quantum.sourceforge.net/
Http://sourceforge.net/projects/dbedit
Http://www.azzurri.jp/en/software/index.jsp
Http://www.azzurri.jp/eclipse/plugins
Http://hiberclipse.sourceforge.net
Http://www.binamics.com/hibernatesync
Http://www.jamesholmes.com/struts/console/
Http://easystruts.sourceforge.net
Http://veloedit.sourceforge.net/
Http://jalopy.sourceforge.net/
Http://andrei.gmxhome.de/jdepend4eclipse/links.html
Http://springide-eclip.sourceforge.net/updatesite/
Http://beust.com/doclipse/ JFace development Wizard
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
Addressbook.zip file will be compressed into a temporary directory. ant clean ant
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Buildfile: build.xml init: [mkdir] Created dir: D: \ Address Book \ dist compile-common: compile-module: [echo] Compiling ... [mkdir] Created dir: D: \ Address Book \ build [mkdir ] Created dir: D: \ Address Book \ build \ classes [javac] Compiling 8 source files to D: \ Address Book \ build \ classes package-common: [jar] Building jar: D: \ Address Book \ dist \ addressbook. jar default: BUILD SUCCESSFUL
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table> NewContactAction category from the File menu to select users New Contact this operation (see Figure 3).
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
A public class NewContactAction extends Action 2 (3 ApplicationWindow window; 4 5 publicNewContactAction (ApplicationWindow w) 6 (7 window w = 8 this.setText ( "New Contact"); 9 this.setToolTipText ( "Create new contact"); 10 11 12) public void run () 13 (14 ContactWizard wizard = new ContactWizard (); 15 16 WizardDialog dialog = new WizardDialog (window.getShell (), wizard); 17 dialog.open ();) 19) 18
run method. ContactWizard before the need to create a new category of examples. Setup Wizard of such individual pages, allows users to provide input to the various jurisdictions. We will be more detailed description of ContactWizard category. WizardDialog category for examples: the first contains the shell variable references, and the second variable contains the line of section 14 ContactWizard created by the application. WizardDialog category responsible for the user guides and the organization indicated that the actual performance of each page.
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table> ContactWizard category, we need to create the basic realization of the inheritance wizard subclass and covers the following methods:
Public void addPages () - This method provides a link to the end-user in order to display the wizard to guide before adding other pages. Give wizard add new pages, as long as the list if, as shown in 3 addPage method can be called. ContactWizard category in the definition of two pages. In the next section we will study how to create new pages.
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public void addPages () (page1 = new BasicContactPage (selection); page2 = new AddressContactPage (selection); addPage (page1); addPage (page2);)
Public boolean performFinish () - When the Finish button when the user clicks on the implementation of this method. In ContactWizard, use this method to collect on each page guide each domain data and filling them to a domain object. Please refer to the list 4.
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
Public boolean performFinish () (Contact contact = new Contact (); contact.setFamilyName (page1.getFamilyName ()); contact.setGivenName (page1.getGivenName ()); contact.setBusinessPhone (page1.getBusinessPhone ()); contact.setHomePhone (page1.getHomePhone ()); contact.setEmailAddress (page1.getEmail ()); AddressBook.addContact (contact); return true;)
addPages performFinish methods and the integrity category.
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
... Public class ContactWizard extends Wizard (private BasicContactPage page1; private AddressContactPage page2; private ISelection selection; public ContactWizard () (super (); setNeedsProgressMonitor (true);) public void addPages () (page1 = new BasicContactPage (selection); page2 = new AddressContactPage (selection); addPage (page1); addPage (page2);) public boolean performFinish () (Contact contact = new Contact (); contact.setFamilyName (page1.getFamilyName ()); contact.setGivenName (page1. getGivenName ()); contact.setBusinessPhone (page1.getBusinessPhone ()); contact.setHomePhone (page1.getHomePhone ()); contact.setEmailAddress (page1.getEmail ()); AddressBook.addContact (contact); return true;))
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table> WizardPage class did not materialize, there will be no acts ContactWizard. You can guide as a pile of cards, each card has its own layout and design. WizardPage responsible for every single page in the wizard (cards) the layout and behaviour. To create a WizardPage, we need to create WizardPage basically inherited from the base class and realize createControl method, so as to create a specific guide pages of GUI controls. WizardPage development, the need to complete the following:
BasicContactPage category, the use of GridLayout. ContactWizard demonstrated in the class structure and layout BasicContactPage the necessary code. Please refer to Figure 1 of the wizard pages Screenshots.
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
... Public void createControl (Composite parent) (Compositecontainer = new Composite (parent, SWT.NULL); GridLayoutlayout = new GridLayout (); container.setLayout (layout); layout.numColumns = 2; layout.verticalSpacing = 9; Label label = new Label (container, SWT.NULL); label.setText ( "& Given Name:"); givenNameText = new Text (container, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData (GridData.FILL_HORIZONTAL); givenNameText.setLayoutData (gd); givenNameText.addModifyListener (new ModifyListener () (public void modifyText (ModifyEvent e) (dialogChanged ();))); label = newLabel (container, SWT.NULL); label.setText ( "& Family Name : "); familyNameText = new Text (container, SWT.BORDER | SWT.SINGLE); gd = newGridData (GridData.FILL_HORIZONTAL); familyNameText.setLayoutData (gd); familyNameText.addModifyListener (new ModifyListener () (public void modifyText (ModifyEvent e) (dialogChanged ();))); label = newLabel (container, SWT.NULL); label.setText ( "& Nickname:"); nickNameText = new Text (container, SWT.BORDER | SWT.SINGLE); gd = newGridData (GridData.FILL_HORIZONTAL); nickNameText.setLayoutData (gd); createLine (container, layout.numColumns); label = newLabel (container, SWT.NULL); label.setText ( "& Business Phone:"); businessPhoneText new Text = ( container, SWT.BORDER | SWT.SINGLE); gd = newGridData (GridData.FILL_HORIZONTAL); businessPhoneText.setLayoutData (gd); label = new Label (container, SWT.NULL); label.setText ( "& Home Phone:"); homePhoneText = new Text (container, SWT.BORDER | SWT.SINGLE); gd = newGridData (GridData.FILL_HORIZONTAL); homePhoneText.setLayoutData (gd); createLine (container, layout.numColumns); label = newLabel (container, SWT.NULL ); label.setText ( "& E-Mail Address:"); emailText = new Text (container, SWT.BORDER | SWT.SINGLE); gd = newGridData (GridData.FILL_HORIZONTAL); emailText.setLayoutData (gd); emailText.addModifyListener (newModifyListener () (public void modifyText (ModifyEvent e) (dialogChanged ();))) / / dialogChanged (); setControl (container);) ...
BasicContactPage class, creates several ModifyListeners implementation of domain-specific data input validation. No matter when the amended version of the text jurisdictions must implement dialogChanged methods. The method responsible for handling errors and error report to the wizard. 7 demonstrated a list of input validation and processing will be required for any error notifications wizard code.
<table Bgcolor="#eeeeee" width="100%" cellpadding="5" cellspacing="0" border="1"> <tr> <td>
... Private void dialogChanged () (if (this.getGivenName (). Length () == 0) (updateStatus ( "Given name must be specified."); Return;) if (this.getFamilyName (). Length ( ) == 0) (updateStatus ( "Family name must be specified."); return;) if (this.getEmail (). length ()> 0) (if (this.getEmail (). indexOf ("@") <0) (updateStatus ( "Enter your email address as yourname@yourdomain.com"); return;)) updateStatus (null);) private void updateStatus (String message) (setErrorMessage (message); setPageComplete (message == null) ; ...
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
ant run
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>
</ Td> </ tr> </ table> <table class="no-print" cellspacing="0" cellpadding="0" align="right"> <tr align="right"> <td>
<table Border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle">
</ Td> <td valign="top" align="right"> </ td> </ tr> </ table> </ td> </ tr> </ table>