Esempio n. 1
0
        private void RunQuery(string query)
        {
            if (query == "")
                query = GetQuery();
            if (query == "")
            {
                MessageBox.Show("You must enter a query first!");
                return;
            }

            Cursor cacheCursor = this.Cursor ;

            //			try
            //			{
                this.Cursor = Cursors.WaitCursor ;
                Application.DoEvents() ;

                IList filter = null;
                if (queryResultMenuItem.Checked)
                {
                    filter = GetListViewObjects();
                }

                objectsListView.Clear() ;
                objectsListView.Columns.Clear() ;
                objectsListView.Items.Clear() ;

                NPathQuery npath = new NPathQuery(query) ;
                IClassMap classMap = Context.NPathEngine.GetRootClassMap(query, Context.DomainMap);
                Type type = Context.AssemblyManager.MustGetTypeFromClassMap(classMap);

                npath.Context = Context;
                npath.PrimaryType = type;

                NPathQueryType npathQueryType = Context.NPathEngine.GetNPathQueryType(query);

                if (npathQueryType == NPathQueryType.SelectObjects)
                {
                    IList result = null;
                    if (queryDataSourceMenuItem.Checked)
                    {
                        result = Context.GetObjects(npath, type);
                    }
                    else if (queryFilterMenuItem.Checked)
                    {
                        result = Context.FilterObjects(npath);
                    }
                    else
                    {
                        result = Context.FilterObjects(filter, npath);
                    }

                    ObjectListViewItem.SetupColumns(Context, type, objectsListView);

                    objectsListView.BeginUpdate() ;
                    foreach (object obj in result)
                    {
                        ListViewItem listViewItem = new ObjectListViewItem(Context, obj, type) ;
                        objectsListView.Items.Add(listViewItem );
                    }
                    objectsListView.EndUpdate() ;
                }

                if (npathQueryType == NPathQueryType.SelectScalar)
                {
                    MessageBox.Show("Only queries that returned objects are allowed in the Object Explorer! For scalar queries, please use the Query Analyzer instead.");
                }

                if (npathQueryType == NPathQueryType.SelectTable )
                {
                    MessageBox.Show("Only queries that returned objects are allowed in the Object Explorer! For tabular queries, please use the Query Analyzer instead.");
                }
            //			}
            //			catch (CompositeException compEx)
            //			{
            //				ListAllSystemExceptions(compEx.InnerExceptions);
            //				MessageBox.Show("Exceptions were encountered while executing the query! Please inspect the list of errors for more information!");
            //			}
            //			catch (Exception ex)
            //			{
            //				IList exceptions = new ArrayList();
            //				exceptions.Add(ex);
            //				ListAllSystemExceptions(exceptions);
            //				MessageBox.Show("An exception was encountered while executing the query! Please inspect the list of errors for more information!");
            //			}

            this.Cursor = cacheCursor ;
        }
Esempio n. 2
0
 private void AddObjectToListView(object dropObject, Type type, ListView listView)
 {
     ListViewItem listViewItem = new ObjectListViewItem(Context, dropObject, type, true) ;
     listView.Items.Add(listViewItem );
 }
Esempio n. 3
0
        private void InsertObjectIntoListView(object dropObject, Type type, ListView listView)
        {
            listView.Clear() ;
            ObjectListViewItem.SetupColumns(Context, dropObject.GetType(), listView );

            ListViewItem listViewItem = new ObjectListViewItem(Context, dropObject, type) ;
            listView.Items.Add(listViewItem );
        }