--- /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.vaepp;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.RichTextArea;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.core.Position;
+import com.gwtext.client.util.Format;
+import com.gwtext.client.widgets.BoxComponent;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.Container;
+import com.gwtext.client.widgets.HTMLPanel;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Window;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.event.PanelListenerAdapter;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.Label;
+import com.gwtext.client.widgets.form.TextArea;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.layout.AnchorLayoutData;
+import com.gwtext.client.widgets.layout.FitLayout;
+import com.gwtext.client.widgets.layout.FormLayout;
+import com.gwtext.client.widgets.layout.RowLayout;
+import com.gwtext.client.widgets.layout.RowLayoutData;
+import com.gwtextux.client.widgets.window.ToastWindow;
+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.message.MessageViewTab;
+import com.pentila.evalcomp.client.services.IServiceProvider;
+import com.pentila.evalcomp.client.services.RessourceServiceAbstract;
+import com.pentila.evalcomp.client.services.widget.EvalSubViewWidget;
+import com.pentila.evalcomp.client.services.widget.ExtRessourcesPanel;
+import com.pentila.evalcomp.client.services.widget.OptSelectionEvalWidget;
+import com.pentila.evalcomp.client.services.widget.TransitionPanel;
+import com.pentila.evalcomp.client.utilities.Tools;
+import com.pentila.evalcomp.client.utilities.UserTools;
+import com.pentila.evalcomp.client.widget.ExtWindow;
+import com.pentila.evalcomp.client.widget.RichTextToolbar;
+import com.pentila.evalcomp.domain.Ressource;
+import com.pentila.evalcomp.domain.User;
+import com.pentila.evalcomp.domain.definition.Property;
+import com.pentila.evalcomp.domain.instance.CompetenceInstance;
+import com.pentila.evalcomp.domain.instance.ScenarioInstance;
+import com.pentila.evalcomp.domain.service.Service;
+import com.pentila.evalcomp.domain.transit.Activity;
+import com.pentila.evalcomp.domain.transit.Todo;
+import com.smartgwt.client.util.SC;
+
+/**
+ * The Class VAEPPService.
+ */
+public class VAEPPService extends RessourceServiceAbstract implements IServiceProvider{
+
+ /** The fs. */
+ private FieldSet fs;
+
+
+ /** The folder name. */
+ private TextField folderName;
+
+ /** The description. */
+ private RichTextArea description;
+
+ /** The activity. */
+ private Activity activity;
+
+ /** The evaluateur choice arg. */
+ private TextArea evaluateurChoiceArg;
+
+ /** The g. */
+ private EditorGrid g;
+
+ /** The cb. */
+ private OptSelectionEvalWidget cb;
+
+
+
+ /**
+ * Instantiates a new vAEPP service.
+ */
+ public VAEPPService() {
+ super();
+
+
+ this.setTitle(Messages.getString("Accepter_une_evaluation"));
+ this.setIconCls("iconPrevenirEvaluateur32");
+
+ initializeInterface();
+
+ }
+
+ /**
+ * Configure service.
+ *
+ * @param todo the todo
+ * @param activity the activity
+ */
+ public void configureService(final Todo todo, final Activity activity) {
+ super.configureService(todo, activity);
+ this.todo = todo;
+
+ this.activity = activity;
+
+ Service serv = activity.getExtActivity().getService();
+
+ if (activity.getId().equals("vaepp_creer")) {
+ this.setIconCls("iconCreerDossier32");
+ } else if (activity.getId().equals("vaepp_editer")) {
+ this.setIconCls("iconEditerDossier32");
+ } else if (activity.getId().equals("vaepp_prevenir")) {
+ this.setIconCls("iconPrevenirEvaluateur32");
+ } else if (activity.getId().equals("vaepp_evaluer")) {
+ this.setIconCls("iconEvaluer32");
+ }
+
+ String candName = "";
+
+ Set<String> usernames = new HashSet<String>();
+
+ if (todo.getDataMap() != null){
+
+ int index = todo.getDataMap().getIndexes().indexOf("candName");
+
+ for (String[] line : todo.getDataMap().getDataMap()){
+ String current = line[index];
+ if (current != null && !current.equals("")){
+ usernames.add(current);
+ }
+
+ }
+
+ for (String un : usernames){
+ candName = candName + un + " ";
+ }
+
+ }
+
+ String name = "";
+ String desc = "";
+
+ Property pname = todo.getProcess().getPropertyByName(
+ "VARIABLE_folder_name");
+ Property pdescription = todo.getProcess().getPropertyByName(
+ "VARIABLE_description");
+
+ if (pname != null) {
+ name = pname.getValue();
+ }
+ if (name.equals("--") || name.equals("")) {
+ DateTimeFormat dtf = DateTimeFormat.getFormat("ddMMyyyy_HHmm");
+ name = dtf.format(new Date());
+ }
+
+ if (pdescription != null) {
+ desc = pdescription.getValue();
+ }
+
+ String username = "";
+ if (!candName.equals("")){
+ username =" ( " + candName +")";
+ }
+
+ //this.setTitle(Messages.getString(serv.getTitlei18n()) + " " + name + username );
+
+ clearZones();
+ content = new Panel();
+ content.setBorder(false);
+ content.setLayout(new RowLayout());
+
+ center.add(content);
+ center.setPaddings(2);
+
+
+ north.add(new Label(Messages.getString(serv.getDescriptioni18n())));
+
+ ScenarioInstance si = (ScenarioInstance) todo.getScenarioInstanceAbstract();
+
+ fs = new FieldSet(Messages.getString("Proprietes"));
+ fs.setIconCls("iconTool16");
+ fs.setCollapsible(true);
+ fs.setAutoHeight(true);
+
+ folderName = new TextField(
+ null, "name", 250);
+
+
+
+
+ if (!activity.getId().equals("vaepp_evaluer")) {
+ folderName.setAllowBlank(false);
+ }
+
+ Label labelFolder = new Label();
+ labelFolder.setHtml("<nobr>"+Messages.getString("nom_du_dossier") + " : </nobr>");
+ Label labelDescription = new Label();
+ labelDescription.setHtml("<nobr>"+Messages.getString("Description") + " : </nobr>");
+
+ final Panel pcontainer = new Panel();
+
+ description = new RichTextArea();
+
+ RichTextToolbar toolbar = new RichTextToolbar(description);
+
+ final Grid grid = new Grid(3, 2);
+ grid.setStyleName("cw-RichText");
+
+ grid.setWidget(0, 0, labelFolder);
+ grid.setWidget(0, 1, folderName);
+ grid.setWidget(1, 0, labelDescription);
+
+ if (activity.getId().equals("vaepp_creer") || activity.getId().equals("vaepp_editer") || activity.getId().equals("vaepp_prevenir") ) {
+ pcontainer.add(description);
+ grid.setWidget(1, 1, toolbar);
+ grid.setWidget(2, 1, pcontainer);
+ }
+ else if (activity.getId().equals("vaepp_evaluer")){
+ pcontainer.setAutoScroll(true);
+ pcontainer.setSize(565, 210);
+ pcontainer.setHtml(desc);
+ pcontainer.setPaddings(5);
+ grid.setWidget(1, 1, pcontainer);
+
+ }
+
+
+
+ grid.getCellFormatter().addStyleName(0, 0, "align-top");
+ grid.getCellFormatter().addStyleName(1, 0, "align-top");
+
+ if (activity.getId().equals("vaepp_editer")
+ || activity.getId().equals("vaepp_evaluer")) {
+
+ getARW().setTitle(Messages.getString("Ressources_associees"));
+
+ Set<Ressource> ressourceSet = si.getEvaluationSubjectInstance()
+ .getRessources();
+
+ getARW().updateRessources(ressourceSet);
+
+ getARW().setReadOnly(false);
+ east.add(getARW());
+ if (activity.getId().equals("vaepp_evaluer")) {
+ getARW().setReadOnly(true);
+ }
+
+ }
+
+
+ folderName.setValue(name);
+ description.setHTML(desc);
+
+ tpanel = new TransitionPanel(todo, activity, this, false);
+
+ if (activity.getId().equals("vaepp_prevenir")) {
+
+ FieldSet prevenir = new FieldSet();
+
+ final FormPanel fp = new FormPanel();
+ fp.setBorder(false);
+
+ // FIXME : Hard Code PRDNAME !
+ fp.setLabelAlign(Position.TOP);
+ fp.setPaddings(12, 0, 0, 5);
+
+ cb = new OptSelectionEvalWidget(this, "Evaluateurs");
+
+ fp.add(cb, new AnchorLayoutData("95%"));
+
+ prevenir.add(fp);
+
+ FormPanel argPanel = new FormPanel();
+ argPanel.setLayout(new FormLayout());
+ argPanel.setBorder(false);
+ argPanel.setPaddings(10, 0, 0, 0);
+ argPanel.setLabelAlign(Position.TOP);
+ evaluateurChoiceArg = new TextArea(Messages.getString("Argumentaire_choix_evaluateur_candidat"));
+
+ evaluateurChoiceArg.setWidth(600);
+ evaluateurChoiceArg.setHeight(120);
+ argPanel.add(evaluateurChoiceArg, new AnchorLayoutData("95%"));
+
+ prevenir.add(argPanel);
+ content.add(prevenir, new RowLayoutData(300));
+
+
+
+ }
+ else if (false && activity.getId().equals("vaepp_evaluer")) {
+ tpanel.hideButtons();
+ }
+ else {
+ tpanel.showButtons();
+ }
+
+
+ fs.add(folderName);
+ fs.add(grid);
+
+ content.add(fs, new RowLayoutData(300));
+
+ if (!activity.getId().equals("vaepp_evaluer") && !activity.getId().equals("vaepp_editer") && si.getEvaluationSubjectInstance() != null){
+ west.add(new EvalSubViewWidget(todo), new RowLayoutData("50%"));
+ }
+ west.add(new ExtRessourcesPanel(todo, activity), new RowLayoutData("50%"));
+
+
+ if (activity.getId().equals("vaepp_editer")
+ || activity.getId().equals("vaepp_evaluer")) {
+
+ createTable();
+
+ }
+
+ south.add(tpanel);
+
+
+ if (!si.getEvaluationSubjectInstance().getMessages().isEmpty()) {
+ final Panel panel = new Panel();
+ panel.setLayout(new FitLayout());
+ panel.setCollapsible(true);
+ panel.setAutoScroll(true);
+ panel.setTitle(Messages.getString("discussion_a_propos") + " " + name);
+ final MessageSmartViewTab mvt = new MessageSmartViewTab();
+ panel.add(mvt);
+ panel.addListener(new PanelListenerAdapter(){
+ public void onResize(BoxComponent component, int adjWidth,
+ int adjHeight, int rawWidth, int rawHeight) {
+ int containerW = panel.getInnerWidth() - 20;
+ int containerH = panel.getInnerHeight() - 10;
+ if (mvt.getWidth() != containerW || mvt.getHeight() != containerH ){
+ if (containerW > 0 && containerH > 0){
+ mvt.resizeTo(containerW, containerH );
+ }
+ }
+ }
+
+ public void onDestroy(Component component) {
+ mvt.destroy();
+ }
+
+ });
+
+ content.add(panel, new RowLayoutData("50%"));
+ mvt.initializeViewMsgInterface(si.getEvaluationSubjectInstance()
+ .getMessages().iterator().next());
+ }
+
+ /*String isFirstTime = todo.getProcess().getPropertyByName(
+ "VARIABLE_isFirstTime").getValue();
+ */
+ if (activity.getId().equals("vaepp_editer")
+ //&& isFirstTime.equals("yes")
+ || activity.getId().equals("vaepp_choix") || activity.getId().equals("vaepp_prevenir")) {
+
+ Button e = new Button(Messages
+ .getString("vaepp_suppression_dossier"));
+ e.addListener(new ButtonListenerAdapter() {
+
+ public void onClick(Button button, EventObject e) {
+ killMe();
+ }
+
+ });
+
+ tpanel.insert(e, 0);
+ }
+
+ this.addListener(new PanelListenerAdapter(){
+
+ public void onAfterLayout(Container self) {
+
+
+ pcontainer.setWidth(fs.getWidth()-140);
+ if (activity.getId().equals("vaepp_creer")){
+ grid.setHeight(fs.getHeight()-100+"px");
+
+ pcontainer.setHeight(getHeight()-260);
+ description.setHeight(pcontainer.getHeight()+"px");
+ }
+ description.setWidth(pcontainer.getWidth()+"px");
+ folderName.setWidth(pcontainer.getWidth()+"px");
+
+
+ if (activity.getId().equals("vaepp_prevenir")){
+ fs.setCollapsed(true);
+ }
+
+ }
+
+
+ });
+
+
+ this.finalizeLayout();
+
+ }
+
+
+ /**
+ * Save folder info.
+ *
+ * @param login the login
+ * @param processID the process id
+ * @param activityID the activity id
+ * @param transID the trans id
+ */
+ public void saveFolderInfo(final String login, final String processID,
+ final String activityID, final String transID) {
+ // TODO Auto-generated method stub
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(fs.getId());
+ }
+
+ public void onSuccess(Object arg0) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(fs.getId());
+ ToastWindow tw = new ToastWindow(Messages
+ .getString("notification"), Messages
+ .getString("save_done"));
+ tw.show();
+ if (login != null) {
+ tpanel.performActivity(login, processID, activityID,
+ transID);
+ }
+
+ }
+
+ };
+
+
+
+
+ if (folderName.getValueAsString().equals("")) {
+ DateTimeFormat dtf = DateTimeFormat.getFormat("ddMMyyyy_HHmm"); //$NON-NLS-1$
+ folderName.setValue(dtf.format(new Date()));
+ }
+ Set<Property> sp = new HashSet<Property>();
+
+ Property name = new Property();
+ Property desc = new Property();
+
+ name.setName("VARIABLE_folder_name");
+
+
+ String dataName = folderName.getValueAsString();
+
+ if (dataName != null && dataName.length() > 255){
+ dataName = dataName.substring(0, 254);
+ folderName.setValue(dataName);
+ }
+
+ name.setValue(dataName);
+
+ desc.setName("VARIABLE_description");
+ desc.setValue(description.getHTML());
+
+ sp.add(name);
+ sp.add(desc);
+
+ Tools.showLoadingRegion(fs.getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.instanceService.setProperties(
+ todo.getProcess().getId(), sp, callback);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.ServiceAbstract#doAfterTransit()
+ */
+ public void doAfterTransit() {
+ if (activity.getId().equals("vaepp_prevenir")){
+ try{
+ String message = "";
+ ScenarioInstance si = (ScenarioInstance) todo.getScenarioInstanceAbstract();
+
+ String folderName = si.getEvaluationSubjectInstance().getName();
+ String evalName = "non spécifié";
+
+
+
+ User eval = (User)(cb.getSelectedUsers().values().iterator().next().iterator().next());
+ evalName = eval.getLastname() + " " + eval.getFirstname();
+
+ message = Format.format(Messages.getString("sended_folder"), folderName, evalName);
+
+ SC.say(Messages.getString("Information"), message);
+ }catch (Exception e){
+
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.ServiceAbstract#doBeforeTransit(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void doBeforeTransit(String login, String processID,
+ String activityID, String transID) {
+
+ if (activity.getId().equals("vaepp_creer")) {
+ this.saveFolderInfo(login, processID, activityID, transID);
+ } else if (activity.getId().equals("vaepp_editer")) {
+ this
+ .saveSelectionCompetences(login, processID, activityID,
+ transID);
+ } else if (activity.getId().equals("vaepp_evaluer")) {
+ this.confirmEvaluation(login, processID, activityID,
+ transID);
+ } else if (activity.getId().equals("vaepp_prevenir")) {
+ this.saveSelectionEvaluateur(login, processID, activityID, transID);
+ } else {
+
+ tpanel.performActivity(login, processID, activityID, transID);
+ }
+
+ }
+
+ /**
+ * Save selection evaluateur.
+ *
+ * @param login the login
+ * @param processID the process id
+ * @param activityID the activity id
+ * @param transID the trans id
+ */
+ private void saveSelectionEvaluateur(final String login,
+ final String processID, final String activityID,
+ final String transID) {
+ // TODO Auto-generated method stub
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ System.out.println("Probleme dans Suppression des ressources"); //$NON-NLS-1$
+ Tools.hideLoadingRegion(getId());
+ }
+
+ public void onSuccess(Object result) {
+ Tools.hideLoadingRegion(getId());
+ ToastWindow tw = new ToastWindow(Messages
+ .getString("notification"), Messages
+ .getString("save_done"));
+ tw.show();
+ if (login != null) {
+ tpanel.performActivity(login, processID, activityID,
+ transID);
+ }
+ }
+ };
+
+ Tools.showLoadingRegion(getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.instanceService
+ .setParticipantsWithArgument(todo.getScenarioInstanceAbstract().getId(), cb
+ .getSelectedUsers(),evaluateurChoiceArg.getText(), callback);
+ }
+
+ /**
+ * Initialize interface.
+ */
+ private void initializeInterface() {
+ content = new Panel();
+ content.setBorder(false);
+ content.setLayout(new RowLayout());
+ content.setAutoScroll(true);
+
+ this.setPaddings(5);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.pentila.evalcomp.client.services.ServiceAbstract#update()
+ */
+ @Override
+ public void update() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Creates the table.
+ */
+ public void createTable() {
+
+ final Panel header = new Panel();
+ header.setLayout(new FitLayout());
+ header.setTitle(Messages.getString("competences_associees"));
+ header.setCollapsible(true);
+ g = new EditorGrid(this.todo, this.activity, this);
+ g.setAutoScroll(true);
+ header.add(g);
+
+ content.add(header, new RowLayoutData("50%"));
+
+ content.addListener(new PanelListenerAdapter(){
+
+ public void onAfterLayout(Container self) {
+
+ if (!header.isCollapsed()){
+ header.setHeight(header.getHeight()-9);
+ }
+
+ }
+
+ });
+
+
+ if (activity.getId().equals("vaepp_editer")) {
+
+ Button b = new Button(Messages.getString("vaepp_save_selection"));
+
+ b.addListener(new ButtonListenerAdapter() {
+
+ public void onClick(Button button, EventObject e) {
+
+ saveSelectionCompetences(null, null, null, null);
+
+ }
+
+ });
+
+ tpanel.insert(b, 0);
+ }
+
+ if (activity.getId().equals("vaepp_evaluer")) {
+
+ Button d = new Button(Messages.getString("vaepp_en_attente"));
+ d.addListener(new ButtonListenerAdapter() {
+
+ public void onClick(Button button, EventObject e) {
+
+
+ saveEvaluationCompetences(null, null, null, null);
+
+ }
+
+ });
+
+ tpanel.insert(d, 0);
+
+ }
+
+ }
+
+ /**
+ * Save selection competences.
+ *
+ * @param login the login
+ * @param processID the process id
+ * @param activityID the activity id
+ * @param transID the trans id
+ */
+ public void saveSelectionCompetences(final String login,
+ final String processID, final String activityID,
+ final String transID) {
+
+ if (!g.isSelectedEmpty()) {
+
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(g.getId());
+ }
+
+ public void onSuccess(Object arg0) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(g.getId());
+ ToastWindow tw = new ToastWindow(Messages
+ .getString("notification"), Messages
+ .getString("save_done"));
+ tw.show();
+ saveFolderInfo(null, processID, activityID, transID);
+ if (login != null) {
+ tpanel.performActivity(login, processID, activityID,
+ transID);
+ }
+ }
+
+ };
+ Tools.showLoadingRegion(g.getId(), Messages.getString("MAJ"),
+ Messages.getString("Chargement"));
+ ConnexionServer.instanceService.populateCIs(UserTools.getUser()
+ .getUid(), todo.getProcess().getSIID(), g.getCompetenceArray(), callback);
+ } else {
+ MessageBox.alert(Messages.getString("Erreur"), Messages
+ .getString("vaepp_must_select"));
+ }
+ }
+
+ /**
+ * Save evaluation competences.
+ *
+ * @param login the login
+ * @param processID the process id
+ * @param activityID the activity id
+ * @param transID the trans id
+ */
+ public void saveEvaluationCompetences(final String login,
+ final String processID, final String activityID,
+ final String transID) {
+ Set<CompetenceInstance> cis = g.getEvaluatedCIs();
+
+ for (CompetenceInstance ci : cis) {
+ ci.setEvaluateur(UserTools.getUser());
+ }
+
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ System.out.println("Probleme dans le set des CI");
+ Tools.hideLoadingRegion(g.getId());
+ }
+
+ public void onSuccess(Object result) {
+ Tools.hideLoadingRegion(g.getId());
+ ToastWindow tw = new ToastWindow(Messages
+ .getString("notification"), Messages
+ .getString("save_done"));
+ tw.show();
+
+ if (login != null) {
+ tpanel.performActivity(login, processID, activityID,
+ transID);
+ }
+ }
+ };
+
+ Tools.showLoadingRegion(g.getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.instanceService.setCompetenceInstances(new ArrayList<CompetenceInstance>(cis), callback);
+
+ }
+
+
+ /**
+ * Confirm evaluation.
+ *
+ * @param login the login
+ * @param processID the process id
+ * @param activityID the activity id
+ * @param transID the trans id
+ */
+ private void confirmEvaluation(final String login,
+ final String processID, final String activityID,
+ final String transID){
+ String unSettedCI = null;
+
+ if (transID == null || "TRANSITION_terminer".equals(transID)){
+ Set<CompetenceInstance> sci = new HashSet<CompetenceInstance>();
+ sci = g.getEvaluatedCIs();
+
+ for (CompetenceInstance ci : sci) {
+ if (ci.getLevel().getInitial()){
+ unSettedCI = ci.getLevel().getName();
+ break;
+ }
+ }
+ }
+ if (unSettedCI != null){
+
+ final ExtWindow confirmWindow = new ExtWindow();
+ confirmWindow.setTitle(Messages.getString("Confirmation"));
+ confirmWindow.setClosable(false);
+ confirmWindow.setWidth(500);
+
+ confirmWindow.setPlain(true);
+
+ VerticalPanel vpMain = new VerticalPanel();
+
+ HTMLPanel message = new HTMLPanel(
+ Format.format(Messages.getString("evaluer_dossier_setting_missing") , new String[]{unSettedCI}));
+ message.setPaddings(15);
+ vpMain.add(message);
+
+ Button cancelButton = new Button(Messages.getString("Fermer"));
+ cancelButton.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ tpanel.showButtons();
+ confirmWindow.destroy();
+ }
+ });
+
+ confirmWindow.addButton(cancelButton);
+ confirmWindow.add(vpMain);
+ confirmWindow.show();
+ }else{
+ saveEvaluationCompetences(login, processID, activityID, transID);
+ }
+
+ }
+
+
+ /**
+ * Kill me.
+ */
+ public void killMe() {
+ final ExtWindow confirmWindow = new ExtWindow();
+
+ confirmWindow.setTitle(Messages.getString("vaepp_confirmation"));
+ confirmWindow.setClosable(false);
+ confirmWindow.setWidth(500);
+
+ confirmWindow.setPlain(true);
+
+ VerticalPanel vpMain = new VerticalPanel();
+
+ HTMLPanel message = new HTMLPanel("<b>"
+ + Messages.getString("vaepp_suppression_dossier") + "</b>");
+ message.setPaddings(15);
+ vpMain.add(message);
+
+ HTMLPanel message2 = new HTMLPanel(Messages
+ .getString("vaepp_suppression_dossier_body"));
+ message2.setPaddings(15);
+ vpMain.add(message2);
+
+ new FieldSet();
+ confirmWindow.setHeight(250);
+
+ Button okButton = new Button(Messages.getString("Oui"));
+ okButton.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+
+ killMeNow();
+ confirmWindow.destroy();
+ }
+ });
+
+ Button cancelButton = new Button(Messages.getString("Non"));
+ cancelButton.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+
+ confirmWindow.destroy();
+ }
+ });
+
+ confirmWindow.addButton(okButton);
+ confirmWindow.addButton(cancelButton);
+
+ confirmWindow.add(vpMain);
+ confirmWindow.show();
+
+ }
+
+ /**
+ * Kill me now.
+ */
+ public void killMeNow() {
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ System.out.println("Probleme dans le set des CI");
+ Tools.hideLoadingRegion(getId());
+ }
+
+ public void onSuccess(Object result) {
+ Tools.hideLoadingRegion(getId());
+ tpanel.redirect();
+ }
+ };
+
+ Set<Long> ssi = new HashSet<Long>();
+
+ ssi.add(todo.getScenarioInstanceAbstract().getId());
+ Tools.showLoadingRegion(getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.instanceService.deleteScenarioInstances(ssi, callback);
+ }
+
+
+ /**
+ * Sets the eval selected.
+ *
+ * @param valid the new eval selected
+ */
+ public void setEvalSelected(boolean valid) {
+ if (valid) {
+ this.tpanel.showButtons();
+ } else {
+ this.tpanel.hideButtons();
+ }
+
+ }
+
+ /**
+ * Sets the evaluation complete.
+ *
+ * @param complete the new evaluation complete
+ */
+ public void setEvaluationComplete(boolean complete) {
+ if (complete) {
+ this.tpanel.showButtons();
+ }
+ else {
+ this.tpanel.hideButtons();
+ }
+ }
+
+
+
+}