List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.eclipse.mat.ui.snapshot.panes.OQLPane.java
License:Open Source License
public void createPartControl(Composite parent) { SashForm sash = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH); queryViewer = new SourceViewer(sash, null, SWT.MULTI | SWT.WRAP); queryString = queryViewer.getTextWidget(); queryString.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); Color background = queryString.getBackground(); IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); ITheme current = themeManager.getCurrentTheme(); ColorRegistry colorRegistry = current.getColorRegistry(); commentCol = colorRegistry.get(ColorProvider.COMMENT_COLOR_PREF); keywordCol = colorRegistry.get(ColorProvider.KEYWORD_COLOR_PREF); IDocument d = createDocument();/*w w w . j a v a 2 s. co m*/ d.set(Messages.OQLPane_F1ForHelp); queryViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateActions(); } }); queryViewer.setDocument(d); queryViewer.configure(new OQLTextViewerConfiguration(getSnapshot(), commentCol, keywordCol)); // Eclipse 4 seems to need this otherwise in high contrast mode the background is white queryString.setBackground(background); queryString.selectAll(); PlatformUI.getWorkbench().getHelpSystem().setHelp(queryString, "org.eclipse.mat.ui.help.oql"); //$NON-NLS-1$ queryString.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode == '\r' && (e.stateMask & SWT.MOD1) != 0) { executeAction.run(); e.doit = false; } else if (e.keyCode == ' ' && (e.stateMask & SWT.CTRL) != 0) { //ctrl space combination for content assist contentAssistAction.run(); } else if (e.keyCode == SWT.F5) { executeAction.run(); e.doit = false; } } }); queryString.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { IActionBars actionBars = getEditor().getEditorSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyQueryStringAction); actionBars.updateActionBars(); } public void focusLost(FocusEvent e) { } }); queryString.setFocus(); createContainer(sash); sash.setWeights(new int[] { 1, 4 }); makeActions(); hookContextMenu(); }
From source file:org.eclipse.mylyn.internal.commons.ui.screenshots.SelectToolAction.java
License:Open Source License
private void setToolAction(int tool) { if (tool == CAPTURE_DROP_DOWN_MENU) { selectedItemID = CAPTURE_DESKTOP; initMenu(tool, new ToolActionItem[] { new ToolActionItem(CAPTURE_DESKTOP, Messages.SelectToolAction_Desktop, ScreenshotImages.MONITOR_OBJ), // new ToolActionItem(CAPTURE_DESKTOP_DELAYED, Messages.SelectToolAction_Desktop_Delayed, ScreenshotImages.MONITOR__DELAY_OBJ), // new ToolActionItem(CAPTURE_CLIPBOARD, Messages.SelectToolAction_Clipboard, ScreenshotImages.CLIPBOARD_OBJ), // new ToolActionItem(CAPTURE_FILE, Messages.SelectToolAction_File, ScreenshotImages.FILE_OBJ), new ToolActionItem(CAPTURE_RECTANGLE, Messages.SelectToolAction_Selected_Rectangle, ScreenshotImages.SEL_RECT) }); return;// ww w. j a v a 2s . c om } if (tool == ZOOM_DROP_DOWN_MENU) { selectedItemID = ZOOM_FIT; initMenu(tool, new ToolActionItem[] { new ToolActionItem(ZOOM_FIT, Messages.SelectToolAction_Fit, null), new ToolActionItem(50, Messages.SelectToolAction_ZoomHalf, null), new ToolActionItem(100, Messages.SelectToolAction_Zoom1X, null), new ToolActionItem(200, Messages.SelectToolAction_Zoom2X, null), new ToolActionItem(400, Messages.SelectToolAction_Zoom4X, null), new ToolActionItem(800, Messages.SelectToolAction_Zoom8X, null) }); return; } if (tool == LINETYPE_TOOLBAR) { selectedItemID = SWT.LINE_SOLID; initBar(tool, new ToolActionItem[] { new ToolActionItem(SWT.LINE_SOLID, Messages.SelectToolAction_Solid_Line, ScreenshotImages.LINE_SOLD), new ToolActionItem(SWT.LINE_DOT, Messages.SelectToolAction_Dotted_Line, ScreenshotImages.LINE_DOT), new ToolActionItem(SWT.LINE_DASH, Messages.SelectToolAction_Dashed_Line, ScreenshotImages.LINE_DASH), new ToolActionItem(SWT.LINE_DASHDOT, Messages.SelectToolAction_Dashed_Line_1_dot, ScreenshotImages.LINE_DASH1D), new ToolActionItem(SWT.LINE_DASHDOTDOT, Messages.SelectToolAction_Dashed_Line_2_dots, ScreenshotImages.LINE_DASH2D) }); return; } if (tool == DRAWLINE_TOOLBAR) { showSelection = true; selectedItemID = DRAW_FREE; initBar(tool, new ToolActionItem[] { new ToolActionItem(DRAW_FREE, Messages.SelectToolAction_Free, ScreenshotImages.EDIT_FREE), new ToolActionItem(DRAW_LINE, Messages.SelectToolAction_Line, ScreenshotImages.EDIT_LINE) }); return; } if (tool == DRAWARROW_TOOLBAR) { showSelection = true; selectedItemID = DRAW_ARROW1; initBar(tool, new ToolActionItem[] { new ToolActionItem(DRAW_ARROW1, Messages.SelectToolAction_Single_Side_Arrow, ScreenshotImages.EDIT_ARROW1), new ToolActionItem(DRAW_ARROW2, Messages.SelectToolAction_Both_Side_Arrow, ScreenshotImages.EDIT_ARROW2) }); selectedItemID = -1; return; } if (tool == DRAWBOX_TOOLBAR) { showSelection = true; selectedItemID = DRAW_RBOX; initBar(tool, new ToolActionItem[] { new ToolActionItem(DRAW_BOX, Messages.SelectToolAction_Rectangle, ScreenshotImages.EDIT_BOX), new ToolActionItem(DRAW_RBOX, Messages.SelectToolAction_Round_Rectangle, ScreenshotImages.EDIT_RBOX), new ToolActionItem(DRAW_OVAL, Messages.SelectToolAction_Oval, ScreenshotImages.EDIT_OVAL), new ToolActionItem(DRAW_FILL_BOX, Messages.SelectToolAction_Fill_Rectangle, ScreenshotImages.EDIT_FILL_BOX), new ToolActionItem(DRAW_FILL_RBOX, Messages.SelectToolAction_Fill_Round_Rectangle, ScreenshotImages.EDIT_FILL_RBOX), new ToolActionItem(DRAW_FILL_OVAL, Messages.SelectToolAction_Fill_Oval, ScreenshotImages.EDIT_FILL_OVAL) }); selectedItemID = -1; return; } if (tool == DRAWTEXT_TOOLBAR) { showSelection = true; selectedItemID = DRAW_TEXT; // Bug:266123 Set initial font as HEADER_FONT FontData fontData = JFaceResources.getFont(JFaceResources.HEADER_FONT).getFontData()[0]; stringCustom = fontData.toString(); intgerCustom = rgb2int(255, 0, 0); selectedItemID = intgerCustom; initFont(tool); selectedItemID = -1; return; } if (tool == LINEBOLD_TOOLBAR) { selectedItemID = 4; initBar(tool, new ToolActionItem[] { new ToolActionItem(1, Messages.SelectToolAction_1dot, ScreenshotImages.LINE_BOLD1), new ToolActionItem(2, Messages.SelectToolAction_2dots, ScreenshotImages.LINE_BOLD2), new ToolActionItem(4, Messages.SelectToolAction_4dots, ScreenshotImages.LINE_BOLD4), new ToolActionItem(8, Messages.SelectToolAction_8dots, ScreenshotImages.LINE_BOLD8) }); return; } if (tool == COLOR_TOOLBAR) { intgerCustom = rgb2int(255, 85, 85); selectedItemID = intgerCustom; initColor(tool); return; } }
From source file:org.eclipse.n4js.tester.ui.resultsview.TestResultsView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize it. */// w w w . ja va2 s . c o m @Override public void createPartControl(final Composite parent) { GridLayout gl; GridData gd; gl = new GridLayout(2, false); gl.marginWidth = 0; gl.marginHeight = 0; gl.marginTop = 4; parent.setLayout(gl); toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT); gd = new GridData(); gd.grabExcessHorizontalSpace = false; gd.horizontalAlignment = SWT.CENTER; toolBar.setLayoutData(gd); progressBar = new TestProgressBar(parent, SWT.BORDER); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; progressBar.setLayoutData(gd); sashForm = new SashForm(parent, SWT.NONE); sashForm.setBackground(sashForm.getDisplay().getSystemColor(SWT.COLOR_GRAY)); gd = new GridData(); gd.horizontalSpan = 2; gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.grabExcessVerticalSpace = true; gd.verticalAlignment = SWT.FILL; sashForm.setLayoutData(gd); viewLayoutHelper = new TestViewLayoutHelper(sashForm); testTreeViewer = new TreeViewerBuilder(newArrayList("Test", "Status", "Duration"), new TestTreeViewerContentProvider()).setUseHashlookup(true).setLinesVisible(false) .setLabelProvider(new TestTreeViewerLabelProvider()).setColumnWeights(asList(5, 2, 1)) .build(sashForm); installToolTipSupport(testTreeViewer.getTree()); viewFilterHelper = new TestViewFilterHelper(testTreeViewer); testTreeViewer.setInput(getViewSite()); stackTrace = new TextViewer(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); // stackTrace.setHyperlinkPresenter(new MultipleHyperlinkPresenter(new RGB(0, 0, 255))); stackTrace.setHyperlinkPresenter(new DefaultHyperlinkPresenter(new RGB(0, 0, 255))); stackTrace.setHyperlinkDetectors(new IHyperlinkDetector[] { n4JSStackTraceHyperlinkDetector }, SWT.NONE); stackTrace.setDocument(new Document()); Font font = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT); stackTrace.getTextWidget().setFont(font); sashForm.addControlListener(new ControlListener() { @Override public void controlResized(ControlEvent e) { viewLayoutHelper.updateSashLayout(); } @Override public void controlMoved(ControlEvent e) { // ignore } }); createActions(); hookContextMenu(); hookDoubleClickAction(); hookSingleClickAction(); contributeToActionBars(); if (storedMemento != null) { restoreLayoutState(storedMemento); storedMemento = null; } refreshActions(); }
From source file:org.eclipse.n4js.ui.console.N4JSStackTraceConsole.java
License:Open Source License
/** * Constructor creating the console with the console font. *///from w w w . j a v a 2 s .c o m public N4JSStackTraceConsole() { super(ConsoleMessages.msgN4JSStackTraceConsole(), CONSOLE_TYPE, null, true); Font font = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT); setFont(font); partitioner.connect(getDocument()); }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Font getFont(FontData... fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); }//from ww w .ja v a 2 s . c o m String key = keyBuilder.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { return JFaceResources.getFont(key); } else { JFaceResources.getFontRegistry().put(key, fontDatas); return JFaceResources.getFont(key); } }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Font getFont(String key) { return JFaceResources.getFont(key); }
From source file:org.eclipse.nebula.widgets.richtext.painter.ResourceHelper.java
License:Open Source License
public static Font getFont(FontData... fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); }/*w ww . ja v a 2s . com*/ String key = keyBuilder.toString(); if (!JFaceResources.getFontRegistry().hasValueFor(key)) { JFaceResources.getFontRegistry().put(key, fontDatas); } return JFaceResources.getFont(key); }
From source file:org.eclipse.ocl.examples.interpreter.console.OCLConsolePage.java
License:Open Source License
@Override public void createControl(Composite parent) { // force left-to-right text direction in the console, because it // works with OCL text and the OCL language is based on English page = new SashForm(parent, SWT.VERTICAL | SWT.LEFT_TO_RIGHT); output = new TextViewer(page, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH)); output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); output.setEditable(false);//from w ww . ja v a 2 s. com output.setDocument(new Document()); colorManager = new ColorManager(); document = new OCLDocument(); document.setOCLFactory(oclFactory); document.setModelingLevel(modelingLevel); input = new OCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI); input.setDocument(document); input.getTextWidget().addKeyListener(new InputKeyListener()); selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { OCLConsolePage.this.selectionChanged(selection); } }; selectionService = getSite().getWorkbenchWindow().getSelectionService(); selectionService.addPostSelectionListener(selectionListener); // get current selection ISelection selection = selectionService.getSelection(); if (selection == null) { selection = getActiveSelection(); } selectionChanged(selection); ((SashForm) page).setWeights(new int[] { 2, 1 }); ClearOutputAction clear = new ClearOutputAction(output); CloseAction close = new CloseAction(); SaveAction save = new SaveAction(); LoadAction load = new LoadAction(); IMenuManager menu = getSite().getActionBars().getMenuManager(); menu.add(load); menu.add(save); menu.add(clear); menu.add(close); IMenuManager metamodelMenu = new MenuManager(OCLInterpreterMessages.console_metamodelMenu, "org.eclipse.ocl.examples.interpreter.metamodel"); //$NON-NLS-1$ menu.add(metamodelMenu); DropDownAction metamodelAction = new DropDownAction(); metamodelAction.setToolTipText(OCLInterpreterMessages.console_metamodelTip); addMetamodelActions(metamodelMenu, metamodelAction); IMenuManager levelMenu = new MenuManager(OCLInterpreterMessages.console_modelingLevel); menu.add(levelMenu); DropDownAction levelAction = new DropDownAction(); levelAction.setToolTipText(OCLInterpreterMessages.console_modelingLevelTip); IAction m2 = new ModelingLevelAction(ModelingLevel.M2); m2.setChecked(true); levelMenu.add(m2); levelAction.addAction(m2); IAction m1 = new ModelingLevelAction(ModelingLevel.M1); levelMenu.add(m1); levelAction.addAction(m1); ActionContributionItem metamodelItem = new ActionContributionItem(metamodelAction); metamodelItem.setMode(ActionContributionItem.MODE_FORCE_TEXT); IToolBarManager toolbar = getSite().getActionBars().getToolBarManager(); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, metamodelItem); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, levelAction); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, load); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, save); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, clear); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, close); }
From source file:org.eclipse.ocl.examples.xtext.console.OCLConsolePage.java
License:Open Source License
@Override public void createControl(Composite parent) { // force left-to-right text direction in the console, because it // works with OCL text and the OCL language is based on English page = new SashForm(parent, SWT.VERTICAL | SWT.LEFT_TO_RIGHT); output = new TextViewer(page, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH)); output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); output.setEditable(false);/*from ww w. java 2 s . c om*/ output.setDocument(new Document()); colorManager = new ColorManager(); // document.setOCLFactory(oclFactory); // document.setModelingLevel(modelingLevel); createEditor(page); input = editor.getViewer(); input.getTextWidget().addKeyListener(new InputKeyListener()); input.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, final ISelection selection) { // System.out.println("selectionChanged: "); if (part instanceof IConsoleView) { IConsole console = ((IConsoleView) part).getConsole(); if (console instanceof OCLConsole) { return; } } if (part instanceof ContentOutline) { ContentOutline contentOutline = (ContentOutline) part; IPage currentPage = contentOutline.getCurrentPage(); if (currentPage instanceof OutlinePage) { OutlinePage outlinePage = (OutlinePage) currentPage; IXtextDocument xtextDocument = outlinePage.getXtextDocument(); Element pivotElement = xtextDocument.readOnly(new IUnitOfWork<Element, XtextResource>() { public Element exec(XtextResource state) throws Exception { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() == 1) { Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof EObjectNode) { EObjectNode eObjectNode = (EObjectNode) selectedObject; URI uri = eObjectNode.getEObjectURI(); EObject csObject = state.getEObject(uri.fragment()); if (csObject instanceof Pivotable) { Element pivotObject = ((Pivotable) csObject).getPivot(); if (pivotObject != null) { return pivotObject; } } } } } return null; } }); if (pivotElement != null) { OCLConsolePage.this.selectionChanged(new StructuredSelection(pivotElement)); return; } } } OCLConsolePage.this.selectionChanged(selection); } }; selectionService = getSite().getWorkbenchWindow().getSelectionService(); selectionService.addPostSelectionListener(selectionListener); // get current selection // ISelection selection = selectionService.getSelection(); // Doesn't have a value preceding console start ISelection selection = BaseUIUtil.getActiveSelection(getSite()); selectionChanged(selection); ((SashForm) page).setWeights(new int[] { 2, 1 }); ClearOutputAction clear = new ClearOutputAction(output); CloseAction close = new CloseAction(); SaveExpressionAction saveExpression = new SaveExpressionAction(this); LoadExpressionAction loadExpression = new LoadExpressionAction(this); IMenuManager menu = getSite().getActionBars().getMenuManager(); menu.add(loadExpression); menu.add(saveExpression); menu.add(clear); menu.add(close); // IMenuManager metamodelMenu = new MenuManager( // OCLInterpreterMessages.console_metamodelMenu, // "org.eclipse.ocl.examples.xtext.console.metamodel"); //$NON-NLS-1$ // menu.add(metamodelMenu); // DropDownAction metamodelAction = new DropDownAction(); // metamodelAction.setToolTipText(OCLInterpreterMessages.console_metamodelTip); // addMetamodelActions(metamodelMenu, metamodelAction); // IMenuManager levelMenu = new MenuManager(OCLInterpreterMessages.console_modelingLevel); // menu.add(levelMenu); // DropDownAction levelAction = new DropDownAction(); // levelAction.setToolTipText(OCLInterpreterMessages.console_modelingLevelTip); // IAction m2 = new ModelingLevelAction(ModelingLevel.M2); // m2.setChecked(true); // levelMenu.add(m2); // levelAction.addAction(m2); // IAction m1 = new ModelingLevelAction(ModelingLevel.M1); // levelMenu.add(m1); // levelAction.addAction(m1); // ActionContributionItem metamodelItem = new ActionContributionItem( // metamodelAction); // metamodelItem.setMode(ActionContributionItem.MODE_FORCE_TEXT); IToolBarManager toolbar = getSite().getActionBars().getToolBarManager(); // toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, metamodelItem); // toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, levelAction); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, loadExpression); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, saveExpression); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, clear); toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, close); }
From source file:org.eclipse.oomph.setup.internal.installer.SimpleInstallerDialog.java
License:Open Source License
static Font getDefaultFont() { if (defaultFont == null) { defaultFont = JFaceResources.getFont(SetupInstallerPlugin.FONT_LABEL_DEFAULT); if (defaultFont == null) { defaultFont = UIUtil.getDisplay().getSystemFont(); }//w w w .j a v a2 s . c o m } return defaultFont; }