def __init__(self, hwTitle, fileName, zipFile):
#       config = self.readFromConfigFile()
        self.studentName =  JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_NAME)
        self.gtNumber = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_GT)
        self.mailServer = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MAIL)
        self.studentEmail = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_EMAIL_ADDR)
        self.cowebPort = 80
        self.hwTitle = hwTitle
        self.fileName = fileName
        self.zipFile = zipFile
Пример #2
0
    def setupGUI(self, initialFilename):
        self.gui = JESUI(self)
        self.gui.windowSetting(None)

        self.setHelpArray()

        self.gui.changeSkin(JESConfig.getInstance().getStringProperty(
            JESConfig.CONFIG_SKIN))
        self.gui.show()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
            self.gui.editor.removeBox()
        else:
            self.gui.editor.addBox()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER):
            self.gui.turnOnGutter()
        else:
            self.gui.turnOffGutter()

        # Install the bridges.
        self.terpControl = InterpreterControl(self.gui, self.interpreter)
        self.replBuffer = REPLBuffer(self.interpreter, self.gui.commandWindow)

        # Open or create the file.
        if initialFilename is None:
            self.fileManager.newFile()
        else:
            self.fileManager.readFile(initialFilename)

        # Startup complete!
        startTimeNS = System.getProperty("jes.starttimens")
        if startTimeNS is not None:
            self.startupTimeSec = ((System.nanoTime() - long(startTimeNS)) /
                                   1000000000.0)

        # Show introduction window if settings could not be loaded (Either new
        # JES user or bad write permissions)
        config = JESConfig.getInstance()
        loadError = config.getLoadError()

        if loadError is not None:
            JOptionPane.showMessageDialog(
                self.gui,
                "Your JESConfig.properties file could not be opened!\n" +
                loadError.toString(), "JES Configuration",
                JOptionPane.ERROR_MESSAGE)
        elif config.wasMigrated():
            JOptionPane.showMessageDialog(
                self.gui, "Your settings were imported from JES 4.3.\n" +
                "JES doesn't use the JESConfig.txt file in " +
                "your home directory anymore, so you can delete it.",
                "JES Configuration", JOptionPane.INFORMATION_MESSAGE)
        elif not config.wasLoaded():
            introController.show()
Пример #3
0
    def setupGUI(self):
        self.gui = JESUI.JESUI(self)
        self.gui.windowSetting(None)

        self.filename = ' '
        self.settingsFileName = ''

        self.chooser = JESFileChooser.JESFileChooser()
        self.defaultPath = io.File(
            JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MEDIAPATH))
        self.setHelpArray()

        self.gui.changeSkin(
            JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_SKIN))
        self.gui.show()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
            self.gui.editor.removeBox()
        else:
            self.gui.editor.addBox()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER):
            self.gui.turnOnGutter()
        else:
            self.gui.turnOffGutter()

        # Install the bridges.
        self.terpControl = InterpreterControl(self.gui, self.interpreter)
        self.replBuffer = REPLBuffer(self.interpreter, self.gui.commandWindow)

        # Show introduction window if settings could not be loaded (Either new
        # JES user or bad write permissions)
        config = JESConfig.getInstance()
        loadError = config.getLoadError()

        if loadError is not None:
            swing.JOptionPane.showMessageDialog(
                self.gui,
                "Your JESConfig.properties file could not be opened!\n" +
                loadError.toString(),
                "JES Configuration",
                swing.JOptionPane.ERROR_MESSAGE
            )
        elif config.wasMigrated():
            swing.JOptionPane.showMessageDialog(
                self.gui,
                "Your settings were imported from JES 4.3.\n" +
                "JES doesn't use the JESConfig.txt file in " +
                "your home directory anymore, so you can delete it.",
                "JES Configuration",
                swing.JOptionPane.INFORMATION_MESSAGE
            )
        elif not config.wasLoaded():
            self.openIntroductionWindow()
Пример #4
0
 def __init__(self, hwTitle, fileName, zipFile):
     #       config = self.readFromConfigFile()
     self.studentName = JESConfig.getInstance().getStringProperty(
         JESConfig.CONFIG_NAME)
     self.gtNumber = JESConfig.getInstance().getStringProperty(
         JESConfig.CONFIG_GT)
     self.mailServer = JESConfig.getInstance().getStringProperty(
         JESConfig.CONFIG_MAIL)
     self.studentEmail = JESConfig.getInstance().getStringProperty(
         JESConfig.CONFIG_EMAIL_ADDR)
     self.cowebPort = 80
     self.hwTitle = hwTitle
     self.fileName = fileName
     self.zipFile = zipFile
Пример #5
0
    def testIncreaseRed(self):
        '''Test BOOK - Increase red (by 20%)'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            value = p.getRed()
            p.setRed(int(value * 1.2))
        self.pict.write("testincred.jpg")
        self.picttest1 = Picture("testincred.jpg")
        self.picttest2 = Picture("barb-incred.jpg")
        self.assertEqual(self.picttest1.getWidth(),self.picttest2.getWidth(),'Widths are not the same (%s != %s)'%(self.picttest1.getWidth(),self.picttest2.getWidth()))
        self.assertEqual(self.picttest1.getHeight(),self.picttest2.getHeight(),'Heights are not the same (%s != %s)'%(self.picttest1.getHeight(),self.picttest2.getHeight()))
        for i in range(self.picttest1.getWidth()):
            for j in range(self.picttest1.getHeight()):
                self.assertEqual(self.picttest1.getBasicPixel(i,j), self.picttest2.getBasicPixel(i,j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testincred.jpg'%(i,j,self.picttest1.getBasicPixel(i,j),self.picttest2.getBasicPixel(i,j)))
Пример #6
0
    def testLighten(self):
        '''Test BOOK - Lighten'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            color = p.getColor()
            p.setColor(color.brighter())
        self.pict.write("testlighten.jpg")
        self.picttest1 = Picture("testlighten.jpg")
        self.picttest2 = Picture("barb-lighten.jpg")
        self.assertEqual(self.picttest1.getWidth(),self.picttest2.getWidth(),'Widths are not the same (%s != %s)'%(self.picttest1.getWidth(),self.picttest2.getWidth()))
        self.assertEqual(self.picttest1.getHeight(),self.picttest2.getHeight(),'Heights are not the same (%s != %s)'%(self.picttest1.getHeight(),self.picttest2.getHeight()))
        for i in range(self.picttest1.getWidth()):
            for j in range(self.picttest1.getHeight()):
                self.assertEqual(self.picttest1.getBasicPixel(i,j), self.picttest2.getBasicPixel(i,j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testlighten.jpg'%(i,j,self.picttest1.getBasicPixel(i,j),self.picttest2.getBasicPixel(i,j)))
Пример #7
0
 def getNameOfExcMsg(self, exc_type, exc_value):
     if JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MODE) == JESConstants.EXPERT_MODE:
         return "%s: %s\n" % (exc_type.__name__, exc_value)
     elif exc_type.__name__ == 'SoundException':
         return "%s\n" % (exc_value)
     else:
         return ''
 def __init__(self, command):
     self.command = command
     self.textAttrib = swing.text.SimpleAttributeSet()
     swing.text.StyleConstants.setFontSize(
         self.textAttrib,
         JESConfig.getInstance().getIntegerProperty(JESConfig.CONFIG_FONT))
     swing.text.StyleConstants.setForeground(self.textAttrib, colors.yellow)
Пример #9
0
 def getNameOfExcMsg(self, exc_type, exc_value):
     if JESConfig.getInstance().getStringProperty(
             JESConfig.CONFIG_MODE) == JESConfig.MODE_EXPERT:
         return "%s: %s\n" % (exc_type.__name__, exc_value)
     elif exc_type.__name__ == 'SoundException':
         return "%s\n" % (exc_value)
     else:
         return ''
Пример #10
0
    def testNegative(self):
        '''Test BOOK - Negative'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            red = p.getRed()
            green = p.getGreen()
            blue = p.getBlue()
            negcolor = Color(255-red, 255-green, 255-blue)
            p.setColor(negcolor)
        self.pict.write("testnegative.jpg")
        self.picttest1 = Picture("testnegative.jpg")
        self.picttest2 = Picture("barb-negative.jpg")
        self.assertEqual(self.picttest1.getWidth(),self.picttest2.getWidth(),'Widths are not the same (%s != %s)'%(self.picttest1.getWidth(),self.picttest2.getWidth()))
        self.assertEqual(self.picttest1.getHeight(),self.picttest2.getHeight(),'Heights are not the same (%s != %s)'%(self.picttest1.getHeight(),self.picttest2.getHeight()))
        for i in range(self.picttest1.getWidth()):
            for j in range(self.picttest1.getHeight()):
                self.assertEqual(self.picttest1.getBasicPixel(i,j), self.picttest2.getBasicPixel(i,j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testnegative.jpg'%(i,j,self.picttest1.getBasicPixel(i,j),self.picttest2.getBasicPixel(i,j)))
Пример #11
0
    def testGreyScale(self):
        '''Test BOOK - GreyScale'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            newRed = p.getRed() * 0.299
            newGreen = p.getGreen() * 0.587
            newBlue = p.getBlue() * 0.114
            luminance = int(newRed + newGreen + newBlue)
            p.setColor(Color(luminance,luminance,luminance))
        self.pict.write("testgreyscale.jpg")
        self.picttest1 = Picture("testgreyscale.jpg")
        self.picttest2 = Picture("barb-greyscale.jpg")
        self.assertEqual(self.picttest1.getWidth(),self.picttest2.getWidth(),'Widths are not the same (%s != %s)'%(self.picttest1.getWidth(),self.picttest2.getWidth()))
        self.assertEqual(self.picttest1.getHeight(),self.picttest2.getHeight(),'Heights are not the same (%s != %s)'%(self.picttest1.getHeight(),self.picttest2.getHeight()))
        for i in range(self.picttest1.getWidth()):
            for j in range(self.picttest1.getHeight()):
                self.assertEqual(self.picttest1.getBasicPixel(i,j), self.picttest2.getBasicPixel(i,j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testgreyscale.jpg'%(i,j,self.picttest1.getBasicPixel(i,j),self.picttest2.getBasicPixel(i,j)))
Пример #12
0
 def retrieveList(self):
     joined = JESConfig.getInstance().getStringProperty(
         JESConfig.CONFIG_RECENT_FILES)
     if not joined:
         return []
     else:
         return [
             fn for fn in joined.split(self.separator) if os.path.isfile(fn)
         ]
Пример #13
0
 def caretUpdate(self, e):
     offset = self.getCaretPosition()
     defaultElement = self.document.getDefaultRootElement()
     elementIndex = defaultElement.getElementIndex(offset)
     row = offset-defaultElement.getElement(elementIndex).getStartOffset()+1
     col = elementIndex + 1
     self.gui.UpdateRowCol(row, col)
     self.checkIfOnKeyword()
     if not JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
         self.updateBox(offset)
         #print str(self.isBlank(offset))
         self.repaint()
     else:
         self.boxX = 0
         self.repaint()
Пример #14
0
 def caretUpdate(self, e):
     offset = self.getCaretPosition()
     defaultElement = self.document.getDefaultRootElement()
     elementIndex = defaultElement.getElementIndex(offset)
     row = offset - \
         defaultElement.getElement(elementIndex).getStartOffset() + 1
     col = elementIndex + 1
     self.gui.UpdateRowCol(row, col)
     self.checkIfOnKeyword()
     if not JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
         self.updateBox(offset)
         # print str(self.isBlank(offset))
         self.repaint()
     else:
         self.boxX = 0
         self.repaint()
Пример #15
0
    def saveAs(self):
        try:
            self.chooser.setCurrentDirectory(self.defaultPath)
            text = self.gui.editor.getText()
            self.chooser.setApproveButtonText("Save File")

            returnVal = self.chooser.showSaveDialog(self.gui)
            if returnVal == 0:  #User has chosen a file, so now it can be saved
                #DNR
                #file = open(self.chooser.getSelectedFile().getPath(),'w+')
                #self.gui.setFileName(self.chooser.getSelectedFile().getName())
                #text = text.splitlines(1)
                #file.writelines(text)
                #self.filename = file.name
                #file.close()
                #Commented out by AW: Trying to see if using java instead of jython
                #gets rid of the newline errors

                filePath = self.chooser.getSelectedFile().getPath()
                self.filename = os.path.normpath(filePath)

                fileWriter = io.FileWriter(filePath, 0)
                fileWriter.write(text)
                fileWriter.close()

                self.defaultPath = self.chooser.getCurrentDirectory()
                self.gui.editor.modified = 0
                self.gui.setFileName(os.path.basename(self.filename))
                self.logBuffer.saveLogFile(self.filename)

                #Now write the backup
                if JESConfig.getInstance().getBooleanProperty(
                        JESConfig.CONFIG_BACKUPSAVE):
                    backupPath = filePath + "bak"
                    fileWriter = io.FileWriter(backupPath, 0)
                    fileWriter.write(text)
                    fileWriter.close()

            return 1

        except lang.Exception, e:
            #TODO - fix
            #Error handling for saveAs
            e.printStackTrace()
            return 0
Пример #16
0
    def saveAs(self):
        try:
            self.chooser.setCurrentDirectory(self.defaultPath)
            text = self.gui.editor.getText()
            self.chooser.setApproveButtonText("Save File")

            returnVal = self.chooser.showSaveDialog(self.gui)
            # User has chosen a file, so now it can be saved
            if returnVal == 0:
                # DNR
                #file = open(self.chooser.getSelectedFile().getPath(),'w+')
                # self.gui.setFileName(self.chooser.getSelectedFile().getName())
                #text = text.splitlines(1)
                # file.writelines(text)
                #self.filename = file.name
                # file.close()
                # Commented out by AW: Trying to see if using java instead of jython
                # gets rid of the newline errors

                filePath = self.chooser.getSelectedFile().getPath()
                self.filename = os.path.normpath(filePath)

                fileWriter = io.FileWriter(filePath, 0)
                fileWriter.write(text)
                fileWriter.close()

                self.defaultPath = self.chooser.getCurrentDirectory()
                self.gui.editor.modified = 0
                self.gui.setFileName(os.path.basename(self.filename))
                self.logBuffer.saveLogFile(self.filename)

                # Now write the backup
                if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE):
                    backupPath = filePath + "bak"
                    fileWriter = io.FileWriter(backupPath, 0)
                    fileWriter.write(text)
                    fileWriter.close()

            return 1

        except lang.Exception, e:
            #TODO - fix
            # Error handling for saveAs
            e.printStackTrace()
            return 0
    def getStackMsg(self,txtStack):
        
        if JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MODE) == JESConstants.EXPERT_MODE:
            stackMsg = ''

            count = 1
            for frame in txtStack:
                if (count == 1 )and (frame[0] ==  JESConstants.COMMAND_FROM_CONSOLE):
                    pass
                else:
                
                    stackMsg = stackMsg + \
                               JESConstants.STACK_MSG % frame
                count += 1
            return stackMsg
        else:
            stackMsg = ''
            return stackMsg
Пример #18
0
    def getStackMsg(self, txtStack):

        if JESConfig.getInstance().getStringProperty(
                JESConfig.CONFIG_MODE) == JESConfig.MODE_EXPERT:
            stackMsg = ''

            count = 1
            for frame in txtStack:
                if (count == 1) and (frame[0] == COMMAND_FROM_CONSOLE):
                    pass
                else:

                    stackMsg = stackMsg + \
                        STACK_MSG % frame
                count += 1
            return stackMsg
        else:
            stackMsg = ''
            return stackMsg
Пример #19
0
    def saveFile(self):
        try:
            if self.filename != '':
                text = self.gui.editor.getText()
                #self.chooser.setCurrentDirectory(self.defaultPath)
                #file = open(self.chooser.getSelectedFile().getPath(),'w+')
                #David - testing something out
                #text = text.splitlines(1)
                #file.writelines(text)
                #self.filename = file.name
                #file.close()
                #Commented out by AW: Trying to see if using java instead of jython
                #gets rid of the newline errors

                filePath = self.chooser.getSelectedFile().getPath()
                self.filename = os.path.normpath(filePath)

                fileWriter = io.FileWriter(filePath, 0)
                fileWriter.write(text)
                fileWriter.close()

                self.defaultPath = self.chooser.getCurrentDirectory()
                self.logBuffer.saveLogFile(self.filename)
                self.gui.editor.modified = 0
                self.gui.setFileName(os.path.basename(self.filename))

                #Now write the backup
                if JESConfig.getInstance().getBooleanProperty(
                        JESConfig.CONFIG_BACKUPSAVE):
                    backupPath = filePath + "bak"
                    fileWriter = io.FileWriter(backupPath, 0)
                    fileWriter.write(text)
                    fileWriter.close()
                return 1
            else:
                return self.saveAs()
        except:
            #Error handling for saveFile
            return self.saveAs()
Пример #20
0
    def saveFile(self):
        try:
            if self.filename != '' :
                text=self.gui.editor.getText()
                #self.chooser.setCurrentDirectory(self.defaultPath)
                #file = open(self.chooser.getSelectedFile().getPath(),'w+')
                #David - testing something out
                #text = text.splitlines(1)
                #file.writelines(text)
                #self.filename = file.name
                #file.close()
                #Commented out by AW: Trying to see if using java instead of jython
                #gets rid of the newline errors
                
                filePath = self.chooser.getSelectedFile().getPath()
                self.filename =  os.path.normpath(filePath)

                fileWriter = io.FileWriter(filePath, 0)
                fileWriter.write(text)
                fileWriter.close()
                
                self.defaultPath = self.chooser.getCurrentDirectory()
                self.logBuffer.saveLogFile(self.filename)
                self.gui.editor.modified = 0
                self.gui.setFileName(os.path.basename(self.filename))
                
                #Now write the backup
                if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE):
                    backupPath = filePath+"bak"
                    fileWriter = io.FileWriter(backupPath, 0)
                    fileWriter.write(text)
                    fileWriter.close()
                return 1
            else:
                return self.saveAs()
        except:
            #Error handling for saveFile
            return self.saveAs()
Пример #21
0
 def createFileChooser(self):
     defaultDir = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MEDIAPATH)
     chooser = self.fileChooser = FileChooser(defaultDir)
     chooser.addExtensionFilter("py", "Python programs")
Пример #22
0
            with open(filename, 'w') as fd:
                fd.write(sourceText)
        except EnvironmentError, exc:
            self.showErrorMessage(
                "Error saving file", "Could not save the file to", filename, exc
            )
        else:
            self.filename = filename
            self.lastDirectory = os.path.dirname(filename)

            self.editor.modified = 0

            self.onWrite.send(self, filename=filename)

            # Now write the backup
            if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE):
                try:
                    backupPath = self.filename + "bak"
                    with open(filename, 'w') as fd:
                        fd.write(sourceText)
                except EnvironmentError, exc:
                    self.showErrorMessage(
                        "Error saving backup",
                        "Could not save the backup file to", backupPath, exc
                    )

            return True


    ### File choosing
Пример #23
0
def getColorWrapAround():
    return JESConfig.getInstance().getSessionWrapAround()
Пример #24
0
def setColorWrapAround(bool):
    JESConfig.getInstance().setSessionWrapAround( bool )
Пример #25
0
 def retrieveList(self):
     joined = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_RECENT_FILES)
     if not joined:
         return []
     else:
         return [fn for fn in joined.split(self.separator) if os.path.isfile(fn)]
Пример #26
0
def getColorWrapAround():
    return JESConfig.getInstance().getSessionWrapAround()
Пример #27
0
 def closeProgram(self):
     JESConfig.getInstance().writeConfig()
     self.pluginInstaller.cleanUp()
     System.exit(0)
 def __init__(self, command):
     self.command = command
     self.textAttrib = swing.text.SimpleAttributeSet()
     swing.text.StyleConstants.setFontSize(self.textAttrib, JESConfig.getInstance().getIntegerProperty(JESConfig.CONFIG_FONT))
     swing.text.StyleConstants.setForeground(self.textAttrib, colors.yellow)
Пример #29
0
 def storeList(self, files):
     joined = self.separator.join(files)
     JESConfig.getInstance().setStringProperty(JESConfig.CONFIG_RECENT_FILES, joined)
Пример #30
0
    def __init__(self, editor):
        self.editor = editor
        self.textAttrib = swing.text.SimpleAttributeSet()
        self.keywordAttrib = swing.text.SimpleAttributeSet()
        self.jesEnvironmentWordAttrib = swing.text.SimpleAttributeSet()
        self.errorLineAttrib = swing.text.SimpleAttributeSet()
        self.highlightLineAttrib = swing.text.SimpleAttributeSet()
        self.commentAttrib = swing.text.SimpleAttributeSet()
        self.stringAttrib = swing.text.SimpleAttributeSet()
        self.lParenAttrib = swing.text.SimpleAttributeSet()
        self.rParenAttrib = swing.text.SimpleAttributeSet()
        self.needToSetEnvironment = 1
        self.fontSize = JESConfig.getInstance().getIntegerProperty(
            JESConfig.CONFIG_FONT)

        swing.text.StyleConstants.setForeground(
            self.stringAttrib, STRING_COLOR)
        swing.text.StyleConstants.setFontFamily(
            self.stringAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.commentAttrib, COMMENT_COLOR)
        swing.text.StyleConstants.setFontFamily(
            self.commentAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.jesEnvironmentWordAttrib, ENVIRONMENT_WORD_COLOR)
        swing.text.StyleConstants.setBold(
            self.jesEnvironmentWordAttrib, KEYWORD_BOLD)
        swing.text.StyleConstants.setFontSize(
            self.jesEnvironmentWordAttrib, self.fontSize)
        swing.text.StyleConstants.setFontSize(self.textAttrib, self.fontSize)
        swing.text.StyleConstants.setBackground(
            self.textAttrib, awt.Color.white)
        swing.text.StyleConstants.setFontFamily(
            self.jesEnvironmentWordAttrib, "Monospaced")
        swing.text.StyleConstants.setFontFamily(self.textAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.keywordAttrib, KEYWORD_COLOR)
        swing.text.StyleConstants.setBold(self.keywordAttrib, KEYWORD_BOLD)
        swing.text.StyleConstants.setFontSize(
            self.keywordAttrib, self.fontSize)
        swing.text.StyleConstants.setFontFamily(
            self.keywordAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.lParenAttrib, LPAREN_COLOR)
        swing.text.StyleConstants.setBold(
            self.lParenAttrib, INVALID_PAREN_BOLD)
        swing.text.StyleConstants.setFontSize(self.lParenAttrib, self.fontSize)
        swing.text.StyleConstants.setFontFamily(
            self.lParenAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.rParenAttrib, RPAREN_COLOR)
        swing.text.StyleConstants.setBold(
            self.rParenAttrib, INVALID_PAREN_BOLD)
        swing.text.StyleConstants.setFontSize(self.rParenAttrib, self.fontSize)
        swing.text.StyleConstants.setFontFamily(
            self.rParenAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.errorLineAttrib, ERROR_LINE_FONT_COLOR)
        swing.text.StyleConstants.setBackground(
            self.errorLineAttrib, ERROR_LINE_BACKGROUND_COLOR)
        swing.text.StyleConstants.setFontFamily(
            self.errorLineAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.highlightLineAttrib, HIGHLIGHT_LINE_FONT_COLOR)
        swing.text.StyleConstants.setBackground(
            self.highlightLineAttrib, HIGHLIGHT_LINE_BACKGROUND_COLOR)
        swing.text.StyleConstants.setFontFamily(
            self.highlightLineAttrib, "Monospaced")

        #self.undoEvents = []

        # Sets up the UndoManager which handles all undos/redos
        self.undoManager = swing.undo.UndoManager()
        self.undoManager.setLimit(MAX_UNDO_EVENTS_TO_RETAIN)

        self.setKeywordStyle(self.keywordAttrib)
        self.setEnvironmentWordStyle(self.jesEnvironmentWordAttrib)
        self.setStringStyle(self.stringAttrib)
        self.setLParenStyle(self.lParenAttrib)
        self.setRParenStyle(self.rParenAttrib)
        self.setCommentStyle(self.commentAttrib)
        self.setDefaultStyle(self.textAttrib)

        # The following variables are set when showErrorLine is called.  They
        # are then used to unhighlight the line when the next text modification
        # is made.
        self.errorLineStart = -1
        self.errorLineLen = -1
        self.highlightLineStart = -1
        self.highlightLineLen = -1
Пример #31
0
    def __init__(self, editor):
        self.editor = editor
        self.textAttrib = swing.text.SimpleAttributeSet()
        self.keywordAttrib = swing.text.SimpleAttributeSet()
        self.jesEnvironmentWordAttrib = swing.text.SimpleAttributeSet()
        self.errorLineAttrib = swing.text.SimpleAttributeSet()
        self.highlightLineAttrib = swing.text.SimpleAttributeSet()
        self.commentAttrib = swing.text.SimpleAttributeSet()
        self.stringAttrib = swing.text.SimpleAttributeSet()
        self.lParenAttrib = swing.text.SimpleAttributeSet()
        self.rParenAttrib = swing.text.SimpleAttributeSet()
        self.needToSetEnvironment = 1
        self.fontSize = JESConfig.getInstance().getIntegerProperty(
            JESConfig.CONFIG_FONT)

        swing.text.StyleConstants.setForeground(self.stringAttrib,
                                                JESConstants.STRING_COLOR)
        swing.text.StyleConstants.setFontFamily(self.stringAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(self.commentAttrib,
                                                JESConstants.COMMENT_COLOR)
        swing.text.StyleConstants.setFontFamily(self.commentAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(
            self.jesEnvironmentWordAttrib, JESConstants.ENVIRONMENT_WORD_COLOR)
        swing.text.StyleConstants.setBold(self.jesEnvironmentWordAttrib,
                                          KEYWORD_BOLD)
        swing.text.StyleConstants.setFontSize(self.jesEnvironmentWordAttrib,
                                              self.fontSize)
        swing.text.StyleConstants.setFontSize(self.textAttrib, self.fontSize)
        swing.text.StyleConstants.setBackground(self.textAttrib,
                                                awt.Color.white)
        swing.text.StyleConstants.setFontFamily(self.jesEnvironmentWordAttrib,
                                                "Monospaced")
        swing.text.StyleConstants.setFontFamily(self.textAttrib, "Monospaced")

        swing.text.StyleConstants.setForeground(self.keywordAttrib,
                                                JESConstants.KEYWORD_COLOR)
        swing.text.StyleConstants.setBold(self.keywordAttrib, KEYWORD_BOLD)
        swing.text.StyleConstants.setFontSize(self.keywordAttrib,
                                              self.fontSize)
        swing.text.StyleConstants.setFontFamily(self.keywordAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(self.lParenAttrib,
                                                JESConstants.LPAREN_COLOR)
        swing.text.StyleConstants.setBold(self.lParenAttrib,
                                          INVALID_PAREN_BOLD)
        swing.text.StyleConstants.setFontSize(self.lParenAttrib, self.fontSize)
        swing.text.StyleConstants.setFontFamily(self.lParenAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(self.rParenAttrib,
                                                JESConstants.RPAREN_COLOR)
        swing.text.StyleConstants.setBold(self.rParenAttrib,
                                          INVALID_PAREN_BOLD)
        swing.text.StyleConstants.setFontSize(self.rParenAttrib, self.fontSize)
        swing.text.StyleConstants.setFontFamily(self.rParenAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(self.errorLineAttrib,
                                                ERROR_LINE_FONT_COLOR)
        swing.text.StyleConstants.setBackground(self.errorLineAttrib,
                                                ERROR_LINE_BACKGROUND_COLOR)
        swing.text.StyleConstants.setFontFamily(self.errorLineAttrib,
                                                "Monospaced")

        swing.text.StyleConstants.setForeground(self.highlightLineAttrib,
                                                HIGHLIGHT_LINE_FONT_COLOR)
        swing.text.StyleConstants.setBackground(
            self.highlightLineAttrib, HIGHLIGHT_LINE_BACKGROUND_COLOR)
        swing.text.StyleConstants.setFontFamily(self.highlightLineAttrib,
                                                "Monospaced")

        #self.undoEvents = []

        #Sets up the UndoManager which handles all undos/redos
        self.undoManager = swing.undo.UndoManager()
        self.undoManager.setLimit(MAX_UNDO_EVENTS_TO_RETAIN)

        HighlightingStyledDocument.setKeywordStyle(self, self.keywordAttrib)
        HighlightingStyledDocument.setEnvironmentWordStyle(
            self, self.jesEnvironmentWordAttrib)
        HighlightingStyledDocument.setStringStyle(self, self.stringAttrib)
        HighlightingStyledDocument.setLParenStyle(self, self.lParenAttrib)
        HighlightingStyledDocument.setRParenStyle(self, self.rParenAttrib)
        HighlightingStyledDocument.setCommentStyle(self, self.commentAttrib)
        HighlightingStyledDocument.setDefaultStyle(self, self.textAttrib)

        #The following variables are set when showErrorLine is called.  They
        #are then used to unhighlight the line when the next text modification
        #is made.
        self.errorLineStart = -1
        self.errorLineLen = -1
        self.highlightLineStart = -1
        self.highlightLineLen = -1
Пример #32
0
    def __init__(self):
        #"@sig public JESProgram()"
        #swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        #        self.userExperience = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MODE);
        #        self.gutterOn = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER);
        #        self.blockBoxOff = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK);
        #        self.autoSaveOnRun = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_AUTOSAVEONRUN);
        #        self.backupSave = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE);
        #        self.wrapPixelValues = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_WRAPPIXELVALUES);
        #        self.userFont = JESConfig.getInstance().getIntegerProperty(JESConfig.CONFIG_FONT);
        #        self.showTurnin = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_SHOWTURNIN);
        #        self.skin = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_SKIN);
        #        self.webDefinitions = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_WEB_TURNIN);
        #        self.mediaFolder = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MEDIAPATH);

        self.logBuffer = JESLogBuffer.JESLogBuffer(self)
        #        self.logBuffer.saveBoolean = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_LOGBUFFER);

        # let's just read the config file once, and if
        # it's no there, we'll handle it right now.
        # self.preCheckForConfigFile()
        # self.getSettingsLater = 0
        # self.loadConfigFile()

        self.textForCommandWindow = ''
        self.aboutWindow = None
        self.introWindow = None

        self.gui = JESUI.JESUI(self)
        self.filename = ' '
        self.settingsFileName = ''
        self.interpreter = JESInterpreter.JESInterpreter(self)
        # a gross hack?, see JESUI.py on why it's commentted out there
        self.interpreter.debugger.watcher.setMinimumSize(
            awt.Dimension(500, 400))
        self.interpreter.debugger.watcher.setPreferredSize(
            awt.Dimension(600, 400))

        self.gui.windowSetting(None)

        self.varsToHighlight = self.interpreter.getVarsToHighlight()

        self.chooser = JESFileChooser.JESFileChooser()
        self.defaultPath = io.File(JESConfig.getInstance().getStringProperty(
            JESConfig.CONFIG_MEDIAPATH))
        self.setHelpArray()
        #self.loadSuccess(), 5/15/09 Dorn: removed as unnecessary and breaks due to needed code in loadSuccess for input

        self.gui.changeSkin(JESConfig.getInstance().getStringProperty(
            JESConfig.CONFIG_SKIN))
        self.gui.show()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
            self.gui.editor.removeBox()
        else:
            self.gui.editor.addBox()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER):
            self.gui.turnOnGutter()
        else:
            self.gui.turnOffGutter()

        # self.checkForConfigFile()
        ## do these once we're started...

        # later is now!
        #if self.getSettingsLater:
        #self.openSettingsGUI()
        #self.openIntroductionWindow()

        #Show introduction window if settings could not be loaded (Either new JES user or bad write permissions)
        if not JESConfig.getInstance().isConfigLoaded():
            self.openIntroductionWindow()
Пример #33
0
 def closeProgram(self):
     JESConfig.getInstance().writeConfig()
     self.pluginInstaller.cleanUp()
     System.exit(0)
Пример #34
0
    def __init__(self):
        #"@sig public JESProgram()"
       #swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
#        self.userExperience = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MODE);
#        self.gutterOn = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER);
#        self.blockBoxOff = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK);
#        self.autoSaveOnRun = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_AUTOSAVEONRUN);
#        self.backupSave = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE);
#        self.wrapPixelValues = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_WRAPPIXELVALUES);
#        self.userFont = JESConfig.getInstance().getIntegerProperty(JESConfig.CONFIG_FONT);
#        self.showTurnin = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_SHOWTURNIN);
#        self.skin = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_SKIN);
#        self.webDefinitions = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_WEB_TURNIN);
#        self.mediaFolder = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MEDIAPATH);

        self.logBuffer=JESLogBuffer.JESLogBuffer(self)
#        self.logBuffer.saveBoolean = JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_LOGBUFFER);
	
        # let's just read the config file once, and if
        # it's no there, we'll handle it right now.
        # self.preCheckForConfigFile()
        # self.getSettingsLater = 0
        # self.loadConfigFile()

        self.textForCommandWindow = ''
        self.aboutWindow = None
        self.introWindow = None

        self.gui = JESUI.JESUI(self)
        self.filename = ' '
        self.settingsFileName=''
        self.interpreter = JESInterpreter.JESInterpreter(self)
        # a gross hack?, see JESUI.py on why it's commentted out there
        self.interpreter.debugger.watcher.setMinimumSize(awt.Dimension(500,400))
        self.interpreter.debugger.watcher.setPreferredSize(awt.Dimension(600,400))

        self.gui.windowSetting(None)
        
        self.varsToHighlight = self.interpreter.getVarsToHighlight()

        self.chooser = JESFileChooser.JESFileChooser()
        self.defaultPath = io.File( JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_MEDIAPATH) )
        self.setHelpArray()
	#self.loadSuccess(), 5/15/09 Dorn: removed as unnecessary and breaks due to needed code in loadSuccess for input

        self.gui.changeSkin( JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_SKIN) )
        self.gui.show()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
            self.gui.editor.removeBox()
        else:
            self.gui.editor.addBox()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER):
            self.gui.turnOnGutter()
        else:
            self.gui.turnOffGutter()

        # self.checkForConfigFile()
            ## do these once we're started...

        # later is now!
        #if self.getSettingsLater:
            #self.openSettingsGUI()
            #self.openIntroductionWindow()

        #Show introduction window if settings could not be loaded (Either new JES user or bad write permissions)
        if not JESConfig.getInstance().isConfigLoaded():
            self.openIntroductionWindow()
Пример #35
0
    def setupGUI(self, initialFilename):
        self.gui = JESUI(self)
        self.gui.windowSetting(None)

        self.setHelpArray()

        self.gui.changeSkin(
            JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_SKIN))
        self.gui.show()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BLOCK):
            self.gui.editor.removeBox()
        else:
            self.gui.editor.addBox()

        if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_GUTTER):
            self.gui.turnOnGutter()
        else:
            self.gui.turnOffGutter()

        # Install the bridges.
        self.terpControl = InterpreterControl(self.gui, self.interpreter)
        self.replBuffer = REPLBuffer(self.interpreter, self.gui.commandWindow)

        # Open or create the file.
        if initialFilename is None:
            self.fileManager.newFile()
        else:
            self.fileManager.readFile(initialFilename)

        # Startup complete!
        startTimeNS = System.getProperty("jes.starttimens")
        if startTimeNS is not None:
            self.startupTimeSec = (
                (System.nanoTime() - long(startTimeNS)) / 1000000000.0
            )

        # Show introduction window if settings could not be loaded (Either new
        # JES user or bad write permissions)
        config = JESConfig.getInstance()
        loadError = config.getLoadError()

        if loadError is not None:
            JOptionPane.showMessageDialog(
                self.gui,
                "Your JESConfig.properties file could not be opened!\n" +
                loadError.toString(),
                "JES Configuration",
                JOptionPane.ERROR_MESSAGE
            )
        elif config.wasMigrated():
            JOptionPane.showMessageDialog(
                self.gui,
                "Your settings were imported from JES 4.3.\n" +
                "JES doesn't use the JESConfig.txt file in " +
                "your home directory anymore, so you can delete it.",
                "JES Configuration",
                JOptionPane.INFORMATION_MESSAGE
            )
        elif not config.wasLoaded():
            introController.show()
Пример #36
0
def setColorWrapAround(bool):
    JESConfig.getInstance().setSessionWrapAround(bool)
Пример #37
0
 def storeList(self, files):
     joined = self.separator.join(files)
     JESConfig.getInstance().setStringProperty(
         JESConfig.CONFIG_RECENT_FILES, joined)