| 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 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
public class ExternalApplicationPreferencesPanel extends PreferencesPanel { |
| 45 |
|
private static final long serialVersionUID = -4140066420809363167L; |
| 46 |
22 |
private static final ImageIcon EDITOR_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/write_obj.gif"); |
| 47 |
22 |
private static final ImageIcon OPEN_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/file_obj.gif"); |
| 48 |
|
|
| 49 |
22 |
private JTextField browserExtensionsField = null; |
| 50 |
22 |
private JTextField editorCommandField = null; |
| 51 |
22 |
private JTextField defaultCommandField = null; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
public ExternalApplicationPreferencesPanel() { |
| 57 |
22 |
this(false); |
| 58 |
22 |
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
public ExternalApplicationPreferencesPanel(boolean project) { |
| 64 |
22 |
super("External Applications", "preferences.external", project); |
| 65 |
|
|
| 66 |
22 |
JPanel preferences = new JPanel( new FormLayout( 5, 2)); |
| 67 |
|
|
| 68 |
22 |
browserExtensionsField = new JTextField(); |
| 69 |
|
|
| 70 |
22 |
preferences.add(new JLabel("Browser Extensions:"), FormLayout.LEFT); |
| 71 |
22 |
preferences.add(browserExtensionsField, FormLayout.RIGHT_FILL); |
| 72 |
|
|
| 73 |
22 |
preferences.add(Box.createVerticalStrut(10), FormLayout.FULL); |
| 74 |
|
|
| 75 |
22 |
JTextPane label = new JTextPane(); |
| 76 |
22 |
label.setBorder(new EmptyBorder(5,40,5,20)); |
| 77 |
22 |
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 |
22 |
label.setEditable(false); |
| 82 |
22 |
label.setBackground(this.getBackground()); |
| 83 |
|
|
| 84 |
|
|
| 85 |
22 |
preferences.add(label, FormLayout.FULL); |
| 86 |
|
|
| 87 |
22 |
preferences.add(Box.createVerticalStrut(10), FormLayout.FULL); |
| 88 |
|
|
| 89 |
22 |
editorCommandField = new JTextField(); |
| 90 |
|
|
| 91 |
22 |
JLabel editorLabel = new JLabel( "Editor Command:"); |
| 92 |
22 |
editorLabel.setIcon(EDITOR_ICON); |
| 93 |
|
|
| 94 |
22 |
preferences.add(editorLabel, FormLayout.LEFT); |
| 95 |
22 |
preferences.add(editorCommandField, FormLayout.RIGHT_FILL); |
| 96 |
|
|
| 97 |
22 |
defaultCommandField = new JTextField(); |
| 98 |
|
|
| 99 |
22 |
JLabel openLabel = new JLabel( "Open Command:"); |
| 100 |
22 |
openLabel.setIcon(OPEN_ICON); |
| 101 |
|
|
| 102 |
22 |
preferences.add(openLabel, FormLayout.LEFT); |
| 103 |
22 |
preferences.add(defaultCommandField, FormLayout.RIGHT_FILL); |
| 104 |
|
|
| 105 |
22 |
setCenterPane(preferences); |
| 106 |
22 |
} |
| 107 |
|
|
| 108 |
|
public void setExternalApplication(ExternalApplication external) { |
| 109 |
22 |
browserExtensionsField.setText(external.getBrowserExtensions() == null ? "" : external.getBrowserExtensions()); |
| 110 |
22 |
defaultCommandField.setText(external.getDefaultCommand() == null ? "" : external.getDefaultCommand()); |
| 111 |
22 |
editorCommandField.setText(external.getEditorCommand() == null ? "" : external.getEditorCommand()); |
| 112 |
22 |
} |
| 113 |
|
|
| 114 |
|
public ExternalApplication getExternalApplication() { |
| 115 |
22 |
ExternalApplication external = new ExternalApplication(); |
| 116 |
22 |
external.setBrowserExtensions(browserExtensionsField.getText()); |
| 117 |
22 |
external.setDefaultCommand(defaultCommandField.getText()); |
| 118 |
22 |
external.setEditorCommand(editorCommandField.getText()); |
| 119 |
|
|
| 120 |
22 |
return external; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public void setEnabled( boolean enabled) { |
| 124 |
0 |
} |
| 125 |
|
} |