1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.xmlhammer.gui.preferences;
24
25 import javax.swing.Box;
26 import javax.swing.ImageIcon;
27 import javax.swing.JLabel;
28 import javax.swing.JPanel;
29 import javax.swing.JTextField;
30 import javax.swing.JTextPane;
31 import javax.swing.border.EmptyBorder;
32
33 import org.bounce.FormLayout;
34 import org.bounce.image.ImageLoader;
35 import org.xmlhammer.model.preferences.ExternalApplication;
36
37 /***
38 * Put comment...
39 *
40 * @version $Revision$, $Date$
41 * @author Edwin Dankert <edankert@gmail.com>
42 */
43
44 public class ExternalApplicationPreferencesPanel extends PreferencesPanel {
45 private static final long serialVersionUID = -4140066420809363167L;
46 private static final ImageIcon EDITOR_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/write_obj.gif");
47 private static final ImageIcon OPEN_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/file_obj.gif");
48
49 private JTextField browserExtensionsField = null;
50 private JTextField editorCommandField = null;
51 private JTextField defaultCommandField = null;
52
53 /***
54 * @param name
55 */
56 public ExternalApplicationPreferencesPanel() {
57 this(false);
58 }
59
60 /***
61 * @param name
62 */
63 public ExternalApplicationPreferencesPanel(boolean project) {
64 super("External Applications", "preferences.external", project);
65
66 JPanel preferences = new JPanel( new FormLayout( 5, 2));
67
68 browserExtensionsField = new JTextField();
69
70 preferences.add(new JLabel("Browser Extensions:"), FormLayout.LEFT);
71 preferences.add(browserExtensionsField, FormLayout.RIGHT_FILL);
72
73 preferences.add(Box.createVerticalStrut(10), FormLayout.FULL);
74
75 JTextPane label = new JTextPane();
76 label.setBorder(new EmptyBorder(5,40,5,20));
77 label.setText("The following patterns will be replaced when evaluating a command:\n" +
78 "${file} - replaced with the current selected file\n" +
79 "${line} - replaced with the line for an error\n" +
80 "${column} - replaced with the column for an error");
81 label.setEditable(false);
82 label.setBackground(this.getBackground());
83
84
85 preferences.add(label, FormLayout.FULL);
86
87 preferences.add(Box.createVerticalStrut(10), FormLayout.FULL);
88
89 editorCommandField = new JTextField();
90
91 JLabel editorLabel = new JLabel( "Editor Command:");
92 editorLabel.setIcon(EDITOR_ICON);
93
94 preferences.add(editorLabel, FormLayout.LEFT);
95 preferences.add(editorCommandField, FormLayout.RIGHT_FILL);
96
97 defaultCommandField = new JTextField();
98
99 JLabel openLabel = new JLabel( "Open Command:");
100 openLabel.setIcon(OPEN_ICON);
101
102 preferences.add(openLabel, FormLayout.LEFT);
103 preferences.add(defaultCommandField, FormLayout.RIGHT_FILL);
104
105 setCenterPane(preferences);
106 }
107
108 public void setExternalApplication(ExternalApplication external) {
109 browserExtensionsField.setText(external.getBrowserExtensions() == null ? "" : external.getBrowserExtensions());
110 defaultCommandField.setText(external.getDefaultCommand() == null ? "" : external.getDefaultCommand());
111 editorCommandField.setText(external.getEditorCommand() == null ? "" : external.getEditorCommand());
112 }
113
114 public ExternalApplication getExternalApplication() {
115 ExternalApplication external = new ExternalApplication();
116 external.setBrowserExtensions(browserExtensionsField.getText());
117 external.setDefaultCommand(defaultCommandField.getText());
118 external.setEditorCommand(editorCommandField.getText());
119
120 return external;
121 }
122
123 public void setEnabled( boolean enabled) {
124 }
125 }