List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.tm.internal.tcf.debug.ui.launch.TestErrorsDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); Label label = new Label(composite, SWT.WRAP); label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); label.setText("Connection diagnostics ended with errors:"); text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); text.setEditable(false);/* w ww .ja v a2 s. co m*/ text.setText(createText()); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = SIZING_TEXT_WIDTH; data.heightHint = SIZING_TEXT_HEIGHT; text.setLayoutData(data); return composite; }
From source file:org.eclipse.tm.internal.terminal.textcanvas.StyleMap.java
License:Open Source License
public Font getFont(Style style) { style = defaultIfNull(style);/*from www . ja va 2 s . co m*/ if (style.isBold()) { return JFaceResources.getFontRegistry().getBold(fFontName); } else if (style.isUnderline()) { return JFaceResources.getFontRegistry().getItalic(fFontName); } return JFaceResources.getFontRegistry().get(fFontName); }
From source file:org.eclipse.tm.internal.terminal.textcanvas.StyleMap.java
License:Open Source License
public Font getFont() { return JFaceResources.getFontRegistry().get(fFontName); }
From source file:org.eclipse.tm.internal.terminal.textcanvas.StyleMap.java
License:Open Source License
public void updateFont() { Display display = Display.getCurrent(); GC gc = new GC(display); if (JFaceResources.getFontRegistry().hasValueFor(fDefaultFontName)) { fFontName = fDefaultFontName;/*from w ww. java 2 s .c o m*/ } else if (JFaceResources.getFontRegistry().hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$ //try RSE Shell View Font fFontName = "REMOTE_COMMANDS_VIEW_FONT"; //$NON-NLS-1$ } else { //fall back to "basic jface text font" fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$ } gc.setFont(getFont()); fCharSize = gc.textExtent("W"); //$NON-NLS-1$ fProportional = false; for (char c = ' '; c <= '~'; c++) { // consider only the first 128 chars for deciding if a font // is proportional if (measureChar(gc, c, true)) fProportional = true; } // TODO should we also consider the upper 128 chars?? for (char c = ' ' + 128; c <= '~' + 128; c++) { measureChar(gc, c, false); } if (fProportional) { fCharSize.x -= 2; //works better on small fonts } for (int i = 0; i < fOffsets.length; i++) { fOffsets[i] = (fCharSize.x - fOffsets[i]) / 2; } if (!fProportional) { //measure font in boldface, too, and if wider then treat like proportional gc.setFont(getFont(fDefaultStyle.setBold(true))); Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$ if (fCharSize.x != charSizeBold.x) { fProportional = true; } } gc.dispose(); }
From source file:org.eclipse.tm.internal.terminal.view.TerminalView.java
License:Open Source License
public void dispose() { Logger.log("entered."); //$NON-NLS-1$ TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler); // dispose all connections ITerminalViewConnection[] conn = fMultiConnectionManager.getConnections(); for (int i = 0; i < conn.length; i++) { conn[i].getCtlTerminal().disposeTerminal(); }// w w w .j av a 2s . c o m super.dispose(); }
From source file:org.eclipse.tm.te.rcp.application.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override public Control createEmptyWindowContents(Composite parent) { final IWorkbenchWindow window = getWindowConfigurer().getWindow(); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); Display display = composite.getDisplay(); Color bgCol = display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND); composite.setBackground(bgCol);/*from w w w. j a va 2 s. c om*/ Label label = new Label(composite, SWT.WRAP); label.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); label.setBackground(bgCol); label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); String msg = Messages.ApplicationWorkbenchAdvisor_noPerspective; label.setText(msg); ToolBarManager toolBarManager = new ToolBarManager(); // TODO: should obtain the open perspective action from ActionFactory openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window); toolBarManager.add(openPerspectiveAction); ToolBar toolBar = toolBarManager.createControl(composite); toolBar.setBackground(bgCol); return composite; }
From source file:org.eclipse.tm.te.ui.swt.widgets.NoteCompositeHelper.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @see PreferencePage#createNoteComposite, this is a plain copy of that! * @param font/*w ww .j ava 2 s. com*/ * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new NoteComposite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); if (composite.getLayout() instanceof GridLayout) { layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; } messageComposite.setLayoutData(layoutData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Note: This is actually wrong but the same as in platforms // PreferencePage if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); /** * Set the controls style to FILL_HORIZONTAL making it multi-line if * needed */ layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(messageLabel, 65); messageLabel.setLayoutData(layoutData); return messageComposite; }
From source file:org.eclipse.tm.te.ui.terminals.tabs.TabFolderManager.java
License:Open Source License
/** * Setup the terminal console tab item listeners. * * @param item The tab item. Must be not <code>null</code>. *///from w ww. ja v a 2s. c o m protected void setupTerminalTabListeners(CTabItem item) { Assert.isNotNull(item); // Create and associate the disposal listener item.addDisposeListener(doCreateTerminalTabDisposeListener(this)); // Create and register the property change listener final IPropertyChangeListener propertyChangeListener = doCreateTerminalTabPropertyChangeListener(item); // Register to the JFace font registry JFaceResources.getFontRegistry().addListener(propertyChangeListener); // Remove the listener from the JFace font registry if the tab gets disposed item.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { JFaceResources.getFontRegistry().removeListener(propertyChangeListener); } }); }
From source file:org.eclipse.tm.terminal.view.ui.controls.NoteCompositeHelper.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @see PreferencePage#createNoteComposite, this is a plain copy of that! * @param font//from www. j a va 2 s .co m * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @param minCharsPerLine * the minimum number of characters per line. Defaults to '65' if less than '20'. * * @return the composite for the note */ public static Composite createNoteComposite(Font font, Composite composite, String title, String message, int minCharsPerLine) { final GC gc = new GC(composite); gc.setFont(font); Composite messageComposite = new NoteComposite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); if (composite.getLayout() instanceof GridLayout) { layoutData.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; } messageComposite.setLayoutData(layoutData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Note: This is actually wrong but the same as in platforms // PreferencePage if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); /** * Set the controls style to FILL_HORIZONTAL making it multi-line if * needed */ layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), minCharsPerLine >= 20 ? minCharsPerLine : 65); messageLabel.setLayoutData(layoutData); gc.dispose(); return messageComposite; }