List of usage examples for org.eclipse.jface.resource JFaceResources getDefaultFont
public static Font getDefaultFont()
From source file:org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { // Create a font for titles in the tooltips FontData[] defaultFont = JFaceResources.getDefaultFont().getFontData(); FontData boldFontData = new FontData(defaultFont[0].getName(), defaultFont[0].getHeight(), SWT.BOLD); tooltipHeading = new Font(parent.getDisplay(), boldFontData); Composite composite = (Composite) super.createDialogArea(parent); // tab folder tabFolder = new TabFolder(composite, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = convertHorizontalDLUsToPixels(TAB_WIDTH_IN_DLUS); gd.heightHint = convertVerticalDLUsToPixels(TAB_HEIGHT_IN_DLUS); tabFolder.setLayoutData(gd);//from w ww . j a v a2 s . c o m // Tool Bar Item Hiding Page TabItem tab = new TabItem(tabFolder, SWT.NONE); tab.setText(WorkbenchMessages.HideToolBarItems_toolBarItemsTab); tab.setControl(createToolBarVisibilityPage(tabFolder)); // Menu Item Hiding Page tab = new TabItem(tabFolder, SWT.NONE); tab.setControl(createMenuVisibilityPage(tabFolder)); tab.setText(WorkbenchMessages.HideMenuItems_menuItemsTab); // Action Set Availability Page actionSetTab = new TabItem(tabFolder, SWT.NONE); actionSetTab.setText(WorkbenchMessages.ActionSetSelection_actionSetsTab); actionSetTab.setControl(createActionSetAvailabilityPage(tabFolder)); // Shortcuts Page if (showShortcutTab()) { TabItem item1 = new TabItem(tabFolder, SWT.NONE); item1.setText(WorkbenchMessages.Shortcuts_shortcutTab); item1.setControl(createShortCutsPage(tabFolder)); } applyDialogFont(tabFolder); return composite; }
From source file:org.eclipse.ui.internal.intro.impl.FontSelection.java
License:Open Source License
private static int getDefaultFontHeight() { Font defaultFont = JFaceResources.getDefaultFont(); FontData[] fontData = defaultFont.getFontData(); int height = MIN_HEIGHT; for (int i = 0; i < fontData.length; i++) { FontData data = fontData[i];/*w w w. j a v a 2 s. co m*/ height = Math.max(height, data.getHeight()); } return Math.min(height, MAX_HEIGHT); }
From source file:org.eclipse.ui.internal.progress.DetailedProgressViewer.java
License:Open Source License
/** * Create a new instance of the receiver with a control that is a child of * parent with style style.//from www.j a va2s . c o m * * @param parent * @param style */ public DetailedProgressViewer(Composite parent, int style) { scrolled = new ScrolledComposite(parent, SWT.V_SCROLL | style); int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); scrolled.getVerticalBar().setIncrement(height * 2); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); control = new Composite(scrolled, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; control.setLayout(layout); control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.addFocusListener(new FocusAdapter() { private boolean settingFocus = false; /* * (non-Javadoc) * * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) { if (!settingFocus) { // Prevent new focus events as a result this update // occurring settingFocus = true; setFocus(); settingFocus = false; } } }); control.addControlListener(new ControlListener() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) */ public void controlMoved(ControlEvent e) { updateVisibleItems(); } /* * (non-Javadoc) * * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) */ public void controlResized(ControlEvent e) { updateVisibleItems(); } }); PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IWorkbenchHelpContextIds.RESPONSIVE_UI); scrolled.setContent(control); hookControl(control); noEntryArea = new Composite(scrolled, SWT.NONE); noEntryArea.setLayout(new GridLayout()); Text noEntryLabel = new Text(noEntryArea, SWT.SINGLE); noEntryLabel.setText(ProgressMessages.ProgressView_NoOperations); noEntryLabel.setBackground(noEntryArea.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); GridData textData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); noEntryLabel.setLayoutData(textData); noEntryLabel.setEditable(false); PlatformUI.getWorkbench().getHelpSystem().setHelp(noEntryLabel, IWorkbenchHelpContextIds.RESPONSIVE_UI); }
From source file:org.eclipse.ui.internal.themes.ColorsAndFontsPreferencePage.java
License:Open Source License
/** * Hook all control listeners./*from www. j a v a 2 s.com*/ */ private void hookListeners() { TreeViewer viewer = tree.getViewer(); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateTreeSelection(event.getSelection()); } }); fontChangeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Display display = event.display; if (isFontSelected()) editFont(display); else if (isColorSelected()) editColor(display); updateControls(); } }); fontResetButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (isFontSelected()) resetFont(getSelectedFontDefinition(), false); else if (isColorSelected()) resetColor(getSelectedColorDefinition(), false); updateControls(); } }); fontSystemButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDefinition definition = getSelectedFontDefinition(); if (definition == null) return; FontData[] defaultFontData = JFaceResources.getDefaultFont().getFontData(); setFontPreferenceValue(definition, defaultFontData); updateControls(); } }); editDefaultButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Display display = event.display; FontDefinition fontDefinition = getSelectedFontDefinition(); if (fontDefinition != null) { String defaultFontId = fontDefinition.getDefaultsTo(); FontDefinition defaultFontDefinition = themeRegistry.findFont(defaultFontId); editFont(defaultFontDefinition, display); } else { ColorDefinition colorDefinition = getSelectedColorDefinition(); if (colorDefinition != null) { String defaultColorId = colorDefinition.getDefaultsTo(); ColorDefinition defaultColorDefinition = themeRegistry.findColor(defaultColorId); editColor(defaultColorDefinition, display); } } updateControls(); } }); goToDefaultButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDefinition fontDefinition = getSelectedFontDefinition(); if (fontDefinition != null) { String defaultFontId = fontDefinition.getDefaultsTo(); FontDefinition defaultFontDefinition = themeRegistry.findFont(defaultFontId); selectAndReveal(defaultFontDefinition); } else { ColorDefinition colorDefinition = getSelectedColorDefinition(); if (colorDefinition != null) { String defaultColorId = colorDefinition.getDefaultsTo(); ColorDefinition defaultColorDefinition = themeRegistry.findColor(defaultColorId); selectAndReveal(defaultColorDefinition); } } updateControls(); } }); }
From source file:org.eclipsercp.hyperbola.presentation.PartTab.java
License:Open Source License
public void paintControl(PaintEvent e) { Rectangle titleRect = getClientArea(); int x = titleRect.x + VERT_SPACING; GC gc = e.gc;/* www .j av a2s. c o m*/ setBackground(getParent().getBackground()); fill(gc, titleRect.x, titleRect.y, titleRect.width - 1, titleRect.height); Image image = getImage(); if (image != null && showImage) { Rectangle imageBounds = image.getBounds(); int imageX = x; int imageHeight = imageBounds.height; int imageY = (titleRect.height - imageHeight) / 2; int imageWidth = imageBounds.width * imageHeight / imageBounds.height; gc.drawImage(image, imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, imageX, imageY, imageWidth, imageHeight); x += imageWidth + VERT_SPACING; } int textWidth = titleRect.width - 1; if (textWidth > 0 && text != null && showText) { gc.setFont(getFont()); Point extent = gc.textExtent(text, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC); int textY = titleRect.y + (titleRect.height - extent.y) / 2; if (selected) gc.setForeground(e.display.getSystemColor(SWT.COLOR_BLACK)); else gc.setForeground(e.display.getSystemColor(SWT.COLOR_DARK_GRAY)); gc.setFont(JFaceResources.getDefaultFont()); gc.drawText(text, x, textY, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC); } }
From source file:org.gumtree.widgets.swt.util.UIResources.java
License:Open Source License
public static Font getDefaultFont() { return JFaceResources.getDefaultFont(); }
From source file:org.gumtree.workflow.ui.viewer2.WorkflowComposerViewer.java
License:Open Source License
protected void createUI() { /********************************************************************* * Initialise/*from w ww. ja va2 s .c o m*/ *********************************************************************/ c = new UIContext(); c.resourceManager = new UIResourceManager(Activator.PLUGIN_ID, this); c.defaultFont = JFaceResources.getDefaultFont(); c.largeBold = c.resourceManager.createDefaultFont(10, SWT.BOLD); c.headerFont = c.resourceManager.createRelativeFont(c.defaultFont, 3, SWT.BOLD); taskUIContexts = new HashMap<ITask, TaskUIContext>(); /********************************************************************* * Setup listeners *********************************************************************/ workfloEventHandler = new IEventHandler<WorkflowEvent>() { public void handleEvent(WorkflowEvent event) { // Re-render on workflow structural change if (event instanceof WorkflowStructuralEvent) { SafeUIRunner.asyncExec(new SafeRunnable() { public void run() throws Exception { // if (isDisposed()) { // return; // } // renderUI(); syncWorkflowUI(); } }); } } }; getWorkflow().addEventListener(workfloEventHandler); taskEventHandler = new IEventHandler<TaskEvent>() { // Update task status public void handleEvent(final TaskEvent event) { SafeUIRunner.asyncExec(new SafeRunnable() { public void run() throws Exception { if (isDisposed()) { return; } if (event.getState() == TaskState.UPDATED) { updateTitle(event.getPublisher()); } else { updateTaskState(event); } } }); } }; taskViewEventHandler = new IEventHandler<TaskViewEvent>() { public void handleEvent(TaskViewEvent event) { // Refresh task SafeUIRunner.asyncExec(new SafeRunnable() { public void run() throws Exception { if (c == null || isDisposed()) { return; } if (c.form != null && !c.form.isDisposed()) { c.form.layout(true, true); c.form.reflow(true); } } }); } }; /********************************************************************* * Draw widget *********************************************************************/ renderUI(); }
From source file:org.jboss.tools.central.editors.GettingStartedPage.java
License:Open Source License
private void showEntries(List<FeedsEntry> entries, Composite composite, PageBook pageBook, ScrolledComposite scrollable) {//w w w . j av a 2 s .c om int i = 0; disposeChildren(composite); for (final FeedsEntry entry : entries) { if (i++ > JBossCentralActivator.MAX_FEEDS) { return; } String text = entry.getFormString(false); FormText formText = toolkit.createFormText(composite, true); TableWrapData td = new TableWrapData(); td.indent = 2; formText.setLayoutData(td); try { formText.setText(text, true, true); } catch (IllegalArgumentException se) { try { text = entry.getFormString(true); formText.setText(text, true, true); } catch (IllegalArgumentException se2) { formText.dispose(); formText = toolkit.createFormText(composite, false); formText.setLayoutData(td); try { formText.setText( "Problem rendering entry - " + StringEscapeUtils.unescapeHtml(se.getMessage()), false, false); } catch (Exception e1) { JBossCentralActivator.log(se); } } continue; } formText.setFont("default", JFaceResources.getDefaultFont()); formText.setFont("date", JFaceResources.getDefaultFont()); formText.setColor("date", JFaceColors.getHyperlinkText(getDisplay())); formText.setFont("description", JFaceResources.getDefaultFont()); formText.setColor("author", JFaceColors.getHyperlinkText(getDisplay())); formText.setImage("image", getFeedsImage()); if (JBossCentralActivator.isInternalWebBrowserAvailable() && entry.getDescription() != null && !entry.getDescription().isEmpty()) { ToolTip toolTip = new FeedsToolTip(formText, entry.getDate() + " " + entry.getDescription()); toolTip.activate(); } formText.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { Object link = e.data; if (link instanceof String) { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); JBossCentralActivator.openUrl((String) link, shell); } } }); } pageBook.showPage(composite); pageBook.layout(true, true); form.reflow(true); recomputeScrollComposite(scrollable, pageBook); resize(); }
From source file:org.jboss.tools.common.model.ui.widgets.DefaultSettings.java
License:Open Source License
protected void initFonts() { defaultFont = JFaceResources.getDefaultFont(); headerFont = JFaceResources.getBannerFont(); titleFont = JFaceResources.getHeaderFont(); }
From source file:org.netxms.ui.eclipse.epp.views.EventProcessingPolicyEditor.java
License:Open Source License
@Override public void createPartControl(Composite parent) { session = (NXCSession) ConsoleSharedData.getSession(); IDialogSettings settings = Activator.getDefault().getDialogSettings(); filterEnabled = settings.getBoolean("EventProcessingPolicyEditor.filterEnabled"); //$NON-NLS-1$ // Initiate loading of required plugins if they was not loaded yet try {//ww w . j av a 2s . c om Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter"); //$NON-NLS-1$ Platform.getAdapterManager().loadAdapter(new ServerAction(0), "org.eclipse.ui.model.IWorkbenchAdapter"); //$NON-NLS-1$ Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter"); //$NON-NLS-1$ } catch (Exception e) { } imageStop = Activator.getImageDescriptor("icons/stop.png").createImage(); //$NON-NLS-1$ imageAlarm = Activator.getImageDescriptor("icons/alarm.png").createImage(); //$NON-NLS-1$ imageSituation = Activator.getImageDescriptor("icons/situation.gif").createImage(); //$NON-NLS-1$ imageExecute = Activator.getImageDescriptor("icons/execute.png").createImage(); //$NON-NLS-1$ imageTerminate = Activator.getImageDescriptor("icons/terminate.png").createImage(); //$NON-NLS-1$ imageCollapse = SharedIcons.COLLAPSE.createImage(); imageExpand = SharedIcons.EXPAND.createImage(); imageEdit = SharedIcons.EDIT.createImage(); parent.setLayout(new FormLayout()); // Create filter area filterControl = new FilterText(parent, SWT.NONE); filterControl.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { onFilterModify(); } }); filterControl.setCloseAction(new Action() { @Override public void run() { enableFilter(false); } }); scroller = new ScrolledComposite(parent, SWT.V_SCROLL); dataArea = new Composite(scroller, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; dataArea.setLayout(layout); dataArea.setBackground(BACKGROUND_COLOR); scroller.setContent(dataArea); scroller.setExpandVertical(true); scroller.setExpandHorizontal(true); scroller.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle r = scroller.getClientArea(); scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT)); } }); // Setup layout FormData fd = new FormData(); fd.left = new FormAttachment(0, 0); fd.top = new FormAttachment(filterControl); fd.right = new FormAttachment(100, 0); fd.bottom = new FormAttachment(100, 0); scroller.setLayoutData(fd); fd = new FormData(); fd.left = new FormAttachment(0, 0); fd.top = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); filterControl.setLayoutData(fd); normalFont = JFaceResources.getDefaultFont(); boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); sessionListener = new SessionListener() { @Override public void notificationHandler(SessionNotification n) { processSessionNotification(n); } }; session.addListener(sessionListener); selection = new TreeSet<RuleEditor>(new Comparator<RuleEditor>() { @Override public int compare(RuleEditor arg0, RuleEditor arg1) { return arg0.getRuleNumber() - arg1.getRuleNumber(); } }); createActions(); contributeToActionBars(); openEventProcessingPolicy(); activateContext(); // Set initial focus to filter input line if (filterEnabled) filterControl.setFocus(); else enableFilter(false); // Will hide filter area correctly }