List of usage examples for org.eclipse.jface.resource FontDescriptor getFontData
public FontData[] getFontData()
From source file:org.eclipse.sapphire.ui.swt.gef.model.DiagramResourceCache.java
License:Open Source License
public DiagramResourceCache() { FontDescriptor descriptor = JFaceResources.getDefaultFontDescriptor(); FontData[] fontData = descriptor.getFontData(); FontData smallerFontData = new FontData(fontData[0].getName(), fontData[0].getHeight() - 1, 0); Font defaultFont = new Font(null, new FontData[] { smallerFontData }); fonts.add(defaultFont);//from w ww . j a va2s . c o m }
From source file:org.eclipse.sirius.editor.editorPlugin.SiriusEditor.java
License:Open Source License
public static FontRegistry getFontRegistry() { if (fontRegistry == null) { fontRegistry = new FontRegistry(); FontDescriptor defaultFontDescriptor = fontRegistry.defaultFontDescriptor(); if (defaultFontDescriptor != null && defaultFontDescriptor.getFontData().length > 0) { FontData defaultFontData = defaultFontDescriptor.getFontData()[0]; FontData required = new FontData(defaultFontData.toString()); required.setStyle(SWT.BOLD); fontRegistry.put("required", new FontData[] { required }); } else {/*from w w w . j a v a 2 s. c om*/ fontRegistry.put("required", new FontData[] { new FontData("Arial", 8, SWT.BOLD) }); } // Start of user code put your own fonts here // End of user code put your own fonts here } return fontRegistry; }
From source file:org.eclipse.ui.internal.texteditor.AbstractZoomTextHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { AbstractTextEditor textEditor = getActiveTextEditor(); if (textEditor == null) { return null; }/* w ww .j a va 2 s .com*/ FontRegistry fontRegistry = textEditor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager() .getCurrentTheme().getFontRegistry(); FontData[] initialFontData = fontRegistry.getFontData(JFaceResources.TEXT_FONT); int destFontSize = initialFontData[0].getHeight() + this.fontDiff; if (destFontSize <= 0) { return null; } FontDescriptor newFontDescriptor = FontDescriptor.createFrom(initialFontData).setHeight(destFontSize); fontRegistry.put(JFaceResources.TEXT_FONT, newFontDescriptor.getFontData()); PlatformUI.getPreferenceStore().setValue(JFaceResources.TEXT_FONT, PreferenceConverter.getStoredRepresentation(newFontDescriptor.getFontData())); WorkbenchPlugin.getDefault().getPreferenceStore().setValue(JFaceResources.TEXT_FONT, PreferenceConverter.getStoredRepresentation(newFontDescriptor.getFontData())); return newFontDescriptor; }
From source file:org.eclipse.ui.tests.preferences.ZoomAndPreferencesFontTest.java
License:Open Source License
@Test public void testThemeAPIvsPreferences() { int targetHeight = 17; // Whatever > 0 and not default size/10 FontRegistry registry = editor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager() .getCurrentTheme().getFontRegistry(); FontData[] data = registry.getFontData(JFaceResources.TEXT_FONT); FontDescriptor desc = FontDescriptor.createFrom(data).setHeight(targetHeight); registry.put(JFaceResources.TEXT_FONT, desc.getFontData()); Assert.assertEquals(targetHeight, text.getFont().getFontData()[0].getHeight()); restoreAndCheckDefaults();//from w w w .ja va2 s.c o m }
From source file:org.lamport.tla.toolbox.ui.intro.ToolboxIntroPart.java
License:Open Source License
public static void createControl(Composite container) { Composite outerContainer = new Composite(container, SWT.NONE); // The local resource manager takes care of disposing images, fonts and // colors when // the outerContainer Composite is disposed. final LocalResourceManager localResourceManager = new LocalResourceManager(JFaceResources.getResources(), outerContainer);//from w w w.j a v a2s .c o m final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; outerContainer.setLayout(gridLayout); final Color backgroundColor = localResourceManager .createColor(ColorDescriptor.createFrom(new RGB(255, 255, 228))); outerContainer.setBackground(backgroundColor); /* Logo */ final Label lblImage = new Label(outerContainer, SWT.NONE); lblImage.setText("Invisible text"); final Bundle bundle = FrameworkUtil.getBundle(ToolboxIntroPart.class); final URL url = FileLocator.find(bundle, new Path("images/splash_small.bmp"), null); final ImageDescriptor logoImage = ImageDescriptor.createFromURL(url); lblImage.setImage(localResourceManager.createImage(logoImage)); /* Welcome header */ final Label lblHeader = new Label(outerContainer, SWT.WRAP); // Double its font size final FontDescriptor headerFontDescriptor = JFaceResources.getHeaderFontDescriptor(); final FontData fontData = headerFontDescriptor.getFontData()[0]; lblHeader .setFont(localResourceManager.createFont(headerFontDescriptor.setHeight(fontData.getHeight() * 2))); // Color value (taken from old style.css) lblHeader.setForeground(localResourceManager.createColor(new RGB(0, 0, 192))); lblHeader.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1)); lblHeader.setText("Welcome to the TLA\u207A Toolbox"); lblHeader.setBackground(backgroundColor); /* What is next section */ Label lblSeparator = new Label(outerContainer, SWT.NONE); lblSeparator.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); final StyledText styledWhatIsNext = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledWhatIsNext.setBackground(backgroundColor); final String whatIsnext = "There is no specification open. Click on Help if you're not sure what you should do next."; styledWhatIsNext.setText(whatIsnext); GridData gd_styledWhatIsNext = new GridData(GridData.FILL_HORIZONTAL); gd_styledWhatIsNext.horizontalAlignment = SWT.LEFT; gd_styledWhatIsNext.horizontalSpan = 2; styledWhatIsNext.setLayoutData(gd_styledWhatIsNext); StyleRange winStyle = new StyleRange(); winStyle.underline = true; winStyle.underlineStyle = SWT.UNDERLINE_LINK; int[] winRange = { whatIsnext.indexOf("Help"), "Help".length() }; StyleRange[] winStyles = { winStyle }; styledWhatIsNext.setStyleRanges(winRange, winStyles); // link styled text to getting started guide styledWhatIsNext.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); } }); /* Getting started text */ final StyledText styledGettingStarted = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledGettingStarted.setBackground(backgroundColor); final String lblString = "If this is the first time you have used the Toolbox, please read the Getting Started guide."; styledGettingStarted.setText(lblString); GridData gd_styledGettingStarted = new GridData(GridData.FILL_HORIZONTAL); gd_styledGettingStarted.horizontalAlignment = SWT.LEFT; gd_styledGettingStarted.horizontalSpan = 2; styledGettingStarted.setLayoutData(gd_styledGettingStarted); new Label(outerContainer, SWT.NONE); new Label(outerContainer, SWT.NONE); StyleRange style = new StyleRange(); style.underline = true; style.underlineStyle = SWT.UNDERLINE_LINK; int[] range = { lblString.indexOf("Getting Started"), "Getting Started".length() }; StyleRange[] styles = { style }; styledGettingStarted.setStyleRanges(range, styles); // link styled text to getting started guide styledGettingStarted.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource( "/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); } }); /* Toolbox version */ final Label verticalFillUp = new Label(outerContainer, SWT.NONE); verticalFillUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1)); verticalFillUp.setBackground(backgroundColor); final Label horizontalLine = new Label(outerContainer, SWT.SEPARATOR | SWT.HORIZONTAL); horizontalLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); final Label lblVersion = new Label(outerContainer, SWT.WRAP); lblVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblVersion.setText("Version 1.5.4 of 06 October 2017"); lblVersion.setBackground(backgroundColor); }
From source file:org.lamport.tla.toolbox.ui.view.ToolboxWelcomeView.java
License:Open Source License
public static void createControl(Composite container) { Composite outerContainer = new Composite(container, SWT.NONE); // The local resource manager takes care of disposing images, fonts and colors when // the outerContainer Composite is disposed. final LocalResourceManager localResourceManager = new LocalResourceManager(JFaceResources.getResources(), outerContainer);/*w w w.j av a2s . c o m*/ final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; outerContainer.setLayout(gridLayout); final Color backgroundColor = localResourceManager .createColor(ColorDescriptor.createFrom(new RGB(255, 255, 228))); outerContainer.setBackground(backgroundColor); /* Logo */ final Label lblImage = new Label(outerContainer, SWT.NONE); lblImage.setText("Invisible text"); final Bundle bundle = FrameworkUtil.getBundle(ToolboxWelcomeView.class); final URL url = FileLocator.find(bundle, new Path("images/splash_small.bmp"), null); final ImageDescriptor logoImage = ImageDescriptor.createFromURL(url); lblImage.setImage(localResourceManager.createImage(logoImage)); /* Welcome header */ final Label lblHeader = new Label(outerContainer, SWT.WRAP); // Double its font size final FontDescriptor headerFontDescriptor = JFaceResources.getHeaderFontDescriptor(); final FontData fontData = headerFontDescriptor.getFontData()[0]; lblHeader .setFont(localResourceManager.createFont(headerFontDescriptor.setHeight(fontData.getHeight() * 2))); // Color value (taken from old style.css) lblHeader.setForeground(localResourceManager.createColor(new RGB(0, 0, 192))); lblHeader.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1)); lblHeader.setText("Welcome to the TLA\u207A Toolbox"); lblHeader.setBackground(backgroundColor); /* What is next section */ Label lblSeparator = new Label(outerContainer, SWT.NONE); lblSeparator.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); final StyledText styledWhatIsNext = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledWhatIsNext.setBackground(backgroundColor); final String whatIsnext = "There is no specification open. Click on Help if you're not sure what you should do next."; styledWhatIsNext.setText(whatIsnext); GridData gd_styledWhatIsNext = new GridData(GridData.FILL_HORIZONTAL); gd_styledWhatIsNext.horizontalAlignment = SWT.LEFT; gd_styledWhatIsNext.horizontalSpan = 2; styledWhatIsNext.setLayoutData(gd_styledWhatIsNext); StyleRange winStyle = new StyleRange(); winStyle.underline = true; winStyle.underlineStyle = SWT.UNDERLINE_LINK; int[] winRange = { whatIsnext.indexOf("Help"), "Help".length() }; StyleRange[] winStyles = { winStyle }; styledWhatIsNext.setStyleRanges(winRange, winStyles); // link styled text to getting started guide styledWhatIsNext.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); } }); // Composite composite = new Composite(outerContainer, SWT.NONE); // composite.setLayout(new GridLayout(2, false)); // composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1)); //SWT.FILL, SWT.CENTER, false, false, 2, 1)); /* Getting started text */ final StyledText styledGettingStarted = new StyledText(outerContainer, SWT.WRAP | SWT.CENTER); styledGettingStarted.setBackground(backgroundColor); final String lblString = "If this is the first time you have used the Toolbox, please read the Getting Started guide."; styledGettingStarted.setText(lblString); GridData gd_styledGettingStarted = new GridData(GridData.FILL_HORIZONTAL); gd_styledGettingStarted.horizontalAlignment = SWT.LEFT; gd_styledGettingStarted.horizontalSpan = 2; styledGettingStarted.setLayoutData(gd_styledGettingStarted); new Label(outerContainer, SWT.NONE); new Label(outerContainer, SWT.NONE); StyleRange style = new StyleRange(); style.underline = true; style.underlineStyle = SWT.UNDERLINE_LINK; int[] range = { lblString.indexOf("Getting Started"), "Getting Started".length() }; StyleRange[] styles = { style }; styledGettingStarted.setStyleRanges(range, styles); // link styled text to getting started guide styledGettingStarted.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); helpSystem.displayHelpResource( "/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); } }); // This shows a help button next to the styled text // final Button helpButton = new Button(composite, SWT.PUSH); // helpButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); // helpButton.setSize(36, 36); // helpButton.setText (""); // helpButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP)); // helpButton.addListener (SWT.Selection, new Listener () { // public void handleEvent (Event event) { // IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); //// helpSystem.displayHelp("org.lamport.tla.toolbox.GettingStarted"); //// helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/contents.html"); // helpSystem.displayHelpResource("/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); // } // }); /* Toolbox version */ final Label verticalFillUp = new Label(outerContainer, SWT.NONE); verticalFillUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1)); verticalFillUp.setBackground(backgroundColor); final Label horizontalLine = new Label(outerContainer, SWT.SEPARATOR | SWT.HORIZONTAL); horizontalLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); final Label lblVersion = new Label(outerContainer, SWT.WRAP); lblVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblVersion.setText("Version 1.5.1 of UNRELEASED"); lblVersion.setBackground(backgroundColor); }
From source file:org.talend.updates.runtime.ui.feature.form.AbstractFeatureForm.java
License:Open Source License
protected Font getInstallButtonFont() { final String installBtnFontKey = AbstractFeatureListInfoItem.class.getName() + ".installButtonFont"; //$NON-NLS-1$ FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(installBtnFontKey)) { FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont()) .setStyle(SWT.BOLD);/* www . ja v a 2 s. com*/ fontRegistry.put(installBtnFontKey, fontDescriptor.getFontData()); } return fontRegistry.get(installBtnFontKey); }
From source file:org.talend.updates.runtime.ui.feature.form.FeaturesUpdatesNotificationForm.java
License:Open Source License
private Font getTitleFont() { final String titleFontKey = this.getClass().getName() + ".titleFont"; //$NON-NLS-1$ FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(titleFontKey)) { FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont()).setHeight(12) .setStyle(SWT.BOLD);//from w w w. j av a2 s. c om fontRegistry.put(titleFontKey, fontDescriptor.getFontData()); } return fontRegistry.get(titleFontKey); }
From source file:org.talend.updates.runtime.ui.feature.form.FeaturesUpdatesNotificationForm.java
License:Open Source License
private Font getInstallButtonFont() { final String installBtnFontKey = this.getClass().getName() + ".installButtonFont"; //$NON-NLS-1$ FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(installBtnFontKey)) { FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont()) .setStyle(SWT.BOLD);/*from w w w. j a v a 2 s.co m*/ fontRegistry.put(installBtnFontKey, fontDescriptor.getFontData()); } return fontRegistry.get(installBtnFontKey); }
From source file:org.talend.updates.runtime.ui.feature.form.item.AbstractControlListItem.java
License:Open Source License
protected Font getTitleFont() { final String titleFontKey = AbstractControlListItem.class.getName() + ".titleFont"; //$NON-NLS-1$ FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(titleFontKey)) { FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont()).setHeight(12) .setStyle(SWT.BOLD);//www.j a v a 2 s .com fontRegistry.put(titleFontKey, fontDescriptor.getFontData()); } return fontRegistry.get(titleFontKey); }