-
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scripts category (rename to "Run & Process")
Signed-off-by: Yannick Schaus <github@schaus.net>
- Loading branch information
Showing
3 changed files
with
83 additions
and
63 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
19 changes: 19 additions & 0 deletions
19
bundles/org.openhab.ui/web/src/assets/definitions/blockly/utils.js
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 @@ | ||
import Blockly from 'blockly' | ||
|
||
/* | ||
* function that allow to call classes within the osgi container | ||
* e.g. service -> 'ruleManager', class -> 'org.openhab.core.automation.RuleManager' | ||
*/ | ||
export function addOSGiService (serviceName, serviceClass) { | ||
const addServiceName = Blockly.JavaScript.provideFunction_( | ||
'addFrameworkService', [ | ||
'function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ + ' (serviceClass) {', | ||
' var bundleContext = Java.type(\'org.osgi.framework.FrameworkUtil\').getBundle(scriptExtension.class).getBundleContext();', | ||
' var serviceReference = bundleContext.getServiceReference(serviceClass);', | ||
' return bundleContext.getService(serviceReference);', | ||
'}' | ||
]) | ||
return Blockly.JavaScript.provideFunction_( | ||
serviceName, | ||
[`var ${Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_} = ${addServiceName}('${serviceClass}');`]) | ||
} |
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