// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/dialog/MessageDialog.java
// public class MessageDialog {
// 
// 	public static void showMessage(Component parentComponent, String title, List<String> messages) {
// 		StringBuilder sb = new StringBuilder();
// 		for (String message : messages) {
// 			sb.append(message);
// 			sb.append("\n");
// 		}
// 		showMessage(parentComponent, title, sb.toString());
// 	}
// 
// 	public static void showMessage(Component parentComponent, String title, String message) {
// 		JTextArea jta = new JTextArea(message);
// 		jta.setLineWrap(true);
// 		jta.setWrapStyleWord(true);
// 		jta.setEditable(false);
// 		JScrollPane jsp = new JScrollPane(jta) {
// 			@Override
// 			public Dimension getPreferredSize() {
// 				return new Dimension(580, 320);
// 			}
// 		};
// 		JOptionPane.showMessageDialog(parentComponent, jsp, title, JOptionPane.ERROR_MESSAGE);
// 	}
// }
// 
// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/event/DesignChangedEvent.java
// public class DesignChangedEvent {
// 	private final SBOLDesign design;
// 
// 	public DesignChangedEvent(SBOLDesign design) {
// 		this.design = design;
// 	}
// 
// 	public SBOLDesign getDesign() {
// 		return design;
// 	}
// }


import edu.utah.ece.async.sboldesigner.sbol.editor.dialog.MessageDialog;
import edu.utah.ece.async.sboldesigner.sbol.editor.event.DesignChangedEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import org.sbolstandard.core2.SBOLValidationException;
import com.google.common.collect.Maps;
import com.google.common.eventbus.Subscribe;

	private void addPartButton(final Part part) {
		JButton button = createPartButton(part);
		add(button);

		buttons.put(part, button);
	}

	private JButton createPartButton(final Part part) {
		JButton button = new JButton();
		button.setText(part.getDisplayId());
		button.setIcon(new ImageIcon(part.getImage()));
		button.setVerticalTextPosition(SwingConstants.BOTTOM);
		button.setHorizontalTextPosition(SwingConstants.CENTER);
		button.setToolTipText(part.getName());
		button.setFocusPainted(false);
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent event) {
				try {
					design.addCD(part, part == Parts.UNSPECIFIED);
				} catch (SBOLValidationException | URISyntaxException e) {
					MessageDialog.showMessage(null, "There was an error: ", e.getMessage());
					e.printStackTrace();
				}
			}
		});
		return button;
	}

	@Subscribe

// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/dialog/MessageDialog.java
// public class MessageDialog {
// 
// 	public static void showMessage(Component parentComponent, String title, List<String> messages) {
// 		StringBuilder sb = new StringBuilder();
// 		for (String message : messages) {
// 			sb.append(message);
// 			sb.append("\n");
// 		}
// 		showMessage(parentComponent, title, sb.toString());
// 	}
// 
// 	public static void showMessage(Component parentComponent, String title, String message) {
// 		JTextArea jta = new JTextArea(message);
// 		jta.setLineWrap(true);
// 		jta.setWrapStyleWord(true);
// 		jta.setEditable(false);
// 		JScrollPane jsp = new JScrollPane(jta) {
// 			@Override
// 			public Dimension getPreferredSize() {
// 				return new Dimension(580, 320);
// 			}
// 		};
// 		JOptionPane.showMessageDialog(parentComponent, jsp, title, JOptionPane.ERROR_MESSAGE);
// 	}
// }
// 
// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/event/DesignChangedEvent.java
// public class DesignChangedEvent {
// 	private final SBOLDesign design;
// 
// 	public DesignChangedEvent(SBOLDesign design) {
// 		this.design = design;
// 	}
// 
// 	public SBOLDesign getDesign() {
// 		return design;
// 	}
// }


// Path: src/main/java/edu/utah/ece/async/sboldesigner/sbol/editor/PartsPanel.java
import edu.utah.ece.async.sboldesigner.sbol.editor.dialog.MessageDialog;
import edu.utah.ece.async.sboldesigner.sbol.editor.event.DesignChangedEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import org.sbolstandard.core2.SBOLValidationException;
import com.google.common.collect.Maps;
import com.google.common.eventbus.Subscribe;

	private void addPartButton(final Part part) {
		JButton button = createPartButton(part);
		add(button);

		buttons.put(part, button);
	}

	private JButton createPartButton(final Part part) {
		JButton button = new JButton();
		button.setText(part.getDisplayId());
		button.setIcon(new ImageIcon(part.getImage()));
		button.setVerticalTextPosition(SwingConstants.BOTTOM);
		button.setHorizontalTextPosition(SwingConstants.CENTER);
		button.setToolTipText(part.getName());
		button.setFocusPainted(false);
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent event) {
				try {
					design.addCD(part, part == Parts.UNSPECIFIED);
				} catch (SBOLValidationException | URISyntaxException e) {
					MessageDialog.showMessage(null, "There was an error: ", e.getMessage());
					e.printStackTrace();
				}
			}
		});
		return button;
	}

	@Subscribe

	public void designChanged(DesignChangedEvent event) {
