package org.jboss.reddeer.jface.text.contentassist;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.jboss.reddeer.swt.api.Table;
import org.jboss.reddeer.swt.api.TableItem;
import org.jboss.reddeer.swt.handler.ShellHandler;
import org.jboss.reddeer.swt.keyboard.KeyboardFactory;
import org.jboss.reddeer.swt.lookup.ShellLookup;

/**
 * This class represents content assistant
 * @author rawagner
 * @since 0.6
 */
public class ContentAssistant {
	
	private Table contentAssistTable;
	private Shell contentAssistShell;
	
	/**
	 * Instantiates content assistant with given table of proposals
	 * @param contentAssistTable table which contains proposals
	 */
	public ContentAssistant(Table contentAssistTable){
		this.contentAssistTable = contentAssistTable;
		this.contentAssistShell = ShellLookup.getInstance().getCurrentActiveShell();
	}
	
	/**
	 * Returns content assist proposals
	 * @return list of proposals
	 */
	public List<String> getProposals(){
		List<String> proposals = new ArrayList<String>();
		for(TableItem i: contentAssistTable.getItems()){
			proposals.add(i.getText());
		}
		return proposals;
	}
	
	/**
	 * Selects given proposal
	 * @param proposal to select
	 */
	public void chooseProposal(String proposal){
		contentAssistTable.getItem(proposal).select();
		KeyboardFactory.getKeyboard().invokeKeyCombination(SWT.CR);
	}
	
	/**
	 * Closes content assist shell
	 */
	public void close(){
		if(contentAssistShell != null){
			ShellHandler.getInstance().closeShell(contentAssistShell);
		}
	}

}


@@ -164,16 +164,64 @@
 .Shell;%0A
+import org.jboss.reddeer.common.logging.Logger;%0A
 import o
@@ -252,16 +252,16 @@
 .Table;%0A
-
 import o
@@ -571,16 +571,97 @@
 ant %7B%0A%09%0A
+%09protected static final Logger log = Logger.getLogger(ContentAssistant.class);%0A%09%0A
 %09private
@@ -1158,16 +1158,65 @@
 sals()%7B%0A
+%09%09log.debug(%22Getting content assist proposals%22);%0A
 %09%09List%3CS
@@ -1259,16 +1259,58 @@
 ing%3E();%0A
+%09%09log.debug(%22Content assist proposals:%22);%0A
 %09%09for(Ta
@@ -1352,16 +1352,71 @@
 ems())%7B%0A
+%09%09%09String text = i.getText();%0A%09%09%09log.debug(%22  %22+text);%0A
 %09%09%09propo
@@ -1424,27 +1424,20 @@
 als.add(
-i.getT
+t
 ext
-()
 );%0A%09%09%7D%0A%09
@@ -1573,16 +1573,75 @@
 posal)%7B%0A
+%09%09log.debug(%22Choose content assist proposal - %22+proposal);%0A
 %09%09conten
@@ -1786,24 +1786,24 @@
  shell%0A%09 */%0A
-
 %09public void
@@ -1812,16 +1812,55 @@
 lose()%7B%0A
+%09%09log.debug(%22Closing content assist%22);%0A
 %09%09if(con

Add logging to content assist #890