package org.openslx.dozmod.gui.window.layout;
import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.control.table.ImageTable;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.GridPos;
public abstract class ImageListWindowLayout extends CompositePage {
private final static Logger LOGGER = Logger.getLogger(ImageListWindowLayout.class);
protected final static String infoTextString = "Hier können Sie Virtuelle Maschinen hochladen, herunterladen, bearbeiten und löschen.";
protected final static String infoTitleString = "Übersicht Virtuelle Maschinen";
protected final static String newButtonLabel = "Neu";
protected final static String editButtonLabel = "Bearbeiten";
protected final static String deleteButtonLabel = "Löschen";
protected final static String downloadButtonLabel = "Download";
protected final static String backButtonLabel = "Zurück";
protected final static String tableGroupLabel = "Images";
protected final static String filterGroupLabel = "Filter";
// --------------------------------------
// search field, table and buttons
protected JTextField searchTextField;
protected ImageTable imageTable;
protected JButton newButton;
protected JButton deleteButton;
protected JButton downloadButton;
protected JButton backButton;
public ImageListWindowLayout() {
super(new BorderLayout());
// --------------------------------------
// Info panel on the top with a search box
JPanel infoPanel = new JPanel(new BorderLayout());
JLabel infoTitle = new JLabel(infoTitleString);
infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD));
JLabel infoText = new JLabel(infoTextString);
infoPanel.add(infoTitle, BorderLayout.NORTH);
infoPanel.add(infoText, BorderLayout.CENTER);
add(infoPanel, BorderLayout.NORTH);
// --------------------------------------
// the panel for the table and search field
JPanel listPanel = new JPanel(new BorderLayout());
// the search field
searchTextField = new JTextField();
listPanel.add(searchTextField, BorderLayout.NORTH);
// the actual table
imageTable = new ImageTable();
listPanel.add(new JScrollPane(imageTable), BorderLayout.CENTER);
add(listPanel, BorderLayout.CENTER);
// --------------------------------------
// the buttons at the bottom
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
newButton = new JButton(newButtonLabel);
deleteButton = new JButton(deleteButtonLabel);
downloadButton = new JButton(downloadButtonLabel);
backButton = new JButton(backButtonLabel);
buttonPanel.add(newButton);
buttonPanel.add(deleteButton);
buttonPanel.add(downloadButton);
buttonPanel.add(backButton);
listPanel.add(buttonPanel, BorderLayout.PAGE_END);
}
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;
}
}