<commit_before>package org.jboss.reddeer.eclipse.datatools.sqltools.result.ui;

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

import org.jboss.reddeer.common.platform.RunningPlatform;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.swt.api.TreeItem;
import org.jboss.reddeer.swt.condition.TreeHasChildren;
import org.jboss.reddeer.swt.impl.toolbar.DefaultToolItem;
import org.jboss.reddeer.swt.impl.tree.DefaultTree;
import org.jboss.reddeer.workbench.impl.view.WorkbenchView;

/**
 * SQL Result View RedDeer implementation
 * 
 * @author <NAME>
 *
 */
public class ResultView extends WorkbenchView {

	/**
	 * Create instance and looks for Result view.
	 */
	public ResultView() {
		super("SQL Results");
	}

	/**
	 * Return SQL results.
	 * 
	 * @return list of SQLResults
	 */
	public List<SQLResult> getResults() {
		open();
		DefaultTree tree = new DefaultTree();
		List<TreeItem> items = tree.getItems();
		List<SQLResult> results = new ArrayList<SQLResult>();

		for (TreeItem item : items) {

			results.add(new SQLResult(item.getCell(0), item.getCell(1), item
					.getCell(2), item.getCell(3)));

		}
		return results;
	}

	/**
	 * Removes all visible results from the SQL Result View.
	 */
	public void removeAllResults() {
		open();
		DefaultTree tree = new DefaultTree();
		String tooltip = "Remove All Visible Results (Shift+Delete)";
		if (RunningPlatform.isOSX()) {
			tooltip = "Remove All Visible Results (⇧⌦)";
		}
		DefaultToolItem item = new DefaultToolItem(tooltip);
		item.click();
		new WaitWhile(new TreeHasChildren(tree));<commit_msg>ResultViewTest failing due to the empty tree (fixes #1320)<commit_after>package org.jboss.reddeer.eclipse.datatools.sqltools.result.ui;

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

import org.jboss.reddeer.common.platform.RunningPlatform;
import org.jboss.reddeer.common.wait.TimePeriod;
import org.jboss.reddeer.common.wait.WaitUntil;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.swt.api.TreeItem;
import org.jboss.reddeer.swt.condition.TreeHasChildren;
import org.jboss.reddeer.swt.impl.toolbar.DefaultToolItem;
import org.jboss.reddeer.swt.impl.tree.DefaultTree;
import org.jboss.reddeer.workbench.impl.view.WorkbenchView;

/**
 * SQL Result View RedDeer implementation
 * 
 * @author <NAME>
 *
 */
public class ResultView extends WorkbenchView {

	/**
	 * Create instance and looks for Result view.
	 */
	public ResultView() {
		super("SQL Results");
	}

	/**
	 * Return SQL results.
	 * 
	 * @return list of SQLResults
	 */
	public List<SQLResult> getResults() {
		open();
		DefaultTree tree = new DefaultTree();
		List<TreeItem> items = tree.getItems();
		List<SQLResult> results = new ArrayList<SQLResult>();

		for (TreeItem item : items) {

			results.add(new SQLResult(item.getCell(0), item.getCell(1), item
					.getCell(2), item.getCell(3)));

		}
		return results;
	}

	/**
	 * Removes all visible results from the SQL Result View.
	 */
	public void removeAllResults() {
		open();
		DefaultTree tree = new DefaultTree();
		new WaitUntil(new TreeHasChildren(tree),TimePeriod.NORMAL, false);
		String tooltip = "Remove All Visible Results (Shift+Delete)";
		if (RunningPlatform.isOSX()) {
			tooltip = "Remove All Visible Results (⇧⌦)";
		}
		DefaultToolItem item = new DefaultToolItem(tooltip);
		item.click();
		new WaitWhile(new TreeHasChildren(tree));
{'fraction_non_alphanumeric': 0.12938402593575007, 'fraction_numerical': 0.0035366931918656055, 'mean_word_length': 4.353312302839116, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '540077', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1111, 'n_words': 249}