summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorJonathan Bauer2015-07-29 18:13:02 +0200
committerJonathan Bauer2015-07-29 18:13:02 +0200
commitaf022c64b0ba9ca110dc82240ff9e735c087b753 (patch)
treedd05d677632ed2832c4e43dec460db5048e4d36c /dozentenmodul/src/main/java
parent[client] auto adjust columns with magic (diff)
downloadtutor-module-af022c64b0ba9ca110dc82240ff9e735c087b753.tar.gz
tutor-module-af022c64b0ba9ca110dc82240ff9e735c087b753.tar.xz
tutor-module-af022c64b0ba9ca110dc82240ff9e735c087b753.zip
[client] first steps for the swingified imagedetailswindow
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java6
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java47
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java5
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java229
4 files changed, 135 insertions, 152 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 c26541bc..f1a6755d 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
@@ -2,6 +2,7 @@ package org.openslx.dozmod.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
+import java.awt.Frame;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.Window;
@@ -35,7 +36,6 @@ import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow;
import org.openslx.dozmod.thrift.Session;
import org.openslx.thrifthelper.ThriftManager;
import org.openslx.thrifthelper.ThriftManager.ErrorCallback;
-import org.openslx.util.QuickTimer;
public abstract class MainWindow {
@@ -256,5 +256,9 @@ public abstract class MainWindow {
}
});
}
+ // hack TODO what to giev to a popup when we aren't in this class?
+ public static JFrame getMainWin() {
+ return mainWindow;
+ }
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
index 66a1a321..8238f2a0 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
@@ -1,6 +1,6 @@
package org.openslx.dozmod.gui.window;
-import java.awt.Window;
+import java.awt.Frame;
import java.util.List;
import org.apache.log4j.Logger;
@@ -29,16 +29,16 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout {
private ImageDetailsRead image = null;
- public ImageDetailsWindow(Window parent) {
- super(parent);
+ public ImageDetailsWindow(Frame modalParent) {
+ super(modalParent);
- // Close button closes window
- btnClose.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getShell().dispose();
- }
- });
+// // Close button closes window
+// btnClose.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// getShell().dispose();
+// }
+// });
}
public void setImage(final String imageBaseId) {
@@ -64,9 +64,9 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout {
@Override
public void run() {
if (e != null || image == null) {
- MainWindow.showMessageBox("Konnte Daten des Images nicht abrufen",
+ Gui.showMessageBox(null, "Konnte Daten des Images nicht abrufen",
MessageType.ERROR, LOGGER, e);
- getShell().dispose();
+ dispose();
} else {
fill();
}
@@ -77,19 +77,19 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout {
}
private void fill() {
- if (isDisposed() || image == null)
+ if (image == null)
return;
txtTitle.setText(SwtUtil.replaceMnemonics(image.getImageName()));
txtDescription.setText(SwtUtil.replaceMnemonics(image.getDescription()));
- lblOwner.setUser(UserCache.find(image.getOwnerId()));
- lblUpdater.setUser(UserCache.find(image.getUpdaterId()));
+ lblOwner.setText(FormatHelper.userName(UserCache.find(image.getOwnerId())));
+ lblUpdater.setText(FormatHelper.userName(UserCache.find(image.getUpdaterId())));
lblCreateTime.setText(FormatHelper.longDate(image.getCreateTime()));
lblUpdateTime.setText(FormatHelper.longDate(image.getUpdateTime()));
List<OperatingSystem> osList = MetaDataCache.getOperatingSystems();
- cboOperatingSystem.setInput(osList);
+// cboOperatingSystem.setInput(osList);
OperatingSystem os = MetaDataCache.getOsById(image.getOsId());
if (os != null) {
- cboOperatingSystem.setSelection(new StructuredSelection(os), true);
+// cboOperatingSystem.setSelection(new StructuredSelection(os), true);
}
Virtualizer virt = MetaDataCache.getVirtualizerById(image.getVirtId());
if (virt != null)
@@ -99,10 +99,10 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout {
tagsString = tagsString + ", " + tag;
}
txtTags.setText(tagsString);
- btnIsTemplate.setSelection(image.isTemplate);
+// btnIsTemplate.setSelection(image.isTemplate);
makeEditable(ImagePerms.canEdit(image));
- getShell().layout(true, true);
- MainWindow.centerShell(getShell());
+// getShell().layout(true, true);
+// MainWindow.centerShell(getShell());
}
@@ -110,8 +110,13 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout {
private void makeEditable(boolean editable){
txtTitle.setEnabled(editable);
txtDescription.setEnabled(editable);
- cboOperatingSystem.getCombo().setEnabled(editable);
+// cboOperatingSystem.getCombo().setEnabled(editable);
txtTags.setEnabled(editable);
btnIsTemplate.setEnabled(editable);
}
+ public static void open(Frame modalParent) {
+ ImageDetailsWindow win = new ImageDetailsWindow(modalParent);
+ MainWindow.centerShell(win);
+ win.setVisible(true);
+ }
}
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 8257f8b2..7211a7c2 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
@@ -94,9 +94,10 @@ public class ImageListWindow extends ImageListWindowLayout {
});
imageTable.addMouseListener(new MouseAdapter() {
@Override
- public void mouseClicked(MouseEvent me) {
- if (me.getClickCount() == 2) {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
// TODO open details popup
+ ImageDetailsWindow.open(MainWindow.getMainWin());
}
}
});
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
index 3d024a54..1d41a739 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
@@ -1,142 +1,115 @@
package org.openslx.dozmod.gui.window.layout;
-import org.eclipse.jface.resource.FontDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-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.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.Frame;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.bwlp.thrift.iface.ShareMode;
import org.openslx.dozmod.gui.control.PersonLabel;
-import org.openslx.dozmod.gui.helper.SwtUtil;
-
-public abstract class ImageDetailsWindowLayout extends Composite {
-
- protected final Text txtTitle;
-
- protected final Text txtDescription;
-
- protected final Label lblCreateTime;
-
- protected final Label lblUpdateTime;
-
- protected final PersonLabel lblOwner;
+import org.openslx.dozmod.gui.helper.GridPos;
- protected final PersonLabel lblUpdater;
+public abstract class ImageDetailsWindowLayout extends JDialog {
- protected final ComboViewer cboOperatingSystem;
+ protected final JTextField txtTitle;
+ protected final JTextField txtDescription;
- protected final Label lblVirtualizer;
+ protected final JLabel lblOwner;
+ protected final JLabel lblCreateTime;
+ protected final JLabel lblUpdater;
+ protected final JLabel lblUpdateTime;
- protected final Text txtTags;
-
- protected final Button btnIsTemplate;
-
- protected final ComboViewer cboShareMode;
-
- protected final Button btnSaveChanges;
-
- protected final Button btnClose;
+ protected final JComboBox<OperatingSystem> cboOperatingSystem;
+ protected final JLabel lblVirtualizer;
+ protected final JTextField txtTags;
+ protected final JCheckBox btnIsTemplate;
+ protected final JComboBox<ShareMode> cboShareMode;
+ protected final JButton btnSaveChanges;
+ protected final JButton btnClose;
// TODO: Permissions, ...
- public ImageDetailsWindowLayout(Shell parent) {
- super(parent, SWT.NONE);
- this.setLayout(new GridLayout(2, false));
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Title label
- txtTitle = new Text(this, SWT.NONE);
- FontData[] fonts = FontDescriptor.copy(JFaceResources.getFontRegistry().getFontData(
- JFaceResources.DEFAULT_FONT));
- for (FontData f : fonts) {
- f.setHeight(f.getHeight() * 2);
- }
- final Font titleFont = new Font(getDisplay(), fonts);
- txtTitle.setFont(titleFont);
- GridData gdTitle = SwtUtil.gridData(SWT.LEFT, SWT.FILL, true, false, 2);
- gdTitle.minimumWidth = 600;
- gdTitle.minimumHeight = 20;
- txtTitle.setLayoutData(gdTitle);
-
- // Create a horizontal separator
- Label separator = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR);
- separator.setLayoutData(SwtUtil.gridData(SWT.FILL, SWT.FILL, true, false, 2));
-
- // Description
- txtDescription = new Text(this, SWT.BORDER);
- txtDescription.setLayoutData(SwtUtil.gridData(SWT.FILL, SWT.FILL, true, false, 2));
-
- // Owner
- new Label(this, SWT.NONE).setText("Besitzer");
- lblOwner = new PersonLabel(this, SWT.NONE);
-
- // Creation time
- new Label(this, SWT.NONE).setText("Erstellt");
- lblCreateTime = new Label(this, SWT.NONE);
-
- // Updater
- new Label(this, SWT.NONE).setText("Geändert durch");
- lblUpdater = new PersonLabel(this, SWT.NONE);
-
- // Update time
- new Label(this, SWT.NONE).setText("Änderungszeitpunkt");
- lblUpdateTime = new Label(this, SWT.NONE);
-
- // OS list
- new Label(this, SWT.NONE).setText("Betriebssystem");
- cboOperatingSystem = new ComboViewer(this, SWT.DROP_DOWN | SWT.READ_ONLY);
- cboOperatingSystem.setContentProvider(ArrayContentProvider.getInstance());
- cboOperatingSystem.setLabelProvider(new LabelProvider() {
- @Override
- public String getText(Object element) {
- return ((OperatingSystem) element).getOsName();
- }
- });
-
- // Virtualizer
- new Label(this, SWT.NONE).setText("Virtualizer");
- lblVirtualizer = new Label(this, SWT.NONE);
-
- // Tags
- new Label(this, SWT.NONE).setText("Tags");
- txtTags = new Text(this, SWT.NONE);
-
- // Share mode
- new Label(this, SWT.NONE).setText("Freigabemodus");
- cboShareMode = new ComboViewer(this, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- // Is template
- new Label(this, SWT.NONE).setText("Vorlage");
- btnIsTemplate = new Button(this, SWT.CHECK);
+ public ImageDetailsWindowLayout(Frame modalParent) {
+ super(modalParent, "der mit dem blub", ModalityType.APPLICATION_MODAL);
+ setResizable(false);
+ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ setLayout(new BorderLayout());
+
+ // label panel on the west side of the borderlayout
+ JPanel labelPanel = new JPanel();
+ labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
+ labelPanel.add(new JLabel("Name"));
+ labelPanel.add(new JLabel("Beschreibung"));
+ labelPanel.add(new JLabel("Besitzer"));
+ labelPanel.add(new JLabel("Erstellt"));
+ labelPanel.add(new JLabel("Geändert durch"));
+ labelPanel.add(new JLabel("Änderungszeitpunkt"));
+ labelPanel.add(new JLabel("Betriebssystem"));
+ labelPanel.add(new JLabel("Virtualizer"));
+ labelPanel.add(new JLabel("Tags"));
+ labelPanel.add(new JLabel("Freigabemodus"));
+ labelPanel.add(new JLabel("Vorlage"));
+ add(labelPanel, BorderLayout.WEST);
- btnSaveChanges = new Button(this, SWT.PUSH);
- btnSaveChanges.setText("Änderungen speichern");
-
- // Close button
- btnClose = new Button(this, SWT.PUSH | SWT.RIGHT | SWT.DOWN);
- btnClose.setText("Schließen");
- btnClose.setLayoutData(SwtUtil.gridData(SWT.RIGHT, SWT.BOTTOM, false, false, 2));
-
- //
- // Dispose of stuff we allocated
- this.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- titleFont.dispose();
- }
- });
+ // content panel on the center of the borderlayout (to auto grab space)
+ JPanel contentPanel = new JPanel();
+ contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));
+ // name
+ txtTitle = new JTextField();
+ txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2));
+ contentPanel.add(txtTitle);
+ // description
+ txtDescription = new JTextField();
+ contentPanel.add(txtDescription);
+ // owner
+ lblOwner = new JLabel();
+ contentPanel.add(lblOwner);
+ // creation time
+ lblCreateTime = new JLabel();
+ contentPanel.add(lblCreateTime);
+ // last updater
+ lblUpdater = new JLabel();
+ contentPanel.add(lblUpdater);
+ // last updated
+ lblUpdateTime = new JLabel();
+ contentPanel.add(lblUpdateTime);
+ // os
+ cboOperatingSystem = new JComboBox<OperatingSystem>();
+ contentPanel.add(cboOperatingSystem);
+ // virtualizer
+ lblVirtualizer = new JLabel();
+ contentPanel.add(lblVirtualizer);
+ // tags
+ txtTags = new JTextField();
+ contentPanel.add(txtTags);
+ // share mode
+ cboShareMode = new JComboBox<ShareMode>();
+ contentPanel.add(cboShareMode);
+ // template
+ btnIsTemplate = new JCheckBox();
+ contentPanel.add(btnIsTemplate);
+ // finally add the content panel to the main frame
+ add(contentPanel, BorderLayout.CENTER);
+
+ // button panel on the bottom
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS));
+ btnSaveChanges = new JButton();
+ btnClose = new JButton();
+ buttonPanel.add(btnSaveChanges);
+ buttonPanel.add(btnClose);
+ add(buttonPanel, BorderLayout.SOUTH);
+ validate();
+ pack();
}
-
}