def run(self):
     
     for val in AbstractShell.shells.values():
         for val2 in val.values():
             val2.endIt()
             
     try:
         managers = [
             PydevPlugin.getPythonInterpreterManager(), 
             PydevPlugin.getJythonInterpreterManager(),
             PydevPlugin.getIronpythonInterpreterManager(),
         ]
         
         for manager in managers:
             try:
                 for info in manager.getInterpreterInfos():
                     info.modulesManager.clearCache()
                     manager.clearCaches()
             except MisconfigurationException:
                 pass #that's ok -- it's not configured
     except:
         s = StringIO.StringIO()
         traceback.print_exc(file=s)
         MessageDialog.openInformation(editor.getSite().getShell(), "Error killing the shells", s.getvalue());
     else:    
         MessageDialog.openInformation(editor.getSite().getShell(), "Ok", "Ok, killed all the running shells.\n(They will be recreated on request)");
Exemple #2
0
def showException(title):
    error = sys.exc_info()[1]
    if isinstance(error, Throwable):
        Logger.getLogger("jython").log(Level.WARNING, title, error)
        ExceptionDetailsErrorDialog.openError(None, title, wisdom(), error)
    else:
        error = str(error)
        Logger.getLogger("jython").log(Level.WARNING, "%s: %s\n%s" % (title, error, traceback.format_exc()))
        MessageDialog.openWarning(None, title, "%s\n\n\n%s" % (wisdom(), error))
 def run(self):
     error_msg = AbstractShell.restartAllShells()
     if error_msg:
         MessageDialog.openInformation(editor.getSite().getShell(),
                                       "Error killing the shells",
                                       error_msg)
     else:
         MessageDialog.openInformation(
             editor.getSite().getShell(), "Ok",
             "Ok, killed all the running shells.\n(They will be recreated on request)"
         )
Exemple #4
0
def showException(title):
    error = sys.exc_info()[1]
    if isinstance(error, Throwable):
        Logger.getLogger("jython").log(Level.WARNING, title, error)
        ExceptionDetailsErrorDialog.openError(None, title, wisdom(), error)
    else:
        error = str(error)
        Logger.getLogger("jython").log(
            Level.WARNING,
            "%s: %s\n%s" % (title, error, traceback.format_exc()))
        MessageDialog.openWarning(None, title,
                                  "%s\n\n\n%s" % (wisdom(), error))
    def isScriptApplicable(self, ps, showError=True):
        '''Raise ScriptUnapplicableError if the script is unapplicable.
        
        @param ps: The current ps as a PySelection.
        '''
        _rDef = re.compile(r'^\s+def\s')
        try:
            sCurrentLine = ps.getCursorLineContents()
            if not _rDef.match(sCurrentLine):
                msg = "The current line is not the first line of a method def statement."
                raise ScriptUnapplicableError(msg)

            oParamInfo = ps.getInsideParentesisToks(True)

            if not oParamInfo:
                msg = "The parameter list does not start on the first line of the method def statement."
                raise ScriptUnapplicableError(msg)
            lsParams = list(oParamInfo.o1)

            if not lsParams or lsParams[0] != 'self':
                msg = "The parameter list does not start with self."
                raise ScriptUnapplicableError(msg)

            # Workaround for bug in PySelection.getInsideParentesisToks()
            # in pydev < 1.0.6. In earlier versions, this can happen
            # with legal def lines such as "def moo(self, ):"
            if '' in lsParams:
                lsParams.remove('')

            if not len(lsParams) > 1:
                msg = "The method has no parameters other than self."
                raise ScriptUnapplicableError(msg)

            return True

        except ScriptUnapplicableError, e:
            if showError:
                sTitle = "Script Unapplicable"
                sHeader = "Script: Assign Method Parameters to Attributes of self"
                sBody = "The script cannot be run due to the following error:"
                sDialogText = ps.getEndLineDelim().join(
                    [sHeader, '', sBody, str(e)])
                oShell = self.editor.getSite().getShell()
                MessageDialog.openInformation(oShell, sTitle, sDialogText)
 def isScriptApplicable(self, ps, showError=True):
     '''Raise ScriptUnapplicableError if the script is unapplicable.
     
     @param ps: The current ps as a PySelection.
     '''
     _rDef = re.compile(r'^\s+def\s')
     try:
         sCurrentLine = ps.getCursorLineContents()
         if not _rDef.match(sCurrentLine):
             msg = "The current line is not the first line of a method def statement."
             raise ScriptUnapplicableError(msg)
         
         oParamInfo = ps.getInsideParentesisToks(True)
         
         if not oParamInfo:
             msg = "The parameter list does not start on the first line of the method def statement."
             raise ScriptUnapplicableError(msg)
         lsParams = list(oParamInfo.o1)
         
         if not lsParams or lsParams[0] != 'self':
             msg = "The parameter list does not start with self."
             raise ScriptUnapplicableError(msg)
         
         # Workaround for bug in PySelection.getInsideParentesisToks()
         # in pydev < 1.0.6. In earlier versions, this can happen 
         # with legal def lines such as "def moo(self, ):"
         if '' in lsParams:
             lsParams.remove('')
             
         if not len(lsParams) > 1:
             msg = "The method has no parameters other than self."
             raise ScriptUnapplicableError(msg)
         
         return True
     
     except ScriptUnapplicableError, e:
         if showError:
             sTitle = "Script Unapplicable"
             sHeader = "Script: Assign Method Parameters to Attributes of self"
             sBody = "The script cannot be run due to the following error:"
             sDialogText = ps.getEndLineDelim().join([sHeader, '', sBody, str(e)])
             oShell = self.editor.getSite().getShell()
             MessageDialog.openInformation(oShell, sTitle, sDialogText)   
def go():    
    """
    The stuff we ought to do
    """
    # Never ever commit egg-info, it breaks lots of stuff
    
    query = MessageDialog.openQuestion(window.getShell(), "Plone Development References Set-up", "This will modify your workspace preferences to be suitable for Plone development. For details please consult the user guide. Continue?") 

    if not query:
        return
    
    # Compiled .PO files
    # Plone will compile these on start up
    add_ignore_mask("*.mo")
    
    # Never commit EGGs. Many broken tools (paster!) 
    # populate / download eggs to source folder
    # also note that capitalization may vary  
    add_ignore_mask("*.egg-info")
    add_ignore_mask("*.egg")
    add_ignore_mask("*.EGG")
    add_ignore_mask("*.EGG-INFO")
    
    # Eclipse settings files
    add_ignore_mask(".project")
    add_ignore_mask(".pydevproject")
    
    # Following are buildout or setuptools generated folders
    add_ignore_mask("bin")
    add_ignore_mask("build")
    add_ignore_mask("develop-eggs")
    add_ignore_mask("downloads")
    add_ignore_mask("eggs")
    add_ignore_mask("fake-eggs")
    add_ignore_mask("parts")
    add_ignore_mask("dist")


    # Not entirely sure what this folder is, but this hidden
    # folder appears in Eclipse project root on OSX
    add_ignore_mask(".settings")
    
    # Following files are in nested buildouts
    add_ignore_mask(".installed.cfg")
    add_ignore_mask(".mr.developer.cfg")
    
    # Nested version control checkouts in the source tree
    add_ignore_mask(".hg")
    add_ignore_mask(".git")
    add_ignore_mask(".bzr")
    
    use_utf8()
    dont_fuck_up_tabs()
    associate_zope_file_types()
    require_restart()
def require_restart():
    """ Need to restart because preference changes are not reflected otherwise.
    
    TODO: There must be a smarter way...
    """
    
    query = MessageDialog.openQuestion(window.getShell(), "Eclipse restart required", "Eclipse restart is required to make changes effective. Restart now?") 

    if query:
        workbench = window.getWorkbench()
        workbench.restart();
        def run(self):
                    
            try:
                text_widget = editor.getPySourceViewer().getTextWidget()
                if text_widget:
                    setting = text_widget.getWordWrap() == False
        
                    text_widget.setWordWrap(setting);
                    
                    statusLine = editor.getAdapter(IEditorStatusLine)
                    if setting:
                        msg = "Word wrap is on"
                    else:
                        msg = "Word wrap is off"
                        
                    statusLine.setMessage(False, msg, None)


            except:
                s = StringIO.StringIO()
                traceback.print_exc(file=s)
                MessageDialog.openInformation(editor.getSite().getShell(), "Error setting the editor wrap", s.getvalue());
        def run(self):

            try:
                text_widget = editor.getPySourceViewer().getTextWidget()
                if text_widget:
                    setting = text_widget.getWordWrap() == False

                    text_widget.setWordWrap(setting)

                    statusLine = editor.getAdapter(IEditorStatusLine)
                    if setting:
                        msg = "Word wrap is on"
                    else:
                        msg = "Word wrap is off"

                    statusLine.setMessage(False, msg, None)

            except:
                s = StringIO.StringIO()
                traceback.print_exc(file=s)
                MessageDialog.openInformation(editor.getSite().getShell(),
                                              "Error setting the editor wrap",
                                              s.getvalue())
def check_we_are_src():
    """ Check whether workspace is set up according to instructions
    
    @return: False if this is not going to work
    """
    workspace = ResourcesPlugin.getWorkspace()    
    root = workspace.getRoot()
    location = root.getRawLocation()
    path = location.toOSString()
    
    if path.endswith("src") or path.endswith("products"): # products is a special case made for my Danish friend
    

        return True
    
    else:        
        query = MessageDialog.openQuestion(window.getShell(), 
                                           "Workspace is not correctly set up", 
                                           "Workspace folder should be src/ folder of buildout.  The current workspace folder '" + path + "' does not look like one. Scan checked out projects from this folder?") 
        return query
def check_omelette():
    """
    @return: True if omelette is available and user would like to import it
    """

    # workspace is org.eclipse.core.internal.resources.Workspace
    # http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html
    workspace = ResourcesPlugin.getWorkspace()    
    root = workspace.getRoot()
    
    # location will be IPath object, we need string presentation of the path
    # 
    location = root.getRawLocation()
    path = location.toOSString()
    omelette_path = os.path.join(path, "..", "parts", "omelette")
    omelette_path = os.path.normpath(omelette_path)

    if os.path.exists(omelette_path):                
        query = MessageDialog.openQuestion(window.getShell(), "Omelette detected", "Omelette buildout part contains all Python files used by Plone in symlinked structure. Importing omelette folder to workspace makes Python name completion to work. However, it is a very heavy task - loooong 'Building workspace' operation must be done when the workspace is refreshed. Unless you have a very powerful computer your computer will probably melt down to smoldering ashes. Alternatively toggle on 'Analyze open editors only' setting in PyDev preferences. Import omelette?") 
        return query
    else:
        return False
 def run(self):
     from org.python.pydev.editor.templates import TemplateHelper
     TemplateHelper.clearTemplateRegistryCache()
     MessageDialog.openInformation(editor.getSite().getShell(), "Ok", "Ok, cleared templates cache.");
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from org.eclipse.jface.dialogs import MessageDialog

ConsoleUtil.writeInfo("firstTime")
MessageDialog.openWarning(None, "Warning", "firstTime ???")

#Fill PV Name only once
if widget.getVar("firstTime") == None:
    widget.setVar("firstTime", True)
    i=0
    for pv in pvs:
        ConsoleUtil.writeInfo("pv name = " + pv.getName())
        table.setCellText(i, 0, pv.getName())
        if not pv.isConnected():
            table.setCellText(i, 1, "Disconnected")
        i+=1

#find index of the trigger PV
i=0
while triggerPV != pvs[i]:
    i+=1

table.setCellText(i, 1, PVUtil.getString(triggerPV))
table.setCellText(i, 2, PVUtil.getTimeString(triggerPV))
table.setCellText(i, 3, PVUtil.getStatus(triggerPV))
table.setCellText(i, 4, PVUtil.getSeverityString(triggerPV))

s = PVUtil.getSeverity(triggerPV)
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from org.csstudio.opibuilder.scriptUtil import PVUtil
import WidgetUtil
from org.eclipse.jface.dialogs import MessageDialog

value = PVUtil.getString(pvs[0])

if value == "":
    MessageDialog.openWarning(None, "Warning", "Field is empty!")
    flag = 0
else:
    flag = 1

if flag == 1:
    StringToSend = value

    PVUtil.writePV("LLRF_USER:CavitySimulator:StringToSendIDN", StringToSend)
 def run(self):
     MessageDialog.openInformation(editor.getSite().getShell(), "Example2", "Activated!!");
Exemple #17
0
from org.eclipse.jface.dialogs import MessageDialog
from org.eclipse.jface.window import Window
from SWTLoginDialog import *    
        
    
dialog = LoginDialog(Display.getCurrent().getActiveShell())
a = dialog.open() 
if a == Window.OK:
    info = dialog.getLoginInfo()
    if info[0] == "admin" and info[1]=="123456":
        display.getWidget("SWTLogin").setVisible(True)
    else:
        MessageDialog.openError(None, "Error", "The user name or password you input is wrong!")
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.eclipse.jface.dialogs import MessageDialog
from java.lang import Math



if Math.random() > 0.5:
	color = ColorFontUtil.getColorFromRGB(0,160,0)
	colorName = "green"

else:
	color = ColorFontUtil.RED
	colorName = "red"

import WidgetUtil
WidgetUtil.setBackColor(display, "myIndicator", color)
WidgetUtil.setMyForeColor(widget, color)

MessageDialog.openInformation(
			None, "Dialog from Python Script", "Python says: my color is " + colorName);

from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.eclipse.jface.dialogs import MessageDialog
from java.lang import Math

if Math.random() > 0.5:
    color = ColorFontUtil.getColorFromRGB(0, 160, 0)
    colorName = "green"

else:
    color = ColorFontUtil.RED
    colorName = "red"

import WidgetUtil
WidgetUtil.setBackColor(display, "myIndicator", color)
WidgetUtil.setMyForeColor(widget, color)

MessageDialog.openInformation(None, "Dialog from Python Script",
                              "Python says: my color is " + colorName)
from org.eclipse.jface.dialogs import MessageDialog


MessageDialog.openInformation(
			None, "Dialog from Python Script", "Python says hi");

Exemple #21
0
def alert(message):
    MessageDialog.openInformation(     
            window.getShell(),     
            "Monkey Dialog", 
            message)
Exemple #22
0
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from org.csstudio.opibuilder.scriptUtil import PVUtil
import WidgetUtil
from org.eclipse.jface.dialogs import MessageDialog

meas = PVUtil.getString(pvs[0])
temp = PVUtil.getString(pvs[1])
value = PVUtil.getString(pvs[2])


if meas=="" or temp =="" or value == "":
	MessageDialog.openWarning(None, "Warning", "At least one field is empty!")    
	flag = 0
else:
	flag = 1
	
if flag ==1:
	StringToSend = meas+":"+temp+":"+value
	PVUtil.writePV("LLRF_USER:CavitySimulator:StringToSendTemp", StringToSend)
from org.eclipse.jface.dialogs import MessageDialog

MessageDialog.openInformation(None, "Dialog from Python Script",
                              "Python says hi")
Exemple #24
0
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from org.eclipse.jface.dialogs import MessageDialog

ConsoleUtil.writeInfo("firstTime")
MessageDialog.openWarning(None, "Warning", "firstTime ???")

#Fill PV Name only once
if widget.getVar("firstTime") == None:
    widget.setVar("firstTime", True)
    i = 0
    for pv in pvs:
        ConsoleUtil.writeInfo("pv name = " + pv.getName())
        table.setCellText(i, 0, pv.getName())
        if not pv.isConnected():
            table.setCellText(i, 1, "Disconnected")
        i += 1

#find index of the trigger PV
i = 0
while triggerPV != pvs[i]:
    i += 1

table.setCellText(i, 1, PVUtil.getString(triggerPV))
table.setCellText(i, 2, PVUtil.getTimeString(triggerPV))
table.setCellText(i, 3, PVUtil.getStatus(triggerPV))
table.setCellText(i, 4, PVUtil.getSeverityString(triggerPV))

s = PVUtil.getSeverity(triggerPV)
Exemple #25
0
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.eclipse.jface.dialogs import MessageDialog

#filePath = display.getWidget("Text Input").getValue()

#MessageDialog.openInformation(
#            None, "Dialog from Hdf5 Script", "HDF5File says: The File is " + filePath);
##############################################################3





fileName = display.getWidget("Text Input").getValue()


PVUtil.writePV("vs://CODES/test/input",fileName)
PVUtil.writePV("vs://CODES/test/inputtrg",1)








MessageDialog.openInformation(
            None, "Dialog from Hdf5 Script", "HDF5File says: The File is " + fileName);
 def run(self):
     from org.python.pydev.editor.templates import TemplateHelper  #@UnresolvedImport
     TemplateHelper.clearTemplateRegistryCache()
     MessageDialog.openInformation(editor.getSite().getShell(), "Ok",
                                   "Ok, cleared templates cache.")
Exemple #27
0
#Name of the flag to show if dialog has been popped up.
flagName = "popped"

labelName = "myLabel"

if widget.getExternalObject(flagName) == None:
    widget.setExternalObject(flagName, 0)
    #Example to write text to BOY Console
    ConsoleUtil.writeInfo("Welcome to Best OPI, Yet (BOY)!")

b = widget.getExternalObject(flagName)

if PVUtil.getDouble(pvs[0]) > PVUtil.getDouble(pvs[1]):
    s = "Temperature is too high!"
    WidgetUtil.setText(display, labelName, s)
    WidgetUtil.setForeColor(display, labelName, RED)
    #If dialog has not been popped up, pop up the dialog
    if b == 0:
        #set popped flag to true
        widget.setExternalObject(flagName, 1)
        MessageDialog.openWarning(None, "Warning",
                                  "The temperature you set is too high!")
else:
    s = "Temperature is normal"
    WidgetUtil.setText(display, "myLabel", s)
    WidgetUtil.setForeColor(display, labelName, GREEN)
    #reset popped flag to false
    if b != 0:
        widget.setExternalObject(flagName, 0)
    add_ignore_mask("dist")


    # Not entirely sure what this folder is, but this hidden
    # folder appears in Eclipse project root on OSX
    add_ignore_mask(".settings")
    
    # Following files are in nested buildouts
    add_ignore_mask(".installed.cfg")
    add_ignore_mask(".mr.developer.cfg")
    
    # Nested version control checkouts in the source tree
    add_ignore_mask(".hg")
    add_ignore_mask(".git")
    add_ignore_mask(".bzr")
    
    use_utf8()
    dont_fuck_up_tabs()
    associate_zope_file_types()
    require_restart()

try: 
    # Sanity check
    import com.aptana
    go()
except ImportError:
    MessageDialog.openInformation(window.getShell(), "Aptana Studio required", "This script works only with Aptana Studio based installation - http://www.aptana.org/" )    
    
    
    
Exemple #29
0
from org.csstudio.opibuilder.scriptUtil import PVUtil
from java.lang import System
from org.eclipse.jface.dialogs import MessageDialog

ok = PVUtil.getDouble(pvs[0])
if ok == 1:
    userName = System.getProperty("UserName")
    password = System.getProperty("Password")
    if userName == "admin" and password == "123456":
        widget.setPropertyValue("visible", True)
    else:
        MessageDialog.openError(None, "Error",
                                "The user name or password is wrong!")
        pvs[0].setValue(0)
Exemple #30
0
#Name of the flag to show if dialog has been popped up.
flagName = "popped"

labelName = "myLabel"

if widget.getExternalObject(flagName) == None:
    widget.setExternalObject(flagName, 0)    
    #Example to write text to BOY Console    
    ConsoleUtil.writeInfo("Welcome to Best OPI, Yet (BOY)!")

b = widget.getExternalObject(flagName);

if PVUtil.getDouble(pvs[0]) > PVUtil.getDouble(pvs[1]):  
        s = "Temperature is too high!"
        WidgetUtil.setText(display, labelName, s)
        WidgetUtil.setForeColor(display, labelName, RED)
        #If dialog has not been popped up, pop up the dialog
        if b == 0:
            #set popped flag to true
            widget.setExternalObject(flagName, 1)                   
            MessageDialog.openWarning(
                None, "Warning", "The temperature you set is too high!")        
else:
    s = "Temperature is normal"
    WidgetUtil.setText(display, "myLabel", s)
    WidgetUtil.setForeColor(display, labelName, GREEN)
    #reset popped flag to false
    if b != 0:
        widget.setExternalObject(flagName, 0)