// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
// 
// 	private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// 	private static float hsbVals[] = Color.RGBtoHSB(
// 			defaultPanelColor.getRed(),
// 			defaultPanelColor.getGreen(),
// 			defaultPanelColor.getBlue(),
// 			null
// 	);
// 
// 	public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// 	public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
// 
// 	public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// 	public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
// 
// 	public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
// 
// 	public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// 	public static final Border fancyPanelBorder = new CompoundBorder(
// 			// Outside border 1px bottom light color
// 			new MatteBorder(0, 0, 1, 0, Color.WHITE),
// 			// Border all around panel 1px dark grey
// 			defaultComponentBorder
// 	);
// 	public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
// 
// }
// 
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// 	private static final long serialVersionUID = 1L;
// 
// 	public HelpIcon(String message) {
// 		super();
// 		try {
// 			setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// 		} catch (Exception e) {
// 			setText("[?]");
// 		}
// 		setToolTipText(message);
// 	}
// }


import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
/*
 * This file is part of PPiMapBuilder.
 *
 * PPiMapBuilder 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.
 *
 * PPiMapBuilder 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 PPiMapBuilder.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
 *
 */

package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;



public class DatabaseSelectionPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private final LinkedHashMap<PsicquicService, JCheckBox> databases;
	private final JPanel panSourceDatabases;

	public DatabaseSelectionPanel() {
		setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
		setOpaque(false);

		// Source databases label
		JLabel lblSourceDatabases = new JLabel("Source databases:");
		add(lblSourceDatabases);

		// Source databases Help Icon
		JLabel lblHelpSourceDatabase = new HelpIcon("Select here the databases from which the interactions will be retrieved");
		lblHelpSourceDatabase.setHorizontalAlignment(SwingConstants.RIGHT);
		add(lblHelpSourceDatabase);

		// Source databases scrollpane containing a panel that will contain checkbox at display
		JScrollPane scrollPaneSourceDatabases = new JScrollPane();
		scrollPaneSourceDatabases.setBorder(PMBUIStyle.fancyPanelBorder);
		scrollPaneSourceDatabases.setViewportBorder(PMBUIStyle.emptyBorder);
		add(scrollPaneSourceDatabases, "newline, grow, spanx 2");

		// Source databases panel that will contain checkbox at display
		panSourceDatabases = new JPanel();
		panSourceDatabases.setBackground(Color.white);
		panSourceDatabases.setBorder(PMBUIStyle.emptyBorder);
		scrollPaneSourceDatabases.setViewportView(panSourceDatabases);
		panSourceDatabases.setLayout(new BoxLayout(panSourceDatabases, BoxLayout.Y_AXIS));

		databases = new LinkedHashMap<PsicquicService, JCheckBox>();
	}

	/**
	 * Updates the database list with an list of String
	 */
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
// 
// 	private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// 	private static float hsbVals[] = Color.RGBtoHSB(
// 			defaultPanelColor.getRed(),
// 			defaultPanelColor.getGreen(),
// 			defaultPanelColor.getBlue(),
// 			null
// 	);
// 
// 	public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// 	public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
// 
// 	public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// 	public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
// 
// 	public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
// 
// 	public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// 	public static final Border fancyPanelBorder = new CompoundBorder(
// 			// Outside border 1px bottom light color
// 			new MatteBorder(0, 0, 1, 0, Color.WHITE),
// 			// Border all around panel 1px dark grey
// 			defaultComponentBorder
// 	);
// 	public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
// 
// }
// 
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// 	private static final long serialVersionUID = 1L;
// 
// 	public HelpIcon(String message) {
// 		super();
// 		try {
// 			setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// 		} catch (Exception e) {
// 			setText("[?]");
// 		}
// 		setToolTipText(message);
// 	}
// }


// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/DatabaseSelectionPanel.java
import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;

/*
 * This file is part of PPiMapBuilder.
 *
 * PPiMapBuilder 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.
 *
 * PPiMapBuilder 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 PPiMapBuilder.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
 *
 */

package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;



public class DatabaseSelectionPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private final LinkedHashMap<PsicquicService, JCheckBox> databases;
	private final JPanel panSourceDatabases;

	public DatabaseSelectionPanel() {
		setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
		setOpaque(false);

		// Source databases label
		JLabel lblSourceDatabases = new JLabel("Source databases:");
		add(lblSourceDatabases);

		// Source databases Help Icon
		JLabel lblHelpSourceDatabase = new HelpIcon("Select here the databases from which the interactions will be retrieved");
		lblHelpSourceDatabase.setHorizontalAlignment(SwingConstants.RIGHT);
		add(lblHelpSourceDatabase);

		// Source databases scrollpane containing a panel that will contain checkbox at display
		JScrollPane scrollPaneSourceDatabases = new JScrollPane();
		scrollPaneSourceDatabases.setBorder(PMBUIStyle.fancyPanelBorder);
		scrollPaneSourceDatabases.setViewportBorder(PMBUIStyle.emptyBorder);
		add(scrollPaneSourceDatabases, "newline, grow, spanx 2");

		// Source databases panel that will contain checkbox at display
		panSourceDatabases = new JPanel();
		panSourceDatabases.setBackground(Color.white);
		panSourceDatabases.setBorder(PMBUIStyle.emptyBorder);
		scrollPaneSourceDatabases.setViewportView(panSourceDatabases);
		panSourceDatabases.setLayout(new BoxLayout(panSourceDatabases, BoxLayout.Y_AXIS));

		databases = new LinkedHashMap<PsicquicService, JCheckBox>();
	}

	/**
	 * Updates the database list with an list of String
	 */
	public void updateList(List<PsicquicService> dbs) {