use of com.liferay.ide.kaleo.core.model.Scriptable in project liferay-ide by liferay.
the class ScriptableOpenActionHandler method run.
@Override
protected Object run(Presentation context) {
try {
Scriptable scriptable = scriptable(context);
if (scriptable != null) {
IKaleoEditorHelper kaleoEditorHelper = KaleoUI.getKaleoEditorHelper(scriptable.getScriptLanguage().text(true));
kaleoEditorHelper.openEditor(context.part(), scriptable, Scriptable.PROP_SCRIPT);
}
} catch (Exception e) {
KaleoUI.logError("Could not open script editor.", e);
}
return null;
}
use of com.liferay.ide.kaleo.core.model.Scriptable in project liferay-ide by liferay.
the class ActionsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
ElementList<Action> actions = getActions();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Action action : actions) {
action.getName().attach(_listener);
factory.add(new ScriptableOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = action.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(Action.TYPE.image());
}
@Override
protected Scriptable scriptable(Presentation context) {
return action;
}
});
}
return factory.result();
}
use of com.liferay.ide.kaleo.core.model.Scriptable in project liferay-ide by liferay.
the class ScriptPropertyEditorCondition method initCondition.
@Override
protected void initCondition(ISapphirePart part, String parameter) {
super.initCondition(part, parameter);
/*
* TODO replace with visible when
*
* SapphireIfElseDirectiveDef ifDef =
* this.getPart().definition().nearest( SapphireIfElseDirectiveDef.class
* );
*
* String param = ifDef.getConditionParameter().content();
*
* for( ScriptLanguageType type :
* ScriptLanguageType.class.getEnumConstants() ) { if(
* type.name().equals( param ) ) { this.paramType = type; break; } }
*/
Scriptable scriptable = _scriptable();
Listener listener = new FilteredListener<PropertyContentEvent>() {
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
ScriptPropertyEditorCondition.this.updateConditionState();
}
};
scriptable.attach(listener, "ScriptLanguage");
}
use of com.liferay.ide.kaleo.core.model.Scriptable in project liferay-ide by liferay.
the class ScriptPropertyEditorCondition method evaluate.
@Override
protected boolean evaluate() {
if (_paramType != null) {
Scriptable scriptable = _scriptable();
ScriptLanguageType scriptLanguageType = scriptable.getScriptLanguage().content(true);
if (scriptLanguageType == null) {
scriptLanguageType = ScriptLanguageType.valueOf(KaleoModelUtil.getDefaultValue(scriptable, KaleoCore.DEFAULT_SCRIPT_LANGUAGE_KEY, ScriptLanguageType.GROOVY));
}
if (_paramType.equals(scriptLanguageType)) {
return true;
}
}
return false;
}
use of com.liferay.ide.kaleo.core.model.Scriptable in project liferay-ide by liferay.
the class ScriptPropertyEditorInput method getScriptLanguage.
public String getScriptLanguage() {
String retval = null;
try {
Scriptable scriptable = _modelElement.nearest(Scriptable.class);
Value<ScriptLanguageType> languageType = scriptable.getScriptLanguage();
ScriptLanguageType scriptType = languageType.content();
Class<?> scriptTypeClass = scriptType.getClass();
Field field = scriptTypeClass.getFields()[scriptType.ordinal()];
EnumSerialization enumValue = field.getAnnotation(EnumSerialization.class);
retval = enumValue.primary();
} catch (Exception e) {
}
return retval;
}
Aggregations