Example #1
0
/// <summary>
/// Edit a new or existing calculated field
/// </summary>
/// <param name="uo">Existing UserObject with content or null to create a new CF</param>
/// <returns></returns>

        public static UserObject Edit(UserObject uo)
        {
            if (uo == null)             // prompt if not supplied
            {
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.CalcField, "Open Calculated Field");
            }
            if (uo == null)
            {
                return(null);
            }

            uo = UserObjectDao.Read(uo);
            if (uo == null)
            {
                return(null);
            }

            CalcField cf = CalcField.Deserialize(uo.Content);

            if (cf == null)
            {
                return(null);
            }

            uo = Edit(cf, uo);
            return(uo);
        }
Example #2
0
        private void BrowseQueries_Click(object sender, EventArgs e)
        {
            string     prompt = "Select Query";
            UserObject uo     = UserObjectOpenDialog.ShowDialog(UserObjectType.Query, prompt, QueryUo);

            if (uo == null)
            {
                return;
            }
            Alert existingAlert = Alert.GetAlertByQueryId(uo.Id);

            if (existingAlert != null)                              // only 1 alert per query per user is allowed
            {
                if (Alert.Id <= 0 ||                                // if this is a new alert or
                    (Alert.Id > 0 && Alert.Id != existingAlert.Id)) // another alert exists for the query
                {
                    MessageBoxMx.Show("You already an existing alert for query " + Lex.Dq(uo.Name),
                                      "Mobius", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            Query q = QbUtil.ReadQuery(uo.Id);

            if (!Alert.QueryValidForAlert(q))
            {
                return;
            }

            QueryUo        = uo;
            QueryName.Text = QueryUo.Name;
        }
Example #3
0
/// <summary>
/// Edit a new or existing link
/// </summary>
/// <param name="uo">Existing UserObject with content or null to create a new link</param>
/// <returns></returns>

        public static UserObject Edit(UserObject uo)
        {
            if (uo == null)             // prompt if not supplied
            {
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.SpotfireLink, "Edit Spotfire Link");
            }
            if (uo == null)
            {
                return(null);
            }

            uo = UserObjectDao.Read(uo);
            if (uo == null)
            {
                throw new Exception("User object not found: " + uo.Id);
            }

            SpotfireViewProps sl = SpotfireViewProps.Deserialize(uo.Content);

            if (sl == null)
            {
                return(null);
            }

            uo = Edit(sl, uo);
            return(uo);
        }
Example #4
0
        /// <summary>
        /// Let the user select an existing annotation and edit it
        /// </summary>
        /// <returns></returns>

        public static MetaTable OpenExistingAnnotationTable(
            UserObject uo)
        {
            if (uo == null)             // prompt if not supplied
            {
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.Annotation, "Open Annotation");
            }
            if (uo == null)
            {
                return(null);
            }

            if (!Permissions.UserHasWriteAccess(SS.I.UserName, uo))
            {
                MessageBoxMx.ShowError("You are not authorized to edit this annotation table.");
                return(null);
            }

            UserDataEditor editor = new UserDataEditor();
            UserObject     uo2    = editor.Edit(uo);

            if (uo2 == null)
            {
                return(null);
            }

            string    tName = "ANNOTATION_" + uo.Id.ToString();
            MetaTable mt    = MetaTableCollection.Get(tName);          // return new version of metatable

            return(mt);
        }
Example #5
0
 internal static UserObjectOpenDialog GetInstance()
 {
     if (Instance == null)
     {
         Instance = new UserObjectOpenDialog();
     }
     return(Instance);
 }
Example #6
0
        ContentsTreeControlUoMenus CommonUoMenus; // common menus

        public UserObjectOpenDialog()
        {
            InitializeComponent();

            Instance = this;

            ContentsTreeWithSearch.FocusedNodeChanged += SearchableContentsTree_FocusedNodeChanged;
            ContentsTreeWithSearch.DoubleClick        += SearchableContentsTree_DoubleClick;
            ContentsTreeWithSearch.MouseDown          += SearchableContentsTree_MouseDown;;
        }
Example #7
0
        /// <summary>
        /// Prompt user for a saved list
        /// </summary>
        /// <param name="prompt"></param>
        /// <param name="defaultName"></param>
        /// <returns></returns>

        public static UserObject SelectListDialog(
            string prompt,
            UserObject defaultUo)
        {
            UserObject uo = UserObjectOpenDialog.ShowDialog(UserObjectType.CnList, prompt, defaultUo);

            if (uo == null)
            {
                return(null);
            }

            return(uo);
        }
Example #8
0
        /// <summary>
        /// Select an existing calculated field definition
        /// </summary>
        /// <returns></returns>

        public static MetaTable SelectExisting()
        {
            UserObject uo = UserObjectOpenDialog.ShowDialog(UserObjectType.CalcField, "Select Calculated Field");

            if (uo == null)
            {
                return(null);
            }

            string    tName = "CALCFIELD_" + uo.Id.ToString();
            MetaTable mt    = MetaTableCollection.Get(tName);

            return(mt);
        }
Example #9
0
        /// <summary>
        /// Prompt user for annotation and return associated metatable
        /// </summary>
        /// <param name="caption"></param>
        /// <returns></returns>

        public static MetaTable SelectAnnotationTable(
            string caption)
        {
            UserObject uo = UserObjectOpenDialog.ShowDialog(UserObjectType.Annotation, caption);

            if (uo == null)
            {
                return(null);
            }
            uo = UserObjectDao.Read(uo);
            MetaTable mt = MetaTable.Deserialize(uo.Content);             // deserialize metatable xml

            return(mt);
        }
Example #10
0
        /// <summary>
        /// Edit a new or existing calculated field
        /// </summary>
        /// <param name="uo">Existing UserObject with content or null to create a new CF</param>
        /// <returns></returns>

        public static CondFormat EditUserObject(
            UserObject uo = null)
        {
            if (uo == null)             // prompt if not supplied
            {
                UserObject defaultUo = new UserObject(UserObjectType.CondFormat);
                defaultUo.ParentFolder = CondFormat.PredefinedCondFormatFolderName;
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.CondFormat, "Edit Conditional Formatting", defaultUo);
            }
            if (uo == null)
            {
                return(null);
            }

            uo = UserObjectDao.Read(uo);
            if (uo == null)
            {
                return(null);
            }

            CondFormat cf = CondFormat.Deserialize(uo.Content);

            if (cf == null)
            {
                return(null);
            }

            string     title = "Conditional Formatting - " + uo.Name + " (" + uo.InternalName + ")";
            CondFormat cf2   = Edit(cf, true, title);

            if (cf2 == null)
            {
                return(null);
            }

            uo.Content = cf2.Serialize();
            UserObjectDao.Write(uo, uo.Id);

            if (MainMenuControl != null)
            {
                MainMenuControl.UpdateMruList(uo.InternalName);
            }

            CondFormat.UpdatePredefined(uo.InternalName, cf2); // update the dictionary of predefined CFs

            UpdateExistingCfReferences(uo, cf2);               // update any references to this cf in the list of open queries

            return(cf);
        }
Example #11
0
        private void BrowseSaved_Click(object sender, EventArgs e)
        {
            SavedList.Checked = true;
            ListName.Enabled  = true;

            string     tok = ListName.Text.Trim();
            UserObject uo  = UserObjectOpenDialog.ShowDialog(UserObjectType.CnList, "Browse Lists", SavedListUo);

            if (uo != null)
            {
                ListName.Text = uo.Name;
                string txt = uo.InternalName;
                SavedListUo = uo;
            }
        }
Example #12
0
        public static UserObject OpenExistingUserDatabase(
            UserObject uo)
        {
            if (uo == null)             // prompt if not supplied
            {
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.UserDatabase, "Open User Compound Database");
            }
            if (uo == null)
            {
                return(null);
            }

            UserDataEditor editor = new UserDataEditor();

            uo = editor.Edit(uo);
            return(uo);
        }
Example #13
0
        /// <summary>
        /// Open a spotfire link or webplayer url
        /// Example: https://[server]/SpotfireWeb/ViewAnalysis.aspx?file=/Mobius/Visualizations/MdbAssay_MOBIUS&configurationBlock=CorpId_LIST={1,3,5};
        /// Example: https://[server]/SpotfireWeb/ViewAnalysis.aspx?file=/Mobius/Visualizations/SELECT_MOBIUS_DATA_Test&configurationBlock=SQLPARMS="1,3,5,7,9";
        /// </summary>
        /// <param name="link">Open a spotfire link or Webplayer URL </param>
        /// <param name="browserControl"></param>

        public static void OpenLink(
            string link,
            string title,
            WebBrowser browserControl)
        {
            SpotfireViewProps sl = null;
            UserObject        uo = null;
            UserObjectType    uoType;
            string            url;
            PopupHtml         form;
            int uoId;

            if (Lex.IsUndefined(title))
            {
                title = link;
            }

            if (Lex.IsUndefined(link))             // prompt for the link to open
            {
                string prompt = "Open Spotfire Link ";
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.SpotfireLink, prompt);
                if (uo == null)
                {
                    return;
                }
                link = uo.InternalName;
            }

            if (Lex.StartsWith(link, "SPOTFIRELINK_"))             // get the link user object
            {
                string internalName = link;
                bool   parseOk      = UserObject.ParseObjectTypeAndIdFromInternalName(link, out uoType, out uoId);
                uo = UserObjectDao.Read(uoId);
                if (uo == null)
                {
                    throw new Exception("User object not found " + internalName);
                }
                sl    = SpotfireViewProps.Deserialize(uo.Content);
                title = uo.Name;
                url   = BuildUrl(sl);
                if (Lex.IsUndefined(url))
                {
                    return;                                       // cancelled
                }
            }

            else
            {
                url = link;              // assume link is a complete url
            }
            if (browserControl == null)  // Open the link within a WebBrowser control
            {
                form = new PopupHtml();
                UIMisc.PositionPopupForm(form);
                form.Text = title;
                form.Show();
                browserControl = form.WebBrowser;
            }

            browserControl.Navigate(url);

            return;
        }
Example #14
0
/// <summary>
/// New parent database selected
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ParentCompoundCollection_TextChanged(object sender, EventArgs e)
        {
            string colType = "";

            if (InSetup)
            {
                return;
            }

            string    parentDb     = ParentCompoundCollection.Text;
            string    parentMtName = null;
            RootTable rti          = RootTable.GetFromTableLabel(parentDb);

            if (rti == null)
            {
                return;
            }

            if (!Lex.Eq(parentDb, "UserDatabase"))
            {
                parentMtName = rti.MetaTableName;
            }

            else             // prompt user for user database
            {
                UserObject ubdbUo = UserObjectOpenDialog.ShowDialog(UserObjectType.UserDatabase, "Select Parent User Database");
                if (ubdbUo == null)
                {
                    return;
                }

                List <UserObject> luo = GetUcdbUserObjects(ubdbUo.Id);
                if (luo == null)
                {
                    return;
                }

                foreach (UserObject uo3 in luo)
                {
                    if (uo3.Type != UserObjectType.Annotation)
                    {
                        return;                                                            // structure or annotation table
                    }
                    MetaTable mt2 = MetaTable.Deserialize(uo3.Content);
                    if (!mt2.IsUserDatabaseStructureTable)
                    {
                        return;                                                        // ucdb structure table
                    }
                    InSetup = true;
                    ParentCompoundCollection.Text = "UserDatabase: " + ubdbUo.Name;
                    InSetup      = false;
                    parentMtName = mt2.Name;
                    break;
                }
            }

            ParentMt = MetaTableCollection.Get(parentMtName);
            if (ParentMt == null)
            {
                return;
            }
            MetaColumn mc = ParentMt.KeyMetaColumn;

            if (AMt != null)
            {             // if annotation, link in parent & key metacolumn info
                AMt.Parent = ParentMt;
                if (AMt.MetaColumns.Count > 0)
                {
                    AMt.MetaColumns[0]           = mc.Clone();           // clone key
                    AMt.MetaColumns[0].MetaTable = AMt;                  // set proper parent
                }
            }

            ColGridDataTable.Rows[0][0] = mc.Label;             // show label in grid also
            if (mc.DataType == MetaColumnType.CompoundId)
            {
                colType = "Compound Identifier";
            }
            else if (mc.IsNumeric)
            {
                colType = "Number";
            }
            else
            {
                colType = "Text";
            }

            ColGridDataTable.Rows[0][1] = colType;
            return;
        }