/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
 *
 * This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
 * the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.votable.gui;

import java.awt.Cursor;

import eu.omp.irap.vespa.votable.utils.StringJoiner;
import eu.omp.irap.vespa.votable.votable.VOTableCtrl;

/**
 * @author N. Jourdane
 */
public class VOTablePanelCtrl extends VOTableCtrl implements VOTablePanelListener {

	/** The view of the VOTable panel. */
	private VOTablePanelView view;


	/**
	 * Constructor of VOTablePanelCtrl
	 */
	public VOTablePanelCtrl() {
		view = new VOTablePanelView(this);
	}

	@Override
	public void displayError(String message, Exception error) {
		super.displayError(message, error);
		view.displayError(message, error);
	}

	@Override
	public void displayTable() {
		view.fillTable(voTableData);
	}

	/**
	 * @return The view of the VOTable panel.
	 */
	public VOTablePanelView getView() {
		return view;
	}

	@Override
	public void onRowsSelected() {
		displayInfo("Selected row(s): " + StringJoiner.join(view.getSelectedRows()), null);
	}

	@Override
	public void setWaitMode(boolean enableWaitcursor) {
		int cursor = enableWaitcursor ? Cursor.WAIT_CURSOR : Cursor.DEFAULT_CURSOR;
		view.setCursor(Cursor.getPredefinedCursor(cursor));
	}
}
