PortDistributionConfigurationPopUp.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
  2. import javax.swing.JFrame;
  3. import javax.swing.JPanel;
  4. import java.awt.BorderLayout;
  5. import java.util.Observable;
  6. import java.util.Observer;
  7. import javax.swing.JComboBox;
  8. import javax.swing.JLabel;
  9. import javax.swing.JButton;
  10. import javax.swing.JSplitPane;
  11. import javax.swing.border.EmptyBorder;
  12. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
  13. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ProbabilityDistributionHandler;
  14. public class PortDistributionConfigurationPopUp extends JFrame implements Observer{
  15. private Port port;
  16. private JSplitPane splitPane;
  17. public PortDistributionConfigurationPopUp(Port port) {
  18. this.port = port;
  19. this.setSize(300, 500);
  20. splitPane = new JSplitPane();
  21. splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
  22. splitPane.setBorder(new EmptyBorder(0, 0, 0, 0));
  23. getContentPane().add(splitPane, BorderLayout.CENTER);
  24. JPanel panel = new JPanel();
  25. splitPane.setLeftComponent(panel);
  26. panel.setLayout(null);
  27. JLabel lblDescription = new JLabel("Distribution Type:");
  28. lblDescription.setBounds(10, 10, 120, 20);
  29. panel.add(lblDescription);
  30. JComboBox comboBox = new JComboBox();
  31. comboBox.setBounds(120, 10, 190, 20);
  32. panel.add(comboBox);
  33. JButton btnImport = new JButton("Import");
  34. btnImport.setBounds(320, 10, 100, 20);
  35. panel.add(btnImport);
  36. splitPane.setDividerLocation(40);
  37. update(null,null);
  38. }
  39. @Override
  40. public void update(Observable o, Object arg) {
  41. if(port == null)return;
  42. ProbabilityDistributionHandler handler = port.getTriggerHandler();
  43. if(handler!=null)
  44. splitPane.setRightComponent(handler.getConfigurationPanel());
  45. else
  46. splitPane.setRightComponent(null);
  47. }
  48. }