diff options
author | Simon Rettberg | 2015-07-29 15:14:08 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-29 15:14:08 +0200 |
commit | e0ca8b7a3fd299505ad964a1d20d1631920c2a8f (patch) | |
tree | 1975709d3e7954ed694a90813ae5a15e263d6846 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java | |
parent | [client] Add JTable helper class ListTable (diff) | |
download | tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.tar.gz tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.tar.xz tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.zip |
[client] ImageListWindow ported to Swing
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java | 171 |
1 files changed, 64 insertions, 107 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java index 14708376..d7e9782a 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java @@ -1,34 +1,32 @@ package org.openslx.dozmod.gui.window.layout; -import java.awt.Button; -import java.awt.Composite; +import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Label; -import java.security.acl.Group; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.border.TitledBorder; -import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.table.LectureTable; import org.openslx.dozmod.gui.helper.CompositePage; +import org.openslx.dozmod.gui.helper.GridPos; import org.openslx.dozmod.gui.helper.LectureListFilter; public abstract class LectureListWindowLayout extends CompositePage { - protected String infoTitleString = "Übersicht Veranstaltungen"; - protected String newButtonLabel = "Neu"; - protected String editButtonLabel = "Bearbeiten"; - protected String deleteButtonLabel = "Löschen"; - protected String backButtonLabel = "Zurück"; - protected String tableGroupLabel = "Veranstaltungen"; - protected String vmInfoGroupLabel = "Detailinformationen"; - protected String filterGroupLabel = "Filter"; + private static final String infoTitleString = "Übersicht Veranstaltungen"; + private static final String newButtonLabel = "Neu"; + private static final String editButtonLabel = "Bearbeiten"; + private static final String deleteButtonLabel = "Löschen"; + private static final String backButtonLabel = "Zurück"; + private static final String tableGroupLabel = "Veranstaltungen"; + private static final String vmInfoGroupLabel = "Detailinformationen"; + private static final String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen."; // buttons protected JButton newButton; @@ -51,123 +49,82 @@ public abstract class LectureListWindowLayout extends CompositePage { protected final LectureTable lectureTable; protected LectureListFilter filter; - protected String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen."; - public LectureListWindowLayout() { super(new GridBagLayout()); // -- info group with title and text -- JPanel infoComposite = new JPanel(); infoComposite.setLayout(new BoxLayout(infoComposite, BoxLayout.PAGE_AXIS)); - infoComposite.setBorder(new TitledBorder(infoTitleString)); - - 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); + JLabel infoTitle = new JLabel(infoTitleString); + infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD)); // the infotext - Label infoText = new Label(infoComposite, SWT.NONE); - infoText.setText(infoTextString); + JLabel infoText = new JLabel(infoTextString); + infoComposite.add(infoTitle); + infoComposite.add(infoText); // -- end group of title -- // -- group for the table -- - 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()); - + JPanel tableGroup = new JPanel(); + tableGroup.setBorder(new TitledBorder(tableGroupLabel)); + tableGroup.setLayout(new GridBagLayout()); + tableGroup.setMinimumSize(new Dimension(800, 600)); + tableGroup.setPreferredSize(tableGroup.getMinimumSize()); // filter text field - searchTextField = new Text(filterGroup, SWT.BORDER); - searchTextField.setMessage("Name, Verantwortlicher"); - // -- end group of filter -- - + searchTextField = new JTextField(); + tableGroup.add(searchTextField, GridPos.get(0, 0, true, false)); // table - Table vmTable = new Table(tableGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true); - vmTable.setLayoutData(tableGridData); - vmTable.setHeaderVisible(true); - vmTable.setLinesVisible(true); - - // TableViewer on the table - tableViewer = new TableViewer(vmTable); - tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + lectureTable = new LectureTable(); + tableGroup.add(new JScrollPane(lectureTable), GridPos.get(0, 1, true, true)); // create, modify 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); - - editButton = new Button(buttonComposite, SWT.PUSH); - editButton.setText(editButtonLabel); - - deleteButton = new Button(buttonComposite, SWT.PUSH); - deleteButton.setText(deleteButtonLabel); - - backButton = new Button(buttonComposite, SWT.PUSH); - backButton.setText(backButtonLabel); + JPanel buttonComposite = new JPanel(); + buttonComposite.setLayout(new BoxLayout(buttonComposite, BoxLayout.LINE_AXIS)); + tableGroup.add(buttonComposite, GridPos.get(0, 2, true, false)); + + newButton = new JButton(newButtonLabel); + buttonComposite.add(newButton); + editButton = new JButton(editButtonLabel); + buttonComposite.add(editButton); + deleteButton = new JButton(deleteButtonLabel); + buttonComposite.add(deleteButton); + backButton = new JButton(backButtonLabel); + buttonComposite.add(backButton); // -- end group for table -- // -- group for details of selected lecture -- - 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)); - + final JPanel vmInfoGroup = new JPanel(); + vmInfoGroup.setLayout(new GridBagLayout()); + vmInfoGroup.setBorder(new TitledBorder(vmInfoGroupLabel)); + vmInfoGroup.setMaximumSize(new Dimension(400, Integer.MAX_VALUE)); + vmInfoGroup.setMinimumSize(new Dimension(350, 0)); + vmInfoGroup.setPreferredSize(vmInfoGroup.getMinimumSize()); // image name info - lectureName = createCaptionAndTextfield("Name:", vmInfoGroup); - idInfo = createCaptionAndTextfield("Id:", vmInfoGroup); - imageBaseId = createCaptionAndTextfield("Image Id:", vmInfoGroup); - lastusedInfo = createCaptionAndTextfield("Zuletzt genutzt:", vmInfoGroup); - permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup); - startTime = createCaptionAndTextfield("Startzeit:", vmInfoGroup); - endTime = createCaptionAndTextfield("Endzeit:", vmInfoGroup); - ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup); + int row = 0; + lectureName = createCaptionAndTextfield("Name", vmInfoGroup, row++); + idInfo = createCaptionAndTextfield("UUID", vmInfoGroup, row++); + imageBaseId = createCaptionAndTextfield("Image", vmInfoGroup, row++); + lastusedInfo = createCaptionAndTextfield("Zuletzt genutzt", vmInfoGroup, row++); + permissionInfo = createCaptionAndTextfield("Berechtigungen", vmInfoGroup, row++); + startTime = createCaptionAndTextfield("Startzeit", vmInfoGroup, row++); + endTime = createCaptionAndTextfield("Endzeit", vmInfoGroup, row++); + ownerInfo = createCaptionAndTextfield("Besitzer", vmInfoGroup, row++); + // For some reason without this the controls above are centered vertically + vmInfoGroup.add(new JPanel(), GridPos.get(0, row++, 2, 1, true, true)); // -- end group of details -- - // Dispose of stuff we allocated - this.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - titleFont.dispose(); - } - }); + add(infoComposite, GridPos.get(0, 0, 2, 1, true, false)); + add(tableGroup, GridPos.get(0, 1, true, true)); + add(vmInfoGroup, GridPos.get(1, 1, false, true)); } - public Text createCaptionAndTextfield(String captionString, Group group) { - Label caption = new Label(group, SWT.NONE); - Text textField = new Text(group, SWT.READ_ONLY); + 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; } |