Ejemplo n.º 1
0
            public static PromptGroup Parse(Object aParent, XmlElement anXmlElement)
            {
                if (!(aParent is Template))
                {
                    throw new IllegalParentException("Illegal type! Expected instance of type: Template");
                }

                Template tParent = aParent as Template;

                String tName       = getRequiredAttribute(anXmlElement, "name");
                String tRepeatable = getRequiredAttribute(anXmlElement, "repeatable");
                String tMaxRepeats = getOptionalAttribute(anXmlElement, "maxRepeats", "");

                PromptGroup tPromptGroup = new PromptGroup();

                tPromptGroup.Name = tName;
                tPromptGroup.SetRepeatableFromString(tRepeatable);
                tPromptGroup.SetMaxRepeatsFromString(tMaxRepeats);

                //Process prompts
                foreach (XmlNode tNode in anXmlElement.ChildNodes)
                {
                    if (tNode is XmlElement)
                    {
                        XmlElement     tElement = tNode as XmlElement;
                        AbstractPrompt tPrompt  = AbstractPrompt.Factory.Parse(tPromptGroup, tElement);
                        tPromptGroup.AddPrompt(tPrompt);
                    }
                }

                return(tPromptGroup);
            }
Ejemplo n.º 2
0
 private void mnuPromptGroup_MoveDown_Click(object sender, EventArgs e)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
             if (prompt.Parent.MoveDownPrompt(prompt))
             {
                 refreshTreeView();
             }
         }
         else if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup promptGroup = (PromptGroup)idPack["Data"];
             if (promptGroup.Parent.MoveDownPromptGroup(promptGroup))
             {
                 refreshTreeView();
             }
         }
     } catch (Exception ex) {
         MessageBox.Show("Error moving down prompt group: " + ex.Message);
     }
 }
Ejemplo n.º 3
0
 public static void Prompt_Click(object data)
 {
     if (data is PromptText)
     {
         PromptText castedObject = data as PromptText;
         editor_pg.SelectedObject = castedObject;
     }
     else if (data is PromptMultiline)
     {
         PromptMultiline castedObject = data as PromptMultiline;
         editor_pg.SelectedObject = castedObject;
     }
     else if (data is PromptDate)
     {
         PromptDate castedObject = data as PromptDate;
         editor_pg.SelectedObject = castedObject;
     }
     else if (data is PromptCheckbox)
     {
         PromptCheckbox castedObject = data as PromptCheckbox;
         editor_pg.SelectedObject = castedObject;
     }
     else if (data is PromptUserDefined)
     {
         PromptUserDefined castedObject = data as PromptUserDefined;
         editor_pg.SelectedObject = castedObject;
     }
     else
     {
         AbstractPrompt castedObject = data as AbstractPrompt;
         editor_pg.SelectedObject = castedObject;
     }
 }
Ejemplo n.º 4
0
            private static AbstractPrompt producePrompt(PromptGroup aParent, XmlElement anXmlElement)
            {
                AbstractPrompt tPrompt      = null;
                String         tName        = null;
                String         tDescription = null;

                foreach (XmlNode tPromptNode in anXmlElement.ChildNodes)
                {
                    String tType = null;

                    if (tPromptNode.Name == "type")
                    {
                        tType = tPromptNode.InnerText;
                    }
                    else if (tPromptNode.Name == "name")
                    {
                        tName = tPromptNode.InnerText;
                    }
                    else if (tPromptNode.Name == "description")
                    {
                        tDescription = tPromptNode.InnerText;
                    }

                    if (tType == AbstractPrompt.FIELD_TEXT)
                    {
                        tPrompt = PromptText.Factory.Parse(aParent, anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_MULTILINE)
                    {
                        tPrompt = PromptMultiline.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_NUMBER)
                    {
                        tPrompt = PromptNumber.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_DATE)
                    {
                        tPrompt = PromptDate.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_CHECKBOX)
                    {
                        tPrompt = PromptCheckbox.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_USERDEFINED)
                    {
                        tPrompt = PromptUserDefined.Factory.Parse(anXmlElement);
                    }
                }

                if (tPrompt != null)
                {
                    tPrompt.Name        = tName;
                    tPrompt.Description = tDescription;
                }

                return(tPrompt);
            }
Ejemplo n.º 5
0
        private void handleBeforePromptDelete(AbstractPrompt prompt)
        {
            if (String.IsNullOrEmpty(template.TemplateText))
            {
                return;
            }
            string oldVariableName = prompt.VariableName;

            template.TemplateText = template.TemplateText.Replace(oldVariableName, "");
            refreshTemplateText();
        }
Ejemplo n.º 6
0
        private void handlePromptRename(AbstractPrompt prompt, string newName)
        {
            string oldVariableName = prompt.VariableName;
            string newVariableName = prompt.GetVariableName(prompt.Parent, newName);

            template.TemplateText = template.TemplateText.Replace(oldVariableName, newVariableName);
            refreshTemplateText();
            Object tObject = leftTabs_Properties.SelectedObject;

            TreeViewClickHandler.Prompt_Click(tObject);
        }
Ejemplo n.º 7
0
        private void mnuPrompt_InsertVariable_Click(object sender, EventArgs e)
        {
            TreeNode node = leftTabs_DocumentTree.SelectedNode;

            try {
                Hashtable idPack = node.Tag as Hashtable;
                if ((string)idPack["Type"] == "prompt")
                {
                    AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
                    insertIntoTemplateEditor(this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea, this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea.Caret.Offset, prompt.VariableName);
                }
            } catch { }
        }
Ejemplo n.º 8
0
        private void mnuPrompt_CopyAs_Click(object sender, EventArgs e)
        {
            TreeNode node = leftTabs_DocumentTree.SelectedNode;

            try {
                Hashtable idPack = node.Tag as Hashtable;
                if ((string)idPack["Type"] == "prompt")
                {
                    AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
                    prompt.Parent.AddPrompt(prompt.Clone());
                    refreshTreeView();
                }
            } catch { }
        }
Ejemplo n.º 9
0
        private void produceAndAddPrompt(PromptGroup aPromptGroup, Type aType, AbstractPrompt aReferencePrompt)
        {
            AbstractPrompt newPrompt = AbstractPrompt.Factory.CreateInstance(aType);

            if (aReferencePrompt != null)
            {
                aPromptGroup.AddPromptAfter(newPrompt, aReferencePrompt);
            }
            else
            {
                aPromptGroup.AddPrompt(newPrompt);
            }
            refreshTreeView();
        }
Ejemplo n.º 10
0
 private void CreatePromptHandler(Type aType)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt tPrompt      = (AbstractPrompt)idPack["Data"];
             PromptGroup    tPromptGroup = tPrompt.Parent;
             produceAndAddPrompt(tPromptGroup, aType, tPrompt);
         }
     } catch (Exception ex) {
         MessageBox.Show("Error creating prompt from Prompt menu: " + ex.Message);
     }
 }
Ejemplo n.º 11
0
 private void mnuPrompt_Delete_Click(object sender, EventArgs e)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
             prompt.Remove();
             refreshTreeView();
         }
     } catch (Exception ex) {
         MessageBox.Show("Error creating prompt: " + ex.Message);
     }
 }
Ejemplo n.º 12
0
        private void leftTabs_DocumentTree_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            // Point where the mouse is clicked.
            Point p = new Point(e.X, e.Y);

            // Get the node that the user has clicked.
            TreeNode node = leftTabs_DocumentTree.GetNodeAt(p);

            try {
                Hashtable idPack = node.Tag as Hashtable;
                if ((string)idPack["Type"] == "prompt")
                {
                    AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
                    insertIntoTemplateEditor(this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea, this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea.Caret.Offset, prompt.VariableName);
                }
            } catch { }
        }
Ejemplo n.º 13
0
        public bool MoveUpPrompt(AbstractPrompt prompt)
        {
            bool isChanged  = false;
            bool foundLower = false;

            _prompts.ForEach(delegate(AbstractPrompt p) { if (p.OrderKey == prompt.OrderKey - 1)
                                                          {
                                                              p.OrderKey = prompt.OrderKey; foundLower = true;
                                                          }
                             });
            if (foundLower)
            {
                prompt.OrderKey = prompt.OrderKey - 1;
                isChanged       = true;
            }
            return(isChanged);
        }
Ejemplo n.º 14
0
 private void mnuPrompt_MoveUp_Click(object sender, EventArgs e)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
             if (prompt.Parent.MoveUpPrompt(prompt))
             {
                 refreshTreeView();
             }
             ;
         }
     } catch (Exception ex) {
         MessageBox.Show("Error reordering: " + ex.Message);
     }
 }
Ejemplo n.º 15
0
        private void topTabs_TemplateEditor_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode));

            ICSharpCode.TextEditor.TextArea textArea = (ICSharpCode.TextEditor.TextArea)sender;
            try {
                Hashtable idPack = node.Tag as Hashtable;
                switch (idPack["Type"] as string)
                {
                case "promptgroup":
                    return;

                case "prompt":
                    break;
                }

                //Build the variable to insert here
                AbstractPrompt prompt = idPack["Data"] as AbstractPrompt;

                Point p = textArea.PointToClient(new Point(e.X, e.Y));
                textArea.BeginUpdate();
                textArea.Document.UndoStack.StartUndoGroup();

                int offset = textArea.Caret.Offset;
                if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                {
                    ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                    if (sel.ContainsPosition(textArea.Caret.Position))
                    {
                        return;
                    }
                    int len = sel.Length;
                    textArea.Document.Remove(sel.Offset, len);
                    if (sel.Offset < offset)
                    {
                        offset -= len;
                    }
                }
                insertIntoTemplateEditor(textArea, offset, prompt.VariableName);
            } finally {
                textArea.Document.UndoStack.EndUndoGroup();
                textArea.EndUpdate();
            }
        }
Ejemplo n.º 16
0
        public void AddPromptAfter(AbstractPrompt aNewPrompt, AbstractPrompt aPrompt)
        {
            aNewPrompt.Parent   = this;
            aNewPrompt.OrderKey = aPrompt.OrderKey;

            int count = _prompts.Count;

            foreach (AbstractPrompt p in _prompts)
            {
                p.OrderKey = p.OrderKey - count;
                if (p == aPrompt)
                {
                    break;
                }
            }

            _prompts.Add(aNewPrompt);
            renumberPrompts();
        }
Ejemplo n.º 17
0
            public static AbstractPrompt Parse(PromptGroup aParent, XmlElement anXmlElement)
            {
                AbstractPrompt tPrompt = producePrompt(aParent, anXmlElement);

                return(tPrompt);
            }
Ejemplo n.º 18
0
 public void AddPrompt(AbstractPrompt aPrompt)
 {
     aPrompt.Parent   = this;
     aPrompt.OrderKey = _prompts.Count + 1;
     _prompts.Add(aPrompt);
 }
Ejemplo n.º 19
0
 public void RemovePrompt(AbstractPrompt aPrompt)
 {
     _prompts.Remove(aPrompt);
     renumberPrompts();
 }