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.helper.Gui; import org.openslx.dozmod.gui.helper.TableHelper; public abstract class ImageListWindowLayout extends Composite { protected String infoTitleString = "Imageauswahl"; protected String newButtonLabel = "Neu"; protected String editButtonLabel = "Bearbeiten"; protected String deleteButtonLabel = "Löschen"; protected String downloadButtonLabel = "Download"; protected String tableGroupLabel = "Images"; protected String vmInfoGroupLabel = "Detailinformationen"; // buttons protected Button newButton; protected Button deleteButton; protected Button editButton; protected Button downloadButton; // 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 TableViewer tableViewer; protected String infoTextString = "Hier können Sie images erstellen, 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); GridData infoGridData = new GridData(SWT.FILL, SWT.FILL, true, false); infoGridData.horizontalSpan = 2; infoComposite.setLayoutData(infoGridData); // 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); // group for the table Group tableGroup = new Group(this, SWT.BORDER); tableGroup.setText(tableGroupLabel); tableGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tableGroup.setLayout(new GridLayout(3, true)); // jface tableviewer on swt table Table vmTable = new Table(tableGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true); tableGridData.horizontalSpan = 3; tableGridData.minimumWidth = 200; vmTable.setLayoutData(tableGridData); vmTable.setHeaderVisible(true); vmTable.setLinesVisible(true); // TableViewer on the table tableViewer = new TableViewer(vmTable); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); TableHelper.createImageTableColumns(tableViewer); // create, modify, download and delete buttons Composite buttonComposite = new Composite(tableGroup, SWT.NONE); GridData buttonCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, false); buttonCompositeGridData.horizontalSpan = 4; 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); // group for the info of the selected image in the tableViewer Group vmInfoGroup = new Group(this, SWT.BORDER); vmInfoGroup.setText(vmInfoGroupLabel); buttonCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, false); buttonCompositeGridData.minimumWidth = 300; vmInfoGroup.setLayoutData(buttonCompositeGridData); vmInfoGroup.setLayout(new GridLayout(2, false)); // image name info imageSelectedNameLabel = createCaptionAndTextfield("Image Name:", vmInfoGroup); // id info idInfo = createCaptionAndTextfield("ID:", vmInfoGroup); versionInfo = createCaptionAndTextfield("Version", vmInfoGroup); lastUpdateInfo = createCaptionAndTextfield("Letztes Update:", vmInfoGroup); permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup); ownerInfo = createCaptionAndTextfield("Besitzer ID", vmInfoGroup); templateInfo = createCaptionAndTextfield("Vorlage:", vmInfoGroup); } 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); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); gridData.minimumWidth = 100; textField.setLayoutData(gridData); return textField; } }