Exemple #1
0
 def __init__(self):
   childW = 500
   childH = 400
   parent = Display.getDefault().getActiveShell()
   child = Shell(parent, SWT.CLOSE | SWT.RESIZE)
   child.setMinimumSize(childW, childH)
   child.setText("Advanced Search")
   self._createContent(child)
   parentW = parent.getBounds().width
   parentH = parent.getBounds().height
   parentX = parent.getBounds().x
   parentY = parent.getBounds().y
   child.setLocation((parentW-childW)/2+parentX, (parentH-childH)/2+parentY)
   child.setSize(childW, childH)
   child.open()
Exemple #2
0
  def __init__(self, parentWindow, metaclasses, wordtosearch, options):
    # do the search
    results = HashSet()
    listMC = ArrayList()
    for mc in metaclasses:
      listMC.add(mc.metaclass)
    results = search(listMC, wordtosearch, options)

    # build the interface
    childW = 420
    if (len(results)==0):
      childH=100
    else:
      childH = 400
    child = Shell(parentWindow, SWT.CLOSE | SWT.RESIZE)
    child.setMinimumSize(childW, childH)
    child.setText("Search Results")
    self.createContent(child, results, wordtosearch)
    x = (parentWindow.getBounds().width-childW)/2+parentWindow.getBounds().x
    y = (parentWindow.getBounds().height-childH)/2+parentWindow.getBounds().y
    child.setLocation(x, y)
    child.setSize(childW, childH)
    child.open()
Exemple #3
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)
Exemple #4
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)