Debian Codegraph @

substance-swingx/src/tools/java/docrobot/ErrorPaneRunner.java

raw symbols SCIP
1 /*
2 * Copyright 2005-2008 Kirill Grouchnikov, based on work by
3 * Sun Microsystems, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 package docrobot;
20
21 import java.awt.Component;
22 import java.util.Map;
23
24 import javax.swing.*;
25 import javax.swing.plaf.ComponentUI;
26
27 import org.fest.swing.core.BasicRobot;
28 import org.fest.swing.core.Robot;
29 import org.pushingpixels.substance.api.SubstanceLookAndFeel;
30 import org.pushingpixels.substance.api.SubstanceSkin;
31 import org.pushingpixels.substance.api.skin.SkinInfo;
32 import org.pushingpixels.substance.swingx.SubstanceErrorPaneUI;
33
34 /**
35 * The main method for taking screenshots for Substance documentation.
36 *
37 * @author Kirill Grouchnikov
38 */
39 public class ErrorPaneRunner {
40 public static class MyErrorPaneUI extends SubstanceErrorPaneUI {
41 public static ComponentUI createUI(JComponent c) {
42 return new MyErrorPaneUI();
43 }
44
45 @Override
46 public JDialog getErrorDialog(Component owner) {
47 JDialog result = super.getErrorDialog(owner);
48 result.setModal(false);
49 return result;
50 }
51 }
52
53 /**
54 * Runs the specified screenshot robot.
55 *
56 * @param args
57 * Ignored.
58 * @throws Exception
59 */
60 public static void main(String[] args) throws Exception {
61 JFrame.setDefaultLookAndFeelDecorated(true);
62 UIManager.put("ErrorPaneUI", MyErrorPaneUI.class.getName());
63
64 String subfolder = "errorpane";
65 Map<String, SkinInfo> skins = SubstanceLookAndFeel.getAllSkins();
66 Robot robot = BasicRobot.robotWithNewAwtHierarchy();
67 for (Map.Entry<String, SkinInfo> skinEntry : skins.entrySet()) {
68 String key = skinEntry.getKey();
69 String normalized = key.toLowerCase().replaceAll(" ", "");
70 new ErrorPaneRobot((SubstanceSkin) Class.forName(
71 skinEntry.getValue().getClassName()).newInstance(),
72 "C:/jprojects/substance-swingx/www/images/" + subfolder
73 + "/" + normalized, robot).run();
74 }
75 }
76 }