Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Framework to develop simple Eclipse plugin using PHP/PHPinJava"
(→Steps to reproduce) |
(→Steps to reproduce) |
||
Line 13: | Line 13: | ||
* Create the PHP file | * Create the PHP file | ||
** Create file helloWorld.php under project root. | ** Create file helloWorld.php under project root. | ||
− | ** Add contents "<? echo "Hello, World | + | ** Add contents "<? echo "Hello, World Eclipse from PHP"; ?>" |
* Create a new interface | * Create a new interface | ||
** Use the package '''testproject.actions''' | ** Use the package '''testproject.actions''' | ||
Line 42: | Line 42: | ||
return rtrn; | return rtrn; | ||
} | } | ||
+ | * '''Launch the Run''' | ||
+ | * From the top menu choose '''Sample Menu -> Sample Action''' | ||
+ | * Use should see the following dialog [[Image:helloFromEclipse.png]] |
Revision as of 00:54, 12 July 2007
Mapping PHP functions to Java methods
This is a step by step tutorial showing the capabilities of the current release.
Goals
- Develop a Hello, World! plugin
- The String "Hello, World!" is generated from evaluation a PHP script
Steps to reproduce
- Install the plugin
- Create a new plugin project (Name it testproject)
- Use the template "Hello, World"
- In the Dependencies tab add org.eclipse.soc2007.phpengine as a Required Plugin-ins
- Create the PHP file
- Create file helloWorld.php under project root.
- Add contents "<? echo "Hello, World Eclipse from PHP"; ?>"
- Create a new interface
- Use the package testproject.actions
- Name it HelloWorld
- Make it extend org.eclipse.soc2007.phpscriptengine.Scriptable
- Add a method String getHelloWorld(String rtrn);
- Annotate the method with:
@ScriptableAnnotation( fileName="helloWorld.php", output="true" )
- The template should have created a Java class testproject.actions.SampleAction.java
- Add a private field
private HelloWorld helloWorld;
- Modify the constructor
public SampleAction() { helloWorld = (HelloWorld)ScriptUtil.registerProxy(this, HelloWorld.class, Activator.class.getClassLoader()); }
- Modify the run method
public void run(IAction action) { MessageDialog.openInformation( window.getShell(), "SamplePlugin Plug-in", helloWorld.getHelloWorld(null)); }
- Implement the getHelloWorld(String) method
public String getHelloWorld(String rtrn) { return rtrn; }