1
0
mirror of https://github.com/octoleo/plantuml.git synced 2025-04-05 17:51:51 +00:00

Merge commit '89406657e7a26c74119a87637f8f96c94055b45b' into patch/1580

This commit is contained in:
Dietrich Travkin 2023-10-30 10:45:34 +01:00
commit 7a7f59f00b
2 changed files with 44 additions and 21 deletions

View File

@ -85,6 +85,11 @@ public class EntityGenderUtils {
public String getGender() { public String getGender() {
return stereotype; return stereotype;
} }
@Override
public String getGender() {
return stereotype;
}
}; };
} }
@ -163,4 +168,17 @@ public class EntityGenderUtils {
}; };
} }
static public EntityGender byClassName(String className) {
return new EntityGender() {
@Override
public boolean contains(Entity test) {
return className.equals(test.getName());
}
@Override
public String getGender() {
return className;
}
};
}
} }

View File

@ -190,30 +190,35 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
} else { } else {
arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1); arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1);
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(arg1)); final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(arg1));
Entity entity = quark.getData(); if (quark == null) {
if (entity == null) return CommandExecutionResult.error("No such quark " + arg1);
return CommandExecutionResult.error("No such element " + quark.getName()); }
gender = EntityGenderUtils.byEntityAlone(entity); if (portion == EntityPortion.METHOD) {
} gender = EntityGenderUtils.byClassName(arg1);
if (gender != null) {
final boolean empty = arg.get("EMPTY", 0) != null;
final boolean emptyMembers = empty && portion == EntityPortion.MEMBER;
if (empty == true && emptyMembers == false)
gender = EntityGenderUtils.and(gender, emptyByGender(portion));
if (diagram.getCurrentGroup().isRoot() == false)
gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(diagram.getCurrentGroup()));
if (emptyMembers) {
diagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.FIELD)),
EntityPortion.FIELD, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
diagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.METHOD)),
EntityPortion.METHOD, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
} else { } else {
diagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show")); Entity entity = quark.getData();
if (entity == null)
return CommandExecutionResult.error("No such element " + quark.getName());
gender = EntityGenderUtils.byEntityAlone(entity);
} }
} }
return CommandExecutionResult.ok(); final boolean empty = arg.get("EMPTY", 0) != null;
final boolean emptyMembers = empty && portion == EntityPortion.MEMBER;
if (empty && !emptyMembers)
gender = EntityGenderUtils.and(gender, emptyByGender(portion));
if (!diagram.getCurrentGroup().isRoot())
gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(diagram.getCurrentGroup()));
if (emptyMembers) {
diagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.FIELD)),
EntityPortion.FIELD, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
diagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.METHOD)),
EntityPortion.METHOD, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
} else {
diagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
}
return CommandExecutionResult.ok();
} }
private EntityPortion getEntityPortion(String s) { private EntityPortion getEntityPortion(String s) {