/** * Sets the font used by this console. Specify <code>null</code> to use * the default text font. * * @param newFont font, or <code>null</code> to indicate the default font */ public void setFont(Font newFont) { // ensure font is initialized getFont(); // translate null to default font if (newFont == null) { newFont = getDefaultFont(); } // fire property change if required if (!fFont.equals(newFont)) { Font old = fFont; fFont = newFont; firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont); } }
public void propertyChange(PropertyChangeEvent event) { if (fViewer != null) { Object source = event.getSource(); String property = event.getProperty(); if (source.equals(fConsole) && IConsoleConstants.P_FONT.equals(property)) { fViewer.setFont(fConsole.getFont()); } else if (IConsoleConstants.P_FONT_STYLE.equals(property)) { fViewer.getTextWidget().redraw(); } else if (property.equals(IConsoleConstants.P_STREAM_COLOR)) { fViewer.getTextWidget().redraw(); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_TAB_SIZE)) { Integer tabSize = (Integer)event.getNewValue(); fViewer.setTabWidth(tabSize.intValue()); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_WIDTH)) { fViewer.setConsoleWidth(fConsole.getConsoleWidth()); } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { fViewer.getTextWidget().setBackground(fConsole.getBackground()); } } }
/** * Sets the font used by this console. Specify <code>null</code> to use * the default text font. * * @param newFont font, or <code>null</code> to indicate the default font */ public void setFont(Font newFont) { // ensure font is initialized getFont(); // translate null to default font Font font = newFont; if (font == null) { font = getDefaultFont(); } // fire property change if required if (!fFont.equals(font)) { Font old = fFont; fFont = font; firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont); } }
@Override public void propertyChange(PropertyChangeEvent event) { if (fViewer != null) { Object source = event.getSource(); String property = event.getProperty(); if (source.equals(fConsole) && IConsoleConstants.P_FONT.equals(property)) { fViewer.setFont(fConsole.getFont()); } else if (IConsoleConstants.P_FONT_STYLE.equals(property)) { fViewer.getTextWidget().redraw(); } else if (property.equals(IConsoleConstants.P_STREAM_COLOR)) { fViewer.getTextWidget().redraw(); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_TAB_SIZE)) { Integer tabSize = (Integer)event.getNewValue(); fViewer.setTabWidth(tabSize.intValue()); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_WIDTH)) { fViewer.setConsoleWidth(fConsole.getConsoleWidth()); } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { fViewer.getTextWidget().setBackground(fConsole.getBackground()); } } }
/** * Constructs a new viewer in the given parent for the specified console. * * @param parent * containing widget * @param console * text console */ public TextConsoleViewer(Composite parent, TextConsole console) { super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); this.console = console; IDocument document = console.getDocument(); setDocument(document); StyledText styledText = getTextWidget(); styledText.setDoubleClickEnabled(true); styledText.addLineStyleListener(this); styledText.addLineBackgroundListener(this); styledText.setEditable(true); setFont(console.getFont()); styledText.addMouseTrackListener(this); styledText.addListener(SWT.MouseUp, mouseUpListener); ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); propertyChangeListener = new HyperlinkColorChangeListener(); colorRegistry.addListener(propertyChangeListener); revealJob.setSystem(true); document.addDocumentListener(documentListener); document.addPositionUpdater(positionUpdater); }
styledText.setEditable(true); styledText.setBackground(console.getBackground()); setFont(console.getFont()); styledText.addMouseTrackListener(this); styledText.addListener(SWT.MouseUp, mouseUpListener);