List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.key_project.key4eclipse.common.ui.wizard.page.KeYExampleWizardPage.java
License:Open Source License
/** * Creates a tab showing the given {@link File}. * @param tabFolder The parent {@link TabFolder}. * @param tabText The tab text to show.//from w w w . jav a2s. c o m * @param file The {@link File} to show its content. */ protected void createFileTab(TabFolder tabFolder, String tabText, File file) { if (file != null && file.exists()) { TabItem poItem = new TabItem(tabFolder, SWT.NONE); poItem.setText(tabText); String text; try { text = IOUtil.readFrom(file); } catch (Exception e) { text = e.getMessage(); } IDocument document = new Document(text); SourceViewer viewer; if (JDTUtil.JAVA_FILE_EXTENSION.equals(IOUtil.getFileExtension(file))) { // Have a look at org.eclipse.jdt.internal.ui.refactoring.JavaStatusContextViewer to see how to setup a SourceViewer for Java IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); viewer = new JavaSourceViewer(tabFolder, null, null, false, SWT.LEFT_TO_RIGHT | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, store); viewer.configure(new SimpleJavaSourceViewerConfiguration( JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null, false)); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document); } else { viewer = new SourceViewer(tabFolder, null, SWT.LEFT_TO_RIGHT | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); } viewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); viewer.setEditable(false); viewer.setInput(document); poItem.setControl(viewer.getControl()); } }
From source file:org.l2x6.eircc.ui.editor.AbstractIrcEditor.java
License:Open Source License
/** * Initializes the given viewer's font./*from w ww . j av a 2s .com*/ * * @param viewer * the viewer * @since 2.0 */ private void initializeViewerFont(ISourceViewer viewer) { boolean isSharedFont = true; Font font = null; String symbolicFontName = JFaceResources.DIALOG_FONT; if (symbolicFontName != null) font = JFaceResources.getFont(symbolicFontName); if (font == null) font = JFaceResources.getDialogFont(); if (!font.equals(logViewer.getTextWidget().getFont())) { setFont(viewer, font); disposeFont(); if (!isSharedFont) fFont = font; } else if (!isSharedFont) { font.dispose(); } }
From source file:org.limy.eclipse.prop.preference.LimyPropPreferencePage.java
License:Open Source License
/** * vr?[pR|?[lg???B/* w w w. j av a 2s. c o m*/ * @param comp ?eR|?[lg */ private void createPreviewViewer(Composite comp) { SourceViewer previewViewer = new SourceViewer(comp, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); previewViewer.configure(new PropertySourceViewerConfiguration((PropertyEditor) null)); String content = LimyEclipsePluginUtils.loadContent(LimyPropPlugin.getDefault(), LimyPropConstants.CONTENT_PREVIEW); IDocument document = new Document(content); previewViewer.setDocument(document); previewViewer.setEditable(false); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); previewViewer.getTextWidget().setFont(font); previewViewer.getTextWidget().setBackground( LimyEclipsePlugin.getDefault().getColorProvider().getColor(LimyEclipseConstants.P_BGCOLOR)); Control preview = previewViewer.getControl(); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; preview.setLayoutData(gridData); setSourceViewer(previewViewer); }
From source file:org.limy.eclipse.web.preference.LimyWebPreferencePage.java
License:Open Source License
/** * vr?[pr?[A???B/*from w ww .ja v a 2 s.com*/ * @param comp */ private void createPreviewViewer(Composite comp) { Label previewLabel = new Label(comp, SWT.NONE); GridData gridData = new GridData(); gridData.horizontalSpan = 2; previewLabel.setLayoutData(gridData); previewLabel.setText("Preview:"); SourceViewer previewViewer = new SourceViewer(comp, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); previewViewer.configure(new VelocitySourceViewerConfiguration((VelocityEditor) null)); String content = LimyEclipsePluginUtils.loadContent(LimyWebPlugin.getDefault(), LimyWebConstants.CONTENT_PREVIEW); IDocument document = new Document(content); previewViewer.setDocument(document); previewViewer.setEditable(false); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); previewViewer.getTextWidget().setFont(font); previewViewer.getTextWidget().setBackground( LimyEclipsePlugin.getDefault().getColorProvider().getColor(LimyEclipseConstants.P_BGCOLOR)); Control preview = previewViewer.getControl(); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; preview.setLayoutData(gridData); setSourceViewer(previewViewer); }
From source file:org.melanee.ocl.service.console.consoles.LMLOCLConsolePage.java
License:Open Source License
@Override public void createControl(Composite parent) { 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);// www . j av a 2s . c om output.setDocument(new Document()); colorManager = new ColorManager(); document = new LMLOCLDocument(); document.setOCLFactory(oclFactory); document.setModelingLevel(modelingLevel); input = new LMLOCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI); input.setDocument(document); input.getTextWidget().addKeyListener(new InputKeyListener()); selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { LMLOCLConsolePage.this.selectionChanged(selection); } }; selectionService = getSite().getWorkbenchWindow().getSelectionService(); selectionService.addPostSelectionListener(selectionListener); ISelection selection = selectionService.getSelection(); selectionChanged(selection); }
From source file:org.metaborg.spoofax.eclipse.editor.SpoofaxInformationControl.java
License:Open Source License
/** * Creates a source viewer information control with the given shell as parent. The given shell styles are applied to * the created shell. The given styles are applied to the created styled text widget. The text widget will be * initialized with the given font. The status field will contain the given text or be hidden. * * @param parent/*from ww w. j a v a 2 s . c o m*/ * the parent shell * @param isResizable * <code>true</code> if resizable * @param symbolicFontName * the symbolic font name * @param statusFieldText * the text to be used in the optional status field or <code>null</code> if the status field should be * hidden */ public SpoofaxInformationControl(Shell parent, boolean isResizable, String statusFieldText, ILanguageImpl language) { this.syntaxService = SpoofaxPlugin.spoofax().syntaxService; this.unitService = SpoofaxPlugin.spoofax().unitService; this.language = language; this.styler = SpoofaxPlugin.spoofax().stylerService; this.categorizer = SpoofaxPlugin.spoofax().categorizerService; GridLayout layout; GridData gd; int shellStyle = SWT.TOOL | SWT.ON_TOP | (isResizable ? SWT.RESIZE : 0); int textStyle = isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE; fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); Display display = fShell.getDisplay(); Composite composite = fShell; layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); composite.setLayoutData(gd); if (statusFieldText != null) { composite = new Composite(composite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } // Source viewer fViewer = new SourceViewer(composite, null, textStyle); fViewer.configure(new SourceViewerConfiguration()); fViewer.setEditable(false); fText = fViewer.getTextWidget(); gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); fText.setLayoutData(gd); fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fText.setBackground(new Color(display, new RGB(246, 246, 246))); // fSymbolicFontName= symbolicFontName; fTextFont = JFaceResources.getFont(JFaceResources.TEXT_FONT); fText.setFont(fTextFont); fText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.character == 0x1B) // ESC fShell.dispose(); } public void keyReleased(KeyEvent e) { } }); // Status field if (statusFieldText != null) { // Horizontal separator line fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Status field label fStatusField = new Label(composite, SWT.RIGHT); fStatusField.setText(statusFieldText); Font font = fStatusField.getFont(); FontData[] fontDatas = font.getFontData(); for (int i = 0; i < fontDatas.length; i++) fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas); fStatusField.setFont(fStatusTextFont); GridData gd2 = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fStatusField.setLayoutData(gd2); fStatusTextForegroundColor = new Color(fStatusField.getDisplay(), blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f)); fStatusField.setForeground(fStatusTextForegroundColor); fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); } addDisposeListener(this); }
From source file:org.multicore_association.shim.edit.gui.swt.viewer.ShimObjectTableLabelProvider.java
License:MIT License
/** * @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, * int)//w ww . ja v a 2 s.co m */ @Override public Font getFont(Object element, int columnIndex) { ShimObject so = (ShimObject) element; Object obj = so.getObj(); Font result = JFaceResources.getFont(JFaceResources.DEFAULT_FONT); if (obj == null || apiClass.equals(obj.getClass())) { ShimObjectColumnFormat format = formatList.get(columnIndex); ColumnType type = format.getType(); switch (type) { case INT: case FLOAT: case HEX: // memo. JFaceResources.TEXT_FONT is monospace font. result = JFaceResources.getFont(JFaceResources.TEXT_FONT); break; default: break; } } return result; }
From source file:org.pdtextensions.core.ui.preferences.formatter.PHPPreview.java
License:Open Source License
public PHPPreview(Map workingValues, Composite parent) { fPreviewDocument = StructuredModelManager.getModelManager() .createStructuredDocumentFor(ContentTypeIdForPHP.ContentTypeID_PHP); fWorkingValues = workingValues;//w ww . jav a2s . co m IPreferenceStore[] chain = { PEXUIPlugin.getDefault().getCombinedPreferenceStore() }; fPreferenceStore = new ChainedPreferenceStore(chain); fSourceViewer = new PHPStructuredTextViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fSourceViewer.setEditable(false); fViewerConfiguration = new PHPStructuredTextViewerSimpleConfiguration(); fSourceViewer.configure(fViewerConfiguration); StyledText fText = fSourceViewer.getTextWidget(); fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ fColorManager = new ColorManager(); fMarginPainter = new MarginPainter(fSourceViewer); final RGB rgb = PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(fColorManager.getColor(rgb)); fSourceViewer.addPainter(fMarginPainter); new PHPSourcePreviewerUpdater(fSourceViewer, fViewerConfiguration, fPreferenceStore); fSourceViewer.setDocument(fPreviewDocument); }
From source file:org.polarsys.capella.ocl.requester.view.OCLInterpreterView.java
License:Open Source License
@Override public void createPartControl(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); page.setFont(JFaceResources.getHeaderFont()); colorManager = new ColorManager(); document = new OCLDocument(); document.setModelingLevel(modelingLevel); contextName = new Label(page, SWT.NONE); errorOutput = new Label(page, SWT.NONE); errorOutput.setForeground(colorManager.getColor(ColorManager.OUTPUT_ERROR)); input = new OCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI); input.setDocument(document);/* w ww. j a v a 2s . com*/ input.getTextWidget().addKeyListener(new InputKeyListener()); input.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); CTabFolder tabFolder = new CTabFolder(page, SWT.BORDER); tabFolder.setSelectionBackground( Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); CTabItem tabItem1 = new CTabItem(tabFolder, SWT.NONE); tabItem1.setText(OCLInterpreterMessages.OCLInterpreterView_tbtmModelOutput_text); Composite composite = new Composite(tabFolder, SWT.NONE); tabItem1.setControl(composite); composite.setLayout(new TreeColumnLayout()); ComposedAdapterFactory adapterFactory = (ComposedAdapterFactory) SiriusEditPlugin.getPlugin() .getItemProvidersAdapterFactory(); adapterFactory.insertAdapterFactory(new TupleItemProviderAdapterFactory()); labelProvider = new AdapterFactoryLabelProvider(adapterFactory); treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.MULTI); Tree tree = treeViewer.getTree(); tree.setHeaderVisible(true); tree.setLinesVisible(true); treeViewer.setContentProvider(getContentProvider()); treeViewer.setLabelProvider(labelProvider); CTabItem tabItem2 = new CTabItem(tabFolder, SWT.NONE); tabItem2.setText("Console Output"); //$NON-NLS-1$ output = new TextViewer(tabFolder, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); StyledText styledTextOutput = output.getTextWidget(); tabItem2.setControl(styledTextOutput); output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH)); output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); output.setEditable(false); output.setDocument(new Document()); tabFolder.setSelection(0); selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { OCLInterpreterView.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[] { 1, 1, 5, 8 }); createActions(); }
From source file:org.python.pydev.debug.pyunit.PyUnitView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { Assert.isTrue(!disposed);/* w w w . ja v a 2 s . c o m*/ super.createPartControl(parent); IInformationPresenter presenter = new InformationPresenterWithLineTracker(); final ToolTipPresenterHandler tooltip = new ToolTipPresenterHandler(parent.getShell(), presenter); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.verticalSpacing = 2; layout.marginWidth = 0; layout.marginHeight = 2; parent.setLayout(layout); configureToolBar(); fCounterComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); fCounterComposite.setLayout(layout); fCounterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); fCounterPanel = new CounterPanel(fCounterComposite); fCounterPanel.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); fProgressBar = new PyUnitProgressBar(fCounterComposite); fProgressBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); fStatus = new Label(fCounterComposite, 0); GridData statusLayoutData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); statusLayoutData.grabExcessHorizontalSpace = true; fStatus.setLayoutData(statusLayoutData); fStatus.setText("Status"); sash = new SashForm(parent, SWT.HORIZONTAL); GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; sash.setLayoutData(layoutData); tree = new Tree(sash, SWT.FULL_SELECTION | SWT.MULTI); tooltip.install(tree); tree.setHeaderVisible(true); Listener sortListener = new PyUnitSortListener(this); colIndex = createColumn(" ", 50, sortListener); colResult = createColumn("Result", 70, sortListener); colTest = createColumn("Test", 180, sortListener); colFile = createColumn("File", 180, sortListener); colTime = createColumn("Time (s)", 80, sortListener); onControlCreated.call(tree); tree.setSortColumn(colIndex); tree.setSortDirection(SWT.DOWN); tree.addMouseListener(new DoubleClickTreeItemMouseListener()); tree.addKeyListener(new EnterProssedTreeItemKeyListener()); tree.addSelectionListener(new SelectResultSelectionListener()); Menu menu = new Menu(tree.getShell(), SWT.POP_UP); MenuItem runItem = new MenuItem(menu, SWT.PUSH); runItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { relaunchSelectedTests(ILaunchManager.RUN_MODE); } }); runItem.setText("Run"); MenuItem debugItem = new MenuItem(menu, SWT.PUSH); debugItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { relaunchSelectedTests(ILaunchManager.DEBUG_MODE); } }); debugItem.setText("Debug"); tree.setMenu(menu); if (PydevPlugin.getDefault() != null) { colorAndStyleCache = new ColorAndStyleCache(PydevPrefs.getChainedPrefStore()); prefListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (tree != null) { String property = event.getProperty(); if (ColorAndStyleCache.isColorOrStyleProperty(property)) { colorAndStyleCache.reloadProperty(property); Color errorColor = getErrorColor(); TreeItem[] items = tree.getItems(); for (TreeItem item : items) { PyUnitTestResult result = (PyUnitTestResult) item.getData(PY_UNIT_TEST_RESULT); if (result != null) { if (result.isOk()) { } else if (result.isSkip()) { } else { //failure or error. item.setForeground(errorColor); } } } if (fProgressBar != null) { fProgressBar.updateErrorColor(true); } } } } }; PydevPrefs.getChainedPrefStore().addPropertyChangeListener(prefListener); } StyledText text = new StyledText(sash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); text.setFont(JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT)); this.setTextComponent(text); onTestRunAdded(); }