01: /*
02: * JEditMode.java - jEdit editing mode
03: * :tabSize=8:indentSize=8:noTabs=false:
04: * :folding=explicit:collapseFolds=1:
05: *
06: * Copyright (C) 2007 Matthieu Casanova
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: */
22:
23: package org.gjt.sp.jedit;
24:
25: import org.gjt.sp.util.Log;
26:
27: /**
28: * @author Matthieu Casanova
29: * @version $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
30: * @since jEdit 4.3pre10
31: */
32: class JEditMode extends Mode {
33: //{{{ JEditMode constructor
34: public JEditMode(String name) {
35: super (name);
36: } //}}}
37:
38: //{{{ getProperty() method
39: /**
40: * Returns a mode property.
41: *
42: * @param key The property name
43: * @since jEdit 4.3pre10
44: */
45: public Object getProperty(String key) {
46: String prefix = "mode." + name + '.';
47:
48: //if(jEdit.getBooleanProperty(prefix + "customSettings"))
49: //{
50: String property = jEdit.getProperty(prefix + key);
51: if (property != null) {
52: Object value;
53: try {
54: value = new Integer(property);
55: } catch (NumberFormatException nf) {
56: value = property;
57: }
58: return value;
59: }
60: //}
61:
62: Object value = props.get(key);
63: if (value != null)
64: return value;
65:
66: String global = jEdit.getProperty("buffer." + key);
67: if (global != null) {
68: try {
69: return new Integer(global);
70: } catch (NumberFormatException nf) {
71: return global;
72: }
73: } else
74: return null;
75: } //}}}
76:
77: //{{{ loadIfNecessary() method
78: /**
79: * Loads the mode from disk if it hasn't been loaded already.
80: * @since jEdit 4.3pre10
81: */
82: public void loadIfNecessary() {
83: if (marker == null) {
84: jEdit.loadMode(this );
85: if (marker == null)
86: Log
87: .log(Log.ERROR, this ,
88: "Mode not correctly loaded, token marker is still null");
89: }
90: } //}}}
91: }
|