Ejemplo n.º 1
0
        public AspectWindowPane(IDEInterop ide)
        {
            try
            {
                this.ide = ide;
                KeyboardShortcutHelper.control = this;
                //Hardcoded language
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru");
                InitializeComponent();
                Adapter       = new AspectCore.TreeViewAdapter(Manager, tvAspects);
                fmSelectPoint = new FmSelectPoint(ide, treeManager);

                SynchronizeUndoButtons();

                if (treeManager.GetParsersCount() == 0)
                {
                    GlobalData.traceAction(Strings.NoParsers);
                }

                GlobalData.traceAction("Загрузка плагина завершена");
                GlobalData.traceAction("Версия .net: " + System.Environment.Version);
                GlobalData.traceAction(System.Environment.Is64BitProcess ? "64-разрядный процесс" : "32-разрядный процесс");

                //костыль
                tvAspects.Scrollable = true;
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 2
0
        private static void SetStackTraceImpl(Exception x, StackTraceElement[] stackTrace)
        {
#if !FIRST_PASS
            Throwable _this = x as Throwable;
            if (_this == null)
            {
                ExceptionInfoHelper eih  = new ExceptionInfoHelper(stackTrace);
                IDictionary         data = x.Data;
                if (data != null && !data.IsReadOnly)
                {
                    lock (data.SyncRoot)
                    {
                        data[EXCEPTION_DATA_KEY] = eih;
                    }
                }
            }
            else
            {
                lock (_this)
                {
                    if (_this.stackTrace == null && _this.tracePart1 == null && _this.tracePart2 == null)
                    {
                        return;
                    }
                    _this.stackTrace = stackTrace;
                }
            }
#endif
        }
Ejemplo n.º 3
0
 private void КомментарийToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (tvAspects.SelectedNode == null)
         {
             return;
         }
         PointOfInterest pt = Adapter.GetPointByNode(tvAspects.SelectedNode);
         if (pt == null)
         {
             return;
         }
         fmEditNote.Note = pt.Note;
         if (fmEditNote.ShowDialog() == DialogResult.OK)
         {
             Adapter.UpdateToolTip(tvAspects.SelectedNode, fmEditNote.Note);
         }
         SynchronizeUndoButtons();
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 4
0
 private void tsbFindNode_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ide.IsDocumentOpen())
         {
             return;
         }
         PointOfInterest pt = null;//= EditPointHelper.FindPointUnderCursor(ide, treeManager);
         if (pt != null)
         {
             pt.Text = ide.GetCurrentLine();
             pt      = TreeSearchEngine.FindPointInAspectTree(Manager.WorkingAspect, pt);
             if (pt != null)
             {
                 TreeNode tn = Adapter.FindNodeByValue(pt);
                 tvAspects.SelectedNode = tn;
                 tvAspects.Focus();
                 SetStatus("");
                 return;
             }
         }
         SetStatus(Strings.CannotFindSubAspect);
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 5
0
        internal static StackTraceElement[] computeStackTrace(Exception x, StackTrace part1, StackTrace part2)
        {
#if FIRST_PASS
            return(null);
#else
            ExceptionInfoHelper eih = new ExceptionInfoHelper(part1, part2);
            return(eih.get_StackTrace(x));
#endif
        }
Ejemplo n.º 6
0
        private void перейтиККодуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (tvAspects.SelectedNode == null)
                {
                    return;
                }
                PointOfInterest pt = Adapter.GetPointByNode(tvAspects.SelectedNode);
                if ((pt?.Context?.Count ?? 0) == 0)
                {
                    return;
                }
                string           fileName = Manager.GetFullFilePath(pt.FileName);
                PointOfInterest  Tree     = ide.IsDocumentOpen(fileName) ? treeManager.GetTree(fileName, ide.GetDocument(fileName)) : treeManager.GetTree(fileName);
                TreeSearchResult Search   = TreeSearchEngine.FindPointInTree2(Tree, pt, treeManager.GetText(fileName));
                if (Search.Count == 0)
                {
                    SetStatus(string.Format(Strings.CannotFindPoint, pt.Title));
                }
                else if (Search.Singular && (ModifierKeys != Keys.Control))
                {
                    //update point anchor if similarity != 1
                    string path = Manager.GetFullFilePath(pt.FileName);
                    ide.NavigateToFileAndPosition(path, Search[0].Location.StartLine, Search[0].Location.StartColumn);
                    SetStatus("");
                }
                else
                {
                    if (Search.Count >= 2)
                    {
                        int d1 = TreeSearchOptions.Equility - Search.GetTotalMatch(0);
                        int d2 = TreeSearchOptions.Equility - Search.GetTotalMatch(1);
                        //float near = Math.Max(pt.NearG, pt.NearL);
                        //float threshold = ((near + 4) / 5 + 1) / 2; //hardcoded
                        //if (Search._result[0].TotalMatch > threshold*TreeSearchOptions.Equility && Search._result[1].TotalMatch < threshold * TreeSearchOptions.Equility)
                        if (d2 != 0 && d2 >= d1 * 2 && (ModifierKeys != Keys.Control))
                        {
                            string path = Manager.GetFullFilePath(pt.FileName);
                            ide.NavigateToFileAndPosition(path, Search[0].Location.StartLine, Search[0].Location.StartColumn);
                            SetStatus("");
                            return;
                        }
                    }

                    fmSelectPoint.Launch(Search, pt);
                    SetStatus("");
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 7
0
 private void tsbRedo_Click(object sender, EventArgs e)
 {
     try
     {
         Adapter.Redo();
         SynchronizeUndoButtons();
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 8
0
        internal static StackTraceElement[] getOurStackTrace(Exception x)
        {
#if FIRST_PASS
            return(null);
#else
#if !WINRT
            Throwable _this = x as Throwable;
            if (_this == null)
            {
                lock (x)
                {
                    ExceptionInfoHelper eih  = null;
                    IDictionary         data = x.Data;
                    if (data != null && !data.IsReadOnly)
                    {
                        lock (data.SyncRoot)
                        {
                            eih = (ExceptionInfoHelper)data[EXCEPTION_DATA_KEY];
                        }
                    }
                    if (eih == null)
                    {
                        return(Throwable.UNASSIGNED_STACK);
                    }
                    return(eih.get_StackTrace(x));
                }
            }
            else
            {
                lock (_this)
                {
                    if (_this.stackTrace == Throwable.UNASSIGNED_STACK ||
                        (_this.stackTrace == null && (_this.tracePart1 != null || _this.tracePart2 != null)))
                    {
#if false
                        ExceptionInfoHelper eih = new ExceptionInfoHelper(_this.tracePart1, _this.tracePart2);
                        _this.stackTrace = eih.get_StackTrace(x);
                        _this.tracePart1 = null;
                        _this.tracePart2 = null;
#else
                        throw new NotImplementedException("e.h");
#endif
                    }
                }
                return(_this.stackTrace ?? Throwable.UNASSIGNED_STACK);
            }
#else
            //throw new NotImplementedException("3");
            System.Diagnostics.Debug.WriteLine(x);
            return(Throwable.UNASSIGNED_STACK);
#endif
#endif
        }
Ejemplo n.º 9
0
        private void tvAspects_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                PointOfInterest pt = Adapter.GetPointByNode(e.Node);
                UpdateButtonsAndMenus(pt);

                ide.UpdateSubAspectProperties(Adapter.GetPointByNode(e.Node), e.Node);
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 10
0
 private void tvAspects_Enter(object sender, EventArgs e)
 {
     try
     {
         if (tvAspects.SelectedNode != null)
         {
             ide.UpdateSubAspectProperties(Adapter.GetPointByNode(tvAspects.SelectedNode), tvAspects.SelectedNode);
         }
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 11
0
 private void tsbOpen_Click(object sender, EventArgs e)
 {
     try
     {
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             OpenAspectFile(openFileDialog.FileName);
         }
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 12
0
        // this method is *only* for .NET exceptions (i.e. types not derived from java.lang.Throwable)
        internal static void setStackTrace(Exception x, StackTraceElement[] stackTrace)
        {
#if !FIRST_PASS
            ExceptionInfoHelper eih  = new ExceptionInfoHelper(checkStackTrace(stackTrace));
            IDictionary         data = x.Data;
            if (data != null && !data.IsReadOnly)
            {
                lock (data.SyncRoot)
                {
                    data[EXCEPTION_DATA_KEY] = eih;
                }
            }
#endif
        }
Ejemplo n.º 13
0
        internal static void fillInStackTrace(Exception x)
        {
#if !FIRST_PASS
            lock (x)
            {
                ExceptionInfoHelper eih  = new ExceptionInfoHelper(null, new StackTrace(true));
                IDictionary         data = x.Data;
                if (data != null && !data.IsReadOnly)
                {
                    lock (data.SyncRoot)
                    {
                        data[EXCEPTION_DATA_KEY] = eih;
                    }
                }
            }
#endif
        }
Ejemplo n.º 14
0
 private void изменитьПривязкуToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (tvAspects.SelectedNode == null)
         {
             return;
         }
         EditPointHelper.EditPointAnchor(ide, treeManager, Manager, Adapter, tvAspects.SelectedNode, SynchronizeUndoButtons);
         //FIX callback
         SynchronizeUndoButtons();
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 15
0
        private void tvAspects_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            try
            {
                tvAspectLabelEditing = false;
                if (e.CancelEdit || e.Label == null || e.Label == "")
                {
                    return;
                }
                Adapter.RenameNode(e.Node, e.Label);

                SynchronizeUndoButtons();
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 16
0
 private void tsbAddPoint_Click(object sender, EventArgs e)
 {
     try
     {
         TreeNode NewParent = tvAspects.SelectedNode;
         if (tvAspects.SelectedNode != null && Adapter.GetPointByNode(tvAspects.SelectedNode).Context.Count != 0)
         {
             NewParent = NewParent.Parent;
         }
         EditPointHelper.AddPoint(ide, treeManager, Manager, Adapter, NewParent, SynchronizeUndoButtons);
         //FIX callback
         SynchronizeUndoButtons();
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 17
0
 private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             Manager.SerializeAspect(saveFileDialog.FileName, true);
             //RegistryHelper.SaveToRegistry(Strings.RegistryKeyLastOpenAspect, saveFileDialog.FileName);
             CurrentAspectFileName = saveFileDialog.FileName;
             tsbSave.Enabled       = true;
             сохранитьToolStripMenuItem.Enabled = true;
             SetStatus("");
         }
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 18
0
        internal static StackTraceElement[] getOurStackTrace(Exception x)
        {
#if FIRST_PASS
            return(null);
#else
            Throwable _this = x as Throwable;
            if (_this == null)
            {
                lock (x)
                {
                    ExceptionInfoHelper eih  = null;
                    IDictionary         data = x.Data;
                    if (data != null && !data.IsReadOnly)
                    {
                        lock (data.SyncRoot)
                        {
                            eih = (ExceptionInfoHelper)data[EXCEPTION_DATA_KEY];
                        }
                    }
                    if (eih == null)
                    {
                        return(Throwable.UNASSIGNED_STACK);
                    }
                    return(eih.get_StackTrace(x));
                }
            }
            else
            {
                lock (_this)
                {
                    if (_this.stackTrace == Throwable.UNASSIGNED_STACK ||
                        (_this.stackTrace == null && (_this.tracePart1 != null || _this.tracePart2 != null)))
                    {
                        ExceptionInfoHelper eih = new ExceptionInfoHelper(_this.tracePart1, _this.tracePart2);
                        _this.stackTrace = eih.get_StackTrace(x);
                        _this.tracePart1 = null;
                        _this.tracePart2 = null;
                    }
                }
                return(_this.stackTrace ?? Throwable.UNASSIGNED_STACK);
            }
#endif
        }
Ejemplo n.º 19
0
        private void tvAspects_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(Strings.TreeNodeType, false))
                {
                    TreeNode Src = (TreeNode)e.Data.GetData(Strings.TreeNodeType);
                    tvAspects.SelectedNode = Src;

                    int kind = CursorHelper.GetCursorKind(tvAspects, Adapter, Src, e.X, e.Y);

                    if (kind == -1)
                    {
                        e.Effect = DragDropEffects.None;
                    }
                    else
                    {
                        e.Effect = DragDropEffects.Move;
                    }

                    if (OldCursor != kind)
                    {
                        OldCursor = kind;
                        if (kind == -1)
                        {
                            Cursor.Current = Cursors.No;
                        }
                        else if (kind == 0)
                        {
                            Cursor.Current = GetCursor(Strings.CursorNewLevel);
                        }
                        else //if (kind == 1)
                        {
                            Cursor.Current = GetCursor(Strings.CursorInLine);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 20
0
 private void tsbRemovePoint_Click(object sender, EventArgs e)
 {
     try
     {
         if (tvAspects.SelectedNode != null)
         {
             if (tvAspects.SelectedNode.Nodes.Count == 0 ||
                 MessageBox.Show(Strings.MBRemoveNodeText, Strings.MBRemoveNodeTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 Adapter.RemoveNode(tvAspects.SelectedNode);
             }
         }
         SynchronizeUndoButtons();
     }
     catch (Exception exc)
     {
         ExceptionInfoHelper.ShowInfo(exc);
     }
 }
Ejemplo n.º 21
0
        private void tvAspects_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(Strings.TreeNodeType, false))
                {
                    TreeNode newParent;
                    int      pos;
                    CursorHelper.GetPositionToInsert(tvAspects, Adapter, e.X, e.Y, out newParent, out pos);
                    TreeNode NewNode = (TreeNode)e.Data.GetData(Strings.TreeNodeType);
                    Adapter.MoveNode(NewNode, newParent, pos);
                    SynchronizeUndoButtons();
                }
                else if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string fileName = ((string[])(e.Data.GetData(DataFormats.FileDrop)))[0];
                    try
                    {
                        ParserWrapper   pw        = treeManager.GetParserWrapper();
                        PointOfInterest subAspect = Manager.DeserializeAspect(fileName, pw);
                        treeManager.ReleaseParserWrapper(pw);
                        if (subAspect != null)
                        {
                            Point    pt        = tvAspects.PointToClient(new Point(e.X, e.Y));
                            TreeNode newParent = tvAspects.GetNodeAt(pt);
                            Adapter.InsertNode(newParent, subAspect);
                        }
                    }
                    catch (Exception exc)
                    {
                        SetStatus(Strings.UnsupportedAspectFile);
                    }

                    SynchronizeUndoButtons();
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Ejemplo n.º 22
0
        // this method is *only* for .NET exceptions (i.e. types not derived from java.lang.Throwable)
        internal static StackTraceElement[] getStackTrace(Exception x)
        {
#if FIRST_PASS
            return(null);
#else
            lock (x)
            {
                ExceptionInfoHelper eih  = null;
                IDictionary         data = x.Data;
                if (data != null && !data.IsReadOnly)
                {
                    lock (data.SyncRoot)
                    {
                        eih = (ExceptionInfoHelper)data[EXCEPTION_DATA_KEY];
                    }
                }
                if (eih == null)
                {
                    return(new StackTraceElement[0]);
                }
                return(eih.get_StackTrace(x));
            }
#endif
        }