summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-07-29 16:30:06 +0200
committerJonathan Bauer2015-07-29 16:30:06 +0200
commit0fd45fd49c96307923b3f5e373bd39a6f46c16a8 (patch)
tree816d3394252058f837707a5eba3910d5cbdd45eb /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java
parent[client] moved TableRenderer (to remove the dotted border around selected cel... (diff)
downloadtutor-module-0fd45fd49c96307923b3f5e373bd39a6f46c16a8.tar.gz
tutor-module-0fd45fd49c96307923b3f5e373bd39a6f46c16a8.tar.xz
tutor-module-0fd45fd49c96307923b3f5e373bd39a6f46c16a8.zip
[client] ImageListLayout using ImageTable (no functions yet!)
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java297
1 files changed, 119 insertions, 178 deletions
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 c817a9fb..e7ff4242 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
@@ -1,211 +1,152 @@
package org.openslx.dozmod.gui.window.layout;
import java.awt.BorderLayout;
-import java.awt.Frame;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.JRootPane;
import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
import javax.swing.JTable;
+import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
-import javax.swing.SwingUtilities;
+import javax.swing.border.TitledBorder;
import org.apache.log4j.Logger;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.awt.SWT_AWT;
-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.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.Text;
-import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.control.table.ImageTable;
import org.openslx.dozmod.gui.helper.CompositePage;
+import org.openslx.dozmod.gui.helper.GridPos;
import org.openslx.dozmod.gui.helper.ResizeColumnListener;
-import org.openslx.dozmod.gui.helper.TableRenderer;
+
public abstract class ImageListWindowLayout extends CompositePage {
private final static Logger LOGGER = Logger.getLogger(ImageListWindowLayout.class);
- protected String infoTitleString = "Übersicht Virtuelle Maschinen";
- protected String newButtonLabel = "Neu";
- protected String editButtonLabel = "Bearbeiten";
- protected String deleteButtonLabel = "Löschen";
- protected String downloadButtonLabel = "Download";
- protected String backButtonLabel = "Zurück";
- protected String tableGroupLabel = "Images";
- protected String vmInfoGroupLabel = "Detailinformationen";
- protected String filterGroupLabel = "Filter";
+ protected final static String infoTitleString = "Übersicht Virtuelle Maschinen";
+ protected final static String newButtonLabel = "Neu";
+ protected final static String editButtonLabel = "Bearbeiten";
+ protected final static String deleteButtonLabel = "Löschen";
+ protected final static String downloadButtonLabel = "Download";
+ protected final static String backButtonLabel = "Zurück";
+ protected final static String tableGroupLabel = "Images";
+ protected final static String vmInfoGroupLabel = "Detailinformationen";
+ protected final static String filterGroupLabel = "Filter";
// buttons
- protected Button newButton;
- protected Button deleteButton;
- protected Button downloadButton;
- protected Button backButton;
-
+ protected JButton newButton;
+ protected JButton deleteButton;
+ protected JButton downloadButton;
+ protected JButton backButton;
// imageDetail texts
- protected Text imageSelectedNameLabel;
- protected Text idInfo;
- protected Text versionInfo;
- protected Text lastUpdateInfo;
- protected Text permissionInfo;
- protected Text ownerInfo;
- protected Text templateInfo;
-
- protected final Text searchTextField;
-
- protected JTable jtable;
+ protected JTextField imageSelectedNameLabel;
+ protected JTextField idInfo;
+ protected JTextField versionInfo;
+ protected JTextField lastUpdateInfo;
+ protected JTextField permissionInfo;
+ protected JTextField ownerInfo;
+ protected JTextField templateInfo;
+
+ protected JTextField searchTextField;
+
+ protected ImageTable imageTable;
protected String infoTextString = "Hier können Sie Virtuelle Maschinen hochladen, herunterladen, bearbeiten und löschen.";
public ImageListWindowLayout() {
- super(new GridBagLayout());
-
- // the layout and layoutData of the ImageListWindow
- this.setLayout(new GridLayout(2, false));
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // -- info group with title and text --
- Composite infoComposite = new Composite(this, SWT.BORDER);
- infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
- // layout for the items of the group
- infoComposite.setLayout(new GridLayout(1, false));
-
- // title of the info group in bold
- Label infoTitle = new Label(infoComposite, SWT.NONE);
- infoTitle.setText(infoTitleString);
- // set the fond
- FontData fontData = infoTitle.getFont().getFontData()[0];
- final Font titleFont = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
- infoTitle.setFont(titleFont);
- // the infotext
- Label infoText = new Label(infoComposite, SWT.NONE);
- infoText.setText(infoTextString);
- // -- end group of title --
-
-
- // -- group for the table --
- final Group tableGroup = new Group(this, SWT.BORDER);
- tableGroup.setText(tableGroupLabel);
- GridData tgLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
- tgLayoutData.minimumWidth = 400;
- tgLayoutData.widthHint = 800;
- tableGroup.setLayoutData(tgLayoutData);
- tableGroup.setLayout(new GridLayout());
-
- // -- group for the filter --
- Group filterGroup = new Group(tableGroup, SWT.BORDER);
- filterGroup.setText(filterGroupLabel);
- GridData fgGridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
- fgGridData.minimumWidth = 400;
- fgGridData.widthHint = 800;
- filterGroup.setLayoutData(fgGridData);
- filterGroup.setLayout(new GridLayout());
-
- // filter text field
- searchTextField = new Text(filterGroup, SWT.BORDER);
- searchTextField.setMessage("Name, Verantwortlicher, OS");
- // -- end group of filter --
-
- // table composite to embed the swing table
- final Composite comp = new Composite(tableGroup, SWT.NO_BACKGROUND | SWT.EMBEDDED);
- comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- final Frame frame = SWT_AWT.new_Frame(comp);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- System.setProperty("sun.awt.noerasebackground", "true");
- // auto-resize-on-scroll http://stackoverflow.com/questions/17858132/automatically-adjust-jtable-column-to-fit-content
- JPanel panel = new JPanel(new BorderLayout());
- frame.add(panel);
- JRootPane root = new JRootPane();
- panel.add(root);
- java.awt.Container contentPane = root.getContentPane();
- // init table
- jtable = new JTable();
- jtable.setShowGrid(false);
- jtable.setCellSelectionEnabled(false);
- jtable.createDefaultColumnsFromModel();
- jtable.setAutoCreateRowSorter(true);
- jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
- jtable.getTableHeader().setReorderingAllowed(false);
- jtable.setDefaultRenderer(Object.class, new TableRenderer());
- jtable.setRowSelectionAllowed(true);
- jtable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-// jtable.setFont(new java.awt.Font("URW Gothic", java.awt.Font.PLAIN, 12));
- new ResizeColumnListener(jtable);
- JScrollPane scrollPane = new JScrollPane(jtable);
- contentPane.setLayout(new BorderLayout());
- contentPane.add(scrollPane);
- }
- });
-
- // create, modify, download and delete buttons
- Composite buttonComposite = new Composite(tableGroup, SWT.NONE);
- GridData buttonCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- buttonCompositeGridData.minimumWidth = 200;
- buttonComposite.setLayoutData(buttonCompositeGridData);
- buttonComposite.setLayout(new RowLayout());
-
- newButton = new Button(buttonComposite, SWT.PUSH);
- newButton.setText(newButtonLabel);
-
- deleteButton = new Button(buttonComposite, SWT.PUSH);
- deleteButton.setText(deleteButtonLabel);
-
- downloadButton = new Button(buttonComposite, SWT.PUSH);
- downloadButton.setText(downloadButtonLabel);
-
- backButton = new Button(buttonComposite, SWT.PUSH);
- backButton.setText(backButtonLabel);
- // -- end group for table --
-
- // -- group for details of selected image --
- final Group vmInfoGroup = new Group(this, SWT.BORDER);
- vmInfoGroup.setText(vmInfoGroupLabel);
- final GridData igGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- igGridData.widthHint = 300;
- vmInfoGroup.setLayoutData(igGridData);
- vmInfoGroup.setLayout(new GridLayout(2, false));
-
+ super(new BorderLayout());
+
+ // --------------------------------------
+ // Info panel on the top with a search box
+ JPanel infoPanel = new JPanel(new BorderLayout());
+ JLabel infoTitle = new JLabel(infoTitleString); // TODO Font
+ infoPanel.add(infoTitle, BorderLayout.NORTH);
+ add(infoPanel, BorderLayout.NORTH);
+
+ // --------------------------------------
+ // List panel with the list of the images
+ JPanel listPanel = new JPanel(new BorderLayout());
+ // the search field
+ searchTextField = new JTextField();
+ listPanel.add(searchTextField, BorderLayout.NORTH);
+ // the actual table
+ imageTable = new ImageTable();
+ listPanel.add(new JScrollPane(imageTable), BorderLayout.CENTER);
+ // the buttons at the bottom
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
+ newButton = new JButton(newButtonLabel);
+ deleteButton = new JButton(deleteButtonLabel);
+ downloadButton = new JButton(downloadButtonLabel);
+ backButton = new JButton(backButtonLabel);
+ buttonPanel.add(newButton);
+ buttonPanel.add(deleteButton);
+ buttonPanel.add(downloadButton);
+ buttonPanel.add(backButton);
+ listPanel.add(buttonPanel, BorderLayout.PAGE_END);
+
+ // --------------------------------------
+ // Details panel on the right side
+ final JPanel detailsPane = new JPanel();
+ detailsPane.setLayout(new GridBagLayout());
+ detailsPane.setBorder(new TitledBorder(vmInfoGroupLabel));
+ detailsPane.setMaximumSize(new Dimension(400, Integer.MAX_VALUE));
+ detailsPane.setMinimumSize(new Dimension(350, 0));
+ detailsPane.setPreferredSize(detailsPane.getMinimumSize());
// image name info
- imageSelectedNameLabel = createCaptionAndTextfield("Image Name:", vmInfoGroup);
- idInfo = createCaptionAndTextfield("ID:", vmInfoGroup);
- versionInfo = createCaptionAndTextfield("Version:", vmInfoGroup);
- lastUpdateInfo = createCaptionAndTextfield("Letztes Update:", vmInfoGroup);
- permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup);
- ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup);
- templateInfo = createCaptionAndTextfield("Vorlage:", vmInfoGroup);
- // -- end group of details --
-
- // Dispose of stuff we allocated
- this.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- titleFont.dispose();
- }
- });
-
+ int row = 0;
+ imageSelectedNameLabel = createCaptionAndTextfield("Name", detailsPane, row++);
+ idInfo = createCaptionAndTextfield("ID", detailsPane, row++);
+ versionInfo = createCaptionAndTextfield("Version", detailsPane, row++);
+ lastUpdateInfo = createCaptionAndTextfield("Letztes Update", detailsPane, row++);
+ permissionInfo = createCaptionAndTextfield("Berechtigungen", detailsPane, row++);
+ ownerInfo = createCaptionAndTextfield("Besitzer", detailsPane, row++);
+ templateInfo = createCaptionAndTextfield("Vorlage", detailsPane, row++);
+ // For some reason without this the controls above are centered vertically
+ detailsPane.add(new JPanel(), GridPos.get(0, row++, 2, 1, true, true));
+ // the actual layout of the whole window
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listPanel, detailsPane);
+ GridBagLayout bag = new GridBagLayout();
+ GridBagConstraints con = new GridBagConstraints();
+ con.fill = GridBagConstraints.BOTH;
+ bag.setConstraints(splitPane, con);
+ add(splitPane);
+
}
-
- public Text createCaptionAndTextfield(String captionString, Group group) {
- Label caption = new Label(group, SWT.NONE);
- Text textField = new Text(group, SWT.READ_ONLY);
+ public JPanel newLabelToTextField(final String labelName, JTextField textField, GridBagConstraints con) {
+ JPanel newPanel = new JPanel();
+ con.gridwidth = 1;
+ con.gridx = 0;
+ con.weightx = 0.1;
+ con.anchor = GridBagConstraints.WEST;
+ con.fill = GridBagConstraints.BOTH;
+ newPanel.add(new JLabel(labelName), con);
+ con.gridx = 1;
+ con.weightx = 1.;
+ con.anchor = GridBagConstraints.EAST;
+ con.fill = GridBagConstraints.HORIZONTAL;
+ if (textField == null) {
+ textField = new JTextField();
+ }
+ newPanel.add(textField, con);
+
+ // finally update "row number"
+ con.gridy++;
+ return newPanel;
+ }
+ public JTextField createCaptionAndTextfield(String captionString, JPanel group, int row) {
+ JLabel caption = new JLabel(captionString);
+ JTextField textField = new JTextField();
+ textField.setEditable(false);
caption.setText(captionString);
- caption.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- gridData.minimumWidth = 180;
- textField.setLayoutData(gridData);
+ group.add(caption, GridPos.get(0, row));
+ group.add(textField, GridPos.get(1, row, true, false));
return textField;
}
-
}