--- /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.evalFolder;
+
+import java.util.Date;
+
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.layout.AnchorLayout;
+import com.gwtext.client.widgets.layout.AnchorLayoutData;
+import com.pentila.evalcomp.client.ConnexionServer;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.message.MessageSmartViewTab;
+
+import com.pentila.evalcomp.client.services.ServiceAbstract;
+import com.pentila.evalcomp.client.services.widget.AssociateRessourcesWidget;
+import com.pentila.evalcomp.client.services.widget.SmartEvalGrid;
+import com.pentila.evalcomp.client.utilities.Tools;
+import com.pentila.evalcomp.domain.definition.EvaluationDefinition;
+import com.pentila.evalcomp.domain.service.ExtendActivity;
+import com.pentila.evalcomp.domain.service.Service;
+import com.pentila.evalcomp.domain.transit.Activity;
+import com.pentila.evalcomp.domain.transit.TEvaluationSubjectInstance;
+import com.pentila.evalcomp.domain.transit.Todo;
+import com.smartgwt.client.data.DataSource;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.Side;
+
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+import com.smartgwt.client.widgets.viewer.DetailViewer;
+import com.smartgwt.client.widgets.viewer.DetailViewerRecord;
+
+
+
+/**
+ * The Class EvaluationFolderPanel.
+ */
+public class EvaluationFolderPanel extends VLayout {
+
+ /** The folder name. */
+ private String folderName;
+
+ /** The id esi. */
+ private Long idESI;
+
+ /** The detail campagn. */
+ DetailViewer detailCampagn;
+
+ /** The detail dossier. */
+ DetailViewer detailDossier;
+
+ /** The v folder. */
+ VLayout vFolder;
+
+ /** The message panel. */
+ private VLayout messagePanel;
+
+ /** The arw. */
+ private AssociateRessourcesWidget arw;
+
+ /** The show detail ed. */
+ private boolean showDetailED = true;
+
+ /** The section stack. */
+ private TabSet sectionStack;
+
+ /** The fil v layout. */
+ private VLayout filVLayout;
+
+ /** The fil section. */
+ Tab filSection;
+
+ private VLayout containerRessource;
+
+ private Boolean folderExpanded = true;
+
+ private String login = null;
+
+ private Tab ressouceTab;
+
+ /**
+ * Instantiates a new evaluation folder panel.
+ *
+ * @param folderName the folder name
+ * @param idESI the id esi
+ * @param showDetailED the show detail ed
+ */
+ public EvaluationFolderPanel(String folderName, Long idESI, boolean showDetailED){
+ super();
+ this.folderName = folderName;
+ this.idESI =idESI;
+
+ this.showDetailED = showDetailED;
+ this.initializeInterface();
+ }
+
+ public EvaluationFolderPanel(String login, String folderName, Long idESI, boolean showDetailED){
+ this(folderName, idESI, showDetailED);
+ this.login = login;
+ }
+
+ public EvaluationFolderPanel(String folderName, Long idESI, boolean showDetailED, boolean expandFolder){
+ super();
+ this.folderName = folderName;
+ this.idESI =idESI;
+
+ this.showDetailED = showDetailED;
+ this.folderExpanded = expandFolder;
+ this.initializeInterface();
+ }
+
+ /**
+ * Initialize interface.
+ */
+ public void initializeInterface(){
+ setPadding(5);
+
+
+
+ sectionStack = new TabSet();
+ sectionStack.setWidth100();
+ //sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
+ //sectionStack.setAnimateSections(true);
+ sectionStack.setOverflow(Overflow.AUTO);
+
+ Tab campSection = new Tab();
+ campSection.setTitle(Messages.getString("Information"));
+ //campSection.setExpanded(false);
+
+ Tab folderSection = new Tab();
+ folderSection.setTitle(Messages.getString("Evaluation"));
+ //folderSection.setExpanded(this.folderExpanded);
+
+ Tab detailSection = new Tab();
+ detailSection.setTitle(Messages.getString("Dossier"));
+ //detailSection.setExpanded(this.folderExpanded);
+
+ filSection = new Tab();
+ filSection.setTitle(Messages.getString("discussion_a_propos") + " " + folderName);
+ //filSection.setExpanded(true);
+
+ filVLayout = new VLayout();
+ filVLayout.setHeight100();
+
+
+ messagePanel = new VLayout();
+
+ filVLayout.addMember(messagePanel);
+ filSection.setPane(messagePanel);
+ //definition des informations de la campagne
+
+ detailCampagn = new DetailViewer();
+ detailCampagn.setTitle("Campagne");
+
+ DataSource dsCamp = new DataSource();
+
+ dsCamp.addField(new DataSourceTextField("campName", Messages
+ .getString("Nom")));
+ dsCamp.addField(new DataSourceTextField("campDesc", Messages
+ .getString("Description")));
+ dsCamp.addField(new DataSourceTextField("planName", Messages
+ .getString("Plan_de_formation")));
+ dsCamp.addField(new DataSourceTextField("periode", Messages
+ .getString("Periode")));
+ dsCamp.addField(new DataSourceTextField("scenarioDescription", Messages
+ .getString("Scenario")));
+ dsCamp.addField(new DataSourceTextField("methodName", Messages
+ .getString("Methode_d_evaluation")));
+
+ detailCampagn.setDataSource(dsCamp);
+ detailCampagn.setWidth100();
+ detailCampagn.setMargin(15);
+ detailCampagn.setAlign(Alignment.LEFT);
+
+ detailCampagn.setLabelStyle("detailLabel leftDetailLabel");
+ detailCampagn.setCellStyle("detail paddingDetail");
+
+ //definition des informations du dossier
+ detailDossier = new DetailViewer();
+ detailDossier.setWidth100();
+ DataSource dsDossier = new DataSource();
+
+ dsDossier.addField(new DataSourceTextField("folderName", Messages
+ .getString("nom_du_dossier")));
+ dsDossier.addField(new DataSourceTextField("evaluationSubject", Messages
+ .getString("Sujets_d_evaluation")));
+ dsDossier.addField(new DataSourceTextField("currentActivity", Messages
+ .getString("activite_en_cours")));
+ dsDossier.addField(new DataSourceTextField("description", Messages
+ .getString("Description")));
+
+ detailDossier.setDataSource(dsDossier);
+ detailDossier.setMargin(15);
+ detailDossier.setAlign(Alignment.LEFT);
+
+ detailDossier.setLabelStyle("detailLabel leftDetailLabel");
+ detailDossier.setCellStyle("detail paddingDetail");
+
+ VLayout vv = new VLayout();
+
+ TabSet ts1 = new TabSet();
+
+ Tab t1 = new Tab();
+ ts1.setTabBarAlign(Side.RIGHT);
+ t1.setTitle(Messages.getString("Dossier_d_evaluation"));
+ t1.setPane(detailDossier);
+ ts1.setTabs(t1);
+
+ TabSet ts2 = new TabSet();
+ ts2.setTabBarAlign(Side.RIGHT);
+ Tab t2 = new Tab();
+ t2.setTitle(Messages.getString("Campagne_d_evaluation"));
+ t2.setPane(detailCampagn);
+
+ ts2.setTabs(t2);
+
+ vv.addMember(ts1);
+ vv.addMember(ts2);
+
+ campSection.setPane(vv);
+
+ containerRessource = new VLayout();
+
+ ressouceTab = new Tab();
+ ressouceTab.setTitle(Messages.getString("Ressources_associees"));
+ ressouceTab.setPane(containerRessource);
+
+ vFolder = new VLayout();
+
+ HLayout hlayout = new HLayout();
+ hlayout.setWidth100();
+ hlayout.addMember(containerRessource);
+
+ vFolder.setHeight100();
+
+ folderSection.setPane(vFolder);
+
+ if (showDetailED){
+ sectionStack.setTabs(campSection, folderSection, ressouceTab, filSection);
+
+ }else{
+ sectionStack.setTabs(folderSection, ressouceTab,filSection);
+
+ }
+
+ addMember(sectionStack);
+
+
+ }
+
+ /**
+ * Update.
+ */
+ public void update(){
+
+ AsyncCallback callback = new AsyncCallback(){
+
+ public void onFailure(Throwable caught) {
+
+ Tools.hideLoading();
+ }
+
+ public void onSuccess(Object result) {
+ TEvaluationSubjectInstance tESI = (TEvaluationSubjectInstance)result;
+
+ EvaluationDefinition ed = tESI.getEvaluationSubjectInstance().getScenarioInstance().getEvaluationInstance().getEvaluationDefinition();
+ String campName = ed.getName();
+ String campDesc = ed.getDescription();
+
+ if (campDesc == null || campDesc.equals("")){
+ campDesc = "--";
+ }
+
+ String planName = ed.getPlan().getName();
+ String startDate = Tools.getDateFormated(ed.getDateStart());
+ String endDate = Tools.getDateFormated(ed.getDateEnd());
+ String state = getEDState(ed);
+
+ String scenarioDescription = ed.getScenarioDefinitions().iterator().next().getDescription();
+ String methodName = null;
+ if (ed.getMethodEval() != null){
+ methodName = ed.getMethodEval().getName();
+
+ if (ed.getMethodEval().getDescription() != null && !ed.getMethodEval().getDescription().equals("")){
+ methodName = methodName + " : " + ed.getMethodEval().getDescription() ;
+ }
+ }
+
+ DetailViewerRecord dvrCamp = new DetailViewerRecord();
+ dvrCamp.setAttribute("campName", campName + "<i> (" + state+ ") </i>" );
+ dvrCamp.setAttribute("campDesc", campDesc);
+ dvrCamp.setAttribute("planName", planName);
+
+ String periode = Messages.getString("du") + " " + startDate + " " + Messages.getString("au") + " " + endDate;
+
+ dvrCamp.setAttribute("periode", periode);
+ dvrCamp.setAttribute("scenarioDescription", scenarioDescription);
+
+ if (methodName != null){
+ detailCampagn.getDataSource().getField("methodName").setHidden(false);
+ dvrCamp.setAttribute("methodName", methodName);
+ }else{
+ detailCampagn.getDataSource().getField("methodName").setHidden(true);
+ }
+ detailCampagn.setData(new DetailViewerRecord[]{dvrCamp});
+
+
+
+ String evualuationSubjectName = tESI.getEvaluationSubjectInstance().getEvaluationSubject().getComputedName();
+ String currentActivities = "";
+ String description = tESI.getEvaluationSubjectInstance().getDescription();
+
+ if (description == null || description.equals("")){
+ description = "--";
+ }
+
+ com.pentila.evalcomp.domain.transit.Process p = tESI.getProcess();
+
+ int i = 0;
+
+ for(Activity act : p.getActivities()){
+
+ ExtendActivity ea = act.getExtActivity();
+ Service serv = ea.getService();
+ currentActivities = currentActivities + Messages.getString(serv.getTitlei18n());
+
+ if (i <= p.getActivities().size()){
+ currentActivities += "<br/>";
+ }
+ i++;
+ }
+
+ if (currentActivities == null || currentActivities.equals("")){
+ currentActivities = Messages.getString("Aucune") + " (" + Messages.getString("Dossier_transmis")+")";
+ }
+
+ DetailViewerRecord dvrDossier = new DetailViewerRecord();
+ dvrDossier.setAttribute("folderName", folderName );
+ dvrDossier.setAttribute("evaluationSubject", evualuationSubjectName);
+ dvrDossier.setAttribute("currentActivity", currentActivities);
+ dvrDossier.setAttribute("description", description);
+
+ detailDossier.setData(new DetailViewerRecord[]{dvrDossier});
+
+ //Inititialisation des valeur de description et du panneau de ressources
+ arw = new AssociateRessourcesWidget(null);
+ arw.setReadOnly(true);
+
+ containerRessource.addMember(arw);
+ arw.updateRessources(tESI.getEvaluationSubjectInstance().getRessources());
+
+
+ if (!tESI.getEvaluationSubjectInstance().getMessages().isEmpty()) {
+
+
+ MessageSmartViewTab mvt = new MessageSmartViewTab();
+
+ mvt.initializeViewMsgInterface(tESI.getEvaluationSubjectInstance()
+ .getMessages().iterator().next());
+
+ messagePanel.addMember(mvt);
+
+ if (!folderExpanded){
+ sectionStack.selectTab(filSection);
+ }
+
+ }else{
+
+
+ }
+
+ updateCompetence(tESI);
+
+ Tools.hideLoading();
+ }
+
+ };
+
+ Tools.showLoading(Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ RequestBuilder rb = ConnexionServer.instanceService.getEvaluationSubjectInstance(idESI, callback);
+ rb.setHeader("code", "A22");
+ ConnexionServer.doSend(rb);
+
+ }
+
+
+ /**
+ * Gets the eD state.
+ *
+ * @param ed the ed
+ * @return the eD state
+ */
+ private String getEDState(EvaluationDefinition ed){
+ int state = ed.getState();
+
+ String finalState = "";
+
+ if (state == EvaluationDefinition.DELETED) {
+ finalState = Messages
+ .getString("supprimee");
+ } else if (state == EvaluationDefinition.FINISHED || (ed.getDateEnd() != null && ed.getDateEnd().before(new Date())) ) {
+ finalState = Messages.getString("terminee");
+ } else if (state == EvaluationDefinition.PAUSED) {
+ finalState = Messages.getString("en_pause");
+
+ } else if (state == EvaluationDefinition.RUNNING) {
+ finalState = Messages.getString("en_cours");
+
+ }
+
+ return finalState;
+ }
+
+
+ private void updateCompetence(final TEvaluationSubjectInstance tESI){
+
+ AsyncCallback callback = new AsyncCallback(){
+
+ public void onFailure(Throwable caught) {
+ // TODO Auto-generated method stub
+
+ Tools.hideLoading();
+
+ }
+
+ public void onSuccess(Object result) {
+ // TODO Auto-generated method stub
+
+ Todo todo = (Todo) result;
+
+ SmartEvalGrid evalGrid = new SmartEvalGrid(todo, true, null, null, "candName", false, login);
+
+ evalGrid.update(todo, 0, ServiceAbstract.pageSize);
+
+ evalGrid.setMinMemberSize(350);
+
+ vFolder.addMember(evalGrid);
+
+ Tools.hideLoading();
+
+ }
+
+
+ };
+
+ Todo todo = new Todo();
+
+ todo.setScenarioInstanceAbstract(tESI.getEvaluationSubjectInstance().getScenarioInstance());
+
+ Tools.showLoading(Messages.getString("MAJ"),
+ Messages.getString("Chargement"));
+
+ RequestBuilder rb = ConnexionServer.instanceService.updateTodo(todo, 0, ServiceAbstract.pageSize, null, this.login,
+ callback);
+ rb.setHeader("code", "A9");
+ ConnexionServer.doSend(rb);
+
+
+ }
+
+}