Java Code Examples for org.eclipse.swt.graphics.Font#isDisposed()

The following examples show how to use org.eclipse.swt.graphics.Font#isDisposed() . These examples are extracted from open source projects. 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
private void setFont(String fontId, FontData[] data)
{
	String fdString = PreferenceConverter.getStoredRepresentation(data);
	// Only set new values if they're different from existing!
	Font existing = JFaceResources.getFont(fontId);
	String existingString = ""; //$NON-NLS-1$
	if (!existing.isDisposed())
	{
		existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
	}
	if (!existingString.equals(fdString))
	{
		// put in registry...
		JFaceResources.getFontRegistry().put(fontId, data);
		// Save to prefs...
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
		String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
		IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
		store.setValue(key, fdString);
	}
}
 
Example 2
private void setFont(String fontId, FontData[] data) {
	String fdString = PreferenceConverter.getStoredRepresentation(data);

	Font existing = JFaceResources.getFont(fontId);
	String existingString = "";
	if (!(existing.isDisposed())) {
		existingString = PreferenceConverter
				.getStoredRepresentation(existing.getFontData());
	}
	if (existingString.equals(fdString)) {
		return;
	}
	JFaceResources.getFontRegistry().put(fontId, data);

	ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	String key = ThemeElementHelper.createPreferenceKey(currentTheme,fontId);
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(key, fdString);
}
 
Example 3
Source Project: nebula   File: GalleryItem.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void setFont(Font font) {
	checkWidget();
	if (font != null && font.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	this.font = font;
	this.parent.redraw(this);
}
 
Example 4
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 5
Source Project: nebula   File: RoundScale.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void setFont(Font font) {
    if (font != null && font.isDisposed()) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    tickLabels.setFont(font);
    super.setFont(font);
    
}
 
Example 6
Source Project: nebula   File: LinearScale.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setFont(Font font) {
	if (font != null && font.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	tickLabels.setFont(font);
	super.setFont(font);

}
 
Example 7
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 8
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 9
@Override
public void dispose() {
	super.dispose();
	if (null != boldFontSupplier) {
		final Font font = boldFontSupplier.get();
		if (null != font && !font.isDisposed()) {
			font.dispose();
		}
	}
}
 
Example 10
Source Project: ermasterr   File: Resources.java    License: Apache License 2.0 5 votes vote down vote up
public static void disposeFontMap() {
    for (final Font font : fontMap.values()) {
        if (!font.isDisposed()) {
            font.dispose();
        }
    }

    fontMap.clear();
}
 
Example 11
@Override
public void deactivate() {
	IFigure figure = getFigure();
	if (figure instanceof ProductSystemFigure) {
		ProductSystemFigure pFigure = (ProductSystemFigure) figure;
		Font infoFont = pFigure.infoFont;
		if (infoFont != null && !infoFont.isDisposed())
			infoFont.dispose();
	}
	super.deactivate();
}
 
Example 12
Source Project: olca-app   File: ProcessPart.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void deactivate() {
	IFigure figure = getFigure();
	if (figure instanceof ProcessFigure) {
		ProcessFigure pFigure = (ProcessFigure) figure;
		Font boldFont = pFigure.boldFont;
		if (boldFont != null && !boldFont.isDisposed())
			boldFont.dispose();
	}
	super.deactivate();
	((Node) getModel()).listeners.removePropertyChangeListener(this);
}
 
Example 13
Source Project: hop   File: PropsUi.java    License: Apache License 2.0 4 votes vote down vote up
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 14
Source Project: pentaho-kettle   File: PropsUI.java    License: Apache License 2.0 4 votes vote down vote up
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 15
Source Project: nebula   File: GridItem.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the font that the receiver will use to paint textual information for
 * this item to the font specified by the argument, or to the default font
 * for that kind of control if the argument is null.
 *
 * @param f
 *            the new font (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 setFont(Font f) {
	checkWidget();
	if (f != null && f.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	defaultFont = f;
	parent.redraw();
}
 
Example 16
Source Project: nebula   File: GridItem.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the font that the receiver will use to paint textual information for
 * the specified cell in this item to the font specified by the argument, or
 * to the default font for that kind of control if the argument is null.
 *
 * @param index
 *            the column index
 * @param font
 *            the new font (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 setFont(int index, Font font) {
	checkWidget();
	if (font != null && font.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	parent.getDataVisualizer().setFont(this, index, font);
	parent.redraw();
}
 
Example 17
/**
 * Sets the font that the receiver will use to paint textual information for
 * this item to the font specified by the argument, or to the default font
 * for that kind of control if the argument is null.
 *
 * @param f
 *            the new font (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 setFont(Font f) {
	checkWidget();
	if (f != null && f.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	defaultFont = f;
	parent.redraw();
}
 
Example 18
/**
 * Sets the font that the receiver will use to paint textual information for
 * the specified cell in this item to the font specified by the argument, or
 * to the default font for that kind of control if the argument is null.
 *
 * @param index
 *            the column index
 * @param font
 *            the new font (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 setFont(int index, Font font) {
	checkWidget();
	if (font != null && font.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	fonts.set(index, font);
	parent.redraw();
}
 
Example 19
/**
 * Sets the font that the receiver will use to paint textual information for
 * this item to the font specified by the argument, or to the default font
 * for that kind of control if the argument is null.
 *
 * @param f
 *            the new font (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 setFont(Font f) {
	checkWidget();
	if (f != null && f.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	defaultFont = f;
	parent.redraw();
}
 
Example 20
/**
 * Sets the font that the receiver will use to paint textual information for
 * the specified cell in this item to the font specified by the argument, or
 * to the default font for that kind of control if the argument is null.
 *
 * @param index
 *            the column index
 * @param font
 *            the new font (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 setFont(int index, Font font) {
	checkWidget();
	if (font != null && font.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	fonts.set(index, font);
	parent.redraw();
}