Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ProblemsDialog |
|
| 1.2;1.2 | ||||
ProblemsDialog$1 |
|
| 1.2;1.2 |
1 | /* $Id: ProblemsDialog.java 17871 2010-01-12 20:49:55Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * tfmorris | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 2008 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.uml.reveng.ui; | |
40 | ||
41 | import java.awt.BorderLayout; | |
42 | import java.awt.Dimension; | |
43 | import java.awt.Frame; | |
44 | import java.awt.Toolkit; | |
45 | import java.awt.event.ActionEvent; | |
46 | import java.awt.event.ActionListener; | |
47 | import java.awt.event.WindowAdapter; | |
48 | import java.awt.event.WindowEvent; | |
49 | ||
50 | import javax.swing.JButton; | |
51 | import javax.swing.JDialog; | |
52 | import javax.swing.JEditorPane; | |
53 | import javax.swing.JLabel; | |
54 | import javax.swing.JPanel; | |
55 | import javax.swing.JScrollPane; | |
56 | ||
57 | import org.argouml.i18n.Translator; | |
58 | ||
59 | /** | |
60 | * A window that shows the problems occurred during import. | |
61 | */ | |
62 | 0 | class ProblemsDialog extends JDialog implements ActionListener { |
63 | ||
64 | private Frame parentFrame; | |
65 | private JButton abortButton; | |
66 | private JButton continueButton; | |
67 | private JLabel northLabel; | |
68 | 0 | private boolean aborted = false; |
69 | ||
70 | /** | |
71 | * The constructor. | |
72 | */ | |
73 | ProblemsDialog(Frame frame, String errors) { | |
74 | 0 | super(frame); |
75 | 0 | setResizable(true); |
76 | 0 | setModal(true); |
77 | 0 | setTitle(Translator.localize("dialog.title.import-problems")); |
78 | ||
79 | 0 | Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); |
80 | 0 | getContentPane().setLayout(new BorderLayout(0, 0)); |
81 | ||
82 | // the introducing label | |
83 | 0 | northLabel = |
84 | new JLabel(Translator.localize("label.import-problems")); | |
85 | 0 | getContentPane().add(northLabel, BorderLayout.NORTH); |
86 | ||
87 | // the text box containing the problem messages | |
88 | 0 | JEditorPane textArea = new JEditorPane(); |
89 | 0 | textArea.setText(errors); |
90 | 0 | JPanel centerPanel = new JPanel(new BorderLayout()); |
91 | 0 | centerPanel.add(new JScrollPane(textArea)); |
92 | 0 | centerPanel.setPreferredSize(new Dimension(600, 200)); |
93 | 0 | getContentPane().add(centerPanel); |
94 | ||
95 | // continue and abort buttons | |
96 | 0 | continueButton = new JButton(Translator.localize("button.continue")); |
97 | 0 | abortButton = new JButton(Translator.localize("button.abort")); |
98 | 0 | JPanel bottomPanel = new JPanel(); |
99 | 0 | bottomPanel.add(continueButton); |
100 | 0 | bottomPanel.add(abortButton); |
101 | 0 | getContentPane().add(bottomPanel, BorderLayout.SOUTH); |
102 | 0 | continueButton.requestFocusInWindow(); |
103 | ||
104 | // listeners | |
105 | 0 | continueButton.addActionListener(this); |
106 | 0 | abortButton.addActionListener(this); |
107 | 0 | addWindowListener(new WindowAdapter() { |
108 | public void windowClosing(WindowEvent evt) { | |
109 | 0 | disposeDialog(); |
110 | 0 | } |
111 | }); | |
112 | ||
113 | 0 | pack(); |
114 | 0 | Dimension contentPaneSize = getContentPane().getSize(); |
115 | 0 | setLocation(scrSize.width / 2 - contentPaneSize.width / 2, |
116 | scrSize.height / 2 - contentPaneSize.height / 2); | |
117 | 0 | } |
118 | ||
119 | /* | |
120 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) | |
121 | */ | |
122 | public void actionPerformed(ActionEvent e) { | |
123 | 0 | if (e.getSource().equals(abortButton)) { |
124 | 0 | aborted = true; |
125 | } | |
126 | 0 | disposeDialog(); |
127 | 0 | } |
128 | ||
129 | /** | |
130 | * Returns whether the Abort button was pressed. | |
131 | * @return aborted | |
132 | */ | |
133 | public boolean isAborted() { | |
134 | 0 | return aborted; |
135 | } | |
136 | ||
137 | private void disposeDialog() { | |
138 | 0 | setVisible(false); |
139 | 0 | dispose(); |
140 | 0 | } |
141 | ||
142 | /** | |
143 | * The UID. | |
144 | */ | |
145 | private static final long serialVersionUID = -9221358976863603143L; | |
146 | } |