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

The following are top voted examples for showing how to use org.eclipse.swt.graphics.Font. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: bdf2   File: TableFigure.java   Source Code and License 6 votes vote down vote up
public TableFigure() {
	ToolbarLayout layout = new ToolbarLayout();
	setLayoutManager(layout);
	LineBorder lineBorder = new LineBorder(ColorConstants.lightGray, 2);
	setBorder(lineBorder);
	setOpaque(true);
	setBackgroundColor(ColorConstants.white);

	Font font = new Font(null, "宋体", 11, SWT.NORMAL);
	label.setFont(font);
	label.setBorder(new LineBorder(ColorConstants.lightGray));
	label.setIcon(Activator.getImage(Activator.IMAGE_TABLE_16));
	label.setOpaque(true);
	label.setBackgroundColor(ColorConstants.lightBlue);
	label.setForegroundColor(ColorConstants.black);
	add(label);
	add(columnFigure);
}
 
Example 2
Project: ide-plugins   File: PluginsSWT.java   Source Code and License 6 votes vote down vote up
public PluginsSWT(Shell shell, List<String> lines) {
    super(shell);
    this.pluginsBean = new PluginsBean(lines);
    
    target = pluginsBean.getPlugins();
    source = Stream.of(Plugin.values())
            .filter(p -> ! target.contains(p))
            .collect(Collectors.toList());
    targetOriginal = target.stream().collect(Collectors.toList());
    
    rowColorTitle = new Color(display, 70, 130, 180);
    int color = myOS == OS.Mac ? 249 : 239;
    rowColorBack = new Color(display, color, color, color);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
  
    fontAwesome = loadCustomFont(getFontAwesomeSize());
    fontGap = new Font(display, fontName, 4, SWT.NORMAL);
    rowTitleFont = new Font(display, fontName, getTopFontSize(), SWT.BOLD);
    rowTextFont = new Font(display, fontName, getTopFontSize() - 2, SWT.NORMAL);
    styleTitle = new TextStyle(rowTitleFont, rowColorTitle, null);
    styleGap = new TextStyle(fontGap, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleRow = new TextStyle(rowTextFont, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleTitleSelected = new TextStyle(rowTitleFont, rowColorSelection, null);
    styleRowSelected = new TextStyle(rowTextFont, rowColorSelection, null);
}
 
Example 3
Project: ide-plugins   File: PluginDialog.java   Source Code and License 6 votes vote down vote up
protected void createTopContent(String title, InputStream imageName) {
    Composite top = new Composite(composite, SWT.NONE);

    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    top.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    final Image image = new Image(top.getDisplay(), imageName);
    Image resized = resizeImage(image, 48, 48);
    Label labelImage = new Label(top, SWT.CENTER);
    labelImage.setImage(resized);
    
    Label label = new Label(top, SWT.NONE);
    label.setText(title);
    final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    label.setFont(newFont);
    label.setBackground(rowColorSelection);
    
    createLineContent();
    
    top.addDisposeListener(e -> {
        newFont.dispose();
        resized.dispose();
    });
}
 
Example 4
Project: neoscada   File: TitleRenderer.java   Source Code and License 6 votes vote down vote up
private Font createFont ( final ResourceManager resourceManager )
{
    final Font defaultFont = resourceManager.getDevice ().getSystemFont ();

    if ( defaultFont == null )
    {
        return null;
    }

    final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
    if ( fd == null )
    {
        return null;
    }

    for ( final FontData f : fd )
    {
        if ( this.fontSize > 0 )
        {
            f.setHeight ( this.fontSize );
        }
    }
    return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
 
Example 5
Project: convertigo-eclipse   File: TextEditorComposite.java   Source Code and License 6 votes vote down vote up
private void initialize() {
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 1;
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessVerticalSpace = true;
	gridData.grabExcessHorizontalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	
	//minimum size (when dialog open)
	gridData.minimumHeight = 200;
	gridData.minimumWidth = 300;
	
	this.setLayout(gridLayout);
	textArea = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	textArea.setFont(new Font(null,"Tahoma",10,0));
	textArea.setLayoutData(gridData);
}
 
Example 6
Project: convertigo-eclipse   File: SqlQueryEditorComposite.java   Source Code and License 6 votes vote down vote up
private void initialize() {
	labelSyntaxe = new Label(this, SWT.NONE);
	
	labelSyntaxe.setText("SQL query syntax examples :\n");
	labelSyntaxe.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
	labelSQLQuery = new Label(this, SWT.NONE);
	labelSQLQuery.setFont(new Font(null,"Tahoma",8,1));
	labelSQLQuery.setText("SELECT * FROM EMPLOYEES WHERE (NAME='{parameter_name}')\n"
							+ "{? = CALL STORED_FUNCTION({parameter_name})}\n"
							+ "{CALL STORED_PROCEDURE({parameter_name})}\n\n");
	labelSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
	textAreaSQLQuery = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	textAreaSQLQuery.setFont(new Font(null,"Tahoma",10,0));
	textAreaSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
	GridLayout gridLayout = new GridLayout();
	this.setLayout(gridLayout);
	setSize(new org.eclipse.swt.graphics.Point(402,289));
}
 
Example 7
Project: convertigo-eclipse   File: ViewLabelProvider.java   Source Code and License 6 votes vote down vote up
public ViewLabelProvider() {
	Device device = Display.getCurrent();

	fontSystem = device.getSystemFont();

	FontData fontData = fontSystem.getFontData()[0];
	
	fontDetectedDatabaseObject = new Font(device, fontData);
	
	FontData fontDataModified = fontSystem.getFontData()[0];
	fontDataModified.setStyle(SWT.BOLD);
	fontModifiedDatabaseObject = new Font(device, fontDataModified);

	colorUnloadedProject = new Color(device, 12, 116, 176);
	colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
	colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
	colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
	colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
 
Example 8
Project: convertigo-eclipse   File: StatisticsDialog.java   Source Code and License 6 votes vote down vote up
private void addStats() {

		for (String key : statsProject.keySet()) {
			if (key != project.getName()) {
				CLabel title = new CLabel(descriptifRight, SWT.BOLD);
				title.setText(key);
				title.setImage(new Image(display, getClass()
						.getResourceAsStream(
								"images/stats_"
										+ key.replaceAll(" ", "_")
												.toLowerCase() + "_16x16.png")));
				title.setBackground(new Color(display, 255, 255, 255));
				title.setMargins(10, 10, 0, 0);

				FontData[] fd = title.getFont().getFontData();
				fd[0].setStyle(SWT.BOLD);
				title.setFont(new Font(title.getFont().getDevice(), fd));

				CLabel subText = new CLabel(descriptifRight, SWT.NONE);
				subText.setText(statsProject.get(key)
						.replaceAll("<br/>", "\r\n").replaceAll("&nbsp;", " "));
				subText.setBackground(new Color(display, 255, 255, 255));
				subText.setMargins(30, 0, 0, 0);
			}
		}
	}
 
Example 9
Project: avoCADo   File: MELabel.java   Source Code and License 6 votes vote down vote up
@Override
void paintElement(PaintEvent e) {
	GC g = e.gc;
	g.setBackground(this.getBackground());
	int width  = this.getBounds().width;
	int height = this.getBounds().height;
	
	// clear entire canvas where button will be painted
	g.fillRectangle(0, 0, width, height);
	
	// draw text
	g.setForeground(this.meColorForeground);
	FontData fd = new FontData();
	fd.setHeight(8);
	if(textIsBold){
		fd.setStyle(SWT.BOLD);
	}else{
		fd.setStyle(SWT.NORMAL);
	}
	g.setFont(new Font(this.getDisplay(), fd));
	Point textPt = g.textExtent(this.meLabel);			
	g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
 
Example 10
Project: openaudible   File: FontShop.java   Source Code and License 6 votes vote down vote up
public FontShop(Display display) {
    if (display == null) {
        Application.report("font display null");
    }

    regFonts = new Font[kNumFonts];
    boldFonts = new Font[kNumFonts];
    italicFonts = new Font[kNumFonts];
    for (int x = 0; x < kNumFonts; x++) {
        regFonts[x] = newDefaultFont(x);
        newStyledFont(x);
    }

    if (curFonts == null)
        curFonts = this;

}
 
Example 11
Project: eclipse-plugin-commander   File: KaviListColumns.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private RankedItem<T> applyCellDefaultStyles(final ColumnOptions<T> options, ViewerCell cell) {
	final RankedItem<T> rankedItem = (RankedItem<T>) cell.getElement();
	cell.setForeground(fromRegistry(options.getFontColor()));
	int rowState = rowStateResolver.apply(rankedItem);
	
    if ((rowState & RowState.SELECTED.value) != 0 && options.isEnableBackgroundSelection()) {
		cell.setBackground(fromRegistry(new RGB(225,226,206)));
	} else {
		cell.setBackground(fromRegistry(options.getBackgroundColor()));
	}
    if ((rowState & RowState.CURSOR.value) != 0 && options.isEnableBackgroundSelection()) {
		cell.setBackground(fromRegistry(ColorUtil.blend(cell.getBackground().getRGB(), new RGB(200,200,200))));
    }
	Font font = createColumnFont(options, cell);
	cell.setFont(font);
	return rankedItem;
}
 
Example 12
Project: SWET   File: ScrolledTextEx.java   Source Code and License 6 votes vote down vote up
private StyledText createStyledText() {
	styledText = new StyledText(shell,
			SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // SWT.WRAP
	GridData gridData = new GridData();
	styledText.setFont(
			new Font(shell.getDisplay(), "Source Code Pro Light", 10, SWT.NORMAL));
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.verticalAlignment = GridData.FILL;
	gridData.grabExcessVerticalSpace = true;
	styledText.setLayoutData(gridData);
	styledText.addLineStyleListener(lineStyler);
	styledText.setEditable(false);
	styledText
			.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
	return styledText;
}
 
Example 13
Project: Hydrograph   File: SourceViewer.java   Source Code and License 6 votes vote down vote up
private void initializeViewer(IDocument document) {
	fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
	setDocument(document);
	installViewerConfiguration();
	setEditable(true);
	Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
	getTextWidget().setFont(font);
	getTextWidget().setData("document",document);
	Control control = getControl();
	GridData data = new GridData(GridData.FILL_BOTH);
	control.setLayoutData(data);
	prependVerifyKeyListener(new VerifyKeyListener() {

		@Override
		public void verifyKey(VerifyEvent event) {
			handleVerifyKeyPressed(event);
		}
	});
	addDocumentListener(document);
}
 
Example 14
Project: Hydrograph   File: CommentBoxFigure.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a new CommentBoxFigure with a MarginBorder that is the given size and a FlowPage containing a TextFlow
 * with the style WORD_WRAP_SOFT.
 * 
 * @param borderSize
 *            the size of the MarginBorder
 */
public CommentBoxFigure(int borderSize) {
	setBorder(new MarginBorder(5));
	FlowPage flowPage = new FlowPage();

	textFlow = new TextFlow();

	textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, ParagraphTextLayout.WORD_WRAP_SOFT));

	flowPage.add(textFlow);

	setLayoutManager(new StackLayout());
	add(flowPage);
	font = new Font(Display.getDefault(), "Arial", 9, SWT.NORMAL);
	setFont(font);
	setForegroundColor(ColorConstants.black);
	setOpaque(false);

}
 
Example 15
Project: Hydrograph   File: CommentBoxLabelEditManager.java   Source Code and License 6 votes vote down vote up
/**
 * update scaledFonts
 * @param zoom
 * 				at zoom 
 */
private void updateScaledFont(double zoom) {
	if (cachedZoom == zoom)
		return;
	
	Text text = (Text)getCellEditor().getControl();
	Font font = getEditPart().getFigure().getFont();
	
	disposeScaledFont();
	cachedZoom = zoom;
	if (zoom == 1.0)
		text.setFont(font);
	else {
		FontData fd = font.getFontData()[0];
		fd.setHeight((int)(fd.getHeight() * zoom));
		text.setFont(scaledFont = new Font(null, fd));
	}
}
 
Example 16
Project: n4js   File: LaunchConfigurationMainTab.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("javadoc")
public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) {
	Composite g = new Composite(parent, SWT.NONE);
	g.setLayout(new GridLayout(columns, false));
	g.setFont(font);
	GridData gd = new GridData(fill);
	gd.horizontalSpan = hspan;
	g.setLayoutData(gd);
	return g;
}
 
Example 17
Project: n4js   File: OpenTypeSelectionDialog.java   Source Code and License 5 votes vote down vote up
@Override
public Font get() {
	final Font font = getDialogArea().getFont();
	final FontData[] data = font.getFontData();
	for (int i = 0; i < data.length; i++) {
		data[i].setStyle(BOLD);
	}
	return new Font(font.getDevice(), data);
}
 
Example 18
Project: n4js   File: OpenTypeSelectionDialog.java   Source Code and License 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 19
Project: BiglyBT   File: SubscriptionWizard.java   Source Code and License 5 votes vote down vote up
private void createFonts() {

		FontData[] fDatas = shell.getFont().getFontData();

		for(int i = 0 ; i < fDatas.length ; i++) {
			fDatas[i].setStyle(SWT.BOLD);
		}
		boldFont = new Font(display,fDatas);


		for(int i = 0 ; i < fDatas.length ; i++) {
			if(com.biglybt.core.util.Constants.isOSX) {
				fDatas[i].setHeight(12);
			} else {
				fDatas[i].setHeight(10);
			}
		}
		subTitleFont = new Font(display,fDatas);

		for(int i = 0 ; i < fDatas.length ; i++) {
			if(com.biglybt.core.util.Constants.isOSX) {
				fDatas[i].setHeight(17);
			} else {
				fDatas[i].setHeight(14);
			}
		}
		titleFont = new Font(display,fDatas);

		// When GTK3 can show a textbox without a border, we can remove the logic
		textInputFont = FontUtils.getFontWithHeight(shell.getFont(), null, Utils.isGTK3 ? 12 : 14);


	}
 
Example 20
Project: n4js   File: ExportSelectionPage.java   Source Code and License 5 votes vote down vote up
@Override
protected void createOptionsGroupButtons(Group optionsGroup) {
	Font font = optionsGroup.getFont();
	optionsGroup.setLayout(new GridLayout(2, true));

	Composite left = new Composite(optionsGroup, SWT.NONE);
	left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
	left.setLayout(new GridLayout(1, true));

	// compress... checkbox
	compressContentsCheckbox = new Button(left, SWT.CHECK | SWT.LEFT);
	compressContentsCheckbox.setText(DataTransferMessages.ZipExport_compressContents);
	compressContentsCheckbox.setFont(font);

}
 
Example 21
Project: n4js   File: AbstractLaunchConfigurationMainTab.java   Source Code and License 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);
	createResourceGroup(comp);
	createImplementationIdGroup(comp);
	setControl(comp);
}
 
Example 22
Project: ide-plugins   File: PluginsSWT.java   Source Code and License 5 votes vote down vote up
private Font loadCustomFont(int fontSize) {
    String fontPath = ProjectUtils.extractResourceToTmp("fontawesome-webfont.ttf");
    boolean isLoaded = display.loadFont(fontPath);
    if (isLoaded) {
        return Stream.of(Display.getDefault().getFontList(null, true))
                .filter(fd -> fd.getName().toLowerCase(Locale.ROOT).contains("fontawesome"))
                .findFirst()
                .map(fd -> {
                    fd.setHeight(fontSize);
                    return new Font(display, fd);
                })
                .orElse(null);
    }
    return null;   
}
 
Example 23
Project: ide-plugins   File: PluginDialog.java   Source Code and License 5 votes vote down vote up
public PluginDialog(Shell shell) {
    super(shell);
    this.display = Display.getDefault();
    
    fontName = display.getSystemFont().getFontData()[0].getName();
    backColor = new Color(display, 244, 244, 244);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
    titleFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    topFont = new Font(display, fontName, getTopFontSize(), SWT.NORMAL);
}
 
Example 24
Project: gemoc-studio-modeldebugging   File: LaunchConfigurationMainTab.java   Source Code and License 5 votes vote down vote up
/***
 * Create the Field where user enters the language used to execute
 * 
 * @param parent container composite
 * @param font used font
 * @return the created composite containing the fields
 */
public Composite createLanguageLayout(Composite parent, Font font) {
	// Language
	createTextLabelLayout(parent, "Melange languages");
	_languageCombo = new Combo(parent, SWT.NONE);
	_languageCombo.setLayoutData(createStandardLayout());

	List<String> languagesNames = MelangeHelper.getAllLanguages();
	String[] empty = {};
	_languageCombo.setItems(languagesNames.toArray(empty));
	_languageCombo.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			//String selection = _languageCombo.getText();
			//List<String> modelTypeNames = MelangeHelper.getModelTypes(selection);
			updateLaunchConfigurationDialog();
		}
	});
	createTextLabelLayout(parent, "");

	createTextLabelLayout(parent, "Melange resource adapter query");
	_melangeQueryText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	_melangeQueryText.setLayoutData(createStandardLayout());
	_melangeQueryText.setFont(font);
	_melangeQueryText.setEditable(false);
	createTextLabelLayout(parent, "");
	
	return parent;
}
 
Example 25
Project: gemoc-studio-modeldebugging   File: DecoratingColumLabelProvider.java   Source Code and License 5 votes vote down vote up
@Override
public Font getFont(Object element) {
	final Font res;

	if (fontProvider == null) {
		res = null;
	} else {
		res = fontProvider.getFont(element);
	}

	return res;
}
 
Example 26
Project: gemoc-studio-modeldebugging   File: DecoratingColumLabelProvider.java   Source Code and License 5 votes vote down vote up
@Override
public Font getToolTipFont(Object element) {
	final Font res;

	if (cellLabelProvider == null) {
		res = null;
	} else {
		res = cellLabelProvider.getToolTipFont(element);
	}

	return res;
}
 
Example 27
Project: gemoc-studio-modeldebugging   File: EnginesStatusView.java   Source Code and License 5 votes vote down vote up
/**
	 * This is a callback that will allow us
	 * to create the viewer and initialize it.
	 */
	public void createPartControl(Composite parent) {
		_viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
		_contentProvider = new ViewContentProvider();
		_viewer.setContentProvider(_contentProvider);
		ColumnViewerToolTipSupport.enableFor(_viewer);
		_viewer.addSelectionChangedListener(
				new ISelectionChangedListener() {
					public void selectionChanged(SelectionChangedEvent event) {
						fireEngineSelectionChanged();
					}
				});
		
		createColumns();
//		_viewer.setColumnProperties( new String[] {"Status", "Identifier", "Step", "Status"} );
//		_viewer.getTree().setHeaderVisible(true);
		Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT);
		_viewer.getTree().setFont(mono);
		
		// Create the help context id for the viewer's control
		PlatformUI.getWorkbench().getHelpSystem().setHelp(_viewer.getControl(), "org.eclipse.gemoc.executionframework.ui.views.engine.EngineStatusView");
			
		// register for changes in the RunningEngineRegistry
		//org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addObserver(this);
		
		buildMenu();		

		org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addEngineRegistrationListener(this);
	}
 
Example 28
Project: openaudible   File: FontShop.java   Source Code and License 5 votes vote down vote up
private Font newStyledFont(int index, int style) {

        Font f = regFonts[index];
        if (isset(f)) {
            FontData[] fontData = f.getFontData();
            fontData[0].setStyle(style);
            fontData[0].setLocale(Translate.getLocale().toString());
            return new Font(Display.getDefault(), fontData);
        } else {
            Application.report("newBold failed. f=" + f);
        }
        return null;
    }
 
Example 29
Project: neoscada   File: TreeNodeLabelProvider.java   Source Code and License 5 votes vote down vote up
public TreeNodeLabelProvider ( final TreeViewer viewer, final IObservableMap... attributeMaps )
{
    super ( attributeMaps );
    this.viewer = viewer;

    this.defaultFont = viewer.getControl ().getFont ();

    final FontData[] fds = this.viewer.getControl ().getFont ().getFontData ();
    for ( final FontData fd : fds )
    {
        fd.setStyle ( SWT.ITALIC );
    }
    this.font = new Font ( this.viewer.getControl ().getDisplay (), fds );
}
 
Example 30
Project: neoscada   File: TreeNodeLabelProvider.java   Source Code and License 5 votes vote down vote up
@Override
public Font getFont ( final Object element )
{
    final TreeNode node = (TreeNode)element;
    if ( node.isProviderSet () )
    {
        return this.defaultFont;
    }
    else
    {
        return this.font;
    }
}
 
Example 31
Project: neoscada   File: StyleBlinker.java   Source Code and License 5 votes vote down vote up
public CurrentStyle ( final Image image, final Color foreground, final Color background, final Font font )
{
    this.image = image;
    this.foreground = foreground;
    this.background = background;
    this.font = font;
}
 
Example 32
Project: neoscada   File: StyleHandler.java   Source Code and License 5 votes vote down vote up
public Style ( final Image[] images, final Color[] foregroundColor, final Color[] backgroundColor, final Font[] font )
{
    this.images = images;
    this.foregroundColor = foregroundColor;
    this.backgroundColor = backgroundColor;
    this.font = font;
}
 
Example 33
Project: convertigo-eclipse   File: ViewLabelProvider.java   Source Code and License 5 votes vote down vote up
public Font getFont(Object element) {
	if (element instanceof DatabaseObjectTreeObject) {
		DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) element;
		DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
		if (databaseObject.hasChanged) return fontModifiedDatabaseObject;
		if (databaseObjectTreeObject.isDetectedObject) return fontDetectedDatabaseObject;
	}
	return fontSystem;
}
 
Example 34
Project: convertigo-eclipse   File: CicsConnectorComposite.java   Source Code and License 5 votes vote down vote up
protected void initialize() {
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	cicsData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	cicsData.setEditable(false);
	cicsData.setBackground(new Color(null,253,253,244));
	cicsData.setFont(new Font(null,"Courier New",10,1));
	cicsData.setLayoutData(gridData);
	cicsData.setText("");
	this.setLayout(new GridLayout());
	setSize(new Point(300, 200));
}
 
Example 35
Project: codelens-eclipse   File: DefaultViewZone.java   Source Code and License 5 votes vote down vote up
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
	StyledText styledText = super.getTextViewer().getTextWidget();
	Rectangle client = styledText.getClientArea();
	gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	styledText.drawBackground(gc, paintX, paintY, client.width, super.getHeightInPx());
	gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));

	Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
	gc.setFont(font);
	gc.drawText(this.getText(), paintX, paintY + 4);
}
 
Example 36
Project: codelens-eclipse   File: StyledTextPatcher.java   Source Code and License 5 votes vote down vote up
private static Method getSetFontMethod(Object styledTextRenderer) throws NoSuchMethodException {
	// if (SET_FONT_METHOD == null) {
	Method SET_FONT_METHOD = styledTextRenderer.getClass().getDeclaredMethod("setFont",
			new Class[] { Font.class, int.class });
	SET_FONT_METHOD.setAccessible(true);
	// }
	return SET_FONT_METHOD;
}
 
Example 37
Project: eclipse-plugin-commander   File: KaviListColumns.java   Source Code and License 5 votes vote down vote up
private Font createColumnFont(final ColumnOptions<T> options, ViewerCell cell) {
	Font font = options.getFont();
	if (font == null) {
		FontDescriptor fontDescriptor = FontDescriptor.createFrom(cell.getFont()).setStyle(options.getFontStyle());
		font = fontDescriptor.createFont(cell.getControl().getDisplay());
		options.setFont(font);
	}
	return font;
}
 
Example 38
Project: pandionj   File: ValueLabel.java   Source Code and License 5 votes vote down vote up
private void setAutoFont(int size, String text, FontStyle ... styles) {
	Font f = FontManager.getFont(size, styles);
	while(FigureUtilities.getTextWidth(text, f) > PandionJConstants.POSITION_WIDTH-4 && size > 8) {
		size--;
		f = FontManager.getFont(size, styles);
	}
	setFont(f);
}
 
Example 39
Project: eclipse-plugin-commander   File: KaviList.java   Source Code and License 5 votes vote down vote up
private int averageCharacterWidth(Font font) {
	int width;
    GC gc = new GC(Display.getDefault());
    gc.setFont(font);
    FontMetrics fontMetrics = gc.getFontMetrics();
	width = fontMetrics.getAverageCharWidth();
	gc.dispose();
	return width;
}
 
Example 40
Project: openaudible   File: FontShop.java   Source Code and License 5 votes vote down vote up
private Font swapFont(Font old, Font newFont) {
    if (old == newFont)
        logger.error("font swap error.");

    if (isset(old))
        old.dispose();
    return newFont;
}
 
Example 41
Project: tap17-muggl-javaee   File: GeneratorSelectionComposite.java   Source Code and License 5 votes vote down vote up
/**
 * Set the supplied text for the provider description text widget and make its font style
 * bold.
 * @param text The text for the provider description text widget.
 */
private void setProviderLoadingFailureText(String text) {
	this.providerDescriptionText.setText(text);
	Font font = this.providerDescriptionText.getFont();
	FontData[] fontData = font.getFontData();
	fontData[0].setStyle(SWT.BOLD);
	this.providerDescriptionText.setFont(new Font(this.display, fontData));
}
 
Example 42
Project: Hydrograph   File: ParameterGridDialog.java   Source Code and License 5 votes vote down vote up
private void attachNote(final Composite container) {
	Label lblParameterGridNote=new Label(container, SWT.NONE);
	FontData fontData = lblParameterGridNote.getFont().getFontData()[0];
	Font font = new Font(lblParameterGridNote.getDisplay(), new FontData(fontData.getName(), fontData
	    .getHeight(), SWT.ITALIC));
	lblParameterGridNote.setText("Note - New parameters will be visible only after you save the job.");
	lblParameterGridNote.setFont(font);
	
	if(!visibleParameterGirdNote)
		lblParameterGridNote.setVisible(false);
}
 
Example 43
Project: Hydrograph   File: UiConverterUtil.java   Source Code and License 5 votes vote down vote up
private void adjustComponentFigure(Component component) {
	Font font = new Font( Display.getDefault(), ModelConstants.labelFont, 10,
			SWT.NORMAL );
	int labelLength = TextUtilities.INSTANCE.getStringExtents(component.getComponentLabel().getLabelContents(), font).width;
	if(labelLength >= ModelConstants.compLabelOneLineLengthLimit && component.getSize().height<96 ){
		component.setSize(new Dimension(component.getSize().width, component.getSize().height + ModelConstants.componentOneLineLabelMargin));
		ComponentLabel componentLabel = component.getComponentLabel();
		componentLabel.setSize(new Dimension(componentLabel.getSize().width, componentLabel.getSize().height + ModelConstants.componentOneLineLabelMargin));
		component.setComponentLabelMargin(ModelConstants.componentTwoLineLabelMargin);
	}
}
 
Example 44
Project: Hydrograph   File: JobRunPreferenceComposite.java   Source Code and License 5 votes vote down vote up
/**
 * Create console buffer widget
 * @param bufferSize
 */
private void createConsoleBufferWidget(String bufferSize){
	HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);
	
	hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
	hydroGroup.setLayout(new GridLayout(1, false));
	hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));
	
	Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	
	label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);
	
	textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
	textWidget.setText(bufferSize);
	textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	textWidget.setTextLimit(6);
	
	attachConsoleBufferValidator();
	
	Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	purgeComposite.setLayout(new GridLayout(2, false));
	purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
	
	Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
	FontData fontData = lblNote.getFont().getFontData()[0];
	Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
	lblNote.setFont(font);
	Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);
	
}
 
Example 45
Project: xcalendar   File: Fonts.java   Source Code and License 4 votes vote down vote up
/**
 * 
 */
public static final int getHeight(Font font) {
	return font.getFontData()[0].getHeight();
}
 
Example 46
Project: n4js   File: N4IDEXpectView.java   Source Code and License 4 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
	fillLayout.marginHeight = 5;
	fillLayout.marginWidth = 5;
	parent.setLayout(fillLayout);

	// main container
	container = new Composite(parent, SWT.BORDER);
	container.setLayout(new FillLayout());

	// create container for stack trace data
	Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);

	FormLayout formLayout = new FormLayout();
	formLayout.marginHeight = 5;
	formLayout.marginWidth = 5;
	formLayout.spacing = 5;
	stacktraceDataContainer.setLayout(formLayout);

	Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackLabelContainer.setLayout(new GridLayout());

	FormData stackLabelFormData = new FormData();
	stackLabelFormData.top = new FormAttachment(0);
	stackLabelFormData.left = new FormAttachment(0);
	stackLabelFormData.right = new FormAttachment(100);
	stackLabelFormData.bottom = new FormAttachment(20);
	stackLabelContainer.setLayoutData(stackLabelFormData);

	Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackTraceContainer.setLayout(new FillLayout());

	FormData stackTraceFormData = new FormData();
	stackTraceFormData.top = new FormAttachment(stackLabelContainer);
	stackTraceFormData.left = new FormAttachment(0);
	stackTraceFormData.right = new FormAttachment(100);
	stackTraceFormData.bottom = new FormAttachment(100);
	stackTraceContainer.setLayoutData(stackTraceFormData);

	// Create viewer for test tree in main container
	testTreeViewer = new TreeViewer(container);
	testTreeViewer.setContentProvider(new XpectContentProvider());
	testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
	testTreeViewer.setInput(null);

	// create stack trace label
	stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
	FontData fontData = stacktraceLabel.getFont().getFontData()[0];
	Display display = Display.getCurrent();
	// may be null if outside the UI thread
	if (display == null)
		display = Display.getDefault();
	Font font = new Font(display, new FontData(fontData.getName(), fontData
			.getHeight(), SWT.BOLD));
	// Make stack trace label bold
	stacktraceLabel.setFont(font);

	stacktraceLabel.setText(NO_TRACE_MSG);

	// create stack trace console
	MessageConsole messageConsole = new MessageConsole("trace", null);
	stacktraceConsole = new TraceConsole(messageConsole);
	stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);

	// context menu
	getSite().setSelectionProvider(testTreeViewer);
	MenuManager contextMenu = new MenuManager();
	contextMenu.setRemoveAllWhenShown(true);
	getSite().registerContextMenu(contextMenu, testTreeViewer);
	Control control = testTreeViewer.getControl();
	Menu menu = contextMenu.createContextMenu(control);
	control.setMenu(menu);
	activateContext();

	createSelectionActions();

}
 
Example 47
Project: xcalendar   File: Fonts.java   Source Code and License 4 votes vote down vote up
public static final Font size(Font font, int delta) {
	FontDescriptor fd = FontDescriptor.createFrom(font);
	int height = fd.getFontData()[0].getHeight() + delta;
	return fd.setHeight(height).createFont(Display.getDefault());
}
 
Example 48
Project: n4js   File: EditorContentExtractor.java   Source Code and License 4 votes vote down vote up
private Font getTextFont() {
	final ITheme theme = getWorkbench().getThemeManager().getCurrentTheme();
	return theme.getFontRegistry().get(TEXT_FONT_ID);
}
 
Example 49
Project: n4js   File: AbstractExportToSingleFileWizardPage.java   Source Code and License 4 votes vote down vote up
/**
 * Creates the export options group controls.
 */
private void createOptionsGroupButtons(Group optionsGroup) {

	Font font = optionsGroup.getFont();
	createOverwriteExisting(optionsGroup, font);
}
 
Example 50
Project: n4js   File: ExportSelectionPage.java   Source Code and License 4 votes vote down vote up
/**
 * Create the export destination specification widgets
 *
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 */
@SuppressWarnings("unused")
@Override
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("npm Target Folder");
	destinationLabel.setFont(font);

	// destination name entry field
	destinationNameField = new Combo(destinationSelectionGroup, SWT.SINGLE
			| 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);
	BidiUtils.applyBidiProcessing(destinationNameField, StructuredTextTypeHandlerFactory.FILE);

	// 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
}
 
Example 51
Project: gemoc-studio-modeldebugging   File: LaunchConfigurationMainTab.java   Source Code and License 4 votes vote down vote up
/***
 * Create the Fields where user enters model to execute
 * 
 * @param parent container composite
 * @param font used font
 * @return the created composite containing the fields
 */
public Composite createModelLayout(Composite parent, Font font) {
	createTextLabelLayout(parent, "Model to execute");
	// Model location text
	_modelLocationText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	_modelLocationText.setLayoutData(createStandardLayout());
	_modelLocationText.setFont(font);
	_modelLocationText.addModifyListener(fBasicModifyListener);
	Button modelLocationButton = createPushButton(parent, "Browse", null);
	modelLocationButton.addSelectionListener(new SelectionAdapter() {

		public void widgetSelected(SelectionEvent evt) {
			// handleModelLocationButtonSelected();
			// TODO launch the appropriate selector

			SelectAnyIFileDialog dialog = new SelectAnyIFileDialog();
			if (dialog.open() == Dialog.OK) {
				String modelPath = ((IResource) dialog.getResult()[0])
						.getFullPath().toPortableString();
				_modelLocationText.setText(modelPath);
				updateLaunchConfigurationDialog();
				_modelProject = ((IResource) dialog.getResult()[0]).getProject();
			}
		}
	});
	createTextLabelLayout(parent, "Model initialization method");
	_modelInitializationMethodText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	_modelInitializationMethodText.setLayoutData(createStandardLayout());
	_modelInitializationMethodText.setFont(font);
	_modelInitializationMethodText.setEditable(false);
	createTextLabelLayout(parent, "");
	createTextLabelLayout(parent, "Model initialization arguments");
	_modelInitializationArgumentsText = new Text(parent, SWT.MULTI | SWT.BORDER |  SWT.WRAP | SWT.V_SCROLL);
	_modelInitializationArgumentsText.setToolTipText("one argument per line");
	GridData gridData = new GridData(GridData.FILL_BOTH);
	gridData.heightHint = 40;
	_modelInitializationArgumentsText.setLayoutData(gridData);
	//_modelInitializationArgumentsText.setLayoutData(createStandardLayout());
	_modelInitializationArgumentsText.setFont(font);
	_modelInitializationArgumentsText.setEditable(true);
	_modelInitializationArgumentsText.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			updateLaunchConfigurationDialog();
		}
	});
	createTextLabelLayout(parent, "");
	
	return parent;
}
 
Example 52
Project: xcalendar   File: XCalendarTheme.java   Source Code and License 4 votes vote down vote up
public Font getFont() {
	return font;
}
 
Example 53
Project: neoscada   File: SWTGraphics.java   Source Code and License 4 votes vote down vote up
@Override
public void setFont ( final Font font )
{
    this.gc.setFont ( font );
}
 
Example 54
Project: neoscada   File: XAxisDynamicRenderer.java   Source Code and License 4 votes vote down vote up
private Font makeFont ( final ResourceManager resourceManager )
{
    return null;
}
 
Example 55
Project: neoscada   File: StyleBlinker.java   Source Code and License 4 votes vote down vote up
private void applyState ()
{
    if ( this.style == null )
    {
        update ( CurrentStyle.EMPTY );
        return;
    }

    Image image;
    if ( this.style.images == null || this.style.images.length == 0 )
    {
        image = null;
    }
    else
    {
        image = this.style.images[this.counter % this.style.images.length];
    }

    Color foreground;
    if ( this.style.foregroundColor == null || this.style.foregroundColor.length == 0 )
    {
        foreground = null;
    }
    else
    {
        foreground = this.style.foregroundColor[this.counter % this.style.foregroundColor.length];
    }

    Color background;
    if ( this.style.backgroundColor == null || this.style.backgroundColor.length == 0 )
    {
        background = null;
    }
    else
    {
        background = this.style.backgroundColor[this.counter % this.style.backgroundColor.length];
    }

    Font font;
    if ( this.style.font == null || this.style.font.length == 0 )
    {
        font = null;
    }
    else
    {
        font = this.style.font[this.counter % this.style.font.length];
    }

    update ( new CurrentStyle ( image, foreground, background, font ) );
}
 
Example 56
Project: neoscada   File: Draw2DGraphics.java   Source Code and License 4 votes vote down vote up
@Override
public void setFont ( final Font font )
{
    this.g.setFont ( font );
}
 
Example 57
Project: neoscada   File: TextComposite.java   Source Code and License 4 votes vote down vote up
public TextComposite ( final Composite parent, final int style, final DataItemDescriptor descriptor, final String format, final String decimal, final boolean isText, final String attribute, int width, int height, final boolean date, final int textHeight, final String textMap, final String hdConnectionId, final String hdItemId, final String queryString )
{
    super ( parent, style, format, decimal, isText, attribute );

    this.date = date;

    this.map = stringToMap ( textMap );

    if ( width == 0 )
    {
        width = 60;
    }
    if ( height == 0 )
    {
        height = SWT.DEFAULT;
    }

    final GridLayout layout = new GridLayout ( 3, false );

    setLayout ( layout );

    this.controlImage = new ControlImage ( this, this.registrationManager );
    Helper.createTrendButton ( this.controlImage, hdConnectionId, hdItemId, queryString );

    this.blockImage = new BlockControlImage ( this.controlImage, SWT.NONE, this.registrationManager );

    this.dataText = new CLabel ( this, SWT.MULTI | SWT.WRAP | SWT.RIGHT | SWT.SHADOW_IN );
    if ( textHeight != 0 )
    {
        // FIXME: use parent font
        this.font = new Font ( getDisplay (), new FontData ( "Arial", textHeight, 0 ) ); //$NON-NLS-1$
        this.dataText.setFont ( this.font );
    }
    final GridData data = new GridData ( SWT.FILL, SWT.CENTER, false, false );
    data.widthHint = data.minimumWidth = width;
    data.heightHint = data.minimumHeight = height;

    this.dataText.setLayoutData ( data );
    this.dataText.setEnabled ( true );
    this.dataText.setEllipsis ( "…" );
    this.dataText.setEllipsisAlignment ( SWT.END );

    this.dataText.setText ( "" ); //$NON-NLS-1$
    final DescriptorLabel label = new DescriptorLabel ( this, SWT.NONE, format, descriptor );
    final GridData labelData = new GridData ( SWT.FILL, SWT.CENTER, true, false );
    labelData.minimumWidth = 100;
    label.setLayoutData ( labelData );

    if ( descriptor != null )
    {
        this.controlImage.setDetailItem ( descriptor.asItem () );
        this.blockImage.setBlockItem ( descriptor.asItem () );
        this.registrationManager.registerItem ( "value", descriptor.getItemId (), descriptor.getConnectionInformation (), false, false ); //$NON-NLS-1$
    }
}
 
Example 58
Project: neoscada   File: ListEntry.java   Source Code and License 4 votes vote down vote up
public Font getFont ()
{
    return this.currentStyle.font;
}
 
Example 59
Project: convertigo-eclipse   File: DecoratingColumnLabelProvider.java   Source Code and License 4 votes vote down vote up
@Override
public Font getFont(Object element) {
	return provider.getFont(element);
}
 
Example 60
Project: convertigo-eclipse   File: EngineLogViewLabelProvider.java   Source Code and License 4 votes vote down vote up
public Font getFont(Object element, int columnIndex) {
	return JFaceResources.getFont(JFaceResources.TEXT_FONT);
}