コード例 #1
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
コード例 #2
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)
コード例 #3
0
ファイル: cars_app.py プロジェクト: krismz/Delv
  # 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
  #pgd.heightHint = 504
  browser2.setLayoutData(pgd)

  browser3 = Browser(shell, SWT.RESIZE)
  jggplot = JRI_ggplot(None, Rengine(["--vanilla"], False, None))
  jggplot.Rengine.eval('mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),labels=c("4cyl","6cyl","8cyl"))')
  #browser3.setUrl(jggplot.qplot("cyl","mpg","mtcars")
  browser3.setUrl(jggplot.qplot("wt","mpg","mtcars", 'geom=c("point", "smooth"), method="lm", formula=y~x, color=cyl, main="Regression of MPG on Weight", xlab="Weight", ylab="Miles per Gallon"'))

  #jgd = GridData(SWT.FILL, SWT.FILL, True, True)
コード例 #4
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)