package org.openslx.dozmod.gui.window.layout; import java.awt.BorderLayout; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JPanel; import org.apache.log4j.Logger; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.ImageListViewer; import org.openslx.dozmod.gui.control.ImageListViewer.FilterType; import org.openslx.dozmod.gui.control.QLabel; import org.openslx.dozmod.gui.helper.CompositePage; import org.openslx.dozmod.gui.helper.GridManager; @SuppressWarnings("serial") public abstract class ImageListWindowLayout extends CompositePage { private final static Logger LOGGER = Logger.getLogger(ImageListWindowLayout.class); private static final int ICON_SIZE_Y = 24; private final ImageListWindowLayout me = this; 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 = "Neue VM"; protected final static String newLectureButtonLabel = "Neue Veranstaltung"; protected final static String editButtonLabel = "Bearbeiten"; protected final static String downloadButtonLabel = "Download"; protected final static String deleteButtonLabel = "Löschen"; protected final static String switchViewButtonLabel = "Veranstaltungen zeigen"; protected final static String showPublishedImagesLabel = "Öffentliche VMs"; // -------------------------------------- // search field, table and buttons protected final ImageListViewer ctlImageListViewer; protected final JButton btnNewVm; protected final JButton btnNewLecture; protected final JButton btnEditDetails; protected final JButton btnDownload; protected final JButton btnDelete; protected final JButton btnSwitchView; protected final JButton btnShowPublishedImages; public ImageListWindowLayout() { super(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // -------------------------------------- // Info panel on the top with a search box JPanel infoPanel = new JPanel(new BorderLayout()); QLabel infoTitle = new QLabel(infoTitleString); infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD)); QLabel infoText = new QLabel(infoTextString); infoPanel.add(infoTitle, BorderLayout.NORTH); infoPanel.add(infoText, BorderLayout.CENTER); ctlImageListViewer = new ImageListViewer(FilterType.USABLE); // -------------------------------------- // the buttons at the bottom JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); btnNewVm = new JButton(newButtonLabel, Gui.getScaledIconResource("/img/new-vm-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); btnEditDetails = new JButton(editButtonLabel, Gui.getScaledIconResource("/img/edit-icon.png", "Edit VM", ICON_SIZE_Y, buttonPanel)); btnDelete = new JButton(deleteButtonLabel, Gui.getScaledIconResource("/img/delete-icon.png", "Delete VM", ICON_SIZE_Y, buttonPanel)); btnDownload = new JButton(downloadButtonLabel, Gui.getScaledIconResource("/img/download-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); btnNewLecture = new JButton(newLectureButtonLabel, Gui.getScaledIconResource("/img/new-lecture-icon.png", "New Lecture", ICON_SIZE_Y, buttonPanel)); btnShowPublishedImages = new JButton(showPublishedImagesLabel, Gui.getScaledIconResource("/img/published-vm-icon.png", "Published Lectures", ICON_SIZE_Y, buttonPanel)); btnShowPublishedImages.setVisible(false); // this gets enabled later when the API version can be queried btnSwitchView = new JButton(switchViewButtonLabel, Gui.getScaledIconResource("/img/switch-icon.png", "Switch", ICON_SIZE_Y, buttonPanel)); buttonPanel.add(btnNewVm); buttonPanel.add(btnEditDetails); buttonPanel.add(btnDelete); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(btnDownload); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(btnNewLecture); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(btnShowPublishedImages); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(btnSwitchView); // put everything together GridManager grid = new GridManager(this, 1); grid.add(infoPanel).fill(true, false).expand(true, false); grid.nextRow(); grid.add(ctlImageListViewer).fill(true, true).expand(true, true); grid.nextRow(); grid.add(buttonPanel).fill(true, false).expand(true, false); grid.nextRow(); grid.finish(false); } }