summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java
blob: 038474888ed7c188f044f8b8430d8ab4626a9672 (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.Font;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
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.JTextField;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.table.LectureTable;
import org.openslx.dozmod.gui.control.table.QScrollPane;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.window.LectureListWindow.FilterType;

@SuppressWarnings("serial")
public abstract class LectureListWindowLayout extends CompositePage {
	
	private static final int ICON_SIZE_Y = 24;

	private static final String infoTitleString = "Übersicht Veranstaltungen";
	private static final String newButtonLabel = "Neue Veranstaltung";
	private static final String editButtonLabel = "Bearbeiten";
	private static final String deleteButtonLabel = "Löschen";
	private static final String switchViewButtonLabel = "VMs zeigen";
	private static final String filterPanelLabel = "Suchen";
	private static final String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen.";

	// buttons
	protected final JButton btnNewLecture;
	protected final JButton btnDeleteLecture;
	protected final JButton btnEditLecture;
	protected final JButton btnSwitchView;
	protected final JComboBox<FilterType> cboFilter;
	protected final QLabel lblVisibleLectureCount;

	protected final JTextField txtSearch;

	protected final LectureTable tblLectures;

	public LectureListWindowLayout() {
		super(new GridBagLayout());
		setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

		GridManager grid = new GridManager(this, 1);

		// --------- info group with title and text -------------------------
		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);
		// ---------------- end group of title ------------------------------

		// ------------ panel for the table and filter -----------------------
		JPanel tablePanel = new JPanel();
		GridManager tableGrid = new GridManager(tablePanel, 1);

		// filterPanel with filter text field and filter combo
		JPanel filterPanel = new JPanel();
		filterPanel.setBorder(new TitledBorder(filterPanelLabel));
		filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.LINE_AXIS));
		txtSearch = new JTextField();
		cboFilter = new JComboBox<FilterType>();
		for (FilterType s : FilterType.values()) {
			cboFilter.addItem(s);
		}
		filterPanel.add(txtSearch);
		filterPanel.add(cboFilter);

		// Panel for itemCount
		JPanel lectureCountPanel = new JPanel();
		lblVisibleLectureCount = new QLabel();
		lectureCountPanel.add(new JLabel("Sichtbar:"));
		lectureCountPanel.add(lblVisibleLectureCount);
		filterPanel.add(lectureCountPanel);

		// the actual table
		tblLectures = new LectureTable();

		tableGrid.add(filterPanel).fill(true, false).expand(true, false);
		tableGrid.nextRow();
		QScrollPane jsp = new QScrollPane(tblLectures);

		jsp.setBackground(UIManager.getColor("Table.background"));
		tableGrid.add(jsp).fill(true, true).expand(true, true);
		tableGrid.nextRow();
		tableGrid.finish(false);
		// ---------- end for table group  -----------------------------

		// ---------- button panel --------------------------------------
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
		buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

		btnNewLecture = new JButton(newButtonLabel, Gui.getScaledIconResource("/img/new-lecture-icon.png", "New Lecture", ICON_SIZE_Y, buttonPanel));
		btnEditLecture = new JButton(editButtonLabel, Gui.getScaledIconResource("/img/edit-icon.png", "Edit Lecture", ICON_SIZE_Y, buttonPanel));
		btnDeleteLecture = new JButton(deleteButtonLabel, Gui.getScaledIconResource("/img/delete-icon.png", "Delete Lecture", ICON_SIZE_Y, buttonPanel));
		btnSwitchView = new JButton(switchViewButtonLabel, Gui.getScaledIconResource("/img/switch-icon.png", "Switch", ICON_SIZE_Y, buttonPanel));
		buttonPanel.add(btnNewLecture);
		buttonPanel.add(btnEditLecture);
		buttonPanel.add(Box.createHorizontalStrut(5));
		buttonPanel.add(btnDeleteLecture);
		buttonPanel.add(Box.createHorizontalGlue());
		buttonPanel.add(btnSwitchView);
		// ----------------- end group for table -------------------------

		grid.add(infoPanel).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(tablePanel).fill(true, true).expand(true, true);
		grid.nextRow();
		grid.add(buttonPanel).fill(true, false).expand(true, false);
		grid.nextRow();

		grid.finish(false);
	}

	protected void setLectureCountLabel(int i) {
		lblVisibleLectureCount.setText(Integer.toString(i));
	}

}