/// <summary> /// /// </summary> /// <param name="gridPanel"></param> /// <param name="qm"></param> public static void DisplayData( MoleculeGridPanel gridPanel, QueryManager qm) { if (gridPanel == null) // if grid panel not defined assume display is in normal results panel { gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; QbUtil.SetMode(QueryMode.Browse); // put into browse mode } else if (gridPanel.Parent is PopupGrid) // display in popup grid { PopupGrid pug = gridPanel.Parent as PopupGrid; pug.Initialize(qm); // be sure popup is initialized WindowsHelper.FitFormOnScreen(pug); pug.Show(); } MoleculeGridControl grid = qm.MoleculeGrid; gridPanel.Visible = true; grid.Visible = true; grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable RefreshDataDisplay(qm); }
/// <summary> /// Build the Query, QueryManager and DataTable for the matching structure display /// </summary> public void BuildStructureDisplayQuery() { MetaTable mt = MetaTableCollection.Get("QuickSearchRelatedStructures"); if (mt == null) { DebugLog.Message("QuickSearchRelatedStructures MetaTable not found"); RSC.MoleculeGridPageControl.Visible = false; return; } Query q = ToolHelper.InitEmbeddedDataToolQuery(mt); QueryTable qt = q.Tables[0]; q.UserObject.Name = qt.MetaTable.Label; StructureDisplayQuery = q; QueryColumn qc = qt.FirstStructureQueryColumn; if (qc != null) // setup dummy criteria { ParsedStructureCriteria pssc = new ParsedStructureCriteria(); pssc.SearchType = StructureSearchType.FullStructure; // just full structure search for now pssc.Molecule = new MoleculeMx(MoleculeFormat.Smiles, "C"); // placeholder structure pssc.ConvertToQueryColumnCriteria(qc); qc.DisplayFormatString = "Highlight=true;Align=true"; } string title = "Related Structures"; qt.Label = title; DataTableMx dt = q.ResultsDataTable as DataTableMx; Qm = ToolHelper.SetupQueryManager(q, dt); MoleculeGridPageControl mgpc = RSC.MoleculeGridPageControl; MoleculeGridPanel gp = mgpc.MoleculeGridPanel; mgpc.Width = RSC.Width - 3; // be sure we have page control correctly sized mgpc.Height = RSC.Height - mgpc.Top - 3; ToolHelper.SetupGridPanelForDisplay(Qm, mgpc.MoleculeGridPanel, true, true); MoleculeGridControl grid = mgpc.MoleculeGrid; if (grid != null && grid.GV != null) { grid.GV.IndicatorWidth = 40; // narrow indicator a bit } //ToolHelper.DisplayData // build and display empty grid for query with columns scaled to fit the grid // (q, dt, RSC.MoleculeGridPageControl.MoleculeGridPanel, true, true); return; }
/// <summary> /// Display data /// - Query and DataTable are already setup in QueryManger /// - Complete the QM members and start display /// </summary> /// <param name="qm"></param> /// <param name="gridPanel"></param> /// <param name="embedDataInQuery"></param> /// <param name="fitDataToGridWidth"></param> public static void DisplayData( QueryManager qm, MoleculeGridPanel gridPanel, bool embedDataInQuery = false, bool fitDataToGridWidth = false) { SetupGridPanelForDisplay(qm, gridPanel, embedDataInQuery, fitDataToGridWidth); DisplayData(gridPanel, qm); return; }
/// <summary> /// Do generic display of a structure /// </summary> /// <param name="title"></param> /// <param name="cidLabel"></param> /// <param name="structLabel"></param> /// <param name="structure"></param> public static void DisplayStructure( string title, string cidLabel, string structLabel, MoleculeMx structure, MoleculeGridPanel gridPanel, bool embedDataInQuery) { List <MoleculeMx> structures = new List <MoleculeMx>(); structures.Add(structure); DisplayStructures(title, cidLabel, structLabel, structures, gridPanel, embedDataInQuery); return; }
internal MoleculeBandedGridViewManager View; // the view associated with the control /// <summary> /// Link the view and the page /// </summary> public void LinkViewToMoleculeGridPageControl( MoleculeBandedGridViewManager view) { View = view; if (!Visible) { return; } if (SS.I.UISetupLevel >= 0) { return; } MoleculeGridPanel.LinkViewToPanel(view); return; }
/// <summary> /// Display the data for the specified Query and matching DataTable /// </summary> /// <param name="q"></param> /// <param name="dt"></param> /// <param name="persistWithinQuery"></param> public static void DisplayData( Query q, DataTableMx dt, MoleculeGridPanel gridPanel, bool embedDataInQuery = false, bool fitDataToGridWidth = false) { if (q.Tables.Count == 0) { throw new Exception("No tables for query"); } QueryTable qt = q.Tables[0]; q.UserObject.Name = qt.MetaTable.Label; QueryManager qm = SetupQueryManager(q, dt); DisplayData(qm, gridPanel, embedDataInQuery, fitDataToGridWidth); return; }
/// <summary> /// Do Generic display of a list of structures /// </summary> /// <param name="title"></param> /// <param name="cidLabel"></param> /// <param name="structLabel"></param> /// <param name="structures"></param> public static void DisplayStructures( string title, string cidLabel, string structLabel, List <MoleculeMx> structures, MoleculeGridPanel gridPanel, bool embedDataInQuery) { QueryManager qm = null; MetaTable mt = MetaTableCollection.GetWithException("Generic_Structure_Table"); mt.MetaBrokerType = MetaBrokerType.NoSql; Query q = ToolHelper.InitEmbeddedDataToolQuery(mt); QueryTable qt = q.Tables[0]; qt.Label = title; qt.GetQueryColumnByName("CompoundId").Label = cidLabel; qt.GetQueryColumnByName("Structure").Label = structLabel; DataTableMx dt = q.ResultsDataTable as DataTableMx; for (int mi = 0; mi < structures.Count; mi++) { MoleculeMx cs = structures[mi]; DataRowMx dr = dt.NewRow(); string cid = cs.Id; if (Lex.IsUndefined(cid)) { cid = (mi + 1).ToString(); } dr[qt.Alias + ".CompoundId"] = new CompoundId(cid); dr[qt.Alias + ".Structure"] = cs; dt.Rows.Add(dr); } DisplayData(q, dt, gridPanel, embedDataInQuery); return; }
/// <summary> /// Setup the proper grid, banded or layout, based on the ResultsFormat setting /// </summary> internal MoleculeGridControl SetGrid() { return(MoleculeGridPanel.SelectBaseGridViewGrid(QueryManager)); }
/// <summary> /// Display the tool data /// </summary> /// <param name="qm"></param> /// <param name="serializeContentInQuery"></param> public static void DisplayDataOld( // Old version from 1/4/2017 QueryManager qm, MoleculeGridPanel gridPanel, bool serializeContentInQuery, bool fitDataToGridWidth = false) { MoleculeGridControl grid = null; bool displayAsNormalQueryResults = (gridPanel == null); // if grid panel not defined assume display is in normal results panel bool displayAsPopupGrid = (gridPanel != null && gridPanel.Parent is PopupGrid); // display in popup grid Query q = qm.Query; q.SetupQueryPagesAndViews(); // be sure we have a default view page if (serializeContentInQuery) { // no database behind this table so persist within the query MetaTable mt = q.Tables[0].MetaTable; // assume just one metatable foreach (MetaColumn mc in mt.MetaColumns) // no criteria allowed { mc.IsSearchable = false; } q.SerializeMetaTablesWithQuery = true; // if no broker then save the metatable definition q.SerializeResultsWithQuery = true; // also save results when saving the query q.BrowseSavedResultsUponOpen = true; // open the results when the query is opened q.ResultsDataTable = qm.DataTable; // point the query to this results table } ResultsFormatFactory rff = new ResultsFormatFactory(qm, OutputDest.WinForms); rff.Build(); // build format ResultsFormatter fmtr = new ResultsFormatter(qm); // and formatter if (displayAsNormalQueryResults) { gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; QbUtil.AddQuery(qm.Query); // add to the list of visible queries QueriesControl.Instance.CurrentBrowseQuery = qm.Query; // make it current } grid = gridPanel.SelectBaseGridViewGrid(qm); //if (qm.ResultsFormat.UseBandedGridView) // grid = gridPanel.BandedViewGrid; //else grid = gridPanel.LayoutViewGrid; qm.MoleculeGrid = grid; grid.QueryManager = qm; DataTableMx dt = qm.DataTable; // save ref to data table grid.DataSource = null; // clear source for header build if (fitDataToGridWidth && grid.BGV != null) { grid.BGV.OptionsView.ColumnAutoWidth = true; // set view for auto width to fit within view } grid.FormatGridHeaders(qm.ResultsFormat); qm.DataTable = dt; // restore data table qm.DataTableManager.SetResultsKeysFromDatatable(); // set the results keys if (displayAsNormalQueryResults) { QbUtil.SetMode(QueryMode.Browse); // put into browse mode } else if (displayAsPopupGrid) { PopupGrid pug = gridPanel.Parent as PopupGrid; pug.Initialize(qm); // be sure popup is initialized pug.Show(); } gridPanel.Visible = true; grid.Visible = true; grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable RefreshDataDisplay(qm); return; }
/// <summary> /// Create and execute the drill down query /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BuildAndRunDrillDownQuery(object sender, PivotCellEventArgs e) { object o; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); if (ds.RowCount <= 0) { return; // no data } Query q2 = Qm.Query.Clone(); q2.ShowGridCheckBoxes = false; // Build name for drilldown from row and column fields values string txt = ""; PivotGridField[] rf = e.GetRowFields(); PivotGridField[] ca = e.GetColumnFields(); Array.Resize(ref rf, rf.Length + ca.Length); Array.Copy(ca, 0, rf, rf.Length - ca.Length, ca.Length); foreach (PivotGridField f in rf) { o = e.GetFieldValue(f); if (o != null && o.ToString() != "") { if (txt != "") { txt += ", "; } txt += o.ToString(); } } if (e.ColumnValueType == PivotGridValueType.GrandTotal || e.RowValueType == PivotGridValueType.GrandTotal) { txt += " Grand Total"; } else if (e.ColumnValueType == PivotGridValueType.Total || e.RowValueType == PivotGridValueType.Total) { txt += " Total"; } q2.UserObject.Name = txt; // Create DataTable containing drill down data DataTableMx dt2 = DataTableManager.BuildDataTable(q2); for (int ri = 0; ri < ds.RowCount; ri++) { // copy rows over DataRowMx dr2 = dt2.NewRow(); object[] vo = dr2.ItemArrayRef; // get ref to the item array for (int ci = 0; ci < dt2.Columns.Count; ci++) { //if (ci == 14) ci = ci; // debug vo[ci] = ds.GetValue(ri, ci); // direct copy into ItemArray } dt2.Rows.Add(dr2); } QueryManager qm2 = ToolHelper.SetupQueryManager(q2, dt2); qm2.ResultsFormat.OutputFormContext = OutputFormContext.Popup; PopupGrid pug = new PopupGrid(qm2); MoleculeGridPanel.ConfigureAndShow(qm2, pug); return; }