0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: *
0026: * The Original Software is NetBeans. The Initial Developer of the Original
0027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0028: * Microsystems, Inc. All Rights Reserved.
0029: *
0030: * If you wish your version of this file to be governed by only the CDDL
0031: * or only the GPL Version 2, indicate your decision by adding
0032: * "[Contributor] elects to include this software in this distribution
0033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034: * single choice of license, a recipient has the option to distribute
0035: * your version of this file under either the CDDL, the GPL Version 2 or
0036: * to extend the choice of license to its licensees as provided above.
0037: * However, if you add GPL Version 2 code and therefore, elected the GPL
0038: * Version 2 license, then the option applies only if the new code is
0039: * made subject to such option by the copyright holder.
0040: */
0041:
0042: package org.netbeans.modules.editor.options;
0043:
0044: import java.awt.Color;
0045: import java.awt.Insets;
0046: import java.io.IOException;
0047: import java.io.ObjectInput;
0048: import java.lang.reflect.Field;
0049: import java.util.Collections;
0050: import java.util.Map;
0051: import java.util.HashMap;
0052: import java.util.List;
0053: import java.util.ArrayList;
0054: import java.util.logging.Logger;
0055: import java.awt.Toolkit;
0056: import org.netbeans.api.editor.mimelookup.MimeLookup;
0057: import org.netbeans.editor.Settings;
0058: import org.netbeans.editor.SettingsNames;
0059: import org.netbeans.editor.SettingsDefaults;
0060: import org.netbeans.editor.SettingsUtil;
0061: import org.netbeans.editor.Coloring;
0062: import org.netbeans.editor.BaseKit;
0063: import org.netbeans.editor.Formatter;
0064: import org.netbeans.editor.MultiKeyBinding;
0065: import org.netbeans.editor.ext.ExtSettingsNames;
0066: import org.netbeans.modules.editor.NbEditorDocument;
0067: import org.netbeans.modules.editor.FormatterIndentEngine;
0068: import org.netbeans.modules.editor.IndentEngineFormatter;
0069: import org.netbeans.modules.editor.SimpleIndentEngine;
0070: import org.openide.text.IndentEngine;
0071: import java.beans.IntrospectionException;
0072: import org.openide.loaders.DataObject;
0073: import java.io.ObjectOutput;
0074: import org.openide.loaders.DataFolder;
0075: import org.openide.filesystems.FileObject;
0076: import javax.swing.KeyStroke;
0077: import java.awt.event.KeyEvent;
0078: import org.openide.util.Lookup;
0079: import org.netbeans.modules.editor.NbEditorUtilities;
0080: import java.awt.RenderingHints;
0081: import java.util.logging.Level;
0082: import java.util.prefs.Preferences;
0083: import org.netbeans.api.editor.mimelookup.MimePath;
0084: import org.netbeans.modules.editor.NbEditorKit;
0085: import org.netbeans.modules.editor.impl.KitsTracker;
0086: import org.netbeans.modules.editor.lib.ColoringMap;
0087: import org.openide.filesystems.FileUtil;
0088: import org.openide.filesystems.Repository;
0089: import org.openide.util.Utilities;
0090:
0091: /**
0092: * Options for the base editor kit.
0093: *
0094: * <b>Mime type vs editor kit class</b>
0095: *
0096: * <p>The <code>BaseOptions</code> class suffers the conceptual problem introduced
0097: * in the editor infrastructure in early days of the Netbeans project. The problem
0098: * is that an implementation class of an editor kit is used for determining the
0099: * mime type of a file being edited. Following this concept a lot of other stuff
0100: * in the editor infrastructure tied up its initialization or registration with
0101: * editor kit implementation classes. While in many situations this only causes
0102: * efficiency problems or coding annoyances it is disasterous for modules that
0103: * need to provide dynamic support for many mime types.
0104: *
0105: * <p>The following description tries to remedy the situation by providing guidelines
0106: * for writing <code>BaseOptions<code> subclasses that are nearly editor kit
0107: * independent.
0108: *
0109: * <p>First, use <code>MimeLookup</code> whenever you can and avoid using static
0110: * getters such as <code>getOptions(Class editorKitClass)</code>. Although the
0111: * current <code>MimeLookup</code> infrastructure allows registering editor related
0112: * classes in a declrative way based on a mime type the <code>getOptions</code> method
0113: * can't simply query <code>MimeLookup</code>, because it doesn't know the mime type!
0114: * The correct way of retrieving an instance of your options class from
0115: * <code>MimeLookup</code> is this:
0116: *
0117: * <pre>
0118: * MimePath mimePath = MimePath.parse("your-mime-type-here");
0119: * YourOptions options = MimeLookup.getLookup(mimePath).lookup(YourOptions.class);
0120: * </pre>
0121: *
0122: * <p>When implementing <code>BaseOptions</code> for a specific mime type override
0123: * the <code>getContentType</code> method and return your mime type. Besides the
0124: * <code>getOptions</code> method this is currently the only place in this class
0125: * where an editor kit implementation class is used.
0126: *
0127: *
0128: * @author Miloslav Metelka
0129: * @author Vita Stejskal
0130: * @version 1.1
0131: */
0132: public class BaseOptions extends OptionSupport {
0133:
0134: private static final Logger LOG = Logger
0135: .getLogger(BaseOptions.class.getName());
0136:
0137: /** Latest version of the options. It must be increased
0138: * manually when new patch is added to the options.
0139: */
0140: protected static final int LATEST_OPTIONS_VERSION = 21;
0141:
0142: protected static final String OPTIONS_VERSION_PROP = "optionsVersion"; // NOI18N
0143:
0144: /** @deprecated Use Editor Settings Storage API instead. */
0145: public static final String ABBREV_MAP_PROP = "abbrevMap"; // NOI18N
0146: public static final String BASE = "base"; // NOI18N
0147: public static final String CARET_BLINK_RATE_PROP = "caretBlinkRate"; // NOI18N
0148: public static final String CARET_COLOR_INSERT_MODE_PROP = "caretColorInsertMode"; // NOI18N
0149: public static final String CARET_COLOR_OVERWRITE_MODE_PROP = "caretColorOverwriteMode"; // NOI18N
0150: public static final String CARET_ITALIC_INSERT_MODE_PROP = "caretItalicInsertMode"; // NOI18N
0151: public static final String CARET_ITALIC_OVERWRITE_MODE_PROP = "caretItalicOverwriteMode"; // NOI18N
0152: public static final String CARET_TYPE_INSERT_MODE_PROP = "caretTypeInsertMode"; // NOI18N
0153: public static final String CARET_TYPE_OVERWRITE_MODE_PROP = "caretTypeOverwriteMode"; // NOI18N
0154: public static final String COLORING_MAP_PROP = "coloringMap"; // NOI18N
0155: public static final String EXPAND_TABS_PROP = "expandTabs"; // NOI18N
0156: public static final String FIND_HIGHLIGHT_SEARCH_PROP = "findHighlightSearch"; // NOI18N
0157: public static final String FIND_HISTORY_PROP = "findHistory"; // NOI18N
0158: public static final String FIND_HISTORY_SIZE_PROP = "findHistorySize"; // NOI18N
0159: public static final String FIND_INC_SEARCH_DELAY_PROP = "findIncSearchDelay"; // NOI18N
0160: public static final String FIND_INC_SEARCH_PROP = "findIncSearch"; // NOI18N
0161: public static final String FIND_MATCH_CASE_PROP = "findMatchCase"; // NOI18N
0162: public static final String FIND_REG_EXP_PROP = "findRegExp"; // NOI18N
0163: public static final String FIND_SMART_CASE_PROP = "findSmartCase"; // NOI18N
0164: public static final String FIND_WHOLE_WORDS_PROP = "findWholeWords"; // NOI18N
0165: public static final String FIND_WRAP_SEARCH_PROP = "findWrapSearch"; // NOI18N
0166: public static final String FIND_BLOCK_SEARCH_PROP = "findBlockSearch"; // NOI18N
0167: public static final String FONT_SIZE_PROP = "fontSize"; // NOI18N
0168: public static final String HIGHLIGHT_CARET_ROW_PROP = "highlightCaretRow"; // NOI18N
0169: public static final String HIGHLIGHT_MATCHING_BRACKET_PROP = "highlightMatchingBracket"; // NOI18N
0170: public static final String INDENT_ENGINE_PROP = "indentEngine"; // NOI18N
0171: public static final String KEY_BINDING_LIST_PROP = "keyBindingList"; // NOI18N
0172: public static final String LINE_HEIGHT_CORRECTION_PROP = "lineHeightCorrection"; // NOI18N
0173: public static final String LINE_NUMBER_VISIBLE_PROP = "lineNumberVisible"; // NOI18N
0174: public static final String MACRO_MAP_PROP = "macroMap"; // NOI18N
0175: public static final String MARGIN_PROP = "margin"; // NOI18N
0176: public static final String PAIR_CHARACTERS_COMPLETION = "pairCharactersCompletion"; // NOI18N
0177: public static final String SCROLL_FIND_INSETS_PROP = "scrollFindInsets"; // NOI18N
0178: public static final String SCROLL_JUMP_INSETS_PROP = "scrollJumpInsets"; // NOI18N
0179: public static final String SPACES_PER_TAB_PROP = "spacesPerTab"; // NOI18N
0180: public static final String STATUS_BAR_CARET_DELAY_PROP = "statusBarCaretDelay"; // NOI18N
0181: public static final String STATUS_BAR_VISIBLE_PROP = "statusBarVisible"; // NOI18N
0182: public static final String TAB_SIZE_PROP = "tabSize"; // NOI18N
0183: public static final String TEXT_LIMIT_LINE_COLOR_PROP = "textLimitLineColor"; // NOI18N
0184: public static final String TEXT_LIMIT_LINE_VISIBLE_PROP = "textLimitLineVisible"; // NOI18N
0185: public static final String TEXT_LIMIT_WIDTH_PROP = "textLimitWidth"; // NOI18N
0186: public static final String TOOLBAR_VISIBLE_PROP = "toolbarVisible"; // NOI18N
0187: public static final String TEXT_ANTIALIASING_PROP = "textAntialiasing"; // NOI18N
0188: public static final String CODE_FOLDING_PROPS_PROP = "codeFoldingProps"; // NOI18N
0189:
0190: protected static final String[] BASE_PROP_NAMES = {
0191: ABBREV_MAP_PROP, CARET_BLINK_RATE_PROP,
0192: CARET_COLOR_INSERT_MODE_PROP,
0193: CARET_COLOR_OVERWRITE_MODE_PROP,
0194: CARET_ITALIC_INSERT_MODE_PROP,
0195: CARET_ITALIC_OVERWRITE_MODE_PROP,
0196: CARET_TYPE_INSERT_MODE_PROP,
0197: CARET_TYPE_OVERWRITE_MODE_PROP, COLORING_MAP_PROP,
0198: EXPAND_TABS_PROP,
0199: FONT_SIZE_PROP,
0200: HIGHLIGHT_CARET_ROW_PROP,
0201: HIGHLIGHT_MATCHING_BRACKET_PROP,
0202: INDENT_ENGINE_PROP,
0203: KEY_BINDING_LIST_PROP,
0204: LINE_HEIGHT_CORRECTION_PROP,
0205: //LINE_NUMBER_VISIBLE_PROP,
0206: MACRO_MAP_PROP, MARGIN_PROP, PAIR_CHARACTERS_COMPLETION,
0207: SCROLL_FIND_INSETS_PROP, SCROLL_JUMP_INSETS_PROP,
0208: SPACES_PER_TAB_PROP, STATUS_BAR_CARET_DELAY_PROP,
0209: STATUS_BAR_VISIBLE_PROP, TAB_SIZE_PROP,
0210: TEXT_LIMIT_LINE_COLOR_PROP, TEXT_LIMIT_LINE_VISIBLE_PROP,
0211: TEXT_LIMIT_WIDTH_PROP, OPTIONS_VERSION_PROP };
0212:
0213: static final long serialVersionUID = -5469192431366914841L;
0214:
0215: //private static final String HELP_ID = "editing.global"; // !!! NOI18N
0216: private static final String NO_INDENT_ENGINE = "NO_INDENT_ENGINE"; // NOI18N
0217:
0218: // private transient Settings.Initializer coloringMapInitializer;
0219:
0220: /** Version of the options. It's used for patching the options. */
0221: private transient int optionsVersion;
0222:
0223: // /* Indent engine available during readExternal() */
0224: // private transient IndentEngine readExternalIndentEngine;
0225: // private transient boolean inReadExternal;
0226:
0227: private transient MIMEOptionNode mimeNode;
0228: // private transient Map defaultMacrosMap;
0229: // private transient Map defaultKeyBindingsMap;
0230: private transient MIMEOptionFolder settingsFolder;
0231: private transient boolean settingsFolderInitialization;
0232: // private transient KeyBindingSettings keyBindingsSettings;
0233: //
0234: // private transient boolean keybindingsInitialized = false;
0235: // private transient boolean loaded = false;
0236:
0237: /** Map of Kit to Options */
0238: private static final HashMap kitClass2Options = new HashMap();
0239:
0240: /** Code template expand key setting name */
0241: public static final String CODE_TEMPLATE_EXPAND_KEY = "code-template-expand-key"; // NOI18N
0242:
0243: // private Lookup.Result resultKB;
0244: // private LookupListener weakLookupListenerKB;
0245: // private LookupListener lookupListenerKB;
0246:
0247: // ------------------------------------------------------------------------
0248: // BaseOptions creation
0249: // ------------------------------------------------------------------------
0250:
0251: public BaseOptions() {
0252: this (BaseKit.class, BASE);
0253: }
0254:
0255: public BaseOptions(Class kitClass, String typeName) {
0256: super (kitClass, typeName);
0257: optionsVersion = LATEST_OPTIONS_VERSION;
0258: kitClass2Options.put(kitClass, this );
0259: // new Throwable("BaseOptions: " + getClass() + "; kitClass=" + kitClass + "; typeName=" + typeName).printStackTrace();
0260: }
0261:
0262: /**
0263: * Gets an instance of <code>BaseOptions</code> for an editir kit implementation
0264: * class. Please see description of <code>BaseKit.getKit(Class)</code> for
0265: * more details.
0266: *
0267: * @param kitClass The editor kit implementation class to get <code>BaseOptions</code> for.
0268: *
0269: * @return The <code>BaseOptions</code> or <code>null</code> if the options
0270: * can't be found or loaded for some reason.
0271: * @deprecated Use <code>MimeLookup</code> to find <code>BaseOptions</code>
0272: * instances for a mime type.
0273: * @see org.netbeans.editor.BaseKit#getKit(Class)
0274: */
0275: public static BaseOptions getOptions(Class kitClass) {
0276: BaseOptions options = null;
0277:
0278: if (kitClass != BaseKit.class && kitClass != NbEditorKit.class) {
0279: String mimeType = KitsTracker.getInstance().findMimeType(
0280: kitClass);
0281: if (mimeType != null) {
0282: Lookup lookup = MimeLookup.getLookup(MimePath
0283: .parse(mimeType));
0284: options = (BaseOptions) lookup
0285: .lookup(BaseOptions.class);
0286: }
0287: }
0288:
0289: // The old way of doing things
0290: if (options == null) {
0291: //check also all superclasses whether they are not in the
0292: //kitClass2Options map
0293: Class c = kitClass;
0294:
0295: while (c != null) {
0296: options = (BaseOptions) kitClass2Options.get(c);
0297: if (options != null)
0298: break;
0299:
0300: AllOptionsFolder.getDefault().loadMIMEOption(c, false);
0301: options = (BaseOptions) kitClass2Options.get(c);
0302: if (options != null)
0303: break;
0304:
0305: c = c.getSuperclass();
0306: }
0307: }
0308:
0309: return options;
0310: }
0311:
0312: // ------------------------------------------------------------------------
0313: // Mime type
0314: // ------------------------------------------------------------------------
0315:
0316: /**
0317: * <b>ALWAYS OVERWRITE THIS AND PROVIDE VALID MIME TYPE!</b>
0318: * @return The mime type for this BaseOptions instance.
0319: */
0320: protected String getContentType() {
0321: BaseKit kit = BaseKit.getKit(getKitClass());
0322: return kit.getContentType();
0323: }
0324:
0325: // diagnostics for #101078
0326: private String getCTImpl() {
0327: String mimeType = getContentType();
0328: if (mimeType == null) {
0329: String msg = "Can't determine mime type for "
0330: + simpleToString(this ) + "; kitClass = "
0331: + getKitClass(); //NOI18N
0332: LOG.log(Level.WARNING, null, new Throwable(msg));
0333:
0334: mimeType = "text/plain"; //NOI18N
0335: }
0336: return mimeType;
0337: }
0338:
0339: private static String simpleToString(Object o) {
0340: if (o == null) {
0341: return null;
0342: } else {
0343: return o.getClass().getName() + "@"
0344: + Integer.toHexString(System.identityHashCode(o)); //NOI18N
0345: }
0346: }
0347:
0348: // ------------------------------------------------------------------------
0349: // o.n.e.Settings initialization
0350: // ------------------------------------------------------------------------
0351:
0352: protected @Override
0353: void updateSettingsMap(Class kitClass, Map settingsMap) {
0354: // final String id = "kitClass=" + kitClass + "; getKitClass()=" + getKitClass() + "; this=" + this;
0355: // System.out.println("### USM: " + id);
0356:
0357: loadXMLSettings();
0358:
0359: super .updateSettingsMap(kitClass, settingsMap);
0360:
0361: if (kitClass == getKitClass()) {
0362: // Create evaluators for indentEngine and formatter
0363: settingsMap.put(NbEditorDocument.INDENT_ENGINE,
0364: new Settings.Evaluator() {
0365: public Object getValue(Class kitClass2,
0366: String settingName) {
0367: return getIndentEngine();
0368: }
0369: });
0370:
0371: settingsMap.put(NbEditorDocument.FORMATTER,
0372: new Settings.Evaluator() {
0373: public Object getValue(Class kitClass2,
0374: String settingName) {
0375: IndentEngine eng = getIndentEngine();
0376: return (eng != null) ? ((eng instanceof FormatterIndentEngine) ? ((FormatterIndentEngine) eng)
0377: .getFormatter()
0378: : ((Formatter) new IndentEngineFormatter(
0379: getKitClass(), eng)))
0380: : null;
0381: }
0382: });
0383:
0384: settingsMap.put(SettingsNames.RENDERING_HINTS,
0385: new Settings.Evaluator() {
0386: public Object getValue(Class kitClass2,
0387: String settingName) {
0388: return computeTextAntialiasingMap(isTextAntialiasing());
0389: }
0390: });
0391: // XXX: remove
0392: // if (coloringMapInitializer != null) {
0393: // coloringMapInitializer.updateSettingsMap(kitClass, settingsMap);
0394: // }
0395: }
0396:
0397: // XXX: remove
0398: // if (kitClass == BaseKit.class && coloringMapInitializer != null) {
0399: // coloringMapInitializer.updateSettingsMap(BaseKit.class, settingsMap);
0400: // }
0401: }
0402:
0403: // ------------------------------------------------------------------------
0404: // Antialiasing
0405: // ------------------------------------------------------------------------
0406:
0407: public boolean isTextAntialiasing() {
0408: // artificial setting -> evaluator used (at begining of this class)
0409: Boolean val = (Boolean) getSettingValue(TEXT_ANTIALIASING_PROP);
0410: if (val != null) {
0411: return val.booleanValue();
0412: } else {
0413: //XXX this prop is not used anymore, but anyway, I believe
0414: //it should have been swing.aatext - I've never seen
0415: //javax.aatext. -Tim
0416: // #56234: Check -Djavax.aatext=true
0417: if (Boolean.getBoolean("javax.aatext")) {
0418: return true;
0419:
0420: } else {
0421: // fix of #31758
0422: if (Utilities.isMac()) {
0423: // On OSX, default to true
0424: return true;
0425: } else {
0426: return isSystemAntialias();
0427: }
0428: }
0429: }
0430: }
0431:
0432: private static boolean isSystemAntialias() {
0433: Map systemHints = (Map) (Toolkit.getDefaultToolkit()
0434: .getDesktopProperty("awt.font.desktophints")); //NOI18N
0435: if (systemHints != null) {
0436: Object o = systemHints
0437: .get(RenderingHints.KEY_TEXT_ANTIALIASING);
0438: boolean result = o != null
0439: && o != RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
0440: && o != RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
0441: return result;
0442: } else {
0443: return false;
0444: }
0445: }
0446:
0447: public void setTextAntialiasing(boolean textAntialiasing) {
0448: setSettingBoolean(TEXT_ANTIALIASING_PROP, textAntialiasing,
0449: TEXT_ANTIALIASING_PROP);
0450: // Cause refresh or renderingHints variable in EditorUI
0451: Settings.touchValue(getKitClass(),
0452: SettingsNames.RENDERING_HINTS);
0453: }
0454:
0455: private Map computeTextAntialiasingMap(boolean aaSetting) {
0456:
0457: Map result;
0458:
0459: Map defaultHints = (Map) (Toolkit.getDefaultToolkit()
0460: .getDesktopProperty("awt.font.desktophints")); //NOI18N
0461:
0462: if (defaultHints != null) { // OK We're at 1.6 or higher
0463: if (true) // On 1.6 always use the default rendering hints regardless of the aaSetting
0464: return defaultHints;
0465:
0466: Object systemSetting = defaultHints
0467: .get(RenderingHints.KEY_TEXT_ANTIALIASING);
0468:
0469: if (systemSetting == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT
0470: || systemSetting == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
0471: || isGasp(systemSetting)) {
0472: result = new HashMap();
0473: result.put(RenderingHints.KEY_TEXT_ANTIALIASING,
0474: RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
0475: } else {
0476: result = defaultHints;
0477: }
0478: } else { // Lower than 1.6 Jdk
0479: if (!aaSetting) {
0480: return Collections.EMPTY_MAP;
0481: }
0482: result = new HashMap();
0483: result.put(RenderingHints.KEY_TEXT_ANTIALIASING,
0484: RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
0485: }
0486:
0487: return result;
0488: }
0489:
0490: private static Object gaspConst = RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
0491:
0492: private boolean isGasp(Object systemSetting) {
0493: // RenderingHints.VALUE_TEXT_ANTIALIAS_GASP is available on JDK 1.6+ only
0494: if (gaspConst == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) {
0495: try {
0496: Field aaConst = RenderingHints.class
0497: .getField("VALUE_TEXT_ANTIALIAS_GASP"); // NOI18N
0498: gaspConst = aaConst.get(null);
0499: } catch (NoSuchFieldException e) {
0500: gaspConst = null;
0501: } catch (IllegalAccessException e) {
0502: gaspConst = null;
0503: }
0504: }
0505:
0506: return systemSetting == gaspConst;
0507: }
0508:
0509: // ------------------------------------------------------------------------
0510: // Code Templates (formerly abbreviations) related getters & setters
0511: // ------------------------------------------------------------------------
0512:
0513: /** Saves the keystroke of code tamplate expansion into properties.xml file under Editors/text/base */
0514: public static void setCodeTemplateExpandKey(KeyStroke ks) {
0515: Settings.setValue(BaseKit.class, CODE_TEMPLATE_EXPAND_KEY,
0516: Utilities.keyToString(ks));
0517: }
0518:
0519: /** Gets Code Template Expand Key. Can return null if there is no key in the settings file */
0520: public static KeyStroke getCodeTemplateExpandKey() {
0521: String ks = (String) Settings.getValue(BaseKit.class,
0522: CODE_TEMPLATE_EXPAND_KEY);
0523: if (ks != null) {
0524: KeyStroke keyStroke = Utilities.stringToKey(ks);
0525: if (keyStroke != null) {
0526: return keyStroke;
0527: }
0528: }
0529: return KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
0530: }
0531:
0532: /**
0533: * @return The same as <code>getAbbrevMap</code>.
0534: * @deprecated Use Editor Settings API instead.
0535: */
0536: public Map<String, String> getDefaultAbbrevMap() {
0537: return getAbbrevMap();
0538: }
0539:
0540: /**
0541: * @return All code templates available for this mime type.
0542: * @deprecated Use Editor Settings API instead.
0543: */
0544: public Map<String, String> getAbbrevMap() {
0545: // Use Settings so that registered initializer, filters and evaluators
0546: // still stand a chance.
0547: @SuppressWarnings("unchecked")
0548: Map<String, String> map = (Map<String, String>) Settings
0549: .getValue(getKitClass(), SettingsNames.ABBREV_MAP, true);
0550: return map;
0551: }
0552:
0553: /**
0554: * Tries to update colorings for the mime type of this instance.
0555: *
0556: * @param map The map with colorings.
0557: * @param saveToXML Ignored.
0558: *
0559: * @deprecated Use Editor Settings Storage API instead.
0560: */
0561: public void setAbbrevMap(Map<String, String> map, boolean saveToXML) {
0562: // XXX: try harder to preseve backwards compatibility of this method
0563: // Map diffMap = null;
0564: // if (saveToXML){
0565: // // we are going to save the diff-ed changes to XML, all default
0566: // // properties have to be available
0567: // loadDefaultAbbreviations();
0568: // diffMap = OptionUtilities.getMapDiff(getAbbrevMap(),map,true);
0569: // if (diffMap.size()>0){
0570: // // settings has changed, write changed settings to XML file
0571: // updateSettings(AbbrevsMIMEProcessor.class, diffMap);
0572: // }
0573: // }
0574: // super.setSettingValue(SettingsNames.ABBREV_MAP, map, ABBREV_MAP_PROP);
0575: }
0576:
0577: /**
0578: * Calls <code>setAbbrevMap(map, true)</code>.
0579: *
0580: * @deprecated Use Editor Settings Storage API instead.
0581: */
0582: public void setAbbrevMap(Map map) {
0583: setAbbrevMap(map, true);
0584: }
0585:
0586: // ------------------------------------------------------------------------
0587: // Keybindings related getters/setters
0588: // ------------------------------------------------------------------------
0589:
0590: /**
0591: * @return The same keybindings as <code>getKeyBindingList</code>, but stored
0592: * in a map.
0593: * @deprecated Use Editor Settings and Editor Settings Storage APIs instead.
0594: */
0595: public Map<String, MultiKeyBinding> getDefaultKeyBindingsMap() {
0596: return OptionUtilities.makeKeyBindingsMap(getKBList());
0597: }
0598:
0599: private List<? extends MultiKeyBinding> getKBList() {
0600: // Use Settings so that registered initializer, filters and evaluators
0601: // still stand a chance.
0602: @SuppressWarnings("unchecked")
0603: List<? extends MultiKeyBinding> list = (List<? extends MultiKeyBinding>) Settings
0604: .getValue(getKitClass(),
0605: SettingsNames.KEY_BINDING_LIST, true);
0606: return list;
0607: }
0608:
0609: /**
0610: * @return The list of <code>MultiKeyBindings</code> available for this mime type.
0611: * The first element in the list is the name of the kit class (ie. <code>String</code>).
0612: * @deprecated Use Editor Settings and Editor Settings Storage APIs instead.
0613: */
0614: public List getKeyBindingList() {
0615: List kb2 = new ArrayList(getKBList());
0616: kb2.add(0, getKitClass().getName()); //insert kit class name
0617: return kb2;
0618: }
0619:
0620: /**
0621: * Sets new keybindings map and save the diff-ed changes to XML file. Calls
0622: * <code>setKeyBindingList(list, true)</code>.
0623: *
0624: * @param list The list with <code>MultiKeyBinding</code>s.
0625: *
0626: * @deprecated Use Editor Settings and Editor Settings Storage APIs instead.
0627: */
0628: public void setKeyBindingList(List list) {
0629: setKeyBindingList(list, true);
0630: }
0631:
0632: /**
0633: * Saves keybindings settings to XML file.
0634: * (This is used especially for record macro action.)
0635: * @deprecated Use Editor Settings and Editor Settings Storage APIs instead.
0636: */
0637: public void setKeyBindingsDiffMap(
0638: Map<String, MultiKeyBinding> diffMap) {
0639: // XXX: try harder to preseve backwards compatibility of this method
0640: // if ((diffMap != null) && (diffMap.size()>0)){
0641: // updateSettings(KeyBindingsMIMEProcessor.class, diffMap);
0642: // }
0643: }
0644:
0645: /**
0646: * Sets new keybindings list to initializer map and if saveToXML is true,
0647: * then new settings will be saved to XML file.
0648: *
0649: * @param list The list with <code>MultiKeyBinding</code>s.
0650: * @param saveToXML Ignored.
0651: *
0652: * @deprecated Use Editor Settings and Editor Settings Storage APIs instead.
0653: */
0654: public void setKeyBindingList(List list, boolean saveToXML) {
0655: // XXX: try harder to preseve backwards compatibility of this method
0656: // if( list.size() > 0 &&
0657: // ( list.get( 0 ) instanceof Class || list.get( 0 ) instanceof String )
0658: // ) {
0659: // list.remove( 0 ); //remove kit class name
0660: // }
0661: //
0662: // Map diffMap = null;
0663: // if (saveToXML){
0664: // // we are going to save the diff-ed changes to XML, all default
0665: // // properties have to be available
0666: // loadDefaultKeyBindings();
0667: // List kbMap = getKeyBindingList();
0668: // if( kbMap.size() > 0 &&
0669: // ( kbMap.get( 0 ) instanceof Class || kbMap.get( 0 ) instanceof String )
0670: // ) {
0671: // kbMap.remove( 0 ); //remove kit class name
0672: // }
0673: //
0674: // diffMap = OptionUtilities.getMapDiff(OptionUtilities.makeKeyBindingsMap(kbMap),
0675: // OptionUtilities.makeKeyBindingsMap(list),true);
0676: // if (diffMap.size()>0){
0677: // // settings has changed, write changed settings to XML file
0678: // updateSettings(KeyBindingsMIMEProcessor.class, diffMap);
0679: // }
0680: // }
0681: //
0682: // super.setSettingValue(SettingsNames.KEY_BINDING_LIST, list, KEY_BINDING_LIST_PROP);
0683: }
0684:
0685: // ------------------------------------------------------------------------
0686: // Fonts & Colors related getters/setters
0687: // ------------------------------------------------------------------------
0688:
0689: /**
0690: * Tries to gather all colorings defined for the mime type of this instance.
0691: *
0692: * @return The map with all colorings defined the mime type of this instance.
0693: * The returned map may be inaccurate, please use the new Editor Settings
0694: * API and its <code>FontColorSettings</code> class.
0695: *
0696: * @deprecated Use Editor Settings API instead.
0697: */
0698: public Map<String, Coloring> getColoringMap() {
0699: return new HashMap<String, Coloring>(ColoringMap.get(
0700: getContentType()).getMap());
0701: }
0702:
0703: /**
0704: * Calls <code>setColoringMap(coloringMap, true)</code>.
0705: *
0706: * @deprecated Use Editor Settings Storage API instead.
0707: */
0708: public void setColoringMap(Map coloringMap) {
0709: setColoringMap(coloringMap, true);
0710: }
0711:
0712: /**
0713: * Tries to update colorings for the mime type of this instance.
0714: *
0715: * @param coloringMap The map with colorings.
0716: * @param saveToXML Ignored.
0717: *
0718: * @deprecated Use Editor Settings Storage API instead.
0719: */
0720: public void setColoringMap(final Map<String, Coloring> coloringMap,
0721: boolean saveToXML) {
0722: if (coloringMap != null) {
0723: Settings.update(new Runnable() {
0724: public void run() {
0725: SettingsUtil.setColoringMap(getKitClass(),
0726: coloringMap, false);
0727: }
0728: });
0729: }
0730:
0731: // XXX: try harder to preseve backwards compatibility of this method
0732: // Map diffMap = null;
0733: // if (coloringMap != null) {
0734: //// if (inReadExternal) {
0735: // /* Fix of #11115
0736: // * The better place would be in upgradeOptions()
0737: // * which was attempted originally. However the normal
0738: // * behavior of setColoringMap() destroys the colorings
0739: // * if they are not upgraded immediately. Therefore
0740: // * the readExternalColoringMap approach was attempted.
0741: // * However there was an NPE in
0742: // * properties.syntax.EditorSettingsCopy.updateColors
0743: // * at line 235 the keyColoring was null.
0744: // * Therefore the patch appears here.
0745: // */
0746: // //coloringMap = UpgradeOptions.patchColorings(getKitClass(), coloringMap);
0747: //// }
0748: //
0749: // if (!usesNewOptionsDialog() && saveToXML){
0750: // diffMap = OptionUtilities.getMapDiff(getColoringMap(),coloringMap,false);
0751: // if (diffMap.size()>0){
0752: // // settings has changed, write changed settings to XML file
0753: // //System.out.println("SETTING COLORING MAP:"+diffMap);
0754: // updateSettings(FontsColorsMIMEProcessor.class, diffMap);
0755: // }
0756: // }
0757: //
0758: // coloringMap.remove(null); // remove kit class
0759: //
0760: // Settings.update(new Runnable() {
0761: // public void run() {
0762: // SettingsUtil.setColoringMap( getKitClass(), coloringMap, false );
0763: // }
0764: // });
0765: //
0766: // coloringMapInitializer = SettingsUtil.getColoringMapInitializer(
0767: // getKitClass(), coloringMap, false,
0768: // getTypeName() + "-coloring-map-initializer" //NOI18N
0769: // );
0770: //
0771: // firePropertyChange(COLORING_MAP_PROP, null, null);
0772: // }
0773: }
0774:
0775: /**
0776: * @deprecated Use Editor Settings API instead.
0777: */
0778: public int getFontSize() {
0779: Coloring dc = SettingsUtil.getColoring(getKitClass(),
0780: SettingsNames.DEFAULT_COLORING, false);
0781: return (dc != null) ? dc.getFont().getSize()
0782: : SettingsDefaults.defaultFont.getSize();
0783: }
0784:
0785: /**
0786: * Does nothing.
0787: *
0788: * @deprecated Use Editor Settings Storage API instead.
0789: */
0790: public void setFontSize(final int size) {
0791: // XXX: do something sensible here like changing the size of the default coloring for example
0792: //
0793: // if (size < 0) {
0794: // NbEditorUtilities.invalidArgument("MSG_NegativeValue"); // NOI18N
0795: // return;
0796: // }
0797: // final int oldSize = getFontSize();
0798: // Map cm = SettingsUtil.getColoringMap(getKitClass(), false, true); // !!! !evaluateEvaluators
0799: // if (cm != null) {
0800: // Iterator it = cm.entrySet().iterator();
0801: // while (it.hasNext()) {
0802: // Map.Entry entry = (Map.Entry)it.next();
0803: // Object value = entry.getValue();
0804: // if (value instanceof Coloring) {
0805: // Coloring c = (Coloring)value;
0806: // Font font = c.getFont();
0807: // if (font != null && font.getSize() != size) {
0808: // font = font.deriveFont((float)size);
0809: // Coloring newColoring = new Coloring(font, c.getFontMode(),
0810: // c.getForeColor(), c.getBackColor()); // this way due to bug in Coloring
0811: // entry.setValue(newColoring);
0812: // }
0813: // }
0814: // }
0815: // setColoringMap(cm);
0816: //
0817: // firePropertyChange(FONT_SIZE_PROP, null, null);
0818: // }
0819: }
0820:
0821: public float getLineHeightCorrection() {
0822: return ((Float) getSettingValue(SettingsNames.LINE_HEIGHT_CORRECTION))
0823: .floatValue();
0824: }
0825:
0826: public void setLineHeightCorrection(float f) {
0827: if (f <= 0) {
0828: NbEditorUtilities.invalidArgument("MSG_OutOfRange"); // NOI18N
0829: return;
0830: }
0831: setSettingValue(SettingsNames.LINE_HEIGHT_CORRECTION,
0832: new Float(f), LINE_HEIGHT_CORRECTION_PROP);
0833: }
0834:
0835: // ------------------------------------------------------------------------
0836: // Editor macros settings
0837: // ------------------------------------------------------------------------
0838:
0839: /**
0840: * The same as <code>getMacroMap()</code>.
0841: * @deprecated Without any replacement.
0842: */
0843: public Map getDefaultMacrosMap() {
0844: return getMacroMap();
0845: }
0846:
0847: // XXX: remove
0848: // /** Loads default abbreviations from MIMEFolder/Defaults/macros.xml and
0849: // * stores them to defaultMacrosMap */
0850: // private void loadDefaultMacros(){
0851: // if (defaultMacrosMap!=null) return;
0852: // MIMEOptionFolder mimeFolder = getMIMEFolder();
0853: // if (mimeFolder == null) return;
0854: //
0855: // MIMEOptionFolder mof = mimeFolder.getFolder(OptionUtilities.DEFAULT_FOLDER);
0856: // if (mof == null) return;
0857: //
0858: // MIMEOptionFile file = mof.getFile(MacrosMIMEProcessor.class, false);
0859: // if ((file!=null) && (!file.isLoaded())) {
0860: // file.loadSettings(false);
0861: // defaultMacrosMap = new HashMap(file.getAllProperties());
0862: // }
0863: // }
0864:
0865: // XXX: not needed in netbeans, but we may want to put it back to keep setMacroMap
0866: // backwards compatible
0867: // /** removes keybindings from deleted macros, or if macro deletion was cancelled
0868: // * it restores old keybinding value */
0869: // private void processMacroKeyBindings(Map diff, List oldKB){
0870: // List deletedKB = new ArrayList();
0871: // List addedKB = new ArrayList();
0872: // List newKB = getKBList();
0873: //
0874: // for( Iterator i = diff.keySet().iterator(); i.hasNext(); ) {
0875: // String key = (String)i.next();
0876: // if (!(diff.get(key) instanceof String)) continue;
0877: // String action = (String) diff.get(key);
0878: // String kbActionName = BaseKit.macroActionPrefix+key;
0879: //
0880: // if (action.length()!=0){
0881: // // process restored macros
0882: // for (int j = 0; j < oldKB.size(); j++){
0883: // if(oldKB.get(j) instanceof MultiKeyBinding){
0884: // MultiKeyBinding mkb = (MultiKeyBinding) oldKB.get(j);
0885: // if (!kbActionName.equals(mkb.actionName)) continue;
0886: // addedKB.add(mkb);
0887: // break;
0888: // }
0889: // }
0890: // continue;
0891: // }
0892: //
0893: // for (int j = 0; j < newKB.size(); j++){
0894: // // process deleted macros
0895: // if(newKB.get(j) instanceof MultiKeyBinding){
0896: // MultiKeyBinding mkb = (MultiKeyBinding) newKB.get(j);
0897: // if (!kbActionName.equals(mkb.actionName)) continue;
0898: // deletedKB.add(mkb);
0899: // break;
0900: // }
0901: // }
0902: // }
0903: //
0904: // if ((deletedKB.size()>0) || (addedKB.size()>0)){
0905: // newKB.removeAll(deletedKB);
0906: // newKB.addAll(addedKB);
0907: // // save changed keybindings to XML file
0908: // setKeyBindingsDiffMap(OptionUtilities.getMapDiff(OptionUtilities.makeKeyBindingsMap(getKBList()),
0909: // OptionUtilities.makeKeyBindingsMap(newKB), true));
0910: // // set new keybindings
0911: // Settings.setValue( getKitClass(), SettingsNames.KEY_BINDING_LIST, newKB);
0912: // }
0913: // }
0914:
0915: /**
0916: * @return The map of macro names (<code>String</code>) and the associated macro code (<code>String</code>).
0917: * The <code>null</code> key entry has value of <code>List<? extends MultiKeyBinding></code>.
0918: * @deprecated Without any replacement.
0919: */
0920: @SuppressWarnings("unchecked")
0921: public Map getMacroMap() {
0922: Map<String, String> settingsMap = (Map<String, String>) super
0923: .getSettingValue(SettingsNames.MACRO_MAP);
0924: Map ret = (settingsMap == null) ? new HashMap() : new HashMap(
0925: settingsMap);
0926: ret.put(null, getKBList());
0927: return ret;
0928: }
0929:
0930: /**
0931: * @deprecated Without any replacement.
0932: */
0933: public void setMacroDiffMap(Map diffMap) {
0934: // XXX: try harder to preseve backwards compatibility of this method
0935: // if ((diffMap != null) && (diffMap.size()>0)){
0936: // updateSettings(MacrosMIMEProcessor.class, diffMap);
0937: // }
0938: }
0939:
0940: /**
0941: * Sets new macros.
0942: *
0943: * <p>WARNING: This method no longer saves macro shortcuts. Use Editor Settings
0944: * Storage API to update shortcuts for your macros.
0945: *
0946: * @param macros The map with macro names mapped to macro code.
0947: * @param saveToXML Ignored.
0948: *
0949: * @deprecated Without any replacement.
0950: */
0951: public void setMacroMap(final Map macros, boolean saveToXML) {
0952: if (macros != null) {
0953: Settings.update(new Runnable() {
0954: public void run() {
0955: BaseOptions.super .setSettingValue(
0956: SettingsNames.MACRO_MAP, macros);
0957: }
0958: });
0959: }
0960:
0961: // Map diffMap = null;
0962: // List kb = new ArrayList();
0963: // if (map.containsKey(null)){
0964: // kb.addAll((List)map.get(null));
0965: // map.remove(null);
0966: // }
0967: // if (saveToXML){
0968: // // we are going to save the diff-ed changes to XML, all default
0969: // // properties have to be available
0970: // loadDefaultMacros();
0971: // diffMap = OptionUtilities.getMapDiff(getMacroMap(),map,true);
0972: // if (diffMap.containsKey(null)) diffMap.remove(null);
0973: // if (diffMap.size()>0){
0974: // // settings has changed, write changed settings to XML file
0975: //// XXX: does not work
0976: //// processMacroKeyBindings(diffMap,kb);
0977: // updateSettings(MacrosMIMEProcessor.class, diffMap);
0978: // }
0979: // }
0980: //
0981: // super.setSettingValue(SettingsNames.MACRO_MAP, map);
0982: }
0983:
0984: /**
0985: * Sets new macros. This method calls <code>setMacroMap(map, true)</code>.
0986: * @param macros The map with macro names mapped to macro code.
0987: * @deprecated Without any replacement.
0988: */
0989: public void setMacroMap(Map macros) {
0990: setMacroMap(macros, true);
0991: }
0992:
0993: // ------------------------------------------------------------------------
0994: // Miscellaneous getters & setters
0995: // ------------------------------------------------------------------------
0996:
0997: public int getTabSize() {
0998: return getSettingInteger(SettingsNames.TAB_SIZE);
0999: }
1000:
1001: public void setTabSize(int tabSize) {
1002: if (tabSize < 0) {
1003: NbEditorUtilities.invalidArgument("MSG_NegativeValue"); // NOI18N
1004: return;
1005: }
1006: setSettingInteger(SettingsNames.TAB_SIZE, tabSize,
1007: TAB_SIZE_PROP);
1008: }
1009:
1010: /* public boolean getExpandTabs() {
1011: return getSettingBoolean(SettingsNames.EXPAND_TABS);
1012: }
1013: [Mila] Moved to IndentEngine; Setter must stay here
1014: */
1015:
1016: public void setExpandTabs(boolean expandTabs) {
1017: setSettingBoolean(SettingsNames.EXPAND_TABS, expandTabs,
1018: EXPAND_TABS_PROP);
1019: }
1020:
1021: /* public int getSpacesPerTab() {
1022: return getSettingInteger(SettingsNames.SPACES_PER_TAB);
1023: }
1024: [Mila] Moved to IndentEngine; Setter must stay here
1025: */
1026: public void setSpacesPerTab(int i) {
1027: if (i > 0)
1028: setSettingInteger(SettingsNames.SPACES_PER_TAB, i,
1029: SPACES_PER_TAB_PROP);
1030: else
1031: Toolkit.getDefaultToolkit().beep();
1032: }
1033:
1034: public String getCaretTypeInsertMode() {
1035: return (String) getSettingValue(SettingsNames.CARET_TYPE_INSERT_MODE);
1036: }
1037:
1038: public void setCaretTypeInsertMode(String type) {
1039: setSettingValue(SettingsNames.CARET_TYPE_INSERT_MODE, type,
1040: CARET_TYPE_INSERT_MODE_PROP);
1041: }
1042:
1043: public String getCaretTypeOverwriteMode() {
1044: return (String) getSettingValue(SettingsNames.CARET_TYPE_OVERWRITE_MODE);
1045: }
1046:
1047: public void setCaretTypeOverwriteMode(String type) {
1048: setSettingValue(SettingsNames.CARET_TYPE_OVERWRITE_MODE, type,
1049: CARET_TYPE_OVERWRITE_MODE_PROP);
1050: }
1051:
1052: /**
1053: *@deprecated since adaptation to new view implementation
1054: the option is not supported
1055: */
1056: public boolean getCaretItalicInsertMode() {
1057: return false;//getSettingBoolean(SettingsNames.CARET_ITALIC_INSERT_MODE);
1058: }
1059:
1060: /**
1061: *@deprecated since adaptation to new view implementation
1062: the option is not supported
1063: */
1064: public void setCaretItalicInsertMode(boolean b) {
1065: setSettingBoolean(SettingsNames.CARET_ITALIC_INSERT_MODE, b,
1066: CARET_ITALIC_INSERT_MODE_PROP);
1067: }
1068:
1069: /**
1070: *@deprecated since adaptation to new view implementation
1071: the option is not supported
1072: */
1073: public boolean getCaretItalicOverwriteMode() {
1074: return false;//getSettingBoolean(SettingsNames.CARET_ITALIC_OVERWRITE_MODE);
1075: }
1076:
1077: /**
1078: *@deprecated since adaptation to new view implementation
1079: the option is not supported
1080: */
1081: public void setCaretItalicOverwriteMode(boolean b) {
1082: setSettingBoolean(SettingsNames.CARET_ITALIC_OVERWRITE_MODE, b,
1083: CARET_ITALIC_OVERWRITE_MODE_PROP);
1084: }
1085:
1086: public Color getCaretColorInsertMode() {
1087: return (Color) super
1088: .getSettingValue(SettingsNames.CARET_COLOR_INSERT_MODE);
1089: }
1090:
1091: /** Sets new CaretColorInsertMode property to initializer map and save the
1092: * changes to XML file */
1093: public void setCaretColorInsertMode(Color color) {
1094: setCaretColorInsertMode(color, true);
1095: }
1096:
1097: /** Sets new CaretColorInsertMode property to initializer map and if saveToXML is true,
1098: * then new settings will be saved to XML file (fontsColors.xml). */
1099: public void setCaretColorInsertMode(Color color, boolean saveToXML) {
1100: super .setSettingValue(SettingsNames.CARET_COLOR_INSERT_MODE,
1101: color, CARET_COLOR_INSERT_MODE_PROP);
1102: }
1103:
1104: public Color getCaretColorOverwriteMode() {
1105: return (Color) super
1106: .getSettingValue(SettingsNames.CARET_COLOR_OVERWRITE_MODE);
1107: }
1108:
1109: /** Sets new CaretColorOverwriteMode property to initializer map and save the
1110: * changes to XML file */
1111: public void setCaretColorOverwriteMode(Color color) {
1112: setCaretColorOverwriteMode(color, true);
1113: }
1114:
1115: /** Sets new CaretColorOverwriteMode property to initializer map and if saveToXML is true,
1116: * then new settings will be saved to XML file (fontsColors.xml). */
1117: public void setCaretColorOverwriteMode(Color color,
1118: boolean saveToXML) {
1119: super .setSettingValue(SettingsNames.CARET_COLOR_OVERWRITE_MODE,
1120: color, CARET_COLOR_OVERWRITE_MODE_PROP);
1121: }
1122:
1123: public int getCaretBlinkRate() {
1124: return getSettingInteger(SettingsNames.CARET_BLINK_RATE);
1125: }
1126:
1127: public void setCaretBlinkRate(int rate) {
1128: if (rate < 0) {
1129: NbEditorUtilities.invalidArgument("MSG_NegativeValue"); // NOI18N
1130: return;
1131: }
1132: setSettingInteger(SettingsNames.CARET_BLINK_RATE, rate,
1133: CARET_BLINK_RATE_PROP);
1134: }
1135:
1136: public boolean getLineNumberVisible() {
1137: return getSettingBoolean(SettingsNames.LINE_NUMBER_VISIBLE);
1138: }
1139:
1140: public void setLineNumberVisible(boolean b) {
1141: setSettingBoolean(SettingsNames.LINE_NUMBER_VISIBLE, b,
1142: LINE_NUMBER_VISIBLE_PROP);
1143: }
1144:
1145: public Insets getScrollJumpInsets() {
1146: return (Insets) getSettingValue(SettingsNames.SCROLL_JUMP_INSETS);
1147: }
1148:
1149: public void setScrollJumpInsets(Insets i) {
1150: setSettingValue(SettingsNames.SCROLL_JUMP_INSETS, i,
1151: SCROLL_JUMP_INSETS_PROP);
1152: }
1153:
1154: public Insets getScrollFindInsets() {
1155: return (Insets) getSettingValue(SettingsNames.SCROLL_FIND_INSETS);
1156: }
1157:
1158: public void setScrollFindInsets(Insets i) {
1159: setSettingValue(SettingsNames.SCROLL_FIND_INSETS, i,
1160: SCROLL_FIND_INSETS_PROP);
1161: }
1162:
1163: public Insets getMargin() {
1164: return (Insets) getSettingValue(SettingsNames.MARGIN);
1165: }
1166:
1167: public void setMargin(Insets i) {
1168: setSettingValue(SettingsNames.MARGIN, i, MARGIN_PROP);
1169: }
1170:
1171: public boolean getStatusBarVisible() {
1172: return getSettingBoolean(SettingsNames.STATUS_BAR_VISIBLE);
1173: }
1174:
1175: public void setStatusBarVisible(boolean v) {
1176: setSettingBoolean(SettingsNames.STATUS_BAR_VISIBLE, v,
1177: STATUS_BAR_VISIBLE_PROP);
1178: }
1179:
1180: public int getStatusBarCaretDelay() {
1181: return getSettingInteger(SettingsNames.STATUS_BAR_CARET_DELAY);
1182: }
1183:
1184: public void setStatusBarCaretDelay(int delay) {
1185: if (delay < 0) {
1186: NbEditorUtilities.invalidArgument("MSG_NegativeValue"); // NOI18N
1187: return;
1188: }
1189: setSettingInteger(SettingsNames.STATUS_BAR_CARET_DELAY, delay,
1190: STATUS_BAR_CARET_DELAY_PROP);
1191: }
1192:
1193: public boolean getFindHighlightSearch() {
1194: return getSettingBoolean(SettingsNames.FIND_HIGHLIGHT_SEARCH);
1195: }
1196:
1197: public void setFindHighlightSearch(boolean b) {
1198: setSettingBoolean(SettingsNames.FIND_HIGHLIGHT_SEARCH, b,
1199: FIND_HIGHLIGHT_SEARCH_PROP);
1200: }
1201:
1202: public boolean getFindBlockSearch() {
1203: return getSettingBoolean(SettingsNames.FIND_BLOCK_SEARCH);
1204: }
1205:
1206: public void setFindBlockSearch(boolean b) {
1207: setSettingBoolean(SettingsNames.FIND_BLOCK_SEARCH, b,
1208: FIND_BLOCK_SEARCH_PROP);
1209: }
1210:
1211: public boolean getFindIncSearch() {
1212: return getSettingBoolean(SettingsNames.FIND_INC_SEARCH);
1213: }
1214:
1215: public void setFindIncSearch(boolean b) {
1216: setSettingBoolean(SettingsNames.FIND_INC_SEARCH, b,
1217: FIND_INC_SEARCH_PROP);
1218: }
1219:
1220: public int getFindIncSearchDelay() {
1221: return getSettingInteger(SettingsNames.FIND_INC_SEARCH_DELAY);
1222: }
1223:
1224: public void setFindIncSearchDelay(int delay) {
1225: if (delay < 0) {
1226: NbEditorUtilities.invalidArgument("MSG_NegativeValue"); // NOI18N
1227: return;
1228: }
1229: setSettingInteger(SettingsNames.FIND_INC_SEARCH_DELAY, delay,
1230: FIND_INC_SEARCH_DELAY_PROP);
1231: }
1232:
1233: public boolean getFindWrapSearch() {
1234: return getSettingBoolean(SettingsNames.FIND_WRAP_SEARCH);
1235: }
1236:
1237: public void setFindWrapSearch(boolean b) {
1238: setSettingBoolean(SettingsNames.FIND_WRAP_SEARCH, b,
1239: FIND_WRAP_SEARCH_PROP);
1240: }
1241:
1242: public boolean getFindSmartCase() {
1243: return getSettingBoolean(SettingsNames.FIND_SMART_CASE);
1244: }
1245:
1246: public void setFindSmartCase(boolean b) {
1247: setSettingBoolean(SettingsNames.FIND_SMART_CASE, b,
1248: FIND_SMART_CASE_PROP);
1249: }
1250:
1251: public Map getFindHistory() {
1252: return new HashMap(
1253: (Map) getSettingValue(SettingsNames.FIND_HISTORY));
1254: }
1255:
1256: public void setFindHistory(Map m) {
1257: setSettingValue(SettingsNames.FIND_HISTORY, m,
1258: FIND_HISTORY_PROP);
1259: }
1260:
1261: public int getFindHistorySize() {
1262: return getSettingInteger(SettingsNames.FIND_HISTORY_SIZE);
1263: }
1264:
1265: public void setFindHistorySize(int size) {
1266: setSettingInteger(SettingsNames.FIND_HISTORY_SIZE, size,
1267: FIND_HISTORY_SIZE_PROP);
1268: }
1269:
1270: public boolean getPairCharactersCompletion() {
1271: return getSettingBoolean(SettingsNames.PAIR_CHARACTERS_COMPLETION);
1272: }
1273:
1274: public void setPairCharactersCompletion(boolean v) {
1275: setSettingBoolean(SettingsNames.PAIR_CHARACTERS_COMPLETION, v,
1276: PAIR_CHARACTERS_COMPLETION);
1277: }
1278:
1279: public Color getTextLimitLineColor() {
1280: return (Color) super
1281: .getSettingValue(SettingsNames.TEXT_LIMIT_LINE_COLOR);
1282: }
1283:
1284: /**
1285: * Sets new TextLimitLineColor property to initializer map and save the
1286: * changes to XML file
1287: *
1288: * @deprecated Use Editor Settings Storage API instead.
1289: */
1290: public void setTextLimitLineColor(Color color) {
1291: setTextLimitLineColor(color, true);
1292: }
1293:
1294: /**
1295: * Sets new TextLimitLineColor property to initializer map and if saveToXML is true,
1296: * then new settings will be saved to XML file (fontsColors.xml).
1297: *
1298: * @deprecated Use Editor Settings Storage API instead.
1299: */
1300: public void setTextLimitLineColor(Color color, boolean saveToXML) {
1301: super .setSettingValue(SettingsNames.TEXT_LIMIT_LINE_COLOR,
1302: color, TEXT_LIMIT_LINE_COLOR_PROP);
1303: }
1304:
1305: public int getTextLimitWidth() {
1306: return getSettingInteger(SettingsNames.TEXT_LIMIT_WIDTH);
1307: }
1308:
1309: public void setTextLimitWidth(int width) {
1310: if (width <= 0) {
1311: NbEditorUtilities.invalidArgument("MSG_OutOfRange"); // NOI18N
1312: return;
1313: }
1314: setSettingInteger(SettingsNames.TEXT_LIMIT_WIDTH, width,
1315: TEXT_LIMIT_WIDTH_PROP);
1316: }
1317:
1318: public boolean getTextLimitLineVisible() {
1319: return getSettingBoolean(SettingsNames.TEXT_LIMIT_LINE_VISIBLE);
1320: }
1321:
1322: public void setTextLimitLineVisible(boolean visible) {
1323: setSettingBoolean(SettingsNames.TEXT_LIMIT_LINE_VISIBLE,
1324: visible, TEXT_LIMIT_LINE_VISIBLE_PROP);
1325: }
1326:
1327: public boolean getHighlightMatchingBracket() {
1328: return getSettingBoolean(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE);
1329: }
1330:
1331: public void setHighlightMatchingBracket(boolean highlight) {
1332: setSettingBoolean(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
1333: highlight, HIGHLIGHT_MATCHING_BRACKET_PROP);
1334: }
1335:
1336: public boolean getHighlightCaretRow() {
1337: return getSettingBoolean(ExtSettingsNames.HIGHLIGHT_CARET_ROW);
1338: }
1339:
1340: public void setHighlightCaretRow(boolean highlight) {
1341: setSettingBoolean(ExtSettingsNames.HIGHLIGHT_CARET_ROW,
1342: highlight, HIGHLIGHT_CARET_ROW_PROP);
1343: }
1344:
1345: public boolean isToolbarVisible() {
1346: return getSettingBoolean(TOOLBAR_VISIBLE_PROP);
1347: }
1348:
1349: public void setToolbarVisible(boolean toolbarVisible) {
1350: setSettingBoolean(TOOLBAR_VISIBLE_PROP, toolbarVisible,
1351: TOOLBAR_VISIBLE_PROP);
1352: }
1353:
1354: public Map<String, Boolean> getCodeFoldingProps() {
1355: Map<String, Boolean> map = new HashMap<String, Boolean>();
1356:
1357: Boolean val = (Boolean) getSettingValue(SettingsNames.CODE_FOLDING_ENABLE);
1358: map.put(SettingsNames.CODE_FOLDING_ENABLE, val);
1359:
1360: return map;
1361: }
1362:
1363: public void setCodeFoldingProps(Map props) {
1364: String name = SettingsNames.CODE_FOLDING_ENABLE;
1365: setSettingValue(name, props.get(name));
1366: }
1367:
1368: /**
1369: * Retrieves the actions from XML file.
1370: * @deprecated Use the layers, ie. Editors/<mime-type>/Popup.
1371: */
1372: public void initPopupMenuItems() {
1373: // XXX: remove
1374: // List orderedPopupFiles = getOrderedMultiPropertyFolderFiles("Popup"); //NOI18N
1375: // if (orderedPopupFiles.size() >0){
1376: // super.setSettingValue(ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST,
1377: // OptionUtilities.getPopupStrings(orderedPopupFiles)); //NOI18N
1378: // }
1379: }
1380:
1381: // ------------------------------------------------------------------------
1382: // IndentEngines related stuff
1383: // ------------------------------------------------------------------------
1384:
1385: public IndentEngine getIndentEngine() {
1386: // XXX: remove
1387: // // Due to #11212
1388: // if (inReadExternal) {
1389: // return readExternalIndentEngine;
1390: // }
1391: //
1392: if (!BASE.equals(getTypeName())) {
1393: Preferences prefs = MimeLookup.getLookup(
1394: MimePath.parse(getContentType())).lookup(
1395: Preferences.class);
1396: String handle = prefs != null ? prefs.get(
1397: INDENT_ENGINE_PROP, null) : null;
1398: if (handle != null) {
1399: Object instance = null;
1400: String handleString = (String) handle;
1401:
1402: if (handleString.equals(NO_INDENT_ENGINE)) {
1403: return IndentEngine.getDefault();
1404: }
1405:
1406: Lookup.Template tmp = new Lookup.Template(null,
1407: handleString, null);
1408: Lookup.Item item = Lookup.getDefault().lookupItem(tmp);
1409: if (item != null) {
1410: instance = item.getInstance();
1411: if (instance instanceof IndentEngine) {
1412: return (IndentEngine) instance;
1413: }
1414: }
1415: }
1416: }
1417:
1418: // [BACKWARD-COMPATIBILITY-START]
1419: /* Either handle or real indent-egine is attempted
1420: * to be obtained from property.
1421: */
1422: Object o = getProperty(INDENT_ENGINE_PROP);
1423: if (o instanceof IndentEngine.Handle) {
1424: IndentEngine eng = (IndentEngine) ((IndentEngine.Handle) o)
1425: .getServiceType();
1426: if (eng != null) {
1427: setIndentEngine(eng);
1428: return eng;
1429: }
1430:
1431: } else if (o instanceof IndentEngine) {
1432: setIndentEngine((IndentEngine) o);
1433: return (IndentEngine) o;
1434: }
1435: // [BACKWARD-COMPATIBILITY-END]
1436:
1437: // Try to find the default indent engine in Services registry
1438: IndentEngine eng = findDefaultIndentEngine();
1439: if (eng != null) { // found
1440: setIndentEngine(eng);
1441: }
1442:
1443: return eng;
1444: }
1445:
1446: public void setIndentEngine(IndentEngine eng) {
1447: // XXX: remove
1448: // /* Disabled direct setting of the engine
1449: // * during project deserialization to avoid doubled
1450: // * indent engine as described in #9687
1451: // */
1452: // if (!inReadExternal) {
1453: String id = null;
1454: if (eng != null) {
1455: Lookup.Template tmp = new Lookup.Template(null, null, eng);
1456: Lookup.Item item = Lookup.getDefault().lookupItem(tmp);
1457: if (item != null) {
1458: id = item.getId();
1459: }
1460: }
1461:
1462: if (!BASE.equals(getTypeName())) {
1463: Preferences prefs = MimeLookup.getLookup(
1464: MimePath.parse(getContentType())).lookup(
1465: Preferences.class);
1466: if (id == null) {
1467: id = NO_INDENT_ENGINE;
1468: }
1469: if (prefs != null) {
1470: prefs.put(INDENT_ENGINE_PROP, id);
1471: } else {
1472: LOG.warning("Could not find Preferences instance for "
1473: + getContentType());
1474: }
1475: }
1476:
1477: refreshIndentEngineSettings();
1478: // }
1479: }
1480:
1481: private void refreshIndentEngineSettings() {
1482: // Touches the settings
1483: Settings.update(new Runnable() {
1484: public void run() {
1485: Settings.touchValue(getKitClass(),
1486: NbEditorDocument.INDENT_ENGINE);
1487: Settings.touchValue(getKitClass(),
1488: NbEditorDocument.FORMATTER);
1489: }
1490:
1491: public boolean asynchronous() {
1492: return true;
1493: }
1494: });
1495: }
1496:
1497: /** Return class of the default indentation engine. */
1498: protected Class getDefaultIndentEngineClass() {
1499: return SimpleIndentEngine.class;
1500: }
1501:
1502: private IndentEngine findDefaultIndentEngine() {
1503: if (getDefaultIndentEngineClass() != null) {
1504: return (IndentEngine) Lookup.getDefault().lookup(
1505: getDefaultIndentEngineClass());
1506: }
1507:
1508: return null;
1509: }
1510:
1511: // ------------------------------------------------------------------------
1512: // Options versioning
1513: // ------------------------------------------------------------------------
1514:
1515: /**
1516: * @deprecated Without any replacement.
1517: */
1518: public void setOptionsVersion(int optionsVersion) {
1519: int oldOptionsVersion = this .optionsVersion;
1520: this .optionsVersion = optionsVersion;
1521:
1522: if (optionsVersion != oldOptionsVersion) {
1523: firePropertyChange(OPTIONS_VERSION_PROP, new Integer(
1524: oldOptionsVersion), new Integer(optionsVersion));
1525: }
1526: }
1527:
1528: /**
1529: * @deprecated Without any replacement.
1530: */
1531: public int getOptionsVersion() {
1532: return optionsVersion;
1533: }
1534:
1535: /**
1536: * Upgrade the deserialized options.
1537: * @param version deserialized version of the options
1538: * @param latestVersion latest version of the options
1539: * that will be set to them after they are upgraded
1540: * @deprecated Without any replacement. This method is never called.
1541: */
1542: protected void upgradeOptions(int version, int latestVersion) {
1543: // Upgrade in separate class to avoid messing up BaseOptions
1544: //UpgradeOptions.upgradeOptions(this, version, latestVersion);
1545: }
1546:
1547: // ------------------------------------------------------------------------
1548: // XML-ization & MIME* stuff
1549: // ------------------------------------------------------------------------
1550:
1551: /**
1552: * @return The <code>MIMEOptionFolder</code> instance for the mime type of
1553: * this <code>BaseOptions</code> instance.
1554: * @deprecated Use Editor Settings Storage API.
1555: */
1556: protected MIMEOptionFolder getMIMEFolder() {
1557: /* #25541 - Instead of synchronized getMIMEFolder() the kit
1558: * is first obtained and then the synchronization is done
1559: * to avoid the deadlock caused by locking in opposite order.
1560: */
1561: String name = getCTImpl();
1562: if (name == null) {
1563: return null;
1564: }
1565:
1566: synchronized (Settings.class) {
1567: if (settingsFolderInitialization) {
1568: return null;
1569: }
1570: settingsFolderInitialization = true;
1571: try {
1572: // return already initialized folder
1573: if (settingsFolder != null) {
1574: return settingsFolder;
1575: }
1576:
1577: FileObject f = Repository.getDefault()
1578: .getDefaultFileSystem().findResource(
1579: AllOptionsFolder.FOLDER + "/" + name); //NOI18N
1580:
1581: // MIME folder doesn't exist, let's create it
1582: if (f == null) {
1583: FileObject fo = Repository.getDefault()
1584: .getDefaultFileSystem().findResource(
1585: AllOptionsFolder.FOLDER);
1586: if (fo != null) {
1587: try {
1588: FileUtil.createFolder(fo, name);
1589: } catch (IOException ioe) {
1590: LOG.log(Level.WARNING, null, ioe);
1591: }
1592:
1593: f = Repository.getDefault()
1594: .getDefaultFileSystem().findResource(
1595: AllOptionsFolder.FOLDER + "/"
1596: + name); // NOI18N
1597: }
1598: }
1599:
1600: if (f != null) {
1601: try {
1602: DataObject d = DataObject.find(f);
1603: DataFolder df = (DataFolder) d
1604: .getCookie(DataFolder.class);
1605: if (df != null) {
1606: settingsFolder = new MIMEOptionFolder(df,
1607: this );
1608: return settingsFolder;
1609: }
1610: } catch (org.openide.loaders.DataObjectNotFoundException ex) {
1611: LOG.log(Level.WARNING, null, ex);
1612: }
1613: }
1614:
1615: return null;
1616: } finally {
1617: settingsFolderInitialization = false;
1618: }
1619: }
1620: }
1621:
1622: /** Gets MIMEOptionNode that belongs to this bean */
1623: public MIMEOptionNode getMimeNode() {
1624: synchronized (Settings.class) {
1625: if (mimeNode == null) {
1626: createMIMENode(getTypeName());
1627: }
1628: return mimeNode;
1629: }
1630: }
1631:
1632: /** Creates Node in global options for appropriate MIME type */
1633: private void createMIMENode(String typeName) {
1634: if (typeName.equals(BASE)) {
1635: return;
1636: }
1637: try {
1638: mimeNode = new MIMEOptionNode(this );
1639: } catch (IntrospectionException ie) {
1640: LOG.log(Level.WARNING, null, ie);
1641: }
1642: }
1643:
1644: // XXX: remove
1645: // /** Load settings from XML files and initialize changes */
1646: // private void loadSettings(Class processor){
1647: // MIMEOptionFile file;
1648: // if (BASE.equals(getTypeName())){
1649: // MIMEOptionFolder mimeFolder = AllOptionsFolder.getDefault().getMIMEFolder();
1650: // if (mimeFolder == null) return;
1651: // file= mimeFolder.getFile(processor, false);
1652: // }else{
1653: // MIMEOptionFolder mimeFolder = getMIMEFolder();
1654: // if (mimeFolder == null) return;
1655: // file= mimeFolder.getFile(processor, false);
1656: // }
1657: // if ((file!=null) && (!file.isLoaded())) {
1658: // file.loadSettings();
1659: // }
1660: // }
1661: //
1662: // /** Save changes to XML files.
1663: // * @see #updateSettings(java.lang.Class, java.util.Map, boolean )
1664: // */
1665: // private void updateSettings(Class processor, Map settings){
1666: // updateSettings(processor, settings, true);
1667: // }
1668: //
1669: // /** Save changes to XML files
1670: // * @param processor MIMEProcessor class
1671: // * @param settings the settings map
1672: // * @param useRequestProcessorForSaving if true settings will be saved in RequestProcessor thread.
1673: // */
1674: // private void updateSettings(Class processor, Map settings, boolean useRequestProcessorForSaving){
1675: // if (processor == FontsColorsMIMEProcessor.class ||
1676: // processor == KeyBindingsMIMEProcessor.class ||
1677: // processor == AbbrevsMIMEProcessor.class ||
1678: // processor == MacrosMIMEProcessor.class
1679: // ) {
1680: // return;
1681: // }
1682: //
1683: // MIMEOptionFile fileX;
1684: // MIMEOptionFolder mimeFolder;
1685: // if (BASE.equals(getTypeName())){
1686: // mimeFolder = AllOptionsFolder.getDefault().getMIMEFolder();
1687: // if (mimeFolder == null) return;
1688: // fileX = mimeFolder.getFile(processor, true);
1689: // }else{
1690: // mimeFolder = getMIMEFolder();
1691: // if (mimeFolder == null) return;
1692: // fileX = mimeFolder.getFile(processor, true);
1693: // }
1694: // final Map finalSettings = settings;
1695: // final MIMEOptionFile file = fileX;
1696: // if (file!=null){
1697: // if (useRequestProcessorForSaving){
1698: // Settings.update(new Runnable() {
1699: // public void run() {
1700: // file.setAllProperties(finalSettings);
1701: // }
1702: // public boolean asynchronous() {
1703: // return true;
1704: // }
1705: // });
1706: // }else{
1707: // file.setAllProperties(finalSettings);
1708: // }
1709: //
1710: // } else {
1711: // LOG.info("A settings file for " + processor + " does not exist in " + mimeFolder.getDataFolder()); //NOI18N
1712: // }
1713: // }
1714: //
1715: // public @Override void setSettingValue(String settingName, Object newValue) {
1716: // setSettingValue(settingName, newValue, settingName);
1717: // }
1718: //
1719: // private boolean isTheSame(String settingName, Object newValue){
1720: // if (settingName == null ||
1721: // settingName.equals(NbEditorDocument.INDENT_ENGINE) ||
1722: // settingName.equals(NbEditorDocument.FORMATTER)
1723: // ) {
1724: // return true;
1725: // }
1726: // Object oldValue = getSettingValue(settingName);
1727: // if ((oldValue == null && newValue == null)
1728: // || (oldValue != null && oldValue.equals(newValue))
1729: // ) {
1730: // return true; // the same object
1731: // }
1732: // return false;
1733: // }
1734: //
1735: //
1736: // /** Sets setting value to initializer Map and save the changes to XML file
1737: // * (properties.xml) */
1738: // public @Override void setSettingValue(String settingName, Object newValue, String propertyName) {
1739: // if (!isTheSame(settingName, newValue)){
1740: // super.setSettingValue(settingName,newValue,propertyName);
1741: //
1742: // // Save it
1743: // Map map = new HashMap();
1744: // map.put(settingName, newValue);
1745: // updateSettings(PropertiesMIMEProcessor.class, map);
1746: // }
1747: // }
1748: //
1749: // public @Override Object getSettingValue(String settingName) {
1750: // loadSettings(PropertiesMIMEProcessor.class);
1751: // return super.getSettingValue(settingName);
1752: // }
1753: //
1754: // protected final @Override void setSettingBoolean(String settingName, boolean newValue, String propertyName) {
1755: // setSettingValue(settingName, newValue ? Boolean.TRUE : Boolean.FALSE);
1756: // }
1757: //
1758: // protected final @Override void setSettingInteger(String settingName, int newValue, String propertyName) {
1759: // setSettingValue(settingName, new Integer(newValue));
1760: // }
1761:
1762: /**
1763: * Load all available settings from XML files and initialize them.
1764: * @deprecated Use Editor Settings Storage API instead. This method is never called.
1765: */
1766: protected void loadXMLSettings() {
1767: // XXX: remove
1768: // if (!loaded) {
1769: // loaded = true;
1770: // if (LOG.isLoggable(Level.FINE)) {
1771: // LOG.fine("Loading " + getClass() + "; mimeType='" + getCTImpl() + "'"); //NOI18N
1772: // }
1773: //
1774: // loadSettings(PropertiesMIMEProcessor.class);
1775: //
1776: // if (LOG.isLoggable(Level.FINE)) {
1777: // LOG.fine("Loaded! " + getClass() + "; mimeType='" + getCTImpl() + "'"); //NOI18N
1778: // }
1779: // } else {
1780: // if (LOG.isLoggable(Level.FINE)) {
1781: // LOG.fine("Already loaded! " + getClass() + "; mimeType='" + getCTImpl() + "'"); //NOI18N
1782: // }
1783: // }
1784: }
1785:
1786: // ------------------------------------------------------------------------
1787: // Serialization, Externalization, etc
1788: // ------------------------------------------------------------------------
1789:
1790: /**
1791: * @deprecated Use Editor Settings Storage API instead. BaseOptions are no longer serialized.
1792: */
1793: public @Override
1794: void readExternal(ObjectInput in) throws IOException,
1795: ClassNotFoundException {
1796: // XXX: remove
1797: // /** Hold the current indent engine due to #11212 */
1798: // readExternalIndentEngine = getIndentEngine();
1799: // inReadExternal = true;
1800: //
1801: // /* Make the current options version to be zero
1802: // * temporarily to distinguish whether the options
1803: // * imported were old and the setOptionsVersion()
1804: // * was not called or whether the options
1805: // * were new so the options version was set
1806: // * to the LATEST_OPTIONS_VERSION value.
1807: // */
1808: // optionsVersion = 0;
1809: //
1810: // try {
1811: // // Read the serialized options
1812: // super.readExternal(in);
1813: // }catch(java.io.OptionalDataException ode){
1814: // // #17385. It occurs during reading Settings.settings, that is unimportant
1815: // } finally {
1816: //
1817: // // Make sure the indent engine settings are propagated
1818: // // (SharedClassObject.putProperty() is final)
1819: // refreshIndentEngineSettings();
1820: //
1821: // // Possibly upgrade the options
1822: // //if (optionsVersion < LATEST_OPTIONS_VERSION) {
1823: // // upgradeOptions(optionsVersion, LATEST_OPTIONS_VERSION);
1824: // //}
1825: //
1826: // optionsVersion = LATEST_OPTIONS_VERSION;
1827: //
1828: // /** Release temp indent engine - #11212 */
1829: // inReadExternal = false;
1830: // readExternalIndentEngine = null;
1831: // }
1832: }
1833:
1834: /**
1835: * Overriden writeExternal method.
1836: * @deprecated Use Editor Settings Storage API instead. BaseOptions are no longer serialized.
1837: */
1838: public void writeExternal() throws IOException {
1839: }
1840:
1841: /**
1842: * Overriden writeExternal method.
1843: * @deprecated Use Editor Settings Storage API instead. BaseOptions are no longer serialized.
1844: */
1845: public @Override
1846: void writeExternal(ObjectOutput out) throws IOException {
1847: }
1848:
1849: /**
1850: * @deprecated Use Editor Settings Storage API instead. BaseOptions are no longer serialized.
1851: */
1852: protected @Override
1853: void firePropertyChange(String name, Object oldValue,
1854: Object newValue) {
1855: // ignore firing... Quick fix of #47261.
1856: // BaseOptions should be rewritten to not extend SystemOption ...
1857: // there is no need to be compatile with NB 3.2 and deserialize its options...
1858: }
1859: }
|