From: maroni Date: Sun, 4 Dec 2011 11:31:49 +0000 (-0200) Subject: (no commit message) X-Git-Url: http://200.18.67.61/gitweb/?a=commitdiff_plain;h=d076ae965e20cd4ddac316880c9593204c3b6296;p=simdecs.git --- d076ae965e20cd4ddac316880c9593204c3b6296 diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c2695bd Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3197301 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/nbproject/private/ \ No newline at end of file diff --git a/build.xml b/build.xml new file mode 100755 index 0000000..10fb677 --- /dev/null +++ b/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project Diagrama. + + + diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100755 index 0000000..2d5f877 --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100755 index 0000000..4550ee3 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1073 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData new file mode 100755 index 0000000..6d2fc73 --- /dev/null +++ b/nbproject/faces-config.NavData @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100755 index 0000000..b276730 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=f5fca5b3 +build.xml.script.CRC32=3c672195 +build.xml.stylesheet.CRC32=651128d4@1.33.1.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=f5fca5b3 +nbproject/build-impl.xml.script.CRC32=add2363b +nbproject/build-impl.xml.stylesheet.CRC32=0cbf5bb7@1.33.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100755 index 0000000..914f4d8 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,87 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart= +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath= +excludes= +includes=** +j2ee.compile.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.5 +j2ee.platform.classpath=${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/jersey-core.jar:${j2ee.server.home}/modules/jstl-impl.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +javac.classpath=\ + ${libs.primefaces.classpath}:\ + ${libs.hibernate-support.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +persistence.xml.dir=${conf.dir} +platform.active=default_platform +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs= +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test +war.content.additional= +war.ear.name=Diagrama.war +war.name=Diagrama.war +web.docbase.dir=web +webinf.dir=web/WEB-INF diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100755 index 0000000..21b6535 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,27 @@ + + + org.netbeans.modules.web.project + + + Diagrama + 1.6.5 + + + ${libs.primefaces.classpath} + WEB-INF/lib + + + ${libs.hibernate-support.classpath} + WEB-INF/lib + + + + + + + + + + + + diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..1e7df27 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/conf/.DS_Store b/src/conf/.DS_Store new file mode 100644 index 0000000..e7fb688 Binary files /dev/null and b/src/conf/.DS_Store differ diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100755 index 0000000..58630c0 --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/java/org/ufcspa/simdecs/diagram/DiagramManager.java b/src/java/org/ufcspa/simdecs/diagram/DiagramManager.java new file mode 100755 index 0000000..ff3eb27 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/DiagramManager.java @@ -0,0 +1,54 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; +import org.ufcspa.simdecs.diagram.elements.SwimLane; + +/** + * + * @author Maroni + */ +public class DiagramManager { + + private String diagramName; + private Map swimLanes; + + public DiagramManager(String diagramName) { + this.diagramName = diagramName; + swimLanes = new TreeMap(); + } + + public void addSwimLane(SwimLane swimLane) { + swimLanes.put(swimLane.getId(), swimLane); + } + + public final void clear() { + swimLanes = new HashMap(); + } + + public String getDiagramName() { + return diagramName; + } + + public void setDiagramName(String diagramName) { + this.diagramName = diagramName; + } + + public ArrayList getSwimLanes() { + return new ArrayList(swimLanes.values()); + } + + public SwimLane getSwimLane(String id) { + return swimLanes.get(id); + } + + public void removeSwimLane(String id) { + swimLanes.remove(id); + } +} diff --git a/src/java/org/ufcspa/simdecs/diagram/Test.java b/src/java/org/ufcspa/simdecs/diagram/Test.java new file mode 100755 index 0000000..f980c3f --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/Test.java @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram; + +/** + * + * @author Maroni + */ +public class Test { + + public static void main(String[] args) { + System.out.println("Teste"); + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/Begin.java b/src/java/org/ufcspa/simdecs/diagram/elements/Begin.java new file mode 100755 index 0000000..4788560 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/Begin.java @@ -0,0 +1,77 @@ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +@NodeElement +public class Begin extends Node { + + @NodeTextProperty(namei18n="NodeBeginDescription") + private String description; + @NodeTextProperty(namei18n="NodeBeginTitle") + private String title; + @NodeTextProperty(namei18n="NodeBeginScenario") + private String scenario; + + public Begin(String messageBundle, Locale locale) { + super(messageBundle, locale); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getScenario() { + return scenario; + } + + public void setScenario(String scenario) { + this.scenario = scenario; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Override + public String getImage() { + return "img/nodes/begin_" + getLocale() + ".png"; + } + + @Override + public String getImageWithLink() { + return "img/nodes/beginLink_" + getLocale() + ".png"; + } + + @Override + public List getGrantedPrevious() { + List list = new ArrayList(); + return list; + } + + @Override + public List getGrantedSwimLanes() { + List list = new ArrayList(); + list.add(new Doctor(messageBundle, locale)); + return list; + } + + @Override + public boolean isFirst() { + return true; + } + + @Override + public String getName() { + return getResourceMessage("elementNodeBegin"); + } +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/Doctor.java b/src/java/org/ufcspa/simdecs/diagram/elements/Doctor.java new file mode 100755 index 0000000..6caab00 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/Doctor.java @@ -0,0 +1,24 @@ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.Locale; + +public class Doctor extends SwimLane { + + public Doctor(String messageBundle, Locale locale) { + super(messageBundle, locale); + } + + @Override + public String getImage() { + if (getSex().equals("M")) + return "img/swimLanes/doctorMale.png"; + else + return "img/swimLanes/doctorFemale.png"; + } + + @Override + public String getType() { + return "doctor"; + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/Element.java b/src/java/org/ufcspa/simdecs/diagram/elements/Element.java new file mode 100755 index 0000000..6b58908 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/Element.java @@ -0,0 +1,82 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.elements; + +import java.io.Serializable; +import java.util.Date; +import java.util.Locale; +import org.ufcspa.simdecs.diagram.util.MessageResourceUtils; + +/** + * + * @author Maroni + */ +public abstract class Element implements Serializable { + + protected String id; + protected String messageBundle; + protected Locale locale; + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Element other = (Element) obj; + if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0); + return hash; + } + + public Element(String messageBundle, Locale locale) { + this.id = this.getClass().getSimpleName() + "-" + String.valueOf((new Date()).getTime()); + this.locale = locale; + this.messageBundle = messageBundle; + } + + public String getMessageBundle() { + return messageBundle; + } + + public void setMessageBundle(String messageBundle) { + this.messageBundle = messageBundle; + } + + public Locale getLocale() { + return locale; + } + + public void setLocale(Locale locale) { + this.locale = locale; + } + + protected String getResourceMessage(String key, Object params[]) { + return MessageResourceUtils.getMessageResourceString(messageBundle, key, params, locale); + } + + protected String getResourceMessage(String key) { + return getResourceMessage(key, null); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/Node.java b/src/java/org/ufcspa/simdecs/diagram/elements/Node.java new file mode 100755 index 0000000..5b410e8 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/Node.java @@ -0,0 +1,48 @@ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.List; +import java.util.Locale; +import javax.print.attribute.Size2DSyntax; + +public abstract class Node extends Element { + + private String currentImage; + + public Node(String messageBundle, Locale locale) { + super(messageBundle, locale); + } + + public abstract String getImage(); + public abstract String getImageWithLink(); + public abstract List getGrantedPrevious(); + public abstract boolean isFirst(); + public abstract List getGrantedSwimLanes(); + public abstract String getName(); + + public boolean isGrantedOnThisSwimLane(SwimLane swimLane) { + for (SwimLane x : getGrantedSwimLanes()) { + if (x.getClass().equals(swimLane.getClass())) + return true; + } + + return false; + } + + public boolean isGrantedAfterThisNode(Node node) { + for (Node x : getGrantedPrevious()) { + if (x.getClass().equals(node.getClass())) + return true; + } + + return false; + } + + public String getCurrentImage() { + return currentImage; + } + + public void setCurrentImage(String currentImage) { + this.currentImage = currentImage; + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/NodeElement.java b/src/java/org/ufcspa/simdecs/diagram/elements/NodeElement.java new file mode 100644 index 0000000..d410d86 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/NodeElement.java @@ -0,0 +1,22 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.elements; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author maroni + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface NodeElement { + + + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/NodeTextProperty.java b/src/java/org/ufcspa/simdecs/diagram/elements/NodeTextProperty.java new file mode 100644 index 0000000..429031d --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/NodeTextProperty.java @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.elements; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author maroni + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface NodeTextProperty { + String namei18n(); + boolean required() default false; + int minLength() default 0; + int maxLength() default 32767; +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/Patient.java b/src/java/org/ufcspa/simdecs/diagram/elements/Patient.java new file mode 100755 index 0000000..54a3b84 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/Patient.java @@ -0,0 +1,25 @@ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.Locale; + +public class Patient extends SwimLane { + + public Patient(String messageBundle, Locale locale) { + super(messageBundle, locale); + } + + @Override + public String getImage() { + if (getSex().equals("M")) + return "img/swimLanes/patientMale.png"; + else + return "img/swimLanes/patientFemale.png"; + } + + @Override + public String getType() { + return "patient"; + } + + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/SwimLane.java b/src/java/org/ufcspa/simdecs/diagram/elements/SwimLane.java new file mode 100755 index 0000000..af6b347 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/SwimLane.java @@ -0,0 +1,112 @@ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Locale; + + +public abstract class SwimLane extends Element { + + private String name; + private Integer age; + private String sex; + private Float weight; + private Float height; + private LinkedList nodes; + + public SwimLane(String messageBundle, Locale locale) { + super(messageBundle, locale); + nodes = new LinkedList(); + } + + public Node getNode(String id) { + for(Node node : nodes) { + if (node.equals(node)) + return node; + } + return null; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Float getHeight() { + return height; + } + + public void setHeight(Float height) { + this.height = height; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + this.weight = weight; + } + + + private void updateImages() { + ListIterator it = nodes.listIterator(); + while(it.hasNext()) { + Node node = (Node) it.next(); + if (it.hasNext()) { + node.setCurrentImage(node.getImageWithLink()); + + } + else { + node.setCurrentImage(node.getImage()); + } + } + } + + public void addNode(Node node) { + if (!nodes.contains(node)) + nodes.addLast(node); + + updateImages(); + } + + public LinkedList getNodes() { + return nodes; + } + + public abstract String getImage(); + public abstract String getType(); + + public Collection getGrantedNextNodes() { + Collection list = new ArrayList(); + + if (nodes.size()==0) { + list.add(new Begin(getMessageBundle(), getLocale())); + return list; + } + + return null; + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/elements/SymptomsSignsAsk.java b/src/java/org/ufcspa/simdecs/diagram/elements/SymptomsSignsAsk.java new file mode 100644 index 0000000..e123cc5 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/elements/SymptomsSignsAsk.java @@ -0,0 +1,56 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.elements; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +/** + * + * @author maroni + */ +@NodeElement +public class SymptomsSignsAsk extends Node { + + public SymptomsSignsAsk(String messageBundle, Locale locale) { + super(messageBundle, locale); + } + + @Override + public List getGrantedPrevious() { + List list = new ArrayList(); + list.add(new Begin(messageBundle, locale)); + return list; + } + + @Override + public List getGrantedSwimLanes() { + List list = new ArrayList(); + list.add(new Doctor(messageBundle, locale)); + return list; + } + + @Override + public String getImage() { + return "img/nodes/SymptomsSignsAsk_" + getLocale() + ".png"; + } + + @Override + public String getImageWithLink() { + return "img/nodes/SymptomsSignsAskLink_" + getLocale() + ".png"; + } + + @Override + public boolean isFirst() { + return false; + } + + @Override + public String getName() { + return getResourceMessage("elementNodeSymptomsSignsAsk"); + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/exceptions/DuplicateDiagramNameException.java b/src/java/org/ufcspa/simdecs/diagram/exceptions/DuplicateDiagramNameException.java new file mode 100755 index 0000000..3719b97 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/exceptions/DuplicateDiagramNameException.java @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.exceptions; + +/** + * + * @author Maroni + */ +public class DuplicateDiagramNameException extends Exception { + + public DuplicateDiagramNameException() { + super(); + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/DefaultManagedBean.java b/src/java/org/ufcspa/simdecs/diagram/mb/DefaultManagedBean.java new file mode 100755 index 0000000..06b484e --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/DefaultManagedBean.java @@ -0,0 +1,86 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.mb; + +import java.util.Locale; +import javax.el.ExpressionFactory; +import javax.faces.application.FacesMessage; +import javax.faces.application.FacesMessage.Severity; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import org.ufcspa.simdecs.diagram.util.MessageResourceUtils; + +/** + * + * @author Maroni + */ +public abstract class DefaultManagedBean { + + public Locale getLocale() { + return getFacesContext().getViewRoot().getLocale(); + } + + public void addMessage(String componentID, Severity severity, String i18nTitle, String i18nMessage) { + FacesContext.getCurrentInstance().addMessage(componentID, new FacesMessage(severity, getResourceMessage(i18nTitle), getResourceMessage(i18nMessage))); + } + + public void addInfoMessage(String componentID, String i18nTitle, String i18nMessage) { + addMessage(componentID, FacesMessage.SEVERITY_INFO, i18nTitle, i18nMessage); + } + + public void addInfoMessage(String i18nTitle, String i18nMessage) { + addInfoMessage(null, i18nTitle, i18nMessage); + } + + public void addWarnMessage(String componentID, String i18nTitle, String i18nMessage) { + addMessage(componentID, FacesMessage.SEVERITY_WARN, i18nTitle, i18nMessage); + } + + public void addWarnMessage(String i18nTitle, String i18nMessage) { + addWarnMessage(null, i18nTitle, i18nMessage); + } + + public void addErrorMessage(String componentID, String i18nTitle, String i18nMessage) { + addMessage(componentID, FacesMessage.SEVERITY_ERROR, i18nTitle, i18nMessage); + } + + public void addErrorMessage(String i18nTitle, String i18nMessage) { + addErrorMessage(null, i18nTitle, i18nMessage); + } + + protected String getTextParameter(String paramName) { + return (String) getFacesContext().getExternalContext().getRequestParameterMap().get(paramName); + } + + protected Object getParameter(String paramName) { + return getFacesContext().getExternalContext().getRequestParameterMap().get(paramName); + } + + protected FacesContext getFacesContext() { + return FacesContext.getCurrentInstance(); + } + + + protected UIComponent getComponentById(String componentId) { + return getFacesContext().getViewRoot().findComponent(componentId); + } + + protected String getMessageBundle() { + return getFacesContext().getApplication().getMessageBundle(); + } + + protected String getResourceMessage(String key, Object params[]) { + return MessageResourceUtils.getMessageResourceString(getMessageBundle(), key, params, getFacesContext().getViewRoot() + .getLocale()); + } + + protected String getResourceMessage(String key) { + return getResourceMessage(key, null); + } + + protected ExpressionFactory getExpressionFactory() { + return getFacesContext().getApplication().getExpressionFactory(); + } +} diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/EditActor.java b/src/java/org/ufcspa/simdecs/diagram/mb/EditActor.java new file mode 100755 index 0000000..3629fb9 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/EditActor.java @@ -0,0 +1,183 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.mb; + +import java.util.HashMap; +import java.util.Map; +import javax.faces.component.html.HtmlSelectOneMenu; +import org.primefaces.component.commandbutton.CommandButton; +import org.ufcspa.simdecs.diagram.elements.Doctor; +import org.ufcspa.simdecs.diagram.elements.Patient; +import org.ufcspa.simdecs.diagram.elements.SwimLane; + +/** + * + * @author Maroni + */ +public class EditActor extends DefaultManagedBean { + + private String id; + private String name; + private Integer age; + private Map actorTypes; + private String type; + private String sex; + private Float weight; + private Float height; + private EditDiagram editDiagram; + + public void addActor() { + if (type.equals("doctor")) { + Doctor doctor = new Doctor(getMessageBundle(), getLocale()); + doctor.setAge(age); + doctor.setHeight(height); + doctor.setName(name); + doctor.setSex(sex); + doctor.setWeight(weight); + editDiagram.getDiagramManager().addSwimLane(doctor); + } else if (type.equals("patient")) { + Patient patient = new Patient(getMessageBundle(), getLocale()); + patient.setAge(age); + patient.setHeight(height); + patient.setName(name); + patient.setSex(sex); + patient.setWeight(weight); + editDiagram.getDiagramManager().addSwimLane(patient); + } + + addInfoMessage("defaultInfoMessageTitle", "SucessAddActorMessage"); + } + + public void editActor() { + SwimLane actorToEdit = editDiagram.getDiagramManager().getSwimLane(id); + actorToEdit.setAge(age); + actorToEdit.setHeight(height); + actorToEdit.setName(name); + actorToEdit.setSex(sex); + actorToEdit.setWeight(weight); + + addInfoMessage("defaultInfoMessageTitle", "SucessEditActorMessage"); + } + + public void removeActor() { + editDiagram.getDiagramManager().removeSwimLane(id); + addInfoMessage("defaultInfoMessageTitle", "SucessRemoveActorMessage"); + } + + public void prepareWindowAddActor() { + id = name = type = sex = null; + age = null; + weight = height = null; + + CommandButton buttonAdd = (CommandButton) getComponentById("fEditActor:buttonAddActor"); + CommandButton buttonEdit = (CommandButton) getComponentById("fEditActor:buttonEditActor"); + CommandButton buttonRemove = (CommandButton) getComponentById("fEditActor:buttonRemoveActor"); + HtmlSelectOneMenu selectType = (HtmlSelectOneMenu) getComponentById("fEditActor:editActorType"); + buttonAdd.setRendered(true); + buttonEdit.setRendered(false); + buttonRemove.setRendered(false); + selectType.setDisabled(false); + } + + public void prepareWindowEditActor() { + id=getTextParameter("pActorID"); + SwimLane actorToEdit = editDiagram.getDiagramManager().getSwimLane(id); + age = actorToEdit.getAge(); + height = actorToEdit.getHeight(); + weight = actorToEdit.getWeight(); + name = actorToEdit.getName(); + sex = actorToEdit.getSex(); + type = actorToEdit.getType(); + + CommandButton buttonAdd = (CommandButton) getComponentById("fEditActor:buttonAddActor"); + CommandButton buttonEdit = (CommandButton) getComponentById("fEditActor:buttonEditActor"); + CommandButton buttonRemove = (CommandButton) getComponentById("fEditActor:buttonRemoveActor"); + HtmlSelectOneMenu selectType = (HtmlSelectOneMenu) getComponentById("fEditActor:editActorType"); + buttonAdd.setRendered(false); + buttonRemove.setRendered(true); + buttonEdit.setRendered(true); + selectType.setDisabled(true); + } + + public EditActor() { + actorTypes = new HashMap(); + actorTypes.put(getResourceMessage("DoctorActorType"), "doctor"); + actorTypes.put(getResourceMessage("PatientActorType"), "patient"); + } + + public Map getActorTypes() { + return actorTypes; + } + + public void setActorTypes(Map actorTypes) { + this.actorTypes = actorTypes; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Float getHeight() { + return height; + } + + public void setHeight(Float height) { + this.height = height; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + this.weight = weight; + } + + public EditDiagram getEditDiagram() { + return editDiagram; + } + + public void setEditDiagram(EditDiagram editDiagram) { + this.editDiagram = editDiagram; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/EditDiagram.java b/src/java/org/ufcspa/simdecs/diagram/mb/EditDiagram.java new file mode 100755 index 0000000..b84d0c6 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/EditDiagram.java @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.mb; + +import org.primefaces.model.DefaultMenuModel; +import org.primefaces.model.MenuModel; +import org.ufcspa.simdecs.diagram.DiagramManager; +import org.ufcspa.simdecs.diagram.elements.Begin; +import org.ufcspa.simdecs.diagram.elements.SwimLane; + +/** + * + * @author Maroni + */ +public class EditDiagram extends DefaultManagedBean { + + private DiagramManager diagramManager; + + + public EditDiagram() { + if (diagramManager == null) + diagramManager = new DiagramManager(getResourceMessage("newUntitledDiagram")); + } + + public DiagramManager getDiagramManager() { + return diagramManager; + } + + public void setDiagramManager(DiagramManager diagramManager) { + this.diagramManager = diagramManager; + } + + +} \ No newline at end of file diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/EditNode.java b/src/java/org/ufcspa/simdecs/diagram/mb/EditNode.java new file mode 100644 index 0000000..505cd9e --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/EditNode.java @@ -0,0 +1,153 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.mb; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import javax.el.MethodExpression; +import javax.faces.event.ActionEvent; +import javax.faces.event.MethodExpressionActionListener; +import org.primefaces.component.menu.Menu; +import org.primefaces.component.menuitem.MenuItem; +import org.primefaces.model.DefaultMenuModel; +import org.primefaces.model.MenuModel; +import org.ufcspa.simdecs.diagram.elements.Node; +import org.ufcspa.simdecs.diagram.elements.NodeElement; +import org.ufcspa.simdecs.diagram.elements.NodeTextProperty; +import org.ufcspa.simdecs.diagram.elements.SwimLane; +import org.ufcspa.simdecs.diagram.mb.beans.PropertyEditorBean; +import org.ufcspa.simdecs.diagram.util.ReflectionUtils; + +/** + * + * @author maroni + */ +public class EditNode extends DefaultManagedBean { + + private final String BASE_ELEMENT_PACKAGE = "org.ufcspa.simdecs.diagram.elements"; + private MenuModel menuActionList; + private EditDiagram editDiagram; + private Class currentNodeClass; + private List properties; + private SwimLane currentSwimLane; + + public EditNode() { + menuActionList = new DefaultMenuModel(); + properties = new ArrayList(); + } + + public EditDiagram getEditDiagram() { + return editDiagram; + } + + public void setEditDiagram(EditDiagram editDiagram) { + this.editDiagram = editDiagram; + } + + public MenuModel getMenuActionList() { + return menuActionList; + } + + public void setMenuActionList(MenuModel menuActionList) { + this.menuActionList = menuActionList; + } + + public void prepareActionMenu() throws ClassNotFoundException, IOException, NoSuchMethodException, IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException { + String pActorID = getTextParameter("pActorID"); + currentSwimLane = editDiagram.getDiagramManager().getSwimLane(pActorID); + + menuActionList = new DefaultMenuModel(); + + for(Class cclass: ReflectionUtils.getClasses(BASE_ELEMENT_PACKAGE)) { + if (cclass.getAnnotation(NodeElement.class) != null) { + Constructor nodeConstructor = cclass.getConstructor(new Class[]{String.class, Locale.class}); + Node node = (Node) nodeConstructor.newInstance(getMessageBundle(), getLocale()); + + if (currentSwimLane.getNodes().isEmpty() && !node.isFirst()) + continue; + + if (!node.isGrantedOnThisSwimLane(currentSwimLane)) + continue; + LinkedList nodes = currentSwimLane.getNodes(); + if (nodes != null && !nodes.isEmpty() && !node.isGrantedAfterThisNode((Node)nodes.getLast())) + continue; + + MenuItem item = new MenuItem(); + item.setValue(node.getName()); + item.setId("menuItem-" + node.getId()); + item.setOnstart("dialogAddNodeMenu.hide();"); + item.setOncomplete("dialogEditNodeMenu.show();"); + item.setUpdate("fEditNodeMenu"); + + MethodExpression actionExpression = getFacesContext().getApplication().getExpressionFactory().createMethodExpression(getFacesContext().getELContext(), + "#{editNode.processAddNode}", + null, + new Class[]{ActionEvent.class}); + + item.addActionListener(new MethodExpressionActionListener(actionExpression)); + menuActionList.addMenuItem(item); + } + } + + Menu menu = (Menu) getComponentById("fAddNodeMenu:dinamycAddNodeMenu"); + menu.getChildren().clear(); + menu.clearInitialState(); + menu.setModel(menuActionList); + menu.buildMenuFromModel(); + } + + public void processAddNode(ActionEvent event) throws ClassNotFoundException { + String callerID = event.getComponent().getClientId(); + String callerClassStrName = callerID.substring(callerID.indexOf("-") + 1, callerID.indexOf("-", callerID.indexOf("-") + 1)); + currentNodeClass = Class.forName(BASE_ELEMENT_PACKAGE + '.' + callerClassStrName); + + properties = new ArrayList(); + for (Field field : currentNodeClass.getDeclaredFields()) { + NodeTextProperty textAnnotation = field.getAnnotation(NodeTextProperty.class); + + if (textAnnotation != null) { + PropertyEditorBean property = new PropertyEditorBean(); + property.setReflectionField(field); + property.setName(getResourceMessage(textAnnotation.namei18n())); + property.setMinLength(textAnnotation.minLength()); + property.setMaxLength(textAnnotation.maxLength()); + property.setRequired(textAnnotation.required()); + properties.add(property); + } + } + + Menu menu = (Menu) getComponentById("fAddNodeMenu:dinamycAddNodeMenu"); + } + + public void addNode() throws NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Constructor nodeConstructor = currentNodeClass.getConstructor(new Class[]{String.class, Locale.class}); + Node node = (Node) nodeConstructor.newInstance(getMessageBundle(), getLocale()); + + for (PropertyEditorBean property : properties) { + Method acessor = ReflectionUtils.getSetterMethod(currentNodeClass, property.getReflectionField()); + acessor.invoke(node, property.getValue()); + } + + currentSwimLane.addNode(node); + + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/LanguageSelector.java b/src/java/org/ufcspa/simdecs/diagram/mb/LanguageSelector.java new file mode 100755 index 0000000..e0b19ee --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/LanguageSelector.java @@ -0,0 +1,43 @@ +package org.ufcspa.simdecs.diagram.mb; + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import javax.enterprise.context.SessionScoped; +import javax.faces.bean.ManagedBean; + +/** + * + * @author Maroni + */ +public class LanguageSelector extends DefaultManagedBean { + + private String selectedLanguage; + + /** Creates a new instance of LanguageSelector */ + public LanguageSelector() { + selectedLanguage = getFacesContext().getViewRoot().getLocale().toString(); + } + + public void handleLanguageChange() { + selectedLanguage = getTextParameter("language"); + String isoLanguage = selectedLanguage.substring(0, 2); + String isoCountry = selectedLanguage.substring(3, 5); + getFacesContext().getViewRoot().setLocale(new Locale(isoLanguage, isoCountry)); + } + + public String getSelectedLanguage() { + return selectedLanguage; + } + + public void setSelectedLanguage(String selectedLanguage) { + this.selectedLanguage = selectedLanguage; + } + +} + diff --git a/src/java/org/ufcspa/simdecs/diagram/mb/beans/PropertyEditorBean.java b/src/java/org/ufcspa/simdecs/diagram/mb/beans/PropertyEditorBean.java new file mode 100644 index 0000000..440a0ec --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/mb/beans/PropertyEditorBean.java @@ -0,0 +1,107 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.mb.beans; + +import java.io.Serializable; +import java.lang.reflect.Field; + +/** + * + * @author maroni + */ +public class PropertyEditorBean implements Serializable { + + private Field reflectionField; + private String name; + private Object value; + private Integer minLength; + private Integer maxLength; + private boolean required; + + public PropertyEditorBean() { + + } + + public PropertyEditorBean(String name, Object value) { + this.name = name; + this.value = value; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PropertyEditorBean other = (PropertyEditorBean) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.value == null) ? (other.value != null) : !this.value.equals(other.value)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 89 * hash + (this.value != null ? this.value.hashCode() : 0); + return hash; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(Integer maxLength) { + this.maxLength = maxLength; + } + + public Integer getMinLength() { + return minLength; + } + + public void setMinLength(Integer minLength) { + this.minLength = minLength; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public Field getReflectionField() { + return reflectionField; + } + + public void setReflectionField(Field reflectionField) { + this.reflectionField = reflectionField; + } + + +} diff --git a/src/java/org/ufcspa/simdecs/diagram/util/MessageResourceUtils.java b/src/java/org/ufcspa/simdecs/diagram/util/MessageResourceUtils.java new file mode 100755 index 0000000..e220b52 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/util/MessageResourceUtils.java @@ -0,0 +1,54 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.util; + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * + * @author Maroni + */ +public class MessageResourceUtils { + + protected static ClassLoader getCurrentClassLoader(Object defaultObject) { + + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + + if (loader == null) { + loader = defaultObject.getClass().getClassLoader(); + } + + return loader; + } + + public static String getMessageResourceString( + String bundleName, + String key, + Object params[], + Locale locale) { + + String text = null; + + ResourceBundle bundle = + ResourceBundle.getBundle(bundleName, locale, + getCurrentClassLoader(params)); + + try { + text = bundle.getString(key); + } catch (MissingResourceException e) { + text = "?? key " + key + " not found ??"; + } + + if (params != null) { + MessageFormat mf = new MessageFormat(text, locale); + text = mf.format(params, new StringBuffer(), null).toString(); + } + + return text; + } +} diff --git a/src/java/org/ufcspa/simdecs/diagram/util/ReflectionUtils.java b/src/java/org/ufcspa/simdecs/diagram/util/ReflectionUtils.java new file mode 100644 index 0000000..fee9019 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/diagram/util/ReflectionUtils.java @@ -0,0 +1,77 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.diagram.util; + +import com.sun.xml.internal.ws.util.StringUtils; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +/** + * + * @author maroni + */ +public class ReflectionUtils { + + public static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + assert classLoader != null; + String path = packageName.replace('.', '/'); + Enumeration resources = classLoader.getResources(path); + List dirs = new ArrayList(); + while (resources.hasMoreElements()) { + URL resource = resources.nextElement(); + dirs.add(new File(resource.getFile())); + } + ArrayList classes = new ArrayList(); + for (File directory : dirs) { + classes.addAll(findClasses(directory, packageName)); + } + return classes.toArray(new Class[classes.size()]); + } + + private static List findClasses(File directory, String packageName) throws ClassNotFoundException { + List classes = new ArrayList(); + if (!directory.exists()) { + return classes; + } + File[] files = directory.listFiles(); + for (File file : files) { + if (file.isDirectory()) { + assert !file.getName().contains("."); + classes.addAll(findClasses(file, packageName + "." + file.getName())); + } else if (file.getName().endsWith(".class")) { + classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6))); + } + } + return classes; + } + + public static Method getSetterMethod(Class reflectClass, Field field) { + for (Method method : reflectClass.getMethods()) { + if (method.getName().equals("set" + StringUtils.capitalize(field.getName()))) { + return method; + } + } + + return null; + } + + public static Method getGetterMethod(Class reflectClass, Field field) { + for (Method method : reflectClass.getMethods()) { + if (method.getName().equals("get" + StringUtils.capitalize(field.getName()))) { + return method; + } + } + + return null; + } + +} diff --git a/src/java/org/ufcspa/simdecs/resources/messages_en_US.properties b/src/java/org/ufcspa/simdecs/resources/messages_en_US.properties new file mode 100755 index 0000000..8fbae06 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/resources/messages_en_US.properties @@ -0,0 +1,49 @@ +# To change this template, choose Tools | Templates +# and open the template in the editor. +editDiagramEditActor=Actor Information +editDiagramAddActor=Add Actor +buttonAdd=Add Actor +buttonEdit=Edit Actor +buttonRemove=Remove Actor +editDiagramAddBegin=Add Begin +editDiagramActorName=Name: +editDiagramActorType=Type: +editDiagramActorSex=Sex: +editDiagramActorSexMale=Male +editDiagramActorSexFemale=Female +editDiagramActorAge=Age: +editDiagramActorWeight=Weight: +editDiagramActorWeightMeasureUnit=kg +editDiagramActorHeight=Height: +editDiagramActorHeightMeasureUnit=meters +DoctorActorType=Doctor +PatientActorType=Patient +selectOneOnList=Select Option +editDiagramMenuFile=File +editDiagramMenuOpen=Open +editDiagramMenuSave=Save +editDiagramMenuNew=New +editDiagramMenuHelp=Help +editDiagramMenuAbout=About +editDiagramMenuLanguage=Language +editDiagramMenuLanguagePortugueseLabel=Brazilian Portuguese +editDiagramMenuLanguagePortugueseCode=pt_BR +editDiagramMenuLanguageEnglishLabel=USA English +editDiagramMenuLanguageEnglishCode=en_US +newUntitledDiagram=Untitiled Diagram +defaultInfoMessageTitle=Information +SucessAddActorMessage=Actor successfully added +SucessEditActorMessage=Actor successfully modifyed +SucessRemoveActorMessage=Ator exclu\u00eddo com sucesso! +elementNodeBegin=Begin +NodeBeginDescription=Description +NodeBeginTitle=Title +NodeBeginScenario=Scenario +editPropertiesTableTitle=Properties +editPropertiesTableName=Name +editPropertiesTableValue=Value +editPropertiesButtonOk=Ok +editPropertiesButtonCancel=Cancel +elementNodeSymptomsSignsAsk=Ask Smptoms and Signs + + diff --git a/src/java/org/ufcspa/simdecs/resources/messages_pt_BR.properties b/src/java/org/ufcspa/simdecs/resources/messages_pt_BR.properties new file mode 100755 index 0000000..8abbba6 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/resources/messages_pt_BR.properties @@ -0,0 +1,50 @@ +# To change this template, choose Tools | Templates +# and open the template in the editor. +editDiagramEditActor=Informa\u00e7\u00f5es do Ator +editDiagramAddActor=Adicionar Ator +buttonAdd=Adicionar +buttonEdit=Editar +buttonRemove=Excluir +editDiagramAddBegin=Adicionar In\u00edcio +editDiagramActorName=Nome: +editDiagramActorType=Tipo: +editDiagramActorSex=Sexo: +editDiagramActorSexMale=Masculino +editDiagramActorSexFemale=Female +editDiagramActorSexFemale=Feminino +editDiagramActorAge=Idade: +editDiagramActorWeight=Peso: +editDiagramActorWeightMeasureUnit=quilogramas +editDiagramActorHeight=Altura: +editDiagramActorHeightMeasureUnit=metros +DoctorActorType=M\u00e9dico +PatientActorType=Paciente +selectOneOnList=Selecione na lista +editDiagramMenuFile=Arquivo +editDiagramMenuOpen=Abrir +editDiagramMenuSave=Salvar +editDiagramMenuNew=Novo +editDiagramMenuHelp=Ajuda +editDiagramMenuAbout=Sobre +editDiagramMenuLanguage=Idioma +editDiagramMenuLanguagePortugueseLabel=Portugu\u00eas do Brasil +editDiagramMenuLanguagePortugueseCode=pt_BR +editDiagramMenuLanguageEnglishLabel=Ingl\u00eas (USA) +editDiagramMenuLanguageEnglishCode=en_US +newUntitledDiagram=Diagrama sem t\u00edtulo +defaultInfoMessageTitle=Aviso +SucessAddActorMessage=Ator adicionado com sucesso! +SucessEditActorMessage=Ator alterado com sucesso! +SucessRemoveActorMessage=Ator exclu\u00eddo com sucesso! +elementNodeBegin=In\u00edcio +NodeBeginDescription=Descri\u00e7\u00e3o +NodeBeginTitle=T\u00edtulo +NodeBeginScenario=Cen\u00e1rio +editPropertiesTableTitle=Propriedades +editPropertiesTableName=Nome +editPropertiesTableValue=Valor +editPropertiesButtonOk=Ok +editPropertiesButtonCancel=Cancelar +elementNodeSymptomsSignsAsk=Perguntar Sinais e Sintomas + + diff --git a/web/.DS_Store b/web/.DS_Store new file mode 100644 index 0000000..fe972b9 Binary files /dev/null and b/web/.DS_Store differ diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml new file mode 100755 index 0000000..662799e --- /dev/null +++ b/web/WEB-INF/faces-config.xml @@ -0,0 +1,48 @@ + + + + + + + + + pt_BR + pt_BR + en_US + + + org.ufcspa.simdecs.resources.messages + + + + editActor + org.ufcspa.simdecs.diagram.mb.EditActor + request + + editDiagram + #{editDiagram} + + + + editDiagram + org.ufcspa.simdecs.diagram.mb.EditDiagram + session + + + languageSelector + org.ufcspa.simdecs.diagram.mb.LanguageSelector + session + + + editNode + org.ufcspa.simdecs.diagram.mb.EditNode + + session + + editDiagram + #{editDiagram} + + diff --git a/web/WEB-INF/glassfish-web.xml b/web/WEB-INF/glassfish-web.xml new file mode 100755 index 0000000..13e0059 --- /dev/null +++ b/web/WEB-INF/glassfish-web.xml @@ -0,0 +1,10 @@ + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/web/WEB-INF/sun-web.xml b/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..227128c --- /dev/null +++ b/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + + + + Keep a copy of the generated servlet class' java code. + + + + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100755 index 0000000..e2c86a7 --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Production + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + *.jsf + + + + 30 + + + + editDiagram.jsf + + diff --git a/web/editDiagram.xhtml b/web/editDiagram.xhtml new file mode 100755 index 0000000..9a95440 --- /dev/null +++ b/web/editDiagram.xhtml @@ -0,0 +1,202 @@ + + + + + + SimDeCS + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + + + +
+ + + + +
+ + +   + +
+ + +   + +
+
+ + + +
+ +
+
+ + + + + + +
+ + diff --git a/web/img/background.gif b/web/img/background.gif new file mode 100755 index 0000000..3b697ce Binary files /dev/null and b/web/img/background.gif differ diff --git a/web/img/dock/about.png b/web/img/dock/about.png new file mode 100755 index 0000000..d9fa819 Binary files /dev/null and b/web/img/dock/about.png differ diff --git a/web/img/dock/addActor.png b/web/img/dock/addActor.png new file mode 100755 index 0000000..20d6e44 Binary files /dev/null and b/web/img/dock/addActor.png differ diff --git a/web/img/dock/addBegin.png b/web/img/dock/addBegin.png new file mode 100755 index 0000000..f0e2305 Binary files /dev/null and b/web/img/dock/addBegin.png differ diff --git a/web/img/dock/open.png b/web/img/dock/open.png new file mode 100755 index 0000000..8460bf4 Binary files /dev/null and b/web/img/dock/open.png differ diff --git a/web/img/dock/save.png b/web/img/dock/save.png new file mode 100755 index 0000000..e71b953 Binary files /dev/null and b/web/img/dock/save.png differ diff --git a/web/img/nodes/SymptomsSignsAskLink_pt_BR.png b/web/img/nodes/SymptomsSignsAskLink_pt_BR.png new file mode 100644 index 0000000..ff8e886 Binary files /dev/null and b/web/img/nodes/SymptomsSignsAskLink_pt_BR.png differ diff --git a/web/img/nodes/SymptomsSignsAsk_pt_BR.png b/web/img/nodes/SymptomsSignsAsk_pt_BR.png new file mode 100644 index 0000000..bd62da1 Binary files /dev/null and b/web/img/nodes/SymptomsSignsAsk_pt_BR.png differ diff --git a/web/img/nodes/beginLink_pt_BR.png b/web/img/nodes/beginLink_pt_BR.png new file mode 100644 index 0000000..e47a535 Binary files /dev/null and b/web/img/nodes/beginLink_pt_BR.png differ diff --git a/web/img/nodes/begin_en_US.png b/web/img/nodes/begin_en_US.png new file mode 100755 index 0000000..bb63d0d Binary files /dev/null and b/web/img/nodes/begin_en_US.png differ diff --git a/web/img/nodes/begin_pt_BR.png b/web/img/nodes/begin_pt_BR.png new file mode 100755 index 0000000..f9b2e54 Binary files /dev/null and b/web/img/nodes/begin_pt_BR.png differ diff --git a/web/img/nodes/end.png b/web/img/nodes/end.png new file mode 100755 index 0000000..0860d15 Binary files /dev/null and b/web/img/nodes/end.png differ diff --git a/web/img/others/plus.png b/web/img/others/plus.png new file mode 100644 index 0000000..88c42b0 Binary files /dev/null and b/web/img/others/plus.png differ diff --git a/web/img/sources/plus.png b/web/img/sources/plus.png new file mode 100755 index 0000000..fb7fdeb Binary files /dev/null and b/web/img/sources/plus.png differ diff --git a/web/img/swimLanes/doctorFemale.png b/web/img/swimLanes/doctorFemale.png new file mode 100755 index 0000000..899f5dd Binary files /dev/null and b/web/img/swimLanes/doctorFemale.png differ diff --git a/web/img/swimLanes/doctorMale.png b/web/img/swimLanes/doctorMale.png new file mode 100755 index 0000000..aba40ce Binary files /dev/null and b/web/img/swimLanes/doctorMale.png differ diff --git a/web/img/swimLanes/patientFemale.png b/web/img/swimLanes/patientFemale.png new file mode 100755 index 0000000..99d9fb6 Binary files /dev/null and b/web/img/swimLanes/patientFemale.png differ diff --git a/web/img/swimLanes/patientMale.png b/web/img/swimLanes/patientMale.png new file mode 100755 index 0000000..f96304d Binary files /dev/null and b/web/img/swimLanes/patientMale.png differ diff --git a/web/img/swimLanes/separator.png b/web/img/swimLanes/separator.png new file mode 100755 index 0000000..739dab6 Binary files /dev/null and b/web/img/swimLanes/separator.png differ diff --git a/web/index.xhtml b/web/index.xhtml new file mode 100755 index 0000000..0acf6cf --- /dev/null +++ b/web/index.xhtml @@ -0,0 +1,18 @@ + + + + + Facelet Title + + + + + + For more information visit http://primefaces.org. + + + + + diff --git a/web/styles.css b/web/styles.css new file mode 100755 index 0000000..77c19c9 --- /dev/null +++ b/web/styles.css @@ -0,0 +1,25 @@ +/* + Document : styles + Created on : 05/11/2011, 14:55:32 + Author : Maroni + Description: + Purpose of the stylesheet follows. +*/ + +/* + TODO customize this sample style + Syntax recommendation http://www.w3.org/TR/REC-CSS2/ +*/ + +root { + display: block; +} + +body { + background: #f6f6f6 url(img/background.gif) bottom left repeat; + font-size: 12px; +} + +.formTable { + text-align: left; +}