コード例 #1
0
ファイル: describer.py プロジェクト: gbtami/storytext
    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)
コード例 #6
0
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
ファイル: misc.py プロジェクト: escribis/.modelio
 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
ファイル: Initialise.py プロジェクト: Gumtree/Pelican_scripts
 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__
コード例 #11
0
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]
コード例 #13
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()
コード例 #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()
コード例 #15
0
    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
ファイル: AdvancedSearch.py プロジェクト: escribis/macros
 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()
コード例 #17
0
 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)
コード例 #18
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)
コード例 #19
0
  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
ファイル: misc.py プロジェクト: escribis/.modelio
 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()
コード例 #22
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__)

load_script('KKB-Plot and Reduction.py')
コード例 #23
0
          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
ファイル: syncExec.py プロジェクト: 130s/openhrp3-1
def Exec(r):
    display = Display.getDefault()
    display.syncExec(r)
    return None
コード例 #25
0
ファイル: addROI.py プロジェクト: Crisam/cs-studio
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
ファイル: syncExec.py プロジェクト: kaihumuc/openhrp
def exec(r):
	display = Display.getDefault()	
	display.syncExec(r)
	return None
コード例 #28
0
                             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
ファイル: misc.py プロジェクト: escribis/.modelio
  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 ()
コード例 #31
0
		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
ファイル: AdvancedSearch.py プロジェクト: escribis/macros
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
ファイル: describer.py プロジェクト: gbtami/storytext
 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__)
コード例 #35
0
	    def run(self):
			m = MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING|SWT.OK)
			m.setText(text)
			m.setMessage(message)
			m.open()
コード例 #36
0
ファイル: pyedit_pythontidy.py プロジェクト: pfluegdk/SGpp
 def runInUi(callable):
     '''
     @param callable: the callable that will be run in the UI
     '''
     Display.getDefault().asyncExec(RunInUi(callable))
コード例 #37
0
ファイル: cars_app.py プロジェクト: krismz/Delv
      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)
コード例 #39
0
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))