Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultipleValueDialog.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultipleValueDialog.java	(revision 3753)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultipleValueDialog.java	(revision 3754)
@@ -33,6 +33,7 @@
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
@@ -91,13 +92,21 @@
 	@Override
 	protected Control createDialogArea(Composite p) {
 		//System.out.println(p.getLayout());
+		Object layout = p.getLayout();
+		if (layout instanceof GridLayout) {
+			GridLayout glayout = (GridLayout)layout;
+			glayout.marginWidth = 5;
+			glayout.marginTop = 5;
+			glayout.verticalSpacing = 5;
+		}
 		
 		for (String name : values.keySet()) {
 			Label label = new Label(p, SWT.NONE);
 			label.setText(name+": "); //$NON-NLS-1$
 			label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false,	false));
+			
 			Text valueText = new Text(p, SWT.BORDER); 
-			valueText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 4, 1)); // 5 ?
+			valueText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); // 5 ?
 			valueText.setText(values.get(name));
 			widgets.put(name, valueText);
 		}
Index: TXM/trunk/bundles/org.txm.searchengine.rcp/src/org/txm/searchengine/rcp/preferences/QueryView.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.rcp/src/org/txm/searchengine/rcp/preferences/QueryView.java	(revision 0)
+++ TXM/trunk/bundles/org.txm.searchengine.rcp/src/org/txm/searchengine/rcp/preferences/QueryView.java	(revision 3754)
@@ -0,0 +1,313 @@
+package org.txm.searchengine.rcp.preferences;
+
+import java.util.LinkedHashMap;
+
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.txm.core.results.TXMResult;
+import org.txm.objects.Workspace;
+import org.txm.rcp.IImageKeys;
+import org.txm.rcp.messages.TXMUIMessages;
+import org.txm.rcp.swt.dialog.MultipleValueDialog;
+import org.txm.rcp.utils.IOClipboard;
+import org.txm.searchengine.core.IQuery;
+import org.txm.searchengine.core.QueryHistory;
+
+public class QueryView extends ViewPart {
+
+	protected TreeViewer tv;
+	protected IQuery copiedQuery;
+
+	@Override
+	public void createPartControl(Composite parent) {
+
+		parent.setLayout(new GridLayout());
+
+		Button go = new Button(parent, SWT.NONE);
+		go.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
+		go.setText("Refresh");
+		go.setToolTipText(TXMUIMessages.common_refresh);
+		go.addSelectionListener(new SelectionAdapter() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				tv.refresh();
+			}
+		});
+		
+		tv = new TreeViewer(parent, SWT.VIRTUAL);
+		tv.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+		tv.setContentProvider(new ITreeContentProvider() {
+
+			@Override
+			public Object[] getElements(Object inputElement) {
+				if (inputElement instanceof TXMResult) {
+					return ((TXMResult) inputElement).getDeepChildren(QueryHistory.class).toArray();
+				} else {
+					return new Object[0];
+				}
+			}
+
+			@Override
+			public Object[] getChildren(Object parentElement) {
+				if (parentElement instanceof QueryHistory) {
+					return ((QueryHistory) parentElement).getQueries().toArray();
+				} else {
+					return new Object[0];
+				}
+			}
+
+			@Override
+			public Object getParent(Object element) {
+				if (element instanceof TXMResult) {
+					return ((TXMResult) element).getParent();
+				} else {
+					return null;
+				}
+			}
+
+			@Override
+			public boolean hasChildren(Object parentElement) {
+				if (parentElement instanceof QueryHistory) {
+					QueryHistory h = ((QueryHistory) parentElement);
+					try {
+						h.compute(false); // silent
+					} catch (InterruptedException e) {
+						e.printStackTrace();
+					}
+					
+					return h.getQueries().size() > 0;
+				} else {
+					return false;
+				}
+			}
+
+		});
+		tv.setUseHashlookup(true);
+		tv.setLabelProvider(new LabelProvider() {
+
+			/*
+			 * (non-Javadoc)
+			 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+			 */
+			@Override
+			public String getText(Object element) {
+				if (element instanceof QueryHistory) {
+					return ((QueryHistory) element).getParent().getName();
+				} else if (element instanceof IQuery) {
+					IQuery q = (IQuery)element;
+					return queryToLabel(q);
+				} else {
+					return ""+element;
+				}
+			}
+
+			@Override
+			public final Image getImage(Object element) {
+				if (element instanceof QueryHistory) {
+					return IImageKeys.getImage(IImageKeys.CORPUS);
+				} else {
+					return null;
+				}
+			}
+		});
+		tv.setInput(Workspace.getInstance());
+
+		tv.getTree().addKeyListener(new KeyListener() {
+
+			@Override
+			public void keyReleased(KeyEvent e) { }
+
+			@Override
+			public void keyPressed(KeyEvent e) {
+				
+				if (e.keyCode == SWT.F5) {
+					QueryView.this.tv.refresh();
+					return;
+				}
+				
+				IStructuredSelection sel = tv.getStructuredSelection();
+				Object o = tv.getStructuredSelection().getFirstElement();
+				
+				if (o instanceof IQuery) {
+					IQuery q = (IQuery)o;
+
+					if (e.keyCode == SWT.DEL) {
+						
+						TreeItem selectedItem = tv.getTree().getSelection()[0];
+						TreeItem parentItem = selectedItem.getParentItem();
+						Object parentObject = parentItem.getData();
+						if (parentObject instanceof QueryHistory) {
+							QueryHistory qh = (QueryHistory)parentObject;
+							System.out.println("Delete query: "+o+" to "+qh.getParent().getName());
+							qh.removeQuery(q);
+							
+							tv.refresh(qh);
+						}
+						
+					} else if (e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) {
+
+//						System.out.println("Edit query: "+o);
+						LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
+						values.put("name", q.getName());
+						values.put("query", q.getQueryString());
+						MultipleValueDialog mvd = new MultipleValueDialog(tv.getTree().getDisplay().getActiveShell(), "Edit Query", values);
+						if (mvd.open() == MultipleValueDialog.OK) {
+							if (!mvd.getValues().get("name").isEmpty()) q.setName(mvd.getValues().get("name"));
+							if (!mvd.getValues().get("query").isEmpty()) q.setQuery(mvd.getValues().get("query"));
+							
+							tv.refresh(q);
+						}
+					}
+					else {
+
+						if ((char) e.keyCode == 'c' & ((e.stateMask & SWT.CTRL) != 0)) {
+							System.out.println("Copied query: "+queryToLabel(q));
+							copiedQuery = q;
+							IOClipboard.write(q.getQueryString());
+						}
+//						else if ((char) e.keyCode == 'v' & ((e.stateMask & SWT.CTRL) != 0)) {
+//							System.out.println("Paste query: "+o);
+//						}
+						
+					}
+				} else if (o instanceof QueryHistory) {
+					if ((char) e.keyCode == 'v' & ((e.stateMask & SWT.CTRL) != 0) && copiedQuery != null) {
+						
+						QueryHistory qh = (QueryHistory)o;
+						System.out.println("Paste query: "+copiedQuery+" to "+qh);
+						qh.addQuery(copiedQuery);
+						tv.refresh(qh);
+					} else if (e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) {
+						
+						QueryHistory qh = (QueryHistory)o;
+						
+						LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
+						values.put("engine", "CQP");
+						values.put("name", "");
+						values.put("query", "");
+						
+						MultipleValueDialog mvd = new MultipleValueDialog(tv.getTree().getDisplay().getActiveShell(), "Edit Query", values);
+						
+						if (mvd.open() == MultipleValueDialog.OK) {
+							if (!mvd.getValues().get("query").isEmpty() && !mvd.getValues().get("engine").isEmpty()) {
+								
+								IQuery newQuery = IQuery.fromPrefString(mvd.getValues().get("engine")+"\t"+mvd.getValues().get("query"));
+								if (!mvd.getValues().get("name").isEmpty()) newQuery.setName(mvd.getValues().get("name"));
+								System.out.println("New query: "+newQuery+" to "+qh);
+								qh.addQuery(newQuery);
+								tv.refresh(qh);
+							}
+							
+							
+						}
+						
+						
+					}
+				}
+			}
+		});
+
+		MenuManager menuManager = new MenuManager();
+		Menu menu = menuManager.createContextMenu(tv.getTree());
+
+		// Set the MenuManager
+		tv.getTree().setMenu(menu);
+		getSite().registerContextMenu(menuManager, tv);
+		// Make the selection available
+		getSite().setSelectionProvider(tv);
+	}
+
+	public static String queryToLabel(IQuery q) {
+		
+		if (q == null) return "";
+		
+		if (q.getName().equals(q.getQueryString())) {
+			return q.getSearchEngine().getName() + " = " + q.getQueryString();
+		} else {
+			return q.getSearchEngine().getName() + " - " + q.getName()+" = "+q.getQueryString();
+		}
+	}
+
+	@Override
+	public void setFocus() {
+		if (tv != null && !tv.getTree().isDisposed()) {
+			tv.getTree().setFocus();
+		}
+	}
+
+	/**
+	 * Refresh.
+	 */
+	public static void refresh() {
+		QueryView v = (QueryView) PlatformUI.getWorkbench()
+				.getActiveWorkbenchWindow().getActivePage().findView(
+						QueryView.class.getName());
+
+		if (v == null) return;
+
+		v.tv.refresh();
+	}
+
+	/**
+	 * Refresh.
+	 */
+	public static void refresh(Object f) {
+		if (f == null) return;
+
+		QueryView v = (QueryView) PlatformUI.getWorkbench()
+				.getActiveWorkbenchWindow().getActivePage().findView(
+						QueryView.class.getName());
+
+		if (v == null) return;
+
+		v.tv.refresh(f);
+	}
+
+	/**
+	 * Opens the File Explorer
+	 */
+	public static void open() {
+		open(null);
+	}
+
+	/**
+	 * Opens the Fiel Explorer
+	 */
+	public static void open(Object f) {
+		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+		try {
+			IViewPart v = page.showView(QueryView.class.getName());
+			if (v instanceof QueryView) {
+				QueryView e = (QueryView)v;
+				e.tv.setSelection(new StructuredSelection(f));
+			}
+		} catch (PartInitException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}

Property changes on: TXM/trunk/bundles/org.txm.searchengine.rcp/src/org/txm/searchengine/rcp/preferences/QueryView.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/bundles/org.txm.searchengine.rcp/plugin.xml
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.rcp/plugin.xml	(revision 3753)
+++ TXM/trunk/bundles/org.txm.searchengine.rcp/plugin.xml	(revision 3754)
@@ -10,5 +10,16 @@
             name="%page.name">
       </page>
    </extension>
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            allowMultiple="false"
+            category="org.txm.rcp"
+            class="org.txm.searchengine.rcp.preferences.QueryView"
+            id="org.txm.searchengine.rcp.preferences.QueryView"
+            name="Query"
+            restorable="true">
+      </view>
+   </extension>
 
 </plugin>
Index: TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java	(revision 3753)
+++ TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java	(revision 3754)
@@ -54,6 +54,14 @@
 
 		return true;
 	}
+	
+	public String getComputingDoneMessage() {
+		return "";
+	}
+	
+	public String getComputingStartMessage() {
+		return "";
+	}
 
 	@Override
 	public String getName() {
@@ -110,7 +118,7 @@
 	public <Q extends IQuery> ArrayList<Q> getQueries(Class<Q> clazz) {
 		ArrayList<Q> ret = new ArrayList<Q>();
 		for (IQuery q : queries) {
-			if (clazz == null || q.getClass().isInstance(clazz) || q.getClass().isAssignableFrom(clazz)) {
+			if (clazz == null || q.getClass().equals(clazz) || q.getClass().isInstance(clazz) || q.getClass().isAssignableFrom(clazz)) {
 				ret.add((Q) q);
 			}
 		}
@@ -165,7 +173,13 @@
 		queries.add(query);
 		modified = true;
 	}
+	
+	public void removeQuery(IQuery query) {
 
+		queries.remove(query);
+		modified = true;
+	}
+
 	public void reduceSize(int MAX) {
 		int diff = queries.size() - MAX;
 		if (diff > 0) { // there are more queries than MAX
@@ -199,7 +213,6 @@
 	}
 
 	public ArrayList<Query> getQueries() {
-		return getQueries(Query.class);
+		return getQueries(null);
 	}
-
 }
