Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 729d16f6367abc41f5780bf00e286769b5c08b04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*****************************************************************************
 * Copyright (c) 2015 CEA LIST and others.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   CEA LIST - Initial API and implementation
 *   
 *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.dnd.smart.graph.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.papyrus.uml.diagram.dnd.smart.graph.api.AbstractUml2GraphServices;
import org.eclipse.papyrus.uml.diagram.dnd.smart.graph.model.NodeEClass;
import org.eclipse.papyrus.uml.diagram.dnd.smart.graph.model.Path;

/**
 * One basic implementation to retrieve Path of actions given a set of source/target elements
 * @author flefevre
 *
 */
public class GenericUml2GraphServices extends AbstractUml2GraphServices {

	
	public GenericUml2GraphServices()
	{
		super();
	}
	
	public GenericUml2GraphServices(int depth, int threshold)
	{
		super(depth,threshold);
	}

	/**
	 * @see org.eclipse.papyrus.uml.diagram.dnd.smart.graph.api.Uml2GraphServices#proposedActionsFromDnd(org.eclipse.emf.ecore.EClass, org.eclipse.emf.ecore.EClass)
	 *
	 * @param source
	 * @param target
	 * @return
	 */
	public Set<Path> proposedActionsFromDnd(EClass source, EClass target) {
		//Retrieve the node from the graph
		NodeEClass mySourceNode = uml2Graph.getNodeEClassMap().get(source.getInstanceTypeName());
		NodeEClass myTargetNode = uml2Graph.getNodeEClassMap().get(target.getInstanceTypeName());
		//Compute the paths and filter them
		return proposedActionsFromDnd(mySourceNode, myTargetNode) ;
	}

	/**
	 * @see org.eclipse.papyrus.uml.diagram.dnd.smart.graph.api.Uml2GraphServices#proposedActionsFromDnd(java.lang.String, java.lang.String)
	 *
	 * @param source
	 * @param target
	 * @return
	 */
	public Set<Path> proposedActionsFromDnd(String source, String target) {
		NodeEClass mySourceNode = uml2Graph.getNodeEClassMap().get(source);
		NodeEClass myTargetNode = uml2Graph.getNodeEClassMap().get(target);
		return proposedActionsFromDnd(mySourceNode, myTargetNode);
	}

	/**
	 * @see org.eclipse.papyrus.uml.diagram.dnd.smart.graph.api.Uml2GraphServices#proposedLitteralActionsFromDnd(java.lang.String, java.lang.String)
	 *
	 * @param source
	 * @param target
	 * @return
	 */
	public Collection<String> proposedLitteralActionsFromDnd(String source, String target) {
		Collection<String> result = new ArrayList<String>();
		
		Set<Path> paths= proposedActionsFromDnd(source, target);
		
		for(Path p :paths){
			result.add(p.getName()+"\n");
		}
		return result;
	}

}

Back to the top