Skip to content

Commit

Permalink
Task #209 - improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
fran_tb authored and fran_tb committed Apr 4, 2024
1 parent d1b3302 commit ddddf31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public class CreateDLRCEFXStudyCommand {
private CreateDLRCEFXStudyCommand() {
}

public static void appendIfNotNull(CompoundCommand cc, Command command) {
if (command != null) {
cc.append(command);
}
}

/**
* Creates a CompoundCommand for adding a new system structure based on the given Concept.
*
Expand Down Expand Up @@ -192,5 +186,17 @@ protected void doExecute() {
// Return the CompoundCommand representing the overall operation
return cmd;
}

/**
* Check if command to be added is valid - and do so
* @param cc the Compound command
* @param command the command to be added
*/
protected static void appendIfNotNull(CompoundCommand cc, Command command) {
if (command != null && command.canExecute()) {
cc.append(command);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static void addElementDefinitionParameters(Concept conceptCEFX, ElementDe


/**
* Creates a new discipline and assigns it to the specified child.
* Creates a new discipline (or return an existing one) of a given discipline name
*
* @param disciplineName The name of the discipline to be created and assigned.
* @return The newly created discipline.
Expand Down Expand Up @@ -256,7 +256,7 @@ public static Discipline createDisciplineForSubSystemName(String disciplineName,


/**
* Creates a new discipline if it doesn't already exist.
* Creates a command for adding a new discipline if it doesn't already exist.
*
* @param disciplineName The name of the discipline to be created.
* @param domain The VirSatTransactionalEditingDomain to perform the creation operation.
Expand All @@ -282,7 +282,7 @@ public static Command createAddDisciplineCommand(Discipline newDiscipline, VirSa
* @param domain
* @return
*/
public static Discipline getExistingDiscipline(String disciplineName, VirSatTransactionalEditingDomain domain) {
protected static Discipline getExistingDiscipline(String disciplineName, VirSatTransactionalEditingDomain domain) {
RoleManagement roleManagement = domain.getResourceSet().getRoleManagement();
for (Discipline existingDiscipline : roleManagement.getDisciplines()) {
if (existingDiscipline.getName().equals(disciplineName)) {
Expand All @@ -298,7 +298,7 @@ public static Discipline getExistingDiscipline(String disciplineName, VirSatTran
* Set child discipline to parent (if any) and create a command to add child
* @return command that will create file structure for a child and add it to the parent
*/
public static CompoundCommand createAddChildSEICommand(EObject parent, StructuralElementInstance child, VirSatTransactionalEditingDomain domain) {
protected static CompoundCommand createAddChildSEICommand(EObject parent, StructuralElementInstance child, VirSatTransactionalEditingDomain domain) {
Discipline discipline = null;
if (parent instanceof IAssignedDiscipline) {
discipline = ((IAssignedDiscipline) parent).getAssignedDiscipline();
Expand Down

0 comments on commit ddddf31

Please sign in to comment.