Class: JLDrill::FileProgressContext

Inherits:
Context::Context show all
Defined in:
lib/jldrill/contexts/FileProgressContext.rb

Defined Under Namespace

Classes: FileProgress

Instance Attribute Summary

Attributes inherited from Context::Context

#mainView, #parent, #viewBridge

Instance Method Summary collapse

Methods inherited from Context::Context

#addView, #isEntered?, #onExit, #peekAtView, #setupViews

Constructor Details

#initialize(viewBridge) ⇒ FileProgressContext

Returns a new instance of FileProgressContext.



28
29
30
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 28

def initialize(viewBridge)
    super(viewBridge)
end

Instance Method Details

#createViewsObject



32
33
34
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 32

def createViews
			@mainView = @viewBridge.FileProgress.new(self)
end

#destroyViewsObject



36
37
38
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 36

def destroyViews
    @mainView = nil
end

#enter(parent) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 74

def enter(parent)
    if isValid?(parent)
        super(parent)
        readFile
        # The view will exit the context when the file
        # has finished loading.  This is because we
        # can't exit the context until the idle process
        # is removed, and this can only be done by the view.
    end
end

#exitObject



85
86
87
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 85

def exit
    super
end

#exitFileProgressContextObject



40
41
42
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 40

def exitFileProgressContext
    self.exit
end

#isValid?(parent) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
71
72
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 63

def isValid?(parent)
    retVal = false
    if !parent.nil?
        if (!getFilename.nil?) && 
            (!getFile.loaded? || (getFile.file != getFilename))
            retVal = true
        end
    end
    return retVal
end

#readFileObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/jldrill/contexts/FileProgressContext.rb', line 44

def readFile
    eof = false
    filename = getFilename()
    if !filename.nil? && !getFile.nil?
        @parent.startLongEvent()
        getFile.load(filename)
        @parent.stopLongEvent()
        @mainView.idle_add do
            eof = getFile.parseChunk(getFile.stepSize)
            @mainView.update(getFile.fraction)
            fraction = getFile.fraction
            if eof
                exitFileProgressContext
            end
            eof
        end
    end
end