コード例 #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)
コード例 #2
0
ファイル: AdvancedSearch.py プロジェクト: escribis/macros
  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)
コード例 #3
0
ファイル: misc.py プロジェクト: escribis/.modelio
 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)
コード例 #4
0
ファイル: SWTLoginDialog.py プロジェクト: SiteView/NNM_CSS
 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
コード例 #5
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)
コード例 #6
0
ファイル: AdvancedSearch.py プロジェクト: escribis/macros
  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())
コード例 #7
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)
コード例 #8
0
def create(parent):
    label = Label(parent, SWT.NONE, text='Hello, World!')
コード例 #9
0
ファイル: test.py プロジェクト: nxi/gumtree
def create(parent):
    tasklet = __executor__.getEngine().get('activatedTasklet').getTasklet()
    label = Label(parent, SWT.NONE)
    label.setText(tasklet.getLabel())