diff options
author | Simon Rettberg | 2015-08-13 18:41:49 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-13 18:41:49 +0200 |
commit | 0d5e03a3d23167cabc9fc82d64d10d15ac8a0b22 (patch) | |
tree | f6f26e6f837b47289a6433cd1fbf1de43cf6434b | |
parent | [server] Don't mix seconds and milliseconds (diff) | |
download | tutor-module-0d5e03a3d23167cabc9fc82d64d10d15ac8a0b22.tar.gz tutor-module-0d5e03a3d23167cabc9fc82d64d10d15ac8a0b22.tar.xz tutor-module-0d5e03a3d23167cabc9fc82d64d10d15ac8a0b22.zip |
[client] Layout; don't close lecture wizard if creation failed
9 files changed, 23 insertions, 29 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index 36b4b43a..871b218c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -232,7 +232,7 @@ public abstract class MainWindow { Session.initialize(whoami, session.address, session.token, session.masterToken); ThriftManager.setSatelliteAddress(Session.getSatelliteAddress()); LOGGER.info("Saved session used for resume."); - } catch (TException e1) { + } catch (Exception e1) { LOGGER.info("Session resume failed.", e1); } } 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 16359b32..4112974d 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 @@ -44,7 +44,6 @@ import org.openslx.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; -import org.openslx.util.Util; import edu.kit.scc.dei.ecplean.ECPAuthenticationException; @@ -127,7 +126,6 @@ public class LoginWindow extends LoginWindowLayout { @Override public void fire() { - Util.sleep(2000); try { // Wait for proxy server init App.waitForInit(); @@ -352,7 +350,7 @@ public class LoginWindow extends LoginWindowLayout { // TODO: Show satellite selection if > 1 //String satAddress = data.satellites.get(0).addressList.get(0); - String satAddress = "132.230.8.113"; + String satAddress = "132.230.8.113"; // TODO: HACK HACK Client client = ThriftManager.getNewSatClient(satAddress); if (client == null) { Gui.showMessageBox(this, "Login erfolgreich, aber der Satellit antwortet nicht", diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java index 8c0b5605..ebd0da26 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java @@ -1,22 +1,16 @@ package org.openslx.dozmod.gui.window.layout; -import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; import java.awt.Rectangle; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.DefaultListCellRenderer; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; -import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JRadioButton; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java index c008dbfe..c57018e5 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java @@ -3,6 +3,7 @@ package org.openslx.dozmod.gui.wizard; import java.awt.Window; import org.apache.log4j.Logger; +import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.LectureWrite; import org.openslx.dozmod.gui.Gui; @@ -16,6 +17,7 @@ import org.openslx.dozmod.gui.wizard.page.LectureOptionsPage; import org.openslx.dozmod.state.LectureWizardState; import org.openslx.dozmod.thrift.LectureCache; import org.openslx.dozmod.thrift.Session; +import org.openslx.dozmod.thrift.ThriftError; import org.openslx.thrifthelper.ThriftManager; @SuppressWarnings("serial") @@ -72,32 +74,31 @@ public class LectureWizard extends Wizard implements UiFeedback { // since we only started the upload and created a "blank" image entry // we can here do all the sanity checks on the fields of UploadWizardState // and react accordingly. - return isStateValid(); - } - - @Override - public void performFinish() { - // TODO evaluate table state and create the map of permissions - // TODO run the actually request over external threaded class + if (!isStateValid()) + return false; + // Now try to submit if (state.uuid != null) { // already got a uuid, this is bad as we were about to do it! LOGGER.error("UUID for new lecture already present, something's bad..."); - return; + return true; } // ok, lets create it try { // push to sat state.uuid = ThriftManager.getSatClient().createLecture(Session.getSatelliteToken(), lectureWriteFromState()); - } catch (Exception e) { - Gui.showMessageBox(this, "Fail to create lecture: ", MessageType.ERROR, LOGGER, e); - return; + } catch (TException e) { + ThriftError.showMessage(this, LOGGER, e, "Fail to create lecture"); + return false; } if (Gui.showMessageBox(this, "Veranstaltung erstellt! Wollen Sie zur Übersicht wechseln?", MessageType.QUESTION_YESNO, null, null)) { LectureCache.get(true); MainWindow.showPage(LectureListWindow.class); } + // TODO evaluate table state and create the map of permissions + // TODO run the actually request over external threaded class + return true; } private boolean isStateValid() { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java index f282cf7f..c997d4a6 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java @@ -6,15 +6,12 @@ import java.util.Date; import java.util.Properties; import javax.swing.Box; -import javax.swing.JCheckBox; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SpinnerDateModel; -import javax.swing.border.TitledBorder; import javax.swing.text.DateFormatter; import org.jdatepicker.impl.JDatePanelImpl; @@ -35,7 +32,6 @@ public abstract class LectureCreationPageLayout extends WizardPage { protected JSpinner startTime; protected JSpinner endTime; - private static final Properties pickerStrings = new Properties(); static { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java index 31e1b837..cd26da82 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java @@ -13,7 +13,6 @@ import javax.swing.event.DocumentListener; import org.apache.log4j.Logger; import org.jdatepicker.impl.JDatePickerImpl; -import org.openslx.bwlp.thrift.iface.LecturePermissions; import org.openslx.dozmod.gui.wizard.Wizard; import org.openslx.dozmod.gui.wizard.layout.LectureCreationPageLayout; import org.openslx.dozmod.state.LectureWizardState; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java index a32ff0c7..f96cedea 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java @@ -19,6 +19,8 @@ public class LectureOptionsPage extends LectureOptionsPageLayout { public LectureOptionsPage(Wizard wizard, LectureWizardState state) { super(wizard); this.state = state; + editPermissionsCheck.setSelected(state.defaultPermissions.edit); + adminPermissionsCheck.setSelected(state.defaultPermissions.admin); setPageComplete(true); } @@ -36,8 +38,8 @@ public class LectureOptionsPage extends LectureOptionsPageLayout { state.internetAccess = networkAccessCheck.isSelected(); state.isEnabled = enabledCheck.isSelected(); - state.defaultPermissions = new LecturePermissions(editPermissionsCheck.isSelected(), - adminPermissionsCheck.isSelected()); + state.defaultPermissions.edit = editPermissionsCheck.isSelected(); + state.defaultPermissions.admin = adminPermissionsCheck.isSelected(); setDescription("Klicken Sie auf 'Weiter' für Berechtigungen oder 'Fertigstellen'"); return true; } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java index f506ce8d..bb64bf77 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java @@ -5,6 +5,7 @@ import java.util.Map; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.LecturePermissions; +import org.openslx.dozmod.thrift.Session; public class LectureWizardState { @@ -20,7 +21,7 @@ public class LectureWizardState { public Date end = null; // default permissions assigned to that lecture by the user // TODO: defaults per sat - public LecturePermissions defaultPermissions = null; + public LecturePermissions defaultPermissions = Session.getSatelliteConfig().defaultLecturePermissions; // explicit permissions per user as set by the creator public Map<String, LecturePermissions> permissionList = null; // -- thrift internal stuff -- diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java index fcee1448..ad2511ce 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftError.java @@ -7,6 +7,7 @@ import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.AuthorizationError; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.bwlp.thrift.iface.TInternalServerError; +import org.openslx.bwlp.thrift.iface.TInvalidDateParam; import org.openslx.bwlp.thrift.iface.TNotFoundException; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.MessageType; @@ -21,6 +22,8 @@ public class ThriftError { messageText += "\n\nZugriff verweigert: " + reason + "\n" + ex.getMessage(); } else if (ex instanceof TInternalServerError) { messageText += "\n\nEin serverseitiger Fehler ist aufgetreten. Bitte kontaktieren Sie den lokalen Support."; + } else if (ex instanceof TInvalidDateParam) { + messageText += "\n\nEin angegebenes Datum ist ungültig:\n" + ex.getMessage(); } else { messageText += "\n\nUnerwartete Ausnahme " + ex.getClass().getSimpleName() + " ist aufgetreten."; } |