--- /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.plan;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.core.Function;
+import com.gwtext.client.core.SortDir;
+import com.gwtext.client.data.ArrayReader;
+import com.gwtext.client.data.FieldDef;
+import com.gwtext.client.data.MemoryProxy;
+import com.gwtext.client.data.ObjectFieldDef;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.data.RecordDef;
+import com.gwtext.client.data.SortState;
+import com.gwtext.client.data.Store;
+import com.gwtext.client.data.StringFieldDef;
+import com.gwtext.client.util.Format;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.TabPanel;
+import com.gwtext.client.widgets.Tool;
+import com.gwtext.client.widgets.Window;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.Checkbox;
+import com.gwtext.client.widgets.form.Field;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.TextArea;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.event.CheckboxListenerAdapter;
+import com.gwtext.client.widgets.form.event.FieldListenerAdapter;
+import com.gwtext.client.widgets.grid.CellMetadata;
+import com.gwtext.client.widgets.grid.ColumnConfig;
+import com.gwtext.client.widgets.grid.ColumnModel;
+import com.gwtext.client.widgets.grid.GridPanel;
+import com.gwtext.client.widgets.grid.Renderer;
+import com.gwtext.client.widgets.layout.AnchorLayoutData;
+import com.gwtext.client.widgets.layout.ColumnLayout;
+import com.gwtext.client.widgets.layout.ColumnLayoutData;
+import com.gwtext.client.widgets.layout.FitLayout;
+import com.gwtext.client.widgets.layout.FormLayout;
+import com.gwtext.client.widgets.layout.HorizontalLayout;
+import com.gwtext.client.widgets.layout.RowLayout;
+import com.gwtext.client.widgets.layout.VerticalLayout;
+import com.pentila.evalcomp.client.ConnexionServer;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.palette.PlanPalettePanel;
+import com.pentila.evalcomp.client.palette.WorkspacePalettePanel;
+import com.pentila.evalcomp.client.plan.widget.PlanMethodEvalWidget;
+import com.pentila.evalcomp.client.plan.widget.PlanRoleWidget;
+import com.pentila.evalcomp.client.plan.widget.PlanScenarioWidget;
+import com.pentila.evalcomp.client.plan.widget.PlanTabPanelRefWidget;
+import com.pentila.evalcomp.client.utilities.ITabManager;
+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.domain.definition.EvaluationDefinition;
+import com.pentila.evalcomp.domain.plan.Plan;
+import com.pentila.evalcomp.domain.transit.TCompositeStat;
+import com.rednels.ofcgwt.client.ChartWidget;
+import com.rednels.ofcgwt.client.model.ChartData;
+import com.rednels.ofcgwt.client.model.Text;
+import com.rednels.ofcgwt.client.model.axis.XAxis;
+import com.rednels.ofcgwt.client.model.axis.YAxis;
+import com.rednels.ofcgwt.client.model.elements.BarChart;
+import com.rednels.ofcgwt.client.model.elements.BarChart.Bar;
+import com.rednels.ofcgwt.client.model.elements.BarChart.BarStyle;
+
+/**
+ * The Class EvalManagementTab. A tab for the manager to edit an evaluation
+ * definition
+ */
+public class PlanManagementTab extends Panel {
+
+ /** The eval imp cb. */
+ private Checkbox evalImpCB = null;
+
+ /** is the interface initialized. */
+ private boolean isInitialized = false;
+
+ /** The method eval imp cb. */
+ private Checkbox methodEvalImpCB = null;
+
+ /** Store if we are in read only mode or not. */
+ private Boolean readOnly = true;
+
+ /** The ref imp cb. */
+ private Checkbox refImpCB = null;
+
+ /** Combobox "impératif / indicatif". */
+ private Checkbox scenarioImpCB = null;
+
+ // Definition des differents panel
+ /** The content v panel. */
+ private Panel contentVPanel;
+
+ /** The current plan shown. */
+ private Plan currentPlanShown = null;
+
+ /** The h role panel. */
+ private HorizontalPanel hRolePanel = null;
+
+ /** The plan_autor. */
+ private TextField plan_autor;
+
+ /** The plan_contact. */
+ private TextField plan_contact;
+
+ /** The plan_date. */
+ private TextField plan_date;
+
+ /** The plan_name. */
+ private TextField plan_name;
+
+ /** The plan_organisation. */
+ private TextArea plan_organisation;
+
+ /** The plan_city. */
+ private TextField plan_city;
+
+ // Information sur le plan
+
+ /** The plan infos field set. */
+ private FieldSet planInfosFS;
+
+ /** The plan meth eval widget. */
+ private PlanMethodEvalWidget planMethEvalWidget = null;
+
+
+ // Information sur les planRef
+ /** The plan referentiel field set. */
+ private FieldSet planRefFS;
+
+ // Information sur les roles
+
+ /** The plan role field set. */
+ private FieldSet planRoleFS;
+
+ // Information sur les scenario et methode d evaluation
+ /** The plan scenarios and meth eval field set. */
+ private FieldSet planScenarioFS;
+
+ /** The plan sc widget. */
+ private PlanScenarioWidget planScWidget = null;
+
+ /** The tab ref panel. */
+ private PlanTabPanelRefWidget tabRefPanel;
+
+ /** The v ref panel. */
+ private Panel vRefPanel;
+
+ /** The it manager. */
+ ITabManager itManager;
+
+ /**
+ * Instantiates a new plan management tab.
+ *
+ * @param ro the ro
+ * @param itManager the it manager
+ */
+ public PlanManagementTab(Boolean ro, final ITabManager itManager) {
+ super(Messages.getString("Plan_de_formation"));
+
+ this.itManager = itManager;
+
+ this.readOnly = ro;
+
+ contentVPanel = new Panel();
+ contentVPanel.setPaddings(5);
+ contentVPanel.setLayout(new RowLayout());
+ contentVPanel.setAutoScroll(true);
+ this.setLayout(new FitLayout());
+ this.setAutoScroll(true);
+
+ this.setIconCls("iconPlan32"); //$NON-NLS-1$
+
+ if (UserTools.getUser().hasRole("ROLE_MANAGER")) {
+
+ Tool tt = new Tool(Tool.SAVE, new Function() {
+
+ public void execute() {
+
+ if (currentPlanShown != null
+ && UserTools.getUser().hasRole("ROLE_MANAGER")) {
+
+ chooseEDWindow();
+
+ }
+ }
+
+ }, Messages.getString("Obtenir_les_statistiques_sur_le_plan_"));
+
+ this.addTool(tt);
+ }
+
+ this.initializePlanInfoInterface();
+
+ this.initializePlanScMethInterface();
+
+ this.initializePlanRoleInterface();
+
+ this.initializePlanRefInterface();
+
+ this.add(contentVPanel);
+
+ }
+
+ /**
+ * Choose ed window.
+ */
+ public void chooseEDWindow() {
+
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(getId());
+ }
+
+ public void onSuccess(Object result) {
+ // TODO Auto-generated method stub
+
+ Plan plan = (Plan) result;
+
+ final ExtWindow w = new ExtWindow();
+
+ Renderer renderEval = new Renderer() {
+ public String render(Object value,
+ CellMetadata cellMetadata, Record record,
+ int rowIndex, int colNum, Store store) {
+ String evalName = record.getAsString("name");
+
+ if (evalName.length() > 20) {
+ cellMetadata.setHtmlAttribute("ext:qtip=\""
+ + evalName + "\"");
+ }
+ return Format
+ .format(
+ "<img src=\"" + Tools.getBaseURL() //$NON-NLS-1$
+ + "images/campagne16.png\"> {0}", new String[] { evalName, }); //$NON-NLS-1$
+ }
+ };
+
+ RecordDef recordDef = new RecordDef(new FieldDef[] {
+ new ObjectFieldDef("id"), new StringFieldDef("name")
+
+ });
+
+ final GridPanel grid = new GridPanel();
+
+ //Filtre sur le type de scénario d'evaluation (-examen)
+ Set<EvaluationDefinition> sed = new HashSet<EvaluationDefinition>();
+ for (EvaluationDefinition ed : plan.getEvaluationDefinitions()){
+
+ String sType = null;
+
+ if (ed.getScenarioDefinitions() != null && !ed.getScenarioDefinitions().isEmpty()){
+ sType = ed.getScenarioDefinitions().iterator().next().getType();
+ }
+
+ if (sType == null || !sType.endsWith("-EXAMEN")){
+ sed.add(ed);
+ }
+ }
+
+
+ int i = 0;
+ Object[][] data = new Object[sed.size()][];
+ for (EvaluationDefinition ed : sed) {
+
+ data[i++] = new Object[] { ed.getId(), ed.getName() };
+ }
+
+ MemoryProxy proxy = new MemoryProxy(data);
+
+ ArrayReader reader = new ArrayReader(recordDef);
+ Store store = new Store(proxy, reader);
+ store.setSortInfo(new SortState("name", SortDir.ASC));
+ store.load();
+
+ grid.setStore(store);
+
+ ColumnConfig[] columns = new ColumnConfig[] { new ColumnConfig(
+ Messages.getString("Campagnes_d_evaluation"), "name",
+ 300, true, renderEval, "name") };
+
+ ColumnModel cm = new ColumnModel(columns);
+ grid.setColumnModel(cm);
+
+ grid.setFrame(true);
+ grid.setStripeRows(true);
+ grid.setAutoExpandColumn("name");
+ grid.setHeight(200);
+ grid.setWidth(330);
+
+ w.add(grid);
+
+ Button stat = new Button(Messages.getString("Statistiques"));
+ stat.addListener(new ButtonListenerAdapter() {
+
+ public void onClick(Button button, EventObject e) {
+
+ Record[] records = grid.getSelectionModel()
+ .getSelections();
+
+ if (records != null && records.length != 0) {
+ w.close();
+ Set<Long> sl = new HashSet<Long>();
+ for (Record r : records) {
+ sl.add((Long) r.getAsObject("id"));
+ }
+ getPlanStatistics(sl);
+
+ } else {
+
+ w.close();
+ }
+ }
+
+ });
+
+ Button close = new Button(Messages.getString("Fermer"));
+ close.addListener(new ButtonListenerAdapter() {
+
+ public void onClick(Button button, EventObject e) {
+
+ w.close();
+
+ }
+
+ });
+
+ w.addButton(stat);
+ w.addButton(close);
+ w.setSize(350, 250);
+ w.show();
+
+ Tools.hideLoadingRegion(getId());
+
+ }
+
+ };
+
+ Tools.showLoadingRegion(getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ RequestBuilder rb = ConnexionServer.planService.getPlan(
+ currentPlanShown.getId(), callback);
+ rb.setHeader("code", "A18");
+ ConnexionServer.doSend(rb);
+
+ }
+
+ /**
+ * Gets the plan statistics.
+ *
+ * @param idEDs the id e ds
+ * @return the plan statistics
+ */
+ public void getPlanStatistics(final Set<Long> idEDs) {
+
+ AsyncCallback callback = new AsyncCallback() {
+ public void onFailure(Throwable caught) {
+ // do some UI stuff to show failure
+ System.out.println("Probleme dans la sauvegarde de l eval"); //$NON-NLS-1$
+ Tools.hideLoadingRegion(getId());
+ }
+
+ public void onSuccess(Object result) {
+ TCompositeStat tcs = (TCompositeStat) result;
+
+ String swfurl = Tools.getBaseURL() + "ofcgwt/open-flash-chart.swf";
+ String path = tcs.getPath();
+
+ WorkspacePalettePanel wpp = (WorkspacePalettePanel) itManager
+ .getPaletteById("WorkspacePalettePanel");
+
+ wpp.setWsPaletteInitialized(true);
+ wpp.expand();
+
+ wpp.update("/" + path);
+ int chartWidth = 1000;
+ int chartHeight = 500;
+ Tools.hideLoadingRegion(getId());
+
+ ExtWindow w = new ExtWindow();
+ w.setTitle(Messages.getString("Statistiques"));
+ w.setAutoScroll(true);
+
+ Button saveButton = new Button(Messages.getString("Enregistrer"));
+
+ saveButton.addListener(new ButtonListenerAdapter(){
+ public void onClick(Button button, EventObject e) {
+
+ AsyncCallback recallback = new AsyncCallback(){
+
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+ Tools.hideLoadingRegion(getId());
+ }
+
+ public void onSuccess(Object result) {
+ TCompositeStat tcs = (TCompositeStat) result;
+ String path = tcs.getPath();
+ WorkspacePalettePanel wpp = (WorkspacePalettePanel)itManager.getPaletteById("WorkspacePalettePanel");
+
+ wpp.setWsPaletteInitialized(true);
+ wpp.expand();
+
+ wpp.update("/"+path);
+ Tools.hideLoadingRegion(getId());
+ }
+
+ };
+
+ Tools.showLoadingRegion(getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.planService.getPlanStatistics(currentPlanShown.getId(),
+ idEDs, true, recallback);
+
+ }
+ });
+
+ w.addButton(saveButton);
+
+ TabPanel tp = new TabPanel();
+
+ for (Entry<String, Map<Integer, Integer>> entry : tcs.getMap()
+ .entrySet()) {
+
+ String title = entry.getKey();
+ Map<Integer, Integer> m = entry.getValue();
+
+ Panel tab = new Panel();
+ tab.setWidth(chartWidth);
+ tab.setHeight(chartHeight);
+
+ tab.setTitle(Messages.getString(title + "_title"));
+
+ ChartWidget chart = new ChartWidget();
+
+ chart.setUrlPrefix(swfurl);
+ chart.setFlashUrl("");
+
+ ChartData cd = new ChartData(Messages.getString(title
+ + "_title"));
+ cd.setBackgroundColour("#ffffff");
+
+
+ List<Bar> sb = new ArrayList<Bar>();
+
+ List<Integer> li = new ArrayList<Integer>(m.keySet());
+
+ Collections.sort(li, new Comparator<Integer>() {
+
+ public int compare(Integer o1, Integer o2) {
+ return o1.compareTo(o2);
+ }
+
+ });
+
+ int range = Collections.max(m.values());
+
+
+
+ XAxis xa = new XAxis();
+
+ xa.setZDepth3D(8);
+ xa.setColour("#909090");
+
+ xa.setMax(li.size());
+
+ cd.setXAxis(xa);
+
+ YAxis ya = new YAxis();
+
+ ya.setSteps(range/15);
+ ya.setMax(range);
+ ya.setGridColour("#909090");
+ cd.setYAxis(ya);
+
+ BarChart bchart = new BarChart(BarStyle.THREED);
+
+ bchart.setColour("#ff8800");
+
+ List<String> xlabels = new ArrayList<String>();
+
+ for (Integer i : li) {
+
+ xlabels.add("" + i);
+
+ Bar b = new Bar(m.get(i));
+
+
+ b.setTooltip(Format.format(Messages.getString(title
+ + "_body"), new String[] { "" + m.get(i),
+ "" + i }));
+
+ sb.add(b);
+ }
+
+ xa.setLabels(xlabels);
+ bchart.addBars(sb);
+
+ cd.setXLegend(new Text(Messages.getString(title + "_Y"),
+ "font-size: 11px;"));
+ cd.setYLegend(new Text(Messages.getString(title + "_X"),
+ "font-size: 11px;"));
+ cd.addElements(bchart);
+
+ chart.setSize("" + chartWidth, "" + chartHeight); //$NON-NLS-1$ //$NON-NLS-2$
+
+ chart.setChartData(cd);
+ chart.setCacheFixEnabled(true);
+ tab.add(chart);
+ tp.add(tab);
+
+ }
+
+ w.add(tp);
+
+ w.setWidth(1100);
+ w.setHeight(600);
+
+ w.show();
+
+ }
+ };
+ Tools.showLoadingRegion(getId(), Messages.getString("MAJ"), Messages
+ .getString("Chargement"));
+ ConnexionServer.planService.getPlanStatistics(currentPlanShown.getId(),
+ idEDs, false, callback);
+
+ }
+
+ /**
+ * Initialize evaluation definition information GUI.
+ */
+ private void initializePlanInfoInterface() {
+
+
+
+ planInfosFS = new FieldSet(Messages.getString("Proprietes"));
+ planInfosFS.setIconCls("iconTool16");
+
+
+ planInfosFS.setCollapsible(true);
+ planInfosFS.setAutoHeight(true);
+
+
+ Panel topPanel = new Panel();
+
+
+ topPanel.setLayout(new ColumnLayout());
+ topPanel.setBorder(false);
+ topPanel.setPaddings(5);
+ Panel columnOnePanel = new Panel();
+ columnOnePanel.setPaddings(5);
+ columnOnePanel.setBorder(false);
+ columnOnePanel.setLayout(new FormLayout());
+
+ plan_name = new TextField(Messages.getString("Nom"), "name", 225);
+ if (readOnly) {
+ plan_name.setReadOnly(true);
+ } else {
+ plan_name.setAllowBlank(false);
+ plan_name.addListener(new FieldListenerAdapter() {
+ @Override
+ public void onChange(Field field, Object newVal, Object oldVal) {
+ savePlanInfo();
+ }
+ });
+ }
+
+ columnOnePanel.add(plan_name, new AnchorLayoutData("95%"));
+
+
+ plan_organisation = new TextArea(Messages.getString("Organisation"),
+ "organisation");
+ plan_organisation.setWidth(225);
+ if (readOnly) {
+ plan_organisation.setReadOnly(true);
+ } else {
+ plan_organisation.setAllowBlank(false);
+ plan_organisation.addListener(new FieldListenerAdapter() {
+ @Override
+ public void onChange(Field field, Object newVal, Object oldVal) {
+ savePlanInfo();
+ }
+ });
+ }
+
+ columnOnePanel.add(plan_organisation, new AnchorLayoutData("95%"));
+
+ plan_city = new TextField(Messages.getString("Ville"), "city", 225);
+ if (readOnly) {
+ plan_city.setReadOnly(true);
+ } else {
+ plan_city.setAllowBlank(false);
+ plan_city.addListener(new FieldListenerAdapter() {
+ @Override
+ public void onChange(Field field, Object newVal, Object oldVal) {
+ savePlanInfo();
+ }
+ });
+ }
+
+ columnOnePanel.add(plan_city, new AnchorLayoutData("95%"));
+
+ topPanel.add(columnOnePanel, new ColumnLayoutData(.5));
+
+ Panel columnTwoPanel = new Panel();
+ columnTwoPanel.setBorder(false);
+ columnTwoPanel.setLayout(new FormLayout());
+ columnTwoPanel.setPaddings(5);
+ plan_autor = new TextField(Messages.getString("Auteur"), "auteur", 225);
+ plan_autor.setReadOnly(true);
+ columnTwoPanel.add(plan_autor, new AnchorLayoutData("95%"));
+
+ plan_contact = new TextField(
+ Messages.getString("Contact"), "contact", 225); //$NON-NLS-1$ //$NON-NLS-2$
+ plan_contact.setReadOnly(true);
+ columnTwoPanel.add(plan_contact, new AnchorLayoutData("95%"));
+
+ plan_date = new TextField(
+ Messages.getString("Date_de_creation"), "date", 225); //$NON-NLS-1$ //$NON-NLS-2$
+ plan_date.setReadOnly(true);
+ columnTwoPanel.add(plan_date, new AnchorLayoutData("95%"));
+
+ topPanel.add(columnTwoPanel, new ColumnLayoutData(0.5));
+
+ planInfosFS.add(topPanel);
+
+
+
+ contentVPanel.add(planInfosFS);
+
+ }
+
+ /**
+ * Initialize ref information GUI.
+ */
+ private void initializePlanRefInterface() {
+
+
+
+ planRefFS = new FieldSet(Messages.getString("Referentiels"));
+
+ planRefFS.setCollapsible(true);
+ planRefFS.setAutoHeight(true);
+
+ planRefFS.setStyleName("main_panel");
+
+ vRefPanel = new Panel();
+ vRefPanel.setLayout(new RowLayout());
+ //vRefPanel.setSpacing(5);
+ vRefPanel.setStyleName("noBorderPanel");
+
+
+ HorizontalPanel hPan = new HorizontalPanel();
+ hPan.setStyleName("noBorderPanel");
+ refImpCB = new Checkbox();
+ refImpCB.setBoxLabel(Messages.getString("referentiel_imperatif"));
+
+ if (readOnly) {
+ refImpCB.setReadOnly(true);
+ refImpCB.disable();
+
+ } else {
+ refImpCB.setReadOnly(false);
+
+ refImpCB.addListener(new CheckboxListenerAdapter() {
+ @Override
+ public void onCheck(Checkbox field, boolean checked) {
+ if (checked) {
+ evalImpCB.enable();
+ savePlanInfo();
+ } else {
+ evalImpCB.disable();
+ // this operation save the plan info
+ evalImpCB.setChecked(false);
+ }
+
+ }
+ });
+ }
+
+ evalImpCB = new Checkbox();
+ evalImpCB.disable();
+ evalImpCB.setBoxLabel(Messages.getString("evaluateurs_imperatif"));
+
+ if (readOnly) {
+ evalImpCB.setReadOnly(true);
+
+ } else {
+ evalImpCB.setReadOnly(false);
+
+ evalImpCB.addListener(new CheckboxListenerAdapter() {
+ @Override
+ public void onCheck(Checkbox field, boolean checked) {
+ savePlanInfo();
+ }
+ });
+ }
+
+ FormPanel fp = new FormPanel();
+ fp.setBorder(false);
+
+ fp.setLabelWidth(10);
+ fp.add(refImpCB);
+ fp.add(evalImpCB);
+ hPan.add(fp);
+
+ if (!readOnly) {
+ //planRefChoose = new PlanRefChoosedWidget();
+ //hPan.add(planRefChoose);
+ }
+
+ vRefPanel.add(hPan);
+ planRefFS.add(vRefPanel);
+
+
+
+ contentVPanel.add(planRefFS);
+
+ }
+
+ /**
+ * Initialize role information GUI.
+ */
+ private void initializePlanRoleInterface() {
+ planRoleFS = new FieldSet(Messages
+ .getString("Attribution_des_roles"));
+ //planRoleFieldSet.setIconCls("iconTool16");
+ //planRoleFieldSet.setWidth("577px");
+
+ planRoleFS.setCollapsible(true);
+ planRoleFS.setAutoHeight(true);
+ planRoleFS.setStyleName("main_panel");
+
+ hRolePanel = new HorizontalPanel();
+ hRolePanel.setSpacing(5);
+ //hRolePanel.setLayout(new HorizontalLayout(5));
+ //hRolePanel.setBorder(true);
+
+ planRoleFS.add(hRolePanel);
+
+ contentVPanel.add(planRoleFS);
+
+ }
+
+ /**
+ * Initialize evaluation definition information GUI.
+ */
+ private void initializePlanScMethInterface() {
+ // TODO Auto-generated method stub
+ planScenarioFS = new FieldSet(Messages
+ .getString("Scenario_et_methode_d_evaluation"));
+ //planScenarioFieldSet.setIconCls("iconTool16");
+ //planScenarioFieldSet.setWidth("577px");
+
+ planScenarioFS.setCollapsible(true);
+ planScenarioFS.setAutoHeight(true);
+ planScenarioFS.setStyleName("main_panel");
+
+ Panel hPanel = new Panel();
+ hPanel.setPaddings(5);
+ hPanel.setLayout(new HorizontalLayout(5));
+ hPanel.setBorder(false);
+
+ Panel vPan1 = new Panel();
+ vPan1.setLayout(new VerticalLayout());
+ vPan1.setBorder(false);
+
+ planScWidget = new PlanScenarioWidget(
+ this.currentPlanShown, readOnly);
+ vPan1.add(planScWidget);
+
+ scenarioImpCB = new Checkbox();
+ scenarioImpCB.setBoxLabel(Messages.getString("imperatif"));
+
+ if (readOnly) {
+ scenarioImpCB.setReadOnly(true);
+ scenarioImpCB.disable();
+ } else {
+ scenarioImpCB.setReadOnly(false);
+
+ scenarioImpCB.addListener(new CheckboxListenerAdapter() {
+ @Override
+ public void onCheck(Checkbox field, boolean checked) {
+ savePlanInfo();
+ }
+ });
+ }
+ FormPanel fp1 = new FormPanel();
+ fp1.setBodyBorder(false);
+ fp1.add(scenarioImpCB);
+ vPan1.add(fp1);
+
+ hPanel.add(vPan1);
+
+ Panel vPan2 = new Panel();
+ vPan2.setLayout(new VerticalLayout());
+ vPan2.setBorder(false);
+
+ planMethEvalWidget = new PlanMethodEvalWidget(
+ this.currentPlanShown, readOnly);
+
+ vPan2.add(planMethEvalWidget);
+
+ methodEvalImpCB = new Checkbox();
+ methodEvalImpCB.setBoxLabel(Messages.getString("imperatif"));
+
+ if (readOnly) {
+ methodEvalImpCB.setReadOnly(true);
+ methodEvalImpCB.disable();
+ } else {
+ methodEvalImpCB.setReadOnly(false);
+
+ methodEvalImpCB.addListener(new CheckboxListenerAdapter() {
+ @Override
+ public void onCheck(Checkbox field, boolean checked) {
+ savePlanInfo();
+ }
+ });
+ }
+ FormPanel fp2 = new FormPanel();
+ fp2.setBodyBorder(false);
+ fp2.add(methodEvalImpCB);
+ vPan2.add(fp2);
+
+ hPanel.add(vPan2);
+
+ planScenarioFS.add(hPanel);
+
+ contentVPanel.add(planScenarioFS);
+
+ }
+
+ /**
+ * Save evaluation subject information.
+ */
+ private void savePlanInfo() {
+ if (isInitialized && currentPlanShown != null && plan_name.isValid()
+ && plan_organisation.isValid()) {
+
+ if (!currentPlanShown.getName()
+ .equals(plan_name.getValueAsString())) {
+ currentPlanShown.setName(plan_name.getValueAsString());
+ PlanPalettePanel.updatePlanName(currentPlanShown);
+ }
+
+ currentPlanShown.setOrganisationName(plan_organisation
+ .getValueAsString());
+
+ currentPlanShown.setScenarioLock(scenarioImpCB.getValue());
+ currentPlanShown.setMethodEvalLock(methodEvalImpCB.getValue());
+ currentPlanShown.setPlanRefLock(refImpCB.getValue());
+ currentPlanShown.setEntityLock(evalImpCB.getValue());
+ currentPlanShown.setCity(plan_city.getValueAsString());
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ // do some UI stuff to show failure
+ System.out
+ .println("Probleme dans la sauvegarde du plan de formation");
+ }
+
+ public void onSuccess(Object result) {
+
+ }
+ };
+ ConnexionServer.planService.editPlan(currentPlanShown, callback);
+ } else {
+ plan_name.validate();
+ plan_organisation.validate();
+ }
+
+ }
+
+ /**
+ * Show the evaluation definition selected.
+ *
+ * @param myPlan
+ * the my plan
+ */
+ public void showPlanSelected(Plan myPlan) {
+
+ isInitialized = false;
+ currentPlanShown = myPlan;
+ this.updatePlanInfo();
+ planScWidget.updatePlanScGrid(currentPlanShown);
+ planMethEvalWidget.updateMethEvalGrid(currentPlanShown);
+
+
+ this.updateRoleInterface();
+ this.updateRefInterface();
+
+ scenarioImpCB.setChecked(currentPlanShown.getScenarioLock());
+ methodEvalImpCB.setChecked(currentPlanShown.getMethodEvalLock());
+ refImpCB.setChecked(currentPlanShown.getPlanRefLock());
+ evalImpCB.setChecked(currentPlanShown.getEntityLock());
+ isInitialized = true;
+
+
+
+ }
+
+ /**
+ * Initialize evaluation definition information values.
+ */
+ private void updatePlanInfo() {
+
+ if (currentPlanShown != null) {
+ plan_name.setValue(currentPlanShown.getName());
+ plan_organisation.setValue(currentPlanShown.getOrganisationName());
+ plan_city.setValue(currentPlanShown.getCity());
+ plan_autor.setValue(currentPlanShown.getCreatorName());
+ plan_contact.setValue(currentPlanShown.getCreatorName());
+ plan_date.setValue(Tools.getDateFormated(currentPlanShown
+ .getCreationDate()));
+ }
+ }
+
+ /**
+ * Update ref interface.
+ */
+ public void updateRefInterface() {
+ if (tabRefPanel != null) {
+ vRefPanel.remove(tabRefPanel);
+
+ tabRefPanel.destroy();
+ }
+ if (currentPlanShown != null) {
+ tabRefPanel = new PlanTabPanelRefWidget(this, currentPlanShown, readOnly);
+ if (!readOnly) {
+ //planRefChoose.updatePlanTabPanelRefWidget(tabRefPanel);
+ }
+
+ vRefPanel.add(tabRefPanel);
+ }
+ }
+
+ /**
+ * Update role interface.
+ */
+ public void updateRoleInterface() {
+ hRolePanel.clear();
+ if (currentPlanShown != null) {
+ for (String role : currentPlanShown.getRoles()) {
+
+ PlanRoleWidget prw = new PlanRoleWidget(currentPlanShown, role,
+ readOnly);
+
+ prw.updateRolePlanGrid();
+
+ hRolePanel.add(prw);
+
+
+ }
+ }
+
+ }
+
+}