public HydrographCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) { Assert.isNotNull(replacementString); Assert.isTrue(replacementOffset >= 0); Assert.isTrue(replacementLength >= 0); Assert.isTrue(cursorPosition >= 0); fReplacementString = replacementString; fReplacementOffset = replacementOffset; fReplacementLength = replacementLength; fCursorPosition = cursorPosition; fImage = image; fDisplayString = displayString; fContextInformation = contextInformation; fAdditionalProposalInfo = additionalProposalInfo; }
@Override public Image getImage(final Object element) { if (element instanceof WorkingSet) { return decorator.decorateImage(WORKING_SET_IMG, element); } // (temporarily) disabled because #isSourceFolder() and #isOutputFolder() obtain a lock on the workspace // (e.g. they call IResource#exists() on IFolder 'element') and this seems to cause performance issues with // locks that egit is obtaining for doing cyclic updates (see IDE-2269): // if (element instanceof IFolder) { // final IFolder folder = (IFolder) element; // if (helper.isSourceFolder(folder) || helper.isOutputFolder(folder)) { // return decorator.decorateImage(SRC_FOLDER_IMG, element); // } // } return delegate.getImage(element); }
/** * Get image by path from image registry. If not already registered a new * image will be created and registered. If not createable a fallback image * is used instead * * @param path * @param pluginId * - plugin id to identify which plugin image should be loaded * @return image */ public static Image getImage(String path, String pluginId) { ImageRegistry imageRegistry = getImageRegistry(); if (imageRegistry == null) { return null; } Image image = imageRegistry.get(path); if (image == null) { ImageDescriptor imageDesc = createImageDescriptor(path, pluginId); image = imageDesc.createImage(); if (image == null) { image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } imageRegistry.put(path, image); } return image; }
public Image getImage(Object objects) { if (objects == null || objects.equals(StructuredSelection.EMPTY)) { return null; } Object object = ((IStructuredSelection) objects).getFirstElement(); if (object instanceof TableEditPart || object instanceof TableTreeEditPart) { return Activator.getImage(Activator.IMAGE_TABLE_16); } else if (object instanceof ColumnEditPart || object instanceof ColumnTreeEditPart) { return Activator.getImage(Activator.IMAGE_COLUMN_16); } else if (object instanceof SchemaEditPart || object instanceof SchemaTreeEditPart) { return Activator.getImage(Activator.IMAGE_SCHEMA_16); } else if (object instanceof ConnectionEditPart) { return Activator.getImage(Activator.IMAGE_CONNECTION); } return null; }
private void addStats() { for (String key : statsProject.keySet()) { if (key != project.getName()) { CLabel title = new CLabel(descriptifRight, SWT.BOLD); title.setText(key); title.setImage(new Image(display, getClass() .getResourceAsStream( "images/stats_" + key.replaceAll(" ", "_") .toLowerCase() + "_16x16.png"))); title.setBackground(new Color(display, 255, 255, 255)); title.setMargins(10, 10, 0, 0); FontData[] fd = title.getFont().getFontData(); fd[0].setStyle(SWT.BOLD); title.setFont(new Font(title.getFont().getDevice(), fd)); CLabel subText = new CLabel(descriptifRight, SWT.NONE); subText.setText(statsProject.get(key) .replaceAll("<br/>", "\r\n").replaceAll(" ", " ")); subText.setBackground(new Color(display, 255, 255, 255)); subText.setMargins(30, 0, 0, 0); } } }
protected void createTopContent(String title, InputStream imageName) { Composite top = new Composite(composite, SWT.NONE); top.setLayout(new GridLayout(2, false)); top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); top.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); final Image image = new Image(top.getDisplay(), imageName); Image resized = resizeImage(image, 48, 48); Label labelImage = new Label(top, SWT.CENTER); labelImage.setImage(resized); Label label = new Label(top, SWT.NONE); label.setText(title); final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL); label.setFont(newFont); label.setBackground(rowColorSelection); createLineContent(); top.addDisposeListener(e -> { newFont.dispose(); resized.dispose(); }); }
/** * Private Constructor. */ private ImageRepository() { this.folderImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Fairytale_folder.png")); this.moonImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Nuvola_apps_kmoon.png")); this.checkImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/400px-P_yes_green.svg.png")); this.logfileImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Gartoon-Gedit-icon.png")); this.helpImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Nuvola_apps_filetypes.png")); this.infoImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Info_icon.png")); this.refreshImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/Arrow_refresh.png")); this.editImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/edit16.png")); this.pushImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/push16.png")); this.popImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/pop16.png")); this.emptyImage = new Image(Display.getDefault(), ImageRepository.class.getResourceAsStream("/images/empty16.png")); }
/** * The <code>LabelProvider</code> implementation of this * <code>ILabelProvider</code> method returns <code>null</code>. * Subclasses may override. */ @Override public Image getImage(Object ofield) { if (ofield == null) return null; FieldValue field = (FieldValue)ofield; Object element = field.get(); if (element instanceof Boolean) { if (ticked==null) ticked = Activator.getImageDescriptor("icons/ticked.png").createImage(); if (unticked==null) unticked = Activator.getImageDescriptor("icons/unticked.gif").createImage(); Boolean val = (Boolean)element; return val ? ticked : unticked; } return null; }
protected Image getIcon(String fullPath) throws IOException { if (fullPath==null) return defaultIcon; if ("".equals(fullPath)) return defaultIcon; try { if (iconMap.containsKey(fullPath)) return iconMap.get(fullPath); final String[] sa = fullPath.split("/"); final Bundle bundle = Platform.getBundle(sa[0]); if (bundle==null) return defaultIcon; if (bundle!=null) { Image image = new Image(null, bundle.getResource(sa[1]+"/"+sa[2]).openStream()); iconMap.put(fullPath, image); } return iconMap.get(fullPath); } catch (Exception ne) { logger.debug("Cannot get icon for "+fullPath, ne); return defaultIcon; } }
/** * Returns an {@link Image} stored in the file at the specified path. * * @param path * the path to the image file * @return the {@link Image} stored in the file at the specified path */ public static Image getImage(String path) { Image image = m_imageMap.get(path); if (image == null) { try { image = getImage(new FileInputStream(path)); m_imageMap.put(path, image); } catch (Exception e) { image = getMissingImage(); m_imageMap.put(path, image); } } return image; }
private ControlDecoration addDecorator(Control control, String message) { ControlDecoration txtDecorator = new ControlDecoration(control, SWT.LEFT); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration( FieldDecorationRegistry.DEC_ERROR); Image img = fieldDecoration.getImage(); txtDecorator.setImage(img); txtDecorator.setDescriptionText(message); txtDecorator.setMarginWidth(3); return txtDecorator; }
public Image getSmallImage(){ if(this.customSmallImage==null){ return this.defaultSmallImage; }else{ return this.customSmallImage; } }
protected Graphic loadGraphic( UISWTInstance swt, String name ) { Image image = swt.loadImage( "com/biglybt/ui/images/" + name ); Graphic graphic = swt.createGraphic(image ); icon_list.add(image); return( graphic ); }
/** * Checks the indirect {@link Image image} caching. */ @Test public void testIndirectImageCaching() { final ImageDescriptor desc1 = ImageRef.LIB_PATH.asImageDescriptor().orNull(); final ImageDescriptor desc2 = ImageRef.LIB_PATH.asImageDescriptor().orNull(); final Image img1 = desc1.createImage(); final Image img2 = desc2.createImage(); assertTrue("Expected different reference of images.", img1 != img2); }
@Override public Image decorateImage(Image image, Object element) { if (image!=null) { if (element instanceof IProject) { IProject project = (IProject) element; boolean b = GW4ENature.hasGW4ENature(project); if (b) { DecorationOverlayIcon icon = new DecorationOverlayIcon(image, GW_DESCRIPTOR, IDecoration.TOP_LEFT); Image ret = (Image)resourceManager.get(icon); return ret; } } } return image; }
@Override public void dispose() { for (Iterator<Image> i = imageCache.values().iterator(); i.hasNext();) { i.next().dispose(); } imageCache.clear(); }
@Override public boolean equals(Object obj) { if (super.equals(obj)) { return true; } if (obj instanceof UISWTGraphic) { Image img2 = ((UISWTGraphic) obj).getImage(); if (img2 == null) { return img == null; } return img2.equals(img); } return false; }
/** * @return the small {@link Image} that can be used as placeholder for missing image. */ private static Image getMissingImage() { Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); // GC gc = new GC(image); gc.setBackground(getColor(SWT.COLOR_RED)); gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); gc.dispose(); // return image; }
@Override public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) { final ProjectComparisonEntry entry = (ProjectComparisonEntry) element; final EObject api = entry.getElementAPI(); if (api != null) return projectCompareTreeHelper.getImage(api); } return null; }
@Override public Image getImage() { if (img == null || img.isDisposed()) { return null; } try { img.getDevice(); } catch (Throwable t) { return null; } return img; }
private void layoutColumns() { columns = getColumnsToDisplay(); tableColumns.clear(); TableColumn cols[] = table.getColumns(); int index = 0; for (F o : columns) { TableColumn column; // Check to see if column already set... if (cols.length > index) { column = cols[index]; } else { column = new TableColumn(table, SWT.LEFT); column.addSelectionListener(getColumnListener()); } String n = getColumnName(o); Image r = getColumnImage(o); column.setImage(r); column.setText(n); column.setWidth(getColumnWidth(o)); column.setData(o); tableColumns.add(column); index++; } // Make sure we didn't shrink. May not be tested. while (table.getColumns().length > columns.length) { table.getColumn(columns.length).dispose(); // last one } assert (table.getColumns().length == columns.length); // setColumWidths(); }
/** * Displays a Yes/No question to the user with the specified message and returns the user's response. * * @param message * the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ private boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return dialog.open() == 0; }
WorkingSetAdapter(final WorkingSet delegate) { this.delegate = delegate; imageDescriptorSupplier = memoize(() -> { final Image image = WorkingSetAdapter.this.delegate.getWorkingSetManager().getImage().orNull(); if (image != null) { return ImageDescriptor.createFromImage(image); } return null; }); }
/** * This Method use to create error message decorator,Its show an error image with message on applied controller field. * @param control * @param message * @return ControlDecoration */ public static ControlDecoration addDecorator(Control control,String message){ ControlDecoration txtDecorator = new ControlDecoration(control,SWT.LEFT); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); Image img = fieldDecoration.getImage(); txtDecorator.setImage(img); txtDecorator.setDescriptionText(message); return txtDecorator; }
/** * Constructor for ImageCanvas. */ public ImageCanvas(Composite parent, int style, Image image, Object layoutData) { super(parent, style | SWT.SHELL_TRIM | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE); this.image = image; setLayoutData(layoutData); setSize(image.getImageData().width, image.getImageData().height); addPaintListener(this); }
public Image getImage(Object element) { TableTreeNode node = (TableTreeNode) element; if (node.isTable) { return Activator.getImage(Activator.IMAGE_TABLE); } else { return Activator.getImage(Activator.IMAGE_DATABASE_CONNECT); } }
@Override public Image getImage(Object element) { if (((ListEntry) element).type == GraphType.AST) { return imageAST; } if (((ListEntry) element).type == GraphType.CFG) return imageCFG; return null; }
private Image getSWTImage() { Shell shell = getShell(); final Display display; if (shell == null || shell.isDisposed()) { shell = getParentShell(); } if (shell == null || shell.isDisposed()) { display = Display.getCurrent(); // The dialog should be always instantiated in UI thread. // However it was possible to instantiate it in other threads // (the code worked in most cases) so the assertion covers // only the failing scenario. See bug 107082 for details. Assert.isNotNull(display, "The dialog should be created in UI thread"); //$NON-NLS-1$ } else { display = shell.getDisplay(); } final Image[] image = new Image[1]; display.syncExec(new Runnable() { public void run() { image[0] = display.getSystemImage(SWT.ICON_QUESTION); } }); return image[0]; }
/** * Returns an {@link Image} encoded by the specified {@link InputStream}. * * @param stream * the {@link InputStream} encoding the image data * @return the {@link Image} encoded by the specified input stream */ protected static Image getImage(InputStream stream) throws IOException { try { Display display = Display.getCurrent(); ImageData data = new ImageData(stream); if (data.transparentPixel > 0) { return new Image(display, data, data.getTransparencyMask()); } return new Image(display, data); } finally { stream.close(); } }
/** * Returns an {@link Image} stored in the file at the specified path relative to the specified class. * * @param clazz * the {@link Class} relative to which to find the image * @param path * the path to the image file, if starts with <code>'/'</code> * @return the {@link Image} stored in the file at the specified path */ public static Image getImage(Class<?> clazz, String path) { String key = clazz.getName() + '|' + path; Image image = m_imageMap.get(key); if (image == null) { try { image = getImage(clazz.getResourceAsStream(path)); m_imageMap.put(key, image); } catch (Exception e) { image = getMissingImage(); m_imageMap.put(key, image); } } return image; }
public static void drawButtonUp(GC gc, String text, int textAlign, Image image, int imageAlign, Rectangle r, int leftMargin, int topMargin) { Display display = Display.getCurrent(); drawButtonUp(gc, text, textAlign, image, imageAlign, r.x, r.y, r.width, r.height, display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND), display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW), display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), display .getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW), leftMargin, topMargin); }
@Override public void cellHover(TableCell cell) { final Object ds = cell.getDataSource(); Image[] imgThumbnail = TorrentUIUtilsV3.getContentImage(ds, true, new ContentImageLoadedListener() { @Override public void contentImageLoaded(Image image, boolean wasReturned) { TorrentUIUtilsV3.releaseContentImage(ds); } }); cell.setToolTip(imgThumbnail == null ? null : imgThumbnail[0]); }
public Image decorateImage(Image image, Object element) { Image decoratedImage = image; if (element == null) { decoratedImage = null; } else if (element instanceof XmlSchemaParticle) { XmlSchemaParticle particle = (XmlSchemaParticle) element; long min = particle.getMinOccurs(); long max = particle.getMaxOccurs(); String occur = null; if (min == 0) { occur = "zero"; if (max > 0) { occur += "_" + (max == 1 ? "one" : max == Long.MAX_VALUE ? "unbounded" : "n"); } } else if (min == 1) { if (max > 1) { occur = "one_" + (max == Long.MAX_VALUE ? "unbounded" : "n"); } } else { occur = "n"; if (max > min) { occur += "_" + (max == Long.MAX_VALUE ? "unbounded" : "m"); } } if (occur != null) { decoratedImage = getOverlayImageOccur(decoratedImage, element, occur); } } else if (element instanceof XmlSchemaAttribute) { XmlSchemaAttribute attribute = (XmlSchemaAttribute) element; XmlSchemaUse use = attribute.getUse(); if (use.equals(XmlSchemaUtils.attributeUseOptional)) { decoratedImage = getOverlayImageOccur(decoratedImage, element, "zero_one"); } } return decoratedImage; }
public final Image getImage ( final Object element ) { final StyledViewerLabel label = new StyledViewerLabel ( "", null ); //$NON-NLS-1$ updateLabel ( label, element ); logger.debug ( "Get Image: {} for {}", new Object[] { label.getImage (), element } ); //$NON-NLS-1$ return label.getImage (); }
/** * Returns an {@link Image} stored in the file at the specified path. * * @param path * the path to the image file * @return the {@link Image} stored in the file at the specified path */ public static Image getImage(String path) { Image image = m_imageMap.get(path); if (image == null) { try { image = getImage(new FileInputStream(path)); m_imageMap.put(path, image); } catch (IOException e) { logger.error("Failed to get image ", e); image = getMissingImage(); m_imageMap.put(path, image); } } return image; }
/** * Change the background color of an image and draw a rectangle on it that * has the same bounds as the image. This effectively turns the image into * the color supplied with the RGB. * @param image The image to be painted. * @param rgb The desired RGB for the image. */ protected void changeImageBackgroundColor(Image image, RGB rgb) { Display display = this.shell.getDisplay(); GC gc = new GC(image); gc.setBackground(new Color(display, rgb)); gc.fillRectangle(this.fileInspConstantClassImage.getBounds()); gc.dispose(); }
private void disposeImages() { for (Image beanIcon : icons.values()) { if (beanIcon != null) beanIcon.dispose(); } icons.clear(); }
@Override public void dispose(TableCell cell) { // Named infoObj so code can be copied easily to the other PiecesItem DownloadManager infoObj = (DownloadManager) cell.getDataSource(); if (infoObj == null) return; Image img = (Image) infoObj.getUserData("PiecesImage"); if (img != null && !img.isDisposed()) img.dispose(); infoObj.setUserData("PiecesImageBuffer", null); infoObj.setUserData("PiecesImage", null); }
public static void drawButtonDown(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y, int w, int h) { Display display = Display.getCurrent(); drawButtonDown(gc, text, textAlign, image, imageAlign, x, y, w, h, display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND), display .getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), 2, 2); }