Index: TXM/trunk/org.txm.analec.rcp/src/org/txm/macro/urs/exploit/CQPUtils.groovy
===================================================================
--- TXM/trunk/org.txm.analec.rcp/src/org/txm/macro/urs/exploit/CQPUtils.groovy	(revision 3320)
+++ TXM/trunk/org.txm.analec.rcp/src/org/txm/macro/urs/exploit/CQPUtils.groovy	(revision 3321)
@@ -2,15 +2,14 @@
 // Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
 // @author sheiden
 
-package org.txm.macro.urs.exploit
+package org.txm.macro.cqp
 
 import org.txm.searchengine.cqp.corpus.*
-import org.txm.rcp.views.corpora.*
 
 def getCorpusByName(name) {
-	def cl = CorpusManager.getCorpusManager().getCorpora().values()
+	def cl = CorpusManager.getCorpusManager().getCorpora()
 	def rc = cl.find {
-		it.getID() == name
+		it.getName() == name
 	}
 	
 	if (rc) return rc
@@ -19,7 +18,7 @@
 	rc = cl.find { c ->
 		def scl = c.getSubcorpora()
 		def rrsc = scl.find { sc ->
-			sc.getID() == name
+			sc.getName() == name
 		}
 		rsc = rrsc
 	}
@@ -27,15 +26,6 @@
 	return rsc
 }
 
-def refreshCorpusViewExpand(monitor, corpus) {
-	monitor.syncExec(new Runnable() {
-		public void run() {
-			CorporaView.refresh()
-			CorporaView.expand(corpus)
-		}
-	})
-}
-
 def getCorpora(def script) {
 
 	def scriptName = this.class.getSimpleName()
@@ -160,6 +150,41 @@
 	
 }
 
+def positionsList2positions(positionsList, maxMatches, pretty) {
+	
+	def res = ""
+
+	if (positionsList.size() == 0) {
+		return "<empty>"
+	} else {
+		def first = 1
+		positionsList.take(maxMatches).each {
+			if (first) { first = 0 } else {
+				if (pretty) {
+					res += ", "
+				} else {
+					res += ","
+				}
+			}
+			// res += "["
+			start = it[0]
+			end = it[1]
+			if (start < end) {
+				res += start+"-"+end
+			} else {
+				res += start
+			}
+			// res += "]"
+		}
+	}
+
+	if (positionsList.size() > maxMatches) {
+		res += "..."
+	}
+	
+	return res
+}
+
 def corpus2positions(def corpus, def maxMatches, def pretty = false) {
 	
 	def res = ""
@@ -199,17 +224,17 @@
 println "** CQPUtils is not meant to be called directly.\nPlease import its methods ${methods}\nwith the following declaration:\nimport org.txm.macro.cqp.CQPUtilsMacro"
 
 /*
-      ___           ___           ___           ___           ___           ___     
-     /\  \         /\__\         /\__\         /\  \         |\__\         /\  \    
-    /::\  \       /::|  |       /::|  |       /::\  \        |:|  |       /::\  \   
-   /:/\:\  \     /:|:|  |      /:|:|  |      /:/\:\  \       |:|  |      /:/\:\  \  
-  /::\~\:\  \   /:/|:|  |__   /:/|:|  |__   /::\~\:\  \      |:|__|__   /::\~\:\  \ 
+	  ___           ___           ___           ___           ___           ___
+	 /\  \         /\__\         /\__\         /\  \         |\__\         /\  \
+	/::\  \       /::|  |       /::|  |       /::\  \        |:|  |       /::\  \
+   /:/\:\  \     /:|:|  |      /:|:|  |      /:/\:\  \       |:|  |      /:/\:\  \
+  /::\~\:\  \   /:/|:|  |__   /:/|:|  |__   /::\~\:\  \      |:|__|__   /::\~\:\  \
  /:/\:\ \:\__\ /:/ |:| /\__\ /:/ |:| /\__\ /:/\:\ \:\__\ ____/::::\__\ /:/\:\ \:\__\
  \/__\:\/:/  / \/__|:|/:/  / \/__|:|/:/  / \:\~\:\ \/__/ \::::/~~/~    \:\~\:\ \/__/
-      \::/  /      |:/:/  /      |:/:/  /   \:\ \:\__\    ~~|:|~~|      \:\ \:\__\  
-      /:/  /       |::/  /       |::/  /     \:\ \/__/      |:|  |       \:\ \/__/  
-     /:/  /        /:/  /        /:/  /       \:\__\        |:|  |        \:\__\    
-     \/__/         \/__/         \/__/         \/__/         \|__|         \/__/    
+	  \::/  /      |:/:/  /      |:/:/  /   \:\ \:\__\    ~~|:|~~|      \:\ \:\__\
+	  /:/  /       |::/  /       |::/  /     \:\ \/__/      |:|  |       \:\ \/__/
+	 /:/  /        /:/  /        /:/  /       \:\__\        |:|  |        \:\__\
+	 \/__/         \/__/         \/__/         \/__/         \|__|         \/__/
 
 
 
@@ -245,117 +270,117 @@
 import java.util.*;
 
 public class Ideone
-{   
-    public static void main (String[] args) throws java.lang.Exception
-    {
-        ArrayList<Interval> x = new ArrayList<>();
+{
+	public static void main (String[] args) throws java.lang.Exception
+	{
+		ArrayList<Interval> x = new ArrayList<>();
 
-        x.add(new Interval(1, 3));
-        x.add(new Interval(2, 6));
-        x.add(new Interval(8, 10));
-        x.add(new Interval(15, 18));
-        x.add(new Interval(17, 20));
+		x.add(new Interval(1, 3));
+		x.add(new Interval(2, 6));
+		x.add(new Interval(8, 10));
+		x.add(new Interval(15, 18));
+		x.add(new Interval(17, 20));
 
-        x = merge(x);
+		x = merge(x);
 
-        for(Interval i : x)
-        {
-            System.out.println(i.getStart() + " " + i.getEnd());
-        }
-    }
+		for(Interval i : x)
+		{
+			System.out.println(i.getStart() + " " + i.getEnd());
+		}
+	}
 
-    public static ArrayList<Interval> merge(ArrayList<Interval> intervals) {
+	public static ArrayList<Interval> merge(ArrayList<Interval> intervals) {
 
-        if(intervals.size() == 0 || intervals.size() == 1)
-            return intervals;
+		if(intervals.size() == 0 || intervals.size() == 1)
+			return intervals;
 
-        Collections.sort(intervals, new IntervalComparator());
+		Collections.sort(intervals, new IntervalComparator());
 
-        Interval first = intervals.get(0);
-        int start = first.getStart();
-        int end = first.getEnd();
+		Interval first = intervals.get(0);
+		int start = first.getStart();
+		int end = first.getEnd();
 
-        ArrayList<Interval> result = new ArrayList<Interval>();
+		ArrayList<Interval> result = new ArrayList<Interval>();
 
-        for (int i = 1; i < intervals.size(); i++) {
-            Interval current = intervals.get(i);
-            if (current.getStart() <= end) {
-                end = Math.max(current.getEnd(), end);
-            } else {
-                result.add(new Interval(start, end));
-                start = current.getStart();
-                end = current.getEnd();
-            }
-        }
+		for (int i = 1; i < intervals.size(); i++) {
+			Interval current = intervals.get(i);
+			if (current.getStart() <= end) {
+				end = Math.max(current.getEnd(), end);
+			} else {
+				result.add(new Interval(start, end));
+				start = current.getStart();
+				end = current.getEnd();
+			}
+		}
 
-        result.add(new Interval(start, end));
-        return result;
-    }
+		result.add(new Interval(start, end));
+		return result;
+	}
 }
 
-class Interval 
+class Interval
 {
-    private int start;
-    private int end;
+	private int start;
+	private int end;
 
-    Interval() {
-        start = 0;
-        end = 0;
-    }
+	Interval() {
+		start = 0;
+		end = 0;
+	}
 
-    Interval(int s, int e) 
-    {
-        start = s;
-        end = e;
-    }
+	Interval(int s, int e)
+	{
+		start = s;
+		end = e;
+	}
 
-    public int getStart() {
-        return start;
-    }
+	public int getStart() {
+		return start;
+	}
 
-    public int getEnd() {
-        return end;
-    }
+	public int getEnd() {
+		return end;
+	}
 }
 
 class IntervalComparator implements Comparator<Interval>
 {
-    public int compare(Interval i1, Interval i2)
-    {
-        return i1.getStart() - i2.getStart();
-    }
+	public int compare(Interval i1, Interval i2)
+	{
+		return i1.getStart() - i2.getStart();
+	}
 }
 
 B) from http://www.programcreek.com/2012/12/leetcode-merge-intervals/
 
 public List<Interval> merge(List<Interval> intervals) {
-    List<Interval> result = new ArrayList<Interval>();
+	List<Interval> result = new ArrayList<Interval>();
  
-    if(intervals==null||intervals.size()==0)
-        return result;
+	if(intervals==null||intervals.size()==0)
+		return result;
  
-    Collections.sort(intervals, new Comparator<Interval>(){
-        public int compare(Interval i1, Interval i2){
-            if(i1.start!=i2.start)
-                return i1.start-i2.start;
-            else
-                return i1.end-i2.end;
-        }
-    });
+	Collections.sort(intervals, new Comparator<Interval>(){
+		public int compare(Interval i1, Interval i2){
+			if(i1.start!=i2.start)
+				return i1.start-i2.start;
+			else
+				return i1.end-i2.end;
+		}
+	});
  
-    Interval pre = intervals.get(0);
-    for(int i=0; i<intervals.size(); i++){
-        Interval curr = intervals.get(i);
-        if(curr.start>pre.end){
-            result.add(pre);
-            pre = curr;
-        }else{
-            Interval merged = new Interval(pre.start, Math.max(pre.end, curr.end));
-            pre = merged;
-        }
-    }
-    result.add(pre);
+	Interval pre = intervals.get(0);
+	for(int i=0; i<intervals.size(); i++){
+		Interval curr = intervals.get(i);
+		if(curr.start>pre.end){
+			result.add(pre);
+			pre = curr;
+		}else{
+			Interval merged = new Interval(pre.start, Math.max(pre.end, curr.end));
+			pre = merged;
+		}
+	}
+	result.add(pre);
  
-    return result;
+	return result;
 }
- */
+ */
\ No newline at end of file
