@Override public Image getPreview ( final int width, final int height ) { final Point p = new Point ( width, height ); final Image img = this.previews.get ( p ); if ( img == null ) { RGB rgb = getLineRenderer ().getLineColor (); if ( rgb == null ) { rgb = DEFAULT_COLOR; } final Color color = (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( rgb ) ); final Image newImage = makePreview ( Display.getDefault (), getLineRenderer ().getLineAttributes (), color, p ); this.previews.put ( p, newImage ); return newImage; } return img; }
private Color getColor(Object element, boolean forground) { IWorkbenchAdapter2 adapter = getAdapter2(element); if (adapter == null) { return null; } RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element); if (descriptor == null) { return null; } try { return resourceManager.createColor(ColorDescriptor.createFrom(descriptor)); } catch (Exception e) { Log.log(e); return null; } }
@Override public void setBackground ( final RGB color ) { if ( color != null ) { this.gc.setBackground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) ); } else { this.gc.setBackground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_BACKGROUND ) ); } }
@Override public void setForeground ( final RGB color ) { if ( color != null ) { this.gc.setForeground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) ); } else { this.gc.setForeground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_FOREGROUND ) ); } }
public ColorUpdater ( final String name, final ResourceManager manager, final ColorDescriptor defaultColor ) { this.name = name; this.manager = manager; this.defaultColor = defaultColor; JFaceResources.getColorRegistry ().addListener ( this ); refresh (); }
private Color getColor(Object element, boolean forground) { IWorkbenchAdapter2 adapter = getAdapter2(element); if (adapter == null) { return null; } RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element); if (descriptor == null) { return null; } return (Color) getResourceManager().get(ColorDescriptor.createFrom(descriptor)); }
@Override public void setForeground ( final RGB color ) { this.g.setForegroundColor ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) ); }
@Override public void setBackground ( final RGB color ) { this.g.setBackgroundColor ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) ); }
private Color getColor( RGB rgb ) { return resourceManager.createColor( ColorDescriptor.createFrom( rgb ) ); }
public void dispose() { colorManager.destroy(ColorDescriptor.createFrom(cellBackgroundColor)); }