Index: /SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
===================================================================
--- /SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java	(revision 2174)
+++ /SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java	(revision 2175)
@@ -33,7 +33,9 @@
 import org.zkoss.zul.Column;
 import org.zkoss.zul.Vbox;
+import org.zkoss.zul.Iframe;
+import org.zkoss.zul.Window;
 
 public class Aggregator extends SelectorComposer<Component> {
-
+    
     @Wire
     private Grid anzeigeGrid;
@@ -56,5 +58,8 @@
     @Wire
     private Button deselectAll;
-
+    @Wire
+    private Window mainWindow;
+    
+    
     @Override
     public void doAfterCompose(Component comp) throws Exception {
@@ -63,15 +68,15 @@
 
         languageSelect.setSelectedItem(german);
-
+        
         Harvester harv = new Harvester();
         ArrayList<Endpoint> ep = harv.getEndpoints();
-
+        
         int i, i2;
-
+        
         for (i = 0; i < ep.size(); i++) {
-
+            
             System.out.println("Calling corpora ...: " + ep.get(i).getUrl());
             ArrayList<Corpus> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl());
-
+            
             if (corpora.size() == 0) {
                 Checkbox cb = new Checkbox();
@@ -80,25 +85,25 @@
                 //"?operation=searchRetrieve&version=1.2"
                 cb.setLabel(ep.get(i).getUrl());
-
+                
                 allCorpora.getChildren().add(cb);
                 allCorpora.getChildren().add(new Separator());
-
+                
                 System.out.println("CHECKBOX: " + cb.getId());
             } else {
                 Label l = new Label(ep.get(i).getUrl() + ":");
-
+                
                 l.setStyle("font-weight:bold");
-
+                
                 allCorpora.getChildren().add(l);
                 allCorpora.getChildren().add(new Separator());
                 for (i2 = 0; i2 < corpora.size(); i2++) {
                     Checkbox cb = new Checkbox();
-
+                    
                     cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue());
                     cb.setLabel(corpora.get(i2).getDisplayTerm());
-
+                    
                     allCorpora.getChildren().add(cb);
                     allCorpora.getChildren().add(new Separator());
-
+                    
                     System.out.println("CHECKBOX: " + cb.getId());
                 } // for i2 ...
@@ -106,16 +111,16 @@
 
             Separator sep = new Separator();
-
+            
             sep.setBar(true);
             allCorpora.getChildren().add(sep);
-
+            
         } // for i ...
 
     }
-
+    
     @Listen("onClick = #selectAll")
     public void onSelectAll(Event ev) {
         int i;
-
+        
         for (i = 0; i < allCorpora.getChildren().size(); i++) {
             if (allCorpora.getChildren().get(i) instanceof Checkbox) {
@@ -129,5 +134,5 @@
     public void onDeselectAll(Event ev) {
         int i;
-
+        
         for (i = 0; i < allCorpora.getChildren().size(); i++) {
             if (allCorpora.getChildren().get(i) instanceof Checkbox) {
@@ -145,24 +150,36 @@
         }
     }
-
+    
     @Listen("onClick=#clearResults")
     public void onClearResults(Event ev) {
         resultsVbox.getChildren().clear();
     }
-
-    @Listen("onClick=#exportResults")
-    public void onExportResults(Event ev) {
-
+    
+    @Listen("onClick=#showHelp")
+    public void onShowHelp(Event ev) {
+        resultsVbox.getChildren().clear();
+        Iframe help = new Iframe();
+        help.setWidth("100%");
+        help.setHeight("100%");
+        help.setSrc("help.html");
+        resultsVbox.appendChild(help);        
+    }
+    
+    @Listen("onClick=#exportResultsCSV")
+    public void onExportResultsCSV(Event ev) {
+        
         int i, i2, i3;
         String temp = "";
-
+        boolean somethingToExport = false;
+        
         for (i = 0; i < resultsVbox.getChildren().size(); i++) {
             if (resultsVbox.getChildren().get(i) instanceof Grid) {
+                somethingToExport = true;
                 Grid aGrid = (Grid) resultsVbox.getChildren().get(i);
                 Rows rows = aGrid.getRows();
-
+                
                 for (i2 = 0; i2 < rows.getChildren().size(); i2++) {
                     Row r = (Row) rows.getChildren().get(i2);
-
+                    
                     for (i3 = 0; i3 < r.getChildren().size(); i3++) {
                         Label l = (Label) r.getChildren().get(i3);
@@ -177,25 +194,71 @@
 
         } // for i ...
-        Filedownload.save(temp, "text/plain", "table.csv");
-    }
-
+        
+        if (somethingToExport) {
+            
+            Filedownload.save(temp, "text/plain", "ClarinDFederatedContentSearch.csv");
+        } else {
+            Messagebox.show("Nothing to export!");
+        }
+    }
+    
+    
+     @Listen("onClick=#exportResultsTCF")
+    public void onExportResultsTCF(Event ev) {
+        
+        int i, i2, i3;
+        String temp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><D-Spin xmlns=\"http://www.dspin.de/data\" version=\"0.4\">\n<MetaData xmlns=\"http://www.dspin.de/data/metadata\">\n";
+        temp = temp  + "<source>CLARIN-D Federated Content Search</source>\n</MetaData>\n  <TextCorpus xmlns=\"http://www.dspin.de/data/textcorpus\">\n<text>";
+        
+        
+        boolean somethingToExport = false;
+        
+        for (i = 0; i < resultsVbox.getChildren().size(); i++) {
+            if (resultsVbox.getChildren().get(i) instanceof Grid) {
+                somethingToExport = true;
+                Grid aGrid = (Grid) resultsVbox.getChildren().get(i);
+                Rows rows = aGrid.getRows();
+                
+                for (i2 = 0; i2 < rows.getChildren().size(); i2++) {
+                    Row r = (Row) rows.getChildren().get(i2);
+                    
+                    for (i3 = 0; i3 < r.getChildren().size(); i3++) {
+                        Label l = (Label) r.getChildren().get(i3);
+                        temp = temp + l.getValue() + " ";
+                    } //for i3
+                    temp = temp + "\n";
+                } // for i2
+            } // if grid
+
+        } // for i ...
+        
+        if (somethingToExport) {
+            temp = temp + "</text>\n</TextCorpus>\n</D-Spin>";
+            Filedownload.save(temp, "text/tcf+xml", "ClarinDFederatedContentSearch.xml");
+        } else {
+            Messagebox.show("Nothing to export!");
+        }
+    }
+     
+   
+    
     @Listen("onClick = #searchButton")
     public void onExecuteSearch(Event ev) {
-
+        
         try {
-
+            
             if (languageSelect.getText().trim().equals("")) {
                 Messagebox.show("Please select a language.");
                 return;
             }
-
+            
             int i, i2;
-
-
+            
+            
             resultsVbox.getChildren().clear();
-
-
-
-
+            
+            
+            boolean isACorpusSelected = false;
+            
             for (i = 0; i < allCorpora.getChildren().size(); i++) {
                 if (allCorpora.getChildren().get(i) instanceof Checkbox) {
@@ -203,10 +266,12 @@
                     if (cb.isChecked()) {
                         // now execute the search:
-
+                        
+                        isACorpusSelected = true;
+                        
                         System.out.println("---- THE SEARCH ----");
-
+                        
                         String endpointURL = null;
                         String corpus = null;
-
+                        
                         if (cb.getId().contains("\t")) {
                             endpointURL = cb.getId().split("\t")[0];
@@ -215,44 +280,44 @@
                             endpointURL = cb.getId();
                         }
-
+                        
                         System.out.println("enddpointURL: " + endpointURL);
                         System.out.println("corpus: " + corpus);
                         SRUSearch srusearch = new SRUSearch();
                         System.out.println("Calling the client ");
-
+                        
                         resultsVbox.appendChild(new Label("Query: " + searchString.getText()));
                         resultsVbox.appendChild(new Label("Endpoint: " + endpointURL));
                         resultsVbox.appendChild(new Label("Corpus: " + corpus));
-
-
+                        
+                        
                         ArrayList<Row> zeilen = srusearch.execute(searchString.getText(), endpointURL, corpus, 10);
-
+                        
                         if (zeilen.size() > 0) {
-
+                            
                             Grid g = new Grid();
-
+                            
                             g.setMold("paging");
                             g.setPageSize(10);
-
+                            
                             Columns columns = new Columns();
-
+                            
                             Column c = new Column();
                             c.setLabel("Left");
-
+                            
                             columns.appendChild(c);
-
+                            
                             c = new Column();
                             c.setLabel("Hit");
                             c.setHflex("min");
                             columns.appendChild(c);
-
+                            
                             c = new Column();
                             c.setLabel("Right");
                             columns.appendChild(c);
-
+                            
                             g.appendChild(columns);
-
+                            
                             Rows rows = new Rows();
-
+                            
                             for (i2 = 0; i2 < zeilen.size(); i2++) {
                                 System.out.println("Adding row " + i2);
@@ -262,9 +327,9 @@
 
                             g.appendChild(rows);
-
+                            
                             resultsVbox.appendChild(g);
                         } else {
                             resultsVbox.appendChild(new Label("Sorry there were no results!"));
-
+                            
                         } // if zeilen > 0
 
@@ -275,10 +340,17 @@
                 }
             } // for i ...
-            System.out.println("Done");
-
+            
+            if (!isACorpusSelected) {
+                
+                Messagebox.show("Please select at least one corpus!", "CLARIN-D FCS Aggregator", 0, Messagebox.EXCLAMATION);
+            }
+            
+            
+            System.out.println("Search is done.");
+            
         } catch (Exception ex) {
             System.out.println(ex.getMessage());
         }
-
+        
     }
 }
Index: /SRUAggregator/trunk/web/index.zul
===================================================================
--- /SRUAggregator/trunk/web/index.zul	(revision 2174)
+++ /SRUAggregator/trunk/web/index.zul	(revision 2175)
@@ -1,4 +1,5 @@
 
 <zk>
+<!--title="CLARIN-D Federated Content Search"-->
     <window  id="mainWindow" contentStyle="background:white;" height="100%" apply="clarind.fcs.Aggregator"> 
         <borderlayout sclass="complex-layout"  >
@@ -19,5 +20,5 @@
                         <textbox id="searchString" value="Elefant" />
                         <button id="searchButton"  label="Search" image="buttonSearch.png"/>     
-                        <!-- forward ="onExecuteSearch"-->
+
                         <separator />
                        
@@ -27,22 +28,17 @@
                              <label>Select by Language:</label>
                         <combobox id="languageSelect" width="150px" value="German">                                                                                                                   
-                            <!--<template name="model"> -->
                             <comboitem label="German" id="german"/>
                             <comboitem label="English" id="english"/>
                             <comboitem label="Dutch" id="dutch" />
                             <comboitem label="-More to come-" />
-                            <!-- </template> -->
                         </combobox>
                         
                          <separator />
                         
-                        <button id="selectAll" label="Select All" image="buttonSelectAll.png"/>                                           
-                        
-                        <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/>
-                        
+                        <button id="selectAll" label="Select All" image="buttonSelectAll.png"/>                                                                  
+                        <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/>                      
+                      
                         <separator />
-                                                    
-                                                                            
-                                                                                                                            
+                                                                                       
                         </groupbox>
                     </panelchildren>
@@ -54,25 +50,41 @@
                 <panel>
                     <panelchildren  id="resultsPanel" style="overflow: auto">
-                        <toolbar id="resultsToolbar"  height="20px">
-                            <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/>
+                        <menubar id="menubar" width="100%">
+                            <menu label="Actions" image="buttonActions.png">
+                                <menupopup>
+                                    <menuitem label="Clear Results" id="clearResults" image="buttonDelete.png" />
+                                  <menuitem label="Export Results to CSV" id="exportResultsCSV" image="buttonExport.png" />
+                                  <menuitem label="Export Results to TCF" id="exportResultsTCF" image="buttonExport.png" />                           
+                             </menupopup>                                
+                            </menu>                            
+                            <menu label="Help" image="buttonHelp.png">
+                                <menupopup>
+                                     <menuitem label="Show Help" id="showHelp" image="buttonHelp.png" />
+                                </menupopup>   
+                            </menu>
+                                                                                 
+                        </menubar>
+<!--                         <toolbar id="resultsToolbar"  height="20px">
+                           <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/>
                             <toolbarbutton id="exportResults" label="Export Results" image="buttonExport.png"/>
+                            <toolbarbutton id="showHelp" label="Show Help" image="buttonHelp.png"/>
                                 
                         </toolbar>
+                        -->
                         <vbox id="resultsVbox">
-                        <grid id="anzeigeGrid">
-                            <columns>
-                                <column></column>
-                                <column></column>  
-                                <column></column>                                       
-                            </columns>
-                            <rows></rows>
-                        </grid>
-                        <html id="anzeigeResults" />
+                            <iframe src="help.html" width="100%" height="100%"/>
+                            <grid id="anzeigeGrid">
+                                <columns>
+                                    <column></column>
+                                    <column></column>  
+                                    <column></column>                                       
+                                </columns>
+                                <rows></rows>
+                            </grid>
+                            <html id="anzeigeResults" />
                         </vbox>
                     </panelchildren>
                     
                 </panel>
-
-                
             </center>
             
