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)");
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)" )
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 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())
from org.eclipse.jface.dialogs import MessageDialog MessageDialog.openInformation( None, "Dialog from Python Script", "Python says hi");
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);
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);
def alert(message): MessageDialog.openInformation( window.getShell(), "Monkey Dialog", message)
def run(self): from org.python.pydev.editor.templates import TemplateHelper TemplateHelper.clearTemplateRegistryCache() MessageDialog.openInformation(editor.getSite().getShell(), "Ok", "Ok, cleared templates cache.");
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/" )
def run(self): from org.python.pydev.editor.templates import TemplateHelper #@UnresolvedImport TemplateHelper.clearTemplateRegistryCache() MessageDialog.openInformation(editor.getSite().getShell(), "Ok", "Ok, cleared templates cache.")
from org.eclipse.jface.dialogs import MessageDialog MessageDialog.openInformation(None, "Dialog from Python Script", "Python says hi")
def run(self): MessageDialog.openInformation(editor.getSite().getShell(), "Example2", "Activated!!");
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)