1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-10 15:50:57 +00:00

#1475 Fix show statement

This commit is contained in:
Dietrich Travkin 2023-10-27 11:23:43 +02:00
parent f8d87217a7
commit 570d056f3d
3 changed files with 82 additions and 21 deletions

View File

@ -37,4 +37,6 @@ package net.sourceforge.plantuml.abel;
public interface EntityGender {
public boolean contains(Entity test);
public String getGender();
}

View File

@ -44,6 +44,11 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return test.getLeafType() == type;
}
@Override
public String getGender() {
return type.name();
}
};
}
@ -52,6 +57,11 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return test.getUid().equals(entity.getUid());
}
@Override
public String getGender() {
return entity.getUid();
}
};
}
@ -63,6 +73,11 @@ public class EntityGenderUtils {
}
return stereotype.equals(test.getStereotype().getLabel(Guillemet.DOUBLE_COMPARATOR));
}
@Override
public String getGender() {
return stereotype;
}
};
}
@ -80,6 +95,11 @@ public class EntityGenderUtils {
}
return false;
}
@Override
public String getGender() {
return null;
}
};
}
@ -88,6 +108,11 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return g1.contains(test) && g2.contains(test);
}
@Override
public String getGender() {
return null;
}
};
}
@ -96,6 +121,11 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return true;
}
@Override
public String getGender() {
return null;
}
};
}
@ -104,6 +134,11 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return test.getBodier().getMethodsToDisplay().size() == 0;
}
@Override
public String getGender() {
return null;
}
};
}
@ -112,7 +147,26 @@ public class EntityGenderUtils {
public boolean contains(Entity test) {
return test.getBodier().getFieldsToDisplay().size() == 0;
}
@Override
public String getGender() {
return null;
}
};
}
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 {
arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1);
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(arg1));
Entity entity = quark.getData();
if (entity == null)
return CommandExecutionResult.error("No such element " + quark.getName());
gender = EntityGenderUtils.byEntityAlone(entity);
}
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"));
if (quark == null) {
return CommandExecutionResult.error("No such quark " + arg1);
}
if (portion == EntityPortion.METHOD) {
gender = EntityGenderUtils.byClassName(arg1);
} 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) {