List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont
public static Font getTextFont()
From source file:org.eclipse.photran.internal.ui.editor_vpg.hover.SourceViewerInformationControl.java
License:Open Source License
/** * Creates a source viewer information control with the given shell as parent. The given * styles are applied to the created styled text widget. The status field will * contain the given text or be hidden.//from w w w . java2 s . c om * * This constructor derives from the original SourceViewerInformationControl class that can be found at * org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl * * It has been modified to be used in Photran hover tool-tip. * @author Jungyoon Lee, Kun Koh, Nam Kim, David Weiner * * @param parent the parent shell * @param isResizable <code>true</code> if resizable * @param orientation the orientation * @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, int orientation, String statusFieldText) { Assert.isLegal( orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT || orientation == SWT.NONE); fOrientation = orientation; GridLayout layout; GridData gd; int shellStyle = SWT.TOOL | SWT.ON_TOP | orientation | (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(); initializeColors(); 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; layout.verticalSpacing = 1; composite.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); composite.setBackground(fBackgroundColor); } fViewer = new SourceViewer(composite, null, textStyle); fViewer.configure(new FortranEditor.FortranSourceViewerConfiguration(null) { @Override protected ITokenScanner getStatementTokenScanner() { // Copied from FortranEditor#getTokenScanner return new FortranKeywordRuleBasedScanner(false, fViewer); } }); fDocument = new Document(); fDocument.set(""); //$NON-NLS-1$ fViewer.setDocument(fDocument); IDocumentPartitioner partitioner = new FastPartitioner(new FortranStmtPartitionScanner(), FortranStmtPartitionScanner.PARTITION_TYPES); partitioner.connect(fDocument); fDocument.setDocumentPartitioner(partitioner); fViewer.setEditable(false); fViewer.getTextWidget().setFont(JFaceResources.getTextFont()); fText = fViewer.getTextWidget(); gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); fText.setLayoutData(gd); fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fText.setBackground(fBackgroundColor); initializeFont(); 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_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); fStatusField.setLayoutData(gd2); // Regarding the color see bug 41128 fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); fStatusField.setBackground(fBackgroundColor); } addDisposeListener(this); }
From source file:org.eclipse.photran.internal.ui.views.declaration.DeclarationView.java
License:Open Source License
private SourceViewer createFortranSourceViewer(Composite parent) { final SourceViewer viewer = new SourceViewer(parent, null, SWT.V_SCROLL); //TextViewer(parent, SWT.NONE); viewer.configure(new FortranEditor.FortranSourceViewerConfiguration(null) { @Override/*from w w w . j av a2s . c om*/ protected ITokenScanner getStatementTokenScanner() { // Copied from FortranEditor#getTokenScanner return new FortranKeywordRuleBasedScanner(false, viewer); } }); viewer.setDocument(document); IDocumentPartitioner partitioner = new FastPartitioner(new FortranStmtPartitionScanner(), FortranStmtPartitionScanner.PARTITION_TYPES); partitioner.connect(document); document.setDocumentPartitioner(partitioner); viewer.getControl().setBackground(LIGHT_YELLOW); viewer.setEditable(false); viewer.getTextWidget().setFont(JFaceResources.getTextFont()); return viewer; }
From source file:org.eclipse.php.formatter.ui.preferences.PhpPreview.java
License:Open Source License
/** * Create a new Java preview//w w w. j a v a 2 s . co m * * @param workingValues * @param parent */ public PhpPreview(CodeFormatterPreferences codeFormatterPreferences, Composite parent) { // set the PHP parser IModelManager mmanager = StructuredModelManager.getModelManager(); fParser = mmanager.createStructuredDocumentFor(ContentTypeIdForPHP.ContentTypeID_PHP).getParser(); this.codeFormatterPreferences = codeFormatterPreferences; // create the text area fText = new StyledText(parent, SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.READ_ONLY); GridData data = new GridData(GridData.FILL_BOTH); fText.setLayoutData(data); fText.setEditable(false); fText.setFont(JFaceResources.getTextFont()); }
From source file:org.eclipse.php.internal.ui.editor.PHPSourceViewer.java
License:Open Source License
public void createControls(Composite parent) { fText = new StyledText(parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fText.getContent().addTextChangeListener(new TextChangeListener() { DocumentReader docReader;//from ww w . j ava 2 s . co m Document document; public void textChanging(TextChangingEvent event) { } public void textChanged(TextChangedEvent event) { if (docReader == null) { document = new Document(); docReader = new DocumentReader(); } fInput = getText(); document.set(fInput); docReader.reset(document, 0); getParser().reset(docReader); fNodes = getParser().getDocumentRegions(); applyStyles(); } public void textSet(TextChangedEvent event) { } }); fText.setBackground(fDefaultBackground); fText.setForeground(fDefaultForeground); fText.setFont(JFaceResources.getTextFont()); setAccessible(fText, SSEUIMessages.Sample_text__UI_); //$NON-NLS-1$ = "&Sample text:" }
From source file:org.eclipse.php.internal.ui.editor.PHPSourceViewer.java
License:Open Source License
public void refresh() { if (!fText.isDisposed()) { fText.setRedraw(false);/*w w w . ja v a2 s .c o m*/ fText.setBackground(fDefaultBackground); fText.setForeground(fDefaultForeground); // update Font fText.setFont(JFaceResources.getTextFont()); // reapplyStyles applyStyles(); fText.setRedraw(true); } }
From source file:org.eclipse.ptp.ems.ui.EnvManagerConfigWidget.java
License:Open Source License
private void createEnvConfigTextbox() { envConfigTextbox = new Text(stack, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); envConfigTextbox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); envConfigTextbox.setText(""); //$NON-NLS-1$ allowEnterAndTabInTextbox(envConfigTextbox); envConfigTextbox.setFont(JFaceResources.getTextFont()); }
From source file:org.eclipse.ptp.internal.rdt.editor.preferences.PrintPreferencePage.java
License:Open Source License
/** * Sets the defaults in the store/*from w ww .j av a2 s. c om*/ */ public static void setDefaults() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); PreferenceConverter.setDefault(store, FONT_KEY, JFaceResources.getTextFont().getFontData()); store.setDefault(HEADER_KEY + LEFT_KEY, HeaderFooterProposalProvider.FILE); store.setDefault(HEADER_KEY + RIGHT_KEY, HeaderFooterProposalProvider.DATE + " " + HeaderFooterProposalProvider.TIME); store.setDefault(HEADER_KEY + CENTER_KEY, ""); store.setDefault(FOOTER_KEY + LEFT_KEY, ""); store.setDefault(FOOTER_KEY + RIGHT_KEY, StyledTextPrintOptions.PAGE_TAG); store.setDefault(FOOTER_KEY + CENTER, ""); store.setDefault(LINE_NUMBER_KEY, false); }
From source file:org.eclipse.rcptt.core.ecl.context.internal.viewer.EclContextEditor.java
License:Open Source License
public Control create(Composite parent, FormToolkit toolkit, IWorkbenchSite site, EditorHeader header) { Section section = new SectionWithComposite("Script", Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED) .create(parent, toolkit);//from w ww . j av a 2s .c o m Composite composite = (Composite) section.getClient(); CompositeRuler ruler = new CompositeRuler(); LineNumberRulerColumn column = new LineNumberRulerColumn() { @Override public int getWidth() { return super.getWidth() + 10; } }; Font font = JFaceResources.getTextFont(); column.setFont(font); column.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); ruler.addDecorator(0, column); viewer = new EclSourceViewer(composite, ruler, null, false, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setEditable(true); viewer.setDocument(new Document(getScript())); viewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { if (!event.getText().equals(event.getReplacedText())) { setScript(viewer.getDocument().get()); } } }); toolkit.adapt(viewer.getControl()); viewer.configure(new EclSourceViewerConfiguration()); viewer.getTextWidget().setFont(font); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); return section; }
From source file:org.eclipse.rcptt.ui.controls.ScriptComposite.java
License:Open Source License
@SuppressWarnings("restriction") @Override// w w w . jav a2 s . co m public void createControl(Composite parent) { super.createControl(parent); final CompositeRuler ruler = new CompositeRuler(); DefaultMarkerAnnotationAccess access = new DefaultMarkerAnnotationAccess(); AnnotationRulerColumn annotations = new AnnotationRulerColumn(12, access); ruler.addDecorator(0, annotations); LineNumberRulerColumn column = new LineNumberRulerColumn() { @Override public int getWidth() { return super.getWidth() + 10; } }; Font font = JFaceResources.getTextFont(); column.setFont(font); column.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); ruler.addDecorator(1, column); OverviewRuler overview = new OverviewRuler(access, 12, EditorsUI.getSharedTextColors()); MarkerAnnotationPreferences preferences = org.eclipse.ui.internal.editors.text.EditorsPlugin.getDefault() .getMarkerAnnotationPreferences(); AnnotationModel model = file != null ? new ResourceMarkerAnnotationModel(file) : new AnnotationModel(); Iterator<?> e = preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference preference = (AnnotationPreference) e.next(); if (preference.contributesToHeader()) overview.addHeaderAnnotationType(preference.getAnnotationType()); // annotations.addAnnotationType(preference.getAnnotationType()); } annotations.addAnnotationType(Q7Builder.MARKER_TYPE); viewer = new EclSourceViewer(parent, ruler, overview, true, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); final IDocument document = new Document(Scenarios.getScriptContent(scenario)); viewer.setDocument(document, model); viewer.configure(new EclSourceViewerConfiguration()); SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, overview, access, EditorsUI.getSharedTextColors()); Iterator<?> it = preferences.getAnnotationPreferences().iterator(); while (it.hasNext()) support.setAnnotationPreference((AnnotationPreference) it.next()); support.install(EditorsUI.getPreferenceStore()); Control rulerControl = ruler.getControl(); rulerControl.addMouseListener(new MouseListener() { public void mouseUp(final MouseEvent e) { } public void mouseDoubleClick(MouseEvent e) { if (1 == e.button) { ToggleBreakpointAction action = new ToggleBreakpointAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(), document, ruler); action.update(); action.run(); } } public void mouseDown(MouseEvent e) { } }); String id = AbstractTextEditor.DEFAULT_RULER_CONTEXT_MENU_ID; MenuManager manager = new MenuManager(id, id); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { if (viewer != null && viewer.getTextWidget() != null) viewer.getTextWidget().setFocus(); ToggleBreakpointAction action1 = new ToggleBreakpointAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(), document, ruler); action1.update(); menu.add(action1); ToggleBreakpointEnablementAction action2 = new ToggleBreakpointEnablementAction(viewer, ruler); action2.update(); if (action2.isEnabled()) { menu.add(action2); } } }); Menu fRulerContextMenu = manager.createContextMenu(rulerControl); rulerControl.setMenu(fRulerContextMenu); viewer.setEditable((Boolean) editable.getValue()); editable.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { viewer.setEditable((Boolean) editable.getValue()); } }); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); getOperationHistory().addOperationHistoryListener(new IOperationHistoryListener() { public void historyNotification(OperationHistoryEvent event) { lastDocumentOperation = event.getEventType(); } }); viewer.getDocument().addDocumentListener(new IDocumentListener() { public void documentChanged(DocumentEvent event) { if (ignoreChanges) { return; } if (!getRecordingMode().equals(RecordingMode.Recording)) { String value = viewer.getDocument().get(); if ((value == null || value.length() == 0) && lastDocumentOperation != OperationHistoryEvent.ABOUT_TO_UNDO) { clear(); } else { Scenarios.setEclContent(scenario, value); } } } public void documentAboutToBeChanged(DocumentEvent event) { // Do nothing } }); IChangeListener scenarioContentListener = new IChangeListener() { public void handleChange(ChangeEvent event) { if (ignoreChanges) { return; } String script; try { script = Scenarios.getScriptContent(scenario); } catch (Exception e) { script = SCENARIO_ERROR; Q7UIPlugin.log(e); } // in some cases after hit upon here from document listener // viewer.getDocument() is null if (viewer.getDocument() != null) { String doc = viewer.getDocument().get(); if (!doc.equals(script)) { viewer.getDocument().set(script); if ((!getRecordingMode().equals(RecordingMode.Stopped) && !getRecordingMode().equals(RecordingMode.Replaying)) && !scrollLock.get()) { try { IDocument document = viewer.getDocument(); int length = document.getLength(); if (document.getLength() > 0) { int lineOfOffset = document.getLineOfOffset(length); int lineOffset = document.getLineOffset(lineOfOffset); viewer.revealRange(lineOffset, 0); } } catch (BadLocationException e) { Q7UIPlugin.log((e)); } } } } } }; IObservableValue scriptContent = EMFObservables.observeValue(scenario, ScenarioPackage.Literals.SCENARIO__CONTENT); scriptContent.addChangeListener(scenarioContentListener); IObservableValue teslaContent = EMFObservables.observeValue(scenario, ScenarioPackage.Literals.SCENARIO__TESLA_CONTENT); teslaContent.addChangeListener(scenarioContentListener); if (site != null) { new TextViewerActionsSupport(viewer, site, editable); } else if (shell != null) { new TextViewerActionsSupport(viewer, shell, editable); } control = viewer.getControl(); }
From source file:org.eclipse.rcptt.ui.editors.ecl.EclSourceViewer.java
License:Open Source License
public static EclSourceViewer createEclSourceViewer(Composite parent) { CompositeRuler ruler = new CompositeRuler(); LineNumberRulerColumn column = new LineNumberRulerColumn() { @Override/*from w ww.j a v a 2 s. c o m*/ public int getWidth() { return super.getWidth() + 10; } }; Font font = JFaceResources.getTextFont(); column.setFont(font); column.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); ruler.addDecorator(0, column); return new EclSourceViewer(parent, ruler); }