Exemplo n.º 1
0
        void OnHitsAdded(QueryResult qres, ICollection hits)
        {
            if (result.Contains(qres))
            {
                Resp resp = ((Resp)result[qres]);
                BT.SimpleRootTile root     = resp.resultPair.rootTile;
                ArrayList         hitsCopy = resp.resultPair.hitsCopy;

                lock (root)  {
                    if (resp.isLocalReq)
                    {
                        root.Add(hits);
                        lock (hitsCopy.SyncRoot)
                            hitsCopy.AddRange(hits);
                    }
                    else
                    {
                        foreach (Hit h in hits)
                        {
                            if (h.UriAsString.StartsWith(NetworkedBeagle.BeagleNetPrefix) ||
                                WebServiceBackEnd.AccessFilter.FilterHit(h))
                            {
                                root.Add(h);
                                lock (hitsCopy.SyncRoot)
                                    hitsCopy.Add(h);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 void OnHitsSubtracted(QueryResult qres, ICollection uris)
 {
     if (result.Contains(qres))
     {
         BT.SimpleRootTile root = ((Resp)result[qres]).resultPair.rootTile;
         lock (root) {
             root.Subtract(uris);
             removeUris(((Resp)result[qres]).resultPair.hitsCopy, uris);
         }
     }
 }
Exemplo n.º 3
0
        public bool canBack(string sessId)
        {
            Resp resp = (Resp)sessionResp[sessId];

            if (resp == null)
            {
                return(false);
            }

            BT.SimpleRootTile root = resp.resultPair.rootTile;
            return((root != null) ? root.HitCollection.CanPageBack:false);
        }
Exemplo n.º 4
0
        private string getResultsLabel(BT.SimpleRootTile root)
        {
            string label;

            if (root.HitCollection.NumResults == 0)
            {
                label = NO_RESULTS;
            }
            else if (root.HitCollection.FirstDisplayed == 0)
            {
                label = String.Format("<b>{0} results of {1}</b> are shown.",
                                      root.HitCollection.LastDisplayed + 1,
                                      root.HitCollection.NumResults);
            }
            else
            {
                label = String.Format("Results <b>{0} through {1} of {2}</b> are shown.",
                                      root.HitCollection.FirstDisplayed + 1,
                                      root.HitCollection.LastDisplayed + 1,
                                      root.HitCollection.NumResults);
            }
            return(label);
        }
Exemplo n.º 5
0
        public string doBack(string sessId)
        {
            Resp resp = (Resp)sessionResp[sessId];

            if (!canBack(sessId) || (resp == null))
            {
                return(NO_RESULTS);
            }

            BT.SimpleRootTile root = resp.resultPair.rootTile;
            if (root != null)
            {
                lock (root) {
                    root.HitCollection.PageBack();

                    bufferRenderContext bctx = resp.bufferContext;
                    bctx.init();
                    root.Render(bctx);
                    return(getResultsLabel(root) + (resp.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery));
                }
            }

            return(NO_RESULTS);
        }
Exemplo n.º 6
0
		public ResultPair(BT.SimpleRootTile rootTile) {
			this._rootTile = rootTile;
			_hitsCopy = ArrayList.Synchronized(new ArrayList());
		}
Exemplo n.º 7
0
		public string doQuery(webArgs wargs)
		{				 
			if (wargs.sessId == null || wargs.searchString == null || wargs.searchString == "")
				return NO_RESULTS;
						 
			log.Debug("WebBackEnd: Got Search String: " + wargs.searchString); 
			
			Query query = new Query();
			query.AddText (wargs.searchString);
			if (wargs.searchSource != null && wargs.searchSource != "")
			{
				query.AddSource(wargs.searchSource);
				query.AddDomain(QueryDomain.System);
			}
			else	
				query.AddDomain (wargs.globalSearch ? QueryDomain.Global:QueryDomain.System);

			QueryResult qres = new QueryResult ();
									
			//Note: QueryDriver.DoQuery() local invocation is used. 
			//The root tile is used only for adding hits and generating html.
			BT.SimpleRootTile root = new BT.SimpleRootTile (); 							
			root.Query = query;
			//root.SetSource (searchSource); Do not SetSource on root! 
											
			ResultPair rp = new ResultPair(root);
			bufferRenderContext bctx = new bufferRenderContext(rp);
			Resp resp = new Resp(rp, bctx, wargs.isLocalReq);

			AttachQueryResult (qres, resp);

			//Add sessionId-Resp mapping
			if (sessionResp.Contains(wargs.sessId)) 
				sessionResp[wargs.sessId] = resp;
			else
				sessionResp.Add(wargs.sessId, resp);	

			log.Info("WebBackEnd: Starting Query for string \"{0}\"", wargs.searchString);

			QueryDriver.DoQueryLocal (query, qres);

			//Wait only till we have enough results to display
			while ((result.Contains(qres)) && 
					(root.HitCollection.NumResults < 10)) 
				Thread.Sleep(100);
				
			if (root.HitCollection.IsEmpty)
				return NO_RESULTS;
						
			lock (root) {			
				root.Render(bctx);				
				return (getResultsLabel(root) + (wargs.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery));
			}			
		}
Exemplo n.º 8
0
		private void CreateWindow (string query)
		{
			Title = Best.DefaultWindowTitle;

			DeleteEvent += new DeleteEventHandler (this.DoDelete);
			MapEvent += new MapEventHandler (MapIt);
			UnmapEvent += new UnmapEventHandler (UnmapIt);

			Icon = Images.GetPixbuf ("best.png");

			Widget content = CreateContents ();

			VBox main = new VBox (false, 3);
			main.PackStart (content, true, true, 3);
			content.Show ();
			Add (main);
			main.Show ();
			main.Realize ();
			canvas.Realize ();

			root = new SimpleRootTile ();
			canvas.Root = root;

			DefaultWidth = 600;
			DefaultHeight = 675;

			accel_group = new Gtk.AccelGroup ();
			this.AddAccelGroup (accel_group);
			global_keys = new GlobalKeybinder (accel_group);

			// Close window (Ctrl-W)
			global_keys.AddAccelerator (new EventHandler (this.HideWindowHandler),
						    (uint) Gdk.Key.w, 
						    Gdk.ModifierType.ControlMask,
						    Gtk.AccelFlags.Visible);

			// Close window (Escape)
			global_keys.AddAccelerator (new EventHandler (this.HideWindowHandler),
						    (uint) Gdk.Key.Escape, 
						    0,
						    Gtk.AccelFlags.Visible);

			// Show source (Ctrl+U)
			global_keys.AddAccelerator (new EventHandler (this.ShowSource),
						    (uint) Gdk.Key.U, 
						    Gdk.ModifierType.ControlMask,
						    Gtk.AccelFlags.Visible);

			// Focus Entry (Ctrl+L)
			global_keys.AddAccelerator (new EventHandler (this.FocusEntryHandler),
						    (uint) Gdk.Key.L, 
						    Gdk.ModifierType.ControlMask,
						    Gtk.AccelFlags.Visible);

			// Previous Page (PageUp)
			global_keys.AddAccelerator (new EventHandler (this.PageBackHandler),
						    (uint) Gdk.Key.Page_Up, 
						    0,
						    Gtk.AccelFlags.Visible);

			// Next Page (PageDown)
			global_keys.AddAccelerator (new EventHandler (this.PageForwardHandler),
						    (uint) Gdk.Key.Page_Down, 
						    0,
						    Gtk.AccelFlags.Visible);

			UpdateFromConf ();
			UpdatePage ();

			if (query != null)
				Search (query);
			
		}
Exemplo n.º 9
0
 public ResultPair(BT.SimpleRootTile rootTile)
 {
     this._rootTile = rootTile;
     _hitsCopy      = ArrayList.Synchronized(new ArrayList());
 }
Exemplo n.º 10
0
        public string doQuery(webArgs wargs)
        {
            if (wargs.sessId == null || wargs.searchString == null || wargs.searchString == "")
            {
                return(NO_RESULTS);
            }

            log.Debug("WebBackEnd: Got Search String: " + wargs.searchString);

            Query query = new Query();

            query.AddText(wargs.searchString);
            if (wargs.searchSource != null && wargs.searchSource != "")
            {
                query.AddSource(wargs.searchSource);
                query.AddDomain(QueryDomain.System);
            }
            else
            {
                query.AddDomain(wargs.globalSearch ? QueryDomain.Global:QueryDomain.System);
            }

            QueryResult qres = new QueryResult();

            //Note: QueryDriver.DoQuery() local invocation is used.
            //The root tile is used only for adding hits and generating html.
            BT.SimpleRootTile root = new BT.SimpleRootTile();
            root.Query = query;
            //root.SetSource (searchSource); Do not SetSource on root!

            ResultPair          rp   = new ResultPair(root);
            bufferRenderContext bctx = new bufferRenderContext(rp);
            Resp resp = new Resp(rp, bctx, wargs.isLocalReq);

            AttachQueryResult(qres, resp);

            //Add sessionId-Resp mapping
            if (sessionResp.Contains(wargs.sessId))
            {
                sessionResp[wargs.sessId] = resp;
            }
            else
            {
                sessionResp.Add(wargs.sessId, resp);
            }

            log.Info("WebBackEnd: Starting Query for string \"{0}\"", wargs.searchString);

            QueryDriver.DoQueryLocal(query, qres);

            //Wait only till we have enough results to display
            while ((result.Contains(qres)) &&
                   (root.HitCollection.NumResults < 10))
            {
                Thread.Sleep(100);
            }

            if (root.HitCollection.IsEmpty)
            {
                return(NO_RESULTS);
            }

            lock (root) {
                root.Render(bctx);
                return(getResultsLabel(root) + (wargs.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery));
            }
        }