forked from ObeoNetwork/UML-Designer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ObeoNetwork#46 add a type to actors in use case diagram
make a difference between human actor and non human actor - remove existing tool for actor creation - create a tool for human actor abble to create new actor or convert existing actor to "human" - create a tool for non human actor abble to create new actor or convert existing actor to "non human"
- Loading branch information
Showing
12 changed files
with
571 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...twork.dsl.uml2.design/src/org/obeonetwork/dsl/uml2/design/api/services/ActorServices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014 Obeo. | ||
* 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: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.obeonetwork.dsl.uml2.design.api.services; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.uml2.uml.Actor; | ||
|
||
/** | ||
* Manage the actor mapping according to human or not. | ||
* | ||
* @author Frederic Bats <a href="mailto:frederic.bats@obeo.fr">frederic.bats@obeo.fr</a> | ||
*/ | ||
public class ActorServices { | ||
/** | ||
* Human Actor. | ||
*/ | ||
public static final String HUMAN = "Human"; //$NON-NLS-1$ | ||
|
||
/** | ||
* Set as a Human. | ||
* | ||
* @param actor | ||
* Actor to set | ||
*/ | ||
public void addActorHumanKeyword(Actor actor) { | ||
addActorKeyword(actor, ActorServices.HUMAN); | ||
} | ||
/** | ||
* Add an actor keyword. | ||
* | ||
* @param actor | ||
* Actor | ||
* @param type | ||
* Keyword | ||
*/ | ||
private void addActorKeyword(Actor actor, String type) { | ||
clearActorKeywords(actor); | ||
actor.addKeyword(type); | ||
} | ||
|
||
private void clearActorKeywords(Actor actor) { | ||
actor.removeKeyword(HUMAN); | ||
} | ||
|
||
private boolean hasKeyword(EObject actor, String keyword) { | ||
if (actor instanceof Actor) { | ||
return ((Actor)actor).getKeywords().contains(keyword); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Check if an object is an Actor. | ||
* | ||
* @param actor | ||
* actor | ||
* @return True if element is a human | ||
*/ | ||
public boolean isActor(EObject actor) { | ||
|
||
return actor instanceof Actor; | ||
} | ||
|
||
/** | ||
* Check if an actor is a human. | ||
* | ||
* @param actor | ||
* actor | ||
* @return True if element is a human | ||
*/ | ||
public boolean isHumanActor(EObject actor) { | ||
return hasKeyword(actor, HUMAN); | ||
} | ||
|
||
/** | ||
* Check if an object is not an Actor. | ||
* | ||
* @param actor | ||
* actor | ||
* @return True if element is a human | ||
*/ | ||
public boolean isNotAnActor(EObject actor) { | ||
|
||
return !isActor(actor); | ||
} | ||
|
||
/** | ||
* Check if an actor is not a human. | ||
* | ||
* @param actor | ||
* actor | ||
* @return True if element is a human | ||
*/ | ||
public boolean isNotHumanActor(EObject actor) { | ||
return !isHumanActor(actor); | ||
} | ||
|
||
/** | ||
* Set as a non Human. | ||
* | ||
* @param actor | ||
* Actor to set | ||
*/ | ||
public void removeActorHumanKeyword(Actor actor) { | ||
if (isHumanActor(actor)){ | ||
clearActorKeywords(actor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.