List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont
public static Font getTextFont()
From source file:org.eclipse.rcptt.ui.verification.WidgetVerificationEditor.java
License:Open Source License
protected Control createWidgetControls(Composite parent, FormToolkit toolkit, IWorkbenchSite site, final EditorHeader header) { this.header = header; Composite box = toolkit.createComposite(parent); GridDataFactory.fillDefaults().grab(true, false).applyTo(box); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(box); Label label = toolkit.createLabel(box, "Widget:"); label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); label.setBackground(null);/*from www .j ava 2 s . c o m*/ selectorText = new StyledText(box, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).hint(1, SWT.DEFAULT).applyTo(selectorText); selectorText.setFont(JFaceResources.getTextFont()); new EclStyledTextHighlighter().install(selectorText); Binding selectorBinding = dbc.bindValue(SWTObservables.observeText(selectorText, SWT.Modify), EMFObservables.observeValue(getWidgetVerification(), ScenarioPackage.Literals.WIDGET_VERIFICATION__SELECTOR), selectorStrategy, selectorStrategy); ControlDecorationSupport.create(selectorBinding, SWT.TOP | SWT.LEFT, box, new ControlDecorationUpdater() { @Override protected void update(ControlDecoration decoration, IStatus status) { decoration.setMarginWidth(2); super.update(decoration, status); } }); final Button button = toolkit.createButton(box, "Pick...", SWT.NONE); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { AutLaunch launch = LaunchUtils.selectAutLaunch(); if (launch == null) return; VerificationType type = VerificationTypeManager.getInstance() .getTypeByVerification(getWidgetVerification()); String selector = WidgetPicker.activate(null, (BaseAutLaunch) launch, type); if (selector != null) { selectorText.setText(selector); header.getRecordButton().notifyListeners(SWT.Selection, new Event()); } } }); return box; }
From source file:org.eclipse.rcptt.verifications.text.ui.TextVerificationEditor.java
License:Open Source License
private void createControls(final FormToolkit toolkit, final Composite client) { Label introLabel = toolkit.createLabel(client, "Text should be:"); introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); introLabel.setBackground(null);/*from w ww . j a v a2s . co m*/ // -- final StyledText text = new StyledText(client, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getTextFont()); GridDataFactory.fillDefaults().grab(true, true).hint(1, 1).applyTo(text); final Button ignoreStylingCheckbox = toolkit.createButton(client, "Ignore text styling and colors", SWT.CHECK); dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), EMFObservables.observeValue(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__TEXT)); IObservableList observableStyles = EMFObservables.observeList(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__STYLES); observableStyles.addListChangeListener(new IListChangeListener() { @Override public void handleListChange(ListChangeEvent event) { updateStyling(text, ignoreStylingCheckbox); } }); // -- final Binding binding = dbc.bindValue(SWTObservables.observeSelection(ignoreStylingCheckbox), EMFObservables .observeValue(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__IGNORE_STYLING)); binding.getModel().addChangeListener(new IChangeListener() { @Override public void handleChange(ChangeEvent event) { updateStyling(text, ignoreStylingCheckbox); } }); updateStyling(text, ignoreStylingCheckbox); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.extdoc.LabelProvider.java
License:Open Source License
/** * Finds all relevant statements and creates a *very* simple summary *///from ww w.ja v a 2s .c om @Override public void update(final ViewerCell cell) { cell.setFont(JFaceResources.getTextFont()); final Selection s = (Selection) cell.getElement(); astMethod = s.method; final String varname = s.varname; if (s.isError()) { cell.setText(s.exception.getMessage()); return; } if (astMethod == ContentProvider.EMPTY) { cell.setText("// failed to resolve method."); setCellToCommentStyle(cell); return; } if (!findStatements(varname)) { cell.setText( "// No interesting statements found.\n// Either index is outdated or method is not actually using this variable?"); setCellToCommentStyle(cell); super.update(cell); return; } setCellText(cell); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.extdoc.LabelProvider.java
License:Open Source License
private void setCellText(final ViewerCell cell) { final StringBuilder sb = new StringBuilder(); for (final ASTNode n : statements) { // term matching in here:... waiting for contribution of // Kristjian... sb.append(n.toString()).append(IOUtils.LINE_SEPARATOR); }/*from w w w . j a v a 2 s . c o m*/ final String[] split = StringUtils.split(sb.toString(), IOUtils.LINE_SEPARATOR); final String summary = StringUtils.join(ArrayUtils.subarray(split, 0, 3), IOUtils.LINE_SEPARATOR); cell.setText(summary); final List<StyleRange> ranges = Lists.newArrayList(); final Color color = JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_KEYWORD); for (final String term : searchterms) { int index = 0; while (true) { index = StringUtils.indexOfIgnoreCase(summary, term, index); if (index == -1) { break; } ranges.add(new StyleRange(index, term.length(), color, null)); index += term.length(); } } cell.setFont(JFaceResources.getTextFont()); cell.setStyleRanges(ranges.toArray(new StyleRange[0])); }
From source file:org.eclipse.swtbot.forms.finder.test.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it./*w ww.j a v a 2s. c o m*/ */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse Forms"); TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("This is an example of a form that is much longer and will need to wrap."); layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); toolkit.createLabel(form.getBody(), "Text field label:"); Text text = toolkit.createText(form.getBody(), ""); td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK); td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setText("Image link with no image"); ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ih.setText("Link with image and text"); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); eci.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ec.setTextClient(eci); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText("Section title"); toolkit.createCompositeSeparator(section); section.setDescription("This is the description that goes below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append("<p>"); buf.append("Here is some plain text for the text to render; "); buf.append( "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); buf.append("</p>"); buf.append("<p>"); buf.append("<span color=\"header\" font=\"header\">This text is in header font and color.</span>"); buf.append("</p>"); buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); buf.append("We can also add <img href=\"image\"/> an image. "); buf.append("</p>"); buf.append("<li>A default (bulleted) list item.</li>"); buf.append("<li>Another bullet list item.</li>"); buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); buf.append( "<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); buf.append("</form>"); FormText rtext = toolkit.createFormText(form.getBody(), false); //rtext.setWhitespaceNormalized(false); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); rtext.setImage("image", JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); rtext.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); rtext.setFont("header", JFaceResources.getHeaderFont()); rtext.setFont("code", JFaceResources.getTextFont()); rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link active: " + e.getHref()); } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad.java
License:Open Source License
@Override public void createPartControl(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;/* w w w . j av a 2s.co m*/ layout.marginWidth = 0; panel.setLayout(layout); panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Create the head label head = new Label(panel, SWT.HORIZONTAL); head.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // Create the StyledText widget text = new StyledText(panel, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); text.setFont(JFaceResources.getTextFont()); text.addSelectionListener(this); text.addCaretListener(new CaretListener() { @Override public void caretMoved(CaretEvent event) { if (deleteHandler != null) deleteHandler.updateEnabledState(); } }); text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (!isDirty()) markDirty(true); } }); lineStyleListener = new ScriptPadLineStyleListener(); text.addLineStyleListener(lineStyleListener); // Register ourselves as selection provider getViewSite().setSelectionProvider(this); // Create the context menu createContextMenu(); // Create the toolbar createToolbar(); // Hook the global actions hookGlobalActions(); // Setup Drag n Drop setupDnD(); // Update the action bars getViewSite().getActionBars().updateActionBars(); }
From source file:org.eclipse.tcf.te.ui.notifications.delegates.DefaultFormTextFactoryDelegate.java
License:Open Source License
/** * Set the fonts used by the form.//from w w w. j av a2 s .co m * * @param toolkit The form toolkit. Must not be <code>null</code>. * @param widget The form text widget. Must not be <code>null</code>. */ protected void setFormTextFonts(FormToolkit toolkit, FormText widget) { Assert.isNotNull(toolkit); Assert.isNotNull(widget); widget.setFont("header", JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); //$NON-NLS-1$ widget.setFont("text", JFaceResources.getTextFont()); //$NON-NLS-1$ }
From source file:org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl.java
License:Open Source License
protected void setupControls(Composite parent) { // The Terminal view now aims to be an ANSI-conforming terminal emulator, so it // can't have a horizontal scroll bar (but a vertical one is ok). Also, do // _not_ make the TextViewer read-only, because that prevents it from seeing a // TAB character when the user presses TAB (instead, the TAB causes focus to // switch to another Workbench control). We prevent local keyboard input from // modifying the text in method TerminalVerifyKeyListener.verifyKey(). fWndParent = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0;/* ww w.j av a 2 s .c o m*/ layout.marginHeight = 0; layout.verticalSpacing = 0; fWndParent.setLayout(layout); ITerminalTextDataSnapshot snapshot = fTerminalModel.makeSnapshot(); // TODO how to get the initial size correctly! snapshot.updateSnapshot(false); ITextCanvasModel canvasModel = new PollingTextCanvasModel(snapshot); fCtlText = createTextCanvas(fWndParent, canvasModel, createLineRenderer(canvasModel)); fCtlText.setLayoutData(new GridData(GridData.FILL_BOTH)); fCtlText.addResizeHandler(new TextCanvas.ResizeListener() { public void sizeChanged(int lines, int columns) { fTerminalText.setDimensions(lines, columns); } }); fCtlText.addMouseListener(new MouseAdapter() { public void mouseUp(MouseEvent e) { // update selection used by middle mouse button paste if (e.button == 1 && getSelection().length() > 0) { copy(DND.SELECTION_CLIPBOARD); } } }); fDisplay = getCtlText().getDisplay(); fClipboard = new Clipboard(fDisplay); // fViewer.setDocument(new TerminalDocument()); setFont(JFaceResources.getTextFont()); }
From source file:org.eclipse.tm4e.ui.internal.widgets.TMViewer.java
License:Open Source License
public void setTheme(ITheme theme) { reconciler.setThemeId(theme.getId()); StyledText styledText = getTextWidget(); styledText.setForeground(null);/* ww w .j a va 2 s . c o m*/ styledText.setBackground(null); theme.initializeViewerColors(styledText); getTextWidget().setFont(JFaceResources.getTextFont()); }
From source file:org.eclipse.ui.editors.text.TextEditorPreferencePage.java
License:Open Source License
/** * Initializes the defaults for the given store. * * @param store the preference store//from w ww . ja v a2 s .c o m * @since 2.0 */ public static void initDefaults(IPreferenceStore store) { if (fgInitialized) return; fgInitialized = true; Font font = JFaceResources.getTextFont(); if (font != null) { FontData[] data = font.getFontData(); if (data != null && data.length > 0) PreferenceConverter.setDefault(store, JFaceResources.TEXT_FONT, data[0]); } Display display = Display.getDefault(); Color color = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, color.getRGB()); store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true); color = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, color.getRGB()); store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true); }