Sha256: 3657f0fe6ed0a4ef5ab8a65eb906a9ea254c189463db071824ae3bc59e9f65ac

Contents?: true

Size: 1.91 KB

Versions: 20

Compression:

Stored size: 1.91 KB

Contents

require 'java'

module Redcar
  class HtmlView

    # Open a HtmlTab for displaying web content
    class DisplayWebContent < Redcar::Command
      def initialize(name,url,display_bar=true,tab_class=HtmlTab)
        @name        = name
        @url         = url
        @display_bar = display_bar
        @tab         = tab_class
      end

      def execute
        use_external = HtmlView.storage['use_external_browser_for_urls']
        if use_external and OpenDefaultBrowserCommand.supported?
          OpenDefaultBrowserCommand.new(@url).run
        else
          win = Redcar.app.focussed_window
          controller = DefaultController.new(@name,@url)
          tab = win.new_tab(@tab)
          tab.html_view.controller = controller
          tab.icon = HtmlTab.web_content_icon if tab.is_a?(HtmlTab)
          tab.focus
          if @display_bar and not HtmlView.show_browser_bar?
            HtmlView::ToggleBrowserBar.new.run
          end
        end
      end
    end

    class ViewFileInWebBrowserCommand < Redcar::EditTabCommand
      def execute
        mirror  = doc.mirror
        if mirror and path = mirror.path and File.exists?(path)
          name = "Preview: " +File.basename(path)
        else
          name    = "Preview"
          preview = java.io.File.createTempFile("preview","html")
          preview.deleteOnExit
          path    = preview.getAbsolutePath
          File.open(path,'w') {|f| f.puts(doc.get_all_text)}
        end
        url = File.expand_path(path)
        DisplayWebContent.new(name,url).run
      end
    end

    class ToggleBrowserBar < Redcar::Command
      sensitize :open_htmltab
      def execute
        if win = Redcar.app.focussed_window
          if HtmlView.show_browser_bar?
            win.close_speedbar if win.speedbar
          else
            speedbar = Redcar::HtmlView::BrowserBar.new
            win.open_speedbar(speedbar)
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
redcar-0.13 plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.5dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.4dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.3dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.2dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.1dev plugins/html_view/lib/html_view/commands.rb
redcar-0.12.1 plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.13.0dev plugins/html_view/lib/html_view/commands.rb
redcar-0.12 plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.27dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.26dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.25dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.24dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.23dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.22dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.21dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.20dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.19dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.18dev plugins/html_view/lib/html_view/commands.rb
redcar-dev-0.12.17dev plugins/html_view/lib/html_view/commands.rb