Exemplo n.º 1
0
 def generate(self, *args):
     # The idea is to just do this, but it seems to cause strange things to happen
     # internally. So we do it outside SWTBot instead.
     # self.widget.setFocus()
     page = self.widget.getViewReference().getPage()
     view = self.widget.getViewReference().getView(False)
     swtsimulator.runOnUIThread(page.activate, view)
Exemplo n.º 2
0
    def connectRecord(self, method):
        class RecordListener(IPartListener):
            def partActivated(listenerSelf, part):
                method(part, self)

        page = self.widget.getViewReference().getPage()
        swtsimulator.runOnUIThread(page.addPartListener, RecordListener())
Exemplo n.º 3
0
 def connectRecord(self, method):
     class RecordListener(IPartListener):
         def partClosed(listenerSelf, part): #@NoSelf
             if part is self.widget.getViewReference().getView(False):
                 storytext.guishared.catchAll(method, part, self)
     page = self.widget.getViewReference().getPage()
     swtsimulator.runOnUIThread(page.addPartListener, RecordListener())
Exemplo n.º 4
0
 def _generate(self, cell):
     row, col = cell
     button = self.mouseButton()
     if button == 3:
         desc = InstantMenuDescriber(self.widget)
         simulator.runOnUIThread(desc.addFilter)
     simulator.runOnUIThread(self.widget.clickOnCell, row, col, self.clickCount(), button)
Exemplo n.º 5
0
 def connectRecord(self, method):
     swtsimulator.CTabCloseEvent.connectRecord(self, method)
     class DisposeFilter(swt.widgets.Listener):
         def handleEvent(listenerSelf, e): #@NoSelf
             if isinstance(e.widget, swt.custom.CTabItem):
                 self.disposedTabs[e.widget] = e.widget.getText()
                 
     if not self.disposeFilter:
         RCPCTabCloseEvent.disposeFilter = DisposeFilter()
         swtsimulator.runOnUIThread(self.widget.widget.widget.getDisplay().addFilter, SWT.Dispose, self.disposeFilter)
Exemplo n.º 6
0
 def drag(self, editPart, toX, toY, keyModifiers=0):
     widgetCentreX, widgetCentreY = self.getCenter(editPart)
     displayCentre = swtsimulator.runOnUIThread(self.getFigureCanvas().toDisplayLocation, widgetCentreX, widgetCentreY)
     centreX = displayCentre.x
     centreY = displayCentre.y
     self.logger.debug("Dragging " + repr((centreX, centreY)) + " to " + repr((toX, toY)))
     self.getFigureCanvas().mouseDrag(centreX, centreY, toX, toY, keyModifiers)
Exemplo n.º 7
0
 def mouseDrag(self, fromX, fromY, toX, toY, keyModifiers=0):
     # These values, and the broad algorithm here, are taken from a draft implementation of DnD for SWTBot
     # The code is attached to the bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271
     # When it is integrated into SWTBot we should probably use it directly
     dragThreshold = 16
     dragDelay = 0.3
     self.eventPoster.moveMouseAndWait(fromX, fromY)
            
     self.eventPoster.checkAndPostKeyPressed(keyModifiers)
     initialDragTargetX = fromX + dragThreshold
     initialDragTargetY = fromY
     swtsimulator.runOnUIThread(storytext.guishared.catchAll, self.startDrag, initialDragTargetX, initialDragTargetY)
     time.sleep(dragDelay)
     self.moveDragged(initialDragTargetX, initialDragTargetY, toX, toY)
     swtsimulator.runOnUIThread(storytext.guishared.catchAll, self.eventPoster.postMouseUp)
     self.eventPoster.checkAndPostKeyReleased(keyModifiers)
Exemplo n.º 8
0
 def isPreferred(self):
     viewWidget = self.getViewWidget()
     if viewWidget in self.widgetViewIds:
         viewId = self.widgetViewIds.get(viewWidget)
         activeViewId = swtsimulator.runOnUIThread(self.getActiveViewId)
         return viewId == activeViewId
     else:
         return False
Exemplo n.º 9
0
 def updateTableInfo(self):
     simulator.runOnUIThread(self.setOffsets, self.widget)
     self.logger.debug("Updated NatTable indexer with row offset " + str(self.rowOffset) + " and column offset " + str(self.colOffset))
     simulator.TableIndexer.updateTableInfo(self)
Exemplo n.º 10
0
 def widgetDisposed(self):
     control = self.getControl()
     return control is None or swtsimulator.runOnUIThread(control.isDisposed)
Exemplo n.º 11
0
 def generate(self, *args):
     # The idea is to just do this, but it seems to cause strange things to happen
     #internally. So we do it outside SWTBot instead.
     #self.widget.setFocus()
     swtsimulator.runOnUIThread(self.clickMatchingTab, *args)
Exemplo n.º 12
0
 def connectRecord(self, method):
     swtsimulator.SelectEvent.connectRecord(self, method)
     widget = self.widget.widget.widget
     if hasattr(widget, "getAccelerator"):
         swtsimulator.runOnUIThread(self.connectRecordKeyBinding, widget, method)
Exemplo n.º 13
0
 def getViewWidget(self):
     widget = self.widget.widget
     if isinstance(widget, swt.widgets.MenuItem):
         return swtsimulator.runOnUIThread(util.getRootMenu, widget)
     else:
         return widget
Exemplo n.º 14
0
 def generate(self, *args):
     swtsimulator.runOnUIThread(self.widget.clickOnCenter)
Exemplo n.º 15
0
 def checkRowInViewport(self, row):
     clientAreaHeight = simulator.runOnUIThread(self.widget.getClientArea).height
     bounds = simulator.runOnUIThread(self.widget.getBoundsByPosition, 0, row)
     y = util.getInt(bounds.y) + util.getInt(bounds.height) / 2
     if y > clientAreaHeight:
         raise UseCaseScriptError, "Could not select row, it is outside the viewport"
Exemplo n.º 16
0
 def scrollToY(self, layer, offset):
     yCoord = layer.getOrigin().getY()
     simulator.runOnUIThread(layer.setOriginY, yCoord + offset)
Exemplo n.º 17
0
 def mouseMoveLeftClick(self, x, y, keyModifiers=0):
     displayLoc = swtsimulator.runOnUIThread(self.toDisplayLocation, x, y)
     self.eventPoster.moveClickAndReturn(displayLoc.x, displayLoc.y, keyModifiers)
Exemplo n.º 18
0
    def connectRecord(self, method):
        class RecordListener(ExpansionAdapter):
            def expansionStateChanged(listenerSelf, e): #@NoSelf
                storytext.guishared.catchAll(method, e, self)

        swtsimulator.runOnUIThread(self.widget.widget.widget.addExpansionListener, RecordListener())
Exemplo n.º 19
0
 def addActivePartListener(self, swtbotView):
     class RecordListener(IPartListener):
         def partActivated(listenerSelf, part):#@NoSelf
             self.monitorMenus(swtbotView)
     page = swtbotView.getViewReference().getPage()
     swtsimulator.runOnUIThread(page.addPartListener, RecordListener())
Exemplo n.º 20
0
 def monitorAllWidgets(self, *args, **kw):
     self.setWidgetAdapter()
     swtsimulator.runOnUIThread(self.cacheAndMonitorViews)
     swtsimulator.WidgetMonitor.monitorAllWidgets(self, *args, **kw)
Exemplo n.º 21
0
 def clickOnCenter(self, row, col, clickCount, button):
     bounds = self.widget.getBoundsByPosition(col, row)
     x = util.getInt(bounds.x) + util.getInt(bounds.width) / 2
     y = util.getInt(bounds.y) + util.getInt(bounds.height) / 2
     displayLoc = simulator.runOnUIThread(self.display.map, self.widget, None, x, y)
     self.eventPoster.moveClickAndReturn(displayLoc.x, displayLoc.y, count=clickCount, button=button)