diff options
author | Stephan Schwaer | 2015-07-07 18:41:13 +0200 |
---|---|---|
committer | Stephan Schwaer | 2015-07-07 18:41:13 +0200 |
commit | 6cdab2d80d7f614345a93f429a8c337fcd161f96 (patch) | |
tree | cbe9f7929df0363ab744399ee99bcc52fa06bd0a /dozentenmodul | |
parent | [client] Adapt to changes in master-sync-shared/ThriftManager (diff) | |
download | tutor-module-6cdab2d80d7f614345a93f429a8c337fcd161f96.tar.gz tutor-module-6cdab2d80d7f614345a93f429a8c337fcd161f96.tar.xz tutor-module-6cdab2d80d7f614345a93f429a8c337fcd161f96.zip |
[client] Added imageWindowComposite and early stage of wizard for creating/editing images.
Diffstat (limited to 'dozentenmodul')
12 files changed, 760 insertions, 36 deletions
diff --git a/dozentenmodul/pom.xml b/dozentenmodul/pom.xml index 3e4d2195..2d162395 100644 --- a/dozentenmodul/pom.xml +++ b/dozentenmodul/pom.xml @@ -151,18 +151,32 @@ </properties> </profile> <profile> - <id>windows</id> + <id>windows_32</id> <activation> <os> <family>windows</family> + <arch>i386</arch> </os> </activation> <properties> - <swt.groupId>org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt</swt.groupId> + <swt.groupId>org.eclipse.swt</swt.groupId> <swt.artifactId>org.eclipse.swt.win32.win32.x86</swt.artifactId> </properties> </profile> <profile> + <id>windows_64</id> + <activation> + <os> + <family>windows</family> + <arch>amd64</arch> + </os> + </activation> + <properties> + <swt.groupId>org.eclipse.swt</swt.groupId> + <swt.artifactId>org.eclipse.swt.win32.win32.x86_64</swt.artifactId> + </properties> + </profile> + <profile> <id>linux_64</id> <activation> <os> @@ -171,9 +185,6 @@ </os> </activation> <properties> - - - <swt.groupId>org.eclipse.swt</swt.groupId> <swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId> </properties> @@ -195,11 +206,6 @@ <dependencies> <dependency> - <groupId>org.mod4j.org.eclipse.jface</groupId> - <artifactId>text</artifactId> - <version>3.5.0</version> - </dependency> - <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.9.1</version> @@ -212,18 +218,6 @@ <scope>compile</scope> </dependency> <dependency> - <groupId>com.toedter</groupId> - <artifactId>jcalendar</artifactId> - <version>1.4</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>net.sourceforge.jdatepicker</groupId> - <artifactId>jdatepicker</artifactId> - <version>1.3.2</version> - <scope>compile</scope> - </dependency> - <dependency> <groupId>${swt.groupId}</groupId> <artifactId>${swt.artifactId}</artifactId> <version>4.4</version> @@ -269,6 +263,12 @@ <version>2.2.4</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.eclipse.jface</groupId> + <artifactId>org.eclipse.jface</artifactId> + <version>3.8.0.v20120521-2329</version> + <scope>compile</scope> + </dependency> </dependencies> </project> diff --git a/dozentenmodul/src/main/java/gui/GuiManager.java b/dozentenmodul/src/main/java/gui/GuiManager.java index 8e28409c..762b8433 100644 --- a/dozentenmodul/src/main/java/gui/GuiManager.java +++ b/dozentenmodul/src/main/java/gui/GuiManager.java @@ -38,6 +38,7 @@ public abstract class GuiManager { gridData.widthHint = 800; gridData.heightHint = 600; contentComposite.setLayoutData(gridData); + mainShell.setMinimumSize(850, 650); mainShell.layout(); diff --git a/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java b/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java index b8296295..370b06d8 100644 --- a/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java +++ b/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java @@ -33,6 +33,10 @@ public class DisclaimerComposite extends Composite { String title = "bwLehrpool Suite"; String noticeLabel = "Hinweis"; + + // Buttons + protected Button agreeBox; + Button continueButton; public DisclaimerComposite(final Shell mainShell) { super(mainShell, SWT.NONE); @@ -71,11 +75,11 @@ public class DisclaimerComposite extends Composite { checkboxComposite.setLayoutData(gridData); - Button agreeBox = new Button(checkboxComposite, SWT.CHECK); + agreeBox = new Button(checkboxComposite, SWT.CHECK); agreeBox.setText(_checkboxText); - final Button continueButton = new Button(this, SWT.PUSH); + continueButton = new Button(this, SWT.PUSH); continueButton.setText("Weiter"); continueButton.setEnabled(false); diff --git a/dozentenmodul/src/main/java/gui/core/ImageWindowComposite.java b/dozentenmodul/src/main/java/gui/core/ImageWindowComposite.java new file mode 100644 index 00000000..6a024e3f --- /dev/null +++ b/dozentenmodul/src/main/java/gui/core/ImageWindowComposite.java @@ -0,0 +1,371 @@ +package gui.core; + + +import gui.GuiManager; +import gui.helper.VMColumns; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedList; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +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.bwlp.thrift.iface.ImagePermissions; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; + +import wizards.ImageWizard; + +public class ImageWindowComposite 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 String infoTextString = "Hier können Sie images erstellen, bearbeiten und löschen."; + + public ImageWindowComposite(Composite mainShell) { + super(mainShell, SWT.NONE); + + this.setLayout(new GridLayout(2, false)); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + this.setLayoutData(gridData); + + + + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.horizontalSpan = 2; + Composite infoComposite = new Composite(this, SWT.BORDER); + infoComposite.setLayoutData(gridData); + infoComposite.setLayout(new GridLayout(1, false)); + + + + Label infoTitle = new Label(infoComposite, SWT.NONE); + infoTitle.setText(infoTitleString); + FontData fontData = infoTitle.getFont().getFontData()[0]; + Font font = new Font(GuiManager.getDisplay(), new FontData(fontData.getName(), fontData + .getHeight(), SWT.BOLD)); + infoTitle.setFont(font); + + Label infoText = new Label(infoComposite, SWT.NONE); + infoText.setText(infoTextString); + + + + // group for the table + Group tableGroup = new Group(this, SWT.BORDER); + tableGroup.setText(tableGroupLabel); + gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + tableGroup.setLayoutData(gridData); + 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 = new GridData(SWT.FILL, SWT.FILL, true, true); + gridData.horizontalSpan = 3; + gridData.minimumWidth = 200; + vmTable.setLayoutData(gridData); + vmTable.setHeaderVisible(true); + vmTable.setLinesVisible(true); + + // TableViewer on the table + final TableViewer tableViewer = new TableViewer(vmTable); + tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + + + + // For testing + ImageSummaryRead imageSummary = new ImageSummaryRead(); + imageSummary.setImageName("Windoof"); + imageSummary.setOsId(1); + LinkedList<ImageSummaryRead> list = new LinkedList<>(); + imageSummary.setUserPermissions(new ImagePermissions(true, true, false, false)); + imageSummary.setUpdateTime(505050550); + imageSummary.setOwnerId("2"); + imageSummary.setImageBaseId("8"); + imageSummary.setCurrentVersionId("8.12"); + list.add(imageSummary); + + ImageSummaryRead imageSummary2 = new ImageSummaryRead(); + imageSummary2.setImageName("Linuksch"); + imageSummary2.setOsId(2); + list.add(imageSummary2); + + // The List to be displayed in the viewer + tableViewer.setInput(list); + + VMColumns.createVMTableColumns(tableViewer); + + tableViewer.refresh(); + + // create, modify, download and delete buttons + Composite buttonComposite = new Composite(tableGroup, SWT.NONE); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.horizontalSpan = 4; + gridData.minimumWidth = 200; + buttonComposite.setLayoutData(gridData); + 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 clicked image in the tableViewer + Group vmInfoGroup = new Group(this, SWT.BORDER); + vmInfoGroup.setText(vmInfoGroupLabel); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 300; + vmInfoGroup.setLayoutData(gridData); + vmInfoGroup.setLayout(new GridLayout(2, false)); + + + // image name info + Label imageNameCaption = new Label(vmInfoGroup, SWT.NONE); + imageSelectedNameLabel = new Text(vmInfoGroup, SWT.READ_ONLY); + + imageNameCaption.setText("Image Name:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + imageSelectedNameLabel.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + String s = selectedElement.getImageName(); + if (s == null) { + imageSelectedNameLabel.setText("Unknown"); + } else { + imageSelectedNameLabel.setText(s); + } + } + }); + + + // id info + Label idInfoCaption = new Label(vmInfoGroup, SWT.NONE); + idInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + idInfoCaption.setText("ID:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + idInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + String s = selectedElement.getImageBaseId(); + if (s == null) { + idInfo.setText("Unknown"); + } else { + idInfo.setText(s); + } + } + }); + // imageSummary.get + + + + Label versionInfoCaption = new Label(vmInfoGroup, SWT.NONE); + versionInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + versionInfoCaption.setText("Version:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + versionInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + String s = selectedElement.getCurrentVersionId(); + if (s == null) { + versionInfo.setText("Unknown"); + } else { + versionInfo.setText(s); + } + } + }); + + + Label lastUpdateInfoCaption = new Label(vmInfoGroup, SWT.NONE); + lastUpdateInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + lastUpdateInfoCaption.setText("Letztes Update:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + lastUpdateInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + long unixTimestamp = selectedElement.getUpdateTime(); + + + if (unixTimestamp == 0) { + lastUpdateInfo.setText("Unknown"); + } else { + Date date = new Date(unixTimestamp*1000L); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String formattedDate = sdf.format(date); + lastUpdateInfo.setText(formattedDate); + } + } + }); + + Label permissionInfoCaption = new Label(vmInfoGroup, SWT.NONE); + permissionInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + permissionInfoCaption.setText("Berechtigungen:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + permissionInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + ImagePermissions p =selectedElement.getUserPermissions(); + if (p != null){ + String s = p.toString(); + if (s == null) { + permissionInfo.setText("Unknown"); + } else { + permissionInfo.setText(s); + } + } else { + permissionInfo.setText("Unknown"); + } + + } + }); + + + Label ownerInfoCaption = new Label(vmInfoGroup, SWT.NONE); + ownerInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + ownerInfoCaption.setText("Besitzer ID:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + ownerInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + + String s = selectedElement.getOwnerId(); + + if (s != null) { + ownerInfo.setText(s); + } else { + ownerInfo.setText("Unknown"); + } + + } + }); + + Label templateCaption = new Label(vmInfoGroup, SWT.NONE); + templateInfo = new Text(vmInfoGroup, SWT.READ_ONLY); + templateCaption.setText("Vorlage:"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.minimumWidth = 100; + templateInfo.setLayoutData(gridData); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) + tableViewer.getSelection(); + ImageSummaryRead selectedElement = (ImageSummaryRead) selection.getFirstElement(); + + if (selectedElement.isTemplate) { + templateInfo.setText("ja"); + } else { + templateInfo.setText("Nein"); + } + } + }); + + + newButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ImageWizard wizard = new ImageWizard(false); + WizardDialog wd = new WizardDialog(getShell(), wizard); + wd.open(); + } + }); + + editButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ImageWizard wizard = new ImageWizard(true); + WizardDialog wd = new WizardDialog(getShell(), wizard); + wd.open(); + } + }); + + + } +} diff --git a/dozentenmodul/src/main/java/gui/core/LoginComposite.java b/dozentenmodul/src/main/java/gui/core/LoginComposite.java index 060b1c61..7c4f92f4 100644 --- a/dozentenmodul/src/main/java/gui/core/LoginComposite.java +++ b/dozentenmodul/src/main/java/gui/core/LoginComposite.java @@ -15,6 +15,7 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; public class LoginComposite extends Composite { @@ -27,6 +28,7 @@ public class LoginComposite extends Composite { protected LOGIN_TYPE loginType = LOGIN_TYPE.BWIDM; private Image titleImage; + // textfields for the username/password protected Text usernameText; @@ -70,6 +72,7 @@ public class LoginComposite extends Composite { gridData.horizontalAlignment = SWT.CENTER; titlePicture.setLayoutData(gridData); + // group for the authentication method. // groups have borders and a title Group authGroup = new Group(this, SWT.NONE); diff --git a/dozentenmodul/src/main/java/gui/core/MainWindowComposite.java b/dozentenmodul/src/main/java/gui/core/MainWindowComposite.java index 278e420e..fe24a610 100644 --- a/dozentenmodul/src/main/java/gui/core/MainWindowComposite.java +++ b/dozentenmodul/src/main/java/gui/core/MainWindowComposite.java @@ -2,6 +2,8 @@ package gui.core; +import gui.GuiManager; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -16,10 +18,14 @@ import org.eclipse.swt.widgets.Shell; public class MainWindowComposite extends Composite { // text for info for the vms selection - String vmInfo = "Infotext VMs."; + protected String vmInfo = "Infotext VMs."; // text for the info for the lecture selection - String lecturesInfo = "Infotext Veranstaltungen."; + protected String lecturesInfo = "Infotext Veranstaltungen."; + + // buttons + protected Button vmButton; + protected Button lecturesButton; public MainWindowComposite(final Shell mainShell) { super(mainShell, SWT.NONE); @@ -33,7 +39,7 @@ public class MainWindowComposite extends Composite { GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); vmGroup.setLayoutData(gridData); - Button vmButton = new Button(vmGroup, SWT.PUSH); + vmButton = new Button(vmGroup, SWT.PUSH); vmButton.setText("VM - Übersicht"); gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true); vmButton.setLayoutData(gridData); @@ -54,7 +60,7 @@ public class MainWindowComposite extends Composite { - Button lecturesButton = new Button(lecturesGroup, SWT.PUSH); + lecturesButton = new Button(lecturesGroup, SWT.PUSH); lecturesButton.setText("Veranstanstaltungen"); gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true); lecturesButton.setLayoutData(gridData); @@ -93,7 +99,7 @@ public class MainWindowComposite extends Composite { * function for the VMButton */ protected void clickedVMButton() { - System.out.println("VM-Button clicked!"); + GuiManager.addContent(new ImageWindowComposite(getShell())); } /** diff --git a/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java b/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java index 594634f8..7ccd68c5 100644 --- a/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java +++ b/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java @@ -25,6 +25,11 @@ public class VMWareInfoComposite extends Composite { String infoTitle = "bwLehrpool Suite"; + protected Button windowsDLButton; + protected Button linuxDLButton; + protected Button readCheck; + protected Button continueButton; + public VMWareInfoComposite(final Shell mainShell) { super(mainShell, SWT.NONE); @@ -57,7 +62,7 @@ public class VMWareInfoComposite extends Composite { windowsComposite.setLayoutData(gridData); new Label(windowsComposite, SWT.NONE).setText("Windows:"); - Button windowsDLButton = new Button(windowsComposite, SWT.PUSH); + windowsDLButton = new Button(windowsComposite, SWT.PUSH); windowsDLButton.setText("VMWare Player Herunterladen"); @@ -68,25 +73,25 @@ public class VMWareInfoComposite extends Composite { linuxComposite.setLayoutData(gridData); new Label(windowsComposite, SWT.NONE).setText("Linux:"); - Button linuxDLButton = new Button(windowsComposite, SWT.PUSH); + linuxDLButton = new Button(windowsComposite, SWT.PUSH); linuxDLButton.setText("VMWare Player Herunterladen"); - Button readCheck = new Button(this, SWT.CHECK); + readCheck = new Button(this, SWT.CHECK); readCheck.setText("Diese Benachrichtigung nicht mehr anzeigen."); gridData = new GridData(GridData.BEGINNING, GridData.END, false, false); readCheck.setLayoutData(gridData); - Button continuteButton = new Button(this, SWT.PUSH); - continuteButton.setText("Weiter"); + continueButton = new Button(this, SWT.PUSH); + continueButton.setText("Weiter"); gridData = new GridData(GridData.BEGINNING, GridData.END, false, false); - continuteButton.setLayoutData(gridData); + continueButton.setLayoutData(gridData); // TODO still looks very ugly // function for agreement checkbox - continuteButton.addSelectionListener(new SelectionAdapter() { + continueButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { clickedContinueButton(); diff --git a/dozentenmodul/src/main/java/gui/helper/VMColumns.java b/dozentenmodul/src/main/java/gui/helper/VMColumns.java new file mode 100644 index 00000000..9e73c307 --- /dev/null +++ b/dozentenmodul/src/main/java/gui/helper/VMColumns.java @@ -0,0 +1,81 @@ +package gui.helper; + +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.openslx.bwlp.dozmod.thrift.MetaDataCache; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; +import org.openslx.bwlp.thrift.iface.OperatingSystem; +import org.openslx.bwlp.thrift.iface.UserInfo; + + +public final class VMColumns { + private VMColumns(){}; + + private static void createColumn(TableViewer table, String colName, int width, ColumnLabelProvider provider){ + TableViewerColumn col = new TableViewerColumn(table, SWT.NONE); + col.getColumn().setWidth(width); + col.getColumn().setText(colName); + col.setLabelProvider(provider); + + } + + /** + * create the columns for the table in the VM mainwindow + * @param table the tableViewer + */ + public static void createVMTableColumns(TableViewer table){ + createColumn(table, "Name", 150, new ColumnLabelProvider() { + @Override + public String getText(Object element) { + ImageSummaryRead image = (ImageSummaryRead) element; + return image.getImageName(); + } + }); + + + + createColumn(table, "OS", 90, new ColumnLabelProvider() { + @Override + public String getText(Object element) { + // TODO remove and uncomment when deploying + ImageSummaryRead image = (ImageSummaryRead) element; + //OperatingSystem os = MetaDataCache.getOsById(image.getOsId()); + + OperatingSystem os = null ; + if (os == null) { + return "Unknown"; + } else { + return os.getOsName(); + } + } + }); + + createColumn(table, "Verantwortlicher", 130, new ColumnLabelProvider() { + @Override + public String getText(Object element) { + ImageSummaryRead image = (ImageSummaryRead) element; + return image.getOwnerId(); + } + }); + + createColumn(table, "Letztes Update", 110, new ColumnLabelProvider() { + @Override + public String getText(Object element) { + ImageSummaryRead image = (ImageSummaryRead) element; + return String.valueOf(image.getUpdateTime()); + } + }); + + createColumn(table, "Größe", 80, new ColumnLabelProvider() { + @Override + public String getText(Object element) { + ImageSummaryRead image = (ImageSummaryRead) element; + return String.valueOf(image.getFileSize()); + } + }); + + + }; +} diff --git a/dozentenmodul/src/main/java/org/openslx/bwlp/dozmod/thrift/MetaDataCache.java b/dozentenmodul/src/main/java/org/openslx/bwlp/dozmod/thrift/MetaDataCache.java index fd4b7172..726dfd3d 100644 --- a/dozentenmodul/src/main/java/org/openslx/bwlp/dozmod/thrift/MetaDataCache.java +++ b/dozentenmodul/src/main/java/org/openslx/bwlp/dozmod/thrift/MetaDataCache.java @@ -50,6 +50,16 @@ public class MetaDataCache { return osCache.get(); } + public static OperatingSystem getOsById(int id){ + List<OperatingSystem> list = getOperatingSystems(); + if (list == null) + return null; + for (OperatingSystem os : list) { + if (os.getOsId() == id) return os; + } + return null; + } + /** * Get all supported virtualizers an image can be declared to be run as. * diff --git a/dozentenmodul/src/main/java/wizards/ImageMetaDataPage.java b/dozentenmodul/src/main/java/wizards/ImageMetaDataPage.java new file mode 100644 index 00000000..4f267dda --- /dev/null +++ b/dozentenmodul/src/main/java/wizards/ImageMetaDataPage.java @@ -0,0 +1,109 @@ +package wizards; + + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + + + +public class ImageMetaDataPage extends WizardPage { + + protected Composite container; + + protected Combo osCombo; + protected Text descriptionText; + protected Button licencedSoftwareCheck; + protected Button licenceServerButton; + + // permissions checks + protected Button readPermissionsCheck; + protected Button writePermissionsCheck; + protected Button linkPermissionsCheck; + protected Button adminPermissionsCheck; + + + + /** + * wizard page for entering image data at creating or editing an image + */ + public ImageMetaDataPage() { + super("Eingabe Ihrer Daten"); + setTitle("Eingabe Ihrer Daten"); + setDescription("Geben Sie bitte einen aussagekräftigen Namen für das neue Image ein."); + } + + + + @Override + public void createControl(Composite parent) { + container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + + + + Label osCaption = new Label(container, SWT.NONE); + osCaption.setText("Betriebssystem:"); + osCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); + + Label descriptionCation = new Label(container, SWT.NONE); + descriptionCation.setText("Beschreibung:"); + descriptionText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.heightHint = 80; + descriptionText.setLayoutData(gd); + + Label licencedSoftwareCaption = new Label(container, SWT.NONE); + licencedSoftwareCaption.setText("Image enthält lizensierte Software:"); + licencedSoftwareCheck = new Button(container, SWT.CHECK); + + + Label licenceServerCaption = new Label(container, SWT.NONE); + licenceServerCaption.setText("Lizenzserver:"); + licenceServerButton = new Button(container, SWT.PUSH); + licenceServerButton.setText("Server-Adresse"); + + + Group permissionsGroup = new Group(container, SWT.BORDER); + gd = new GridData(); + gd.horizontalSpan = 2; + permissionsGroup.setLayoutData(gd); + + + permissionsGroup.setText("Standart Berechtigungen"); + permissionsGroup.setLayout(new GridLayout(4, true)); + + readPermissionsCheck = new Button(permissionsGroup, SWT.CHECK); + readPermissionsCheck.setText("Lesen"); + writePermissionsCheck = new Button(permissionsGroup, SWT.CHECK); + writePermissionsCheck.setText("Schreiben"); + linkPermissionsCheck = new Button(permissionsGroup, SWT.CHECK); + linkPermissionsCheck.setText("Verlinken"); + adminPermissionsCheck = new Button(permissionsGroup, SWT.CHECK); + adminPermissionsCheck.setText("Admin"); + + + // required to avoid an error in the system + setControl(container); + setPageComplete(true); + } + + + public String getImageDescription() { + return descriptionText.getText(); + } + +} diff --git a/dozentenmodul/src/main/java/wizards/ImageUploadPage.java b/dozentenmodul/src/main/java/wizards/ImageUploadPage.java new file mode 100644 index 00000000..b4f36589 --- /dev/null +++ b/dozentenmodul/src/main/java/wizards/ImageUploadPage.java @@ -0,0 +1,87 @@ +package wizards; + + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + + + +public class ImageUploadPage extends WizardPage { + + protected Text imageName; + protected Composite container; + protected boolean editExistingImage; + protected Button imageFileBrowseButton; + + + + /** + * Page for uploading an imagefile + * @param editExistingImage wether to edit existing image file or create new one + */ + public ImageUploadPage(boolean editExistingImage) { + super("Eingabe Ihrer Daten"); + setTitle("Eingabe Ihrer Daten"); + setDescription("Geben Sie bitte einen aussagekräftigen Namen für das neue Image ein."); + this.editExistingImage = editExistingImage; + } + + + + @Override + public void createControl(Composite parent) { + container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + Label imageNameCaption= new Label(container, SWT.NONE); + imageNameCaption.setText("Name des Images"); + + + imageName = new Text(container, SWT.BORDER | SWT.SINGLE); + imageName.setText(""); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + imageName.setLayoutData(gd); + imageName.setEnabled(!editExistingImage); + System.out.println(editExistingImage); + + imageName.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (!imageName.getText().isEmpty()) { + setPageComplete(true); + } else { + setPageComplete(false); + } + } + }); + + Label imageFileCaption = new Label(container, SWT.NONE); + imageFileCaption.setText("Imagefile:"); + imageFileBrowseButton = new Button(container, SWT.PUSH); + imageFileBrowseButton.setText("Browse"); + + + // required to avoid an error in the system + setControl(container); + setPageComplete(editExistingImage); + } + + + public String getText1() { + return imageName.getText(); + } + +} diff --git a/dozentenmodul/src/main/java/wizards/ImageWizard.java b/dozentenmodul/src/main/java/wizards/ImageWizard.java new file mode 100644 index 00000000..1723a2d2 --- /dev/null +++ b/dozentenmodul/src/main/java/wizards/ImageWizard.java @@ -0,0 +1,47 @@ +package wizards; + +import org.eclipse.jface.wizard.Wizard; + +public class ImageWizard extends Wizard{ + + protected ImageUploadPage imageUploadPage; + protected ImageMetaDataPage imageMetaDataPage; + protected boolean editExistingImage; + + + + + /** + * Wizard for creating or editing an image + * @param editExistingImage wether to create new or edit existing image + */ + public ImageWizard(boolean editExistingImage) { + super(); + setNeedsProgressMonitor(true); + this.editExistingImage = editExistingImage; + } + + + @Override + public String getWindowTitle() { + return "Neues Image erzeugen"; + } + + + @Override + public void addPages() { + imageUploadPage = new ImageUploadPage(editExistingImage); + imageMetaDataPage = new ImageMetaDataPage(); + addPage(imageUploadPage); + addPage(imageMetaDataPage); + } + + + @Override + public boolean performFinish() { + // Print the result to the console + System.out.println(imageUploadPage.getText1()); + System.out.println(imageMetaDataPage.getImageDescription()); + return true; + } +} |