List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:net.refractions.udig.mapgraphic.style.FontStyleConfigurator.java
License:Open Source License
@Override public void createControl(Composite parent) { GridLayout gridLayout = new GridLayout(); int columns = 1; gridLayout.numColumns = columns;// w ww . j a v a2 s . c o m parent.setLayout(gridLayout); Composite group = new Composite(parent, SWT.NONE); group.setLayoutData(new GridData(GridData.FILL_BOTH)); group.setLayout(new GridLayout(2, false)); label = new Text(group, SWT.BORDER | SWT.WRAP); if (swtFont != null) { label.setFont(swtFont); } // This text is formally random :-) http://en.wikipedia.org/wiki/Lorem_ipsum label.setText( "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_BOTH)); final Button button = new Button(group, SWT.PUSH); button.setText(Messages.Font_ExampleText); button.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { final FontDialog dialog = new FontDialog(button.getShell()); // setup default font IBlackboard blackboard = getStyleBlackboard(); FontStyle fontStyle = (FontStyle) blackboard.get(FontStyleContent.ID); if (fontStyle != null) { Font f = fontStyle.getFont(); FontData[] fd = AWTSWTImageUtils.awtFontToSwt(f, JFaceResources.getFontRegistry()) .getFontData(); dialog.setFontList(fd); } // show dialog and get results FontData result = dialog.open(); if (result != null) { Font awtfont = AWTSWTImageUtils.swtFontToAwt(result); fontStyle.setFont(awtfont); swtFont = AWTSWTImageUtils.awtFontToSwt(awtfont, JFaceResources.getFontRegistry()); label.setFont(swtFont); label.setText(label.getText()); } } }); }
From source file:net.refractions.udig.mapgraphic.style.FontStyleConfigurator.java
License:Open Source License
@Override protected void refresh() { FontStyle fontStyle = (FontStyle) getStyleBlackboard().get(FontStyleContent.ID); if (fontStyle.getFont() != null) { swtFont = AWTSWTImageUtils.awtFontToSwt(fontStyle.getFont(), JFaceResources.getFontRegistry()); if (label != null) { label.setFont(swtFont);// www . j a va 2 s. co m } } }
From source file:net.refractions.udig.project.ui.internal.PaletteCombo.java
License:Open Source License
/** * @param window//from w w w .j a v a 2s. c om * @return */ protected Point computeImageSize(Control window) { GC gc = new GC(window); Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); gc.setFont(f); int height = gc.getFontMetrics().getHeight(); gc.dispose(); Point p = new Point(height * 3 - 6, height); return p; }
From source file:net.refractions.udig.style.sld.editor.internal.EditorDialog.java
License:Open Source License
/** * Creates the wizard's title area.//from ww w . j ava 2 s . c om * * @param parent * the SWT parent for the title area composite. * @return the created title area composite. */ protected Composite createTitleArea(Composite parent) { // Create the title area which will contain // a title, message, and image. int margins = 2; titleArea = new Composite(parent, SWT.NONE); FormLayout layout = new FormLayout(); layout.marginHeight = 0; layout.marginWidth = margins; titleArea.setLayout(layout); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.verticalAlignment = SWT.TOP; titleArea.setLayoutData(layoutData); // Message label messageArea = new DialogMessageArea(); messageArea.createContents(titleArea); titleArea.addControlListener(new ControlAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ @Override public void controlResized(ControlEvent e) { updateMessage(); } }); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) updateMessage(); if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) { updateMessage(); Font dialogFont = JFaceResources.getDialogFont(); updateTreeFont(dialogFont); Control[] children = ((Composite) buttonBar).getChildren(); for (int i = 0; i < children.length; i++) children[i].setFont(dialogFont); } } }; titleArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); JFaceResources.getFontRegistry().addListener(fontListener); messageArea.setTitleLayoutData(createMessageAreaData()); messageArea.setMessageLayoutData(createMessageAreaData()); return titleArea; }
From source file:net.resheim.eclipse.launcher.macosx.LaunchOptionsDialog.java
License:Open Source License
/** * Creates UI for allowing the user to enforce normal size fonts * * @param parent// ww w. j ava2s . co m * the root container */ private void createFontGroup(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridData gd_container = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); gd_container.horizontalIndent = -6; container.setLayoutData(gd_container); GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 0; container.setLayout(layout); // Button for disabling font size reduction final Button button = new Button(container, SWT.CHECK); button.setText(Messages.LaunchOptionsDialog_8); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { disableSmallFonts = button.getSelection(); } }); button.setSelection(false); Label label = new Label(container, SWT.NONE); label.setText(Messages.LaunchOptionsDialog_9); label.setFont(JFaceResources.getFontRegistry().getItalic("")); //$NON-NLS-1$ // Button for disabling font size reduction final Button button2 = new Button(container, SWT.CHECK); button2.setText(Messages.LaunchOptionsDialog_10); button2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { clean = button2.getSelection(); } }); button.setSelection(false); Label label2 = new Label(container, SWT.NONE); label2.setText("-clean"); //$NON-NLS-1$ label2.setFont(JFaceResources.getFontRegistry().getItalic("")); //$NON-NLS-1$ }
From source file:net.sf.colorer.eclipse.editors.ColorerEditor.java
License:LGPL
public ColorerEditor() { super();/*from w w w . jav a2 s .c o m*/ ColorerPlugin.getDefault().addReloadListener(fReloadListener); prefStore = ColorerPlugin.getDefault().getCombinedPreferenceStore(); prefStore.addPropertyChangeListener(this); JFaceResources.getFontRegistry().addListener(this); fTextColorer = new TextColorer(this); fColorerSVC = new ColorerSourceViewerConfiguration(fTextColorer); setSourceViewerConfiguration(fColorerSVC); }
From source file:net.sf.colorer.eclipse.editors.ColorerEditor.java
License:LGPL
public void dispose() { detachBaseEditor();/* w ww . j av a 2 s. c o m*/ prefStore.removePropertyChangeListener(this); JFaceResources.getFontRegistry().removeListener(this); ColorerPlugin.getDefault().removeReloadListener(fReloadListener); super.dispose(); }
From source file:net.sf.eclipsefp.haskell.ui.internal.views.worksheet.EvalComposite.java
License:Open Source License
public EvalComposite(final WorkSheetViewPage page, final EvalExpression expression) { super(page.getMainComposite(), SWT.NONE); this.page = page; this.expression = expression; GridLayout gl = new GridLayout(3, false); this.setLayout(gl); final Text lExpr = new Text(this, SWT.WRAP | SWT.MULTI); lExpr.setEditable(false);// www . ja v a 2s . co m lExpr.setBackground(getBackground()); lExpr.setFont(JFaceResources.getFontRegistry().getItalic(lExpr.getFont().getFontData()[0].getName())); GridData gdExpr = new GridData(GridData.FILL_HORIZONTAL); gdExpr.horizontalSpan = 2; gdExpr.widthHint = getBounds().width - 20; lExpr.setLayoutData(gdExpr); lExpr.setText(getExpression()); ToolBar tb = new ToolBar(this, SWT.FLAT); ToolItem tiRemove = new ToolItem(tb, SWT.PUSH); tiRemove.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE)); tiRemove.setToolTipText(UITexts.worksheet_removeexpression_tooltip); lResultIcon = new Label(this, SWT.NONE); lResultIcon.setBackground(getBackground()); lResultIcon.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); dblListener = new MouseAdapter() { @Override public void mouseDoubleClick(final MouseEvent event) { EvalExpressionDialog id = new EvalExpressionDialog(getShell(), UITexts.worksheet_editexpression_title, UITexts.worksheet_addexpression_message, expression); if (id.open() == Window.OK) { expression.setExpression(id.getValue()); expression.setResultType(id.getResultType()); expression.setLastResult(null); lExpr.setText(getExpression()); page.save(); page.eval(); } } }; buildEmptyControl(); tiRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final org.eclipse.swt.events.SelectionEvent arg0) { String msg = NLS.bind(UITexts.worksheet_removeexpression_message, expression.getExpression()); if (MessageDialog.openConfirm(getShell(), UITexts.worksheet_removeexpression_title, msg)) { page.remove(EvalComposite.this); } } }); lExpr.addMouseListener(dblListener); lResultIcon.addMouseListener(dblListener); this.addMouseListener(dblListener); setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); }
From source file:net.sf.eclipsensis.console.NSISConsole.java
License:Open Source License
@Override protected void init() { super.init(); Display.getDefault().asyncExec(new Runnable() { public void run() { JFaceResources.getColorRegistry().addListener(NSISConsole.this); JFaceResources.getFontRegistry().addListener(NSISConsole.this); initializeStreams();/*w w w . ja va2 s . com*/ dump(); } }); }
From source file:net.sf.eclipsensis.console.NSISConsole.java
License:Open Source License
private void initializeStreams() { synchronized (mPending) { if (!mInitialized) { mInfoStream = new NSISConsoleOutputStream(this); mErrorStream = new NSISConsoleOutputStream(this); mWarningStream = new NSISConsoleOutputStream(this); // install colors mInfoColor = createColor(CONSOLE_INFO_COLOR); mInfoStream.setColor(mInfoColor); mWarningColor = createColor(CONSOLE_WARNING_COLOR); mWarningStream.setColor(mWarningColor); mErrorColor = createColor(CONSOLE_ERROR_COLOR); mErrorStream.setColor(mErrorColor); // install font Font f = JFaceResources.getFontRegistry().get(CONSOLE_FONT); setFont(f);//from ww w.j a v a 2 s. c o m mInitialized = true; } } }