Ejemplo n.º 1
0
        protected override void ShowOpen()
        {
            GUIStyle headStyle = GUIHelper.MakeHeader();

            GUILayout.Label("Input SQL", headStyle);
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Url:", GUILayout.Width(100));
            url = GUILayout.TextField(url, GUILayout.Width(250));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Id:", GUILayout.Width(100));
            id = GUILayout.TextField(id, GUILayout.Width(250));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("PassWord:"******"Databse:", GUILayout.Width(100));
            //database = GUILayout.TextField(database, GUILayout.Width(250));
            //GUILayout.EndHorizontal();

            if (GUILayout.Button("Connect", GUILayout.Width(150)))
            {
                try
                {
                    reader = new SQLReader(string.Empty, string.Empty, id, pwd, url, port);
                }
                catch (Exception e)
                {
                    reader = null;
                    Debug.LogException(e);
                }
            }

            if (reader != null)
            {
                string[] databaseNames = MySQLManager.GetAllDatabaseName().GetColume(0).ToArray();
                EditorGUILayout.LabelField("Database: ", GUILayout.Width(100));
                currentDatabaseIndex = EditorGUILayout.Popup(currentDatabaseIndex, databaseNames, GUILayout.Width(100));
                if (databaseNames != null)
                {
                    currentDatabseName = databaseNames[currentDatabaseIndex];
                    reader             = new SQLReader(currentDatabseName, "", id, pwd, url, port);
                    //databaseNames = MySQLManager.GetAllDatabaseName().GetColume(0).ToArray();
                }

                string[] tableNames = MySQLManager.GetAllTableName().GetColume(0).ToArray();
                EditorGUILayout.LabelField("Worksheet: ", GUILayout.Width(100));
                currentSheetIndex = EditorGUILayout.Popup(currentSheetIndex, tableNames, GUILayout.Width(100));
                if (tableNames != null)
                {
                    currentSheetName = tableNames[currentSheetIndex];
                    reader           = new SQLReader((reader as SQLReader).database, currentSheetName, id, pwd, url, port);
                    //tableNames = reader.GetSheetNames();
                }

                EditorGUILayout.LabelField("DataType: ", GUILayout.Width(100));
                currentExcelType = (DataType)EditorGUILayout.EnumPopup(currentExcelType, GUILayout.Width(100));
            }
        }