|
@ -22,7 +22,9 @@ import javax.swing.border.LineBorder; |
|
|
import java.awt.SystemColor; |
|
|
import java.awt.SystemColor; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionEvent; |
|
|
import ksiazka.kucharska.retrieveTest; |
|
|
|
|
|
|
|
|
import ksiazka.kucharska.RetrieveData; |
|
|
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
|
|
|
|
|
public class FrmMain extends JFrame { |
|
|
public class FrmMain extends JFrame { |
|
|
|
|
|
|
|
@ -32,17 +34,17 @@ public class FrmMain extends JFrame { |
|
|
private static final long serialVersionUID = 2634383304749703669L; |
|
|
private static final long serialVersionUID = 2634383304749703669L; |
|
|
private JPanel contentPane; |
|
|
private JPanel contentPane; |
|
|
private JTextField txtSearch; |
|
|
private JTextField txtSearch; |
|
|
private JTextField txtEdTitle; |
|
|
|
|
|
private JTextField txtTags; |
|
|
|
|
|
|
|
|
public static JTextField txtEdTitle; |
|
|
|
|
|
public static JTextField txtTags; |
|
|
private JButton btnSave; |
|
|
private JButton btnSave; |
|
|
private JButton btnCancel; |
|
|
private JButton btnCancel; |
|
|
private JTextPane txtIngredients; |
|
|
|
|
|
private JTextPane txtDescription; |
|
|
|
|
|
|
|
|
public static JTextPane txtIngredients; |
|
|
|
|
|
public static JTextPane txtDescription; |
|
|
private JButton btnAddRecipe; |
|
|
private JButton btnAddRecipe; |
|
|
private JButton btnSearch; |
|
|
private JButton btnSearch; |
|
|
private JButton btnDelRecipe; |
|
|
private JButton btnDelRecipe; |
|
|
private JButton btnLoadImg; |
|
|
private JButton btnLoadImg; |
|
|
private JLabel lblRecipeTitle; |
|
|
|
|
|
|
|
|
public static JLabel lblRecipeTitle; |
|
|
private static DefaultListModel recipesListModel; |
|
|
private static DefaultListModel recipesListModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +128,13 @@ public class FrmMain extends JFrame { |
|
|
panel.add(btnSearch, gbc_btnSearch); |
|
|
panel.add(btnSearch, gbc_btnSearch); |
|
|
|
|
|
|
|
|
recipesListModel = new DefaultListModel(); |
|
|
recipesListModel = new DefaultListModel(); |
|
|
JList recipesList = new JList(recipesListModel); |
|
|
|
|
|
|
|
|
final JList recipesList = new JList(recipesListModel); |
|
|
|
|
|
recipesList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
|
|
public void valueChanged(ListSelectionEvent e){ |
|
|
|
|
|
if(recipesList.getSelectedIndex() != -1) |
|
|
|
|
|
RetrieveData.fillComponents(recipesList.getSelectedValue().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
GridBagConstraints gbc_recipesList = new GridBagConstraints(); |
|
|
GridBagConstraints gbc_recipesList = new GridBagConstraints(); |
|
|
gbc_recipesList.insets = new Insets(0, 0, 5, 0); |
|
|
gbc_recipesList.insets = new Insets(0, 0, 5, 0); |
|
|
gbc_recipesList.gridwidth = 2; |
|
|
gbc_recipesList.gridwidth = 2; |
|
@ -146,7 +154,7 @@ public class FrmMain extends JFrame { |
|
|
panel.add(panel_1, gbc_panel_1); |
|
|
panel.add(panel_1, gbc_panel_1); |
|
|
panel_1.setLayout(new GridLayout(0, 2, 0, 0)); |
|
|
panel_1.setLayout(new GridLayout(0, 2, 0, 0)); |
|
|
|
|
|
|
|
|
btnAddRecipe = new JButton("Dodaj"); |
|
|
|
|
|
|
|
|
btnAddRecipe = new JButton("Nowy"); |
|
|
btnAddRecipe.addActionListener(new ActionListener() { |
|
|
btnAddRecipe.addActionListener(new ActionListener() { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
ActivateAddMenu(); |
|
|
ActivateAddMenu(); |
|
@ -155,16 +163,29 @@ public class FrmMain extends JFrame { |
|
|
panel_1.add(btnAddRecipe); |
|
|
panel_1.add(btnAddRecipe); |
|
|
|
|
|
|
|
|
btnDelRecipe = new JButton("Usuń"); |
|
|
btnDelRecipe = new JButton("Usuń"); |
|
|
|
|
|
btnDelRecipe.addActionListener(new ActionListener() { |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
DefaultListModel model = (DefaultListModel) recipesList.getModel(); |
|
|
|
|
|
if (recipesList.getSelectedIndex() != -1) |
|
|
|
|
|
{ |
|
|
|
|
|
RetrieveData.removeRecipe(recipesList.getSelectedValue().toString()); |
|
|
|
|
|
model.remove(recipesList.getSelectedIndex()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
panel_1.add(btnDelRecipe); |
|
|
panel_1.add(btnDelRecipe); |
|
|
|
|
|
|
|
|
JPanel panel_2 = new JPanel(); |
|
|
JPanel panel_2 = new JPanel(); |
|
|
splitPane.setRightComponent(panel_2); |
|
|
splitPane.setRightComponent(panel_2); |
|
|
panel_2.setLayout(null); |
|
|
panel_2.setLayout(null); |
|
|
|
|
|
|
|
|
btnSave = new JButton("Zapisz"); |
|
|
|
|
|
|
|
|
btnSave = new JButton("Dodaj"); |
|
|
btnSave.addActionListener(new ActionListener() { |
|
|
btnSave.addActionListener(new ActionListener() { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
RetrieveData.addNewRecipe(); |
|
|
DeactivateAddMenu(); |
|
|
DeactivateAddMenu(); |
|
|
|
|
|
DefaultListModel model = (DefaultListModel) recipesList.getModel(); |
|
|
|
|
|
model.addElement(txtEdTitle.getText()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
btnSave.setVisible(false); |
|
|
btnSave.setVisible(false); |
|
@ -230,6 +251,7 @@ public class FrmMain extends JFrame { |
|
|
btnCancel.setBounds(319, 46, 117, 25); |
|
|
btnCancel.setBounds(319, 46, 117, 25); |
|
|
panel_2.add(btnCancel); |
|
|
panel_2.add(btnCancel); |
|
|
|
|
|
|
|
|
retrieveTest.retrieveData(); |
|
|
|
|
|
|
|
|
//RetrieveData.insertSampleData(); |
|
|
|
|
|
RetrieveData.fillList(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |