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

The following examples show how to use org.eclipse.swt.graphics.Font#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: ThemeUIComposite.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 2
Source File: ThemePreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 3
Source File: GalleryItem.java    From nebula with 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 File: ProcessPart.java    From olca-app with 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 5
Source File: ProductSystemPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@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 6
Source File: Resources.java    From ermasterr with 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 7
Source File: OpenTypeSelectionDialog.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void dispose() {
	super.dispose();
	if (null != boldFontSupplier) {
		final Font font = boldFontSupplier.get();
		if (null != font && !font.isDisposed()) {
			font.dispose();
		}
	}
}
 
Example 8
Source File: CSSEngineHelper.java    From nebula with 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
Source File: CSSEngineHelper.java    From nebula with 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 10
Source File: LinearScale.java    From nebula with 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 11
Source File: RoundScale.java    From nebula with 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 12
Source File: CSSEngineHelper.java    From nebula with 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 13
Source File: PropsUi.java    From hop with 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 File: PropsUI.java    From pentaho-kettle with 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 File: GridItem.java    From nebula with 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 16
Source File: GridItem.java    From translationstudio8 with GNU General Public License v2.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 17
Source File: GridItem.java    From translationstudio8 with GNU General Public License v2.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);
	}
	fonts.set(index, font);
	parent.redraw();
}
 
Example 18
Source File: GridItem.java    From tmxeditor8 with GNU General Public License v2.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 19
Source File: GridItem.java    From tmxeditor8 with GNU General Public License v2.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);
	}
	fonts.set(index, font);
	parent.redraw();
}
 
Example 20
Source File: GridItem.java    From nebula with 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();
}