Eclipse RCP plug-in programming to learn shorthand
Advertisements
To facilitate the test and does not affect the normal work of Eclipse,
Best to install a specific Eclipse environment.
see http://www.eclipse.org/downloads/
Choose this version of the Eclipse
Eclipse for RCP and RAP Developers, 181 MB
eclipse-rcp-indigo-win32.zip
You must extract to your hard drive, then create a batch start_rcp.bat,
Point to their own jdk path, as follows:
set PATH= set PATH=D:\java\jdk1.6.0_20\bin;%PATH% start eclipse.exe
Then double-click execution, set a different workspace directory, for example
C: \ Documents and Settings \ Administrator \ workspace_rcp
Into the Eclipse RCP, turn off the beginning of the welcome screen.
Second, understand the use of SWT
SWT RCP write much need to know the preparation method.
Can refer to the official website of the introduction.
http://www.eclipse.org/swt/
Can work independently of the Eclipse SWT, so it is necessary to add in the classpath of its own specific jar library.
The RCP dependent on Eclipse, Eclipse provides the framework to be considered,
But the benefits do not need to take into account the swt jar (because Eclipse already using it).
SWT official website provides lots of code snippets,
http://www.eclipse.org/swt/snippets/
Try to run these small programs can quickly understand the SWT's SWT control without the need to look at the documentation.
They generally use this package:
import org.eclipse.swt.widgets .*;
You'll see later, SWT and RCP programs have a strong program interchangeability.
Third, create a custom view of plug-ins.
My goal is to create a simple plug-in -
Create a custom view, and then display a picture on the inside.
Creating an RCP project:
File-> New-> Project ...
Select a wizard-> Plugin Development-> Plug-in Project
Plugin-in Project
Project name: fill org.eclipse.examples.nanami, press the Next button.
Content
Default settings, press the Next button.
Templates
Select the Plug-in with a view, then press the Next button.
Main View Settings
Default settings, then press the Finish button.
Fourth, test engineering.
Because the view is too complex to create a template, you can simplify it.
Has created two classes:
org.eclipse.examples.nanami.Activator
org.eclipse.examples.nanami.views.SampleView
View icon is a small icon, for display in the view:
/ Org.eclipse.examples.nanami / icons / sample.gif
Project settings can double-click the file list
/ Org.eclipse.examples.nanami / META-INF / MANIFEST.MF
First test the View (not to make any changes to the current)
Open Activator.java file, then click the Debug button on the toolbar.
Select Eclipse Application, click OK to open a new Eclipse environment.
Window-> Show View-> Others-> Sample Category-> Sample View
Open to change the view (display a list of three items).
Direct exit to the Eclipse environment.
Fifth, modify view properties
Right Project -> Properties-> Resource-> Text file encoding-> Other: UTF-8 filling
Double-click build.properties, switch to the build.properties label,
Edit this file at the end add:
javacDefaultEncoding .. = UTF-8
This release compiled code using UTF-8.
Next, modify the title of the view and replace their icons.
Icon.gif copy the new icon to the icons /, and then double-click the plugin.xml file.
The
<view
name="Sample View"
icon="icons/sample.gif"
category="org.eclipse.examples.nanami"
>
</view>
To
<view
name="Nanami View "
icon="icons/icon.gif"
category="org.eclipse.examples.nanami"
>
</view>
Then
<category
name="Sample Category"
>
</category>
To
<category
name="Nanami"
>
</category>
So that you can modify the view of classification, name and small icon.
Re-commissioning works, to see whether the purpose.
Sixth, change the view code.
View of the main code in SampleView.java this file.
SampleView inheritance ViewPart, the entry point in
public void createPartControl (Composite parent)
As used in this entry
org.eclipse.jface.viewers.TableViewer
This class seems to be jface controls, using up more difficult.
This class can be simplified into this:
package org.eclipse.examples.nanami.views;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.ui.part.ViewPart;
public class SampleView extends ViewPart {
public static final String ID = "org.eclipse.examples.nanami.views.SampleView";
private Canvas canvas;
public Control getControl() {
return canvas;
}
@Override
public void createPartControl(Composite parent) {
// Create a Canvas control
final Image image = new Image(Display.getCurrent(),
SampleView.class.getResourceAsStream("nanami.jpg"));
canvas = new Canvas(parent, SWT.BORDER);
canvas.setBounds(0, 0, 800, 600);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
event.gc.drawImage(image, 0, 0);
}
});
// Create the right-click menu
Menu menu = new Menu(parent.getShell(), SWT.POP_UP);
final MenuItem copyItem = new MenuItem(menu, SWT.PUSH);
copyItem.setText(" Version information ");
copyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
SampleView.this.showMessage("Nanami View , v0.0.1.\n"
+ "Copyright weimingtom. All rights reserved.");
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
}
});
getControl().setMenu(menu);
}
/**
* Pop-up dialog boxes
*
* @param message
*/
private void showMessage(String message) {
MessageDialog.openInformation(getControl().getShell(), "Nanami View ",
message);
}
@Override
public void setFocus() {
getControl().setFocus();
}
}
Then copy the picture to org.eclipse.examples.nanami.views nanami.jpg this package, the
Easy to read view this image.
The above code uses
public void createPartControl (Composite parent)
The parameters parent as a parent container,
Create a new Canvas, and then display the picture.
You can use the same method to create additional SWT controls.
Debugging results like this:
Seven, install one: directly to the local warehouse
Double-click META-INF/MANIFEST.MF,
Switch to the Overview,
Exporting part of the
1. ... Organize Manifests Wizard
Automatically modify the META-INF/MANIFEST.MF
Add Export-Package
4. ... Export Wizard
Choose Install into host. Repository
Although it is quite fast,
However, RCP can only be installed at compile on Eclipse RCP project.
Eight, the installation method two: Create a site project.
Another method is to create a plug-in update site, then let the local Eclipse installation.
File-> New-> Others
Select the Plug-in Development-> Feature Project
Project name: fill nanami_feature
Feature ID: fill org.eclipse.examples.nanami
Feature Name: fill Nanami
Click Next.
By Finisth.
Feature.xml settings in the pop-up switched to Plug-ins tab
Add just write plug-ins
org.eclipse.examples.nanami
Then Ctrl + S to save the configuration file.
Best to create a plug-in site.
File-> New-> Others
Select the Plug-in Development-> Update Site Porject
Project name: fill nanami
Click Finish to open site.xml configuration
Click Add Feature ... add just created Feature Project ID:
org.eclipse.examples.nanami
Press Ctrl + S to save.
At the top left corner of the Build All ... compilation.
Generated plugins, features several directories and jar files.
Project -> right click -> Properties -> Properties
Copy this site local path name, for example, my path is:
C: \ Documents and Settings \ Administrator \ workspace_rcp \ nanami
Help-> Install New Software ...
Click the Add button -> press the Local button
In the "Browse For Folder" dialog box enter the folder path above:
C: \ Documents and Settings \ Administrator \ workspace_rcp \ nanami
Location is populated:
file: / C: / Documents and Settings / Administrator / workspace_rcp / nanami /
Press OK to return just the dialog box:
Barring unforeseen circumstances, the following appeared Uncategorized-> Nanami this plug-in.
To speed up the installation, but my plugin does not rely on other plug-ins, so the following
Contact all update sites during install to find required software
Before removing the hook.
Check Nanami plug-in, and then click Next.
Select Nanami, click Next.
Select I accept the terms of the license agreement. Click Finish.
Pop-up warning box, ignore it, just press OK.
Then press the Restart Now to restart Eclipse.
Window-> Show View-> Others-> Nanami-> Nanami view
Open your own custom view that the effect is as follows:
If you want to uninstall the plug-in
Help-> About Eclipse-> Installation Details
Nanami then select the Uninstall ... uninstall it below.
Related Posts of Eclipse RCP plug-in programming to learn shorthand
-
Eclipse to run using the specified JVM m2eclipse plugin can not find tools.jar
Used the m2eclipse plug-ins using struts2 when com.sun necessary to rely on the default-tools.jar, specifically because at the struts-annotations bag designated default-tools.jar <profile> <id> default-tools.jar </ id> <activatio ...
-
in `require ': no such file to load - date / format
Learn today ruby, the ruby download and install, and then began to refer to the relevant entry-tutorial section of a small process running directly on the command line: ruby-e "print 'hello, yiditushe'", after the carriage return, prompt
-
Struts + Spring + Hibernate practice
Tools: Eclipse3.1, MyEclipse4.03, Tomcat5.5.9, Properties Editor plug-ins, MySql4.1.13 New construction: the name for the login Create Struts framework Create index.jsp, add a link to login.jsp Press Ctrl + N, to create login.jsp, LoginAction, the use of
-
Read "prototype.js 1.4 Developer Edition Manual" excerpt
Information Address: http://thinhunan.cnblogs.com/archive/2006/04/01/DeveloperNotesForPrototype.html Extract 1, $ F () function Function: Return of any form input control value, the parameters are the element id or the element itself Example: <script
-
common event in js
/ / 1: onblur event occurs when the object loses focus function upperCase () ( var x = document.getElementById ( "fname"). value document.getElementById ( "fname"). value = x.toUpperCase () ) </ script> Enter your name: <input
-
Workspace run under different Eclipse
Now do live more and more often required to use eclipse in java and ruby & rails project conducted between the tangential shear from the past, because in the rails project used a coloring Aptana preferences, the results open the java project sour ...
-
jBPM Development Getting Started Guide
Although the workflow is still immature stage of development, not even a recognized standard. But its application has already been launched in the Express, indicating the market's demand for job-flow framework are urgent and enormous. Backgrounds of o
-
Openfire Plugin Developer's Guide
Introduction Openfire features plug-ins are enhanced. This document is a guide to developers to create plug-ins. The structure of a plug-in Plug-ins Plug-ins openfireHome stored in the directory. When deploying a plug-in jar or war file, it will automatic












