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

                             
                             
                          
                          
                               
                              

                               
                                                       
                                                   
                                             
 
 
                                                                   
 

                                                                                           
                                                                                                                                                 

                                                                                         
                                                                                   
                                                                     
                                                                       
                                                                     

                                                                  
                                                                  
                                                                                                                                                   
 
                                                 
                                          

                                             
                                    
                                           
                                         
                                       
                                     
                                              
 
 
                                        




                                                                  


                                                                             
                                                             
                                                             


                                                         
                                                           
                                                                  
                                                        

                                                                                       
                                                   
                                                    
                                             
                                             

                                                 
                                           
                                                               


                                                                                
                                                    
 
                                                         



                                                                                       
                                                                      



                                                                  
                                                  
                                                


                                                                           

                                                                  
         






                               



                                                                                                  
                                               

                                                                       
                                 

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

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

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 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 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 backButtonLabel = "Zurück";
	protected final static String tableGroupLabel = "Images";
	protected final static String filterGroupLabel = "Filter";
	protected final static String[] filterLabels = {"Alle anzeigen", "Nur eigene Anzeigen", "Nur editierbare anzeigen", "Nur Vorlagen zeigen"};

	// --------------------------------------
	// search field, table and buttons
	protected JTextField searchTextField;
	protected ImageTable imageTable;
	protected JButton newButton;
	protected JButton newLectureButton;
	protected JButton downloadButton;
	protected JButton deleteButton;
	protected JButton backButton;
	protected JComboBox<String> filterCbo;


	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 and filter combo box
		JPanel filterPanel = new JPanel();
		filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.LINE_AXIS));
		searchTextField = new JTextField();
		filterCbo = new JComboBox<String>();
		for (String s: filterLabels){
			filterCbo.addItem(s);
		}
		filterPanel.add(searchTextField);
		filterPanel.add(filterCbo);
		listPanel.add(filterPanel, 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);
		newLectureButton = new JButton(newLectureButtonLabel);
		deleteButton = new JButton(deleteButtonLabel);
		downloadButton = new JButton(downloadButtonLabel);
		backButton = new JButton(backButtonLabel);
		buttonPanel.add(newButton);
		buttonPanel.add(newLectureButton);
		buttonPanel.add(downloadButton);
		buttonPanel.add(Box.createRigidArea(new Dimension(5,  0)));
		buttonPanel.add(deleteButton);
		buttonPanel.add(Box.createHorizontalGlue());
		buttonPanel.add(backButton);
		listPanel.add(buttonPanel, BorderLayout.PAGE_END);
	}

	/**
	 * @param captionString
	 * @param group
	 * @param row
	 * @return
	 */
	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;
	}
}