Search in sources :

Example 16 with Property

use of org.eclipse.sapphire.Property in project liferay-ide by liferay.

the class NodeNameListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Element element = property.element();
    WorkflowDefinition workflow = element.adapt(WorkflowDefinition.class);
    Map<String, String> eventInfo = new HashMap<>();
    event.fillTracingInfo(eventInfo);
    String oldName = eventInfo.get("before");
    if (oldName == null) {
        oldName = _lastNodeNames.get(property);
    }
    String newName = eventInfo.get("after");
    List<Transition> allTransitions = new ArrayList<>();
    if (workflow != null) {
        ElementList<Condition> allConditions = workflow.getConditions();
        ElementList<Fork> allForks = workflow.getForks();
        ElementList<Join> allJoins = workflow.getJoins();
        ElementList<State> allStates = workflow.getStates();
        ElementList<Task> allTasks = workflow.getTasks();
        for (Condition condition : allConditions) {
            ElementList<Transition> conditionTransitions = condition.getTransitions();
            for (Transition transition : conditionTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Fork fork : allForks) {
            ElementList<Transition> forkTransitions = fork.getTransitions();
            for (Transition transition : forkTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Join join : allJoins) {
            ElementList<Transition> joinTransitions = join.getTransitions();
            for (Transition transition : joinTransitions) {
                allTransitions.add(transition);
            }
        }
        for (State state : allStates) {
            ElementList<Transition> stateTransitions = state.getTransitions();
            for (Transition transition : stateTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Task task : allTasks) {
            ElementList<Transition> taskTransitions = task.getTransitions();
            for (Transition transition : taskTransitions) {
                allTransitions.add(transition);
            }
        }
    }
    for (Transition transition : allTransitions) {
        String targetName = transition.getTarget().toString();
        if (targetName.equals(oldName)) {
            if (newName != null) {
                transition.setTarget(newName);
                if (_lastNodeNames.containsKey(property)) {
                    _lastNodeNames.remove(property);
                }
            } else {
                _lastNodeNames.put(property, oldName);
            }
        }
    }
}
Also used : Condition(com.liferay.ide.kaleo.core.model.Condition) Task(com.liferay.ide.kaleo.core.model.Task) Fork(com.liferay.ide.kaleo.core.model.Fork) HashMap(java.util.HashMap) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) State(com.liferay.ide.kaleo.core.model.State) Transition(com.liferay.ide.kaleo.core.model.Transition) Property(org.eclipse.sapphire.Property)

Aggregations

Property (org.eclipse.sapphire.Property)16 Element (org.eclipse.sapphire.Element)10 IProject (org.eclipse.core.resources.IProject)5 ValueProperty (org.eclipse.sapphire.ValueProperty)4 IType (org.eclipse.jdt.core.IType)3 JavaModelException (org.eclipse.jdt.core.JavaModelException)3 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)3 FilteredListener (org.eclipse.sapphire.FilteredListener)3 Listener (org.eclipse.sapphire.Listener)3 Value (org.eclipse.sapphire.Value)3 Path (org.eclipse.sapphire.modeling.Path)3 Hook (com.liferay.ide.hook.core.model.Hook)2 Transition (com.liferay.ide.kaleo.core.model.Transition)2 ArrayList (java.util.ArrayList)2 TypeSelectionExtension (org.eclipse.jdt.ui.dialogs.TypeSelectionExtension)2 Event (org.eclipse.sapphire.Event)2 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 PropertyDef (org.eclipse.sapphire.PropertyDef)2 JavaTypeKind (org.eclipse.sapphire.java.JavaTypeKind)2