X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FKnowledgeElementFacade.java;fp=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FKnowledgeElementFacade.java;h=1b72325d03b2032f6cca73ebc65419280636e2ce;hb=967487668f1719e7a8d80d55bd5377e0170a1b25;hp=0000000000000000000000000000000000000000;hpb=3441a87265c83366a5590af2ed3fc5086d7fd63b;p=tools%2Fsiman.git diff --git a/Workspace/Siman/src/org/splat/simer/KnowledgeElementFacade.java b/Workspace/Siman/src/org/splat/simer/KnowledgeElementFacade.java new file mode 100644 index 0000000..1b72325 --- /dev/null +++ b/Workspace/Siman/src/org/splat/simer/KnowledgeElementFacade.java @@ -0,0 +1,130 @@ +package org.splat.simer; + +import org.splat.som.KnowledgeElement; +import org.splat.wapp.PopupMenu; + + +public class KnowledgeElementFacade { + + private KnowledgeElement my; + private State state; + private String value; + private PopupMenu popup; + + private enum State { closed, open } + +// ============================================================================================================================== +// Constructor +// ============================================================================================================================== + + public KnowledgeElementFacade (KnowledgeElement represented) { +// ------------------------------------------------------------ + my = represented; + state = State.closed; + + this.refresh(); // Initializes the presentation of my knowledge + } + +// ============================================================================================================================== +// Public member functions +// ============================================================================================================================== + + public void develop () { +// ---------------------- + state = State.open; + } + + public void reduce () { +// --------------------- + state = State.closed; + } + +// ============================================================================================================================== +// Getters +// ============================================================================================================================== + + public String getFullValue () { +// ----------------------------- + return my.getValue().replaceAll("'", "‘").replaceAll("\"", """); + } + public String getIndex () { +// ------------------------- + return String.valueOf(my.getIndex()); + } + public PopupMenu getPopup () { +// ---------------------------- + popup.setContext("feedbex", my); // Cannot be done at construction because pop-ups are shared + return popup; + } + public String getPresentationState () { +// ------------------------------------- + return state.toString(); + } + public String getProgressState () { +// --------------------------------- + return my.getProgressState().toString(); + } + public String getTitle () { +// ------------------------- + return my.getTitle(); + } + public String getValue () { +// ------------------------- + if (state == State.closed) return value; + else return my.getValue(); + } + public boolean isFacadeOf (KnowledgeElement represented) { +// -------------------------------------------------------- + return my.equals(represented); + } + +// ============================================================================================================================== +// Protected services +// ============================================================================================================================== + + protected void refresh () { +// ------------------------- + String[] tags = {"", "", "", "", "" }; + + popup = ApplicationSettings.getPopupMenu("feedbex"); + value = my.getValue(); + +// One line extract of the knowledge value + int size = 70 + 3; // Maximum length displayable on 1 line, including the starting

tag + int i; + for (i=0; i -1 && pos < size) size = size + 2*tags[i].length() + 1; // Inclusion of the open and close tags + } + if (value.startsWith("

")) { + int endex = value.indexOf("

"); + if ((i=value.indexOf(" 0) if (i < endex) endex = i; + if ((i=value.indexOf("