package org.openslx.dozmod.gui.window.layout;
import java.awt.Font;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import org.openslx.dozmod.gui.control.table.LectureTable;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.GridPos;
public abstract class LectureListWindowLayout extends CompositePage {
private static final String infoTitleString = "Übersicht Veranstaltungen";
private static final String newButtonLabel = "Neu";
private static final String editButtonLabel = "Bearbeiten";
private static final String deleteButtonLabel = "Löschen";
private static final String switchViewButtonLabel = "Zu 'Images' wechseln";
private static final String filterPanelLabel = "Suchen";
private static final String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen.";
protected final static String[] showOwnedLabel = {"Alle anzeigen", "Nur eigene Anzeigen", "Nur editierbare anzeigen", "Bald auslaufend"};
// buttons
protected JButton newButton;
protected JButton deleteButton;
protected JButton editButton;
protected JButton switchViewButton;
protected JComboBox<String> filterCbo;
// imageDetail texts
protected JTextField lectureName;
protected JTextField idInfo;
protected JTextField imageBaseId;
protected JTextField lastusedInfo;
protected JTextField permissionInfo;
protected JTextField ownerInfo;
protected JTextField startTime;
protected JTextField endTime;
protected final JTextField searchTextField;
protected final LectureTable lectureTable;
public LectureListWindowLayout() {
super(new GridBagLayout());
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
// -- info group with title and text --
JPanel infoComposite = new JPanel();
infoComposite.setLayout(new BoxLayout(infoComposite, BoxLayout.PAGE_AXIS));
// title of the info group in bold
JLabel infoTitle = new JLabel(infoTitleString);
infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD));
// the infotext
JLabel infoText = new JLabel(infoTextString);
infoComposite.add(infoTitle);
infoComposite.add(infoText);
// -- end group of title --
// -- group for the table --
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new GridBagLayout());
tablePanel.setPreferredSize(tablePanel.getMinimumSize());
// filterPanel with filter text field and filter combo
JPanel filterPanel = new JPanel();
filterPanel.setBorder(new TitledBorder(filterPanelLabel));
filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.LINE_AXIS));
searchTextField = new JTextField();
filterCbo = new JComboBox<String>();
for (String s: showOwnedLabel){
filterCbo.addItem(s);
}
filterPanel.add(searchTextField);
filterPanel.add(filterCbo);
tablePanel.add(filterPanel, GridPos.get(0, 0, true, false));
// table
lectureTable = new LectureTable();
tablePanel.add(new JScrollPane(lectureTable), GridPos.get(0, 1, true, true));
// create, modify and delete buttons
JPanel buttonComposite = new JPanel();
buttonComposite.setLayout(new BoxLayout(buttonComposite, BoxLayout.LINE_AXIS));
buttonComposite.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
tablePanel.add(buttonComposite, GridPos.get(0, 2, true, false));
newButton = new JButton(newButtonLabel);
buttonComposite.add(newButton);
editButton = new JButton(editButtonLabel);
buttonComposite.add(editButton);
deleteButton = new JButton(deleteButtonLabel);
buttonComposite.add(deleteButton);
buttonComposite.add(Box.createHorizontalGlue());
switchViewButton = new JButton(switchViewButtonLabel);
buttonComposite.add(switchViewButton);
// -- end group for table --
add(infoComposite, GridPos.get(0, 0, 2, 1, true, false));
add(tablePanel, GridPos.get(0, 1, true, true));
}
public JTextField createCaptionAndTextfield(String captionString, JPanel group, int row) {
JLabel caption = new JLabel(captionString);
JTextField textField = new JTextField();
textField.setEditable(false);
caption.setText(captionString);
group.add(caption, GridPos.get(0, row));
group.add(textField, GridPos.get(1, row, true, false));
return textField;
}
}