// {{{ _save() method @Override protected void _save() { jEdit.setProperty("buffer." + JEditBuffer.ENCODING, (String) defaultEncoding.getSelectedItem()); jEdit.setBooleanProperty("buffer.encodingAutodetect", encodingAutodetect.isSelected()); jEdit.setProperty("encodingDetectors", encodingDetectors.getText()); jEdit.setProperty("fallbackEncodings", fallbackEncodings.getText()); for (Entry entry : encodingsList.getValues()) { if (entry.isChecked()) { unsetProperty("encoding.opt-out." + entry.getValue()); } else { setBooleanProperty("encoding.opt-out." + entry.getValue(), true); } } } // }}}
// {{{ _init() method @Override protected void _init() { // Default file encoding String[] encodings = getEncodings(true); sort(encodings, new StandardUtilities.StringCompare<String>(true)); defaultEncoding = new JComboBox(encodings); defaultEncoding.setEditable(true); defaultEncoding.setSelectedItem( jEdit.getProperty("buffer." + JEditBuffer.ENCODING, System.getProperty("file.encoding"))); addComponent(jEdit.getProperty("options.general.encoding"), defaultEncoding); // Auto detect encoding encodingAutodetect = new JCheckBox(jEdit.getProperty("options.general.encodingAutodetect")); encodingAutodetect.setSelected(jEdit.getBooleanProperty("buffer.encodingAutodetect")); addComponent(encodingAutodetect, BOTH); // Encoding detectors encodingDetectors = new JTextField(jEdit.getProperty("encodingDetectors", "BOM XML-PI")); addComponent(jEdit.getProperty("options.general.encodingDetectors"), encodingDetectors); // Fallback Encodings fallbackEncodings = new JTextField(jEdit.getProperty("fallbackEncodings", "")); fallbackEncodings.setToolTipText( jEdit.getProperty("options.general.fallbackEncodings.tooltip")); addComponent(jEdit.getProperty("options.general.fallbackEncodings"), fallbackEncodings); // Encodings to display encodings = getEncodings(false); sort(encodings, new StandardUtilities.StringCompare<String>(true)); Vector<Entry> encodingEntriesVector = new Vector<Entry>(); boolean enableSelectAll = false; boolean enableSelectNone = false; for (String encoding : encodings) { boolean selected = !getBooleanProperty("encoding.opt-out." + encoding, false); enableSelectAll = enableSelectAll || !selected; enableSelectNone = enableSelectNone || selected; encodingEntriesVector.add(new Entry(selected, encoding)); } encodingsList = new JCheckBoxList(encodingEntriesVector); encodingsList.getModel().addTableModelListener(new TableModelHandler()); JScrollPane encodingsScrollPane = new JScrollPane(encodingsList); encodingsScrollPane.setBorder( new TitledBorder(getProperty("options.encodings.selectEncodings"))); Dimension d = encodingsList.getPreferredSize(); d.height = Math.min(d.height, 200); encodingsScrollPane.setPreferredSize(d); addComponent(encodingsScrollPane, BOTH); // Select All/None Buttons Box buttonsBox = createHorizontalBox(); buttonsBox.add(createHorizontalStrut(12)); ActionHandler actionHandler = new ActionHandler(); selectAllButton = new JButton(getProperty("options.encodings.selectAll")); selectAllButton.addActionListener(actionHandler); selectAllButton.setEnabled(enableSelectAll); buttonsBox.add(selectAllButton); buttonsBox.add(createHorizontalStrut(12)); selectNoneButton = new JButton(getProperty("options.encodings.selectNone")); selectNoneButton.addActionListener(actionHandler); selectNoneButton.setEnabled(enableSelectNone); buttonsBox.add(selectNoneButton); buttonsBox.add(createHorizontalStrut(12)); addComponent(buttonsBox); } // }}}