--- /dev/null
+/*****************************************************************************
+ * Copyright Igor Barma, Eric Brun, Alexandre Desoubeaux, Christian Martel,
+ * (2 décembre 2008)
+ *
+ * Ce logiciel est un programme informatique servant à l'évaluation des
+ * compétences.
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ *******************************************************************************/
+package com.pentila.evalcomp.client.services;
+
+import com.gwtext.client.core.Function;
+import com.gwtext.client.core.Margins;
+import com.gwtext.client.core.RegionPosition;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Tool;
+import com.gwtext.client.widgets.Toolbar;
+import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.event.WindowListenerAdapter;
+import com.gwtext.client.widgets.form.Label;
+import com.gwtext.client.widgets.layout.AnchorLayout;
+import com.gwtext.client.widgets.layout.AnchorLayoutData;
+import com.gwtext.client.widgets.layout.BorderLayout;
+import com.gwtext.client.widgets.layout.BorderLayoutData;
+import com.gwtext.client.widgets.layout.FitLayout;
+import com.gwtext.client.widgets.layout.RowLayout;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.services.widget.TransitionPanel;
+import com.pentila.evalcomp.client.utilities.Tools;
+import com.pentila.evalcomp.client.widget.ExtWindow;
+import com.pentila.evalcomp.domain.certification.ScenarioDefCert;
+import com.pentila.evalcomp.domain.certification.ScenarioInstCert;
+import com.pentila.evalcomp.domain.definition.EventActivity;
+import com.pentila.evalcomp.domain.definition.Property;
+import com.pentila.evalcomp.domain.definition.ScenarioDefinitionValidation;
+import com.pentila.evalcomp.domain.instance.ScenarioInstance;
+import com.pentila.evalcomp.domain.instance.ScenarioInstanceAbstract;
+import com.pentila.evalcomp.domain.instance.ScenarioInstanceValidation;
+import com.pentila.evalcomp.domain.plan.PlanComponent;
+import com.pentila.evalcomp.domain.plan.PlanRef;
+import com.pentila.evalcomp.domain.service.Service;
+import com.pentila.evalcomp.domain.transit.Activity;
+import com.pentila.evalcomp.domain.transit.Todo;
+
+/**
+ * The Class ServiceAbstract.
+ */
+public class ServiceAbstract extends Panel implements IServiceProvider {
+
+ public static final int pageSize = 25;
+
+ /** The todo. */
+ protected Todo todo;
+
+ /** The tpanel. */
+ protected TransitionPanel tpanel;
+
+ /** The north. */
+ public Panel north;
+
+ /** The south. */
+ public Panel south;
+
+ /** The center. */
+ public Panel center;
+
+ /** The west. */
+ public Panel west;
+
+ /** The east. */
+ public Panel east;
+
+ /** The content. */
+ public Panel content;
+
+
+ /**
+ * Instantiates a new service abstract.
+ */
+ public ServiceAbstract(){
+ super();
+ this.setLayout(new BorderLayout());
+ this.setBorder(false);
+ north = new Panel();
+
+ north.setHeight(30);
+ north.setPaddings(5);
+ BorderLayoutData bn = new BorderLayoutData(RegionPosition.NORTH);
+ bn.setMargins(new Margins(5, 5, 5, 5));
+ this.add(north, bn);
+
+ south = new Panel();
+ south.setHeight(40);
+ BorderLayoutData sn = new BorderLayoutData(RegionPosition.SOUTH);
+ sn.setMargins(new Margins(5, 5, 5, 5));
+ this.add(south, sn);
+
+ west = new Panel();
+ west.setTitle("");
+ west.setCollapsible(true);
+ west.setLayout(new RowLayout());
+ west.setWidth(200);
+ BorderLayoutData wn = new BorderLayoutData(RegionPosition.WEST);
+ wn.setSplit(true);
+ wn.setMinSize(175);
+ wn.setMaxSize(400);
+ wn.setMargins(new Margins(5, 5, 5, 5));
+ this.add(west, wn);
+
+ east = new Panel();
+ east.setTitle("");
+ east.setCollapsible(true);
+ east.setLayout(new FitLayout());
+ east.setWidth(300);
+ BorderLayoutData en = new BorderLayoutData(RegionPosition.EAST);
+ en.setSplit(true);
+ en.setMinSize(175);
+ en.setMaxSize(400);
+ en.setMargins(new Margins(5, 5, 5, 5));
+ this.add(east, en);
+
+ center = new Panel();
+ center.setBorder(false);
+ center.setLayout(new FitLayout());
+ BorderLayoutData cn = new BorderLayoutData(RegionPosition.CENTER);
+
+ this.add(center, cn);
+
+ Tool tool = new Tool(Tool.MAXIMIZE, new Function() {
+
+ public void execute() {
+
+ final ExtWindow w = new ExtWindow();
+ w.setLayout(new AnchorLayout());
+ w.setMaximizable(true);
+ w.setTitle(getTitle());
+
+
+ w.addListener(new WindowListenerAdapter() {
+
+ public boolean doBeforeClose(Panel panel){
+ center.enable();
+ center.add(content);
+ center.doLayout();
+ return true;
+ }
+
+ });
+
+
+ w.add(content, new AnchorLayoutData("100% 100%"));
+ w.show();
+ center.disable();
+ }
+
+
+
+ });
+ addTool(tool);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#doAfterTransit()
+ */
+ public void doAfterTransit(){};
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#doBeforeTransit(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void doBeforeTransit(String login, String processID,
+ String activityID, String transID){};
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceWidgetContainer#update()
+ */
+ public void update(){};
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#getTodo()
+ */
+ public Todo getTodo() {
+ return todo;
+ }
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#getTransitionPanel()
+ */
+ public TransitionPanel getTransitionPanel() {
+ return tpanel;
+ }
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#clearZones()
+ */
+ public void clearZones(){
+ north.clear();
+ south.clear();
+ west.clear();
+ east.clear();
+ center.clear();
+ }
+
+ /**
+ * Finalize layout.
+ */
+ public void finalizeLayout(){
+
+ boolean closeNorth = north.getComponents().length == 0;
+ if (closeNorth){
+ north.hide();
+ }else{
+
+ if (north.getComponents().length == 1){
+ Component c = north.getComponent(0);
+ if (c instanceof Label){
+ Label l = (Label) c;
+ if (!l.getText().trim().equals("")){
+ north.show();
+ }else{
+ north.hide();
+ }
+ }
+ }else{
+
+ north.show();
+ }
+ }
+
+
+ boolean closeEast = east.getComponents().length == 0;
+
+
+
+ if (closeEast){
+ east.hide();
+ }else{
+ east.show();
+ }
+
+
+ boolean closeWest = west.getComponents().length == 0;
+
+
+
+ if (closeWest){
+ west.hide();
+ }else{
+
+ boolean showWest = false;
+ for (Component c : west.getComponents()){
+ if (!c.isHidden()){
+ showWest = true;
+ break;
+ }
+ }
+ if (showWest){
+ west.show();
+ }else{
+ west.hide();
+ }
+ }
+
+
+
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#configureService(com.pentila.evalcomp.domain.transit.Todo, com.pentila.evalcomp.domain.transit.Activity)
+ */
+ public void configureService(Todo todo, Activity activity) {
+ Service serv = activity.getExtActivity().getService();
+
+ ScenarioInstanceAbstract sa = todo.getScenarioInstanceAbstract();
+
+ if(sa instanceof ScenarioInstance){
+ ScenarioInstance si = (ScenarioInstance) sa;
+ String dateLimite = null;
+ String dateDebut = null;
+ String nomPropriete = null;
+
+ for(EventActivity ea : si.getEvaluationSubjectInstance().getEvaluationSubject().getEventActivities()){
+ String currentEventActivityId = null;
+ String[] array = ea.getActivityId().split("_", 2);
+ if (array.length != 2){
+ continue;
+ }
+ currentEventActivityId = array[1];
+
+ if(activity.getId().equalsIgnoreCase(currentEventActivityId)){
+ for (Property prop : si.getScenarioDefinition().getPid().getPropertiesByType(Property.DEADLINE)){
+ if( prop.getName().equals(ea.getActivityId())){
+ nomPropriete = prop.getDescription();
+ break;
+ }
+ }
+ dateDebut = Tools.getMinimalDateFormated(ea.getStartDate(), true);
+ dateLimite = Tools.getMinimalDateFormated(ea.getEndDate(), true );
+ break;
+ }
+ }
+ if( dateLimite == null){
+ dateLimite = Tools.getMinimalDateFormated(si.getEvaluationInstance().getEvaluationDefinition().getDateEnd(), true);
+ }
+ if( dateDebut == null){
+ dateDebut = Tools.getMinimalDateFormated(si.getEvaluationInstance().getEvaluationDefinition().getDateStart(), true);
+ }
+ if(nomPropriete == null){
+ nomPropriete = Messages.getString("fin_de_la_campagne");
+ }
+
+ int i = 0;
+ String roles = "";
+ for (String roleName : todo.getCurrentUserRoles()){
+ String roleN = Messages.getString(roleName + "_single");
+ if (roleN.startsWith("!")){
+ roleN = Messages.getString(roleName);
+ }
+
+ roles += roleN;
+
+ if (i < todo.getCurrentUserRoles().size() -1 ){
+ roles += " | ";
+ }
+ i++;
+
+
+ }
+
+ if (!roles.equals("")){
+ roles = Messages.getString("Roles_") + " : " + roles;
+ }
+
+ this.setTitle(Messages.getString(serv.getTitlei18n())
+
+ + "<br> " + dateDebut
+ + "<IMG SRC=\"" + Tools.getBaseURL() + "images/arrow-blue-right-16x16-bottom.png" + "\">"
+ + " " + dateLimite + " ( " + nomPropriete + " ) "
+ + "<span style=\"float:right;\">" + roles + "</span>"
+ );
+
+ }else if (sa instanceof ScenarioInstanceValidation){
+
+ String roles = "";
+ int i = 0;
+ for (String roleName : todo.getCurrentUserRoles()){
+
+ String roleN = Messages.getString(roleName + "_single");
+ if (roleN.startsWith("!")){
+ roleN = Messages.getString(roleName);
+ }
+
+ roles += roleN;
+
+ if (i < todo.getCurrentUserRoles().size()-1 ){
+ roles += " | ";
+ }
+ i++;
+ }
+
+ if (!roles.equals("")){
+ roles = Messages.getString("Roles_") + " : " + roles;
+ }
+
+ ScenarioInstanceValidation siv = (ScenarioInstanceValidation)sa;
+
+ ScenarioDefinitionValidation sdv = (ScenarioDefinitionValidation) siv.getScenarioDefinition();
+
+ PlanComponent pc = sdv.getPlanComponent();
+
+ PlanRef pr = (PlanRef)pc;
+
+ String dateLimite = Tools.getMinimalDateFormated(pr.getValidationDate(), true);
+
+ this.setTitle(Messages.getString(serv.getTitlei18n())
+
+ + "<br>"
+ + "<IMG SRC=\"" + Tools.getBaseURL() + "images/arrow-blue-right-16x16-bottom.png" + "\">"
+ + " " + dateLimite
+ + "<span style=\"float:right;\">" + roles + "</span>"
+ );
+ }else if (sa instanceof ScenarioInstCert){
+
+ String roles = "";
+ int i = 0;
+ for (String roleName : todo.getCurrentUserRoles()){
+ String roleN = Messages.getString(roleName + "_single");
+ if (roleN.startsWith("!")){
+ roleN = Messages.getString(roleName);
+ }
+
+ roles += roleN;
+
+ if (i < todo.getCurrentUserRoles().size()-1 ){
+ roles += " | ";
+ }
+ i++;
+ }
+
+ if (!roles.equals("")){
+ roles = Messages.getString("Roles_") + " : " + roles;
+ }
+
+ ScenarioInstCert sic = (ScenarioInstCert)sa;
+
+ ScenarioDefCert sdc = (ScenarioDefCert) sic.getScenarioDefinition();
+
+ PlanRef pr = sdc.getPlanRef();
+
+ String dateLimite = Tools.getMinimalDateFormated(pr.getCertDate(), true);
+
+ this.setTitle(Messages.getString(serv.getTitlei18n())
+
+ + "<br>"
+ + "<IMG SRC=\"" + Tools.getBaseURL() + "images/arrow-blue-right-16x16-bottom.png" + "\">"
+ + " " + dateLimite
+ + "<span style=\"float:right;\">" + roles + "</span>"
+ );
+ }
+
+
+ }
+
+}