コード例 #1
0
 def _createBrowser(self, html=None, url=None):
     data = GridData(SWT.FILL, SWT.FILL, 1, 1)
     data.verticalIndent = 10
     self.browser = Browser(self.window, SWT.BORDER)
     self.browser.setLayoutData(data)
     if url is not None:
         self.setURL(url)
     else:
         if html is not None:
             self.setText(html)
         else:
             pass
コード例 #2
0
      def createDialogArea(self, parent):
          composite = self.super__createDialogArea(parent)

          glayout = GridLayout(1, False)
          composite.setLayout(glayout)

          data = GridData(SWT.FILL, SWT.FILL, True, True);
          data.widthHint = 800;
          data.heightHint = 350;
          composite.setLayoutData(data);

          browser = Browser(composite, SWT.NONE)
          browser.setUrl(File(output.name).toURI().toString())
          browser.setLayoutData(GridData(SWT.FILL, SWT.FILL, True, True));

          return composite
コード例 #3
0
    def createPartControl(self, parent):
        b = Browser(parent, SWT.NONE)
        b.setUrl("http://www.vogella.de")
        class MyProgressListener(ProgressListener):
            def completed(self, event):
                print "Page loaded"
                # try {
                #        Thread.sleep(2000);
                #    } catch (InterruptedException e) {
                #        e.printStackTrace();
                #    }
                #  // Execute JavaScript in the browser
                b.execute("alert(\"JavaScript, called from Java\");");

            def changed(self, event):
                pass
        b.addProgressListener(MyProgressListener())
コード例 #4
0
class USEWindow(object):
  def __init__(self, title= None, toDisplay= None):


    parentShell = Display.getDefault().getActiveShell()
    self.window = Shell(parentShell, SWT.CLOSE | SWT.RESIZE)
    self.window.setText(title)
    self.window.setLayout(FillLayout())
    self.window.setSize (self.window.computeSize(1400, 500))
    self.text = Browser(self.window, SWT.NONE)
    self.text.setText( \
              "<html><header><style>" +
              "<!--.tab { margin-left: 40px;} .tab2 { margin-left: 80px; }" + 
              " .tab3 { margin-left: 120px; }.tab4 { margin-left: 160px; }-->" +
              "</style></header><body><div style=\"overflow: auto;\">" + 
              toDisplay + "</div></body></html>")
    self.window.open ()
コード例 #5
0
ファイル: misc.py プロジェクト: escribis/.modelio
 def _createBrowser(self,html=None,url=None):
   data = GridData(SWT.FILL,SWT.FILL,1,1)
   data.verticalIndent = 10;
   self.browser = Browser(self.window, SWT.BORDER)
   self.browser.setLayoutData(data)
   if url is not None:
     self.setURL(url)
   else:
     if html is not None:
       self.setText(html)
     else:
       pass
コード例 #6
0
ファイル: cars_app.py プロジェクト: krismz/Delv
  from javax.swing import JFrame, JPanel, JApplet, UIManager
  from java.awt import FlowLayout, Dimension

  # custom views etc
  from DelvProcessing import *
  import inSite
  import org.rosuda.JRI.Rengine as Rengine
  from JRI_ggplot import JRI_ggplot
  
  # Following from http://www.eclipse.org/articles/Article-Swing-SWT-Integration/
  # To reduce flicker on resize:
  System.setProperty("sun.awt.noerasebackground", "false")
  # To get Swing look and feel to match SWT:
  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())  

  browser = Browser(shell, SWT.RESIZE)
  #browser.setText("hello world!")
  # TODO get the url to lineup a better way
  browser.setUrl('file:///Users/krismz/Software/delv/examples/java_cars/lineup.js/demo/index.html')
  bgd = GridData(SWT.FILL, SWT.FILL, True, True)
  #bgd.widthHint = 1500
  ##bgd.heightHint = 1200
  ##bgd.widthHint = 1200
  #bgd.heightHint = 800
  bgd.horizontalSpan = 3
  browser.setLayoutData(bgd)

  browser2 = Browser(shell, SWT.RESIZE)
  browser2.setUrl('file:///Users/krismz/Software/delv/examples/java_cars/parallel_coords.html')
  pgd = GridData(SWT.FILL, SWT.FILL, True, False)
  #pgd.widthHint = 804
コード例 #7
0
class HtmlWindow(object):
    def __init__(self,
                 url=None,
                 html=None,
                 title="information",
                 width=800,
                 height=800,
                 labeltext=""):
        parent = Display.getDefault().getActiveShell()
        self.window = Shell(parent, SWT.CLOSE | SWT.RESIZE)
        # give minimum size, location and size
        self.window.setMinimumSize(width, height)
        parentBounds = parent.getBounds()
        self.window.setLocation( \
          (parentBounds.width-width)/2+parentBounds.x, \
          (parentBounds.height-height)/2+parentBounds.y )
        self.window.setSize(width, height)
        # layout
        gridLayout = GridLayout(1, 1)
        self.window.setLayout(gridLayout)
        self.window.setText(title)
        self._createLabel(labeltext)
        self._createBrowser(url=url, html=html)
        self._createOkButton()
        self._listenSelection()
        self.window.open()

    def _createLabel(self, labeltext):
        data = GridData(GridData.FILL_HORIZONTAL)
        data.verticalIndent = 5
        self.label = Label(self.window, SWT.WRAP)
        self.label.setLayoutData(data)
        self.label.setText(labeltext)
        self.label.setLocation(10, 40)

    def _createBrowser(self, html=None, url=None):
        data = GridData(SWT.FILL, SWT.FILL, 1, 1)
        data.verticalIndent = 10
        self.browser = Browser(self.window, SWT.BORDER)
        self.browser.setLayoutData(data)
        if url is not None:
            self.setURL(url)
        else:
            if html is not None:
                self.setText(html)
            else:
                pass

    def _createOkButton(self):
        data = GridData(GridData.HORIZONTAL_ALIGN_END)
        data.widthHint = 50
        button = Button(self.window, SWT.FLAT)
        button.setLayoutData(data)
        button.setText("OK")

        class MyListener(Listener):
            def handleEvent(self, event):
                if (event.widget == button):
                    button.getShell().close()

        button.addListener(SWT.Selection, MyListener())
        self.okButton = button

    def _listenSelection(self):
        thebrowser = self.browser
        from org.modelio.api.modelio import Modelio
        from org.modelio.api.app.navigation import INavigationListener

        class SelectionListener(INavigationListener):
            #def navigateTo(self):
            #  thebrowser.setText("selection is "+str(target.getName()))
            pass

        Modelio.getInstance().getNavigationService().addNavigationListener(
            SelectionListener())

    def setText(self, html):
        self.browser.setText( \
          "<html><header></header><body>" + html + "</body></html>")

    def setURL(self, url):
        self.browser.setUrl(url)

    def setLabel(self, text):
        self.label.setText(text)
コード例 #8
0
ファイル: misc.py プロジェクト: escribis/.modelio
class HtmlWindow(object):
  def __init__(self, url=None, html=None,title="information",width=800,height=800,labeltext=""):      
    parent = Display.getDefault().getActiveShell()
    self.window = Shell(parent, SWT.CLOSE | SWT.RESIZE)
    # give minimum size, location and size
    self.window.setMinimumSize(width, height)
    parentBounds = parent.getBounds()
    self.window.setLocation( \
      (parentBounds.width-width)/2+parentBounds.x, \
      (parentBounds.height-height)/2+parentBounds.y )
    self.window.setSize(width, height)
    # layout
    gridLayout = GridLayout(1, 1)
    self.window.setLayout(gridLayout)
    self.window.setText(title)
    self._createLabel(labeltext)
    self._createBrowser(url=url,html=html)
    self._createOkButton()
    self._listenSelection()
    self.window.open()
  def _createLabel(self,labeltext):
    data = GridData(GridData.FILL_HORIZONTAL)
    data.verticalIndent = 5;
    self.label = Label(self.window, SWT.WRAP)
    self.label.setLayoutData(data)
    self.label.setText(labeltext)
    self.label.setLocation(10, 40)
  def _createBrowser(self,html=None,url=None):
    data = GridData(SWT.FILL,SWT.FILL,1,1)
    data.verticalIndent = 10;
    self.browser = Browser(self.window, SWT.BORDER)
    self.browser.setLayoutData(data)
    if url is not None:
      self.setURL(url)
    else:
      if html is not None:
        self.setText(html)
      else:
        pass
  def _createOkButton(self):    
    data = GridData(GridData.HORIZONTAL_ALIGN_END)
    data.widthHint = 50
    button = Button(self.window, SWT.FLAT)    
    button.setLayoutData(data)    
    button.setText("OK")        
    class MyListener(Listener):
       def handleEvent(self, event):        
        if (event.widget == button):
           button.getShell().close()
    button.addListener(SWT.Selection, MyListener())
    self.okButton = button
  def _listenSelection(self):
    thebrowser = self.browser
    from org.modelio.api.modelio import Modelio
    from org.modelio.api.app.navigation import INavigationListener
    class SelectionListener(INavigationListener):
      #def navigateTo(self):
      #  thebrowser.setText("selection is "+str(target.getName()))
      pass
    Modelio.getInstance().getNavigationService().addNavigationListener(SelectionListener())
  def setText(self,html):  
    self.browser.setText( \
      "<html><header></header><body>" + html + "</body></html>")
  def setURL(self,url):
    self.browser.setUrl(url)
  def setLabel(self,text):
    self.label.setText(text)
コード例 #9
0
    def createPartControl(self, parent):
        sash = SashForm(parent, SWT.HORIZONTAL)

        local_file = File("C:/temp/demofile/map.html");
        browser =  Browser(parent, SWT.NONE)

        class ThisControlListener(ControlListener):
            def controlResized(self, e):
                # Use Javascript to set the browser width and height
                browser.execute(
                    "document.getElementById('map_canvas').style.width=%i;"
                    % (browser.getSize().x - 20))

                browser.execute(
                    "document.getElementById('map_canvas').style.height=%i;"
                    % (browser.getSize().y - 20))

            def controlMoved(self, e):
                pass

        browser.addControlListener(ThisControlListener())

        # Called by JavaScript
        class __CustomFunction(BrowserFunction):
            def __init__(self, browser, name):
                BrowserFunction.__init__(self, browser, name)
                self.data = CustomFunctionData(None)
                self.data.browser(browser)

            def function(self, arguments):
                lat = arguments[0]
                lng = arguments[1]
                MapView.locations.add("%s : %s" % (lat, lng))
                self.data.browser.execute(
                    "document.getElementById('map_canvas').style.width=%i;"
                    % (self.data.browser.getSize().x - 20))
                self.data.browser.execute(
                    "document.getElementById('map_canvas').style.height=%i;"
                    % (self.data.browser.getSize().y - 20))
                return None
        __CustomFunction(browser, "theJavaFunction")

        c = Composite(sash, SWT.BORDER)
        c.setLayout(GridLayout(2, True))


        where_button = Button(c, SWT.PUSH)
        where_button.setText("Where Am I ?")
        class __Where_SelectionAdapter(SelectionAdapter):
            def widgetSelected(self, e):
                lat = browser.evaluate("return map.getCenter().lat();")
                lng = browser.evaluate("return map.getCenter().lng();")
                MapView.locations.add("%s : %s" % (lat,lng))
        where_button.addSelectionListener(__Where_SelectionAdapter())

        add_button = Button(c, SWT.PUSH)
        add_button.setText("Add Marker")
        class __Add_SelectionAdapter(SelectionAdapter):
            def widgetSelected(self, e):
                browser.evaluate('createMarker')
        add_button.addSelectionListener(__Add_SelectionAdapter())

        locations = List(c, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL)
        grid_data = GridData(SWT.FILL, SWT.FILL, True, True)
        grid_data.horizontalSpan = 2
        locations.setLayoutData(grid_data)

        browser.setUrl(local_file.toURI().toString())