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)
Ejemplo n.º 2
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
Ejemplo n.º 3
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())
Ejemplo n.º 5
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()
Ejemplo n.º 6
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__
Ejemplo n.º 7
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 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()
Ejemplo n.º 9
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)
Ejemplo n.º 11
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 ()
Ejemplo n.º 15
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()
Ejemplo n.º 16
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__)
Ejemplo n.º 17
0
 def applyModifier(self, modifier, color):
     try:
         return modifier(color)
     except:
         colorToUse = Color(Display.getDefault(), color.getRed(), color.getGreen(), color.getBlue())
         return modifier(colorToUse)
        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))
Ejemplo n.º 20
0
def Exec(r):
    display = Display.getDefault()
    display.syncExec(r)
    return None
Ejemplo n.º 21
0
    def runInUi(callAble):
        """@param callable: the callable that will be run in the UI."""

        Display.getDefault().asyncExec(RunInUi(callAble))
	    def run(self):
			m = MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING|SWT.OK)
			m.setText(text)
			m.setMessage(message)
			m.open()
Ejemplo n.º 23
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 ()
Ejemplo n.º 24
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()
Ejemplo n.º 25
0
 def runInUi(callable):
     '''
     @param callable: the callable that will be run in the UI
     '''
     Display.getDefault().asyncExec(RunInUi(callable))
Ejemplo n.º 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()
Ejemplo n.º 27
0
def exec(r):
	display = Display.getDefault()	
	display.syncExec(r)
	return None
		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())
Ejemplo n.º 29
0
 def runInUi(callable):
     '''
     @param callable: the callable that will be run in the UI
     '''
     Display.getDefault().asyncExec(RunInUi(callable))
Ejemplo n.º 30
0
    def runInUi(callAble):
        """@param callable: the callable that will be run in the UI."""

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