protected void updateTableFont() { Font newFont = JFaceResources.getFont(FontPreferencePage.BASE_FONT_KEY); Font oldFont = tableViewer.getTable().getFont(); Font font = SWTUtil.changeFontSize(oldFont, newFont); tableViewer.getTable().setFont(font); tableViewer.getTable().layout(true, true); // bug: row height never decreases }
private Control createPreviewer(Composite parent) { IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {getPreferenceStore(), generalTextStore}); fPreviewViewer = new CSourceViewer( parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration( fColorManager, store, null, ICPartitions.C_PARTITIONING, false); fPreviewViewer.configure(configuration); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); // $NON-NLS-1$ IDocument document = new Document(content); CUIPlugin.getDefault() .getTextTools() .setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null); fPreviewViewer.setDocument(document); installSemanticHighlighting(); return fPreviewViewer.getControl(); }
private void createSignaturePreview(Composite composite, RowLayouter layouter) { Label previewLabel = new Label(composite, SWT.NONE); previewLabel.setText(RefactoringMessages.ExtractMethodInputPage_signature_preview); layouter.perform(previewLabel); IPreferenceStore store = DartToolsPlugin.getDefault().getCombinedPreferenceStore(); fSignaturePreview = new DartSourceViewer( composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store); fSignaturePreview.configure( new DartSourceViewerConfiguration( DartToolsPlugin.getDefault().getDartTextTools().getColorManager(), store, null, null)); fSignaturePreview .getTextWidget() .setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fSignaturePreview.adaptBackgroundColor(composite); fSignaturePreview.setDocument(fSignaturePreviewDocument); fSignaturePreview.setEditable(false); Control signaturePreviewControl = fSignaturePreview.getControl(); PixelConverter pixelConverter = new PixelConverter(signaturePreviewControl); GridData gdata = new GridData(GridData.FILL_BOTH); gdata.widthHint = pixelConverter.convertWidthInCharsToPixels(50); gdata.heightHint = pixelConverter.convertHeightInCharsToPixels(2); signaturePreviewControl.setLayoutData(gdata); layouter.perform(signaturePreviewControl); }
private void styleViewer() { IPreferenceStore store = EditorsUI.getPreferenceStore(); Color foreground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)) foreground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); Color background = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) background = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); Color selectionForeground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT)) selectionForeground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND); Color selectionBackground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)) selectionBackground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND); StyledText text = getTextWidget(); text.setForeground(foreground); text.setBackground(background); text.setSelectionForeground(selectionForeground); text.setSelectionBackground(selectionBackground); text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); if (lineNumberRuler != null) { lineNumberRuler.setFont(text.getFont()); lineNumberRuler.setForeground(foreground); lineNumberRuler.setBackground(background); } }
public void createPartControl(Composite parent) { text = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); makeActions(); contributeToActionBars(); }
/* * (non-Javadoc) * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) */ public Font getFont(Object element) { Font font = JFaceResources.getFont(IThemeManager.VIEW_FONT_NAME); if (font == null) { font = JFaceResources.getTextFont(); } return font; }
/** * Constructor for TabbedPropertyTitle. * * @param parent the parent composite. * @param factory the widget factory for the tabbed property sheet */ public TabbedPropertyTitle(Composite parent, TabbedPropertySheetWidgetFactory factory) { super(parent, SWT.NO_FOCUS); this.factory = factory; // RAP not suppported // this.addPaintListener(new PaintListener() { // // public void paintControl(PaintEvent e) { // if (image == null && (text == null || text.equals(BLANK))) { // label.setVisible(false); // } else { // label.setVisible(true); // drawTitleBackground(e); // } // } // }); // /RAP factory.getColors().initializeSectionToolBarColors(); setBackground(factory.getColors().getBackground()); setForeground(factory.getColors().getForeground()); FormLayout layout = new FormLayout(); layout.marginWidth = 1; layout.marginHeight = 2; setLayout(layout); Font font; if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) { FontData[] fontData = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData(); /* title font is 2pt larger than that used in the tabs. */ fontData[0].setHeight(fontData[0].getHeight() + 2); JFaceResources.getFontRegistry().put(TITLE_FONT, fontData); } font = JFaceResources.getFont(TITLE_FONT); label = factory.createCLabel(this, BLANK); // label.setBackground(new Color[] { // factory.getColors().getColor(IFormColors.H_GRADIENT_END), // factory.getColors().getColor(IFormColors.H_GRADIENT_START) }, // new int[] { 100 }, true); label.setFont(font); label.setForeground(factory.getColors().getColor(IFormColors.TITLE)); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.top = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); label.setLayoutData(data); /* * setImage(PlatformUI.getWorkbench().getSharedImages().getImage( * ISharedImages.IMG_OBJ_ELEMENT)); */ }
@Override public void createControl(Composite parent) { super.createControl(parent); final SourceViewer viewer = getSourceViewer(); viewer.unconfigure(); IPreferenceStore store = DartToolsPlugin.getDefault().getCombinedPreferenceStore(); viewer.configure( new DartSourceViewerConfiguration( DartToolsPlugin.getDefault().getDartTextTools().getColorManager(), store, null, null)); viewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); }
SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) { SourceViewer viewer = null; String contentTypeID = ContentTypeIdForHTML.ContentTypeID_HTML; viewer = new StructuredTextViewer( parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer .getTextWidget() .setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); // $NON-NLS-1$ IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID); IDocument document = scratchModel.getStructuredDocument(); viewer.configure(viewerConfiguration); viewer.setDocument(document); return viewer; }
public static SourceViewer createErlangPreviewer( final Composite parent, IColorManager colorManager, Map<TokenHighlight, HighlightStyle> colors, final String content) { // TODO we should move this method, to a utility class (or maybe create // an ErlangPreviewSourceViewer class) if (colorManager == null) { colorManager = new ColorManager(); } if (colors == null) { colors = new HashMap<TokenHighlight, HighlightStyle>(); for (final TokenHighlight th : TokenHighlight.values()) { colors.put(th, th.getDefaultData()); } } final IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); final IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { ErlideUIPlugin.getDefault().getPreferenceStore(), generalTextStore }); final SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); final IDocument document = new Document(content); viewer.setDocument(document); final ErlangDocumentSetupParticipant setupParticipant = new ErlangDocumentSetupParticipant(); setupParticipant.setup(document); final TextSourceViewerConfiguration configuration = new SyntaxColorPreviewEditorConfiguration(store, colorManager, colors); viewer.configure(configuration); final Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new ErlangSourceViewerUpdater(viewer, configuration, store); viewer.setEditable(false); final Cursor arrowCursor = viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); return viewer; }
protected VirtualSourceViewer createViewer( Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) { int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; VirtualSourceViewer viewer = new VirtualSourceViewer(parent, fVerticalRuler, fOverviewRuler, true, styles); viewer.getControl().setLayoutData(parent.getLayoutData()); viewer.setEditable(false); viewer .getTextWidget() .setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT)); viewer.setRangeIndicator(new DefaultRangeIndicator()); getSourceViewerDecorationSupport(viewer); viewer.configure(new SourceViewerConfiguration()); JFaceResources.getFontRegistry().addListener(this); JFaceResources.getColorRegistry().addListener(this); getEditorPreferenceStore().addPropertyChangeListener(this); return viewer; }
private void createSignaturePreview(Composite composite) { Label previewLabel = new Label(composite, SWT.NONE); previewLabel.setText(RefactoringMessages.ChangeSignatureInputPage_method_Signature_Preview); // //XXX: use ViewForm to draw a flat border. Beware of common problems with wrapping // layouts // //inside GridLayout. GridData must be constrained to force wrapping. See bug 9866 et al. // ViewForm border= new ViewForm(composite, SWT.BORDER | SWT.FLAT); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); fSignaturePreview = new JavaSourceViewer( composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store); fSignaturePreview.configure( new JavaSourceViewerConfiguration( JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null)); fSignaturePreview .getTextWidget() .setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fSignaturePreview.adaptBackgroundColor(composite); fSignaturePreview.setDocument(fSignaturePreviewDocument); fSignaturePreview.setEditable(false); // Layouting problems with wrapped text: see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866 Control signaturePreviewControl = fSignaturePreview.getControl(); PixelConverter pixelConverter = new PixelConverter(signaturePreviewControl); GridData gdata = new GridData(GridData.FILL_BOTH); gdata.widthHint = pixelConverter.convertWidthInCharsToPixels(50); gdata.heightHint = pixelConverter.convertHeightInCharsToPixels(2); signaturePreviewControl.setLayoutData(gdata); // //XXX must force JavaSourceViewer text widget to wrap: // border.setContent(signaturePreviewControl); // GridData borderData= new GridData(GridData.FILL_BOTH); // borderData.widthHint= gdata.widthHint; // borderData.heightHint= gdata.heightHint; // border.setLayoutData(borderData); }
@Override protected void createContent(final Composite parent) { fContentComposite = new Composite(parent, SWT.NONE) { @Override public Point computeSize(final int width, final int height, final boolean changed) { return super.computeSize(width, height, changed || width != getSize().x); } }; fContentComposite.setBackgroundMode(SWT.INHERIT_FORCE); final GridLayout gridLayout = LayoutUtil.applyCompositeDefaults(new GridLayout(), 2); gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5); fContentComposite.setLayout(gridLayout); final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4); final int hIndent = Math.max(2, LayoutUtil.defaultHSpacing() / 3); { // Title image fTitleImage = new Label(fContentComposite, SWT.NULL); final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID); fTitleImage.setImage(image); final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false); fTitleText = new StyledText(fContentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) { @Override public Point computeSize(int width, final int height, final boolean changed) { if (!fLayoutHint && width <= 0 && fContentComposite.getSize().x > 0) { width = fContentComposite.getSize().x - LayoutUtil.defaultHMargin() - fTitleImage.getSize().x - LayoutUtil.defaultHSpacing() - 10; } final Point size = super.computeSize(width, -1, true); // if (width >= 0) { // size.x = Math.min(size.x, width); // } return size; } }; fTitleText.setFont(JFaceResources.getDialogFont()); final GC gc = new GC(fTitleText); final FontMetrics fontMetrics = gc.getFontMetrics(); final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false); imageGd.horizontalIndent = hIndent; final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading(); final int imageHeight = image.getBounds().height; final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5)); if (textHeight + shift < imageHeight) { imageGd.verticalIndent = vIndent + shift; textGd.verticalIndent = vIndent + (imageHeight - textHeight); } else { imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift; textGd.verticalIndent = vIndent; } fTitleImage.setLayoutData(imageGd); fTitleText.setLayoutData(textGd); fLayoutWorkaround = true; gc.dispose(); } fInfoText = new StyledText( fContentComposite, fMode == MODE_FOCUS ? (SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL) : (SWT.MULTI | SWT.READ_ONLY)); fInfoText.setIndent(hIndent); fInfoText.setFont(JFaceResources.getFont(PREF_DETAIL_PANE_FONT)); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); // gd.widthHint = LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50); fInfoText.setLayoutData(gd); setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); updateInput(); }
private void initializeDefault() { NORMAL = JFaceResources.getFont(AESH_CONSOLE_FONT); }
/** * 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 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 SourceViewerInformationControl( Shell parent, boolean isResizable, String symbolicFontName, String statusFieldText) { 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(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); fSymbolicFontName = symbolicFontName; fTextFont = JFaceResources.getFont(symbolicFontName); 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); }
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(); 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(); }