diff options
| author | Jonathan Bauer | 2015-07-09 16:08:06 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-07-09 16:08:06 +0200 |
| commit | e762621de49a3cc844f08f3f0359ff80b1b03498 (patch) | |
| tree | 96e86575f174e29f82d98f53d70bbeba015bd90a /dozentenmodul/src/main/java | |
| parent | [client] Support message boxes with feedback; ask user whether to retry on th... (diff) | |
| download | tutor-module-e762621de49a3cc844f08f3f0359ff80b1b03498.tar.gz tutor-module-e762621de49a3cc844f08f3f0359ff80b1b03498.tar.xz tutor-module-e762621de49a3cc844f08f3f0359ff80b1b03498.zip | |
[client] fixed buttons of disclaimer/vmware license
imagelistwindow first implementation with list refresh function
openPopups set dialogShell as child of mainShell
Diffstat (limited to 'dozentenmodul/src/main/java')
7 files changed, 83 insertions, 37 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GuiManager.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GuiManager.java index c1084fb1..ed34d1fd 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GuiManager.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GuiManager.java @@ -4,6 +4,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import org.apache.log4j.Logger; +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -27,6 +28,8 @@ public abstract class GuiManager { private static Shell mainShell; private static Composite contentComposite; private static Display display; + + private static final String THRIFT_CONNECTION_ERROR = "Lost connection to the masterserver. Do you want to retry?"; @@ -59,8 +62,13 @@ public abstract class GuiManager { } } - public static void openPopup(Class<?> clazz) { - Shell dialogShell = new Shell(display); + /** + * @param clazz Class to open as a popup over the main window + */ + public static void openPopup(Class<?> clazz, boolean modal) { + // TODO find the right style bits for a floating window + Shell dialogShell = new Shell(mainShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); + // TODO check if its a composite // populate dialogShell dialogShell.setLayout(new GridLayout(1, false)); LOGGER.debug(clazz.getDeclaredClasses()); @@ -78,13 +86,16 @@ public abstract class GuiManager { // TODO Auto-generated catch block e.printStackTrace(); } + dialogShell.layout(); dialogShell.pack(); dialogShell.open(); - while (!dialogShell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } + if (modal) { + while (!dialogShell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java index 6db29f15..dbd9c3cb 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java @@ -15,6 +15,7 @@ public class DisclaimerWindow extends DisclaimerWindowLayout{ public DisclaimerWindow(final Shell mainShell) { super(mainShell); + final DisclaimerWindow me = this; // function for agreement checkbox agreeBox.addSelectionListener(new SelectionAdapter() { @Override @@ -31,8 +32,7 @@ public class DisclaimerWindow extends DisclaimerWindowLayout{ if (!Config.setDisclaimerAgreement(true)) LOGGER.error("Could not set the agreement to the disclaimer in '" + Config.getPath() + "'!"); Config.store(); - // now check the config to see if the user has agreed to vmware stuff - GuiManager.addContent(new VirtualizerNoticeWindow(getShell())); + me.getParent().dispose(); } }); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java new file mode 100644 index 00000000..2df16976 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java @@ -0,0 +1,34 @@ +package org.openslx.dozmod.gui.window; + +import java.util.List; + +import org.apache.thrift.TException; +import org.eclipse.swt.widgets.Shell; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; +import org.openslx.dozmod.gui.window.layout.ImageListWindowLayout; +import org.openslx.dozmod.thrift.Session; +import org.openslx.thrifthelper.ThriftManager; + +public class ImageListWindow extends ImageListWindowLayout { + + public ImageListWindow(final Shell mainShell) { + super(mainShell); + + refreshList(); + } + + private boolean refreshList() { + List<ImageSummaryRead> imageList; + try { + imageList = ThriftManager.getSatClient().getImageList(Session.getSatelliteToken(), null, 0); + } catch (TException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } + tableViewer.setInput(imageList); + tableViewer.refresh(); + return true; + } + +} diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java index 3a87c73d..69393466 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java @@ -314,12 +314,14 @@ public class LoginWindow extends LoginWindowLayout { // TODO HACK HACK ThriftManager.setSatelliteAddress("132.230.8.113"); + GuiManager.addContent(new MainWindow(getShell())); // now read the config to see if the user already agreed to the disclaimer if (!Config.getDisclaimerAgreement()) - GuiManager.addContent(new DisclaimerWindow(getShell())); - else if (!Config.getVmwareLicenseAgreement()) - GuiManager.addContent(new VirtualizerNoticeWindow(getShell())); + GuiManager.openPopup(DisclaimerWindow.class, true); + if (!Config.getVmwareLicenseAgreement()) + GuiManager.openPopup(VirtualizerNoticeWindow.class, true); // TODO: See MainWindowLayout comments + } /** diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainWindow.java index 86e7caea..195f748f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainWindow.java @@ -1,6 +1,9 @@ package org.openslx.dozmod.gui.window; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Shell; +import org.openslx.dozmod.gui.helper.GuiManager; import org.openslx.dozmod.gui.window.layout.MainWindowLayout; public class MainWindow extends MainWindowLayout { @@ -8,6 +11,21 @@ public class MainWindow extends MainWindowLayout { public MainWindow(Shell mainShell) { super(mainShell); // TODO Auto-generated constructor stub + // function for vmButton + vmButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + GuiManager.addContent(new ImageListWindow(getShell())); + } + }); + + // function for lecturesButton + lecturesButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // + } + }); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java index 177957bc..6961b396 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java @@ -14,6 +14,8 @@ public class VirtualizerNoticeWindow extends VirtualizerNoticeWindowLayout { public VirtualizerNoticeWindow(final Shell mainShell) { super(mainShell); + final VirtualizerNoticeWindow me = this; + // function for agreement checkbox continueButton.addSelectionListener(new SelectionAdapter() { @Override @@ -21,7 +23,7 @@ public class VirtualizerNoticeWindow extends VirtualizerNoticeWindowLayout { if (!Config.setVmwareLicenseAgreement(true)) LOGGER.error("Could not set the agreement to the vmware license in '" + Config.getPath() + "'!"); Config.store(); - // TODO GuiManager.addContent(new MainWindowLayout(getShell())); + me.getParent().dispose(); } }); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java index 99d97eac..0d242b75 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java @@ -3,7 +3,6 @@ package org.openslx.dozmod.gui.window.layout; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.LinkedList; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -56,11 +55,13 @@ public abstract class ImageListWindowLayout extends Composite { 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(Composite mainShell) { + public ImageListWindowLayout(final Composite mainShell) { super(mainShell, SWT.NONE); this.setLayout(new GridLayout(2, false)); @@ -107,31 +108,9 @@ public abstract class ImageListWindowLayout extends Composite { vmTable.setLinesVisible(true); // TableViewer on the table - final TableViewer tableViewer = new TableViewer(vmTable); + 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); - TableHelper.createImageTableColumns(tableViewer); tableViewer.refresh(); |
