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"
(→Steps to reproduce) |
(→Steps to reproduce) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
* 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 | + | * Create a PHP file |
− | ** Create file helloWorld.php under project root. | + | ** Create a file helloWorld.php under project root. |
** Add contents "<? echo "Hello, World Eclipse from PHP"; ?>" | ** 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''' | ||
** Name it '''HelloWorld''' | ** Name it '''HelloWorld''' | ||
− | ** | + | ** Annotate the class with: |
− | ** Add a method '''String getHelloWorld(String | + | @ScriptableClass( |
+ | fileName="testproject/actions/helloWorld.php" | ||
+ | ) | ||
+ | ** Add a method '''String getHelloWorld(String name);''' | ||
** Annotate the method with: | ** Annotate the method with: | ||
− | @ | + | @ScriptableMethod( |
− | + | functionName="helloWorld" | |
− | + | ||
) | ) | ||
− | * The template should have created a Java | + | * The template should have created a Java file testproject/actions/SampleAction.java |
− | + | public class SampleAction implements IWorkbenchWindowActionDelegate { | |
+ | * Add a private field | ||
private HelloWorld helloWorld; | private HelloWorld helloWorld; | ||
− | * Modify the constructor | + | * Modify the constructor (Activator is testproject.Activator) |
− | + | helloWorld = (HelloWorld)PhpScriptableFactory.newInstance( | |
− | + | HelloWorld.class); | |
− | + | ||
* Modify the '''run''' method | * Modify the '''run''' method | ||
public void run(IAction action) { | public void run(IAction action) { | ||
Line 36: | Line 38: | ||
window.getShell(), | window.getShell(), | ||
"SamplePlugin Plug-in", | "SamplePlugin Plug-in", | ||
− | helloWorld.getHelloWorld( | + | helloWorld.getHelloWorld("Your_Name")); |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
* '''Launch the Run''' | * '''Launch the Run''' | ||
* From the top menu choose '''Sample Menu -> Sample Action''' | * From the top menu choose '''Sample Menu -> Sample Action''' | ||
− | * Use should see | + | * 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.