Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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"
(New page: =Mapping PHP functions to Java methods= * Install the plugin * Create a new plugin project * Use the template "Hello, World" * In the '''Dependencies''' tab add '''org.eclipse.soc2007.phpe...) |
(→Steps to reproduce) |
||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Mapping PHP functions to Java methods= | =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 | * Install the plugin | ||
− | * Create a new plugin project | + | * Create a new plugin project (Name it '''testproject''') |
* Use the template "Hello, World" | * Use the template "Hello, World" | ||
* In the '''Dependencies''' tab add '''org.eclipse.soc2007.phpengine''' as a Required Plugin-ins | * In the '''Dependencies''' tab add '''org.eclipse.soc2007.phpengine''' as a Required Plugin-ins | ||
+ | * Create a PHP file | ||
+ | ** Create a 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''' | ||
+ | ** Annotate the class with: | ||
+ | @ScriptableClass( | ||
+ | fileName="testproject/actions/helloWorld.php" | ||
+ | ) | ||
+ | ** Add a method '''String getHelloWorld(String name);''' | ||
+ | ** Annotate the method with: | ||
+ | @ScriptableMethod( | ||
+ | functionName="helloWorld" | ||
+ | ) | ||
+ | * The template should have created a Java file testproject/actions/SampleAction.java | ||
+ | public class SampleAction implements IWorkbenchWindowActionDelegate { | ||
+ | * Add a private field | ||
+ | private HelloWorld helloWorld; | ||
+ | * Modify the constructor (Activator is testproject.Activator) | ||
+ | helloWorld = (HelloWorld)PhpScriptableFactory.newInstance( | ||
+ | HelloWorld.class); | ||
+ | * Modify the '''run''' method | ||
+ | public void run(IAction action) { | ||
+ | MessageDialog.openInformation( | ||
+ | window.getShell(), | ||
+ | "SamplePlugin Plug-in", | ||
+ | helloWorld.getHelloWorld("Your_Name")); | ||
+ | } | ||
+ | * '''Launch the Run''' | ||
+ | * From the top menu choose '''Sample Menu -> Sample Action''' | ||
+ | * Use should see a dialog telling you "Hello World 'YourName'" | ||
+ | * Not seeing the desired output? | ||
+ | ** Be sure to check if the installed plugin and the fragment are in the Run plugins list. |
Latest revision as of 15:33, 5 August 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 a PHP file
- Create a 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
- Annotate the class with:
@ScriptableClass( fileName="testproject/actions/helloWorld.php" )
- Add a method String getHelloWorld(String name);
- Annotate the method with:
@ScriptableMethod( functionName="helloWorld" )
- The template should have created a Java file testproject/actions/SampleAction.java
public class SampleAction implements IWorkbenchWindowActionDelegate {
- Add a private field
private HelloWorld helloWorld;
- Modify the constructor (Activator is testproject.Activator)
helloWorld = (HelloWorld)PhpScriptableFactory.newInstance( HelloWorld.class);
- Modify the run method
public void run(IAction action) { MessageDialog.openInformation( window.getShell(), "SamplePlugin Plug-in", helloWorld.getHelloWorld("Your_Name")); }
- Launch the Run
- From the top menu choose Sample Menu -> Sample Action
- Use should see a dialog telling you "Hello World 'YourName'"
- Not seeing the desired output?
- Be sure to check if the installed plugin and the fragment are in the Run plugins list.