summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
blob: b379db00af9a8db5319bcc508a7fc43290392ffb (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                             
 
                             

                                   
                              
 


                             
                          
                               
                              
                              
                                       

                               
                                                       
                                                   
                                             
 
 
                                                                   
 

                                                                                           
                                                                                                                                                 








                                                                                         
 



                                                      



                                         
 

                                                 







                                                    
                                        









                                                                            
                                                               




















                                                                                       
                                                              





                                                                                  
                                  










                                                                                                 




                                                                                   
                               




                                                                                                  
                                               

                                                                       
                                 

         
package org.openslx.dozmod.gui.window.layout;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

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 vmInfoGroupLabel = "Detailinformationen";
	protected final static String filterGroupLabel = "Filter";

	// --------------------------------------
	// Left panel: search field, table and buttons
	protected JTextField searchTextField;
	protected ImageTable imageTable;
	protected JButton newButton;
	protected JButton deleteButton;
	protected JButton downloadButton;
	protected JButton backButton;

	// --------------------------------------
	// Right panel: image details information
	protected JTextField imageSelectedNameLabel;
	protected JTextField idInfo;
	protected JTextField versionInfo;
	protected JTextField lastUpdateInfo;
	protected JTextField permissionInfo;
	protected JTextField ownerInfo;
	protected JTextField templateInfo;

	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); // TODO Font
		infoPanel.add(infoTitle, BorderLayout.NORTH);
		add(infoPanel, BorderLayout.NORTH);

		// --------------------------------------
		// LEFT: List panel with the list of the images
		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);
		// 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);

		// --------------------------------------
		// RIGHT: Details panel for the selected image
		final JPanel detailsPane = new JPanel();
		detailsPane.setLayout(new GridBagLayout());
		detailsPane.setBorder(new TitledBorder(vmInfoGroupLabel));
		detailsPane.setMaximumSize(new Dimension(400, Integer.MAX_VALUE));
		detailsPane.setMinimumSize(new Dimension(350, 0));
		detailsPane.setPreferredSize(detailsPane.getMinimumSize());
		// image name info
		int row = 0;
		imageSelectedNameLabel = createCaptionAndTextfield("Name", detailsPane, row++);
		idInfo = createCaptionAndTextfield("ID", detailsPane, row++);
		versionInfo = createCaptionAndTextfield("Version", detailsPane, row++);
		lastUpdateInfo = createCaptionAndTextfield("Letztes Update", detailsPane, row++);
		permissionInfo = createCaptionAndTextfield("Berechtigungen", detailsPane, row++);
		ownerInfo = createCaptionAndTextfield("Besitzer", detailsPane, row++);
		templateInfo = createCaptionAndTextfield("Vorlage", detailsPane, row++);
		// For some reason without this the controls above are centered vertically
		detailsPane.add(new JPanel(), GridPos.get(0, row++, 2, 1, true, true));
		// the actual layout of the whole window
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
		splitPane.setLeftComponent(listPanel);
		splitPane.setRightComponent(detailsPane);
		// make the left panel grab the excess space
		splitPane.setResizeWeight(1);
		add(splitPane);
	}
	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;
	}
}