SummaryPanel.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package org.leumasjaffe.recipe.view.summary;
  2. import java.awt.Dimension;
  3. import java.awt.GridBagConstraints;
  4. import java.awt.GridBagLayout;
  5. import java.awt.Insets;
  6. import javax.swing.JLabel;
  7. import javax.swing.JPanel;
  8. import javax.swing.JSeparator;
  9. import javax.swing.JTextField;
  10. import javax.swing.JTextPane;
  11. import org.jdesktop.swingx.VerticalLayout;
  12. import org.leumasjaffe.recipe.model.Element;
  13. import org.leumasjaffe.recipe.view.ImagePanel;
  14. import lombok.AccessLevel;
  15. import lombok.experimental.FieldDefaults;
  16. @SuppressWarnings("serial")
  17. @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
  18. public class SummaryPanel extends JPanel {
  19. JPanel panelIngredients;
  20. public SummaryPanel() {
  21. GridBagLayout gridBagLayout = new GridBagLayout();
  22. gridBagLayout.columnWidths = new int[]{0, 0, 0};
  23. gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
  24. gridBagLayout.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
  25. gridBagLayout.rowWeights = new double[]{1.0, 1.0, 1.0, Double.MIN_VALUE};
  26. setLayout(gridBagLayout);
  27. JPanel panelHeader = new JPanel();
  28. GridBagConstraints gbc_panelHeader = new GridBagConstraints();
  29. gbc_panelHeader.gridwidth = 2;
  30. gbc_panelHeader.insets = new Insets(0, 0, 5, 0);
  31. gbc_panelHeader.fill = GridBagConstraints.BOTH;
  32. gbc_panelHeader.gridx = 0;
  33. gbc_panelHeader.gridy = 0;
  34. add(panelHeader, gbc_panelHeader);
  35. GridBagLayout gbl_panelHeader = new GridBagLayout();
  36. gbl_panelHeader.columnWidths = new int[]{0, 0, 0};
  37. gbl_panelHeader.rowHeights = new int[]{0, 0};
  38. gbl_panelHeader.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
  39. gbl_panelHeader.rowWeights = new double[]{0.0, Double.MIN_VALUE};
  40. panelHeader.setLayout(gbl_panelHeader);
  41. JTextField txtTitle = new JTextField();
  42. txtTitle.setText("Title");
  43. GridBagConstraints gbc_txtTitle = new GridBagConstraints();
  44. gbc_txtTitle.insets = new Insets(0, 0, 0, 5);
  45. gbc_txtTitle.fill = GridBagConstraints.HORIZONTAL;
  46. gbc_txtTitle.gridx = 0;
  47. gbc_txtTitle.gridy = 0;
  48. panelHeader.add(txtTitle, gbc_txtTitle);
  49. txtTitle.setColumns(10);
  50. JLabel lblDuration = new JLabel("Duration");
  51. GridBagConstraints gbc_lblDuration = new GridBagConstraints();
  52. gbc_lblDuration.gridx = 1;
  53. gbc_lblDuration.gridy = 0;
  54. panelHeader.add(lblDuration, gbc_lblDuration);
  55. panelIngredients = new JPanel();
  56. GridBagConstraints gbc_panelIngredients = new GridBagConstraints();
  57. gbc_panelIngredients.gridheight = 2;
  58. gbc_panelIngredients.insets = new Insets(0, 0, 0, 5);
  59. gbc_panelIngredients.fill = GridBagConstraints.BOTH;
  60. gbc_panelIngredients.gridx = 0;
  61. gbc_panelIngredients.gridy = 1;
  62. add(panelIngredients, gbc_panelIngredients);
  63. panelIngredients.setLayout(new VerticalLayout());
  64. JPanel panelPhoto = new ImagePanel();
  65. GridBagConstraints gbc_panelPhoto = new GridBagConstraints();
  66. gbc_panelPhoto.insets = new Insets(0, 0, 5, 0);
  67. gbc_panelPhoto.fill = GridBagConstraints.BOTH;
  68. gbc_panelPhoto.gridx = 1;
  69. gbc_panelPhoto.gridy = 1;
  70. add(panelPhoto, gbc_panelPhoto);
  71. JTextPane txtpnDescription = new JTextPane();
  72. txtpnDescription.setPreferredSize(new Dimension(0, 100));
  73. txtpnDescription.setText("Description");
  74. GridBagConstraints gbc_txtpnDescription = new GridBagConstraints();
  75. gbc_txtpnDescription.fill = GridBagConstraints.BOTH;
  76. gbc_txtpnDescription.gridx = 1;
  77. gbc_txtpnDescription.gridy = 2;
  78. add(txtpnDescription, gbc_txtpnDescription);
  79. }
  80. public void addProduct(final Element comp) {
  81. panelIngredients.add(new ElementSummaryPanel(comp));
  82. panelIngredients.add(new JSeparator());
  83. }
  84. }