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 _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)
def getImageFromName(self,name): if name not in self.imageMap: try: image = Image(Display.getCurrent(),os.path.join(self.resourcePath,name+self.extension)) except: image = None self.imageMap[name] = image return self.imageMap[name]
def 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
def getImageFromName(self, name): if name not in self.imageMap: try: image = Image( Display.getCurrent(), os.path.join(self.resourcePath, name + self.extension)) except: image = None self.imageMap[name] = image return self.imageMap[name]
def 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()
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)
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())
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())
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