コード例 #1
0
        /// <summary>
        /// InitializeMapForDev
        /// </summary>
        /// <param name="dm"></param>

        void InitializeMapForDev(DataTableMapMsx dm)
        {
            QueryTable  qt      = null;
            QueryColumn qc      = null;
            string      alias   = "";
            string      colName = "";

            if (dm.ColumnMapCollection != null && dm.ColumnMapCollection.Count > 0)
            {
                return;
            }

            dm.ColumnMapCollection = new ColumnMapCollection();

            DataTableMsx dt = SVP.Doc.DataManager.TableCollection[0];

            dm.SpotfireDataTable = dt;

            foreach (DataColumnMsx dc in dt.Columns)
            {
                colName = dc.Name;
                int i1 = colName.IndexOf(".");
                if (i1 <= 0 || i1 + 1 >= colName.Length)                 // name without alias
                {
                    alias = "T1";
                }

                else
                {
                    alias   = colName.Substring(0, i1);
                    colName = colName.Substring(i1 + 1);
                }

                int qti = Query.GetQueryTableIndexByAlias(alias);
                if (qti < 0)
                {
                    continue;
                }

                qt = Query.Tables[qti];

                qc = qt.GetQueryColumnByLabel(colName);
                if (qc == null)
                {
                    continue;
                }

                ColumnMapMsx cm = new ColumnMapMsx();
                cm.QueryColumn = qc;

                cm.SpotfireColumn = dc;

                cm.SpotfireColumnName = dc.Name;
                cm.Role = dc.Name;

                dm.ColumnMapCollection.Add(cm);
            }

            return;
        }
コード例 #2
0
		public void Setup(
			SpotfireViewManager svm,
			EventHandler callerEditValueChangedHandler = null)
		{
			DataTableMapMsx dataMap = null;
			Setup(svm, dataMap, callerEditValueChangedHandler);
		}
コード例 #3
0
        /// <summary>
        /// ShowDialog
        /// </summary>
        /// <param name="dataMap"></param>
        /// <param name="initialTabName"></param>
        /// <returns></returns>

        public static DialogResult ShowDialog(
            DataTableMapMsx dataMap)
        {
            DataMapOptionsDialog dmd = new DataMapOptionsDialog();

            dmd.DataMap = dataMap;

            dmd.Setup();

            return(dmd.ShowDialog());
        }
コード例 #4
0
        /// <summary>
        /// Setup the control for specified view
        /// </summary>
        /// <param name="view"></param>

        public void Setup(
            DataTableMapMsx dataTableMap,
            EventHandler callerEditValueChangedEventHandler = null)
        {
            InSetup      = true;
            DataTableMap = dataTableMap;

            CallerEditValueChangedHandler = callerEditValueChangedEventHandler;

            QueryTablesComboBox.Text         = "";
            QueryTablesComboBox.SelectedItem = null;

            ComboBoxItemCollection items = QueryTablesComboBox.Properties.Items;

            items.Clear();

            QueryTablesComboBox.Text = "";

            AssertMx.IsNotNull(Query, "Query");

            foreach (QueryTable qtEnum in Query.Tables)
            {
                items.Add(new ComboBoxItem(new LabeledUiItem(qtEnum.ActiveLabel, qtEnum)));
            }

            items.Add(AllTablesItem);

            items.Add(NoTablesItem);

            QueryTable qt = DataTableMap?.QueryTable;

            if (dataTableMap.IsMappedToSingleQueryTable)
            {
                QueryTablesComboBox.Text         = qt.ActiveLabel;
                QueryTablesComboBox.SelectedItem = new LabeledUiItem(qt.ActiveLabel, qt);
            }

            else if (dataTableMap.IsMappedToAllQueryTables)             // if cols are mapped assume all tables
            {
                QueryTablesComboBox.Text         = AllTablesItem.Label;
                QueryTablesComboBox.SelectedItem = AllTablesItem;
            }

            else             // not mapped to any tables
            {
                QueryTablesComboBox.Text         = NoTablesItem.Label;
                QueryTablesComboBox.SelectedItem = NoTablesItem;
            }

            InSetup = false;

            return;
        }
コード例 #5
0
		/// <summary>
		/// Fill the field grid with current mappings
		/// </summary>

		internal void UpdateFieldGridDataTable()
		{
			DataRow dr;
			DataColumn dc;
			MetaColumnType mcType = MetaColumnType.Unknown;

			bool excludeNoRoleColumns = false; // if true don't include columns that don't have a role from the initial template analysis file

			InSetup = true;

			DataTable dt = FieldDataTable;
			dt.Clear();

			if (CurrentMap != null)
				foreach (ColumnMapMsx cm in CurrentMap.ColumnMapList)
				{
					if (excludeNoRoleColumns && Lex.IsUndefined(cm.Role)) continue;

					dr = dt.NewRow();

					QueryColumn qc = cm.QueryColumn;

					if (qc != null) // column is mapped
					{
						dr["MobiusTableNameField"] = qc.QueryTable.ActiveLabel;
						dr["MobiusColNameField"] = qc.ActiveLabel;
						mcType = qc.MetaColumn.DataType;
					}

					else // no query column assigned, get type image from spotfire if including these
					{
						mcType = DataTableMapMsx.GetMatchingMobiusDataTypeFromSpotfireColumn(cm.SpotfireColumn);
					}

					int imgIdx = (int)MetaColumn.GetMetaColumnDataTypeImageIndex(mcType);
					if (mcType == MetaColumnType.CompoundId) imgIdx = (int)Bitmaps16x16Enum.Key;
					dr["DataTypeImageField"] = Bitmaps.Bitmaps16x16.Images[imgIdx];

					dr["SpotfireColNameField"] = cm.SpotfireColumnName;
					dr["OriginalSpotfireColNameField"] = cm.Role;

					dr["SelectedField"] = cm.Selected;

					dr["ColumnMapMsxRefField"] = cm; // store Field ref
					dt.Rows.Add(dr);
				}

			Changed = false;
			InSetup = false;
			return;
		}
コード例 #6
0
		/// <summary>
		/// Setup the control for specified view
		/// </summary>
		/// <param name="view"></param>

		public void Setup(
			SpotfireViewManager svm,
			DataTableMapMsx dataMap = null,
			EventHandler callerEditValueChangedHandler = null)
		{
			DataRow dr;
			DataColumn dc;

			InSetup = true;

			SVM = svm;
			DataTableMaps = svm?.SVP.DataTableMaps;

			CallerEditValueChangedHandler = callerEditValueChangedHandler;

			DataTableSelectorControl.Setup(DataTableMaps, DataTableSelectorControl_EditValueChanged);

			QtSelectorControl.Setup(CurrentMap, QueryTableAssignmentChanged);

			GridView.OptionsSelection.MultiSelect = !SelectSingleColumn;
			GridView.OptionsBehavior.Editable = !SelectSingleColumn;

			DataTable dt = new DataTable();
			dt.Columns.Add(new DataColumn("DataTypeImageField", typeof(Image)));
			dt.Columns.Add(new DataColumn("SpotfireColNameField", typeof(string)));
			dt.Columns.Add(new DataColumn("OriginalSpotfireColNameField", typeof(string)));
			dt.Columns.Add(new DataColumn("SelectedField", typeof(bool)));
			dt.Columns.Add(new DataColumn("MobiusTableNameField", typeof(string)));
			dt.Columns.Add(new DataColumn("MobiusColNameField", typeof(string)));
			dt.Columns.Add(new DataColumn("ColumnMapMsxRefField", typeof(ColumnMapMsx)));

			dt.RowChanged += new DataRowChangeEventHandler(Dt_RowChanged); // Monitor row changes

			//dr = dt.NewRow(); // add blank row at bottom
			//dt.Rows.Add(dr);

			FieldDataTable = dt;
			FieldGrid.DataSource = dt;

			UpdateFieldGridDataTable(); // do initial fill of the grid DataTable

			HeaderPanel.Enabled = CanEditMapping;

			Changed = false;
			InSetup = false;
			return;
		}
コード例 #7
0
		/// <summary>
		/// Get the Field definitions from the grid
		/// </summary>

		public DataTableMapMsx GetColumnMapList()
		{
			DataTableMapMsx map = new DataTableMapMsx();
			map.ParentMapList = SVP.DataTableMaps;
			DataTableMaps.CurrentMap = map;

			foreach (DataRow dr in FieldDataTable.Rows)
			{
				ColumnMapMsx fli = dr["ColumnMapMsxRefField"] as ColumnMapMsx;
				if (fli == null) continue;

				QueryColumn qc = fli.QueryColumn;
				if (qc == null) continue;

				fli.QueryColumn = qc;
				fli.SpotfireColumnName = dr["SpotfireColNameField"] as string;
				fli.Selected = (bool)dr["SelectedField"]; // not currently used
				CurrentMap.Add(fli);
			}

			return CurrentMap;
		}
コード例 #8
0
		private void GridView_MouseUp_Callback(object state)
		{
			ColumnMapMsx cm;
			QueryColumn qc;
			QnfEnum subColumn;
			DialogResult dr;
			string newSpotfireName;

			MouseEventArgs e = state as MouseEventArgs;

			if (e == null) return;

			Point p = new Point(e.X, e.Y);

			GridHitInfo gridHitInfo = FieldGridView.CalcHitInfo(p);
			GridViewInfo gridViewInfo = FieldGridView.GetViewInfo() as GridViewInfo;
			GridCellInfo gridCellInfo = gridViewInfo.GetGridCellInfo(gridHitInfo);

			int ri = gridHitInfo.RowHandle;
			if (ri < 0) return;
			GridColumn gc = gridHitInfo.Column;
			if (gc == null) return;
			int c = gc.AbsoluteIndex;

			if (SelectSingleColumn) // just do a simple single column selection
			{
				UpdateSelectSingleColumnData(ri);
				return;
			}

			DataRow dRow = FieldDataTable.Rows[ri];

			//DataMap.ColumnMapList.Items[ri];

			cm = dRow["ColumnMapMsxRefField"] as ColumnMapMsx; // get ColumnMap for current item

			if (cm == null) throw new Exception("Null ColumnMapMsxRefField");
			//if (cm == null) qc = null;
			//else qc = cm.QueryColumn;

			qc = cm.QueryColumn;
			subColumn = cm.SubColumn;

			// Rename column

			if (gc == SpotfireColNameCol)
			{
				RenameColumn(ri);
				return;
			}

			// Commands checked below are only available if editing of the mapping is allowed

			if (!CanEditMapping) return;

			// Select which Mobius column maps to a Spotfire Column

			if (gc == MobiusTableNameCol || gc == MobiusColNameCol) // select Mobius column to match if defining mapping
			{
				string role = dRow["OriginalSpotfireColNameField"] as string;
				if (Lex.IsUndefined(role)) return; // can only assign cols with "roles" from the original template analysis

				string spotfireName = "";
				FieldSelectorControl fieldSelector = new FieldSelectorControl();
				fieldSelector.QueryColumn = qc;

				SelectColumnOptions flags = new SelectColumnOptions();
				flags.ExcludeImages = true;
				flags.FirstTableKeyOnly = true;
				flags.SelectFromQueryOnly = true;
				flags.QnSubcolsToInclude = QnfEnum.Split | QnfEnum.Qualifier | QnfEnum.NumericValue | QnfEnum.NValue; // split QualifiedNumbers
				flags.IncludeNoneItem = true;

				flags.AllowedDataTypes = DataTableMapMsx.GetMetaColumnTypesCompatibleWithSpotfireColumn(cm.SpotfireColumn, allowCompoundId: (ri == 0));

				p = FieldGrid.PointToScreen(p);
				if (CurrentMap.QueryTable != null) // select from single query table only
					dr = fieldSelector.SelectColumnFromQueryTable(CurrentMap.QueryTable, qc, flags, p.X, p.Y, out qc, out subColumn);

				else // select from any table in the query
					dr = fieldSelector.SelectColumnFromQuery(Query, qc, flags, p.X, p.Y, out qc, out subColumn);

				if (dr != DialogResult.OK) return;

				cm.QueryColumn = qc; // new query column mapped to

				if (qc != null) // assigning a new QueryColumn 
				{
					dRow["MobiusTableNameField"] = qc.QueryTable.ActiveLabel;
					dRow["MobiusColNameField"] = qc.ActiveLabel;

					newSpotfireName = CurrentMap.AssignUniqueSpotfireColumnName(qc.ActiveLabel);
					dRow["SpotfireColNameField"] = newSpotfireName; // update grid

					cm.SpotfireColumnName = newSpotfireName; // store new name

					//if (Lex.Ne(cm.SpotfireColumnName, newSpotfireName)) // changing name?
					//{
					//	cm.NewSpotfireColumnName = newSpotfireName; // store new name
					//}

					cm.MobiusFileColumnName = qc.MetaTableDotMetaColumnName + ColumnMapParms.SpotfireExportExtraColNameSuffix;
				}

				else // set to none (e.g. null col)
				{
					dRow["MobiusTableNameField"] = "";
					dRow["MobiusColNameField"] = "";

					newSpotfireName = CurrentMap.AssignUniqueSpotfireColumnName("None");
					dRow["SpotfireColNameField"] = newSpotfireName; // update grid
					cm.SpotfireColumnName = newSpotfireName; // update map
					//cm.NewSpotfireColumnName = newSpotfireName; // update map

					cm.MobiusFileColumnName = ""; // not mapped to a col
				}

				FieldGrid.RefreshDataSource();

				SVM.RemapDataTable(CurrentMap); // update spotfire view accordingly

				UpdateFieldGridDataTable();

				cm.NewSpotfireColumnName = ""; // clear new name used for rename (needed?)
			}

			return;
		}