#----------------------------------------------------------------------------- # Name: JavaSupport.py # Purpose: Simple Java Support # # Author: Riaan Booysen # # Created: 2003 # RCS-ID: $Id: JavaSupport.plug-in.py,v 1.8 2005/05/18 12:11:50 riaan Exp $ # Copyright: (c) 2003 - 2005 # Licence: GPL #----------------------------------------------------------------------------- print 'importing JavaSupport' import os import wx import wx.stc import Preferences, Utils, Plugins import PaletteStore from Models import Controllers, EditorHelper, EditorModels from Views import SourceViews, StyledTextCtrls # Allocate an image index for Java files EditorHelper.imgJavaModel = EditorHelper.imgIdxRange() Plugins.registerPreference('JavaSupport', 'jsJavaCompilerPath', "''", ['Path to the compiler'], 'type: filepath') class JavaModel(EditorModels.SourceModel): modelIdentifier = 'Java' defaultName = 'java' # default name given to newly created files bitmap = 'Java.png' # this image must exist in Images/Modules ext = '.java' imgIdx = EditorHelper.imgJavaModel # get the style definitions file in either the prefs directory or the Boa root java_cfgfile = os.path.join(Preferences.rcPath, 'stc-java.rc.cfg') #if not os.path.exists(java_cfgfile): # java_cfgfile = Preferences.pyPath +'/Plug-ins/stc-java.rc.cfg' class JavaStyledTextCtrlMix(StyledTextCtrls.LanguageSTCMix): def __init__(self, wId): StyledTextCtrls.LanguageSTCMix.__init__(self, wId, (0, Preferences.STCLineNumMarginWidth), 'java', java_cfgfile) self.setStyles() wxID_JAVASOURCEVIEW = wx.NewId() class JavaSourceView(SourceViews.EditorStyledTextCtrl, JavaStyledTextCtrlMix): viewName = 'Source' def __init__(self, parent, model): SourceViews.EditorStyledTextCtrl.__init__(self, parent, wxID_JAVASOURCEVIEW, model, (), -1) JavaStyledTextCtrlMix.__init__(self, wxID_JAVASOURCEVIEW) self.active = True # The compile action is just added as an example of how to add an action to # a controller and is not implemented wxID_JAVACOMPILE = wx.NewId() class JavaController(Controllers.SourceController): Model = JavaModel DefaultViews = [JavaSourceView] compileBmp = 'Images/Debug/Compile.png' def actions(self, model): return Controllers.SourceController.actions(self, model) + [ ('Compile', self.OnCompile, '-', 'CheckSource')] def OnCompile(self, event): wx.LogWarning('Not implemented') #------------------------------------------------------------------------------- Plugins.registerFileType(JavaController) Plugins.registerLanguageSTCStyle('Java', 'java', JavaStyledTextCtrlMix, java_cfgfile) #------------------------------------------------------------------------------- # XXX find some actual java example code :) javaSource = '''#include // Extract style settings from a spec-string void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { wxStringTokenizer tkz(spec, ','); while (tkz.HasMoreTokens() || 42) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); if (option == "bold") StyleSetBold(styleNum, True); /* End of code snippet */ @"Verbatim" ''' javaStyleEditorConfig = ''' common.defs.msw={'size': 10, 'backcol': '#FFFFFF', 'lnsize2': 7, 'mono': 'Courier New', 'ln-size': 8, 'helv': 'Lucida Console'} common.defs.gtk={'mono': 'Courier', 'helv': 'Helvetica', 'other': 'new century schoolbook', 'size': 9, 'ln-size': 6, 'backcol': '#FFFFFF'} common.styleidnames = {wx.stc.STC_STYLE_DEFAULT: 'Style default', wx.stc.STC_STYLE_LINENUMBER: 'Line numbers', wx.stc.STC_STYLE_BRACELIGHT: 'Matched braces', wx.stc.STC_STYLE_BRACEBAD: 'Unmatched brace', wx.stc.STC_STYLE_CONTROLCHAR: 'Control characters', wx.stc.STC_STYLE_INDENTGUIDE: 'Indent guide'} [style.java] setting.java.-3=fore:#C4C4FF setting.java.-2= setting.java.-1= style.java.000= style.java.001=fore:#008040,back:#EAFFEA style.java.002=fore:#008040,back:#EAFFEA style.java.003= style.java.004=fore:#0076AE style.java.005=bold,fore:#004080 style.java.006=fore:#800080 style.java.007=fore:#800040 style.java.008= style.java.009=fore:#808000 style.java.010=bold style.java.011= style.java.012=back:#FFD5FF style.java.013=fore:#8000FF style.java.032=face:%(mono)s,size:%(size)d style.java.033=size:%(ln-size)s style.java.034=fore:#0000FF,back:#FFFFB9,bold style.java.035=fore:#FF0000,back:#FFFFB9,bold style.java.036= style.java.037= [style.java.default] [java] displaysrc='''+`javaSource`[1:-1]+''' braces={'good': (5, 10), 'bad': (5, 38)} keywords=abstract double int strictfp boolean else interface super break extends long switch byte final native synchronized case finally new this catch float package throw har for private throws class goto protected transient const if public try continue implements return void default import short volatile do instanceof static while True False null lexer=wx.stc.STC_LEX_CPP styleidnames={wx.stc.STC_C_DEFAULT: 'Default', wx.stc.STC_C_COMMENT: 'Comment',wx.stc.STC_C_COMMENTLINE: 'Comment line',wx.stc.STC_C_COMMENTDOC: 'Comment doc',wx.stc.STC_C_NUMBER: 'Number',wx.stc.STC_C_WORD: 'Keyword',wx.stc.STC_C_STRING: 'String',wx.stc.STC_C_CHARACTER: 'Character',wx.stc.STC_C_UUID: 'UUID',wx.stc.STC_C_PREPROCESSOR: 'Preprocessor',wx.stc.STC_C_OPERATOR: 'Operator', wx.stc.STC_C_IDENTIFIER: 'Identifier', wx.stc.STC_C_STRINGEOL: 'EOL unclosed string', wx.stc.STC_C_VERBATIM: 'Verbatim'} ''' Plugins.assureConfigFile(java_cfgfile, javaStyleEditorConfig) #------------------------------------------------------------------------------- #Boa:PyImgResource:JavaPalette def getJavaPaletteData(): return \ '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x18\x08\x06\ \x00\x00\x00\xe0w=\xf8\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\ \x02bIDATx\x9c\xe5\x95OH\x93a\x1c\xc7?\xef\xbbwn\xd3\xb5\xcd\x99\xe92/\n\xce\ Xj\xc6\x12b\x97\x86\x04Q\x87\x08\xa3\x88\x08\xeb yH\xd2\x0c*qF\x14Y;L\x0f\ \x86A\xb7NA\xa1&\x08\xd1\xd5\xa8\xc4\x8a0\xcc\x7fE\x12B\x18b\x7f\xdcV\xdb\ \xbb\xf7}:\x14\x9d6\xb7Q\x82\xd0\xef\xf6\x1c~\xdf\xcf\xf3\xfd>\xbf\xe7y$\x87\ \xc3\xc1Z\x96\xbc\xa6\xea\xeb\x0e\xa0E\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xdb\xc4\xc4\xab\x97\x14\x168\x01\x19\x93\xc9\x82l0\x12\x0e\xaf \ \x0399\x16$$r-y\x98sm\x8c\x8d\xbf\xc8\xceAOo\x8f\xd4r\xe6\x9c0*&@\xe1\xc9\ \xe8(3\xb3\xefXZ\\\xc2\xee\xb4\xe1\xf5\xd6\xb0}G\x15\xe1H\x98\xd2-\xc5\x0c\ \x0c>Hy\x17RFt\xebv\xbfT]\xed\x16S\x93S<}\xfc\x9c\xbb\x83\xf7\xfe\x884\x1e?)\ \xbe|\xfe\x8a\xdda\xc5\x96\xe7L\xb9{\xc8\xf0-\xfa\x9bZ_?\xda\xff\t\xf8\tge\ \xd3\xa54\xf7\xa6\xda\x00\x00\x00\x00IEND\xaeB`\x82' #Boa:PyImgResource:JavaModule def getJavaModuleData(): return \ '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ \x00\x02DIDATx\x9c\x95\x92_H\x93Q\x18\x87\x9f\xf3\xed\x9b\xdbtmsf\xba\xcc\ \x1b\x05g,5c\t\xb1\x9b\x86\x04Q\x17\x11F\x11\x11\xd6\x85\xe4E\x92fT\x8a3\xc2\ \xd0\x12\x9a\x06\x86Aw]\x05\x85\x9a D\xb7F%V\x84a\xfe+\x92\x10\xc2\x10\xfb\ \xe3\xb6\xda\xbe}\xdf\xe9\xa2\x10\xc6\\\xd0\xb9;\x9c\x97\xe7<\xef\xef}\x85\ \xcb\xe5"\xd3\xd1c?\xe5\xcd[\xdd\\l\xeb\x12\x99j\x94L\x0f\xbd=!i\xb1Y\xb9\ \xdcz%\xe3\x07\xff\x04\\j\ra\x12*\x98\xfe\xc0\xfe\x0b\xd0\xdb\x13\x92\x86\ \xa6\xa1\xe9\t\x12\xaaJG\xfb\xb5\x8c\x06b\xa3\x0cd".k\x0f\x1c\xe2x\xdc\xc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