summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
blob: fb83e9115b2fe639d2a71bb23163a78c528ea61e (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.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

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.apache.thrift.TException;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
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;
import org.openslx.dozmod.thrift.Session;
import org.openslx.dozmod.thrift.ThriftError;
import org.openslx.thrifthelper.ThriftManager;

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

	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 = "Detailansicht / Bearbeiten";
	protected final static String downloadButtonLabel = "Download";
	protected final static String deleteButtonLabel = "Löschen";
	protected final static String switchViewButtonLabel = "Veranstaltungen zeigen";

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

	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-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/red-cross.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));
		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.createHorizontalGlue());
		buttonPanel.add(btnSwitchView);

		/*
		 * WARNING: Test crap
		 */
		JButton butt = new JButton("LOL");
		butt.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				try {
					String token = ThriftManager.getSatClient().requestImageReplication(Session.getSatelliteToken(),
							"e9de1941-b673-4711-b033-d8c37d1e2d3e");
					MainWindow.addPassiveTransfer(token, "POO POO VM", false);
				} catch (TException e1) {
					ThriftError.showMessage(ImageListWindowLayout.this, null, e1, "BOO BOO");
				}
			}
		});
		buttonPanel.add(butt);
		/*
		 * END TEST
		 */

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

}