示例#1
0
        // Constructor
        //public CloseableTabItem()
        //    : this(null)
        //{
        //}
        public CloseableTabItem(String fileName)
        {
            if (!String.IsNullOrEmpty(fileName))
            {
                ModelFile = fileName;
                // Create an instance of the usercontrol
                closeableTabHeader = new CloseableHeader();
                // Assign the usercontrol to the tab header
                this.Header = closeableTabHeader;

                ModelTree = new InputModelTreeView(ModelFile);
                abstractLattice = new AbstractLattice(ModelFile);

                this.Content = ModelTree;

                // Attach to the CloseableHeader events
                // (Mouse Enter/Leave, Button Click, and Label resize)
                closeableTabHeader.button_close.Click += new RoutedEventHandler(button_close_Click);
                closeableTabHeader.label_TabTitle.SizeChanged += new SizeChangedEventHandler(label_TabTitle_SizeChanged);
            }
            else
            {
                //ModelTree = new InputModelTreeView();
                MessageBox.Show("Failed to load input file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                abstractLattice = null;
            }
        }
示例#2
0
        public bool acceptSuggestion(Suggestion sg)
        {
            if (visEl != null)
            {
                //update weights in Suggester
                this.visualiserSuggester.retrieveSuggestion(sg.SuggestionString, "ACCEPT");

                if (sg.RHS.Equals(visEl.Data.Name))// map to Visual element
                {
                    AbstractTreeLatticeNode atln = sourceASTL.getAbstractNodeAtAddress(sg.LHS);

                    if (atln != null)
                    {
                        XmlNode tx = atln.ToXML();
                        TreeViewViewModel tv = new TreeViewViewModel(tx);
                        visEl.processVisual_TreeNodeDrop(tv.Root, atln.Address); //like dropping a TreeNode on visEl
                        reportMessage("Suggestion \"" + sg.ToString() + "\" applied", ReportIcon.OK);
                        return true;
                    }
                }
                else //map to internal elements
                {

                    AbstractLattice sourceLattice = new AbstractLattice(visEl.ReverseData);
                    AbstractTreeLatticeNode lownode = sourceLattice.Root.findInChildrenByName(sg.LHS);

                    //MessageBox.Show("Source: " + sg.LHS);

                    if (lownode != null)
                    {
                        string lhs = visEl.abstractTree.findRelativeAddress(sourceLattice.Root, lownode);

                        if (!String.IsNullOrEmpty(lhs))
                        {
                            string rhs = sg.RHS;
                            //if (rhs.StartsWith(visEl.abstractTree.Root.Name))
                            //  rhs = rhs.Substring(visEl.abstractTree.Root.Name.Length+1);

                            //MessageBox.Show("in sugg\n\nSource: " + lhs + "\nTarget: " + rhs);

                            XmlNode tx = sourceLattice.Root.ToXML();
                            TreeViewViewModel tv = new TreeViewViewModel(tx);
                            TreeNodeViewModel tn = tv.findInTreeByName(sg.LHS);
                            if (tn != null)//which should be
                                //MessageBox.Show("in sugg: " + tv.Root.ToXML().OuterXml);
                                if (visEl.processElement_TreeNodeDrop(lhs, rhs, tn) == true)
                                {//like dropping a tree node on element of the list
                                    reportMessage("Suggestion \"" + sg.ToString() + "\" applied", ReportIcon.OK);
                                    return true;
                                }
                            //MessageBox.Show("in sugg\n\n"+visEl.templateVM.TemplateXmlNode.OuterXml + "\n\n" + visEl.templateVMR.TemplateXmlNode.OuterXml);
                        }

                        return false;
                    }
                }

                reportMessage("Could not find suggestion in source model", ReportIcon.Error);
                return false;

            }
            else//else will never happen
            {
                reportMessage("No visual element to apply suggestions to", ReportIcon.Error);
                return false;
            }
        }
示例#3
0
 public Correspondence()
 {
     _ATLHS = new AbstractLattice();
     _ATRHS = new AbstractLattice();
 }
示例#4
0
        private void Test_Click(object sender, RoutedEventArgs e)
        {
            //AbstractLattice sabs = new AbstractLattice(@"C:\Users\iavazpour\Desktop\CitationsEndNote.xml");
            //AbstractLattice tabs = new AbstractLattice(@"C:\Users\iavazpour\Desktop\FromJobRefDocBook.xml");

            AbstractLattice tabs = new AbstractLattice("real_estate_nky.xml");
            //AbstractLattice sabs = new AbstractLattice("real_estate_texas.xml");
            //AbstractLattice tabs = new AbstractLattice("real_estate_yahoo.xml");
            //AbstractLattice tabs = new AbstractLattice("real_estate_homeseeker.xml");
            AbstractLattice sabs = new AbstractLattice("real_estate_windermere.xml");

            Suggester testSugg;

            SuggesterConfig scP = new SuggesterConfig();
            SuggesterConfig scR = new SuggesterConfig();

            double prec = 0;
            double reca = 1;

            SuggesterConfig sct = new SuggesterConfig();
            sct.UseIsoRankSimSuggester = true;
            sct.UseNameSimSuggester = true;
            sct.UseNeighborSimSuggester = true;
            sct.UseStructSimSuggester = true;
            sct.UseTypeSimSuggester = true;
            sct.UseValueSimSuggester = true;

            testSugg = new Suggester(sabs, tabs, sct);
            testSugg.imFeelingLucky();

            String test1 =  "Evaluation Results for test1 " + testSugg.evaluator.printAnalysisResults();
            //MessageBox.Show(test1);

            SuggesterConfig sc = new SuggesterConfig();
            sc.UseIsoRankSimSuggester = false;
            sc.UseNameSimSuggester = false;
            sc.UseNeighborSimSuggester = false;
            sc.UseStructSimSuggester = false;
            sc.UseTypeSimSuggester = false;
            sc.UseValueSimSuggester = false;

            for (int i = 1; i < 2; i++)
            {
                sc.UseIsoRankSimSuggester = !sc.UseIsoRankSimSuggester;
                for (int j = 1; j < 2; j++)
                {
                    sc.UseNameSimSuggester = !sc.UseNameSimSuggester;
                    for (int t = 0; t < 2; t++)
                    {
                        sc.UseNeighborSimSuggester = !sc.UseNeighborSimSuggester;
                        for (int a = 0; a < 2; a++)
                        {
                            sc.UseStructSimSuggester = !sc.UseStructSimSuggester;
                            for (int b = 0; b < 2; b++)
                            {
                                sc.UseTypeSimSuggester = !sc.UseTypeSimSuggester;
                                for (int d = 0; d < 2; d++)
                                {
                                    sc.UseValueSimSuggester = !sc.UseValueSimSuggester;

                                    testSugg = new Suggester(sabs, tabs, sc);
                                    testSugg.imFeelingLucky();

                                    if (testSugg.evaluator.Precision > prec)
                                    {
                                        scP = sc;
                                        prec = testSugg.evaluator.Precision;
                                    }

                                    if (testSugg.evaluator.Recall < reca)
                                    {
                                        scR = sc;
                                        reca = testSugg.evaluator.Recall;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            testSugg = new Suggester(sabs, tabs, scP);
            testSugg.imFeelingLucky();
            //MessageBox.Show(scP.ToString() + testSugg.evaluator.printAnalysisResults(), "Evaluation Results for precision");
            string test2 = "Evaluation Results for precision" + testSugg.evaluator.printAnalysisResults();

            testSugg = new Suggester(sabs, tabs, scR);
            testSugg.imFeelingLucky();
            //MessageBox.Show(scR.ToString() + testSugg.evaluator.printAnalysisResults(), "Evaluation Results for recall");
            string test3 = "Evaluation Results for recall" + testSugg.evaluator.printAnalysisResults();

            MessageBox.Show(test1 + test2 + test3);

            //AbstractLattice sabsR = new AbstractLattice(@"C:\Users\iavazpour\Desktop\CitationsEndNote.xml");
            //AbstractLattice tabsR = new AbstractLattice(@"C:\Users\iavazpour\Desktop\FromJobRefDocBook.xml");

            //First Create the instance of Stopwatch Class
            //Stopwatch sw = new Stopwatch();

            // Start The StopWatch ...From 000
            //sw.Start();

            //testSugg.imFeelingLucky();

            //sw.Stop();

            //this.updateSuggestions(testSugg.getSuggestionsAsStrings(testSugg.LastResults));

            //MessageBox.Show(string.Format("Minutes :{0}\nSeconds :{1}\n Mili seconds :{2}", sw.Elapsed.Minutes,
             //   sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds));

            //testSugg = new Suggester(sabs, tabs, sc);

            //sw = new Stopwatch();

            // Start The StopWatch ...From 000
            //sw.Start();

            //testSugg.imFeelingLucky();

            //sw.Stop();

            //this.updateSuggestions(testSugg.getSuggestionsAsStrings(testSugg.LastResults));

            //MessageBox.Show(string.Format("Minutes :{0}\nSeconds :{1}\n Mili seconds :{2}", sw.Elapsed.Minutes,
               // sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds));

            /*Object obj = TestVisual.Resources["sourceData"];
            MessageBox.Show(obj.GetType().ToString());
            if ((obj as XmlDataProvider) != null)
            {
                XmlNode xnode = (obj as XmlDataProvider).Document.DocumentElement.Clone();
                if (xnode != null)
                {
                    XElement xmlDocumentWithoutNs = RemoveAllNamespaces(XElement.Parse(xnode.OuterXml));
                    MessageBox.Show(xmlDocumentWithoutNs.ToString());
                    XmlDocument xdoc = new XmlDocument();
                    xdoc.LoadXml(xmlDocumentWithoutNs.ToString());
                    TestVisual.Data =  xdoc.DocumentElement;
                }

            }*/

            //string test = @"javasource/class_declarations/class_declaration/properties/java_property/identifier";

            //MyLogicalTreeHelper helper = new MyLogicalTreeHelper();
            //Collection<object> results = helper.getVisualElementsByName(SourceCanvas, QualifiedNameString.Convert("javasource"));

            //foreach (var obj in results)
            //{
            //    AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            //    FrameworkElement found = (obj) as FrameworkElement;
            //    FrameworkElementAdorner fea = new FrameworkElementAdorner(found);
            //    if (myAdornerLayer != null)
            //    {
            //        myAdornerLayer.Add(fea);

            //    }
            //}

            //var foundTextBox = LogicalTreeHelper.FindLogicalNode(SourceCanvas, "type");
            //if (foundTextBox != null)
            //{
            //    AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            //    FrameworkElementAdorner fea = new FrameworkElementAdorner(foundTextBox as FrameworkElement);
            //    if (myAdornerLayer != null)
            //    {
            //        myAdornerLayer.Add(fea);
            //        //(foundTextBox as Label).Background = Brushes.Red;
            //    }
            //}
            //else
            //    ReportStatusBar.ShowMessage("not found", ReportIcon.Error);
            //evaluateCombination();
        }
示例#5
0
        private void LoadTarget_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TargetCanvas.Children.Clear();
                targetVisualElements.Clear();

                OpenFileDialog openDialog = new OpenFileDialog();
                openDialog.Title = "Open Target file";
                openDialog.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
                openDialog.FilterIndex = 0;
                Nullable<bool> result = openDialog.ShowDialog();

                if (result == true)
                {
                    targetFile = openDialog.FileName;
                    XAMLRenderer rend = new XAMLRenderer();
                    TargetCanvas.Children.Add(rend.createVisualisation(targetFile));

                    if (TargetCanvas.Children.Count > 0)//get visual elements for suggester
                        targetVisualElements = rend.VisualElementList;

                    targetASTL = new AbstractLattice(targetFile);
                    prepareSuggestions();
                    ReportStatusBar.ShowStatus("Target model loaded", ReportIcon.OK);

                    string modelname = targetFile.Substring(targetFile.LastIndexOf("\\") + 1);
                    //log event
                    logger.log("Target model \"" + modelname + "\" opened.", ReportIcon.Info);
                }
                else
                    ReportStatusBar.ShowStatus("Could not load Target model", ReportIcon.Error);
            }
            catch (Exception ex)
            {
                ReportStatusBar.ShowStatus(ex.ToString(), ReportIcon.Error);
            }
        }
示例#6
0
        private void ItemElement_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("TreeNodeViewModel"))//Visualiser
            {
                TreeNodeViewModel sourceNode = e.Data.GetData("TreeNodeViewModel") as TreeNodeViewModel;

                if (templateVM.HeaderNode != null && sourceLatticeNodeToMatch != null)
                {
                    //string source = "";
                    //if (sourceNode.Name.Equals(templateVM.HeaderNode.Name))
                    //    source = ".";
                    // else
                    string source = sourceNode.getRelativeAddress(templateVM.HeaderNode);

                    string target = ((sender as ListBoxItem).DataContext as Element).Address;//was t

                    //string target = t.Substring(t.IndexOf('/') + 1);

                    //MessageBox.Show("in element\n\nDragged\nSource: " + source + "\nTarget: " + target);
                    //MessageBox.Show("in element: "+ sourceNode.ToXML().OuterXml);
                    //============
                    processElement_TreeNodeDrop(source, target, sourceNode);
                    //============

                    //log event
                    (ParentWindow as Visualiser).logger.log("\"" + sourceNode.getRelativeAddress(templateVM.HeaderNode) + "\" was dropped on \"" + target + "\" attribute of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);

                }
                else
                    ShowStatus("Please set the header node first!", ReportIcon.Error);

                e.Handled = true;

                AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
                myAdornerLayer.Remove(visualDragAdorner);
            }

            else if ((e.Data.GetDataPresent("Element")) && (ParentWindow is Mapper))//Mapper
            {
                Element sourceElement = e.Data.GetData("Element") as Element;
                Element targetElement = (sender as ListBoxItem).DataContext as Element;
                //string rule = (sourceElement.Name + " : " + sourceElement.Address + " -> " + targetElement.Name + " : " + targetElement.Address);

                string targetMatch = targetElement.Address.Substring(targetElement.Address.IndexOf('/') + 1);

                string sourceMatch = sourceElement.Address.Substring(sourceElement.Address.IndexOf('/') + 1);

                if ((ParentWindow as Mapper).NewTemplate != null)
                    (ParentWindow as Mapper).NewTemplate.updateXmlNodeByExactValue(targetMatch, sourceMatch, targetElement.Value);

                //for reverse
                if ((ParentWindow as Mapper).NewTemplateR != null)
                    (ParentWindow as Mapper).NewTemplateR.updateXmlNodeByExactValue(sourceMatch, targetMatch, sourceElement.Value);

                //log event
                (ParentWindow as Mapper).logger.log("Element \"" + sourceElement.Address + "\" was dropped on Element \"" + targetElement.Address + "\".", ReportIcon.OK);

                e.Handled = true;

                AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
                myAdornerLayer.Remove(visualDragAdorner);

            }

            else if (e.Data.GetDataPresent("VisualElement"))//scheduling
            {

                VisualElement v = e.Data.GetData("VisualElement") as VisualElement;

                string targetBase = ((sender as ListBoxItem).DataContext as Element).Address;
                //what to replace
                string target = targetBase.Substring(targetBase.IndexOf('/') + 1);

                bool replaceElement = false;
                string forwardTemplateCallName = "";

                //get metamodel of source model example to find template element restructure

                if (!target.ToLower().Equals("start"))//not start element of the scheduling
                {
                    //update abstractions
                    AbstractTreeLatticeNode reference = this.abstractTree.getAbstractNodeAtAddress(targetBase);
                    reference.Children.Add(v.abstractTree.Root);
                    //update metamodel(create a partial model example)
                    v.abstractTree.Root.parent = reference;

                    if (ParentWindow != null)
                    {
                        if (ParentWindow is Visualiser)
                        {
                            try
                            {
                                string test = (ParentWindow as Visualiser).sourceASTL.RelativeAddressByName(this.templateVM.TemplateName, v.templateVM.TemplateName);
                                if (!String.IsNullOrEmpty(test))
                                    forwardTemplateCallName = test;

                                //show new abstraction rendered in sample popup - commented due to error
                                //debugger
                                /*(this.ParentWindow as Visualiser).samplePopup.Child = rend.renderPartialVisualisation(this);
                                (this.ParentWindow as Visualiser).showSamplePopup(e.GetPosition(this.ParentWindow as Visualiser));*/
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Exception occured in ItemElement_Drop -> " + ex.ToString(), "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                            }

                        }
                        else if (ParentWindow is Mapper)//!! will not get trigered, mapper does not have start!
                        {
                            string test = (ParentWindow as Mapper).sourceASTL.RelativeAddressByName(this.templateVM.TemplateName, v.templateVM.TemplateName);
                            if (!String.IsNullOrEmpty(test))
                                forwardTemplateCallName = test;
                        }
                    }
                    else
                        forwardTemplateCallName = v.templateVM.TemplateName;

                    if (target.Equals(v.Data.Name))
                    {
                        ShowStatus("VisualElement-ItemElementDrop: setting replacement to true -> target = " + target + " v.Data.Name = " + v.Data.Name, ReportIcon.Warning);
                        replaceElement = true;
                    }
                    else
                        replaceElement = false;
                }
                else
                {
                    forwardTemplateCallName = v.templateVM.TemplateName;
                    replaceElement = false;
                }

                templateVM.updateXmlNodeByTempalte(target, forwardTemplateCallName, replaceElement);

                //log event
                (ParentWindow as Visualiser).logger.log("\"" + v.VEName + "\" is set to be placed in \"" + target + "\" of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);

                //******for reverse*******
                //************************
                if (!target.ToLower().Equals("start"))//not start element of the scheduling
                {
                    string reverseTemplateCallName = "";

                    string test = this.abstractTree.RelativeAddressByName(this.templateVMR.TemplateName, v.templateVMR.TemplateName);
                    if (!String.IsNullOrEmpty(test))
                        reverseTemplateCallName = test;

                    if (string.IsNullOrEmpty(reverseTemplateCallName))
                        reverseTemplateCallName = v.templateVMR.TemplateName;

                    if (v.templateVM.TemplateName.Equals(v.ReverseData.Name))
                        replaceElement = true;
                    else
                        replaceElement = false;

                    AbstractLattice tempReverseASTL = new AbstractLattice(this.ReverseData);
                    string toReplace = tempReverseASTL.RelativeAddressByName(this.templateVM.TemplateName, v.templateVM.TemplateName);

                    if (string.IsNullOrEmpty(toReplace))
                        toReplace = v.templateVM.TemplateName;

                    this.templateVMR.updateXmlNodeByTempalte(toReplace, reverseTemplateCallName, replaceElement);

                }
                else //we were at the start of scheduling
                {
                    //create start for reverse template
                    this.templateVMR.updateXmlNodeByTempalte("start", v.templateVMR.TemplateName, false);
                }

                //generate arrow
                if ((ParentWindow != null) && (ParentWindow is Visualiser))
                {
                    //create Arrow
                    ArrowLine aline1 = new ArrowLine();
                    aline1.Stroke = Brushes.Black;
                    aline1.StrokeThickness = 2;
                    aline1.IsArrowClosed = true;

                    //get visual element center point
                    Point vePos = v.TransformToVisual((ParentWindow as Visualiser).schedulingCanvas).Transform(new Point(0, 0));
                    if (v.ActualWidth > 180)
                        aline1.X1 = vePos.X + 180 / 2;
                    else
                        aline1.X1 = vePos.X + v.ActualWidth / 2;

                    if (v.ActualHeight > 180)
                        aline1.Y1 = vePos.Y + 180 / 2;
                    else
                        aline1.Y1 = vePos.Y + v.ActualHeight / 2;

                    //Point lePos = (sender as ListBoxItem).TransformToVisual((current as Visualiser).schedulingCanvas).Transform(new Point(0, 0));
                    aline1.X2 = e.GetPosition((ParentWindow as Visualiser).schedulingCanvas).X + (sender as ListBoxItem).ActualWidth / 2;
                    aline1.Y2 = e.GetPosition((ParentWindow as Visualiser).schedulingCanvas).Y;

                    Canvas.SetZIndex(aline1, 2);
                    (ParentWindow as Visualiser).schedulingCanvas.Children.Add(aline1);

                }

                e.Handled = true;

                AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
                myAdornerLayer.Remove(visualDragAdorner);
            }

            else if (e.Data.GetDataPresent("VisualFunctionElementDragObject"))//Visualiser functions
            {
                VisualFunctionElementDragObject eleDrag = e.Data.GetData("VisualFunctionElementDragObject") as VisualFunctionElementDragObject;

                if (ParentWindow is Visualiser)
                {
                    string t = ((sender as ListBoxItem).DataContext as Element).Address;
                    string target = t.Substring(t.IndexOf('/') + 1);//target is where the output goes

                    templateVM.updateXmlNodeByVariableName(target, "$" + eleDrag.element.Value);

                    //for reverse generation
                    eleDrag.function.updateOutput(eleDrag.element.Value, target);

                    //draw the line conecting both elements

                    //for reverse
                    //needs to first check if all args of the input have been matched before dragging the output

                    //get elements participating in function
                    XmlNode functionData = eleDrag.function.Data;
                    XmlNode forwardInputs = functionData.SelectSingleNode("inputs");

                    foreach (XmlNode x in forwardInputs.ChildNodes)
                    {
                        //look for output variable name
                        string outputString = "output" + x.Name.Substring(3);//x.Name is like arg1
                        templateVMR.updateXmlNodeByVariableName(x.InnerText, "$" + outputString);
                    }

                    //log event
                    (ParentWindow as Visualiser).logger.log("Function element \"" + eleDrag.element.Address + "\" was dropped on \"" + target + "\" of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);

                    e.Handled = true;
                }
                else if (ParentWindow is Mapper)
                {
                    string t = ((sender as ListBoxItem).DataContext as Element).Address;
                    string target = t.Substring(t.IndexOf('/') + 1);//target is where the output goes

                    (ParentWindow as Mapper).NewTemplate.updateXmlNodeByVariableName(target, "$" + eleDrag.element.Value);

                    //for reverse generation
                    eleDrag.function.updateOutput(eleDrag.element.Value, target);

                    //draw the line conecting both elements

                    //for reverse
                    //needs to first check if alll args of the input have been matched before dragging the output

                    //get elements participating in function
                    XmlNode functionData = eleDrag.function.Data;
                    XmlNode forwardInputs = functionData.SelectSingleNode("inputs");

                    foreach (XmlNode x in forwardInputs.ChildNodes)
                    {
                        //look for output variable name
                        string outputString = "output" + x.Name.Substring(3);//x.Name is like arg1

                        //if X is constant value, then it has come from nowhere! (from th pannel of constant values)
                        //therefore it will not be considered for puttin back to its place becouse it is considered
                        //as lossy data -> for futur processing
                        //so:
                        double Num;
                        bool isNum = double.TryParse(x.InnerText, out Num);

                        if (!(isNum) && !(x.InnerText.StartsWith("'"))) //is not a constant number or string
                            (ParentWindow as Mapper).NewTemplateR.updateXmlNodeByVariableName(x.InnerText, "$" + outputString);
                    }

                    //log event
                    (ParentWindow as Mapper).logger.log("Function element \"" + eleDrag.element.Address + "\" was dropped on \"" + target + "\" of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);

                    e.Handled = true;
                }

                AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
                myAdornerLayer.Remove(visualDragAdorner);
            }
            else if (e.Data.GetDataPresent("VisualCondition"))//Visualiser Conditions
            {
                VisualCondition cond = (e.Data.GetData("VisualCondition") as VisualCondition);

                string t = ((sender as ListBoxItem).DataContext as Element).Address;

                string target = t.Substring(t.IndexOf('/') + 1);//target is where the output goes

                if (ParentWindow is Visualiser)
                {
                    templateVM.updateNodeByCondition(target, cond.getConditionCode());

                    //log event
                    (ParentWindow as Visualiser).logger.log("Condition \"" + cond.Name + "\" was dropped on \"" + target + "\" of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);
                }
                else if (ParentWindow is Mapper)
                {
                    (ParentWindow as Mapper).NewTemplate.updateNodeByCondition(target, cond.getConditionCode());
                    //log event
                    (ParentWindow as Mapper).logger.log("Condition \"" + cond.Name + "\" was dropped on \"" + target + "\" of Visual Element \"" + this.VEName + "\".", ReportIcon.OK);
                }

                //no reverse for conditions yet

                e.Handled = true;

                AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
                myAdornerLayer.Remove(visualDragAdorner);
            }
            else
                ShowStatus("Unrecognised drag element -> " + e.Data.GetType().ToString(), ReportIcon.Error);
        }
示例#7
0
        public VisualElement()
        {
            //this.Loaded += new RoutedEventHandler(VisualELement_Loaded);

            //add event handler for droping elements on visual element
            this.Drop += new DragEventHandler(VisualElement_Drop);

            this.MouseDown += new MouseButtonEventHandler(VisualElement_MouseDown);

            this.MouseMove += new MouseEventHandler(VisualELement_MouseMove);

            this.MouseRightButtonDown += new MouseButtonEventHandler(VisualElement_RightClick);

            this.MouseEnter += new MouseEventHandler(VisualElement_MouseEnter);

            this.MouseLeave += new MouseEventHandler(VisualElement_MouseLeave);

            this.DragEnter += new DragEventHandler(VisualElement_DragEnter);

            this.DragLeave += new DragEventHandler(VisualElement_DragLeave);

            this.TouchDown += new EventHandler<TouchEventArgs>(VisualElement_TouchDrag);

            //this.MouseDoubleClick += new MouseButtonEventHandler(VisualElement_MouseDoubleClick);//suggestion representation

            elementList = new List<Element>();

            abstractTree = new AbstractLattice();
            //abstractTreeReverse = new AbstractLattice();

            visualMouseAdorner = new VisualElementMouseAdorner(this);
            visualDragAdorner = new VisualElementDragAdorner(this);

            MyItemsHost = new ListBox();

            this.Unloaded += VisualElement_Unloaded;
        }
示例#8
0
 public NeighborSimSuggester(AbstractLattice sASTL, AbstractLattice tASTL)
 {
     sourceASTL = sASTL;
     targetASTL = tASTL;
 }
示例#9
0
        public void processVisual_TreeNodeDrop(TreeNodeViewModel treeN, String FullAddress)
        {
            //set header for template XSLT
            templateVM.HeaderNode = treeN; // I do not think these will be used, they have been used in visualiser to check and set visualfunction abstraction

            //set address Id for template XSLT
            templateVM.TemplateAddress = FullAddress; // I do not think these will be used

            AbstractTreeLatticeNode matchingNode = (ParentWindow as Visualiser).sourceASTL.getAbstractNodeAtAddress(FullAddress);

            //define correspondence
            if (matchingNode != null)//if you have found the node
            {
                if (matchingNode.ruleIndex == -1)
                {
                    sourceLatticeNodeToMatch = matchingNode;
                }
                else if (matchingNode.parent != null)
                {
                    //create a duplicate****************************** duplicate not implemented yet
                    sourceLatticeNodeToMatch = matchingNode.duplicate();
                    matchingNode.parent.Children.Add(sourceLatticeNodeToMatch);
                }

                sourceLatticeNodeToMatch.isMatched = true;
                sourceLatticeNodeToMatch.ruleIndex = RULEINDEX;//assign an index for current rule

                //assign same rule index for this.abstractTree
                this.abstractTree.Root.ruleIndex = sourceLatticeNodeToMatch.ruleIndex;
                this.abstractTree.Root.isMatched = true;

                //increment index for other correspondences
                RULEINDEX++;

                //go for reverse, the top part will be obsolete
                //this.abstractTreeReverse = new AbstractLattice(matchingNode);//might not need abstract tree for reverse, as one way suggestion will eb shown
                this.ReverseData = matchingNode.ToXML();// treeNode.ToXML();//matchingNode might have worked as well but the signature problems might get in the way
                this.templateVMR.TemplateName = this.Data.Name;
            }

            //suggester initiation
            AbstractLattice sourceAST = new AbstractLattice(matchingNode);
            this.abstractTree.prepare();
            SuggesterConfig config = new SuggesterConfig();
            config.UseNameSimSuggester = true;
            config.UseTypeSimSuggester = true;
            config.UseIsoRankSimSuggester = true;
            config.UseValueSimSuggester = true;
            config.UseStructSimSuggester = true;
            (ParentWindow as Visualiser).visualiserSuggester = new Suggester(sourceAST, this.abstractTree, config);

            (ParentWindow as Visualiser).updateSuggestions((ParentWindow as Visualiser).visualiserSuggester.getSuggestionsAsStrings((ParentWindow as Visualiser).visualiserSuggester.imFeelingLucky()));

            //log event
            (ParentWindow as Visualiser).logger.log("\"" + FullAddress + "\" was dropped on \"" + this.VEName + "\"", ReportIcon.OK);
            (ParentWindow as Visualiser).ReportStatusBar.ShowStatus("Mapping " + treeN.Name + " to " + this.Data.Name, ReportIcon.Info);
        }
示例#10
0
 public ValueSimSuggester(AbstractLattice sASTL, AbstractLattice tASTL)
 {
     sourceASTL = sASTL;
     targetASTL = tASTL;
 }
示例#11
0
 public NeighborSimSuggester()
 {
     sourceASTL = null;
     targetASTL = null;
 }
示例#12
0
 public ValueSimSuggester()
 {
     sourceASTL = null;
     targetASTL = null;
 }
示例#13
0
 public NameSimSuggester()
 {
     sourceASTL = null;
     targetASTL = null;
 }
示例#14
0
 public IsoRankSuggester(String sourceFile, String targetFile)
 {
     //reading files to abstract trees
     sourceASTL = new AbstractLattice(sourceFile);
     targetASTL = new AbstractLattice(targetFile);
 }
示例#15
0
 public IsoRankSuggester(AbstractLattice sASTL, AbstractLattice tASTL)
 {
     sourceASTL = sASTL;
     targetASTL = tASTL;
 }
示例#16
0
 public IsoRankSuggester()
 {
     sourceASTL = null;
     targetASTL = null;
 }