Esempio n. 1
0
        public static void CreateFile(string newFile, string content)
        {
            string dir        = System.IO.Path.GetDirectoryName(newFile);
            string nameExtens = System.IO.Path.GetExtension(newFile);
            string nameClear  = System.IO.Path.GetFileNameWithoutExtension(newFile);

            if (System.IO.File.Exists(newFile))
            {
                newFile = System.IO.Path.Combine(dir, nameClear + "_1" + nameExtens);
            }

            string ext = System.IO.Path.GetExtension(newFile);

            if (ext == ".db")
            {
                using (FileStream fs = System.IO.File.Create(newFile))
                    fs.Close();
                SqlLiteDal sqlld = new SqlLiteDal(newFile);
                //Console.WriteLine(content);
                sqlld.RunSqlScalar(content);
            }
            else
            {
                using (StreamWriter file = new StreamWriter(newFile)) {
                    file.Write(content);
                    file.Close();
                    file.Dispose();
                }
            }
        }
Esempio n. 2
0
        public SqlLiteAddTable(string database)
        {
            this.TransientFor = MainClass.MainWindow;
            this.Build();
            this.Title="New Table";
            //this.dbConnection = dbConnection;
            this.database = database;

            sqlLiteDal= new SqlLiteDal(this.database);

            tvFields.Model =fieldsStore;

            tvFields.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0);
            tvFields.AppendColumn(MainClass.Languages.Translate("type"), new Gtk.CellRendererText(), "text",1);
        }
Esempio n. 3
0
        public DataDatabaseView(string fileName)
        {
            hbox = new HBox();
            sqlLiteDal = new SqlLiteDal(fileName);

            lblTable = new Label(MainClass.Languages.Translate("tables"));
            hbox.PackStart(lblTable,false,false,10);

            cbTable = new ComboBox();
            cbTable.Changed += new EventHandler(OnComboProjectChanged);
            CellRendererText textRenderer = new CellRendererText();
            cbTable.PackStart(textRenderer, true);
            cbTable.AddAttribute(textRenderer, "text", 0);
            cbTable.Model = tablesComboModel;
            cbTable.WidthRequest = 200;

            hbox.PackStart(cbTable,false,false,2);
            hbox.PackEnd(new Label(""),true,true,2);

            this.PackStart(hbox,false,false,5);

            ScrolledWindow sw = new ScrolledWindow ();
            sw.ShadowType = ShadowType.EtchedIn;
            sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);

            treeView = new TreeView (tableModel);
            treeView.RulesHint = true;
            //treeView.SearchColumn = (int) Column.Description;
            sw.Add (treeView);

            this.PackStart(sw,true,true,5);

            this.ShowAll();

            GetTables();
        }
Esempio n. 4
0
        public StructureDatabaseView(string fileName)
        {
            this.filename = fileName;

            hbox = new HBox();

            sqlLiteDal = new SqlLiteDal(fileName);

            lblTable = new Label( MainClass.Languages.Translate("tables"));
            hbox.PackStart(lblTable, false, false, 10);

            cbTable = new ComboBox();
            cbTable.Changed += new EventHandler(OnComboProjectChanged);

            CellRendererText textRenderer = new CellRendererText();
            cbTable.PackStart(textRenderer, true);
            cbTable.AddAttribute(textRenderer, "text", 0);
            cbTable.Model = tablesComboModel;
            cbTable.WidthRequest = 200;

            hbox.PackStart(cbTable, false, false, 2);
            hbox.PackEnd(new Label(""), true, true, 2);

            HButtonBox hbbAction = new HButtonBox();
            hbbAction.LayoutStyle = Gtk.ButtonBoxStyle.Start;
            hbbAction.Spacing =6;

            Button btnAddTable = new Button(MainClass.Languages.Translate("add_table"));
            btnAddTable.Clicked+= delegate(object sender, EventArgs e) {

                SqlLiteAddTable addtable = new SqlLiteAddTable( filename );
                int result = addtable.Run();
                if (result == (int)ResponseType.Ok) {
                    GetTables();
                }
                addtable.Destroy();
            };

            Button btnDeleteTable = new Button(MainClass.Languages.Translate("delete_table"));
            btnDeleteTable.Clicked+= delegate(object sender, EventArgs e) {

                if(!CheckSelectTable())  return;

                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo,MainClass.Languages.Translate("permanently_delete_table", curentTable), "", Gtk.MessageType.Question);
                int result = md.ShowDialog();
                if (result != (int)Gtk.ResponseType.Yes)
                    return;

                DropTable();
                GetTables();
            };

            Button btnEditTable = new Button(MainClass.Languages.Translate("edit_table"));
            btnEditTable.Clicked+= delegate(object sender, EventArgs e) {

                if(!CheckSelectTable())  return;

                SqlLiteEditTable editTable = new SqlLiteEditTable(filename,curentTable);
                int result = editTable.Run();
                if (result == (int)ResponseType.Ok) {
                    GetTables();
                }
                editTable.Destroy();
            };

            hbbAction.Add(btnAddTable);
            hbbAction.Add(btnDeleteTable);
            hbbAction.Add(btnEditTable);
            hbox.PackEnd(hbbAction, false, false, 10);

            this.PackStart(hbox, false, false, 5);

            ScrolledWindow sw = new ScrolledWindow();
            sw.ShadowType = ShadowType.EtchedIn;
            sw.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);

            treeView = new TreeView(tableModel);
            GenerateColumns();
            treeView.RulesHint = true;
            //treeView.SearchColumn = (int) Column.Description;
            sw.Add(treeView);

            this.PackStart(sw, true, true, 5);

            ScrolledWindow sw2 = new ScrolledWindow ();
            sw2.ShadowType = ShadowType.EtchedIn;
            sw2.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
            sw2.HeightRequest = 50;

            textControl = new TextView();
            textControl.Editable = false;
            textControl.HeightRequest = 50;
            sw2.Add (textControl);
            this.PackEnd(sw2, false, false, 5);

            this.ShowAll();
            GetTables();
            //cbTable.Active = 0;
        }
Esempio n. 5
0
        protected override void OnActivated()
        {
            MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.OkCancel, "Are you sure?", "", Gtk.MessageType.Question);
            int result = md.ShowDialog();
            if(result != (int)Gtk.ResponseType.Ok){
                return;
            }

            ProgressDialog progressDialog;

            string filename = System.IO.Path.Combine(MainClass.Paths.ConfingDir, "completedcache");
            sqlLiteDal = new SqlLiteDal(filename);

            string sql = "";

            if(sqlLiteDal.CheckExistTable("completed") ){
                sql = "DROP TABLE completed ;";
                sqlLiteDal.RunSqlScalar(sql);
            }

            sql = "CREATE TABLE completed (id INTEGER PRIMARY KEY, name TEXT, signature TEXT, type NUMERIC, parent TEXT,summary TEXT ,returnType TEXT ) ;";
            sqlLiteDal.RunSqlScalar(sql);

            SyntaxMode mode = new SyntaxMode();
            mode = SyntaxModeService.GetSyntaxMode("text/moscrif");

            progressDialog = new ProgressDialog("Generated...",ProgressDialog.CancelButtonType.None, mode.Keywords.Count() ,MainClass.MainWindow);

            foreach (Keywords kw in mode.Keywords){

                progressDialog.Update(kw.ToString());
                foreach (string wrd in kw.Words){
                        insertNewRow(wrd,wrd,(int)CompletionDataTyp.keywords,"","","");
                    }
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("data.json", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fc.TransientFor = MainClass.MainWindow;
            fc.SetCurrentFolder(@"d:\Work\docs-api\output\");

            if (fc.Run() != (int)ResponseType.Accept) {
                return;
            }
            string json ;
            string fileName = fc.Filename;
            progressDialog.Destroy();
            fc.Destroy();
            progressDialog = new ProgressDialog("Generated...",ProgressDialog.CancelButtonType.None,100 ,MainClass.MainWindow);

            using (StreamReader file = new StreamReader(fileName)) {
                json = file.ReadToEnd();
                file.Close();
                file.Dispose();
            }

            //XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json);
            //doc.Save(fileName+"xml");

            /*JObject jDoc= JObject.Parse(json);
            //classes
            Console.WriteLine("o.Count->"+jDoc.Count);

            foreach (JProperty jp in jDoc.Properties()){
                Console.WriteLine(jp.Name);
            }
            Console.WriteLine("------------");
            JObject classes = (JObject)jDoc["classes"];
            foreach (JProperty jp in classes.Properties()){
                Console.WriteLine(jp.Name);
                JObject classDefin = (JObject)classes[jp.Name];
                string name = (string)classDefin["name"];
                string shortname = (string)classDefin["shortname"];
                string description = (string)classDefin["description"];
                //string type = (string)classDefin["type"];
                insertNewRow(name,name,(int)CompletionDataTyp.types,"",description,name);
            }
            Console.WriteLine("------------");

            JArray classitems = (JArray)jDoc["classitems"];
            foreach (JObject classitem in classitems){

                string name = (string)classitem["name"];
                Console.WriteLine(name);

                string description = (string)classitem["description"];
                string itemtype = (string)classitem["itemtype"];
                string classParent = (string)classitem["class"];
                string signature = (string)classitem["name"];
                CompletionDataTyp type = CompletionDataTyp.noting;
                string returnType= classParent;

                switch (itemtype){
                    case "method":{
                        JArray paramsArray = (JArray)classitem["params"];
                        signature = signature+ GetParams(paramsArray);
                        type = CompletionDataTyp.members;
                        JObject returnJO =(JObject)classitem["return"] ;
                        if(returnJO!=null){
                            returnType = (string)returnJO["type"];
                        }

                        break;
                    }
                    case "property":{

                        string tmpType = (string)classitem["type"];
                        if(!String.IsNullOrEmpty(tmpType)){
                            returnType=tmpType.Replace("{","").Replace("}","");
                        }
                        type = CompletionDataTyp.properties;
                        break;
                    }
                    case "event":{
                        JArray paramsArray = (JArray)classitem["params"];
                        signature = signature+ GetParams(paramsArray);
                        type = CompletionDataTyp.events;
                        break;
                    }
                    case "attribute":{
                        continue;
                        break;
                    }
                    default:{
                        type = CompletionDataTyp.noting;
                        break;
                    }

                }

                insertNewRow(name,signature,(int)type,classParent,description,returnType);
            }*/
            //classitems

            //			string name = (string)o["project"]["name"];
            //			Console.WriteLine(name);

            progressDialog.Destroy();

            md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Done", "", Gtk.MessageType.Info);
            md.ShowDialog();

            return;
            /*

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Select DOC Directory (with xml)", null, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            FileInfo[] xmls = new FileInfo[]{};

            if (fc.Run() == (int)ResponseType.Accept) {

                DirectoryInfo di = new DirectoryInfo(fc.Filename);
                xmls = di.GetFiles("*.xml");
                //List<string> output = new List<string>();

                //MainClass.CompletedCache.ListTypes= listSignature.Distinct().ToList();
                //MainClass.CompletedCache.ListMembers= listMemberSignature.Distinct().ToList();
            }
            progressDialog.Destroy();
            fc.Destroy();
            progressDialog = new ProgressDialog("Generated...",ProgressDialog.CancelButtonType.None,xmls.Length ,MainClass.MainWindow);
                    foreach (FileInfo xml in xmls)
                    {
                        try
                        {
                    progressDialog.Update(xml.Name);
                    if(!xml.Name.StartsWith("_"))
                        getObject(xml.FullName);
                        }
                        catch(Exception ex) {
                            Console.WriteLine(ex.Message);
                            Console.WriteLine(ex.StackTrace);
                            return;
                        }
                    }
            progressDialog.Destroy();

            md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Done", "", Gtk.MessageType.Info);
            md.ShowDialog();*/
        }
Esempio n. 6
0
        public static void CreateFile(string newFile, string content)
        {
            string dir = System.IO.Path.GetDirectoryName(newFile);
            string nameExtens = System.IO.Path.GetExtension(newFile);
            string nameClear = System.IO.Path.GetFileNameWithoutExtension(newFile);

            if (System.IO.File.Exists(newFile))
                newFile = System.IO.Path.Combine(dir,  nameClear+"_1"+nameExtens);

            string ext = System.IO.Path.GetExtension(newFile);
            if (ext == ".db"){
                using (FileStream fs = System.IO.File.Create(newFile))
                fs.Close();
                SqlLiteDal sqlld = new SqlLiteDal(newFile);
                //Console.WriteLine(content);
                sqlld.RunSqlScalar(content);

            } else {
                using (StreamWriter file = new StreamWriter(newFile)) {
                    file.Write(content);
                    file.Close();
                    file.Dispose();
                }
            }
        }
Esempio n. 7
0
        public void GetCompletedData()
        {
            ListDataKeywords=new List<CompletionData>();
            ListDataTypes =new List<CompletionData>();
            ListDataMembers =new List<CompletionData>();
            ListDataProperties =new List<CompletionData>();
            ListDataEvents =new List<CompletionData>();

            AllCompletionRepeat=new CompletionDataList();
            AllCompletionOnlyOne =new CompletionDataList();
            NewCompletion =new CompletionDataList();
            DotCompletion =new CompletionDataList();

            if(!System.IO.File.Exists(FilePath)){
                Tool.Logger.Error("CodeCompletion file not exist!",null);
                return;
            }

            SqlLiteDal sqlLiteDal = new SqlLiteDal(FilePath);

            SqliteConnection dbcon =  (SqliteConnection)sqlLiteDal.GetConnect();//GetConnect();
            if (dbcon == null){
                return;
            }

            SqliteCommand dbcmd = dbcon.CreateCommand();

            string sql = "SELECT *  FROM completed;";
            dbcmd.CommandText = sql;
            SqliteDataReader reader = null;
            try {
                reader = dbcmd.ExecuteReader();

                int numberCollumns = reader.FieldCount;

                if (numberCollumns <5)return;

                while (reader.Read()) {

                    CompletionData cd;
                    string name = reader.GetValue(1).ToString();
                    string signature= reader.GetValue(2).ToString();
                    int type=  reader.GetInt32(3);
                    string parent= reader.GetValue(4).ToString();
                    string summary = "";
                    string returnType = "";
                    if(numberCollumns >=6)
                        summary= reader.GetValue(5).ToString();

                    if(numberCollumns >=7)
                        returnType= reader.GetValue(6).ToString();

                    cd = new CompletionData(name,null,signature,name,1,parent,returnType);

                    cd.Signature =signature;

                    if(!string.IsNullOrEmpty(summary)){
                        cd.Description = cd.Description + Environment.NewLine+ summary;//+Environment.NewLine;
                    }

                    if(type == (int)CompletionDataTyp.keywords){
                        ListDataKeywords.Add(cd);
                    } else if(type == (int)CompletionDataTyp.members){
                        ListDataMembers.Add(cd);
                    } else if(type == (int)CompletionDataTyp.types){
                        ListDataTypes.Add(cd);
                    } else if(type == (int)CompletionDataTyp.properties){
                        ListDataProperties.Add(cd);
                    } else if(type == (int)CompletionDataTyp.events){
                        ListDataEvents.Add(cd);
                    }
                }

            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Tool.Logger.Error("ERROR LOADING COMPLETED CACHE");
                Tool.Logger.Error(ex.Message);

                //MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error);
                //ms.ShowDialog();

            } finally {

                if (reader != null) reader.Close();
                reader = null;
                dbcmd.Dispose();
                dbcmd = null;
                dbcon.Close();
                dbcon = null;
            }
            AllCompletionRepeat=GetCompletionData(CompletionTyp.allType,false );
            AllCompletionOnlyOne =GetCompletionData(CompletionTyp.allType,true );
            NewCompletion =GetCompletionData(CompletionTyp.newType,true );
            DotCompletion =GetCompletionData(CompletionTyp.dotType,true );
            IncludeCompletion =GetCompletionData(CompletionTyp.includeType,true );
        }