The reconstruction of the Eclipse's Java development environment is one of the most useful features it provides. This article will introduce you to creating your own reconstruction (as the natural extension of the Eclipse). Many parts of the solutions provided herein are taken from the recently published Book of Java Developer's Guide to Eclipse. Because Eclipse has a powerful Java development environment, it makes it a good review of people. This Java development environment (coupled to team environment and other basic functions) makes Eclipse become a compelling integrated development environment, which is a good news for Java developers. Moreover, Eclipse is still an open source project. But truly make people feel excited to Eclipse is that it provides the possibility of expansion. Many Eclipse-based commercial products show this practical significance of this way of providing integrated products. For example, IBM WebSphere Application Developer and Rational XDE illustrate that Eclipse has had already affected. These products and other Eclipse-based products reduce the user's "learning curve" because they have similar user interfaces. Of course, for large software companies, this is very valuable, but is it for small companies or individuals? This is the place where the Eclipse extensibility is interested. Not only those companies with large-scale development organizations can be integrated with it, but people who are willing to spend several Eclipse frameworks can also take advantage of this capability. "Oh," You may think, "Don't mention what framework; I don't have time to learn more frames." Don't worry; this learning is very fast and very easy. Before you start formation in your mind, you will declare a little "Hello World" extension for Eclipse. Please feel free to use the actual value and a clear demo in how to enhance the productive use of the Eclipse's Java development environment. You may even be a bit surprisingly found: To complete some quite amazing things, just dozens of lines of code. This article will show you what is possible, where to start, and will provide you with any reliable evaluation you need. Although the expansion of Eclipse is a senior topic, you just know how to use the Eclipse's Java development environment. I'm easily reconstructing members visibility. I didn't worry too much when I was writing code. I didn't worry about the way of visuality as default (package), private, and public or protected. When you create a method, I make them public. Only when I finally set the organizational structure of the package and completed the reconstruction of the method - no matter the new method from existing code, the method is moved or moved in the hierarchical structure or the method to other Class - I will retrieve the visibility of the method. I think that before I know the final class, I don't want to declare my "customers" what may I need. In other words, before sharing a new framework, you must determine what is implementing details, what is required, so others can expand it. If you only need to select the method in the Outline view, Hierarchy view, or anywhere you view method - then by clicking the menu option, you can set one or more methods into desired visibility - then this is very convenient. It is accustomed to this feature that I have learned in the days when I use Visualage for SmallTalk. Figure 1 shows the extension of the Outline view context of the Java editor in the Java development environment of Eclipse.
Figure 1. Expansion of the context menu for the method
From the user's point of view, this is very clever because it is a natural way to introduce the user interface. Without any hints, these new menu options do not belong to the Eclipse initial Java development tool (Java Development Tool, JDT). In fact, that is the reason for the menu level, using the "SOLN" prefix - so you can tell it! Moreover, developers don't have to remember that these options can only be used only in a particular view or editor, as if the method is displayed, where they can display it. Briefly describe "Hello World" "Hey, wait, you promise not to have 'Hello, World'!" Yes, but before we start discussing the real interesting thing, you really need to first understand the foundation of Eclipse. So, if you have never written your own Eclipse extension, please quickly learn about the Eclipse architecture and plug-in development environment. Otherwise, please jump to the next section. Continue this "travel"! Essentially, Eclipse is a set of loose binding but interconnected code blocks. If you figure out how these code blocks are "discovered", and how they find and extend their mutual discovery and extension, you can understand the basic principles of the Eclipse architecture. Figure 2. Eclipse platform architecture
These functional units are called plugins. The Eclipse platform is running (see Figure 2) Responsible for finding the declaration of these plugins in a file called PLUGIN.XML, each plugin.xml file is in the subdirectories of each plug-in, these subdirectories are located Eclipse's public directory is named PLUGINS (specifically,
/ Eclipse / plugins. Based on these files, the Eclipse platform is built at the time of starting at the time of launch, called the plug-in registry, according to this registry, the given plugin can determine which plugins can be extended at runtime. Plugins that wish to be extended by other plugins will declare an extension point. This is some "power board" of the plugin, which is expanded to the plugin, and other plugins can take advantage of this plugin.
Go back to our example, then the task is to determine where to "insert" Eclipse from "insert" to meet the corresponding extensions we need. Fortunately, once you use Eclipse for a while, you will know that there is an amazing thing that can be used, although you may not actually use it. This is because the models built in the Eclipse user interface and the models built from the classes that make up the Eclipse plugin are usually almost one or one. Figure 3 makes this clearer:
Figure 3. View and its model
Here we see a series of ordinary user interfaces, the right side is the most widely known user interface - command prompt window, in which the Dir command displays the file system content, and then the left-specific view is high. - JDT package explorer. From the perspective of the user interface, all of these views can be visualized by the same "model" (that is, some files). As an Eclipse user, we naturally want these two Eclipse views to provide us with different ways to view the same thing: Navigator demonstrates the specialized view of some operating system files (Eclipse workspace), and Package Explorer shows us to us The same documents, these files are organized and expressed by methods for the Java programmers.
By understanding how the Eclipse user interface reflects its underlying model, and how the Eclipse model becomes the basis of mutual build, this provides us with how to find the best position of "inserting" our extension. The Eclipse interface name below shows that ifile and iCompiLationUnit are the two interface examples we can expect from the model that make up the Eclipse. Since they usually correspond to the control items displayed in the user interface, you have an intuitive feeling for the effects obtained by programming. This is the first part of our "travel". In the section II section, we will discuss development solutions. We don't plan to provide this solution and explain one by one, explore some of them, isn't this more interesting? Let us first discuss some questions related to the following questions: Use our own method visibility to expand JDT.
Ask the problem than knowing the answer more important than knowing the answer
Let us first explore some regular issues:
In the user interface, how to display extensions, and where is it displayed? How often is it to extend the user interface? How to know how to know "Select" is similar to "Select"? After we have a good understanding of the basic Eclipse field, we will turn to some JDT-specific issues: how to extend the user interface of the JDT-specific element (as a member displayed in the Outline view)? Extend view or their underlying model? What is the relationship between elements displayed in Package Explorer and other views (such as OUTLINE views)? Does our extension need to know any difference between them? How to change the JDT model by programming? How to analyze Java source code for modification? Of course, there is the last big problem: What is the next step?