Example #1
0
 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)
Example #2
0
  def createContent(self, child, results, wordtosearch):
    resultsCount = len(results)
    gridLayout = GridLayout(1, 1)
    child.setLayout(gridLayout)

    #-- Introduction text
    introdata = GridData(GridData.FILL_HORIZONTAL) ; introdata.verticalIndent = 5
    introlabel = Label(child, SWT.WRAP)            ; introlabel.setLayoutData(introdata)
    if (resultsCount==0):
      introlabel.setText("No element matching your search request '"+wordtosearch+"' has been found.")
    else:
      if not orgVersion:
        introlabel.setText("Click on each element to select it directly from the UML model explorer.")
    introlabel.setLocation(10, 40)

    #-- "Objects found" panel containing a table (if the results is not empty)
    if (resultsCount!=0):
      resultsGroup = Group(child, SWT.NONE)
      fd_resultsGroup = GridData(SWT.FILL, SWT.FILL, 1,1)
      resultsGroup.setLayoutData(fd_resultsGroup)
      if resultsCount == 1:
        text = "1 element found"
      else:
        text = str(resultsCount)+" elements found"
      resultsGroup.setText(text)
      gridLayout2 = GridLayout()
      gridLayout2.numColumns = 1
      resultsGroup.setLayout(gridLayout)
      table = TableViewer(resultsGroup, SWT.NONE);
      table.getControl().setLayoutData(GridData(GridData.FILL_BOTH))
      # When a element in the list is selected then select it in modelio explorer
      # This is achieved with fireNavigate method of the NavigationService
      # FIXME this feature is currently not working on V3 because of fireNavigate
      class SCListener(ISelectionChangedListener):
        def __init__(self, app):
          self.app = app
        def selectionChanged(self, event):
          selection = event.getSelection()
          element = selection.getFirstElement()
          print element
          if (element != None):
            Modelio.getInstance().getNavigationService().fireNavigate(element)

      sclistener = SCListener(self)
      table.setContentProvider(self.SearchResultsContentProvider(results))
      table.setLabelProvider(self.SearchResultsLabelProvider())
      table.addSelectionChangedListener(sclistener)
      table.setInput(results)

    #-- "Close" Button
    closeBtn = Button(child, SWT.FLAT)
    closeBtn.setText("Close")
    class MyListener(Listener):
     def handleEvent(self, event):
      if (event.widget == closeBtn):
         closeBtn.getShell().close()
    listener = MyListener()
    closeBtn.addListener(SWT.Selection, listener)
    btndata = GridData(GridData.HORIZONTAL_ALIGN_END) ;    btndata.widthHint = 50
    closeBtn.setLayoutData(btndata)
Example #3
0
 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)
Example #4
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
Example #5
0
 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
Example #6
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
Example #7
0
    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 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
 def createDialogArea(self, parent):
     self.getShell().setText("Login")
     container=self.super__createDialogArea(parent)
     gridLayout= container.getLayout()
     gridLayout.numColumns=2;  
     
     label = Label(container, SWT.None)
     label.setLayoutData(GridData(SWT.RIGHT, SWT.CENTER, False, False))
     label.setText("User Name: ")
     
     self.text = Text(container, SWT.BORDER)
     self.text.setLayoutData(GridData(SWT.FILL, SWT.CENTER, True, False))       
             
     label = Label(container, SWT.None)
     label.setLayoutData(GridData(SWT.RIGHT, SWT.CENTER, False, False))
     label.setText("Password: ")
     
     self.passwordText = Text(container, SWT.BORDER|SWT.PASSWORD)
     self.passwordText.setLayoutData(GridData(SWT.FILL, SWT.CENTER, True, False))
     return container
Example #10
0
  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
  #pgd.heightHint = 504
  browser2.setLayoutData(pgd)

  browser3 = Browser(shell, SWT.RESIZE)
Example #11
0
  def _createContent(self, child):
    gridLayout = GridLayout(1, 1)
    child.setLayout(gridLayout)

    #---- (1) "Name filter" group
    # This group contains:
    # - a text area with a filter label
    # - regexpr check box with its label
    nameFilterGroup = Group(child, SWT.NONE)
    fd_resultsGroup = GridData(GridData.FILL_HORIZONTAL)
    nameFilterGroup.setLayoutData(fd_resultsGroup)
    nameFilterGroup.setText("Name filter")
    gridLayout2 = GridLayout()
    gridLayout2.numColumns = 2
    nameFilterGroup.setLayout(gridLayout2)
    filterlabel = Label(nameFilterGroup, SWT.NULL)
    filterlabel.setText("Filter: ")
    filterTxt = Text(nameFilterGroup, SWT.SINGLE | SWT.BORDER)
    gridData = GridData(SWT.FILL, SWT.DEFAULT, 1, 0)
    filterTxt.setLayoutData(gridData)
    regexpCheckBox = Button(nameFilterGroup, SWT.CHECK)
    regexpCheckBox.setText("Use regular expression")

    #---- (2) "Metaclass filter" group
    # This group contains:
    # (2.1) a table on the left for unselected metaclasses
    # (2.2) two buttons on the center: ">>" and "<<" 
    # (2.3) a table on the right for selected metaclasses
    mcFilterGroup = Group(child, SWT.NONE)
    gd_mcFilterGroup = GridData(SWT.FILL, SWT.FILL, 1,1)
    mcFilterGroup.setLayoutData(gd_mcFilterGroup)
    mcFilterGroup.setText("Metaclass filter")
    gridLayout3 = GridLayout() ; gridLayout3.numColumns = 3
    mcFilterGroup.setLayout(gridLayout3)
    # (2.1) table for unselected metaclasses
    unselectedMetaclassesTable = TableViewer(mcFilterGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL)
    unselectedMetaclassesTable.setLabelProvider(self._MCLabelProvider())
    unselectedMetaclassesTable.setContentProvider(self._MCContentProvider())
    gdata = GridData(SWT.FILL, SWT.FILL, 1, 1)
    gdata.minimumWidth = 200;
    unselectedMetaclassesTable.getControl().setLayoutData(gdata)
    unselectedMetaclassesTable.setInput(unselectedMetaclasses)

    # (2.2) Add (">>") and Remove ("<<") buttons
    # They allow to change the list of metaclasses selected
    # The buttons are in a composite
    compositeButtons = Composite(mcFilterGroup, SWT.NONE)
    gdLayout = GridLayout()
    gdLayout.numColumns = 1;
    compositeButtons.setLayout(gdLayout)
    gdata2 = GridData(SWT.DEFAULT, SWT.CENTER, 0, 1)
    gdata2.widthHint = 50
    compositeButtons.setLayoutData(gdata2)
    # ">>" button
    addBtn = Button(compositeButtons, SWT.FLAT)
    addBtn.setText(">>")
    gd_addData = GridData(GridData.FILL_HORIZONTAL)
    gd_addData.widthHint = 20
    addBtn.setLayoutData(gd_addData)
    # "<<" button
    removeBtn = Button(compositeButtons, SWT.FLAT)
    removeBtn.setText("<<")
    gd_removeData = GridData(GridData.FILL_HORIZONTAL)
    gd_removeData.widthHint = 20
    removeBtn.setLayoutData(gd_removeData)

    # (2.3) Table on the right for selected metaclasses
    selectedMetaclassTable = TableViewer(mcFilterGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL)
    selectedMetaclassTable.setLabelProvider(self._MCLabelProvider())
    selectedMetaclassTable.setContentProvider(self._MCContentProvider())
    gdata3 = GridData(SWT.FILL, SWT.FILL, 1, 1)
    gdata3.minimumWidth = 200;
    selectedMetaclassTable.getControl().setLayoutData(gdata3)
    selectedMetaclassTable.setInput(selectedMetaclasses)

    #---- (3) Bottom buttons : "Search" and "Close"
    compositeBottomButtons = Composite(child, SWT.NONE)
    gdLayout = GridLayout()
    gdLayout.numColumns = 2;
    compositeBottomButtons.setLayout(gdLayout)
    compositeBottomButtons.setLayoutData(GridData(SWT.END, SWT.BOTTOM, 0, 0 ))
    searchBtn = Button(compositeBottomButtons, SWT.FLAT)
    searchBtn.setText("Search")
    closeBtn = Button(compositeBottomButtons, SWT.FLAT)
    closeBtn.setText("Close")
    btndata = GridData(GridData.HORIZONTAL_ALIGN_END)
    btndata.widthHint = 50
    closeBtn.setLayoutData(btndata)
    btndata = GridData(GridData.HORIZONTAL_ALIGN_END)
    btndata.widthHint = 50
    searchBtn.setLayoutData(btndata)
    
    #---- Install a listener shared by all buttons
    class _ButtonsListener(Listener):
      def handleEvent(self, event):
        if (event.widget == closeBtn):
          # "Close" button handler
          closeBtn.getShell().close()
        elif (event.widget == searchBtn):
          # "Search" button handler
          wordtosearch = filterTxt.getText().strip()
          if (wordtosearch != ""):
            options = [regexpCheckBox.getSelection()]
            SearchResultsWindow(child, selectedMetaclasses, wordtosearch, options)
        elif (event.widget == addBtn):
          #  ">>" button handler
          indices = unselectedMetaclassesTable.getControl().getSelectionIndices()
          i = 0
          for indice in indices:
            mc = unselectedMetaclasses[indice-i]
            selectedMetaclasses.append(mc)
            unselectedMetaclasses.remove(mc)
            i = i+1
          selectedMetaclasses.sort(key=key_name)
          unselectedMetaclassesTable.refresh()
          selectedMetaclassTable.refresh()
        elif (event.widget == removeBtn):
          #  "<<" button handler
          indices = selectedMetaclassTable.getControl().getSelectionIndices()
          i = 0
          for indice in indices:
            mc = selectedMetaclasses[indice-i]
            unselectedMetaclasses.append(mc)
            selectedMetaclasses.remove(mc)
            i = i+1
          unselectedMetaclasses.sort(key=key_name)
          unselectedMetaclassesTable.refresh()
          selectedMetaclassTable.refresh()
    listener = _ButtonsListener()
    addBtn.addListener(SWT.Selection, listener)
    removeBtn.addListener(SWT.Selection, listener)
    closeBtn.addListener(SWT.Selection, listener)
    searchBtn.addListener(SWT.Selection, listener)
    
    #---- Install a table listener for both tables
    class _TableSelectionChangedListener(ISelectionChangedListener):
      def selectionChanged(self, e):
        selection = e.getSelection()
    unselectedMetaclassesTable.addSelectionChangedListener(_TableSelectionChangedListener())
    selectedMetaclassTable.addSelectionChangedListener(_TableSelectionChangedListener())
Example #12
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())