Java Code Examples for org.eclipse.swt.graphics.Font

The following examples show how to use org.eclipse.swt.graphics.Font. 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
@Override
public void createOptions(final Composite optionsGroup, Font font) {
    optionsGroupComposite = optionsGroup;
    optionsGroupFont = font;

    createOptionsForKar(optionsGroup, font);
    // createOptionForDockerImage(optionsGroup, font);

    if ("ROUTE_MICROSERVICE".equals(
            getProcessItem().getProperty().getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE))) {
        createDockerOptions(optionsGroup);
        restoreWidgetValuesForImage();
    }

    restoreWidgetValuesForKar();
}
 
Example 2
Source Project: swt-bling   Source File: Sleak.java    License: MIT License 6 votes vote down vote up
void refreshLabel () {
  int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 0;
  for (int i=0; i<objects.length; i++) {
    Object object = objects [i];
    if (object instanceof Color) colors++;
    if (object instanceof Cursor) cursors++;
    if (object instanceof Font) fonts++;
    if (object instanceof GC) gcs++;
    if (object instanceof Image) images++;
    if (object instanceof Region) regions++;
  }
  String string = "";
  if (colors != 0) string += colors + " Color(s)\n";
  if (cursors != 0) string += cursors + " Cursor(s)\n";
  if (fonts != 0) string += fonts + " Font(s)\n";
  if (gcs != 0) string += gcs + " GC(s)\n";
  if (images != 0) string += images + " Image(s)\n";
  /* Currently regions are not counted. */
  //  if (regions != 0) string += regions + " Region(s)\n";
  if (string.length () != 0) {
    string = string.substring (0, string.length () - 1);
  }
  label.setText (string);
}
 
Example 3
Source Project: pentaho-kettle   Source File: EnterOptionsDialog.java    License: Apache License 2.0 6 votes vote down vote up
public void getData() {
  fixedFontData = props.getFixedFont();
  fixedFont = new Font( display, fixedFontData );

  graphFontData = props.getGraphFont();
  graphFont = new Font( display, graphFontData );

  noteFontData = props.getNoteFont();
  noteFont = new Font( display, noteFontData );

  backgroundRGB = props.getBackgroundRGB();
  if ( backgroundRGB == null ) {
    backgroundRGB = display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ).getRGB();
  }
  background = new Color( display, backgroundRGB );

  graphColorRGB = props.getGraphColorRGB();
  graphColor = new Color( display, graphColorRGB );

  tabColorRGB = props.getTabColorRGB();
  tabColor = new Color( display, tabColorRGB );
}
 
Example 4
private void setDefaultFont(Font newFont) {
	String[] fontIds = { "org.eclipse.jface.textfont",
			"org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" };
	FontData[] newData = newFont.getFontData();
	for (String fontId : fontIds) {
		setFont(fontId, newData);
	}

	newData = newFont.getFontData();
	FontData[] smaller = new FontData[newData.length];
	int j = 0;
	for (FontData fd : newData) {
		int height = fd.getHeight();
		if (height >= 12) {
			fd.setHeight(height - 2);
		} else if (height >= 10) {
			fd.setHeight(height - 1);
		}
		smaller[(j++)] = fd;
	}
	setFont("com.aptana.explorer.font", smaller);
}
 
Example 5
Source Project: typescript.java   Source File: TypeScriptTemplatePreferencePage.java    License: MIT License 6 votes vote down vote up
protected SourceViewer createViewer(Composite parent) {
	IDocument document= new Document();
	JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
	tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
	IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore();
	SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
	SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
	viewer.configure(configuration);
	viewer.setEditable(false);
	viewer.setDocument(document);

	Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
	viewer.getTextWidget().setFont(font);
	new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);
	
	Control control= viewer.getControl();
	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
	control.setLayoutData(data);
	
	return viewer;
}
 
Example 6
Source Project: nebula   Source File: CalendarComposite.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void drawChartOntoGC(GC gc) {
	Rectangle bounds = super.getBounds();
	gc.setBackground(mColorManager.getCalendarBackgroundColor());
	gc.fillRectangle(bounds);

	Font used = null;
	if (CalendarCombo.OS_CARBON) {
		used = mSettings.getCarbonDrawFont();
		if (used != null)
			gc.setFont(used);
	}

	// header
	drawHeader(gc);
	// day titles
	drawTitleDays(gc);
	// days
	drawDays(gc);
	// 1 pixel border
	drawBorder(gc);

	gc.dispose();
	if (used != null)
		used.dispose();
}
 
Example 7
Source Project: xds-ide   Source File: SyntaxColorerPreviewer.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public SyntaxColorerPreviewer(Composite parent, final IPreferenceStore preferenceStore) {
     super(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
     this.preferenceStore = preferenceStore;
     this.setLayoutData(new GridData(GridData.FILL_BOTH));
     
     Font font= JFaceResources.getTextFont();
     this.setFont(font);
     
     defBackgroundColor = getEditorBackgroundColor(preferenceStore);
     this.setBackground(defBackgroundColor);
     
     prefListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
	try { // Widget may be disposed here
	    defBackgroundColor = getEditorBackgroundColor(preferenceStore);
              setBackground(defBackgroundColor);
              updateColors();
       } catch (Exception e) {} 
}
     };
     
     preferenceStore.addPropertyChangeListener(prefListener);
     
     tokenManager = new TokenManager();
 }
 
Example 8
private TextStyle createResultsStyle() {
	background = new Color(Display.getCurrent(), 0x19, 0x19, 0x70);
	foreground = new Color(Display.getCurrent(), 0xff, 0xff, 0xff);
	FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
	fontData.setStyle(fontData.getStyle());
	rsFont = new Font(Display.getDefault(), fontData);
	TextStyle style = new TextStyle(rsFont, foreground, background);
	return style;
}
 
Example 9
Source Project: openstock   Source File: SWTUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create an awt font by converting as much information
 * as possible from the provided swt <code>FontData</code>.
 * <p>Generally speaking, given a font size, an swt font will
 * display differently on the screen than the corresponding awt
 * one. Because the SWT toolkit use native graphical ressources whenever
 * it is possible, this fact is platform dependent. To address
 * this issue, it is possible to enforce the method to return
 * an awt font with the same height as the swt one.
 *
 * @param device The swt device being drawn on (display or gc device).
 * @param fontData The swt font to convert.
 * @param ensureSameSize A boolean used to enforce the same size
 * (in pixels) between the swt font and the newly created awt font.
 * @return An awt font converted from the provided swt font.
 */
public static java.awt.Font toAwtFont(Device device, FontData fontData,
        boolean ensureSameSize) {
    int height = (int) Math.round(fontData.getHeight() * device.getDPI().y
            / 72.0);
    // hack to ensure the newly created awt fonts will be rendered with the
    // same height as the swt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        JPanel DUMMY_PANEL = new JPanel();
        java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
                fontData.getStyle(), height);
        if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                > tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    > tmpGC.textExtent(Az).x) {
                height--;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                < tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    < tmpGC.textExtent(Az).x) {
                height++;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return new java.awt.Font(fontData.getName(), fontData.getStyle(),
            height);
}
 
Example 10
Source Project: birt   Source File: ScriptMainTab.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void buildTempFolder( Composite parentG )
{
	Font font = parentG.getFont( );
	Group tempFolderGroup = ScriptSWTFactory.createGroup( parentG,
			Messages.getString( "ScriptMainTab.msg.temp.folder" ), //$NON-NLS-1$
			2,
			1,
			GridData.FILL_HORIZONTAL );
	Composite folder = ScriptSWTFactory.createComposite( tempFolderGroup,
			font,
			3,
			2,
			GridData.FILL_BOTH,
			0,
			0 );
	fTempFolder = ScriptSWTFactory.createSingleText( folder, 1 );
	fTempFolder.addModifyListener( modifyListener );

	Button forderSearchButton = createPushButton( folder,
			Messages.getString( "ScriptMainTab.button.text.search" ), //$NON-NLS-1$
			null );

	forderSearchButton.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			IPath chosen = chooseDropLocation( Messages.getString( "ScriptMainTab.title.temp.folder" ), //$NON-NLS-1$
					Messages.getString( "ScriptMainTab.msg.select.temp.folder" ), //$NON-NLS-1$
					fTempFolder.getText( ) );
			if ( chosen != null )
				fTempFolder.setText( chosen.toOSString( ) );
		}
	} );

	createVariableButton( folder,
			Messages.getString( "ScriptMainTab.button.text.variables" ), //$NON-NLS-1$ 
			fTempFolder );
}
 
Example 11
private Control createPreviewer(Composite parent) {

		IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
		IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
		fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.BORDER, store);
		SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaPartitions.JAVA_PARTITIONING, false);
		fPreviewViewer.configure(configuration);
		// fake 1.5 source to get 1.5 features right.
		configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5));
		Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
		fPreviewViewer.getTextWidget().setFont(font);
		new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);

		fPreviewViewer.setEditable(false);
		Cursor arrowCursor= fPreviewViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
		fPreviewViewer.getTextWidget().setCursor(arrowCursor);

		// Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
//		fPreviewViewer.getTextWidget().setCaret(null);

		String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
		IDocument document= new Document(content);
		JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
		fPreviewViewer.setDocument(document);

		installSemanticHighlighting();


		return fPreviewViewer.getControl();
	}
 
Example 12
Source Project: ECG-Viewer   Source File: SWTUtils.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create an awt font by converting as much information
 * as possible from the provided swt <code>FontData</code>.
 * <p>Generally speaking, given a font size, an swt font will
 * display differently on the screen than the corresponding awt
 * one. Because the SWT toolkit use native graphical ressources whenever
 * it is possible, this fact is platform dependent. To address
 * this issue, it is possible to enforce the method to return
 * an awt font with the same height as the swt one.
 *
 * @param device The swt device being drawn on (display or gc device).
 * @param fontData The swt font to convert.
 * @param ensureSameSize A boolean used to enforce the same size
 * (in pixels) between the swt font and the newly created awt font.
 * @return An awt font converted from the provided swt font.
 */
public static java.awt.Font toAwtFont(Device device, FontData fontData,
        boolean ensureSameSize) {
    int height = (int) Math.round(fontData.getHeight() * device.getDPI().y
            / 72.0);
    // hack to ensure the newly created awt fonts will be rendered with the
    // same height as the swt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        JPanel DUMMY_PANEL = new JPanel();
        java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
                fontData.getStyle(), height);
        if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                > tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    > tmpGC.textExtent(Az).x) {
                height--;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                < tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    < tmpGC.textExtent(Az).x) {
                height++;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return new java.awt.Font(fontData.getName(), fontData.getStyle(),
            height);
}
 
Example 13
public Point computeSizeConstraints(int widthInChars, int heightInChars)
{
	if (fSymbolicFontName == null)
		return null;

	GC gc = new GC(fBrowser);
	Font font = fSymbolicFontName == null ? JFaceResources.getDialogFont() : JFaceResources
			.getFont(fSymbolicFontName);
	gc.setFont(font);
	int width = gc.getFontMetrics().getAverageCharWidth();
	int height = gc.getFontMetrics().getHeight();
	gc.dispose();

	return new Point(widthInChars * width, heightInChars * height);
}
 
Example 14
Source Project: nebula   Source File: GridColumn_Test.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test( expected = IllegalArgumentException.class )
public void testSetHeaderFont_DisposedFont() {
  Font font = new Font( display, "Arial", 20, SWT.BOLD );
  font.dispose();

  column.setHeaderFont( font );
}
 
Example 15
Source Project: nebula   Source File: DefaultRowHeaderRenderer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
    * {@inheritDoc}
    */
   @Override
public Point computeSize(GC gc, int wHint, int hHint, Object value)
   {
       GridItem item = (GridItem) value;

       String text = getHeaderText(item);
       Image image = getHeaderImage(item);

       Font previousFont = gc.getFont();
	if (getHeaderFont(item) == null) {
		gc.setFont(item.getParent().getFont());
	} else {
		gc.setFont(getHeaderFont(item));
	}

       int x = leftMargin;

       if( image != null ) {
       	x += image.getBounds().width + 5;
       }

       x += gc.stringExtent(text).x + rightMargin;

       int y = topMargin;

       if( image != null ) {
       	y += Math.max(gc.getFontMetrics().getHeight(),image.getBounds().height);
       } else {
       	y += gc.getFontMetrics().getHeight();
       }


       y += bottomMargin;
       gc.setFont(previousFont);

       return new Point(x, y);
   }
 
Example 16
Source Project: EasyShell   Source File: CommandPage.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void createNewButton(Font font, GridData gridData, Composite groupComponent) {
    addNewButton = new Button(groupComponent, SWT.PUSH);
    addNewButton.setText(Activator.getResourceString("easyshell.command.page.button.text.new"));
    addNewButton.setToolTipText(Activator.getResourceString("easyshell.command.page.button.tooltip.new"));
    addNewButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            addNewDialog();
        }
    });
    addNewButton.setLayoutData(gridData);
    addNewButton.setFont(font);
    setButtonLayoutData(addNewButton);
}
 
Example 17
protected TextAttribute createTextAttribute(String id, TextStyle defaultTextStyle) {
	TextStyle textStyle = new TextStyle();
	preferencesAccessor.populateTextStyle(id, textStyle, defaultTextStyle);
	int style = textStyle.getStyle();
	Font fontFromFontData = EditorUtils.fontFromFontData(textStyle.getFontData());
	return new TextAttribute(EditorUtils.colorFromRGB(textStyle.getColor()), EditorUtils.colorFromRGB(textStyle
			.getBackgroundColor()), style, fontFromFontData);
}
 
Example 18
Source Project: birt   Source File: DataItemCombo.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void setFont( Font font )
{
	super.setFont( font );
	this.font = font;
	text.setFont( font );
	list.setFont( font );
	internalLayout( true );
}
 
Example 19
Source Project: pmTrans   Source File: EditingPane.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public void updateFont() {
	text.setFont(new Font(Display.getCurrent(), Config.getInstance()
			.getString(Config.FONT), Config.getInstance().getInt(
			Config.FONT_SIZE), SWT.NORMAL));
	text.setBackground(Config.getInstance().getColor(
			Config.BACKGROUND_COLOR));
	text.setForeground(Config.getInstance().getColor(Config.FONT_COLOR));
}
 
Example 20
Source Project: EasyShell   Source File: MenuDataDialog.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void createRemoveButton(Composite parent) {
    Font font = parent.getFont();
    removeButton = new Button(parent, SWT.PUSH);
    removeButton.setText(Activator.getResourceString("easyshell.menu.editor.dialog.button.text.remove"));
    removeButton.setToolTipText(Activator.getResourceString("easyshell.menu.editor.dialog.button.tooltip.remove"));
    removeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            removeDialog();
        }
    });
    removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    removeButton.setFont(font);
    setButtonLayoutData(removeButton);
}
 
Example 21
Source Project: nebula   Source File: SnippetGalleryViewerTester.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public Font getFont(Object element) {
	String label = (String) element;
	if (Integer.parseInt(label.substring(label.indexOf(' ') + 1)) % 2 > 0) {
		return null;
	} else {
		FontData sysFontData = Display.getCurrent().getSystemFont().getFontData()[0];
		sysFontData.setStyle(SWT.BOLD | SWT.ITALIC);
		return new Font(Display.getCurrent(), sysFontData);
	}
}
 
Example 22
Source Project: birt   Source File: ReportDocumentEditor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Composite createComposite( Composite parent, Font font,
		int columns, int hspan, int fill, int marginwidth, int marginheight )
{
	Composite g = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( columns, false );
	layout.marginWidth = marginwidth;
	layout.marginHeight = marginheight;
	g.setLayout( layout );
	g.setFont( font );
	GridData gd = new GridData( fill );
	gd.horizontalSpan = hspan;
	g.setLayoutData( gd );
	return g;
}
 
Example 23
Source Project: nebula   Source File: AdaptedDataVisualizer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.grid.DataVisualizer#setDefaultFont(org.eclipse.swt.graphics.Font)
 */
@Override
public void setDefaultFont(Font defaultFont) {
	/**
	 * Is empty
	 */
}
 
Example 24
private String getFontInCSSFormat(Font font) {
	FontData fontData = font.getFontData()[0];
	String fontName = fontData.getName();
	int fontStyle = fontData.getStyle();
	String HTML_STYLES[] = new String[] { "NORMAL", "BOLD", "ITALIC" };

	return String.format("font: %s; font-family: %s",
	                     fontStyle <= 2 ? HTML_STYLES[fontStyle] : HTML_STYLES[0],
	                     fontName);
}
 
Example 25
Source Project: n4js   Source File: LaunchConfigurationMainTab.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
 **/
@Override
public void createControl(Composite parent) {
	Font font = parent.getFont();
	Composite comp = createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
	createFileGroup(comp);
	setControl(comp);

}
 
Example 26
Source Project: nebula   Source File: TableComboViewerSnippet1.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public Font getFont(Object element, int index) {
	Model item = (Model)element;
	
	if (item.getId() == 1 || item.getId() == 15 || 
		item.getId() == 5 || item.getId() == 20 ||
		item.getId() == 10) {
		return boldFont;
	}
	else {
		return null;
	}			
}
 
Example 27
Source Project: Pydev   Source File: AppEngineTemplatePage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the font and the grid data for some control.
 */
private void setFillHorizontalLayoutDataAndFont(Control control, Font font) {
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    control.setLayoutData(data);
    control.setFont(font);
}
 
Example 28
Source Project: nebula   Source File: GridItem_Test.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testClear() {
  GridItem item = new GridItem( grid, SWT.NONE );
  Font font = new Font( display, "Arial", 20, SWT.BOLD );
  Color background = new Color( display, 0, 255, 0 );
  Color foreground = new Color( display, 0, 0, 255 );
  item.setFont( font );
  item.setBackground( background );
  item.setForeground( foreground );
  grid.clear( 0, false );
  assertSame( grid.getFont(), item.getFont() );
  assertSame( grid.getBackground(), item.getBackground() );
  assertSame( grid.getForeground(), item.getForeground() );
}
 
Example 29
Source Project: nebula   Source File: Axis.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setFont(Font font) {
	if (font == null)
		return;
	super.setFont(font);
	this.scaleFontData = getFont().getFontData()[0];
}
 
Example 30
/**
 * Create the export destination specification widgets
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 */
protected void createDestinationGroup(Composite parent) {

	Font font = parent.getFont();
	// destination specification group
	Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 3;
	destinationSelectionGroup.setLayout(layout);
	destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
			| GridData.VERTICAL_ALIGN_FILL));
	destinationSelectionGroup.setFont(font);

	Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
	destinationLabel.setText(getDestinationLabel());
	destinationLabel.setFont(font);

	// destination name entry field
	destinationNameField = new Text(destinationSelectionGroup, SWT.BORDER);
	destinationNameField.addListener(SWT.Modify, this);
	destinationNameField.addListener(SWT.Selection, this);
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	destinationNameField.setLayoutData(data);
	destinationNameField.setFont(font);

	// destination browse button
	destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
	destinationBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
	destinationBrowseButton.addListener(SWT.Selection, this);
	destinationBrowseButton.setFont(font);
	setButtonLayoutData(destinationBrowseButton);

	new Label(parent, SWT.NONE); // vertical spacer
}