--- /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.validation;
+
+import com.google.gwt.user.client.ui.FormPanel;
+import com.google.gwt.user.client.ui.Hidden;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.BoxComponent;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.event.PanelListenerAdapter;
+import com.gwtext.client.widgets.layout.RowLayout;
+import com.gwtext.client.widgets.layout.RowLayoutData;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.services.ServiceAbstract;
+import com.pentila.evalcomp.client.services.widget.TransitionPanel;
+import com.pentila.evalcomp.client.utilities.Tools;
+import com.pentila.evalcomp.domain.definition.ScenarioDefinitionValidation;
+import com.pentila.evalcomp.domain.instance.ScenarioInstanceValidation;
+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;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DrawEvent;
+import com.smartgwt.client.widgets.events.DrawHandler;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
+import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
+
+/**
+ * The Class EvaluationService.
+ */
+public class ValiderService extends ServiceAbstract {
+
+
+
+ /** The instance validation id. */
+ private Long idPlanRef;
+
+ /** The validation grid. */
+ private ValidationGrid validationGrid;
+ private ValidationGridTheo validationGridTheo;
+
+ private FormPanel exportFormPanel;
+
+ private ValidationGridGlobal validationGridGlobal;
+
+ private Integer exportType = 1;
+
+ /**
+ * Instantiates a new evaluation service.
+ */
+ public ValiderService() {
+ super();
+
+ this.setTitle(Messages.getString("Valider"));
+ this.setIconCls("iconEvaluer32");
+
+ initializeInterface();
+
+ }
+
+ /**
+ * Configure service.
+ *
+ * @param todo
+ * the todo
+ * @param activity
+ * the activity
+ */
+ @SuppressWarnings("unchecked")
+ public void configureService(final Todo todo, Activity activity) {
+ super.configureService(todo, activity);
+ this.todo = todo;
+ Service serv = activity.getExtActivity().getService();
+
+ //this.setTitle(Messages.getString(serv.getTitlei18n()));
+
+
+ this.setIconCls("iconValider32");
+
+ final ScenarioInstanceValidation siv = (ScenarioInstanceValidation) todo
+ .getScenarioInstanceAbstract();
+
+ ScenarioDefinitionValidation sdv = (ScenarioDefinitionValidation) siv
+ .getScenarioDefinition();
+
+ clearZones();
+ content = new Panel();
+ content.setBorder(false);
+ content.setLayout(new RowLayout());
+ content.setAutoScroll(true);
+ center.add(content);
+
+ north.add(new Label(Messages.getString(serv.getTitlei18n())));
+
+
+ PlanRef pr = (PlanRef) sdv.getPlanComponent();
+
+ idPlanRef = pr.getId();
+
+ tpanel = new TransitionPanel(todo, activity, this, true);
+
+ // FIXME : HARD CODE ROLE_OBSERVER !
+ boolean isObserver = todo.hasRole("ROLE_OBSERVER", activity);
+
+
+ Canvas a= null;
+ if (pr.getMethodValidationInstances().size()>1){
+
+ TabSet tabSet = new TabSet();
+ final Tab tab1 = new Tab(Messages.getString("Global"));
+ Tab tab2 = new Tab(Messages.getString("Pratique"));
+ Tab tab3 = new Tab(Messages.getString("Theorique"));
+
+ validationGridGlobal = new ValidationGridGlobal(pr, null, isObserver);
+
+ tab1.setPane(validationGridGlobal);
+
+ tabSet.addDrawHandler(new DrawHandler(){
+
+ public void onDraw(DrawEvent event) {
+ tab1.addTabSelectedHandler(new TabSelectedHandler(){
+
+ public void onTabSelected(TabSelectedEvent event) {
+ exportType = 1;
+ if (!validationGridGlobal.getInitialized()){
+ validationGridGlobal.initializeInterface();
+ }else{
+ validationGridGlobal.update();
+ }
+
+ }
+
+ });
+ exportType = 1;
+ validationGridGlobal.initializeInterface();
+
+ }
+
+ });
+
+ tab2.addTabSelectedHandler(new TabSelectedHandler(){
+
+ public void onTabSelected(TabSelectedEvent event) {
+
+ exportType = 0;
+
+ if (!validationGrid.getInitialized()){
+ validationGrid.initializeInterface();
+ }else{
+ validationGrid.update();
+ }
+ }
+
+ });
+
+ validationGrid = new ValidationGrid(pr, null, isObserver);
+ tab2.setPane(validationGrid);
+
+ validationGridTheo = new ValidationGridTheo(pr, null, isObserver);
+ tab3.setPane(validationGridTheo);
+ tab3.addTabSelectedHandler(new TabSelectedHandler(){
+
+ public void onTabSelected(TabSelectedEvent event) {
+
+ exportType = 2;
+
+ if (!validationGridTheo.getInitialized()){
+ validationGridTheo.initializeInterface();
+ }else{
+ validationGridTheo.update();
+ }
+ }
+
+ });
+
+ tabSet.setTabs(tab1, tab2, tab3);
+ content.add(tabSet, new RowLayoutData("100%"));
+ a = tabSet;
+
+ }else if (pr.getMethodValidationInstance() != null){
+
+ exportType = 0;
+
+ validationGrid = new ValidationGrid(pr, null, isObserver);
+ content.add(validationGrid, new RowLayoutData("100%"));
+ validationGrid.initializeInterface();
+ a = validationGrid;
+ }else if (pr.getMethodValidationInstanceTheorique() != null){
+
+ exportType = 2;
+
+ validationGridTheo = new ValidationGridTheo(pr, null, isObserver);
+ content.add(validationGridTheo, new RowLayoutData("100%"));
+ validationGridTheo.initializeInterface();
+
+ }
+ final Canvas v = a;
+
+ content.addListener(new PanelListenerAdapter(){
+
+
+ public void onResize(BoxComponent component, int adjWidth,
+ int adjHeight, int rawWidth, int rawHeight) {
+
+ int containerW = content.getInnerWidth();
+ int containerH = content.getInnerHeight();
+
+ if (v.getWidth() != containerW || v.getHeight() != containerH ){
+
+ if (containerW > 0 && containerH > 0){
+
+ v.resizeTo(containerW, containerH );
+
+
+ }
+
+ }
+
+ }
+
+ });
+ this.addListener(new PanelListenerAdapter(){
+ public void onDestroy(Component component)
+ {
+ v.destroy();
+
+ }
+ });
+ initializeExport(null);
+
+
+ south.add(tpanel);
+ tpanel.showButtons();
+
+
+
+ finalizeLayout();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.pentila.evalcomp.client.services.IServiceProvider#doAfterTransit()
+ */
+ public void doAfterTransit() {
+
+
+ validationGrid.disable();
+
+ }
+
+ /*
+ * (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(final String login, final String processID,
+ final String activityID, final String transID) {
+
+ }
+
+ /**
+ * Initialize interface.
+ */
+ private void initializeInterface() {
+
+ this.setPaddings(5);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.pentila.evalcomp.client.services.IServiceProvider#update()
+ */
+ public void update() {
+
+ validationGrid.updateGrid(idPlanRef, null, 0, 50, null);
+
+ }
+
+ public void initializeExport(final Long sicId){
+ VerticalPanel vp = new VerticalPanel();
+ exportFormPanel = new com.google.gwt.user.client.ui.FormPanel("_target");
+ exportFormPanel.setWidget(vp);
+ exportFormPanel.setAction(Tools.getExportAccessURL());
+ exportFormPanel.setMethod(com.google.gwt.user.client.ui.FormPanel.METHOD_POST);
+
+
+ final Hidden hIVID = new Hidden("IVID" , "");
+ final Hidden hGID = new Hidden("GID", "");
+ final Hidden hUids = new Hidden("uids", "");
+ final Hidden typeExport = new Hidden("typeExport", "");
+ vp.add(hIVID);
+ vp.add(hGID);
+ vp.add(hUids);
+ Button exportButton = new Button(Messages.getString("Exporter"),
+ new ButtonListenerAdapter() {
+ public void onClick(Button button, EventObject e) {
+
+ String GID = "";
+ String uids = "";
+
+ if (sicId != null) {
+ GID = "" + sicId;
+ }
+
+
+ switch (exportType){
+ case 0:
+ uids = validationGrid.getSel();
+ break;
+ case 1:
+ uids = validationGridGlobal.getSel();
+ break;
+ case 2:
+ uids = validationGridTheo.getSel();
+ break;
+ }
+
+ if (!uids.equals("")) {
+ hIVID.setValue("" + idPlanRef);
+ hGID.setValue(GID);
+ hUids.setValue(uids);
+ typeExport.setValue("" + exportType);
+ exportFormPanel.submit();
+
+
+ }else{
+ MessageBox.alert(Messages.getString("Vous_devez_selectionner_au_moins_un_candidat"));
+ }
+
+ }
+ });
+ tpanel.add(exportButton);
+ content.add(exportFormPanel);
+ }
+}