LinkCreationDialog.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
  2. import java.awt.Component;
  3. import java.util.Collection;
  4. import javax.swing.JDialog;
  5. import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
  6. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
  7. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
  8. /**
  9. * Simple Window which contains the {@link LinkCreationPanel}
  10. *
  11. * @author Andreas T. Meyer-Berg
  12. */
  13. @SuppressWarnings("serial")
  14. public class LinkCreationDialog extends JDialog {
  15. /**
  16. * Link Creation Panel which is displayed
  17. */
  18. private LinkCreationPanel content;
  19. /**
  20. * Parent Frame for relative location
  21. */
  22. private Component parent;
  23. /**
  24. * Create a Dialog for link editing
  25. * @param link link to be edited
  26. * @param controller controller to be used
  27. * @param panel which is the parent
  28. */
  29. public LinkCreationDialog(Link link, Controller controller, Component panel) {
  30. super();
  31. content = new LinkCreationPanel(link, controller, this);
  32. parent = panel;
  33. initialize();
  34. }
  35. /**
  36. * Creates a Dialog for creation of a new connections
  37. * @param devices devices to be linked
  38. * @param controller controller to manipulate the model
  39. * @param panel panel which is the parent
  40. */
  41. public LinkCreationDialog(Collection<SmartDevice> devices, Controller controller, Component panel){
  42. super();
  43. content = new LinkCreationPanel(devices, controller, this);
  44. parent = panel;
  45. initialize();
  46. }
  47. /**
  48. * Initialize the panel
  49. */
  50. private void initialize() {
  51. this.setModal(true);
  52. this.setContentPane(content);
  53. this.pack();
  54. setLocationRelativeTo(parent);
  55. this.setVisible(true);
  56. }
  57. }