Java Code Examples for org.eclipse.swt.graphics.Image#isDisposed()
The following examples show how to use
org.eclipse.swt.graphics.Image#isDisposed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Pics.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public static Image getImage(final String imageName, final AbstractUIPlugin plugin) { if (plugin == null) { return null; } final ImageRegistry reg = plugin.getImageRegistry(); Image result = reg.get(imageName); if (result != null && !result.isDisposed()) {//prevent from bad dispose return result; } final ImageDescriptor descriptor = getImageDescriptor(imageName, plugin); if (descriptor != null) { result = descriptor.createImage(); } reg.remove(imageName); if (result != null) { reg.put(imageName, result); } return result; }
Example 2
Source File: BusinessObjectPlugin.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public static Image getImage(final String imageName) { final ImageRegistry reg = getDefault().getImageRegistry(); Image result = reg.get(imageName); if (result != null && !result.isDisposed()) {//prevent from bad dispose return result; } final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName)); if (descriptor != null) { result = descriptor.createImage(); } reg.remove(imageName); if (result != null) { reg.put(imageName, result); } return result; }
Example 3
Source File: PeerFilesView.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
@Override public void dispose(TableCell cell) { // only dispose of image here, this method is reused in other methods Graphic graphic = cell.getGraphic(); if (graphic instanceof UISWTGraphic) { final Image img = ((UISWTGraphic) graphic).getImage(); if (img != null && !img.isDisposed()){ Utils.execSWTThread(() -> Utils.disposeSWTObjects(img)); // see http://forum.vuze.com/thread.jspa?threadID=117243 // could it be that it isn't being marked as disposed after disposal and // being double-disposed? ((UISWTGraphic) graphic).setImage( null ); } } }
Example 4
Source File: SWTGraphicUtil.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Returns a new scaled image. * * @param source the image to be scaled * @param newWidth new width of the image * @param newHeight new height of the image * @return a scaled image of the source */ public static Image resize(final Image source, final int newWidth, final int newHeight) { if (source == null) { return null; } if (source.isDisposed()) { SWT.error(SWT.ERROR_WIDGET_DISPOSED); } final Image scaledImage = new Image(source.getDevice(), newWidth, newHeight); final GC gc = new GC(scaledImage); gc.setAntialias(SWT.ON); gc.setInterpolation(SWT.HIGH); gc.drawImage(source, 0, 0, source.getBounds().width, source.getBounds().height, 0, 0, newWidth, newHeight); gc.dispose(); return scaledImage; }
Example 5
Source File: XLIFFEditor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 启动编辑器。 * * @param site * the site * @param input * the input * @throws PartInitException * the part init exception * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, * org.eclipse.ui.IEditorInput) */ public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("init(IEditorSite site, IEditorInput input)"); } setSite(site); setInput(input); // 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性 setPartName(input.getName()); Image oldTitleImage = titleImage; if (input != null) { IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null; titleImage = imageDesc != null ? imageDesc.createImage() : null; } setTitleImage(titleImage); if (oldTitleImage != null && !oldTitleImage.isDisposed()) { oldTitleImage.dispose(); } getSite().setSelectionProvider(this); }
Example 6
Source File: ImportProjectWizardPage2.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 销毁图片资源 */ private void disposeImg() { if(null != projectImg && !projectImg.isDisposed()){ projectImg.dispose(); } if(null != folderImg&& !folderImg.isDisposed()){ folderImg.dispose(); } if(null !=hsXLiffImg && !hsXLiffImg.isDisposed() ){ hsXLiffImg.dispose(); } if(null !=htmlImg && !htmlImg.isDisposed()){ htmlImg.dispose(); } if(null !=defaultImg && !defaultImg.isDisposed()){ defaultImg.dispose(); } for (Entry<String, Image> entry : imgMap.entrySet()) { Image value = entry.getValue(); if(null != value && !value.isDisposed()){ value.dispose(); } } imgMap.clear(); }
Example 7
Source File: TerminologyViewPart.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void setProcessMessage(Image image, String message, String tooltip) { if (image != null && !image.isDisposed()) { tipLabel.setImage(image); } else { tipLabel.setImage(null); } tipLabel.setText(message); tipLabel.setToolTipText(tooltip); tipLabel.pack(); }
Example 8
Source File: XLFEditor.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("init(IEditorSite site, IEditorInput input)"); } setSite(site); setInput(input); // 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性 setPartName(input.getName()); Image oldTitleImage = titleImage; if (input != null) { IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null; titleImage = imageDesc != null ? imageDesc.createImage() : null; } setTitleImage(titleImage); if (oldTitleImage != null && !oldTitleImage.isDisposed()) { oldTitleImage.dispose(); } getSite().setSelectionProvider(this); cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM); cursorArrow = new Cursor(null, SWT.CURSOR_ARROW); hookListener(); }
Example 9
Source File: ModifyLangCodeDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean close() { for (String code : imageCache.keySet()) { Image im = imageCache.get(code); if (im != null && !im.isDisposed()) { im.dispose(); } } imageCache.clear(); return super.close(); }
Example 10
Source File: NameItem.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
private void disposeCellIcon(TableCell cell) { if (!(cell instanceof TableCellSWT)) { return; } final Image img = ((TableCellSWT) cell).getIcon(); if (img != null) { ((TableCellSWT) cell).setIcon(null); if (!img.isDisposed()) { img.dispose(); } } }
Example 11
Source File: ImageManager.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private static Image get(String filename, String overlay) { if (filename == null || overlay == null) return null; String id = filename + "-" + overlay; Image withOverlay = registry.get(id); if (withOverlay != null && !withOverlay.isDisposed()) return withOverlay; DecorationOverlayIcon withIcon = new DecorationOverlayIcon( get(filename), descriptor(overlay), IDecoration.BOTTOM_RIGHT); withOverlay = withIcon.createImage(); registry.put(id, withOverlay); return withOverlay; }
Example 12
Source File: RotatedTextImageUI.java From birt with Eclipse Public License 1.0 | 5 votes |
public void disposeImage( ExtendedItemHandle handle, Image image ) { if ( image != null && !image.isDisposed( ) ) { image.dispose( ); } }
Example 13
Source File: LanguageCodesPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * @see org.eclipse.jface.dialogs.DialogPage#dispose() */ public void dispose() { for (String code : imageCache.keySet()) { Image im = imageCache.get(code); if (im != null && !im.isDisposed()) { im.dispose(); } } if (isBidiImage != null && !isBidiImage.isDisposed()) { isBidiImage.dispose(); } imageCache.clear(); super.dispose(); }
Example 14
Source File: ColumnSubResultNew.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void cellPaint(GC gc, TableCellSWT cell) { SubscriptionResultFilterable entry = (SubscriptionResultFilterable) cell.getDataSource(); Rectangle cellBounds = cell.getBounds(); Image img = entry== null || entry.getRead() ? imgOld: imgNew; if (img != null && !img.isDisposed()) { Rectangle imgBounds = img.getBounds(); gc.drawImage(img, cellBounds.x + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y + ((cellBounds.height - imgBounds.height) / 2)); } }
Example 15
Source File: ImageCache.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private Image getFromImageHash(Object key) { synchronized (lock) { Image ret = imageHash.get(key); if (ret != null && ret.isDisposed()) { imageHash.remove(key); ret = null; } return ret; } }
Example 16
Source File: ColumnActivityNew.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void cellPaint(GC gc, TableCellSWT cell) { ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource(); Rectangle cellBounds = cell.getBounds(); Image img = entry.getReadOn() <= 0 ? imgNew : imgOld; if (img != null && !img.isDisposed()) { Rectangle imgBounds = img.getBounds(); gc.drawImage(img, cellBounds.x + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y + ((cellBounds.height - imgBounds.height) / 2)); } }
Example 17
Source File: SWTUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Convenience method for disposing of an image * * @param image */ public static void disposeImage(Image image) { if (image != null && !image.isDisposed()) { image.dispose(); } }
Example 18
Source File: GuiResource.java From hop with Apache License 2.0 | 4 votes |
private void disposeImage( Image image ) { if ( image != null && !image.isDisposed() ) { image.dispose(); } }
Example 19
Source File: PGroup.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Sets the image. * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the image is disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setImage(Image image) { checkWidget(); if (image != null && image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); this.image = image; strategy.update(); }
Example 20
Source File: GridItem.java From tmxeditor8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the receiver's image at a column. * * @param index * the column index * @param image * the new image * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> * </ul> * @throws org.eclipse.swt.SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * </li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setImage(int index, Image image) { checkWidget(); if (image != null && image.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } images.set(index, image); parent.imageSetOnItem(index, this); parent.redraw(); }