/jEdit/tags/jedit-4-3-pre15/org/gjt/sp/jedit/JEditMode.java

#
Java | 105 lines | 55 code | 8 blank | 42 comment | 10 complexity | 017db1bf20e973e84d8c9086b16f80e3 MD5 | raw file

✨ Summary
  1. /*
  2. * JEditMode.java - jEdit editing mode
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2007 Matthieu Casanova
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * 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. package org.gjt.sp.jedit;
  23. import org.gjt.sp.util.Log;
  24. /**
  25. * @author Matthieu Casanova
  26. * @version $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
  27. * @since jEdit 4.3pre10
  28. */
  29. class JEditMode extends Mode
  30. {
  31. //{{{ JEditMode constructor
  32. JEditMode(String name)
  33. {
  34. super(name);
  35. } //}}}
  36. //{{{ getProperty() method
  37. /**
  38. * Returns a mode property.
  39. *
  40. * @param key The property name
  41. * @since jEdit 4.3pre10
  42. */
  43. @Override
  44. public Object getProperty(String key)
  45. {
  46. String prefix = "mode." + name + '.';
  47. //if(jEdit.getBooleanProperty(prefix + "customSettings"))
  48. //{
  49. String property = jEdit.getProperty(prefix + key);
  50. if(property != null)
  51. {
  52. Object value;
  53. try
  54. {
  55. value = new Integer(property);
  56. }
  57. catch(NumberFormatException nf)
  58. {
  59. value = property;
  60. }
  61. return value;
  62. }
  63. //}
  64. Object value = props.get(key);
  65. if(value != null)
  66. return value;
  67. String global = jEdit.getProperty("buffer." + key);
  68. if(global != null)
  69. {
  70. try
  71. {
  72. return new Integer(global);
  73. }
  74. catch(NumberFormatException nf)
  75. {
  76. return global;
  77. }
  78. }
  79. else
  80. return null;
  81. } //}}}
  82. //{{{ loadIfNecessary() method
  83. /**
  84. * Loads the mode from disk if it hasn't been loaded already.
  85. * @since jEdit 4.3pre10
  86. */
  87. @Override
  88. public void loadIfNecessary()
  89. {
  90. if(marker == null)
  91. {
  92. jEdit.loadMode(this);
  93. if (marker == null)
  94. Log.log(Log.ERROR, this, "Mode not correctly loaded, token marker is still null");
  95. }
  96. } //}}}
  97. }