public virtual void Search(int currentPage = 0)
        {
            InputGridEditorItem page = (InputGridEditorItem)getEditor().getActivePage();

            try
            {
                GrilleFilter filter = page.getInputGridForm().GridForm.filterForm.Fill();
                filter.grid      = new Grille();
                filter.grid.code = page.EditedObject.code;
                filter.grid.columnListChangeHandler = page.EditedObject.columnListChangeHandler;
                filter.grid.report = page.EditedObject.report;
                filter.grid.oid    = page.EditedObject.oid;
                filter.grid.name   = page.EditedObject.name;
                //filter.grid = page.EditedObject;
                filter.page     = currentPage;
                filter.pageSize = (int)page.getInputGridForm().GridForm.toolBar.pageSizeComboBox.SelectedItem;
                filter.showAll  = page.getInputGridForm().GridForm.toolBar.showAllCheckBox.IsChecked.Value;
                GrillePage rows = this.GetInputGridService().getGridRows(filter);
                page.getInputGridForm().GridForm.displayPage(rows);
                //OnChange();
            }
            catch (ServiceExecption) {
                GrillePage rows = new GrillePage();
                rows.rows = new List <object[]>(0);
                page.getInputGridForm().GridForm.displayPage(rows);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override void OnPageClosed(object sender, EventArgs args)
        {
            base.OnPageClosed(sender, args);
            InputGridEditorItem page = (InputGridEditorItem)sender;

            page.getInputGridForm().SelectionChanged -= OnSelectedTabChange;
        }
        /// <summary>
        /// Cette méthode est exécutée lorsqu'on sélectionne une Input Table sur la sidebar.
        /// Cette opération a pour but d'ouvrir une page pour la table selectionnée dans l'éditeur.
        /// </summary>
        /// <param name="sender">La table sélectionnée</param>
        protected void onSelectGridFromSidebar(object sender)
        {
            if (sender != null && sender is Grille)
            {
                Grille grid = (Grille)sender;
                EditorItem <Grille> page = getInputGridEditor().getPage(grid.name);
                if (page != null)
                {
                    page.fillObject();
                    getInputGridEditor().selectePage(page);
                }
                else if (grid.oid != null && grid.oid.HasValue)
                {
                    this.Open(grid.oid.Value);
                }
                else
                {
                    page = getInputGridEditor().addOrSelectPage(grid);
                    initializePageHandlers(page);
                    page.Title = grid.name;

                    getInputGridEditor().ListChangeHandler.AddNew(grid);
                }
                InputGridEditorItem pageOpen = (InputGridEditorItem)getInputGridEditor().getActivePage();
                UpdateStatusBar();
            }
        }
        /// <summary>
        /// Initialisation des Handlers sur une nouvelle page.
        /// En plus des handlers de base, on initialise les handlers sur :
        /// - DesignerPropertiesPanel
        /// -
        /// - SpreadSheet
        /// -
        /// </summary>
        protected override void initializePageHandlers(EditorItem <Grille> page)
        {
            base.initializePageHandlers(page);
            InputGridEditorItem editorPage = (InputGridEditorItem)page;

            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.groupField.GroupService = GetInputGridService().GroupService;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.groupField.subjectType = SubjectTypeFound();
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.KeyUp += onNameTextChange;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.LostFocus += onNameTextLostFocus;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.groupField.Changed += onGroupFieldChange;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.OnSetTableVisible += OnSetTableVisible;

            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.visibleInShortcutCheckbox.Checked += OnVisibleInShortcutCheck;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.visibleInShortcutCheckbox.Unchecked += OnVisibleInShortcutCheck;

            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.Changed += OnInputGridPropertiesChange;
            editorPage.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.selectionColumnChanged += OnInputGridPropertiesSelectionColumnChange;

            if (editorPage.getInputGridForm().AdministrationBar != null)
            {
                editorPage.getInputGridForm().AdministrationBar.Changed += OnChangeEventHandler;
            }

            initializeGridFormHandlers(editorPage.getInputGridForm());

            editorPage.getInputGridForm().SelectionChanged += OnSelectedTabChange;
        }
        protected virtual void UpdateGridForm()
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            page.getInputGridForm().EditedObject = page.EditedObject;
            page.getInputGridForm().displayObjectInGridForm();
            Search(page.EditedObject.GrilleFilter != null ? page.EditedObject.GrilleFilter.page : 1);
        }
        protected void onGroupFieldChange()
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();
            string name = page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.groupField.textBox.Text;

            ((InputGridSideBar)SideBar).GrilleGroup.GrilleTreeview.updateGrille(name, page.Title, true);
            OnChange();
        }
        protected override void Rename(string name)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Text = name;
            page.EditedObject.name = name;
            base.Rename(name);
        }
        /// <summary>
        /// Methode à exécuter lorsqu'il y a un changement sur la vue.
        /// </summary>
        /// <returns>
        /// OperationState.CONTINUE si l'opération a réussi
        /// OperationState.STOP sinon
        /// </returns>
        public override OperationState OnChange()
        {
            base.OnChange();
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            page.getInputGridForm().GridForm.gridBrowser.RebuildGrid = true;
            UpdateStatusBar();
            return(OperationState.CONTINUE);
        }
        protected void BuildConfigurationGridColumns()
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            page.getInputGridForm().InputGridSheetForm.BuildColunms();
        }
        private void OnVisibleInShortcutCheck(object sender, RoutedEventArgs e)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (!page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.throwEvent)
            {
                return;
            }
            page.EditedObject.visibleInShortcut = page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.visibleInShortcutCheckbox.IsChecked.Value;
            OnChange();
        }
        /// <summary>
        /// Cette méthode est exécutée lorsqu'on sélectionne une target sur la sidebar.
        /// Cette opération a pour but de rajouté la target sélectionnée au filtre de la table en édition,
        /// ou au scope des cellProperties correspondants à la sélection Excel.
        /// </summary>
        /// <param name="sender">La target sélectionné</param>
        protected void onSelectTargetFromSidebar(object target)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            page.SetTarget((Target)target);
            OnChange();
        }
        public override OperationState Rename()
        {
            if (base.Rename() != OperationState.CONTINUE)
            {
                return(OperationState.STOP);
            }

            IsRenameOnDoubleClick = true;
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            return(ValidateEditedNewName(page.EditedObject.name));
        }
 /// <summary>
 /// Cette méthode est exécutée lorsqu'on sélectionne une mesure sur la sidebar.
 /// Cette opération a pour but d'assigner la mesure sélectionnée
 /// aux cellProperties correspondants à la sélection Excel.
 /// </summary>
 /// <param name="sender">La mesure sélectionnée</param>
 protected void onSelectMeasureFromSidebar(object sender)
 {
     if (sender != null && (sender is Measure || sender is CalculatedMeasure))
     {
         InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();
         if (page == null)
         {
             return;
         }
         page.SetMeasure((Measure)sender);
     }
 }
        private void OnDeleteRows(object obj)
        {
            String message = "You are about to delete " + ((List <long>)obj).Count + " row(s).\nDo you want to continue?";

            if (MessageDisplayer.DisplayYesNoQuestion("Delete", message) == MessageBoxResult.Yes)
            {
                if (this.GetInputGridService().deleteGridRows((List <long>)obj))
                {
                    InputGridEditorItem page = (InputGridEditorItem)getEditor().getActivePage();
                    Search(page.getInputGridForm().GridForm.toolBar.current);
                }
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 protected void onSelectPeriodFromSidebar(object sender)
 {
     if (sender != null)
     {
         InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();
         if (page == null)
         {
             return;
         }
         page.SetPeriod(sender);
         OnChange();
     }
 }
        private void OnInputGridPropertiesChange(object obj)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            if (obj is bool && (bool)obj)
            {
                BuildConfigurationGridColumns();
            }
            OnChange();
        }
        private void OnDuplicateRows(object obj)
        {
            String message = "You are about to duplicate " + ((List <long>)obj).Count + " row(s).\nDo you want to continue?";

            if (MessageDisplayer.DisplayYesNoQuestion("Duplicate", message) == MessageBoxResult.Yes)
            {
                var list = ((List <long>)obj).ConvertAll(i => (int)i).ToList();
                if (this.GetInputGridService().duplicateGridRows(list))
                {
                    InputGridEditorItem page = (InputGridEditorItem)getEditor().getActivePage();
                    Search(page.getInputGridForm().GridForm.toolBar.total + 1);
                }
            }
        }
示例#18
0
        /// <summary>
        /// Retourne une nouvelle page.
        /// </summary>
        /// <returns>Une nouvelle instance de EditorItem</returns>
        protected override EditorItem <Grille> getNewPage()
        {
            InputGridEditorItem item = new InputGridEditorItem(this.SubjectType);

            if (this.Service != null)
            {
                PeriodName name = this.Service.PeriodNameService.getRootPeriodName();
                PeriodName defaultName = name.getDefaultPeriodName();
                item.getInputGridForm().GridForm.filterForm.periodFilter.DefaultPeriodName = defaultName;
                item.getInputGridForm().GridForm.filterForm.periodFilter.DisplayPeriod(null);
            }
            item.getInputGridForm().GridForm.gridBrowser.Service = this.Service;
            return(item);
        }
        /// <summary>
        /// Cette methode permet de créer une nouvelle table.
        /// </summary>
        /// <returns>CONTINUE si la création du nouveau Model se termine avec succès. STOP sinon</returns>
        public override OperationState Create()
        {
            Grille grid = GetNewGrid();

            ((InputGridSideBar)SideBar).GrilleGroup.GrilleTreeview.AddGrille(grid);
            InputGridEditorItem page = (InputGridEditorItem)getEditor().addOrSelectPage(grid);

            //page.getInputGridForm().userRightPanel.InitService(GetInputGridService().ProfilService, page.EditedObject.oid);

            initializePageHandlers(page);
            page.Title = grid.name;
            getEditor().ListChangeHandler.AddNew(grid);
            return(OperationState.CONTINUE);
        }
        /// <summary>
        /// Cette methode est exécuté lorsqu'on édit le nom de la table active.
        /// Si l'utilisateur tappe sur la touche ENTER, le nouveau nom est validé.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void onNameTextChange(object sender, KeyEventArgs args)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (args.Key == Key.Escape)
            {
                page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Text = page.Title;
            }
            else if (args.Key == Key.Enter)
            {
                ValidateEditedNewName();
                OnChange();
            }
        }
        private void OnSetTableVisible(object item)
        {
            if (!(item is bool))
            {
                return;
            }
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (item is Grille)
            {
                ((Grille)page.EditedObject).visibleInShortcut = (bool)item;
            }
            OnChange();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        public override OperationState Open(Grille grid)
        {
            if (getEditor().getPage(grid) == null)
            {
                grid.loadGrilleFilter();
            }
            InputGridEditorItem page = (InputGridEditorItem)getEditor().addOrSelectPage(grid);

            //page.getInputGridForm().userRightPanel.InitService(GetInputGridService().ProfilService, page.EditedObject.oid);
            UpdateStatusBar();
            UpdateToolBar(page.EditedObject);
            initializePageHandlers(page);
            getEditor().ListChangeHandler.AddNew(grid);
            Search();
            return(OperationState.CONTINUE);
        }
        protected void Mask(bool mask, string content = "Saving...")
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            ApplicationManager.MainWindow.BusyBorder.Visibility = mask ? Visibility.Visible : Visibility.Hidden;
            if (mask)
            {
                ApplicationManager.MainWindow.LoadingProgressBar.Maximum = 100;
                ApplicationManager.MainWindow.LoadingProgressBar.Value   = 0;
                ApplicationManager.MainWindow.LoadingLabel.Content       = content;

                ApplicationManager.MainWindow.LoadingProgressBar.Visibility = Visibility.Visible;
                ApplicationManager.MainWindow.LoadingLabel.Visibility       = Visibility.Visible;
                ApplicationManager.MainWindow.LoadingImage.Visibility       = Visibility.Hidden;
            }
        }
 /// <summary>
 /// Sauve les objets en cours d'édition sur la page.
 /// </summary>
 /// <returns>
 /// OperationState.CONTINUE si l'opération a réussi
 /// OperationState.STOP sinon
 /// </returns>
 public override OperationState Save(EditorItem <Grille> page)
 {
     try
     {
         InputGridEditorItem currentPage = (InputGridEditorItem)page;
         currentPage.EditedObject.loadFilters();
         if (base.Save(page) == OperationState.STOP)
         {
             return(OperationState.STOP);
         }
         UpdateGridForm();
     }
     catch (Exception)
     {
         DisplayError("Unable to save Grid", "Unable to save Grid.");
         return(OperationState.STOP);
     }
     return(OperationState.CONTINUE);
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected virtual OperationState ValidateEditedNewName(string newName = "")
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();
            Grille table             = page.EditedObject;

            if (string.IsNullOrEmpty(newName))
            {
                newName = page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Text.Trim();
            }
            if (string.IsNullOrEmpty(newName))
            {
                DisplayError("Empty Name", "The Grid name can't be mepty!");
                page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.SelectAll();
                page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Focus();
                return(OperationState.STOP);
            }


            foreach (InputGridEditorItem unInputTable in getInputGridEditor().getPages())
            {
                if (unInputTable != getInputGridEditor().getActivePage() && newName == unInputTable.Title)
                {
                    DisplayError("Duplicate Name", "There is another Grid named: " + newName);
                    page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Text = page.Title;
                    page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.SelectAll();
                    page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.NameTextBox.Focus();
                    return(OperationState.STOP);
                }
            }
            if (!IsRenameOnDoubleClick)
            {
                if (table.name.ToUpper().Equals(newName.ToUpper()))
                {
                    return(OperationState.CONTINUE);
                }
            }

            ((InputGridSideBar)SideBar).GrilleGroup.GrilleTreeview.updateGrille(newName, table.name, false);
            table.name = newName;
            page.Title = newName;
            return(OperationState.CONTINUE);
        }
        protected virtual void PerformSelectionChange()
        {
            InputGridEditorItem page = (InputGridEditorItem)getEditor().getActivePage();

            if (page.getInputGridForm().SelectedIndex == 1)
            {
                ((InputGridPropertyBar)this.PropertyBar).DesignLayoutAnchorable.Content = page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel;

                //ApplicationManager.MainWindow.displayPropertyBar(this.PropertyBar);
            }
            else
            {
                ((InputGridPropertyBar)this.PropertyBar).DesignLayoutAnchorable.Content = page.getInputGridForm().GridForm.filterForm;

                //ApplicationManager.MainWindow.displayPropertyBar(null);
                if (page.getInputGridForm().GridForm.gridBrowser.RebuildGrid)
                {
                    UpdateGridForm();
                }
            }
        }
 public void Export()
 {
     try
     {
         string filePath = openFileDialog("Export to Excel", null);
         if (filePath == null)
         {
             return;
         }
         InputGridEditorItem page   = (InputGridEditorItem)getEditor().getActivePage();
         GrilleFilter        filter = page.getInputGridForm().GridForm.filterForm.Fill();
         filter.grid = page.EditedObject;
         filter.file = filePath;
         bool response = this.GetInputGridService().exportToExcel(filter);
         if (response)
         {
             MessageDisplayer.DisplayInfo("Export to Excel", "Grid exported!");
         }
     }
     catch (ServiceExecption) { }
 }
        public virtual OperationState ClearGrid()
        {
            OperationState      state = OperationState.CONTINUE;
            InputGridEditorItem page  = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (page == null)
            {
                return(state);
            }
            if (!page.EditedObject.oid.HasValue)
            {
                return(state);
            }
            bool result = GetInputGridService().Clear(page.EditedObject.oid.Value);

            if (result)
            {
                page.EditedObject.loaded = false;
                UpdateToolBar(page.EditedObject);
            }
            return(state);
        }
        private void updateRunProgress(AllocationRunInfo info)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (info == null || info.runEnded == true)
            {
                page.IsModify = true;
                OnChange();
                Mask(false);
            }
            else
            {
                int rate = info.totalCellCount != 0 ? (Int32)(info.runedCellCount * 100 / info.totalCellCount) : 0;
                if (rate > 100)
                {
                    rate = 100;
                }

                ApplicationManager.MainWindow.LoadingProgressBar.Maximum = info.totalCellCount;
                ApplicationManager.MainWindow.LoadingProgressBar.Value   = info.runedCellCount;
                ApplicationManager.MainWindow.LoadingLabel.Content       = "" + rate + " %";
            }
        }
        private void OnInputGridPropertiesSelectionColumnChange(object obj)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            if (obj is GrilleColumn)
            {
                GrilleColumn column = (GrilleColumn)obj;

                if (column.type.Equals(ParameterType.SCOPE.ToString()))
                {
                    //Target target = column.scope;
                    //if (target.typeName.Equals(typeof(AttributeValue).Name, StringComparison.OrdinalIgnoreCase))
                    //{
                    //    Kernel.Domain.AttributeValue value = GetInputGridService().ModelService.getAttributeValue(target.oid.Value, target.name);
                    //   column.SetValue(value);
                    //   page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.ColumnForms.Display(column);
                    //}

                    //if (target.typeName.Equals(typeof(Misp.Kernel.Domain.Attribute).Name, StringComparison.OrdinalIgnoreCase))
                    //{
                    //    Misp.Kernel.Domain.Attribute value = GetInputGridService().ModelService.getAttributeByOid(target.oid.Value);
                    //    column.SetValue(value);
                    //    page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.ColumnForms.Display(column);
                    //}
                    //if (target.typeName.Equals(typeof(Entity).Name, StringComparison.OrdinalIgnoreCase))
                    //{
                    //    Misp.Kernel.Domain.Entity value = GetInputGridService().ModelService.getEntityByOid(target.oid.Value);
                    //    column.SetValue(value);
                    //    page.getInputGridForm().InputGridSheetForm.InputGridPropertiesPanel.ColumnForms.Display(column);
                    //}
                }
            }
        }