Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 def getCustomTooltipDescription(self, tooltip, widget):
     event = self.makeToolTipEvent(widget)
     if util.callPrivateMethod(tooltip, "shouldCreateToolTip", [ event ]):
         shell = Shell()
         result = util.callPrivateMethod(tooltip, "createToolTipContentArea", [ event, shell ], [ Event, Composite ])
         desc = self.getDescription(result)
         result.dispose()
         shell.dispose()
         return desc
     else:
         return ""
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 ()
Ejemplo n.º 4
0
def select_scn_file():
    from org.eclipse.swt.widgets import Display, FileDialog, Shell
    from org.eclipse.swt import SWT

    display = Display.getDefault().getActiveShell()
    shell = Shell(display)

    fd = FileDialog(shell, SWT.OPEN)
    fd.setText('Open')
    filterExt = ['*.scn', '*.*']
    fd.setFilterExtensions(filterExt)
    return fd.open()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
      widthDelta = newRect.width - self.oldRect.width;
      if heightDelta > 0 or widthDelta > 0:
        gc = GC(composite);
      try:
        gc.fillRectangle(newRect.x, self.oldRect.height, newRect.width, heightDelta)
        gc.fillRectangle(self.oldRect.width, newRect.y, widthDelta, newRect.height)
      except:
        gc.dispose()
      self.oldRect = newRect


if __name__ == "__main__":
  
  # # TODO better to have swing or swt on the main thread?
  display = Display()
  shell = Shell(display)
  # StackLayout, only one is active at a time, Fill vs Grid vs other?
  gl = GridLayout()
  gl.numColumns = 3
  shell.setLayout(gl)

  # WARNING!! The following Swing / AWT imports MUST happen AFTER
  # the SWT display has been created!
  
  # And swing components
  from javax.swing import JFrame, JPanel, JApplet, UIManager
  from java.awt import FlowLayout, Dimension

  # custom views etc
  from DelvProcessing import *
  import inSite
Ejemplo n.º 7
0
    def __init__(self,
                 rootDataObjects,
                 getChildrenFun,
                 isLeafFun,
                 getImageFun=None,
                 getTextFun=None,
                 title="Explorer",
                 getGrayedFun=None,
                 getBackgroundFun=None,
                 getForegroundFun=None,
                 onSelectionFun=None):
        def _addRootDataObjects():
            # add the roots to the tree
            for rootDataObject in rootDataObjects:
                node = TreeItem(self.tree, 0)
                _decorateTreeItem(node, rootDataObject)
                # add a dummy node if this is not a leaf
                if not isLeafFun(rootDataObject):
                    TreeItem(node, 0)

        def _decorateTreeItem(node, dataObject):
            node.setData(dataObject)
            if getTextFun is not None:
                text = getTextFun(dataObject)
            else:
                text = unicode(dataObject)
            if text is not None:
                node.setText(text)
            if getImageFun is not None:
                image = getImageFun(dataObject)
                if image is not None:
                    # print "not none"
                    node.setImage(image)
            if getGrayedFun is not None:
                grayed = getGrayedFun(dataObject)
                if grayed is not None:
                    node.setGrayed(grayed)
            if getBackgroundFun is not None:
                background = getBackgroundFun(dataObject)
                if background is not None:
                    node.setBackground(background)
            if getForegroundFun is not None:
                foreground = getForegroundFun(dataObject)
                if foreground is not None:
                    node.setForeground(foreground)

        class ThisTreeExpandListener(Listener):
            def handleEvent(self, event):
                node = event.item
                # print "expanding node "+str(node.getData()),
                items = node.getItems()
                # print ": ",len(items),"children"
                # check if this subtree has already been expanded before
                # if so there is nothing to do, otherwise remove dummy nodes
                for item in items:
                    # print "  object",item.getData(),type(item.getData()),
                    if item.getData() is not None:
                        # print "already visited. Stop"
                        return
                    else:
                        # print "remove this node"
                        item.dispose()
                # get the children and add them to the tree
                for childDataObject in getChildrenFun(node.getData()):
                    item = TreeItem(node, 0)
                    _decorateTreeItem(item, childDataObject)
                    if not isLeafFun(childDataObject):
                        # create a dummy node
                        TreeItem(item, 0)

        class ThisTreeSelectionListener(Listener):
            def handleEvent(self, event):
                node = event.item
                # print "item selected",node,type(node)
                # print "details",event.detail
                if onSelectionFun is not None:
                    onSelectionFun(node.getData())

        parentShell = Display.getDefault().getActiveShell()
        self.window = Shell(parentShell, SWT.CLOSE | SWT.RESIZE)
        self.window.setText(title)
        self.window.setLayout(FillLayout())
        self.tree = Tree(self.window, SWT.BORDER)
        self.tree.addListener(SWT.Expand, ThisTreeExpandListener())
        self.tree.addListener(SWT.Selection, ThisTreeSelectionListener())
        _addRootDataObjects()
        size = self.tree.computeSize(300, SWT.DEFAULT)
        width = max(300, size.x)
        height = max(300, size.y)
        self.window.setSize(self.window.computeSize(width, height))
        self.window.open()
Ejemplo n.º 8
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)
Ejemplo n.º 9
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()
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
  def __init__(self,rootDataObjects,getChildrenFun,isLeafFun,
                getImageFun=None,getTextFun=None,title="Explorer",
                getGrayedFun=None,getBackgroundFun=None,getForegroundFun=None,
                onSelectionFun=None
              ):
              
    def _addRootDataObjects():
      # add the roots to the tree
      for rootDataObject in rootDataObjects:
        node = TreeItem(self.tree, 0)
        _decorateTreeItem(node,rootDataObject)
        # add a dummy node if this is not a leaf
        if not isLeafFun(rootDataObject):
          TreeItem(node,0)   
    
    def _decorateTreeItem(node,dataObject):
      node.setData(dataObject)
      if getTextFun is not None:
        text = getTextFun(dataObject)
      else:
        text = unicode(dataObject)
      if text is not None:
        node.setText(text)
      if getImageFun is not None:
        image = getImageFun(dataObject)
        if image is not None:
          # print "not none"
          node.setImage(image)
      if getGrayedFun is not None:
        grayed = getGrayedFun(dataObject)
        if grayed is not None:
          node.setGrayed(grayed)
      if getBackgroundFun is not None:
        background = getBackgroundFun(dataObject)
        if background is not None:
          node.setBackground(background)
      if getForegroundFun is not None:
        foreground = getForegroundFun(dataObject)
        if foreground is not None:
          node.setForeground(foreground)

    class ThisTreeExpandListener(Listener):
      def handleEvent(self, event):         
        node = event.item
        # print "expanding node "+str(node.getData()),
        items = node.getItems()
        # print ": ",len(items),"children"
        # check if this subtree has already been expanded before
        # if so there is nothing to do, otherwise remove dummy nodes
        for item in items:
          # print "  object",item.getData(),type(item.getData()),
          if item.getData() is not None:
            # print "already visited. Stop"
            return
          else:
            # print "remove this node"
            item.dispose()
        # get the children and add them to the tree
        for childDataObject in getChildrenFun(node.getData()):
          item = TreeItem(node,0)
          _decorateTreeItem(item,childDataObject)
          if not isLeafFun(childDataObject):
            # create a dummy node 
            TreeItem(item, 0)
            
    class ThisTreeSelectionListener(Listener):
      def handleEvent(self, event):
        node = event.item
        # print "item selected",node,type(node)
        # print "details",event.detail
        if onSelectionFun is not None:
          onSelectionFun(node.getData())        
        
    parentShell = Display.getDefault().getActiveShell()
    self.window = Shell(parentShell, SWT.CLOSE | SWT.RESIZE)
    self.window.setText(title)
    self.window.setLayout(FillLayout())
    self.tree = Tree(self.window, SWT.BORDER)
    self.tree.addListener(SWT.Expand, ThisTreeExpandListener())
    self.tree.addListener(SWT.Selection,ThisTreeSelectionListener())
    _addRootDataObjects()
    size = self.tree.computeSize(300, SWT.DEFAULT)
    width = max (300, size.x)
    height = max (300, size.y)
    self.window.setSize (self.window.computeSize(width, height))
    self.window.open ()
Ejemplo n.º 12
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)