1 22 23 package org.gjt.sp.jedit.options; 24 25 import javax.swing.*; 27 import java.awt.event.*; 28 import java.util.Arrays ; 29 import org.gjt.sp.jedit.*; 30 32 33 34 public class GeneralOptionPane extends AbstractOptionPane 35 { 36 public GeneralOptionPane() 38 { 39 super("general"); 40 } 42 protected void _init() 44 { 45 46 47 String [] lineSeps = { jEdit.getProperty("lineSep.unix"), 48 jEdit.getProperty("lineSep.windows"), 49 jEdit.getProperty("lineSep.mac") }; 50 lineSeparator = new JComboBox(lineSeps); 51 String lineSep = jEdit.getProperty("buffer.lineSeparator", 52 System.getProperty("line.separator")); 53 if("\n".equals(lineSep)) 54 lineSeparator.setSelectedIndex(0); 55 else if("\r\n".equals(lineSep)) 56 lineSeparator.setSelectedIndex(1); 57 else if("\r".equals(lineSep)) 58 lineSeparator.setSelectedIndex(2); 59 addComponent(jEdit.getProperty("options.general.lineSeparator"), 60 lineSeparator); 61 62 63 String [] encodings = MiscUtilities.getEncodings(true); 64 Arrays.sort(encodings,new MiscUtilities.StringICaseCompare()); 65 encoding = new JComboBox(encodings); 66 encoding.setEditable(true); 67 encoding.setSelectedItem(jEdit.getProperty("buffer.encoding", 68 System.getProperty("file.encoding"))); 69 addComponent(jEdit.getProperty("options.general.encoding"),encoding); 70 71 72 encodingAutodetect = new JCheckBox(jEdit.getProperty( 73 "options.general.encodingAutodetect")); 74 encodingAutodetect.setSelected(jEdit.getBooleanProperty("buffer.encodingAutodetect")); 75 addComponent(encodingAutodetect); 76 77 78 String [] modCheckOptions = { 79 jEdit.getProperty("options.general.checkModStatus.nothing"), 80 jEdit.getProperty("options.general.checkModStatus.prompt"), 81 jEdit.getProperty("options.general.checkModStatus.reload"), 82 jEdit.getProperty("options.general.checkModStatus.silentreload") 83 }; 84 checkModStatus = new JComboBox(modCheckOptions); 85 if(jEdit.getBooleanProperty("autoReload")) { 86 if(jEdit.getBooleanProperty("autoReloadDialog")) 87 checkModStatus.setSelectedIndex(2); 89 else checkModStatus.setSelectedIndex(3); 91 } 92 else { 93 if(jEdit.getBooleanProperty("autoReloadDialog")) 94 checkModStatus.setSelectedIndex(1); 96 else checkModStatus.setSelectedIndex(0); 98 } 99 addComponent(jEdit.getProperty("options.general.checkModStatus"), 100 checkModStatus); 101 102 103 recentFiles = new JTextField(jEdit.getProperty( 104 "options.general.recentFiles")); 105 recentFiles.setText(jEdit.getProperty("recentFiles")); 106 addComponent(jEdit.getProperty("options.general.recentFiles"), 107 recentFiles); 108 109 110 sortRecent = new JCheckBox(jEdit.getProperty( 111 "options.general.sortRecent")); 112 sortRecent.setSelected(jEdit.getBooleanProperty("sortRecent")); 113 addComponent(sortRecent); 114 115 116 saveCaret = new JCheckBox(jEdit.getProperty( 117 "options.general.saveCaret")); 118 saveCaret.setSelected(jEdit.getBooleanProperty("saveCaret")); 119 addComponent(saveCaret); 120 121 122 persistentMarkers = new JCheckBox(jEdit.getProperty( 123 "options.general.persistentMarkers")); 124 persistentMarkers.setSelected(jEdit.getBooleanProperty( 125 "persistentMarkers")); 126 addComponent(persistentMarkers); 127 128 129 restore = new JCheckBox(jEdit.getProperty( 130 "options.general.restore")); 131 restore.setSelected(jEdit.getBooleanProperty("restore")); 132 restore.addActionListener(new ActionListener() 133 { 134 public void actionPerformed(ActionEvent evt) 135 { 136 restoreCLI.setEnabled(restore.isSelected()); 137 } 138 }); 139 140 addComponent(restore); 141 restoreCLI = new JCheckBox(jEdit.getProperty( 142 "options.general.restore.cli")); 143 restoreCLI.setSelected(jEdit.getBooleanProperty("restore.cli")); 144 restoreCLI.setEnabled(restore.isSelected()); 145 addComponent(restoreCLI); 146 147 148 sortBuffers = new JCheckBox(jEdit.getProperty( 149 "options.general.sortBuffers")); 150 sortBuffers.setSelected(jEdit.getBooleanProperty("sortBuffers")); 151 sortBuffers.addActionListener(new ActionListener() 152 { 153 public void actionPerformed(ActionEvent evt) 154 { 155 sortByName.setEnabled(sortBuffers.isSelected()); 156 } 157 }); 158 159 addComponent(sortBuffers); 160 161 162 sortByName = new JCheckBox(jEdit.getProperty( 163 "options.general.sortByName")); 164 sortByName.setSelected(jEdit.getBooleanProperty("sortByName")); 165 sortByName.setEnabled(sortBuffers.isSelected()); 166 addComponent(sortByName); 167 168 newKeyboardHandling = new JCheckBox(jEdit.getProperty("options.general.newkeyhandling")); 169 newKeyboardHandling.setSelected(jEdit.getBooleanProperty("newkeyhandling")); 170 addComponent(newKeyboardHandling); 171 172 173 } 175 protected void _save() 177 { 178 179 String lineSep = null; 180 switch(lineSeparator.getSelectedIndex()) 181 { 182 case 0: 183 lineSep = "\n"; 184 break; 185 case 1: 186 lineSep = "\r\n"; 187 break; 188 case 2: 189 lineSep = "\r"; 190 break; 191 } 192 jEdit.setProperty("buffer.lineSeparator",lineSep); 193 jEdit.setProperty("buffer.encoding",(String ) 194 encoding.getSelectedItem()); 195 jEdit.setBooleanProperty("buffer.encodingAutodetect", 196 encodingAutodetect.isSelected()); 197 switch(checkModStatus.getSelectedIndex()) 198 { 199 case 0: 200 jEdit.setBooleanProperty("autoReloadDialog",false); 201 jEdit.setBooleanProperty("autoReload",false); 202 break; 203 case 1: 204 jEdit.setBooleanProperty("autoReloadDialog",true); 205 jEdit.setBooleanProperty("autoReload",false); 206 break; 207 case 2: 208 jEdit.setBooleanProperty("autoReloadDialog",true); 209 jEdit.setBooleanProperty("autoReload",true); 210 break; 211 case 3: 212 jEdit.setBooleanProperty("autoReloadDialog",false); 213 jEdit.setBooleanProperty("autoReload",true); 214 break; 215 } 216 jEdit.setProperty("recentFiles",recentFiles.getText()); 217 jEdit.setBooleanProperty("sortRecent",sortRecent.isSelected()); 218 boolean nkh = newKeyboardHandling.isSelected(); 219 jEdit.setBooleanProperty("newkeyhandling", nkh); 220 Options.SIMPLIFIED_KEY_HANDLING = nkh; 221 jEdit.setBooleanProperty("saveCaret",saveCaret.isSelected()); 222 jEdit.setBooleanProperty("persistentMarkers", 223 persistentMarkers.isSelected()); 224 jEdit.setBooleanProperty("restore",restore.isSelected()); 225 jEdit.setBooleanProperty("restore.cli",restoreCLI.isSelected()); 226 jEdit.setBooleanProperty("sortBuffers",sortBuffers.isSelected()); 227 jEdit.setBooleanProperty("sortByName",sortByName.isSelected()); 228 } 230 private JComboBox lineSeparator; 232 private JComboBox encoding; 233 private JCheckBox encodingAutodetect; 234 private JComboBox checkModStatus; 235 private JTextField recentFiles; 236 private JCheckBox saveCaret; 237 private JCheckBox sortRecent; 238 private JCheckBox persistentMarkers; 239 private JCheckBox restore; 240 private JCheckBox restoreCLI; 241 private JCheckBox sortBuffers; 242 private JCheckBox sortByName; 243 private JCheckBox newKeyboardHandling; 244 } 246 | Popular Tags |