Search in sources :

Example 6 with Scriptable

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;
}
Also used : IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Example 7 with Scriptable

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();
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent) Presentation(org.eclipse.sapphire.ui.Presentation) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Event(org.eclipse.sapphire.Event) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Example 8 with Scriptable

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");
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Example 9 with Scriptable

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;
}
Also used : ScriptLanguageType(com.liferay.ide.kaleo.core.model.ScriptLanguageType) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Example 10 with Scriptable

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;
}
Also used : Field(java.lang.reflect.Field) EnumSerialization(org.eclipse.sapphire.modeling.annotations.EnumSerialization) ScriptLanguageType(com.liferay.ide.kaleo.core.model.ScriptLanguageType) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Aggregations

Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)11 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)5 ResourceAction (com.liferay.ide.kaleo.core.model.ResourceAction)3 Role (com.liferay.ide.kaleo.core.model.Role)3 User (com.liferay.ide.kaleo.core.model.User)3 Assignable (com.liferay.ide.kaleo.core.model.Assignable)2 Task (com.liferay.ide.kaleo.core.model.Task)2 IKaleoEditorHelper (com.liferay.ide.kaleo.ui.IKaleoEditorHelper)2 Element (org.eclipse.sapphire.Element)2 Action (com.liferay.ide.kaleo.core.model.Action)1 RoleName (com.liferay.ide.kaleo.core.model.RoleName)1 RoleType (com.liferay.ide.kaleo.core.model.RoleType)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)1 ChangeTaskAssignmentsOp (com.liferay.ide.kaleo.core.op.ChangeTaskAssignmentsOp)1 Field (java.lang.reflect.Field)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ElementHandle (org.eclipse.sapphire.ElementHandle)1 Event (org.eclipse.sapphire.Event)1 FilteredListener (org.eclipse.sapphire.FilteredListener)1