Пример #1
0
        public ascx_ManualMethodStreams buildGui(bool addLogViewer)
        {
            //AstEngine.HostPanel.clear();
            var topPanel   = this.add_1x1("Methods & Parameters", "Source Code", true);
            var tabControl = topPanel[1].add_TabControl();

            //CodeViewer = tabControl.add_Tab("Source Code").add_SourceCodeViewer();
            CodeViewer = topPanel[0].add_SourceCodeViewer();
            CodeViewer.editor().colorCodeForExtension(".cs");
            CodeStreamTreeViewTab = tabControl.add_Tab("CodeStream TreeView");
            TaintRulesTab         = tabControl.add_Tab("Taint Rules");
            //CodeStreamGraphTab = tabControl.add_Tab("CodeStream Graph");
            //CodeStreamGraphTab.backColor(Color.White);
            //CodeStreamCodeViewer = CodeStreamTreeViewTab.add_SourceCodeViewer();
            //CodeStreamTreeView = CodeStreamCodeViewer.insert_Left<TreeView>(200);
            CodeStreamTreeView = CodeStreamTreeViewTab.add_TreeView();
            TaintRulesList     = TaintRulesTab.add_GroupBox("Taint Propagators").add_TextArea();
            //CodeStreamGraph = CodeStreamGraphTab.add_Panel().add_Graph();

            ParametersTreeView = CodeViewer.insert_Below <TreeView>(100)
                                 .showSelection()
                                 .sort();
            MethodsCalledTreeView = ParametersTreeView.insert_Right <TreeView>(250)
                                    .showSelection()
                                    .sort();
            var commandsPanel = CodeViewer.insert_Below <Panel>(20);

            SaveCodeLink      = commandsPanel.add_Link("save code", 0, 0, () => saveEditorContents());
            showINodeLink     = commandsPanel.add_Link("show INode CodeStream", 0, 60, () => showCurrentINodeCodeStream());
            CurrentINodeLabel = commandsPanel.add_Label("current INode: ", 0, 200);
            commandsPanel.add_Label("Search:", 0, 350)
            .top(2)
            .append_TextBox("")
            .top(0)
            .onTextChange((text) => CodeViewer.editor().invoke("searchForTextInTextEditor_findNext", text))
            .onEnter((text) => CodeViewer.editor().invoke("searchForTextInTextEditor_findNext", text))
            .align_Right(commandsPanel);

            // context menu

            CodeStreamTreeView.add_ContextMenu()
            .add_MenuItem("Expand Selectd Node",
                          () => {
                var selectedNode = CodeStreamTreeView.selected();
                if (selectedNode.notNull())
                {
                    selectedNode.ExpandAll();
                }
                selectedNode.selected();
            });

            /*MethodsCalledTreeView.add_ContextMenu()
             *                                   .add_MenuItem("Show Method Stream Details", ()=> showMethodStreamDetails(CodeViewer.get_Text()));
             */
            //events

            CodeStreamTreeView.afterSelect <O2CodeStreamNode>
                ((streamNode) => CodeViewer.editor().setSelectionText(streamNode.INode.StartLocation, streamNode.INode.EndLocation));

            MethodsCalledTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode));
            ParametersTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode));

            CodeViewer.onCaretMove((caret) => findINodeAtCaretLocation(caret));
            //CodeViewer.editor().eDocumentDataChanged += (text)=> saveEditorContents();
            if (addLogViewer)
            {
                this.insert_Below <Panel>(100).add_LogViewer();
            }

            commandsPanel.onDrop(
                (file) => {
                if (file.fileExists())
                {
                    loadFile(file);
                }
            });

            loadDefaultTaintRules();
            return(this);
        }