Java Code Examples for org.eclipse.swt.graphics.Color#isDisposed()
The following examples show how to use
org.eclipse.swt.graphics.Color#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: ColorsPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override public void dispose() { for (Image img : imageList) { if (img != null && !img.isDisposed()) { img.dispose(); } } imageList.clear(); for (Color c : colorList) { if (c != null && !c.isDisposed()) { c.dispose(); } } colorList.clear(); super.dispose(); }
Example 2
Source File: EditorConfigColorManager.java From editorconfig-eclipse with Apache License 2.0 | 5 votes |
public void dispose(Display display) { Map<RGB, Color> colorTable = fDisplayTable.get(display); if (colorTable != null) { Iterator<Color> e = colorTable.values().iterator(); while (e.hasNext()) { Color color = e.next(); if (color != null && !color.isDisposed()) color.dispose(); } } }
Example 3
Source File: NGC.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void setForeground(IColor color) { if (color == null) { return; } if (color.getColor() instanceof Color) { Color c = (Color) color.getColor(); if (!c.isDisposed()) { fContext.setForeground(c); fForeground = color; } } }
Example 4
Source File: DefaultGalleryItemRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void freeDropShadowsColors() { // Free colors : { Iterator<Color> i = this.dropShadowsColors.iterator(); while (i.hasNext()) { Color c = i.next(); if (c != null && !c.isDisposed()) c.dispose(); } } }
Example 5
Source File: ListItemRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void freeDropShadowsColors() { // Free colors : { Iterator<Color> i = this.dropShadowsColors.iterator(); while (i.hasNext()) { Color c = i.next(); if (c != null && !c.isDisposed()) c.dispose(); } } }
Example 6
Source File: BadgedLabel.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void checkColor(Color color) { if (color == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } if (color.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } }
Example 7
Source File: JavaSourceViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void configure(SourceViewerConfiguration configuration) { /* * Prevent access to colors disposed in unconfigure(), see: * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53641 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86177 */ StyledText textWidget= getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { Color foregroundColor= textWidget.getForeground(); if (foregroundColor != null && foregroundColor.isDisposed()) textWidget.setForeground(null); Color backgroundColor= textWidget.getBackground(); if (backgroundColor != null && backgroundColor.isDisposed()) textWidget.setBackground(null); } super.configure(configuration); if (configuration instanceof JavaSourceViewerConfiguration) { JavaSourceViewerConfiguration javaSVCconfiguration= (JavaSourceViewerConfiguration)configuration; fOutlinePresenter= javaSVCconfiguration.getOutlinePresenter(this, false); if (fOutlinePresenter != null) fOutlinePresenter.install(this); fStructurePresenter= javaSVCconfiguration.getOutlinePresenter(this, true); if (fStructurePresenter != null) fStructurePresenter.install(this); fHierarchyPresenter= javaSVCconfiguration.getHierarchyPresenter(this, true); if (fHierarchyPresenter != null) fHierarchyPresenter.install(this); } if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(this); initializeViewerColors(); } fIsConfigured= true; }
Example 8
Source File: PropsUI.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GUIResource gui = GUIResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( new PaintListener() { @Override public void paintControl( PaintEvent paintEvent ) { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } } ); } font = null; // GUIResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GUIResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GUIResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GUIResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 9
Source File: ColorPaletteTest.java From swt-bling with MIT License | 4 votes |
private void disposeColor(Color color) { if (color != null && !color.isDisposed()) { color.dispose(); } }
Example 10
Source File: PropsUi.java From hop with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GuiResource gui = GuiResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( paintEvent -> { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } ); } font = null; // GuiResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GuiResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GuiResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GuiResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 11
Source File: ColorCache.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
public static Color getSchemedColor(Device device, int red, int green, int blue) { ensureMapColorsInitialized(device); Long key = new Long(((long) red << 16) + (green << 8) + blue + 0x1000000l); Color color = mapColors.get(key); if (color == null || color.isDisposed()) { try { if (red < 0) { red = 0; } else if (red > 255) { red = 255; } if (green < 0) { green = 0; } else if (green > 255) { green = 255; } if (blue < 0) { blue = 0; } else if (blue > 255) { blue = 255; } RGB rgb = new RGB(red, green, blue); float[] hsb = rgb.getHSB(); hsb[0] += Colors.diffHue; if (hsb[0] > 360) { hsb[0] -= 360; } else if (hsb[0] < 0) { hsb[0] += 360; } hsb[1] *= Colors.diffSatPct; //hsb[2] *= Colors.diffLumPct; color = getColor(device, hsb); mapColors.put(key, color); } catch (IllegalArgumentException e) { Debug.out("One Invalid: " + red + ";" + green + ";" + blue, e); } } return color; }
Example 12
Source File: GridItem.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Sets the foreground color at the given column index in the receiver to * the color specified by the argument, or to the default system color for * the item if the argument is null. * * @param index * the column index * @param foreground * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument 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 setForeground(int index, Color foreground) { checkWidget(); if (foreground != null && foreground.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } parent.getDataVisualizer().setForeground(this, index, foreground); parent.redraw(); }
Example 13
Source File: GridItem.java From tmxeditor8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the receiver's foreground color to the color specified by the * argument, or to the default system color for the item if the argument is * null. * * @param foreground * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been * disposed</li> * </ul> * @throws 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 setForeground(Color foreground) { checkWidget(); if (foreground != null && foreground.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } defaultForeground = foreground; parent.redraw(); }
Example 14
Source File: GridItem.java From translationstudio8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the receiver's background color to the color specified by the * argument, or to the default system color for the item if the argument is * null. * * @param background * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been * disposed</li> * </ul> * @throws 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 setBackground(Color background) { checkWidget(); if (background != null && background.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } defaultBackground = background; parent.redraw(); }
Example 15
Source File: GridItem.java From tmxeditor8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the background color at the given column index in the receiver to * the color specified by the argument, or to the default system color for * the item if the argument is null. * * @param index * the column index * @param background * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument 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 setBackground(int index, Color background) { checkWidget(); if (background != null && background.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } backgrounds.set(index, background); parent.redraw(); }
Example 16
Source File: GridItem.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Sets the background color at the given column index in the receiver to * the color specified by the argument, or to the default system color for * the item if the argument is null. * * @param index * the column index * @param background * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument 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 setBackground(int index, Color background) { checkWidget(); if (background != null && background.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } parent.getDataVisualizer().setBackground(this, index, background); parent.redraw(); }
Example 17
Source File: GalleryItem.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Sets the receiver's background color to the color specified by the * argument, or to the default system color for the item if the argument is * null. * * @param color * The new color (or null) * * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been * 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 setBackground(Color background) { checkWidget(); if (background != null && background.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } this.background = background; this.parent.redraw(this); }
Example 18
Source File: GalleryItem.java From nebula with Eclipse Public License 2.0 | 3 votes |
/** * Sets the receiver's foreground color to the color specified by the * argument, or to the default system color for the item if the argument is * null. * * @param color * The new color (or null) * * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been * 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 setForeground(Color foreground) { checkWidget(); if (foreground != null && foreground.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } this.foreground = foreground; this.parent.redraw(this); }
Example 19
Source File: GridItem.java From translationstudio8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the foreground color at the given column index in the receiver to * the color specified by the argument, or to the default system color for * the item if the argument is null. * * @param index * the column index * @param foreground * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument 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 setForeground(int index, Color foreground) { checkWidget(); if (foreground != null && foreground.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } foregrounds.set(index, foreground); parent.redraw(); }
Example 20
Source File: GridItem.java From tmxeditor8 with GNU General Public License v2.0 | 3 votes |
/** * Sets the receiver's background color to the color specified by the * argument, or to the default system color for the item if the argument is * null. * * @param background * the new color (or null) * @throws IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been * disposed</li> * </ul> * @throws 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 setBackground(Color background) { checkWidget(); if (background != null && background.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } defaultBackground = background; parent.redraw(); }