summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-30 16:20:03 +0200
committerSimon Rettberg2015-07-30 16:20:03 +0200
commit0aa11d89887ed78f3e8b7de5e57e7ef511556f49 (patch)
tree8673ec1685fd1f4de46e525b0750111b8a05a611 /dozentenmodul/src/main/java
parent[client] Started porting wizards to Swing (diff)
downloadtutor-module-0aa11d89887ed78f3e8b7de5e57e7ef511556f49.tar.gz
tutor-module-0aa11d89887ed78f3e8b7de5e57e7ef511556f49.tar.xz
tutor-module-0aa11d89887ed78f3e8b7de5e57e7ef511556f49.zip
[client] Continued implementation of Wizard
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/App.java3
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java5
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImagePermissionTable.java31
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java2
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/TableHelper.java2
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserImagePermissions.java19
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserToPermissionLink.java36
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java4
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java27
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java4
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java74
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java25
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageCustomPermissionPageLayout.java56
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java8
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java6
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageCustomPermissionPage.java180
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java5
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java6
18 files changed, 204 insertions, 289 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
index 094678f4..fb789811 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
@@ -19,6 +19,7 @@ import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.util.ProxyConfigurator;
import org.openslx.thrifthelper.ThriftManager;
+import org.openslx.util.Util;
public class App {
@@ -135,7 +136,7 @@ public class App {
MainWindow.open();
}
});
-
+ Util.sleep(1000);
}
/**
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
index a7688791..6e9870d0 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
@@ -256,7 +256,10 @@ public class Gui {
public static boolean showMessageBox(Component parent, String message, MessageType messageType,
Logger logger, Throwable exception) {
if (parent != null) {
- parent = SwingUtilities.getWindowAncestor(parent);
+ Window ancestor = SwingUtilities.getWindowAncestor(parent);
+ if (ancestor != null) {
+ parent = ancestor;
+ }
}
if (logger != null)
logger.log(messageType.logPriority, message, exception);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImagePermissionTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImagePermissionTable.java
new file mode 100644
index 00000000..bc928436
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImagePermissionTable.java
@@ -0,0 +1,31 @@
+package org.openslx.dozmod.gui.control.table;
+
+import org.openslx.dozmod.gui.helper.UserImagePermissions;
+import org.openslx.dozmod.thrift.UserCache;
+
+@SuppressWarnings("serial")
+public class ImagePermissionTable extends ListTable<UserImagePermissions> {
+
+ private static String[] columnNames = { "Benutzer", "Link", "Download", "Bearbeiten", "Admin" };
+
+ public ImagePermissionTable() {
+ super(columnNames);
+ }
+
+ @Override
+ protected Object getValueAtInternal(int rowIndex, int columnIndex) {
+ UserImagePermissions row = get(rowIndex);
+ if (columnIndex == 0)
+ return UserCache.find(row.userId);
+ if (columnIndex == 1)
+ return row.permissions.link;
+ if (columnIndex == 2)
+ return row.permissions.download;
+ if (columnIndex == 3)
+ return row.permissions.edit;
+ if (columnIndex == 4)
+ return row.permissions.admin;
+ throw new IndexOutOfBoundsException();
+ }
+
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java
index 6cb5bfe0..4c562ece 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java
@@ -21,7 +21,7 @@ public class GridPos {
wy = 1;
}
return new GridBagConstraints(cellX, cellY, spanX, spanY, wx, wy,
- GridBagConstraints.FIRST_LINE_START, fill, inset, 0, 0);
+ GridBagConstraints.LINE_START, fill, inset, 0, 0);
}
public static GridBagConstraints get(int cellX, int cellY, int spanX, int spanY) {
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/TableHelper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/TableHelper.java
index 59677b48..7dc79db5 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/TableHelper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/TableHelper.java
@@ -138,7 +138,7 @@ public final class TableHelper {
new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- UserToPermissionLink userPerms = (UserToPermissionLink) element;
+ UserImagePermissions userPerms = (UserImagePermissions) element;
UserInfo user = UserCache.find(userPerms.getUserId());
return FormatHelper.userName(user);
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserImagePermissions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserImagePermissions.java
new file mode 100644
index 00000000..30ad7459
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserImagePermissions.java
@@ -0,0 +1,19 @@
+package org.openslx.dozmod.gui.helper;
+
+import org.openslx.bwlp.thrift.iface.ImagePermissions;
+
+/**
+ * Helper class for linking UserIds to permissions of an image.
+ */
+public class UserImagePermissions {
+
+ public final String userId;
+ public final ImagePermissions permissions;
+
+
+ public UserImagePermissions(String userId, ImagePermissions permission){
+ this.userId = userId;
+ this.permissions = permission;
+ }
+
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserToPermissionLink.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserToPermissionLink.java
deleted file mode 100644
index 8d14cf37..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/UserToPermissionLink.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.openslx.dozmod.gui.helper;
-
-import org.eclipse.swt.widgets.Button;
-import org.openslx.bwlp.thrift.iface.ImagePermissions;
-
-/**
- * Helper class for linking UserIds to permissions of an image.
- */
-public class UserToPermissionLink {
-
- private String userId;
- private ImagePermissions permission;
-
- public Button[] buttons = new Button[4];
-
- public UserToPermissionLink(String userId, ImagePermissions permission){
- this.setUserId(userId);
- this.setPermission(permission);
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public ImagePermissions getPermission() {
- return permission;
- }
-
- public void setPermission(ImagePermissions permission) {
- this.permission = permission;
- }
-}
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
index 7211a7c2..87923761 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
@@ -7,6 +7,7 @@ import java.awt.event.MouseEvent;
import java.util.List;
import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
@@ -18,6 +19,7 @@ import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.window.layout.ImageListWindowLayout;
+import org.openslx.dozmod.gui.wizard.ImageWizard;
import org.openslx.dozmod.thrift.ImageCache;
import org.openslx.dozmod.thrift.UserCache;
import org.openslx.dozmod.util.FormatHelper;
@@ -104,7 +106,7 @@ public class ImageListWindow extends ImageListWindowLayout {
newButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- // TODO open wizard for image creation
+ new ImageWizard(SwingUtilities.getWindowAncestor(me)).setVisible(true);
}
});
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
index 4a09aa00..33cdea74 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
@@ -1,6 +1,6 @@
package org.openslx.dozmod.gui.wizard;
-import javax.swing.JFrame;
+import java.awt.Window;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
@@ -15,11 +15,12 @@ import org.openslx.dozmod.state.UploadWizardState;
import org.openslx.dozmod.thrift.Session;
import org.openslx.thrifthelper.ThriftManager;
+@SuppressWarnings("serial")
public class ImageWizard extends Wizard {
private final static Logger LOGGER = Logger.getLogger(ImageWizard.class);
- private UploadWizardState uploadWizardState;
+ private final UploadWizardState uploadWizardState = new UploadWizardState();;
protected ImageUploadPage imageUploadPage;
protected ImageMetaDataPage imageMetaDataPage;
protected ImageCustomPermissionPage imageCustomPermissionPage;
@@ -29,26 +30,19 @@ public class ImageWizard extends Wizard {
*
* @param editExistingImage whether to create new or edit existing image
*/
- public ImageWizard(JFrame parent) {
+ public ImageWizard(Window parent) {
super(parent);
- this.uploadWizardState = new UploadWizardState();
+ imageUploadPage = new ImageUploadPage(this, uploadWizardState);
+ imageMetaDataPage = new ImageMetaDataPage(this, uploadWizardState);
+ imageCustomPermissionPage = new ImageCustomPermissionPage(this, uploadWizardState);
+ addPage(imageUploadPage);
+ addPage(imageMetaDataPage);
+ addPage(imageCustomPermissionPage);
}
@Override
public String getWindowTitle() {
return "Neues Image erzeugen";
-
- }
-
- @Override
- public void addPages() {
- // create the shared object for all pages of the wizard
- imageUploadPage = new ImageUploadPage(uploadWizardState);
- imageMetaDataPage = new ImageMetaDataPage(uploadWizardState);
- imageCustomPermissionPage = new ImageCustomPermissionPage(uploadWizardState);
- addPage(imageUploadPage);
- addPage(imageMetaDataPage);
- addPage(imageCustomPermissionPage);
}
@Override
@@ -98,7 +92,6 @@ public class ImageWizard extends Wizard {
Gui.showMessageBox(this, "Creation of image worked :)", MessageType.INFO, LOGGER, null);
return true;
-
}
private boolean isStateValid() {
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 e34d93b3..1cf5dcb6 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
@@ -1,6 +1,6 @@
package org.openslx.dozmod.gui.wizard;
-import javax.swing.JFrame;
+import java.awt.Window;
import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.wizard.layout.LectureCreationPageLayout;
@@ -19,7 +19,7 @@ public class LectureWizard extends Wizard {
* Wizard for creating or editing a lecture
* @param editExistingLecture whether to create new or edit existing lecture
*/
- public LectureWizard(JFrame parent, boolean editExistingLecture) {
+ public LectureWizard(Window parent, boolean editExistingLecture) {
super(parent);
this.editExistingLecture = editExistingLecture;
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java
index cf785d7c..ac77dfb6 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java
@@ -1,13 +1,69 @@
package org.openslx.dozmod.gui.wizard;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Window;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
import javax.swing.JDialog;
-import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.openslx.dozmod.gui.MainWindow;
@SuppressWarnings("serial")
-public abstract class Wizard extends JDialog {
+public class Wizard extends JDialog {
- public Wizard(JFrame parent) {
+ private final JLabel titleLabel;
+ private final JLabel messageLabel;
+ private final List<WizardPage> pages = new ArrayList<>();
+ private final JPanel contentPanel;
+
+ public Wizard(Window parent) {
super(parent, ModalityType.APPLICATION_MODAL);
+ setLayout(new BorderLayout());
+ JPanel header = new JPanel();
+ header.setMinimumSize(new Dimension(0, 100));
+ header.setOpaque(true);
+ header.setBackground(Color.WHITE);
+ header.setLayout(new BoxLayout(header, BoxLayout.PAGE_AXIS));
+ header.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ // Labels in header
+ titleLabel = new JLabel("<title>");
+ messageLabel = new JLabel("<message>");
+ titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
+ titleLabel.setForeground(Color.BLACK);
+ messageLabel.setForeground(Color.BLACK);
+ header.add(titleLabel);
+ header.add(messageLabel);
+ // Add header
+ getContentPane().add(header, BorderLayout.PAGE_START);
+ // Add content panel
+ contentPanel = new JPanel();
+ contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));
+ contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ add(contentPanel, BorderLayout.CENTER);
+ //
+ setPreferredSize(new Dimension(550, 420));
+ setResizable(false);
+ MainWindow.centerShell(this);
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowOpened(WindowEvent e) {
+ if (!pages.isEmpty()) {
+ WizardPage page = pages.get(0);
+ page.setVisible(true);
+ }
+ e.getWindow().pack();
+ }
+ });
}
public String getWindowTitle() {
@@ -15,10 +71,12 @@ public abstract class Wizard extends JDialog {
return null;
}
- protected abstract void addPages();
-
protected final void addPage(WizardPage page) {
- // TODO Auto-generated method stub
+ contentPanel.add(page);
+ if (!pages.isEmpty()) {
+ page.setVisible(false);
+ }
+ pages.add(page);
}
/**
@@ -34,12 +92,12 @@ public abstract class Wizard extends JDialog {
void updateHeader() {
// TODO Auto-generated method stub
-
+
}
void updateButtons() {
// TODO Auto-generated method stub
-
+
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java
index 880e3eae..52b6f85b 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java
@@ -14,7 +14,7 @@ public abstract class WizardPage extends JPanel {
private boolean isComplete = false;
- private Wizard wizard = null;
+ private final Wizard wizard;
/**
* Whether the user is allowed to go back to this page once they clicked
@@ -22,7 +22,10 @@ public abstract class WizardPage extends JPanel {
*/
protected boolean canComeBack = true;
- public WizardPage(String title) {
+ public WizardPage(Wizard wizard, String title) {
+ if (wizard == null)
+ throw new NullPointerException("WizardPage needs a Wizard");
+ this.wizard = wizard;
this.title = title;
}
@@ -52,7 +55,8 @@ public abstract class WizardPage extends JPanel {
}
/**
- * Called when the page is being shown. This can be caused by three possible events:
+ * Called when the page is being shown. This can be caused by three possible
+ * events:
* 1) The wizard opens and this is the fist page
* 2) The user clicked "Previous" and this is the previous page
* 3) The user clicked "Next" and this is the next page
@@ -61,14 +65,15 @@ public abstract class WizardPage extends JPanel {
}
/**
- * Called when the page is being hidden. This can be caused by three possible events:
+ * Called when the page is being hidden. This can be caused by three
+ * possible events:
* 1) The user clicked finish and this is the page currently displayed
* 2) The user clicked "Previous" and this is the current page
* 3) The user clicked "Next" and this is the current page
*/
protected void onPageLeave() {
}
-
+
/*
* Setters from derived classes
*/
@@ -96,14 +101,4 @@ public abstract class WizardPage extends JPanel {
this.updateHeader();
}
- /*
- * Setters from Wizard
- */
-
- void setWizard(Wizard wizard) {
- if (this.wizard != null)
- throw new IllegalStateException("Parent Wizard already set");
- this.wizard = wizard;
- }
-
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageCustomPermissionPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageCustomPermissionPageLayout.java
index 311f6684..ab69fa6e 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageCustomPermissionPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageCustomPermissionPageLayout.java
@@ -1,59 +1,45 @@
package org.openslx.dozmod.gui.wizard.layout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-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.Table;
+import javax.swing.JButton;
+import javax.swing.JScrollPane;
-public class ImageCustomPermissionPageLayout extends WizardPage {
+import org.openslx.dozmod.gui.control.table.ImagePermissionTable;
+import org.openslx.dozmod.gui.helper.GridPos;
+import org.openslx.dozmod.gui.wizard.Wizard;
+import org.openslx.dozmod.gui.wizard.WizardPage;
- protected Composite container;
+@SuppressWarnings("serial")
+public class ImageCustomPermissionPageLayout extends WizardPage {
// The table stuff
- protected Table permissionTable;
- protected TableViewer permissionTableViewer;
+ protected ImagePermissionTable permissionTable;
// Buttons
- protected Button addUser;
- protected Button removeUser;
+ protected JButton addUser;
+ protected JButton removeUser;
protected String addUserLabel = "Benutzer Hinzufügen";
protected String removeUserLabel = "Benutzer entfernen";
-
/**
* wizard page for setting custom permissions
+ *
+ * @param wizard
*/
- public ImageCustomPermissionPageLayout() {
- super("Eingabe Ihrer Daten", "Eingabe Ihrer Daten", null);
+ public ImageCustomPermissionPageLayout(Wizard wizard) {
+ super(wizard, "Benutzerspezifische Rechte setzen");
setDescription("Setzen Sie hier spezielle Berechtigungen, sofern Sie dies wünschen.");
- }
-
- @Override
- public void createControl(Composite parent) {
- container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 2;
// table
- permissionTable = new Table(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- permissionTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- permissionTable.setHeaderVisible(true);
- permissionTable.setLinesVisible(true);
+ permissionTable = new ImagePermissionTable();
+ add(new JScrollPane(permissionTable), GridPos.get(0, 0, true, true));
// Buttons below Table
- addUser = new Button(container, SWT.PUSH);
- addUser.setText(addUserLabel);
-
- removeUser = new Button(container, SWT.PUSH);
- removeUser.setText(removeUserLabel);
+ addUser = new JButton();
+ add(addUser, GridPos.get(0, 1));
- setControl(container);
+ removeUser = new JButton();
+ add(removeUser, GridPos.get(1, 1));
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java
index 74f0055d..be113f2a 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java
@@ -14,6 +14,7 @@ import javax.swing.border.TitledBorder;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.dozmod.gui.helper.GridPos;
+import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.WizardPage;
@SuppressWarnings("serial")
@@ -32,10 +33,11 @@ public abstract class ImageMetaDataPageLayout extends WizardPage {
/**
* wizard page for entering image data at creating or editing an image
+ *
+ * @param wizard
*/
- @SuppressWarnings("serial")
- public ImageMetaDataPageLayout() {
- super("Metadaten");
+ public ImageMetaDataPageLayout(Wizard wizard) {
+ super(wizard, "Metadaten");
setDescription("Geben Sie bitte einen aussagekräftigen Namen für das neue Image ein.");
setLayout(new GridBagLayout());
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java
index 616f5088..aa30a8bc 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java
@@ -10,6 +10,7 @@ import javax.swing.JTextField;
import org.openslx.dozmod.gui.control.BlockProgressBar;
import org.openslx.dozmod.gui.helper.GridPos;
+import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.WizardPage;
@SuppressWarnings("serial")
@@ -23,12 +24,13 @@ public abstract class ImageUploadPageLayout extends WizardPage {
/**
* Page for uploading an imagefile
+ * @param wizard
*
* @param editExistingImage wether to edit existing image file or create new
* one
*/
- public ImageUploadPageLayout() {
- super("Neue VM anlegen");
+ public ImageUploadPageLayout(Wizard wizard) {
+ super(wizard, "Neue VM anlegen");
setDescription("Bitte wählen Sie eine virtuelle Maschine zum Hochladen aus.");
setLayout(new GridBagLayout());
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageCustomPermissionPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageCustomPermissionPage.java
index 1b9a92cb..98c8b5c5 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageCustomPermissionPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageCustomPermissionPage.java
@@ -1,192 +1,48 @@
package org.openslx.dozmod.gui.wizard.page;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import org.apache.log4j.Logger;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableEditor;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.bwlp.thrift.iface.UserInfo;
-import org.openslx.dozmod.gui.helper.TableHelper;
-import org.openslx.dozmod.gui.helper.UserToPermissionLink;
+import org.openslx.dozmod.gui.helper.UserImagePermissions;
+import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.ImageCustomPermissionPageLayout;
import org.openslx.dozmod.state.UploadWizardState;
import org.openslx.dozmod.thrift.UserCache;
+@SuppressWarnings("serial")
public class ImageCustomPermissionPage extends ImageCustomPermissionPageLayout {
private final static Logger LOGGER = Logger
.getLogger(ImageCustomPermissionPage.class);
private UploadWizardState uploadWizardState = null;
- private ArrayList<UserToPermissionLink> permissionList = null;
- private Map<String, ImagePermissions> imagePermissionsMap = null;
-
- protected TableViewer permissionTableViewer;
+ private ArrayList<UserImagePermissions> permissionList = null;
/**
* wizard page for setting custom permissions
+ * @param wizard
*/
- @SuppressWarnings("serial")
- public ImageCustomPermissionPage(UploadWizardState uploadWizardState) {
- super();
+ public ImageCustomPermissionPage(Wizard wizard, UploadWizardState uploadWizardState) {
+ super(wizard);
this.uploadWizardState = uploadWizardState;
- // data "model"
- imagePermissionsMap = new HashMap<String, ImagePermissions>() {
- {
- for (UserInfo user : UserCache.getAll()) {
- put(user.getUserId(), new ImagePermissions(true, true, true, false));
- }
- }
- };
- permissionList = new ArrayList<UserToPermissionLink>();
- }
-
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
-
- List<String> mapKeys = new ArrayList<String>(imagePermissionsMap.keySet());
- if (imagePermissionsMap != null) {
- for (String key : mapKeys) {
- permissionList.add(new UserToPermissionLink(key, imagePermissionsMap
- .get(key)));
- }
- }
- // Initialize the table viewer now that everything is ready
- permissionTableViewer = new TableViewer(permissionTable);
- permissionTableViewer.setContentProvider(ArrayContentProvider.getInstance());
-
- // create table columns through TableHelper
- TableHelper.createImagePermissionTableColumns(permissionTableViewer,
- new ColumnLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- TableItem item = (TableItem) cell.getItem();
- Object cellElement = cell.getElement();
- UserToPermissionLink userPermLink = null;
- if (cellElement instanceof UserToPermissionLink) {
- userPermLink = (UserToPermissionLink) cellElement;
- }
- if (userPermLink == null) {
- // TODO handle properly
- LOGGER.debug("Could not cast '" + cellElement
- + "' to UserToPermissionLink!");
- return;
- }
- int cellIndex = cell.getColumnIndex();
- // CASE there are 5 columns, therefore we need to subtract 1
- // (for the user label) when using cellIndex as index for the buttons array!!!
- if (userPermLink.buttons[cellIndex - 1] == null) {
- userPermLink.buttons[cellIndex - 1] = createButton((Composite) cell
- .getViewerRow().getControl(), SWT.CHECK);
- userPermLink.buttons[cellIndex - 1].setData("userId", userPermLink.getUserId());
- userPermLink.buttons[cellIndex - 1].setData("index", cellIndex - 1);
- }
- // finally set the button's state according to the perms
- boolean savedPerm = false;
- switch (cellIndex) {
- case 1:
- savedPerm = userPermLink.getPermission().link;
- break;
- case 2:
- savedPerm = userPermLink.getPermission().download;
- break;
- case 3:
- savedPerm = userPermLink.getPermission().edit;
- break;
- case 4:
- savedPerm = userPermLink.getPermission().admin;
- default:
- break;
- }
- userPermLink.buttons[cellIndex -1].setSelection(savedPerm);
- TableEditor editor = new TableEditor(item.getParent());
- editor.grabHorizontal = true;
- editor.grabVertical = true;
- editor.setEditor(userPermLink.buttons[cellIndex - 1], item, cell.getColumnIndex());
- editor.layout();
- }
- });
-
- permissionTableViewer.setInput(permissionList);
- permissionTableViewer.refresh();
+ permissionList = new ArrayList<UserImagePermissions>();
+ for (UserInfo user : UserCache.getAll()) {
+ permissionList.add(new UserImagePermissions(user.getUserId(), new ImagePermissions(true, true, true, false)));
+ }
+ permissionTable.setData(permissionList);
// add user button adapter
- addUser.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- LOGGER.debug("addUser called");
- }
- });
- }
- /**
- * @param parent Parent to this button
- * @param style Style
- * @return the button
- */
- private Button createButton(Composite parent, int style) {
- Button newButton = new Button(parent, style);
- newButton.addSelectionListener(new SelectionAdapter() {
+ addUser.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- Button o = (Button) e.getSource();
- callback(o);
+ public void actionPerformed(ActionEvent e) {
+ LOGGER.debug("addUser called"); // TODO
}
});
- return newButton;
- }
- /**
- * @param button
- */
- public void callback(final Button button) {
- int index = (int)button.getData("index");
- String userId = (String) button.getData("userId");
- ImagePermissions perm = null;
- if (imagePermissionsMap.containsKey(userId)) {
- perm = imagePermissionsMap.get(userId);
- } else {
- LOGGER.error(userId + " is not in the permission map!");
- return;
- }
- LOGGER.debug("Before: " + perm);
- switch(index) {
- case 0:
- perm.link = button.getSelection();
- break;
- case 1:
- perm.download = button.getSelection();
- break;
- case 2:
- perm.edit = button.getSelection();
- break;
- case 3:
- perm.admin = button.getSelection();
- break;
- default:
- break;
- }
- uploadWizardState.permissionList = imagePermissionsMap;
- LOGGER.debug("After: " + perm);
- }
- /**
- * @return permission list table object
- */
- public Table getTable() {
- return permissionTable;
}
+
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java
index ac33bd06..a33fdb37 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java
@@ -12,6 +12,7 @@ import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.ShareMode;
import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.ImageMetaDataPageLayout;
import org.openslx.dozmod.state.UploadWizardState;
import org.openslx.dozmod.thrift.MetaDataCache;
@@ -25,8 +26,8 @@ public class ImageMetaDataPage extends ImageMetaDataPageLayout {
private UploadWizardState state;
- public ImageMetaDataPage(UploadWizardState uploadWizardState) {
- super();
+ public ImageMetaDataPage(Wizard wizard, UploadWizardState uploadWizardState) {
+ super(wizard);
this.state = uploadWizardState;
setPageComplete(false);
// HACK set fixed uploadWizardState to test functions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java
index 202bad4f..33f15f40 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java
@@ -23,6 +23,8 @@ import org.openslx.dozmod.filetransfer.TransferEventListener;
import org.openslx.dozmod.filetransfer.UploadTask;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.gui.wizard.ImageWizard;
+import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.ImageUploadPageLayout;
import org.openslx.dozmod.state.UploadWizardState;
import org.openslx.dozmod.thrift.MetaDataCache;
@@ -40,8 +42,8 @@ public class ImageUploadPage extends ImageUploadPageLayout {
private UploadWizardState state;
private String lastDetectedName = null;
- public ImageUploadPage(UploadWizardState uploadWizardState) {
- super();
+ public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState) {
+ super(wizard);
setPageComplete(false);
this.canComeBack = false;
this.state = uploadWizardState;