List of usage examples for org.eclipse.jface.resource JFaceResources BANNER_FONT
String BANNER_FONT
To view the source code for org.eclipse.jface.resource JFaceResources BANNER_FONT.
Click Source Link
"org.eclipse.jface.bannerfont"
). From source file:org.eclipse.tcf.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//from ww w .ja v a 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) { 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, minCharsPerLine >= 20 ? minCharsPerLine : 65); messageLabel.setLayoutData(layoutData); return messageComposite; }
From source file:org.eclipse.team.internal.ui.dialogs.PreferencePageContainerDialog.java
License:Open Source License
/** * Creates the dialog's title area./*from ww w . java 2 s.c om*/ * * @param parent the SWT parent for the title area composite * @return the created title area composite */ private Composite createMessageArea(Composite parent) { // Create the title area which will contain // a title, message, and image. fTitleArea = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; layout.numColumns = 2; // Get the colors for the title area Display display = parent.getDisplay(); Color bg = JFaceColors.getBannerBackground(display); Color fg = JFaceColors.getBannerForeground(display); GridData layoutData = new GridData(GridData.FILL_BOTH); fTitleArea.setLayout(layout); fTitleArea.setLayoutData(layoutData); fTitleArea.setBackground(bg); // Message label fMessageLabel = new CLabel(fTitleArea, SWT.LEFT); fMessageLabel.setBackground(bg); fMessageLabel.setForeground(fg); fMessageLabel.setText(" ");//$NON-NLS-1$ fMessageLabel.setFont(JFaceResources.getBannerFont()); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty()) || JFaceResources.DIALOG_FONT.equals(event.getProperty())) { updateMessage(); } } }; fMessageLabel.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); JFaceResources.getFontRegistry().addListener(fontListener); GridData gd = new GridData(GridData.FILL_BOTH); fMessageLabel.setLayoutData(gd); // Title image fTitleImage = new Label(fTitleArea, SWT.LEFT); fTitleImage.setBackground(bg); fTitleImage.setImage(TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_TITLE_IMG)); gd = new GridData(); gd.horizontalAlignment = GridData.END; fTitleImage.setLayoutData(gd); updateMessage(); return fTitleArea; }
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);/*from w w w .j a v a 2 s. c o 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.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/*from w w w .ja va2 s .c o m*/ * 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.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 ww w .j av a 2s. c o 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; }
From source file:org.jboss.tools.jst.css.dialog.tabs.BaseTabControl.java
License:Open Source License
/** * //from ww w . ja v a 2 s. c o m * @param parent * @param label */ protected Label addSectionLabel(Composite parent, String label) { Label labelControl = new Label(parent, SWT.NONE); labelControl.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); labelControl.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); labelControl.setText(label); return labelControl; }
From source file:org.mailster.gui.prefs.ConfigurationDialog.java
License:Open Source License
/** * Creates the wizard's title area./* w ww. j a v a 2s .com*/ * * @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 contai a title, message, and image. */ int margins = 2; Composite titleArea = new Composite(parent, SWT.NONE); FormLayout layout = new FormLayout(); layout.marginHeight = 5; layout.marginWidth = margins; titleArea.setLayout(layout); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.verticalAlignment = SWT.TOP; titleArea.setLayoutData(layoutData); /* Message label */ this.messageArea = new DialogMessageArea(); this.messageArea.createContents(titleArea); titleArea.addControlListener(new ControlAdapter() { /** * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ 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); this.messageArea.setTitleLayoutData(this.createMessageAreaData()); this.messageArea.setMessageLayoutData(this.createMessageAreaData()); return (titleArea); }
From source file:org.netxms.ui.eclipse.objectview.widgets.ObjectStatusMap.java
License:Open Source License
/** * @param parent/*w w w . ja v a 2 s .c o m*/ * @param style */ public ObjectStatusMap(IViewPart viewPart, Composite parent, int style) { super(parent, style | SWT.V_SCROLL); initDetailsProviders(); this.viewPart = viewPart; session = (NXCSession) ConsoleSharedData.getSession(); final SessionListener sessionListener = new SessionListener() { @Override public void notificationHandler(SessionNotification n) { if (n.getCode() == SessionNotification.OBJECT_CHANGED) onObjectChange((AbstractObject) n.getObject()); else if (n.getCode() == SessionNotification.OBJECT_DELETED) onObjectDelete(n.getSubCode()); } }; session.addListener(sessionListener); addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { session.removeListener(sessionListener); } }); setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, getDisplay())); setExpandHorizontal(true); setExpandVertical(true); addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle r = getClientArea(); setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT)); } }); dataArea = new Composite(this, SWT.NONE); setContent(dataArea); GridLayout layout = new GridLayout(); layout.verticalSpacing = 10; dataArea.setLayout(layout); dataArea.setBackground(getBackground()); titleFont = JFaceResources.getFontRegistry().getBold(JFaceResources.BANNER_FONT); menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); }
From source file:org.org.eclipse.core.utils.platform.dialogs.input.AbstractInputTrayDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout);/*ww w . ja v a2 s . c om*/ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); applyDialogFont(composite); if (title != null) { Composite titleContainer = new Composite(composite, SWT.NONE); titleContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); titleContainer.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); titleContainer.setLayout(new GridLayout(1, false)); Label nameLabel = new Label(titleContainer, SWT.NONE); nameLabel.setText(title); nameLabel.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); nameLabel.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); nameLabel.setForeground(JFaceColors.getBannerForeground(this.getShell().getDisplay())); nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } Composite fieldsContainer = new Composite(composite, SWT.BORDER); fieldsContainer.setLayout(new GridLayout(numColumns, false)); fieldsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Composite validationMessageContainer = new Composite(composite, SWT.BORDER); validationMessageContainer.setLayout(new GridLayout(1, false)); validationMessageContainer.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); validationMessageContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); validationMessageLabel = new Text(validationMessageContainer, SWT.MULTI | SWT.READ_ONLY); validationMessageLabel.setText(""); validationMessageLabel.setForeground(JFaceColors.getErrorText(this.getShell().getDisplay())); validationMessageLabel.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); validationMessageLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); return fieldsContainer; }
From source file:org.org.eclipse.core.utils.platform.dialogs.message.AbstractMessageAndButtonDialog.java
License:Open Source License
/** * Create the area the message will be shown in. * /* ww w. j a v a 2 s. c o m*/ * @param parent * The composite to parent from. * @return Control */ protected Control createMessageArea(Composite parent) { // create composite Composite messageAreaContainer = new Composite(parent, SWT.NULL); messageAreaContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); messageAreaContainer.setLayout(new GridLayout(2, false)); if (subTitle != null) { Composite titleContainer = new Composite(messageAreaContainer, SWT.BORDER); titleContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false, 2, 1)); titleContainer.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); titleContainer.setLayout(new GridLayout(1, false)); Label nameLabel = new Label(titleContainer, SWT.NONE); nameLabel.setText(subTitle); nameLabel.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); nameLabel.setBackground(JFaceColors.getBannerBackground(this.getShell().getDisplay())); nameLabel.setForeground(JFaceColors.getBannerForeground(this.getShell().getDisplay())); nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); } // create image Image image = getImage(); if (image != null) { imageLabel = new Label(messageAreaContainer, SWT.BORDER | SWT.FLAT); image.setBackground(imageLabel.getBackground()); imageLabel.setImage(image); imageLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); } // create message if (message != null) { ScrolledComposite scrolledComposite = new ScrolledComposite(messageAreaContainer, SWT.BORDER | SWT.FLAT | SWT.V_SCROLL | SWT.H_SCROLL); scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); scrolledComposite.setLayout(new GridLayout(1, false)); FormToolkit formToolkit = new FormToolkit(scrolledComposite.getDisplay()); messageLabel = formToolkit.createFormText(scrolledComposite, true); messageLabel.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { try { PlatformUI.getWorkbench().getBrowserSupport() .createBrowser(IWorkbenchBrowserSupport.AS_VIEW, "myId", null, null).openURL( //$NON-NLS-1$ new URL((String) e.data)); } catch (MalformedURLException ex) { // forget it... we can't do anything about it... } catch (PartInitException ex) { // forget it... we don't want to do anything about it...yet ;) } } public void linkExited(HyperlinkEvent e) { } public void linkEntered(HyperlinkEvent e) { } }); message = message.replaceAll("&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll("<", "<"); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll(">", ">"); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll("\n", "<br/>"); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll("\f", "<br/>"); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll("\r", "<br/>"); //$NON-NLS-1$ //$NON-NLS-2$ message = "<p>" + message + "</p>"; //$NON-NLS-1$ //$NON-NLS-2$ messageLabel.setText(message, true, true); messageLabel.setWhitespaceNormalized(false); GridData data = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); messageLabel.setLayoutData(data); messageLabel.setBackground(JFaceColors.getBannerBackground(scrolledComposite.getDisplay())); scrolledComposite.setContent(messageLabel); scrolledComposite.setExpandVertical(true); scrolledComposite.setExpandHorizontal(true); getShell().layout(true); } return parent; }