01: package net.sourceforge.squirrel_sql.plugins.graph.graphtofiles;
02:
03: import net.sourceforge.squirrel_sql.fw.util.StringManager;
04: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
05: import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
06:
07: import javax.swing.*;
08: import java.awt.*;
09: import java.awt.image.BufferedImage;
10:
11: public class GraphToFilesDlg extends JDialog {
12:
13: JTabbedPane tabPages;
14: JButton btnSaveToFile;
15: JButton btnClose;
16:
17: JLabel[] lblPages;
18:
19: private static final StringManager s_stringMgr = StringManagerFactory
20: .getStringManager(GraphToFilesCtrlr.class);
21:
22: public GraphToFilesDlg(Frame owner, BufferedImage[] images)
23: throws HeadlessException {
24: super (owner);
25:
26: // i18n[graphToClipboard.title=Copy graph image pages to clipboard]
27: setTitle(s_stringMgr.getString("graphToFile.title"));
28:
29: buildGui();
30:
31: lblPages = new JLabel[images.length];
32: for (int i = 0; i < images.length; i++) {
33: lblPages[i] = new JLabel(new ImageIcon(images[i]));
34: lblPages[i].setTransferHandler(new ImageSelection());
35: tabPages.addTab("" + (i + 1), new JScrollPane(lblPages[i]));
36: }
37:
38: setSize(500, 450);
39: setVisible(true);
40:
41: GUIUtils.centerWithinParent(this );
42: }
43:
44: private void buildGui() {
45: getContentPane().setLayout(new GridBagLayout());
46:
47: GridBagConstraints gbc;
48:
49: tabPages = new JTabbedPane();
50: gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1,
51: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
52: new Insets(5, 5, 5, 5), 0, 0);
53: getContentPane().add(tabPages, gbc);
54:
55: gbc = new GridBagConstraints(0, 1, 1, 1, 1, 0,
56: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
57: new Insets(5, 5, 5, 5), 0, 0);
58: getContentPane().add(createButtonPanel(), gbc);
59: }
60:
61: private JPanel createButtonPanel() {
62: JPanel ret = new JPanel();
63:
64: GridBagConstraints gbc;
65:
66: // i18n[graphToClipboard.copyButton=Copy image from selected tab]
67: btnSaveToFile = new JButton(s_stringMgr
68: .getString("graphToFile.saveFilesTo"));
69: gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
70: GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE,
71: new Insets(5, 5, 5, 5), 0, 0);
72: ret.add(btnSaveToFile, gbc);
73:
74: gbc = new GridBagConstraints(1, 0, 1, 1, 1, 0,
75: GridBagConstraints.CENTER, GridBagConstraints.BOTH,
76: new Insets(5, 5, 5, 5), 0, 0);
77: ret.add(new JPanel(), gbc);
78:
79: // i18n[graphToClipboard.closeButton=Close]
80: btnClose = new JButton(s_stringMgr
81: .getString("graphToClipboard.closeButton"));
82: gbc = new GridBagConstraints(2, 0, 1, 1, 0, 0,
83: GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
84: new Insets(5, 5, 5, 5), 0, 0);
85: ret.add(btnClose, gbc);
86:
87: return ret;
88:
89: }
90: }
|