-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
org.nodeclipse.java.avatarjs idea/code
- Loading branch information
Showing
20 changed files
with
590 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.nodeclipse.java.avatarjs</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Nodeclipse Java Avatar.js | ||
Bundle-SymbolicName: org.nodeclipse.java.avatarjs;singleton:=true | ||
Bundle-Version: 0.12.0.qualifier | ||
Bundle-Activator: org.nodeclipse.java.avatarjs.Activator | ||
Bundle-Vendor: Nodeclipse/Enide | ||
Require-Bundle: org.eclipse.ui, | ||
org.eclipse.core.runtime, | ||
org.eclipse.ui.ide, | ||
org.eclipse.ui.editors, | ||
org.eclipse.debug.ui, | ||
org.nodeclipse.ui, | ||
org.nodeclipse.debug, | ||
org.eclipse.wst.jsdt.core;bundle-version="1.1.102", | ||
org.eclipse.wst.jsdt.ui, | ||
org.nodeclipse.common | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | ||
Bundle-ActivationPolicy: lazy | ||
Import-Package: org.nodeclipse.debug.launch, | ||
org.nodeclipse.debug.util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
# org.nodeclipse.java.avatarjs | ||
|
||
Quick and dirty idea/code to launch .js with java 8 and Avatar.js lib | ||
Not yet finished, reason: | ||
running with Java/Avatar.js is launching like `java -Djava.library.path=lib -jar lib/avatar-js.jar helloWorld.js` | ||
- libs maybe missing or in other folder, | ||
- embedding not released binaries in Eclipse plugin seems bad idea (also there are native lib for every OS) | ||
- would require searching for project root (Node can actually run from any folder) | ||
|
||
|
||
## Usage | ||
|
||
Read at <> | ||
|
||
Read also built-in <kbd>F1</kbd> | ||
and [Online Help](https://github.com/Nodeclipse/nodeclipse-1/tree/master/org.nodeclipse.help/contents#intro) | ||
|
||
### Links | ||
|
||
- http://www.infoq.com/articles/nashorn | ||
- https://blogs.oracle.com/theaquarium/entry/project_avatar_is_open_source | ||
- https://avatar.java.net/ | ||
- http://blog.jonasbandi.net/2014/03/running-nodejs-applications-on-jvm-with.html | ||
- http://strongloop.com/strongblog/how-to-run-node-js-on-the-jvm-with-avatar-js-and-loopback/ | ||
|
||
## Developing | ||
|
||
Depends on `.ui` and `.common` | ||
|
||
`Import-Package: org.nodeclipse.debug.launch` in MANIFEST.MF is for `org.nodeclipse.debug.launch.LaunchConfigurationEnvironmentTab` | ||
|
||
org.nodeclipse.debug.util is for in org.nodeclipse.phantomjs.launch.LaunchConfigurationDelegate | ||
|
||
TODO copy that Class or make .debug module general (not Node.js related) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = plugin.xml,\ | ||
META-INF/,\ | ||
.,\ | ||
icons/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+463 Bytes
...nodeclipse.java.avatarjs/icons/java_16x16_bottom_right_corner_run_half_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+565 Bytes
...eclipse.java.avatarjs/icons/nashorn_16x16_bottom_right_corner_run_half_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+630 Bytes
org.nodeclipse.java.avatarjs/icons/nashorn_16x16_top_right_corner_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
|
||
<extension | ||
point="org.eclipse.ui.editors"> | ||
<editor | ||
class="org.nodeclipse.ui.editors.NodeEditor" | ||
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor" | ||
default="true" | ||
extensions="ajs" | ||
icon="icons/java_16x16.png" | ||
id="org.nodeclipse.java.avatarjs.editors.JJSEditor" | ||
name="Avatar.js Editor"> | ||
</editor> | ||
</extension> | ||
|
||
<extension | ||
point="org.eclipse.debug.core.launchConfigurationTypes"> | ||
<launchConfigurationType | ||
delegate="org.nodeclipse.java.avatarjs.launch.LaunchConfigurationDelegate" | ||
id="org.nodeclipse.java.avatarjs.launch.LaunchConfigurationType" | ||
modes="run, debug" | ||
name="Avatar.js Application"> | ||
</launchConfigurationType> | ||
</extension> | ||
<extension | ||
point= "org.eclipse.debug.ui.launchConfigurationTypeImages" > | ||
<launchConfigurationTypeImage | ||
configTypeID= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationType" | ||
icon= "icons/java_16x16_bottom_right_corner_run_half_size.png" | ||
id= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationTypeImage" > | ||
</launchConfigurationTypeImage> | ||
</extension> | ||
<!-- avatar.js run/debug --> | ||
<extension | ||
point= "org.eclipse.debug.ui.launchShortcuts" > | ||
<shortcut | ||
class= "org.nodeclipse.java.avatarjs.launch.LaunchShortcut" | ||
icon= "icons/nashorn_16x16_bottom_right_corner_run_half_size.png" | ||
id= "org.nodeclipse.debug.launch.LaunchShortcut" | ||
label= "Avatar.js Application" | ||
modes= "run, debug" > | ||
<configurationType | ||
id= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationType" > | ||
</configurationType> | ||
<contextualLaunch> | ||
<enablement> | ||
<with | ||
variable= "selection" > | ||
<count | ||
value= "1" > | ||
</count> | ||
<iterate> | ||
<or> | ||
<test | ||
property= "org.eclipse.debug.ui.matchesPattern" | ||
value= "*.js" > | ||
</test> | ||
<test | ||
property= "org.eclipse.debug.ui.matchesPattern" | ||
value= "*.jjs" > | ||
</test> | ||
</or> | ||
</iterate> | ||
</with> | ||
</enablement> | ||
</contextualLaunch> | ||
</shortcut> | ||
</extension> | ||
|
||
|
||
<extension | ||
point="org.eclipse.debug.ui.launchConfigurationTabGroups"> | ||
<launchConfigurationTabGroup | ||
class= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationTabGroup" | ||
id= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationTabGroup" | ||
type= "org.nodeclipse.java.avatarjs.launch.LaunchConfigurationType" > | ||
</launchConfigurationTabGroup> | ||
</extension> | ||
|
||
<extension | ||
point="org.eclipse.ui.preferencePages"> | ||
<page | ||
category="org.nodeclipse.ui.preferences.NodePreferencePage" | ||
class="org.nodeclipse.java.avatarjs.preferences.AvatarjsPreferencePage" | ||
id="org.nodeclipse.java.avatarjs.preferences.AvatarjsPreferencePage" | ||
name="Avatar.js"> | ||
</page> | ||
</extension> | ||
|
||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.nodeclipse.nodeclipse-1</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.12.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.nodeclipse.java.avatarjs</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
<name>org.nodeclipse.java.avatarjs</name> | ||
<description>org.nodeclipse.java.avatarjs</description> | ||
</project> | ||
|
51 changes: 51 additions & 0 deletions
51
org.nodeclipse.java.avatarjs/src/org/nodeclipse/java/avatarjs/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.nodeclipse.java.avatarjs; | ||
|
||
import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
import org.nodeclipse.java.avatarjs.preferences.AvatarjsConstants; | ||
import org.osgi.framework.BundleContext; | ||
|
||
/** | ||
* The activator class controls the plug-in life cycle | ||
*/ | ||
public class Activator extends AbstractUIPlugin { | ||
|
||
// The plug-in ID | ||
public static final String PLUGIN_ID = AvatarjsConstants.PLUGIN_ID; | ||
|
||
// The shared instance | ||
private static Activator plugin; | ||
|
||
/** | ||
* The constructor | ||
*/ | ||
public Activator() { | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | ||
*/ | ||
public void start(BundleContext context) throws Exception { | ||
super.start(context); | ||
plugin = this; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | ||
*/ | ||
public void stop(BundleContext context) throws Exception { | ||
plugin = null; | ||
super.stop(context); | ||
} | ||
|
||
/** | ||
* Returns the shared instance | ||
* | ||
* @return the shared instance | ||
*/ | ||
public static Activator getDefault() { | ||
return plugin; | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
...se.java.avatarjs/src/org/nodeclipse/java/avatarjs/launch/LaunchConfigurationDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package org.nodeclipse.java.avatarjs.launch; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.debug.core.DebugPlugin; | ||
import org.eclipse.debug.core.ILaunch; | ||
import org.eclipse.debug.core.ILaunchConfiguration; | ||
import org.eclipse.debug.core.ILaunchManager; | ||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; | ||
import org.eclipse.debug.core.model.RuntimeProcess; | ||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.nodeclipse.common.preferences.CommonDialogs; | ||
import org.nodeclipse.debug.util.Constants; | ||
import org.nodeclipse.debug.util.VariablesUtil; | ||
import org.nodeclipse.java.avatarjs.preferences.AvatarjsConstants; | ||
import org.nodeclipse.ui.Activator; | ||
//import org.nodeclipse.ui.preferences.PreferenceConstants; | ||
import org.nodeclipse.ui.util.NodeclipseConsole; | ||
|
||
/** | ||
* Launching `jjs` from Java 8.<br> | ||
* see LaunchConfigurationDelegate in .debug and .phantomjs module for comparison. | ||
* | ||
* @since 0.7 | ||
* @author Paul Verest | ||
*/ | ||
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate { | ||
|
||
@Override | ||
public void launch(ILaunchConfiguration configuration, String mode, | ||
ILaunch launch, IProgressMonitor monitor) throws CoreException { | ||
|
||
//NodeclipseConsole.write("launch jjs\n"); | ||
|
||
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); | ||
boolean isDebugMode = mode.equals(ILaunchManager.DEBUG_MODE); | ||
|
||
// Using configuration to build command line | ||
List<String> cmdLine = new ArrayList<String>(); | ||
|
||
String jjsPath= preferenceStore.getString(AvatarjsConstants.JAVA_PATH); | ||
// Check if the node location is correctly configured | ||
File jjsFile = new File(jjsPath); | ||
if(!jjsFile.exists()){ | ||
// If the location is not valid than show a dialog which prompts the user to goto the preferences page | ||
// Dialogs.showPreferencesDialog("path to jjs util from Java 8 runtime is not correctly configured.\n\n" | ||
// + "Please goto Window -> Prefrences -> Nodeclipse and configure the correct location under 'JJS path:'"); | ||
CommonDialogs.showPreferencesDialog(AvatarjsConstants.PREFERENCES_PAGE, | ||
"Java 8 Nashorn jjs location is not correctly configured.\n\n" | ||
+ "Please goto Window -> Preferences -> "+AvatarjsConstants.PREFERENCE_PAGE_NAME | ||
+" and configure the correct location"); | ||
return; | ||
} | ||
cmdLine.add(jjsPath); | ||
|
||
if (isDebugMode) { | ||
//TODO research how to debug | ||
} | ||
|
||
String file = configuration.getAttribute("KEY_FILE_PATH", ""); | ||
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString(); | ||
// path is relative, so cannot find it, unless get absolute path | ||
cmdLine.add(filePath); | ||
|
||
File workingPath = null; | ||
String workingDirectory = configuration.getAttribute(Constants.ATTR_WORKING_DIRECTORY, ""); | ||
if(workingDirectory.length() > 0) { | ||
workingDirectory = VariablesUtil.resolveValue(workingDirectory); | ||
if(workingDirectory != null) { | ||
workingPath = new File(workingDirectory); | ||
} | ||
} | ||
if (workingPath == null){ | ||
workingPath = (new File(filePath)).getParentFile(); | ||
} | ||
|
||
Map<String, String> envm = new HashMap<String, String>(); | ||
envm = configuration.getAttribute(Constants.ATTR_ENVIRONMENT_VARIABLES, envm); | ||
String[] envp = new String[envm.size()]; | ||
int idx = 0; | ||
for(String key : envm.keySet()) { | ||
String value = envm.get(key); | ||
envp[idx++] = key + "=" + value; | ||
} | ||
|
||
|
||
for(String s : cmdLine) NodeclipseConsole.write(s+" "); | ||
NodeclipseConsole.write("\n"); | ||
|
||
String[] cmds = {}; | ||
cmds = cmdLine.toArray(cmds); | ||
// Launch a process to debug.eg, | ||
Process p = DebugPlugin.exec(cmds, workingPath, envp); | ||
RuntimeProcess process = (RuntimeProcess)DebugPlugin.newProcess(launch, p, AvatarjsConstants.PROCESS_MESSAGE); | ||
if (isDebugMode) { | ||
//TODO research how to debug | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.