package org.openslx.dozmod.gui.window.layout; import java.awt.BorderLayout; import java.awt.Frame; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import org.openslx.dozmod.Branding; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.QLabel; import org.openslx.dozmod.gui.helper.GridManager; @SuppressWarnings("serial") public abstract class GenericNoticeWindowLayout extends JDialog { protected String info = "Bitte lesen und bestätigen Sie folgende rechtliche Hinweise:"; protected JTextArea notice; protected JScrollPane disclaimerPanel; protected String checkboxText = "Ja, ich akzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen."; private static String title = Branding.getApplicationName(); private static String noticeLabel = "Hinweis"; private static String continueButtonLabel = "Weiter"; // Buttons protected final JCheckBox chkAgreeBox; protected final JButton btnContinue; public GenericNoticeWindowLayout(Frame modalParent) { super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); this.setLayout(new BorderLayout()); // Panel used for creating border. We'll add everything into this. JPanel borderPanel = new JPanel(); borderPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(borderPanel); // information before the notice QLabel noticePanel = new QLabel(); noticePanel.setBorder(BorderFactory.createTitledBorder(noticeLabel)); noticePanel.setText(info); // the disclaimer text box with scrolling functionality notice = new JTextArea(30, 20); notice.setEditable(false); notice.setLineWrap(true); notice.setWrapStyleWord(true); disclaimerPanel = new JScrollPane(notice, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // checkbox for acknowledging the notice JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); chkAgreeBox = new JCheckBox(checkboxText); chkAgreeBox.setEnabled(false); buttonPanel.add(chkAgreeBox); // spacer buttonPanel.add(Box.createHorizontalGlue()); // the continue button btnContinue = new JButton(continueButtonLabel); btnContinue.setEnabled(false); buttonPanel.add(btnContinue); // put everything together GridManager grid = new GridManager(borderPanel, 1); grid.add(noticePanel).fill(true, false).expand(true, false); grid.nextRow(); grid.add(disclaimerPanel).fill(true, true).expand(true, true); grid.nextRow(); grid.add(buttonPanel).fill(true, false).expand(true, false); grid.finish(false); pack(); if (modalParent != null) { Gui.centerShellOverShell(modalParent, this); } } public void setNoticeText(String text) { if (notice != null) { notice.setText(text); notice.setCaretPosition(0); } } }