Ejemplo n.º 1
0
        public override IAddonInstance LoadAddon(XmlElement xml)
        {
            var res = new TablePerspective();

            res.LoadFromXml(xml);
            return(res);
        }
        public static DialogResult Run(TablePerspective per, ITableStructure table, IDatabaseSource db)
        {
            var win = new TablePerspectiveEditorForm(per, table, db);

            win.ShowDialogEx();
            return(win.DialogResult);
        }
Ejemplo n.º 3
0
        public void LoadParts(TablePerspective per, bool select, bool conditions, bool dockpanel)
        {
            var doc = XmlTool.CreateDocument("Perspective");

            per.SaveToXml(doc.DocumentElement);
            LoadParts(doc.DocumentElement, select, conditions, dockpanel);
        }
Ejemplo n.º 4
0
        public override object GetEditObject(object item)
        {
            string fn  = Path.Combine(TablePerspectiveAddonType.Instance.GetDirectory(), item.ToString() + ".per");
            var    per = new TablePerspective();

            per.LoadFromFile(fn);
            return(per.Conditions);
        }
Ejemplo n.º 5
0
 private TableDataState GetState(TablePerspective per)
 {
     if (per == null)
     {
         return(DefaultState);
     }
     return(States.Get(per, null));
 }
Ejemplo n.º 6
0
        internal void UseFixedPerspective(string perfile)
        {
            var per = new TablePerspective();

            per.LoadFromFile(perfile);
            per.FileName = perfile;
            SelectPerspective(per);
            IsFixedPerspective = true;
        }
Ejemplo n.º 7
0
        public override void SaveItem(object item, object editem)
        {
            string fn  = Path.Combine(TablePerspectiveAddonType.Instance.GetDirectory(), item.ToString() + ".per");
            var    per = new TablePerspective();

            per.LoadFromFile(fn);
            per.Conditions = (TablePerspectiveConditions)editem;
            per.SaveToFile(fn);
        }
Ejemplo n.º 8
0
        private void WantAdapter(TablePerspective per)
        {
            if (m_adapters.ContainsKey(per ?? nullPer))
            {
                return;
            }

            m_adapters[per ?? nullPer] = new BedAdapter(m_conn, GetQueryTemplate(per, QueryType.Select), m_isFullTableSelect);
            m_writable = !m_adapters[per ?? nullPer].IsReadOnly;
        }
Ejemplo n.º 9
0
        public PerspectiveInstanceTreeNode(ITreeNode parent, ITableSource conn, TablePerspective per)
            : base(conn, parent, System.IO.Path.GetFileName(per.FileName))
        {
            m_per  = per;
            m_conn = conn;
            var appobj = new PerspectiveInstanceAppObject();

            appobj.FillFromTable(conn);
            appobj.FileName = per.FileName;
            SetAppObject(appobj);
        }
Ejemplo n.º 10
0
        //private string GetPerKey(TablePerspective per)
        //{
        //    if (per == null) return "";
        //    return per.UniqueKey();
        //}

        public ITableStructure GetStructure(TablePerspective per)
        {
            //string perkey = GetPerKey(per);
            m_conn.ReconnectIfBroken();
            if (m_conn.Dialect.DialectCaps.MultipleDatabase)
            {
                m_conn.SystemConnection.SafeChangeDatabase(m_dbname);
            }

            WantAdapter(per);
            return(m_adapters[per ?? nullPer].GetStructure());
        }
        public void Init(TablePerspective per, ITableStructure table, IDatabaseSource db)
        {
            per.Select.Columns.NormalizeBaseTables();

            cbxReferencedTable.Items.Clear();
            m_per   = per;
            m_db    = db;
            m_table = table;
            foreach (var tbl in AllTables)
            {
                cbxReferencedTable.Items.Add(tbl);
            }
            m_filter = per.Conditions.CloneUsingXml();
            objectFilterFrame1.Filter = m_filter;
            //tbxDatabase.Text = m_per.Conditions.Database;
            //chbDatabase.Checked = m_per.Conditions.DatabaseChecked;
            //chbDatabaseRegex.Checked = m_per.Conditions.SchemaRegex;

            //tbxServer.Text = m_per.Conditions.Server;
            //chbServer.Checked = m_per.Conditions.ServerChecked;
            //chbServerRegex.Checked = m_per.Conditions.ServerRegex;

            //tbxSchema.Text = m_per.Conditions.Schema;
            //chbSchema.Checked = m_per.Conditions.SchemaChecked;
            //chbSchemaRegex.Checked = m_per.Conditions.SchemaRegex;

            //tbxTable.Text = m_per.Conditions.Table;
            //chbTable.Checked = m_per.Conditions.TableChecked;
            //chbTableRegex.Checked = m_per.Conditions.TableRegex;

            //chbColumns.Checked = m_per.Conditions.ColumnsChecked;
            //tbxColumns.Text = "";
            //if (m_per.Conditions.Columns != null)
            //{
            //    tbxColumns.Text = m_per.Conditions.Columns.CreateDelimitedText("\r\n");
            //}

            foreach (var rel in m_per.Select.From.Relations)
            {
                AddRelation(rel);
            }

            FillAvailableColSources();

            var cd = m_per.Select.GetColumnDisplay();

            foreach (var col in cd)
            {
                dataGridViewColumns.Rows.Add(col.ValueRef.Alias ?? "", col.ValueRef.SafeToString(), col.LookupRef.SafeToString());
            }
            LoadCurrentRelation();
        }
Ejemplo n.º 12
0
        internal void ModifyDataStatePer(TablePerspective per, Action <TableDataState> action)
        {
            var state = GetState(per);

            if (state != null)
            {
                action(state);
            }
            else
            {
                if (!m_missingActions.ContainsKey(per))
                {
                    m_missingActions[per] = new List <Action <TableDataState> >();
                }
                m_missingActions[per].Add(action);
            }
        }
Ejemplo n.º 13
0
 public static void WantCache()
 {
     if (m_cache == null)
     {
         m_cache = new List <TablePerspective>();
         foreach (string fn in Directory.GetFiles(Core.TablePerspectivesDirectory))
         {
             try
             {
                 var per = TablePerspective.FromFile(fn);
                 m_cache.Add(per);
             }
             catch
             {
                 continue;
             }
         }
     }
 }
Ejemplo n.º 14
0
 internal void SelectPerspective(TablePerspective per)
 {
     if (per != null && !States.ContainsKey(per))
     {
         var state = new TableDataState();
         state.DataStatePer = this;
         state.Perspective  = per;
         States[per]        = state;
     }
     Perspective = per;
     if (per != null && m_missingActions.ContainsKey(per))
     {
         foreach (var act in m_missingActions[per])
         {
             act(States[per]);
         }
         m_missingActions[per].Clear();
     }
 }
Ejemplo n.º 15
0
        private string GetQueryTemplate(TablePerspective per, QueryType type)
        {
            if (per == null)
            {
                return(type == QueryType.SelectCount ? m_countQuery : m_query);
            }
            var sw      = new StringWriter();
            var dmp     = (Dialect ?? GenericDialect.Instance).CreateDumper(sw);
            var handler = new DmlfHandler {
                BaseTable = new DmlfSource {
                    Alias = "basetbl", TableOrView = m_tableSource.FullName
                }
            };

            if (type == QueryType.SelectCount)
            {
                per.Select.GenSqlCount(dmp, handler);
            }
            else if (type == QueryType.SelectVisible)
            {
                DmlfResultFieldCollection vis, hid, old;
                per.Select.Columns.SplitVisible(out vis, out hid);
                old = per.Select.Columns;
                try
                {
                    per.Select.Columns = vis;
                    per.Select.GenSql(dmp, handler);
                }
                finally
                {
                    per.Select.Columns = old;
                }
            }
            else
            {
                per.Select.GenSql(dmp, handler);
            }
            return(sw.ToString());
        }
 public TablePerspectiveEditorFrame(TablePerspective per, ITableStructure table, IDatabaseSource db)
 {
     InitializeComponent();
     Init(per, table, db);
 }
Ejemplo n.º 17
0
 public ITableStructure GetStructure(TablePerspective per)
 {
     return(m_table.Columns.GetTableStructure("table"));
 }
Ejemplo n.º 18
0
 public void NotifyPerspectiveChanged(TablePerspective per)
 {
 }
Ejemplo n.º 19
0
 public void NotifyPerspectiveChanged(TablePerspective per)
 {
     m_adapters.Remove(per);
 }
Ejemplo n.º 20
0
 public ITableStructure GetStructure(TablePerspective per)
 {
     return(m_table.Structure);
 }