Пример #1
0
    def getImageName(self, image):
        name = self.imageToName.get(image)
        if name is not None:
            return name

        data = image.getImageData()
        hasExcessData = data.width * data.depth / 8 < data.bytesPerLine
        imageDict = self.storedImages.get((data.width, data.height), {})
        for name, imgData in imageDict.items():
            if self.imageDataMatches(data, imgData, hasExcessData):
                baseName = os.path.basename(name)
                self.imageToName[image] = baseName             
                return baseName
        for iconId, iconName in self.systemIcons:
            iconImage = Display.getCurrent().getSystemImage(iconId)
            if iconImage and self.imageDataMatches(data, iconImage.getImageData(), hasExcessData):
                return "system_" + iconName
        for img, imgName in self.renderedImages:
            if self.imageDataMatches(data, img.getImageData(), hasExcessData):
                return "rendered_" + imgName
        # Last chance, see if the image has been greyed out 
        for name, imgData in imageDict.items():
            greyedImg = Image(Display.getCurrent(), Image(Display.getCurrent(), imgData), SWT.IMAGE_GRAY)
            greyedData = greyedImg.getImageData()
            hasGreyedExcessData = greyedData.width * greyedData.depth / 8 < greyedData.bytesPerLine
            if self.imageDataMatches(data, greyedData, hasGreyedExcessData):
                greyedName =  os.path.basename(name) + "', 'greyed out"
                self.imageToName[image] = greyedName             
                return greyedName
 def run(self):
     while display.isActive():
         scan_id = long(display.getVar("LatestPointScanID"))
         if scan_id > 0:
             scanInfo = client.getScanInfo(scan_id)
             statusLabel.setPropertyValue("text",
                                          scanInfo.getState().toString())
             if scanInfo.getState().isActive():
                 scanNameLabel.setPropertyValue("text", scanInfo.getName())
                 commandLabel.setPropertyValue("text",
                                               scanInfo.getCurrentCommand())
                 progressBar.setPropertyValue(
                     "pv_value",
                     scanInfo.getPercentage() / 100.0)
                 # Mark scanned points as green
                 for i in range(table.getRowCount()):
                     xpos = float(table.getCellText(i, 1))
                     ypos = float(table.getCellText(i, 2))
                     if (
                             xpos == PVUtil.getDouble(pvs[1])
                             and ypos == PVUtil.getDouble(pvs[2])
                             and scanInfo.getPercentage() >=
                             i * 100.0 / table.getRowCount()
                     ):  #To make sure the matched position is set from this scan
                         Display.getDefault().asyncExec(
                             SetRowColor(i, ColorFontUtil.GREEN))
             elif scanInfo.getState().isDone():
                 display.setVar("LatestPointScanID", -1)
         else:
             scanNameLabel.setPropertyValue("text", "None")
             commandLabel.setPropertyValue("text", "")
             progressBar.setPropertyValue("pv_value", 0)
         Thread.sleep(1000)
Пример #3
0
 def _getForeground(data):
   if isinstance(data,ElementInfo):
     return Color(Display.getCurrent(),0,0,150)
   elif isinstance(data,MetaFeatureSlot):
     mv = data.getModelValue()
     if mv.isElement() or mv.isElementList(): 
       return Color(Display.getCurrent(),0,100,0)
     else:
       return Color(Display.getCurrent(),0,180,0)      
Пример #4
0
def open_file_dialog(type=SWT.SINGLE, ext=['*.*']):
    __display_run__ = __Display_Runnable__(type, ext)
    Display.getDefault().asyncExec(__display_run__)
    while __display_run__.filename is None:
        time.sleep(0.5)
    if type == SWT.MULTI:
        fns = []
        for fn in __display_run__.filenames:
            fns.append(__display_run__.path + '/' + fn)
        return fns
    return __display_run__.filename
Пример #5
0
    def run(self):
        while display.isActive():
            scanInfos = client.server.getScanInfos()
            findActive = False
            markedDone = False
            for scanInfo in scanInfos:
                if scanInfo.getId() == long(
                        display.getVar("LatestPointScanID")):
                    statusLabel.setPropertyValue(
                        "text",
                        scanInfo.getState().toString())
                if scanInfo.getState().isDone():
                    #mark table to dark gray if it is done.
                    if scanInfo.getId() == long(
                            display.getVar(
                                "LatestPointScanID")) and not markedDone:
                        for i in range(table.getRowCount()):
                            Display.getDefault().asyncExec(
                                SetRowColor(i, ColorFontUtil.DARK_GRAY))
                        markedDone = True
                    continue
                if scanInfo.getState().isActive():
                    scanNameLabel.setPropertyValue("text", scanInfo.getName())
                    commandLabel.setPropertyValue("text",
                                                  scanInfo.getCurrentCommand())
                    progressBar.setPropertyValue(
                        "pv_value",
                        scanInfo.getPercentage() / 100.0)
                    #Mark scanned points as green
                    if scanInfo.getId() == long(
                            display.getVar("LatestPointScanID")):
                        markedDone = False
                        for i in range(table.getRowCount()):
                            xpos = float(table.getCellText(i, 1))
                            ypos = float(table.getCellText(i, 2))
                            if (
                                    xpos == PVUtil.getDouble(pvs[1])
                                    and ypos == PVUtil.getDouble(pvs[2])
                                    and scanInfo.getPercentage() >=
                                    i * 100.0 / table.getRowCount()
                            ):  #To make sure the matched position is set from this scan
                                Display.getDefault().asyncExec(
                                    SetRowColor(i, ColorFontUtil.GREEN))

                    findActive = True

            if not findActive:
                scanNameLabel.setPropertyValue("text", "None")
                commandLabel.setPropertyValue("text", "")
                progressBar.setPropertyValue("pv_value", 0)
            Thread.sleep(200)
def showDialogBox(text, message):      	 
	from org.eclipse.swt.widgets import Display
	from java.lang import Runnable
	
	class ShowDialogBox(Runnable):
	    def __init__(self):
	        pass
	
	    def run(self):
			m = MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING|SWT.OK)
			m.setText(text)
			m.setMessage(message)
			m.open()
	
	Display.getDefault().syncExec(ShowDialogBox())
Пример #7
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()
Пример #8
0
 def valueChanged(self, controller, newValue):
     global __file_to_add__
     newCount = int(newValue.getStringData())
     if newCount != self.saveCount:
         self.saveCount = newCount
         try:
             checkFile = File(__file_name_node__.getValue().getStringData())
             checkFile = File(__data_folder__ + "/" + checkFile.getName())
             __file_to_add__ = checkFile.getAbsolutePath()
             if not checkFile.exists():
                 print "The target file :" + __file_to_add__ + " can not be found"
                 return
             runnable = __Display_Runnable__()
             runnable.run = add_dataset
             Display.getDefault().asyncExec(runnable)
         except:
             print 'failed to add dataset ' + __file_to_add__
Пример #9
0
 def getImageFromName(self,name):
   if name not in self.imageMap:
     try:
       image = Image(Display.getCurrent(),os.path.join(self.resourcePath,name+self.extension))
     except:
       image = None
     self.imageMap[name] = image
   return self.imageMap[name]
Пример #10
0
 def valueChanged(self, controller, newValue):
     global __file_to_add__
     newCount = int(newValue.getStringData());
     if newCount != self.saveCount:
         self.saveCount = newCount;
         try:
             checkFile = File(__file_name_node__.getValue().getStringData());
             checkFile = File(__data_folder__ + "/" + checkFile.getName());
             __file_to_add__ = checkFile.getAbsolutePath();
             if not checkFile.exists():
                 print "The target file :" + __file_to_add__ + " can not be found";
                 return
             runnable = __Display_Runnable__()
             runnable.run = add_dataset
             Display.getDefault().asyncExec(runnable)
         except: 
             print 'failed to add dataset ' + __file_to_add__
def hardwareModelIsMissingMessageBox(programs):
	for program in programs :
		if not program.getRepresenting():
			msg = MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING|SWT.OK)
			msg.setText("Update or generate code")
			msg.setMessage("Warn : generate hardware model please.")
			msg.open()
			return False
	return True
Пример #12
0
 def getImageFromName(self, name):
     if name not in self.imageMap:
         try:
             image = Image(
                 Display.getCurrent(),
                 os.path.join(self.resourcePath, name + self.extension))
         except:
             image = None
         self.imageMap[name] = image
     return self.imageMap[name]
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()
Пример #14
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()
    def run_in_display(self, func):
        # https://stackoverflow.com/questions/1265174/nullpointerexception-in-platformui-getworkbench-getactiveworkbenchwindow-get

        # We can subclass java.lang.Runnable using normal python-style subclassing
        class SelectedTextGetterRunnable(Runnable):
            def run(self):
                func()

        # and create an instance of it.
        runner = SelectedTextGetterRunnable()

        display = Display.getDefault()
        display.asyncExec(runner)
Пример #16
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()
 def run(self):
     while display.isActive():
         scan_id = long(display.getVar("LatestPointScanID"))
         if scan_id > 0:
             scanInfo = client.getScanInfo(scan_id)
             statusLabel.setPropertyValue("text", scanInfo.getState().toString())
             if scanInfo.getState().isActive():
                 scanNameLabel.setPropertyValue("text", scanInfo.getName())
                 commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand())
                 progressBar.setPropertyValue("pv_value", scanInfo.getPercentage()/100.0)
                 # Mark scanned points as green 
                 for i in range(table.getRowCount()):
                     xpos=float(table.getCellText(i, 1))
                     ypos=float(table.getCellText(i, 2))
                     if (xpos == PVUtil.getDouble(pvs[1]) and ypos==PVUtil.getDouble(pvs[2]) 
                         and scanInfo.getPercentage() >= i*100.0/table.getRowCount()): #To make sure the matched position is set from this scan                              
                         Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.GREEN))
             elif scanInfo.getState().isDone():
                  display.setVar("LatestPointScanID", -1)
         else:
             scanNameLabel.setPropertyValue("text", "None")
             commandLabel.setPropertyValue("text", "")
             progressBar.setPropertyValue("pv_value", 0)
         Thread.sleep(1000)
 def run(self):
     while display.isActive():
         scanInfos = client.server.getScanInfos()
         findActive = False
         markedDone = False
         for scanInfo in scanInfos:
             if scanInfo.getId() == long(display.getVar("LatestPointScanID")):
                 statusLabel.setPropertyValue("text", scanInfo.getState().toString())
             if scanInfo.getState().isDone():
                 #mark table to dark gray if it is done.
                 if scanInfo.getId() == long(display.getVar("LatestPointScanID")) and not markedDone :
                     for i in range(table.getRowCount()):
                         Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.DARK_GRAY))
                     markedDone=True 
                 continue
             if scanInfo.getState().isActive():
                 scanNameLabel.setPropertyValue("text", scanInfo.getName())
                 commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand())
                 progressBar.setPropertyValue("pv_value", scanInfo.getPercentage()/100.0)
                 #Mark scanned points as green 
                 if scanInfo.getId() == long(display.getVar("LatestPointScanID")):
                     markedDone=False
                     for i in range(table.getRowCount()):
                         xpos=float(table.getCellText(i, 1))
                         ypos=float(table.getCellText(i, 2))
                         if (xpos == PVUtil.getDouble(pvs[1]) and ypos==PVUtil.getDouble(pvs[2]) 
                             and scanInfo.getPercentage() >= i*100.0/table.getRowCount()): #To make sure the matched position is set from this scan                              
                             Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.GREEN))                            
                
                 findActive=True   
                 
         if not findActive:
             scanNameLabel.setPropertyValue("text", "None")
             commandLabel.setPropertyValue("text", "")
             progressBar.setPropertyValue("pv_value", 0)
         Thread.sleep(200)
  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 ()
Пример #20
0
def go():
    global display
    
    # global variable window is org.eclipse.ui.internal.WorkbenchWindow
    open_monkey_console()

    display = Display.getCurrent()
    
    runnable = MyRunnable()
    if not runnable.prepare():
        return
    
    create_progress_monitor()
        
    progress_monitor_dialog = ProgressMonitorDialog(window.getShell())
    progress_monitor_dialog.run(True, True, runnable);
    
    window.updateActionBars()
Пример #21
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()
        traceback.print_exc(file=sys.stdout)
        print 'failed to log'


def slog(text):
    logln(text + '\n')
    logBook(text)


class __Dispose_Listener__(DisposeListener):
    def __init__(self):
        pass

    def widgetDisposed(self, event):
        pass


def __dispose_all__(event):
    if __buffer_logger__:
        __buffer_logger__.close()
    if __history_logger__:
        __history_logger__.close()


__dispose_listener__ = __Dispose_Listener__()
__dispose_listener__.widgetDisposed = __dispose_all__

__display_run__ = __Display_Runnable__()
Display.getDefault().asyncExec(__display_run__)

load_script('KKB-Plot and Reduction.py')
          PopupDialog.__init__(self, 
                               Shell(),
                               PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, 
                               True, False, True, False, 
                               'Details about \'' + advice.getName() + '\'', 'Juniper IDE')

      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

class ShowDialog(Runnable):
      def __init__(self, advice):
          self.advice = advice
      def run(self):
          AlertDialog(self.advice).open()

Display.getDefault().syncExec(ShowDialog(advice))
Пример #24
0
def Exec(r):
    display = Display.getDefault()
    display.syncExec(r)
    return None
Пример #25
0
class MyROIInfoProvider(IROIInfoProvider):
    '''Provide custom information for ROI.
    '''
    def getROIInfo(self, xIndex, yIndex, width, height):
        return name + "(" + str(xIndex) + ", " + str(yIndex) + " )"
        
class MyROIListener(IROIListener):
    '''Listener on ROI updates.
    '''
    def roiUpdated(self, xIndex, yIndex, width, height):
        roiXPV.setValue(xIndex)
        roiYPV.setValue(yIndex)
        roiWPV.setValue(width)
        roiHPV.setValue(height)

currentDisplay = Display.getCurrent()
class UpdateROIUITask(Runnable):
	def run(self):
		#this method must be called in UI thread
		intensityGraph.setROIDataBounds(name, PVUtil.getLong(roiXPV), PVUtil.getLong(roiYPV), PVUtil.getLong(roiWPV),PVUtil.getLong(roiHPV))
		
class UpdateROIFromPVListener(PVListener):
	'''Update the ROI while ROI PV value updated'''
	def pvValueUpdate(self, pv):
		currentDisplay.asyncExec(UpdateROIUITask())

intensityGraph.addROI(name, MyROIListener(), MyROIInfoProvider())

roiXPV.addListener(UpdateROIFromPVListener())
roiYPV.addListener(UpdateROIFromPVListener())
roiWPV.addListener(UpdateROIFromPVListener())
Пример #26
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()
Пример #27
0
def exec(r):
	display = Display.getDefault()	
	display.syncExec(r)
	return None
                             xyGraph.primaryYAxis)
rightAnnotation.setCursorLineStyle(Annotation.CursorLineStyle.UP_DOWN)
rightAnnotation.setValues(7, 5)
xyGraph.addAnnotation(rightAnnotation)


class RightAnnotationListener(IAnnotationListener):
    '''Listener on right annotation
	'''
    def annotationMoved(self, oldX, oldY, newX, newY):
        rightPV.setValue(newX)


rightAnnotation.addAnnotationListener(RightAnnotationListener())

currentDisplay = Display.getCurrent()


class UpdateAnnotationUITask(Runnable):
    def run(self):
        #this method must be called in UI thread
        leftAnnotation.setValues(PVUtil.getDouble(leftPV),
                                 leftAnnotation.getYValue())
        rightAnnotation.setValues(PVUtil.getDouble(rightPV),
                                  rightAnnotation.getYValue())


class UpdateAnnotationPVListener(IPVListener):
    '''Update the ROI while ROI PV value updated'''
    def valueChanged(self, pv):
        currentDisplay.asyncExec(UpdateAnnotationUITask())
Пример #29
0
    def runInUi(callAble):
        """@param callable: the callable that will be run in the UI."""

        Display.getDefault().asyncExec(RunInUi(callAble))
Пример #30
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 ()
		scp.set('todir', 'root@'+ip+':${deployment.path}')
		scp.set('keyfile', '${accesspoint.keyfile}')
		scp.set('forwardingHost', '${accesspoint.address}')
		scp.set('forwardingUserName', '${accesspoint.username}')
		scp.set('passphrase', '')
		scp.set('trust', 'on')
		scp.set('verbose', 'on')

f.write('<?xml version="1.0"?>' + ET.tostring(project, encoding='utf-8'))
f.close()

# Make Jdesigner re-generate Java files
from org.modelio.api.modelio import Modelio
from org.modelio.module.javadesigner.api import JavaDesignerParameters
config.setParameterValue(JavaDesignerParameters.GENDOCPATH, "$(Project)/code/"+projectName+"/doc")
config.setParameterValue(JavaDesignerParameters.GENERATIONPATH, "$(Project)/code/"+projectName+"/src")
config.setParameterValue(JavaDesignerParameters.JARFILEPATH, "$(Project)/code/"+projectName+"/src")
config.setParameterValue(JavaDesignerParameters.JAVAHGENERATIONPATH, "$(Project)/code/"+projectName+"/src")

from org.eclipse.swt.widgets import Display
from java.lang import Runnable

class RunGeneration(Runnable):
    def __init__(self):
        pass

    def run(self):
    	jdesigner.generate(swPlat, True)

Display.getDefault().asyncExec(RunGeneration())
Пример #32
0
def messageBox(s):
  parent = Display.getDefault().getActiveShell()
  child = Shell(parent, SWT.OK)
  mb = MessageBox (child, SWT.OK | SWT.ERROR)
  mb.setMessage(s)
  mb.open()
Пример #33
0
 def applyModifier(self, modifier, color):
     try:
         return modifier(color)
     except:
         colorToUse = Color(Display.getDefault(), color.getRed(), color.getGreen(), color.getBlue())
         return modifier(colorToUse)
Пример #34
0
        traceback.print_exc(file=sys.stdout)
        print 'failed to log'
    
def slog(text):
    logln(text + '\n')
    logBook(text)



class __Dispose_Listener__(DisposeListener):
    
    def __init__(self):
        pass
    
    def widgetDisposed(self, event):
        pass
    
def __dispose_all__(event):
    if __buffer_logger__:
        __buffer_logger__.close()
    if __history_logger__:
         __history_logger__.close()
    

__dispose_listener__ = __Dispose_Listener__()
__dispose_listener__.widgetDisposed = __dispose_all__


__display_run__ = __Display_Runnable__()
Display.getDefault().asyncExec(__display_run__)
	    def run(self):
			m = MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING|SWT.OK)
			m.setText(text)
			m.setMessage(message)
			m.open()
Пример #36
0
 def runInUi(callable):
     '''
     @param callable: the callable that will be run in the UI
     '''
     Display.getDefault().asyncExec(RunInUi(callable))
Пример #37
0
      heightDelta = newRect.height - self.oldRect.height
      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 *
Пример #38
0
 def map_swt_color(self, in_value, default=SWT.COLOR_BLUE):
     color_constant = self.map_color(in_value)
     if color_constant:
         return Display.getCurrent().getSystemColor(color_constant)
     else:
         return Display.getCurrent().getSystemColor(default)
try:
    input_path = input_path_parameter
except NameError:
    input_path = '/media/sf_Dropbox/Projects/JUNIPER/WP5/libdag/xml/taskset.xml'

import subprocess
try:
    output = subprocess.check_output([dag_path, input_path])
except CalledProcessError as e:
    output = e.output
    
    from org.eclipse.swt.widgets import MessageBox
    from org.eclipse.swt.widgets import Display
    from org.eclipse.swt import SWT
    
    m = MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR|SWT.OK)
    m.setText("JuniperIDE")
    m.setMessage("Error running Schedulability analyser!")
    m.open()
    
from tempfile import NamedTemporaryFile
output_file = NamedTemporaryFile(delete=False)
output_file.write(output)
output_file.close()

from org.modelio.api.modelio import Modelio
from org.modelio.api.editor import EditorType
from java.io import File
Modelio.getInstance().getEditionService().openEditor(selectedElements.get(0), File(output_file.name), EditorType.TXTEditor, True)

import os
Пример #40
0
 def runInUi(callable):
     '''
     @param callable: the callable that will be run in the UI
     '''
     Display.getDefault().asyncExec(RunInUi(callable))
Пример #41
0
    def runInUi(callAble):
        """@param callable: the callable that will be run in the UI."""

        Display.getDefault().asyncExec(RunInUi(callAble))