View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.dialogs;
17  
18  import java.awt.BorderLayout;
19  import java.awt.Frame;
20  import java.awt.event.ActionEvent;
21  import java.awt.event.ActionListener;
22  import java.util.List;
23  
24  import javax.swing.JButton;
25  import javax.swing.JDialog;
26  import javax.swing.JList;
27  import javax.swing.JPanel;
28  import javax.swing.JScrollPane;
29  import javax.swing.JTextArea;
30  
31  import p3j.misc.gui.GUI;
32  
33  /**
34   * Simple dialog to display warnings that occurred during the loading of a
35   * projection.
36   * 
37   * @see p3j.misc.Serializer
38   * 
39   *      Created on 14.10.2012
40   * 
41   * @author Christina Bohk
42   * @author Roland Ewald
43   */
44  public class ShowWarningAfterProjectionLoadingDialog extends JDialog {
45  
46    /** The Constant serialVersionUID. */
47    private static final long serialVersionUID = 3246519924977747183L;
48  
49    /** Width of the dialog. */
50    public static final int DIALOG_WIDTH = 850;
51  
52    /** Height of the dialog. */
53    public static final int DIALOG_HEIGHT = 300;
54  
55    /** The content panel. */
56    private final JPanel contentPanel;
57  
58    /** The OK button that closes the dialog. */
59    private final JButton okButton = new JButton("OK");
60    {
61      okButton.addActionListener(new ActionListener() {
62        @Override
63        public void actionPerformed(ActionEvent e) {
64          setVisible(false);
65        }
66      });
67    }
68  
69    /**
70     * Instantiates a new dialog.
71     * 
72     * @param owner
73     *          the owner
74     * @param p3jConfiguration
75     *          the p3j configuration
76     */
77    public ShowWarningAfterProjectionLoadingDialog(Frame owner,
78        List<String> warnings) {
79      super(owner, "Warnings During Projection Import", true);
80      setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
81      GUI.centerOnScreen(this);
82      contentPanel = new JPanel();
83      contentPanel.setLayout(new BorderLayout(GUI.STD_LAYOUT_GAP,
84          GUI.STD_LAYOUT_GAP));
85      JTextArea explanation = new JTextArea(
86          "Due to parameter name differences between versions, some parameter instances have been matched via name similarity to resolve ambiguity.\n"
87              + "Please check if the matching is correct:");
88      explanation.setEditable(false);
89      contentPanel.add(explanation, BorderLayout.NORTH);
90      JList<String> warningsList = new JList<>(
91          warnings.toArray(new String[warnings.size()]));
92      contentPanel.add(new JScrollPane(warningsList), BorderLayout.CENTER);
93      contentPanel.add(okButton, BorderLayout.SOUTH);
94      getContentPane().add(contentPanel);
95    }
96  }