summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
blob: 6397c82019f26aa39cdb31617a479ace88da7003 (plain) (tree)
1
2
3
4
5
                                             
 
                                                      
                                             
                           










                                         
                                  
                                                   
                                                     
 
                                                                   
 
                                                                            



                                                          
                                                     

                                                                  
                                                     
 




                                        

                                    
 







                                              
 
                                             
 
                                                
                                         
 
                                                                                                                                    
 
                                                                 

                                           
                                                                   
                                                         
                                                                                 
 
                                                       
                                                                          
                                                                                                 
                                                    

                                                                  
                                                  

                                                                     
                               
                                                                         
                                                                                                                    
                                        
                               

                                                                    
                                           
 
 
                                            

                                                               




                                                                                     
 


                                                                      
                                                                                         

                                              

                                                        
 



                                                                         
 
                        
                                                                                                
                                                                                      
                                                     
                                               
                                              

                                           
                                                       
                                                                                   

 
 
                                                              
                                                                                
                                                                                                 

                                                                       
                                                           
 










                                                                       


                                                                   
                                            
 

                                                                      
                                                      


                                                                                          

                                                                
                                  
                                                                                               
                                                                       
                                                                                 

                                                                                           
                                                                                
                                                                                  
                                             

 

         
                                                                                  


                                                                
                                                                                      
                                                                                  
                                            

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

import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.ImageListFilter;

public abstract class ImageListWindowLayout extends CompositePage {

	protected String infoTitleString = "Übersicht Virtuelle Maschinen";
	protected String newButtonLabel = "Neu";
	protected String editButtonLabel = "Bearbeiten";
	protected String deleteButtonLabel = "Löschen";
	protected String downloadButtonLabel = "Download";
	protected String backButtonLabel = "Zurück";
	protected String tableGroupLabel = "Images";
	protected String vmInfoGroupLabel = "Detailinformationen";
	protected String filterGroupLabel = "Filter";

	// buttons
	protected Button newButton;
	protected Button deleteButton;
	protected Button editButton;
	protected Button downloadButton;
	protected Button backButton;


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

	protected final Text searchTextField;

	protected final TableViewer tableViewer;
	protected ImageListFilter filter;

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

	public ImageListWindowLayout(final Composite mainShell) {
		super(mainShell, SWT.NONE);

		// the layout and layoutData of the ImageListWindow
		this.setLayout(new GridLayout(2, false));
		this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		// -- info group with title and text --
		Composite infoComposite = new Composite(this, SWT.BORDER);
		infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
		// layout for the items of the group
		infoComposite.setLayout(new GridLayout(1, false));

		// title of the info group in bold
		Label infoTitle = new Label(infoComposite, SWT.NONE);
		infoTitle.setText(infoTitleString);
		// set the fond
		FontData fontData = infoTitle.getFont().getFontData()[0];
		Font font = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
		infoTitle.setFont(font);
		// the infotext
		Label infoText = new Label(infoComposite, SWT.NONE);
		infoText.setText(infoTextString);
		// -- end group of title --


		// -- group for the table --
		Group tableGroup = new Group(this, SWT.BORDER);
		tableGroup.setText(tableGroupLabel);
		GridData tgLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
		tgLayoutData.minimumWidth = 400;
		tgLayoutData.widthHint = 800;
		tableGroup.setLayoutData(tgLayoutData);
		tableGroup.setLayout(new GridLayout());

		// -- group for the filter --
		Group filterGroup = new Group(tableGroup, SWT.BORDER);
		filterGroup.setText(filterGroupLabel);
		GridData fgGridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
		fgGridData.minimumWidth = 400;
		fgGridData.widthHint = 800;
		filterGroup.setLayoutData(fgGridData);
		filterGroup.setLayout(new GridLayout());

		// filter text field
		searchTextField = new Text(filterGroup, SWT.BORDER);
		searchTextField.setMessage("Name, Verantwortlicher, OS");
		// -- end group of filter --

		// table
		Table vmTable = new Table(tableGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
		GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
		vmTable.setLayoutData(tableGridData);
		vmTable.setHeaderVisible(true);
		vmTable.setLinesVisible(true);

		// TableViewer on the table
		tableViewer = new TableViewer(vmTable);
		tableViewer.setContentProvider(ArrayContentProvider.getInstance());



		// create, modify, download and delete buttons
		Composite buttonComposite = new Composite(tableGroup, SWT.NONE);
		GridData buttonCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
		buttonCompositeGridData.minimumWidth = 200;
		buttonComposite.setLayoutData(buttonCompositeGridData);
		buttonComposite.setLayout(new RowLayout());

		newButton = new Button(buttonComposite, SWT.PUSH);
		newButton.setText(newButtonLabel);

		editButton = new Button(buttonComposite, SWT.PUSH);
		editButton.setText(editButtonLabel);

		deleteButton = new Button(buttonComposite, SWT.PUSH);
		deleteButton.setText(deleteButtonLabel);

		downloadButton = new Button(buttonComposite, SWT.PUSH);
		downloadButton.setText(downloadButtonLabel);

		backButton = new Button(buttonComposite, SWT.PUSH);
		backButton.setText(backButtonLabel);
		// -- end group for table --

		// -- group for details of selected image --
		final Group vmInfoGroup = new Group(this, SWT.BORDER);
		vmInfoGroup.setText(vmInfoGroupLabel);
		final GridData igGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
		igGridData.widthHint = 300;
		vmInfoGroup.setLayoutData(igGridData);
		vmInfoGroup.setLayout(new GridLayout(2, false));

		// image name info
		imageSelectedNameLabel = createCaptionAndTextfield("Image Name:", vmInfoGroup);
		idInfo = createCaptionAndTextfield("ID:", vmInfoGroup);
		versionInfo = createCaptionAndTextfield("Version:", vmInfoGroup);
		lastUpdateInfo = createCaptionAndTextfield("Letztes Update:", vmInfoGroup);
		permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup);
		ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup);
		templateInfo = createCaptionAndTextfield("Vorlage:", vmInfoGroup);
		// -- end group of details --


	}

	public Text createCaptionAndTextfield(String captionString, Group group) {
		Label caption = new Label(group, SWT.NONE);
		Text textField = new Text(group, SWT.READ_ONLY);
		caption.setText(captionString);
		caption.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
		gridData.minimumWidth = 180;
		textField.setLayoutData(gridData);
		return textField;
	}

}