Eclipse Getting Started - Introduction to Eclipse and Plugin Development

xiaoxiao2021-03-06  57

Eclipse is the next-generation IDE development environment that replaces IBM Visual Age for Java (hereinafter referred to as Ivj), but its future goal is not only a IDE environment specializing in developing Java programs, but it can expand according to the eclipse architecture, it can expand To any language, it can even be a tool drawn. Currently, Eclipse has begun to provide a function plugin for C language development. It's more difficult to expensive, Eclipse is an open source project, anyone can download the source code of Eclipse, and develop its own function plugin on this basis. That is to say, as long as someone needs it, there will be a development plugin that is built in languages ​​such as COBOL, Perl, Python, Eclipse. At the same time, you can extend the functionality of the existing plug-in by developing new plugins, such as adding Tomcat server plugins in an existing Java development environment. You can expand unlimited, and there is a unified look, operation, and system resource management, which is also the potential of Eclipse.

Although the Eclipse project is currently not completed, it has been able to appreciate the Eclipse design leading ideology and the main features from existing versions. Learn now, Eclipse can not only make the majority of programmers to the idea of ​​high ideas, but more importantly, if they can participate in the development of the Eclipse project or read its open source, this for the majority of programmers It is undoubtedly a good opportunity to improve the programming level. Eclipse plans to provide versions of multiple platforms, like Windows, Linux, Solaris, HP-UX, and AIX, and below, only describe Windows versions. The first part of this article first introduces the basic use of Eclipse. The second part describes how to develop Eclipse's plugin.

One. Introduction to Eclipse

Eclipse is an open source project, you can go to www.eclipse.org to download the latest version of Eclipse for free, generally Eclipse offers several download versions: Release, Stable Build, Integration Build and Nightly Build, it is recommended to download Release or Stable versions. The author used the build20020125 (STABLE version). The Eclipse itself is written in Java language, but the downloaded compressed package does not include Java running environments, requiring users to install JRE separately, and indicate the path to bin in the JRE in the environment variable of the operating system. The step of installing Eclipse is very simple: just decompress the downloaded compressed package according to the original path. Be careful If you have an updated version, you must first remove the old version to reinstall, you can't directly decompress the original path to cover the old version. After decompression, you can go to the corresponding installation path to run the Eclipse.exe. If downloaded the Release or Stable version, and the JRE environment is installed correctly. Generally, there will be no problem. After flashing a cool, Eclipse shows its default interface:

Figure one

At first glance, Eclipse's interface is a bit like JBilder, but it will find it more like IVJ in the actual operation process. After all, the leading amount of developing Eclipse is the development of IVJ's principal (can refer to www.oti.com). It is also worth mentioning that in addition to the IBM, there is a large number of people such as Borland, Rational Software, Redhat, Merant, etc., which laid a good foundation for Eclipse's future.

The following will provide a brief introduction to the various characteristics of Eclipse, including: file storage, development environment, compilation and operation, version management, and plug-ins. 1. File storage

Most IVJ's beginners are very uncomfortable to find the Java source code, because IVJ stores all source code into a Reposital library file, you want to get the source code of the text format must be exported from reportation from Report Source code. Ivj used by ReponsTory almost extremely extremely extreme, which is this, making many programmers to love IVJ. Eclipse saves the source code in text, but implements almost all functions of IVJ on source code management, and adds some new features to achieve this, not sighing at the Eclipse developer's superb skills.

After installing Eclipse, there will be a Workspace folder in the next layer of the installation path. Generate a new item in Eclipse, which will be generated in Workspace to store all files used in Workspace to store all files used in the project. You can use the Windows Explorer to access or maintain these files directly.

There are three ways to add existing files to a project: The first is the same as in IVJ, import files into the project in the "IMPORT" function in the "File" menu. This is also recommended. The second is to drag files into the project directly from Windows Explorer. The third is to copy the file directly into the project folder, and then select the item or folder in the Eclipse's resource browsing window and perform the Refresh from locate. One point to be explained is that the project folder can be placed anywhere in the computer, and can specify the project path to the existing project folder in Eclipse, and then refresh in Eclipse. However, it should be noted that any project folder is established or specified, and it is currently only implemented in the Eclipse method, even if it is newly created under the Workspace path of the default storage project folder, in Eclipse It is also unable to turn it into a project, that is, this folder is not visible to Eclipse.

2. Eclipse development environment

Like IVJ, the Eclipse development environment is called Workbench, which is mainly composed of three parts: view (Perspective), edit window (editor), and viewing window (view). In the following introduction, I hope the reader knows that the Java view, the Java package browsing window, the resource view, the resource browsing window (in fact, the most important thing is to distinguish the view and window) to avoid confusion in further reading. Figure 2 is the relationship structure between them:

Figure II

In Figure 2, you can see that Workbench contains multiple views, while each view also contains different windows. Since each editing window has a lot of commonality and the default, they are displayed in the same area, so we only marked a editing window in each view to represent green. Observing the window is different, here is expressed in red.

Let's first introduce the editing window. The display and editing of all files are included in the edit window. By default, multiple files are arranged in the TagTable mode in the same window, which can be used to arrange these files into a variety of layouts. The method is to drag the label (tag) of a file to the border of the editing window, release when the cursor has the corresponding changes.

When the file is added to the project, double-click the file in the resource browsing or java package, Eclipse will try to open this file: where the Eclipse embedded editor can open some files default, such as * .java, *. Txt, * .class, etc. If it is other type of file, Eclipse calls the operating system's corresponding default editor to open, such as Word documents, PDF files, etc. At the same time, Eclipse can also open the corresponding file with the specified editor like IVJ. For example, when you double-click the HTML file in the Eclipse project, you may want to open with notepad instead of using the system default IE. The implementation method is to open the WorkbenchàPReferences dialog box in the menu bar, then select WorkbenchàFile Editors in the dialog, then add file type, such as * .html, and specify the editor to it. In the editing window, it is worth noting that the programmer who is accustomed to editing the Java program when editing the Java program (ie, only a single method is displayed in the editing window, not the source of all the program. Code), this method is indeed very reasonable development method, not only the display of the code is more simple, and can assist the programmer to have a better package. The Eclipse provides a switch button on the toolbar that can be switched between "display all code" and "only the selected unit" (here the unit refers to a single method, variable, imported packet, etc.) The following figure 3). No recommended

Programmers who have used IVJ also try to develop code development in the "only displayed unit" state. Secondly, it is the observation window, which matches the editing window and provides a variety of related information and browsing methods. Commonly used observations include Resource Browse Window (Navigator), Java Packet Browse Window (Packages), Console, Tasklet (Task), and more.

The browsing window and Java browsing window are part of the viewing window. The former and Windows browsers are similar, can browse all files in the project folder, the latter used to browse information in the Java package in the project, the variables and methods in the classes in the package, the variables and methods in the class. In the Java browsing window, you can open the hierarchical browsing window (Hierarchy) in the menu of the mouse button, this window is very practical, it can view the hierarchy of the class very clearly. Compiling error information in the class can be found in the task window, and it can also be a mission-active task window: add new task description information to track the progress of the project. The console is primarily used to display the output information of the program. In debugging, there will be a richer observation window to help programmers make debugging, such as variable values ​​to see windows, breakpoint windows, and more.

The observation window is the core of any IDE development environment. It is also a good IDE development environment using a good observation window. Eclipse offers a wealth of observation windows that can really use these windows. I am afraid to have been hone after a period of time.

Last introduction view. A view includes one or more editing windows and viewing windows. The upper part of the leftmost shortcut bar in the development environment is displayed the currently open view icon. The view is the most flexible part of Eclipse, which can customize the type of observation window included in each view, or you can customize a new view. These features are included in the "Perspective" menu. Several default views are available in the Eclipse's Java development environment, such as resource perspective, the default view of the first time Eclipse), Java perspective, debug perspection, Team view (Team Perspective, etc.). Each view corresponds to different types of observation windows. You can see the viewing window corresponding to the view from the perspectiveàshow view in the menu bar. Of course, the observation window of each view is configurable, and you can configure in the Perspectiveàcustomize in the menu bar. Diversified views can not only help programmers observe the code in different angles, but also meet different program habits. 3. Compilation and operation

The debugging function in IVJ is very powerful, a variety of tracking methods, breakpoint settings, variable values, and more. These are also available in Eclipse. When the plugin is introduced herein, it will be more detailed in connection with the example how to use the configuration project environment, how to run and debug programs.

In the Java view, there are two buttons in the toolbar, which are used to debug and run separately. And maybe the plug-in of the installed plug-in will exist in a variety of run / debugprues, in order to determine the current item to run, you need to set the launcheràrun / debug option in the item's properties option. Usually we need to use the "Java Applicance" mode. In this manner, if the current location is a Java program containing the main () method, click the debug / run button to immediately start the debug / run function. If the current location is on the package or item, Eclipse searches all the executables included in the current location, and then selects the run by the programmer himself.

The plug-in development environment is installed in the current Eclipse's Release and Stable versions (PLUG-IN Development Environment, PDE, which is also a plug-in), at which time the system is running in addition to "Java Applicance", there may be two Method: "Run-Time Workbench" and "Run-Time Workbench with Tracing", when using PDE development plug-ins, it will be used below, we also mention it.

4. Version management

You can divide the Eclipse version of the version into two kinds of personal (or).

Eclipse provides a powerful personal version of management mechanism, each saved changes can be recovered. And you can recover from the version of each method. The operation is also very convenient, in any of the observation window that you want to operate, such as the resource browsing window, select the file, click the right mouse button, select Compare with or replace with, if it is the method that has been deleted, you can Choose Add from local history, then the corresponding local history will appear, follow your needs to find the corresponding version. Powerful personal version management functions provide more confidence in programmers: only, any accidental mistake can be recovered, developing under Eclipse, there is "regret medicine"! Eclipse default provides an interface for version management tool CVS, which is very convenient to connect to the CVS server. With CVS version management, Eclipse provides a good environment for team development. To connect the CVS server, you need to open the team view (Team Perspective) and then click the right mouse button in the Repositalies Observatory and select New. In the open dialog box, you can fill in the information you need to connect to the CVS library you want, such as CVS server type, current Eclipse supports three ways: PServer, ExtSSH, and EXT, you have to fill in user name, host name, password, repounds, etc. information.

Using CVS in Eclipse, it is necessary to pay attention to some terms and function changes. Branch in CVS is called stream, cancel the function of Check Out, Import, and Commit in CVS, and the TEAM-> synchronized in the right mole menu. With stream is replaced. These functions are done through the graphical interface. There will be current files and the comparison window of the previous versions in each operation, the operation is very intuitive, easy to master, so this will not be further introduced.

5. Plugin

Use a plugin to enrich the functionality of Eclipse. Here's how to apply plugins to embed Tomcat servers. This plugin is not developed by the Eclipse project group, but a company called Sysdeo, very small, only 27.8k. You can go to http://www.sysdeo.com/eclipse/tomcatplugin.html to free download. In addition, this plugin only supports version of Tomat 4.0, which can get the latest version of Tomcat at www.apache.org.

To install a plugin, simply extract the downloaded ZIP files to "your Eclipse's installation path / plugins" below, then restart Eclipse. After startup, select Perspectiveàcustomize on the menu bar, select Otheràtomcat in the open dialog. It will immediately find that Eclipse has two changes: there is a Tomcat option in the menu bar. There are two buttons in the toolbar. The top is the Tomcat kitten that you might be familiar with, as shown below. In addition, in the menu bar selection: WorkbenchàPReferences, you will find that this also a Tomcat option is required to specify your Tomcat installation root path here. Then check if the JRE specified in the Preferences dialog box, the JRE specified by JavaàInStalled JRE, whether the Tomcat's JRE is the same jre, if not, may cause Tomat to start normally. If there is no problem with the above check, you can start Tomcat directly with "Kitten" on the toolbar. It should be noted that the startup process is very slow, we must wait patiently to the following information: Starting Service Tomcat-StandalongApache Tomcat / 4.0.1starting service Tomcat-apacheapache tomcat / 4.0.1

You can then enter http: // localhost: 8080 in an external browser (such as IE) to test whether Tomcat is normal.

Figure three

If it is normal, you can further try to debug the servlet or JSP program in Eclipse. Below we will use Tomcat's servlet routine HelloWorldexample.java to demonstrate how to debug the Sevlet program in Eclipse.

First, you must create a new Java project in the Java view. For convenience, you can directly assign the project path to the path where the HelloWorldExMaple program is located, as shown in Figure 4:

Figure four

After pressing "Next", go to the Java Settings dialog, select the libraries tab, and use the Add External Jars button to specify the location of the servlet.jar package. It uses the servlet.jar package in Tomcat. Figure 5:

Figure 5

Finally, click "Finish" to complete the generation of the project. Default package in the new project can find HelloWorldexample.java, double-click Open file, and try to add a breakpoint to HelloWorldexample (double-click the Edit window left boundary). After the external browser, enter http: // localhost: 8080 / examples / servlet / helloWorldexample, then see what Eclipse changes, is a debug window! Debugging operations in Eclipse and the vast majority of identities are similar, such as setting breakpoints, single-step tracking, variable value, etc., it will not be detailed here.

two. Developing Eclipse plugins (Plug-Ins)

Eclipse's most attractive place is its plugin architecture. Important concepts in this system are Extension Points, which is the interface provided for plugins. Each plugin is developed on existing extension points and may have its own extension points to continue development on this plugin.

Due to the plugin, the core part of the Eclipse system is very simple to complete when starting, the work of the platform is started, and the platform of the platform and the plugin for the system. Most of the features implemented in Eclipse are completed by the corresponding plug-in, such as the appearance of the Wrokbench UI plugin completion interface, the Resource Management plugin completes the maintenance or generation of resource management work such as projects or files (in the second example below This plugin will be used), and the Version and Configuration Management (VCM) plugin is responsible for completing version control functions, and so on. Although every feature mentioned above is the function necessary for most IDE environments, Eclipse also made them all the plug-in mode, and even developed the development environment of Java programs (Java Development Tooling, JDT) It is just a normal insert in the Eclipse system. The entire Eclipse architecture is like a large puzzle, which can be plug-in, and the plugin can also be added to the existing plug-in. The following plug-in development example is developed at the observation window extension in the Workbench UI plugin. The first part of this article introduces one of the development interfaces of Eclipse is the observation window. It usually cooperates with the edit window to display some useful information, here we only generate a watch window that shows welcome information, assumes a new plugin called Welcome.

The first step is to create a Java project with a guide. We can select Fileànew in the menu bar, or use the wizard button in the toolbar, or use the New Wizard dialog box in the resource window with the NEW, open the Wizard dialog, and create a project with the default. And build a Welcome.java file in the project, the code is as follows:

Package com.nidapeng.eclipse.plugin;

Import org.eclipse.swt.widgets.composite;

Import org.eclipse.swt.widgets.label;

Import org.eclipse.swt.swt;

Import org.eclipse.ui.part.viewpart;

Public class welcome extends viewpart {

Label label;

Public welcome () {

}

Public void createpartControl (Composite Parent) {

Label = new label (parent, swt.wrap);

Label.setText ("Welcome to Eclipse";

}

Public void setfocus () {

}

}

In order for this program to be compiled normally, configure its compilation environment, that is, specify the desired ClassPath. There are several ways in Eclipse, commonly used: the first is to select the item at the resource window or Java package window, click the right button, select Properties in the open menu, then in the Properties dialog box Choose Java Build PathàLibraries, add three packages with the Add External Jars feature, which are both the eclipse's existing plug-in package, which can be found in the corresponding path below "Your Eclipse installation path / plugins". They are the runtime.jar in the org.eclipse.core.Runtime plugin, ORG.Eclipse.swt in Swt.jar and Org.eclipse.ui in Workbench.Eclipse.ui. The second specified classpath is to first import the three packets mentioned above into a next item in the Eclipse. If imported into the same item as Welcome.java, there is no need to further specify the classpath, otherwise you need to select Java Build PathàProjects in the Properties menu of the project, then select the items where these three packages are. In our project, you have to generate an XML file, and its name must plugin.xml. code show as below:

ID = "com.nidapeng.eclipse.plugin"

Name = "Welcome to Eclipse"

Version = "1.0"

Provider-name = "ni Dapeng">

Point = "org.eclipse.ui.views">

Name = "Welcome"

ID = "com.nidapeng.eclipse.plugin.category1">

Name = "Welcome to Eclipse"

Category = "com.nidapeng.eclipse.plugin.category1"

Class = "com.nidapeng.eclipse.plugin.welcome"

ID = "com.nidapeng.eclipse.plugin.View1">

There are four main tags in Plugin.xml: Plugin, Requires, Runtime, Extension. The properties of the Plugin tag provide basic information for the Welcome plug-in we have to develop. In addition to Name, Version, Provider-name, the most important thing is ID, it requires conflicts with the existing Eclipse plugin ID, so we use The name is the ID of the plugin. The Requires tab is listed in the needed plugin, here we want to use the Eclipse Workbench and SWT API, thus import the org.eclipse.ui plugin. The Runtime label is specified in the file name of the JAR package where we developed the plugin. The Extension tag is the information of the plugin extension point. Org.eclipse.ui.views is the observation window extension provided by the Eclipse system. Our example is a view window (this shows that we are going to further development in org.eclipse.ui.views extension. EXTension also includes two labels, and we will know the meaning of these two labels in subsequent Welcome plug-in steps. It should be noted that the uniqueness of the ID of the Category and View tags, and declare the Welcome plugin class name in the properties of the View. In Eclipse, Plugin.xml provides the default visual editor, which can be done with this editor during writing PLUGIN.XML. If you enter the PLUGIN.XML file source code, you can also check your code with this editor: If the editor does not read it correctly, you have some questions in your Plugin.xml.

After confirming that weclome.java and plugin.xml are correct, you can use the export command in the Eclipse menu bar to export Weclome.java as JAR file, and its name should be consistent with the JAR declared in Plugin.xml. Export Plugin.xml at the same time. The method of installing the Welcome plug-in and the installation Tomcat plug-in method described herein is the same: first establish a com.nidapeng.eclipse.plugin path under the "Eclipse" path, then WECLOME.JAR and PLUGIN. XML is copied to this path. The Eclipse must then be restarted. When the Eclipse is started, it searches for all plugins under the plugin path and registers them (just registration, "only when a plugin is required, Eclipse will start it). Select PerspectiveàShow Viewàothers in a rebooted Eclipse, in the open dialog, we will find the Name property declared in the Category tab in the plugin.xml: Welcome. The View tag Name property is included in the Welcome's support: Welcome to Eclipse. Select it and confirm that the Welcome window will appear in a location on the Eclipse Workbench. If the above operation is performed, no new window is displayed, you can open the show view menu again. At this point, there should be a new one in the menu: Welcome to Eclipse, then select it.

Above we completed a plug-in to observe the window, but this operation process is less convenient for developing a slightly complex plug-in: each test must pack, release, restart the Eclipse system! To this end, Eclipse provides a plug-in (a bit winding): Plug-in Development Environment (PDE). As mentioned earlier this article, the current Eclipse's Release or Stable version provides this plugin, so if the installed Eclipse is one of the two versions, you can directly carry out the following steps. Let's develop a slightly complex plugin with a PDE environment. The first step is still going to create a project, just in the wizard is not using Java projects, but Plug-in project in Plug-in developments. When the application wizard is generated into a new project, pay attention to two points: The first is the PDE project name is the PLUGIN ID, so it is necessary to ensure its uniqueness, here our project name is com.nidapeng.eclipse.plugin.pde. Second, in order to further illustrate the structure of the Eclipse plug-in, in the Plug-In Code Generators, select a default plug-in with a wizard template, as shown in Figure 6:

Figure 6

This type of plug-in class generated by default is not required for us to build, and can also build our project with a generation of air plug-ins, which is just to further illustrate the plugin structure of Eclipse.

After the project is generated, there will be a pdeplugin.java file in our project, which is a plugin class generated by the default. Note that it inherits the Abstractuiplugin class, and the AbstractUiplugin class implements the org.eclipse.ui.plugin interface. In fact, all Eclipse plugins will have a class that implements the PLUGIN interface. This class will be the main class of the new plugin (similar to the Java class with the main () function), which is responsible for managing the survival of the plugin. In our AbstractUiplugin inheritance, the first one of the generated plugins generated in Eclipse is also unique instance in the Singleton mode. In general, a getDefault () method is also implemented in the inheritance subclass. Returns an instance of the current plugin. Moreover, when Eclipse uses the plugin for the first time, this primary class will be the first class that is called, so we can also perform some initialization work in its code. And if the plugin needs to use Preferences, Dialogs, or ImageS resources, you can also get their instances in this class, such as using getDialogSettings (), getImageReGistry () method.

But as mentioned earlier, PDEPLUGIN.JAVA is not required by the following example, we don't have to make any modifications to it. In our first example, the WeClome plugin does not generate Abstractuiplugin at this time, at which point the system automatically generates a default main class for the WeClome plugin (similar to the Java class constructor, if there is no statement, the system will Specifies a default constructor).

The following code is to really realize the function of our new plugin, assuming that this plugin is NOTICEVIEW:

Package com.nidapeng.eclipse.plugin.pde;

Import org.eclipse.core.resources. *;

Import org.eclipse.core.Resources.IResourceChangeEvent; import org.eclipse.core.Runtime.coreException;

Import java.util.resourcebundle;

Import org.eclipse.swt.widgets.label;

Import org.eclipse.swt.widgets.composite;

Import org.eclipse.ui.part.viewpart;

Import org.eclipse.swt.swt;

Import org.eclipse.swt.widgets.display;

Public Class NoticeView Extends ViewPart IMplements

Runnable, IResourceChangelistener, IResourceDeltavisitor {

Private resourcebundle resourcebundle;

PRIVATE LABEL LABEL;

Private Display Disp;

PRIVATE STRING Disptxt;

Public noticeView () {

ResourceSPLUGIN.GETWORKSPACE (). AddResourceChangelistener (this,

IResourceChangeeevent.pre_close

| IResourceChangeeevent.pre_delete

| IResourceChangeeevent.pre_auto_build

| IResourceChangeeevent.post_auto_build

| IResourceChangeeevent.post_change);

}

Public Static iWorkspace getWorkspace () {

// ResourceSplugin plugin's main class!

Return resourcesplugin.getWorkspace ();

}

Public void createpartControl (Composite Parent) {

Label = new label (parent, swt.wrap);

Label.Settext ("Change your Project Status ...");

DISP = Display.getDefault ();

}

Public void setfocus () {

}

// Realize the ResourceChanged method in the IResourceChangeListener interface

Public void resourcechanged (iResourceChangeeevent Event) {

IResource res = event.getResource ();

Switch (Event.gettype ()) {

Case IResourceChangeEvent.pre_close:

Disptxt = Res.GetFullPath () "Is About to Closed!";

Break;

Case IResourceChangeEvent.pre_delete:

Disptxt = Res.GetFullPath () "Is About to be deleted!";

Break;

Case IResourceChangeeevent.post_change:

Try {

Event.getdelta (). accept (this);

} catch (coreexception e) {

E.PrintStackTrace ();

}

Break;

Case IResourceChangeeEvent.pre_auto_build: try {

Event.getdelta (). accept (this);

} catch (coreexception e) {

E.PrintStackTrace ();

}

Break;

Case IResourceChangeeevent.post_auto_build:

Try {

Event.getdelta (). accept (this);

} catch (coreexception e) {

E.PrintStackTrace ();

}

Break;

}

Disp.syncexec (this);

}

/ / Realize the Visit method in the IResourceDeltavisitor interface

Public Boolean Visit (IResourceDelta Delta) {

IResource Res = Delta.getResource ();

Switch (delta.getkind ()) {

Case IResourceDelta.Added:

Disptxt = "resource" res. GetFullPath () "WAS Added."

Break;

Case IResourceDelta.removed:

Disptxt = "resource" res. GetFullPath () "Was removed."

Break;

Case IResourceDelta.changed:

Disptxt = "resource" res. GetFullPath () "HAS Changed."

Break;

}

Return true; // visit the children

}

/ / Realize the Run method in the runnable interface

Public void run () {

Try {

Label.setText (Disptxt);

} catch (exception e) {

E.PrintStackTrace ();

}

}

}

The first Welcome plugin above, this new plugin also inherits ViewPart, and the difference is to implement three interfaces: Runnable, IResourceChangelistener, IResourceDeltaVisitor. Among them, everyone should be familiar with: multithreaded interface. IResourceChangeListener and IResourceDeltaVisitor are resource interfaces in the Eclipse system, where resources are items or files in Eclipse. In the process of running the NoticeView plugin, you can trigger events in both interfaces by adding, opening, deleting items, or files, and displays related information in our viewing window.

In the program, it is in the resourcechanged () function, and does not call the label.setText () method directly like everyone's imagination, but calls Disp.Syncexec (this), where DISP is DISPLAY Type objects. This is because the resourcechanged () method running thread and the Eclipse main thread running in the Lable in the plugin is not the same thread. If the label.setText () method is directly called, an exception will be thrown.

The following is also required to make some changes to the Plugin.xml in the project, mainly, plus the extended point declaration:

ID = "com.nidapeng.eclipse.plugin.pde" name = "PDE plugin"

Version = "1.0.0"

Provider-name = "nidapeng"

Class = "com.nidapeng.eclipse.plugin.pde.pdeplugin">

ID = "noticeView"

Name = "notice view"

Point = "org.eclipse.ui.views">

Name = "notice"

ID = "com.nidapeng.eclipse.plugin.pde.category1">

Name = "NOTICE Resource View"

Category = "com.nidapeng.eclipse.plugin.pde.category1"

Class = "com.nidapeng.eclipse.plugin.pde.noticeView"

ID = "com.nidapeng.eclipse.plugin.pde.view1">

This XML file and the Welcome plugin PLUGIN.XML are very close, and there is not much explanation here.

To run this plugin, you can use the run button in Eclipse because this project is a Plug-in Project, and the item will automatically run in Run-Time Workbench. After running, you will generate a platform with the current Eclipse. You can run the NoticeView plugin directly on this platform. You can use the plugin to do what features can be used, or use the direct Run-Time Workbench mode to debug the plugin. The process of installing plug-in and restarting Eclipse is eliminated. You can see that the process of using PDE development plug-ins is much smarter than the Java development environment!

The development of Eclipse is not limited to the development of plug-ins, which can also replace standard SWing in Java to develop Java-based independent applications GUI development. It has the advantage of being obvious: high speed, resource occupation, cross-platform, code open, and large companies support, etc.

转载请注明原文地址:https://www.9cbs.com/read-116587.html

New Post(0)