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




                                                      

                                              


























































                                                                                                               
                                                                                                 







                                                                         

                                                                                                                               

















                                                                                     
                                                                                         

                                              



















                                                                                                





































                                                                                                 







                                                                    













                                                                                      
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.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
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.LectureListFilter;

public abstract class LectureListWindowLayout extends CompositePage {

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

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


	// imageDetail texts
	protected Text lectureName;
	protected Text idInfo;
	protected Text imageBaseId;
	protected Text lastusedInfo;
	protected Text permissionInfo;
	protected Text ownerInfo;
	protected Text startTime;
	protected Text endTime;

	protected final Text searchTextField;

	protected final TableViewer tableViewer;
	protected LectureListFilter filter;

	protected String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen.";

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

		// the layout and layoutData of the LectureListWindow
		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];
		final Font titleFont = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
		infoTitle.setFont(titleFont);
		// 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");
		// -- 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 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);

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

		// -- group for details of selected lecture --
		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
		lectureName = createCaptionAndTextfield("Name:", vmInfoGroup);
		idInfo = createCaptionAndTextfield("Id:", vmInfoGroup);
		imageBaseId = createCaptionAndTextfield("Image Id:", vmInfoGroup);
		lastusedInfo = createCaptionAndTextfield("Zuletzt genutzt:", vmInfoGroup);
		permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup);
		startTime = createCaptionAndTextfield("Startzeit:", vmInfoGroup);
		endTime = createCaptionAndTextfield("Endzeit:", vmInfoGroup);
		ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup);
		// -- end group of details --

		// Dispose of stuff we allocated
		this.addDisposeListener(new DisposeListener() {
			@Override
			public void widgetDisposed(DisposeEvent e) {
				titleFont.dispose();
			}
		});
	}

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

}