예제 #1
0
        /// <summary>
        /// Dialog to allow user to select one or more items from a dictionary
        /// </summary>
        /// <param name="title"></param>
        /// <param name="prompt"></param>
        /// <param name="dictionaryName"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>

        public static string CheckedListBoxDialog(
            string title,
            string prompt,
            string dictionaryName,
            string criteria)
        {
            if (Instance == null)
            {
                Instance = new CriteriaDictMultSelect();
            }

            Instance.Text        = title;
            Instance.Prompt.Text = prompt;
            Instance.SetupCheckedListBoxFromDictionary(dictionaryName, criteria);

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.Cancel)
            {
                return(null);
            }

            string newSelections = Instance.GetCheckedListItems();

            return(newSelections);
        }
예제 #2
0
/// <summary>
/// Invoke the editor
/// </summary>
/// <param name="qc"></param>
/// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            if (Lex.StartsWith(qc.MetaColumn.Dictionary, "ContentsTree"))
            {
                return(CriteriaContentsTreeList.Edit(qc));
            }

            if (Instance == null)
            {
                Instance = new CriteriaDictMultSelect();
            }

            new JupyterGuiConverter().ConvertFormOrUserControl(Instance);

            string title  = "Search criteria for " + qc.ActiveLabel;
            string prompt = "Select one or more " + qc.ActiveLabel + " from the list below.";

            string dictName = GetCriteriaSpecificDictionary(qc);

            string selections = CheckedListBoxDialog(title, prompt, dictName, qc.Criteria);

            if (selections == null)
            {
                return(false);
            }

            else
            {
                if (selections == "")
                {
                    qc.Criteria = qc.CriteriaDisplay = "";
                }
                else
                {
                    qc.CriteriaDisplay = selections;

                    if (!qc.MetaColumn.IsNumeric)
                    {                     // quote items if necessary
                        List <string> items = Csv.SplitCsvString(selections);
                        for (int i1 = 0; i1 < items.Count; i1++)
                        {
                            items[i1] = Lex.AddSingleQuotes(items[i1]);
                        }
                        selections = Csv.JoinCsvString(items);
                    }

                    qc.Criteria = qc.MetaColumn.Name + " in (" + selections + ")";
                }
                return(true);
            }
        }
예제 #3
0
/// <summary>
/// Invoke the editor
/// </summary>
/// <param name="qc">QueryColumn to edit</param>
/// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            //if (DebugMx.True) return CriteriaYesNo.Edit(qc);

            if (qc.MetaColumn.DictionaryMultipleSelect)
            {
                return(CriteriaDictMultSelect.Edit(qc));
            }

            else if (Lex.Eq(qc.MetaColumn.Dictionary, "yes_no"))
            {
                return(CriteriaYesNo.Edit(qc));
            }

            MetaColumn mc = qc.MetaColumn;

            if (Instance == null)
            {
                Instance = new CriteriaDialog();
            }
            if (Instance.Visible)
            {
                return(false);                              // catch 2nd of two quick single-clicks & ignore
            }
            new JupyterGuiConverter().ConvertFormOrUserControl(Instance, true);

            Instance.Setup(qc);
            Instance.Qc = qc;
            Form         activeForm = SessionManager.ActiveForm;
            DialogResult dr         = Instance.ShowDialog(SessionManager.ActiveForm);

            if (activeForm != null)
            {
                activeForm.BringToFront();
            }

            if (dr == DialogResult.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
/// <summary>
/// Edit gene families
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void EditGeneFamilies_Click(object sender, EventArgs e)
        {
            string title      = "Allowed Gene Families";
            string prompt     = "Select one or more Gene Families from the list below.";
            string dictName   = "TA_Gene_Family";
            string selections = GeneFamilies.Text;

            selections = Csv.JoinCsvString(Csv.SplitCsvString(selections));       // quote any items with spaces in them

            string criteria = "GeneFamilies in (" + selections + ")";             // put in criteria form for dialog box

            selections = CriteriaDictMultSelect.CheckedListBoxDialog(title, prompt, dictName, criteria);

            if (selections != null)
            {
                GeneFamilies.Text = selections;
            }
            return;
        }
예제 #5
0
        /// <summary>
        /// Dialog to make multiple dictionary selections from checked list dialog box
        /// </summary>
        /// <param name="dictionaryName"></param>
        /// <param name="selections"></param>
        /// <param name="prompt"></param>
        /// <returns></returns>

        public static string GetCheckedListBoxDialog(
            string dictionaryName,
            string selections,
            string prompt)
        {
            MetaTable  mt = new MetaTable();            // create dummy table
            MetaColumn mc = mt.AddMetaColumn(dictionaryName, prompt, MetaColumnType.String);

            mc.Dictionary = dictionaryName;

            //if (selections.Contains(","))  { ... } (still have problem for single item)

            // split and reformat to properly handle unquoted items with spaces in them, e.g. "big cat, little dog"

            List <string> items = Csv.SplitCsvString(selections, false);

            selections = Csv.JoinCsvString(items);

            QueryTable  qt = new QueryTable(mt);
            QueryColumn qc = qt.QueryColumns[0];

            qc.Criteria = mc.Name + " in (" + selections + ")";
            bool success = CriteriaDictMultSelect.Edit(qc);

            if (!success)
            {
                return(null);
            }

            ParsedSingleCriteria psc = MqlUtil.ParseQueryColumnCriteria(qc);

            if (psc == null || psc.ValueList == null)
            {
                selections = "";
            }
            else
            {
                selections = MqlUtil.FormatValueListString(psc.ValueList, false);
            }
            return(selections);
        }
예제 #6
0
        /// <summary>
        /// Invoke the editor
        /// </summary>
        /// <param name="qc">QueryColumn to edit</param>
        /// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            ParsedSingleCriteria psc;

            if (qc.MetaColumn.DictionaryMultipleSelect)
            {
                return(CriteriaDictMultSelect.Edit(qc));
            }

            if (Instance == null)
            {
                Instance = new CriteriaMolFormula();
            }

            if (qc.Criteria != "")
            {
                psc = MqlUtil.ParseQueryColumnCriteria(qc);
            }

            else
            {
                psc        = new ParsedSingleCriteria();
                psc.OpEnum = CompareOp.FormulaEqual;
            }

            Instance.Formula.Text = psc.Value;
            if (psc.OpEnum == CompareOp.FormulaEqual)
            {
                Instance.ExactMF.Checked = true;
            }
            else
            {
                Instance.PartialMF.Checked = true;
            }

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.Cancel)
            {
                return(false);
            }

            string val = Instance.Formula.Text.Trim();

            if (val == "")             // no criteria
            {
                qc.Criteria = qc.CriteriaDisplay = "";
                return(true);
            }

            if (Instance.ExactMF.Checked)
            {
                qc.Criteria        = qc.MetaColumn.Name + " fmla_eq " + Lex.AddSingleQuotes(val);;
                qc.CriteriaDisplay = "= " + val;
            }

            else
            {
                qc.Criteria        = qc.MetaColumn.Name + " fmla_like " + Lex.AddSingleQuotes(val);
                qc.CriteriaDisplay = "like " + val;
            }

            return(true);
        }