Search in sources :

Example 1 with IKaleoEditorHelper

use of com.liferay.ide.kaleo.ui.IKaleoEditorHelper in project liferay-ide by liferay.

the class EditNotificationHandler method edit.

@Override
public Object edit(Element modelElement, Presentation context) {
    Notification notification = modelElement.nearest(Notification.class);
    IKaleoEditorHelper kaleoEditorHelper = KaleoUI.getKaleoEditorHelper(notification.getTemplateLanguage().text(true));
    kaleoEditorHelper.openEditor(getPart(), notification, Notification.PROP_TEMPLATE);
    return null;
}
Also used : IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) Notification(com.liferay.ide.kaleo.core.model.Notification)

Example 2 with IKaleoEditorHelper

use of com.liferay.ide.kaleo.ui.IKaleoEditorHelper in project liferay-ide by liferay.

the class EditScriptActionHandler method edit.

@Override
public Object edit(Element modelElement, Presentation context) {
    Scriptable scriptable = modelElement.nearest(Scriptable.class);
    IKaleoEditorHelper kaleoEditorHelper = KaleoUI.getKaleoEditorHelper(scriptable.getScriptLanguage().text(true));
    kaleoEditorHelper.openEditor(context.part(), scriptable, Action.PROP_SCRIPT);
    return null;
}
Also used : IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Example 3 with IKaleoEditorHelper

use of com.liferay.ide.kaleo.ui.IKaleoEditorHelper 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 4 with IKaleoEditorHelper

use of com.liferay.ide.kaleo.ui.IKaleoEditorHelper in project liferay-ide by liferay.

the class StateNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    NewStateNodeOp newStateNodeOp = op.nearest(NewStateNodeOp.class);
    NewStateNode newStateNode = newNodeFromWizard.nearest(NewStateNode.class);
    State state = newNode.nearest(State.class);
    if ((newStateNode != null) && (state != null)) {
        state.setName(newStateNode.getName().content());
        NewStateType newStateType = newStateNodeOp.getType().content();
        if (newStateType.equals(NewStateType.START)) {
            state.setInitial(true);
        } else if (newStateType.equals(NewStateType.END)) {
            state.setEnd(true);
        }
        String workflowStatus = newStateNodeOp.getWorkflowStatus().content(false);
        if (!empty(workflowStatus)) {
            Action newAction = state.getActions().insert();
            newAction.setName(state.getName().content());
            newAction.setScriptLanguage(KaleoModelUtil.getDefaultValue(state, KaleoCore.DEFAULT_SCRIPT_LANGUAGE_KEY, ScriptLanguageType.GROOVY));
            newAction.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
            IKaleoEditorHelper editorHelper = KaleoUI.getKaleoEditorHelper(newAction.getScriptLanguage().text());
            if (editorHelper != null) {
                try {
                    File statusUpdatesFolder = new File(FileLocator.toFileURL(Platform.getBundle(editorHelper.getContributorName()).getEntry("palette/Status Updates")).getFile());
                    File statusSnippet = new File(statusUpdatesFolder, workflowStatus + "." + editorHelper.getFileExtension());
                    if (FileUtil.exists(statusSnippet)) {
                        newAction.setScript(FileUtil.readContents(statusSnippet, true));
                    }
                } catch (Exception e) {
                }
            }
        }
        if (!newStateType.equals(NewStateType.END) && (newStateNodeOp.getExitTransitionName().content() != null)) {
            Transition newTransition = state.getTransitions().insert();
            newTransition.setTarget(newStateNodeOp.getExitTransitionName().content());
            newTransition.setName(newStateNodeOp.getExitTransitionName().content());
        }
    }
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) NewStateNodeOp(com.liferay.ide.kaleo.core.op.NewStateNodeOp) State(com.liferay.ide.kaleo.core.model.State) IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) NewStateType(com.liferay.ide.kaleo.core.op.NewStateType) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) NewStateNode(com.liferay.ide.kaleo.core.op.NewStateNode) File(java.io.File)

Example 5 with IKaleoEditorHelper

use of com.liferay.ide.kaleo.ui.IKaleoEditorHelper in project liferay-ide by liferay.

the class TemplateOpenActionHandler method run.

@Override
protected Object run(Presentation context) {
    try {
        Notification notification = notification(context);
        IKaleoEditorHelper kaleoEditorHelper = KaleoUI.getKaleoEditorHelper(notification.getTemplateLanguage().text(true));
        kaleoEditorHelper.openEditor(context.part(), notification, Notification.PROP_TEMPLATE);
    } catch (Exception e) {
        KaleoUI.logError("Could not open template editor.", e);
    }
    return null;
}
Also used : IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) Notification(com.liferay.ide.kaleo.core.model.Notification)

Aggregations

IKaleoEditorHelper (com.liferay.ide.kaleo.ui.IKaleoEditorHelper)5 Notification (com.liferay.ide.kaleo.core.model.Notification)2 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)2 Action (com.liferay.ide.kaleo.core.model.Action)1 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)1 State (com.liferay.ide.kaleo.core.model.State)1 Transition (com.liferay.ide.kaleo.core.model.Transition)1 NewStateNode (com.liferay.ide.kaleo.core.op.NewStateNode)1 NewStateNodeOp (com.liferay.ide.kaleo.core.op.NewStateNodeOp)1 NewStateType (com.liferay.ide.kaleo.core.op.NewStateType)1 File (java.io.File)1