summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
blob: e7ff4242b28649f962ee4d4d0ae5325238ed74cc (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.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
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;
import org.openslx.dozmod.gui.helper.ResizeColumnListener;


public abstract class ImageListWindowLayout extends CompositePage {

	private final static Logger LOGGER = Logger.getLogger(ImageListWindowLayout.class);

	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";

	// buttons
	protected JButton newButton;
	protected JButton deleteButton;
	protected JButton downloadButton;
	protected JButton backButton;

	// imageDetail texts
	protected JTextField imageSelectedNameLabel;
	protected JTextField idInfo;
	protected JTextField versionInfo;
	protected JTextField lastUpdateInfo;
	protected JTextField permissionInfo;
	protected JTextField ownerInfo;
	protected JTextField templateInfo;

	protected JTextField searchTextField;

	protected ImageTable imageTable;

	protected String infoTextString = "Hier können Sie Virtuelle Maschinen hochladen, herunterladen, bearbeiten und löschen.";

	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);

		// --------------------------------------
		// 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);

		// --------------------------------------
		// Details panel on the right side
		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, listPanel, detailsPane);
		GridBagLayout bag = new GridBagLayout();
    	GridBagConstraints con = new GridBagConstraints();
    	con.fill = GridBagConstraints.BOTH;
    	bag.setConstraints(splitPane, con);
		add(splitPane);
		

	}
	public JPanel newLabelToTextField(final String labelName, JTextField textField, GridBagConstraints con) {
		JPanel newPanel = new JPanel();
		con.gridwidth = 1;
		con.gridx = 0;
		con.weightx = 0.1;
		con.anchor = GridBagConstraints.WEST;
		con.fill = GridBagConstraints.BOTH;
		newPanel.add(new JLabel(labelName), con);
		con.gridx = 1;
		con.weightx = 1.;
		con.anchor = GridBagConstraints.EAST;
		con.fill = GridBagConstraints.HORIZONTAL;
		if (textField == null) {
			textField = new JTextField();
		}
		newPanel.add(textField, con);
		
		// finally update "row number"
		con.gridy++;
		return newPanel;
	}
	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;
	}
}