List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont
public static Font getTextFont()
From source file:org.fusesource.ide.zk.jmx.jmxdoc.JmxDocFormText.java
License:Apache License
public static void initFormText(FormText formText) { formText.setWhitespaceNormalized(false); Font formTextFont = formText.getFont(); FontData formTextFontData = formTextFont.getFontData()[0]; FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD); final Font h1Font = new Font(formTextFont.getDevice(), h1FontData); formText.setFont(FONT_H1_KEY, h1Font); FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD); final Font h3Font = new Font(formTextFont.getDevice(), h3FontData); formText.setFont(FONT_H3_KEY, h3Font); Font codeFont = JFaceResources.getTextFont(); formText.setFont(FONT_CODE_KEY, codeFont); formText.addDisposeListener(new DisposeListener() { @Override/*from ww w.j a va2 s .c om*/ public void widgetDisposed(DisposeEvent e) { h1Font.dispose(); h3Font.dispose(); } }); // Set fontKeySet = JFaceResources.getFontRegistry().getKeySet(); // if (fontKeySet != null) { // for (Object fontKey : fontKeySet) { // System.out.println(fontKey); // } // } }
From source file:org.fusesource.ide.zk.zookeeper.editors.znodeform.ZnodeModelTextDataEditor.java
License:Apache License
@Override protected void createContent() { FormToolkit toolkit = getToolkit();/*from ww w.ja v a2 s. c o m*/ _Text = toolkit.createText(this, "", SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); _Text.setFont(JFaceResources.getTextFont()); setLayout(new FillLayout()); /* FormData formData = new FormData(); formData.top = new FormAttachment(0, 0); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); _Text.setLayoutData(formData); */ _Text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { setDirtyInternal(true); } }); }
From source file:org.jboss.tools.birt.oda.ui.impl.CustomDataSetWizardPage.java
License:Open Source License
private Control createQueryComposite(Composite parent) { Composite composite = new Composite(parent, SWT.FILL | SWT.LEFT_TO_RIGHT); GridLayout layout = new GridLayout(); layout.numColumns = 1;//ww w . j a v a2 s . co m composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); CompositeRuler ruler = new CompositeRuler(); LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn(); ruler.addDecorator(0, lineNumbers); sourceViewer = new SourceViewer(composite, ruler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); sourceViewer.setInput(parent); styledText = sourceViewer.getTextWidget(); styledText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateData(); } }); styledText.setFont(JFaceResources.getTextFont()); Control control = sourceViewer.getControl(); GridData gd = new GridData(GridData.FILL_BOTH); control.setLayoutData(gd); IDocument document = new Document(); document.set(getInitialQueryString()); HQLEditorDocumentSetupParticipant docSetupParticipant = new HQLEditorDocumentSetupParticipant(); docSetupParticipant.setup(document); sourceViewer.setEditable(true); sourceViewer.setDocument(document); IUndoManager undoManager = new TextViewerUndoManager(10); sourceViewer.setUndoManager(undoManager); undoManager.connect(sourceViewer); attachMenus(sourceViewer); // add support of additional accelerated key sourceViewer.getTextWidget().addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (isUndoKeyPress(e)) { sourceViewer.doOperation(ITextOperationTarget.UNDO); } else if (isRedoKeyPress(e)) { sourceViewer.doOperation(ITextOperationTarget.REDO); } validateData(); } private boolean isUndoKeyPress(KeyEvent e) { // CTRL + z return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'z') || (e.keyCode == 'Z')); } private boolean isRedoKeyPress(KeyEvent e) { // CTRL + y return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'y') || (e.keyCode == 'Y')); } public void keyReleased(KeyEvent e) { // do nothing } }); IHandler handler = new AbstractHandler() { public Object execute(ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException { sourceViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); return null; } }; IWorkbench workbench = PlatformUI.getWorkbench(); fService = (IHandlerService) workbench.getAdapter(IHandlerService.class); fActivation = fService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler); QueryEditor editor = new QueryEditor() { public boolean askUserForConfiguration(String name) { return false; } public void executeQuery(ConsoleConfiguration cfg) { } public ConsoleConfiguration getConsoleConfiguration() { return getInternalConsoleConfiguration(); } public String getConsoleConfigurationName() { return getConfigurationName(); } public QueryInputModel getQueryInputModel() { return null; } public String getQueryString() { return null; } public String getEditorText() { return null; } public void setConsoleConfigurationName(String text) { } }; SourceViewerConfiguration svc = new HQLSourceViewerConfiguration(editor); sourceViewer.configure(svc); testButton = new Button(composite, SWT.NONE); testButton.setText(Messages.CustomDataSetWizardPage_Test_query); testButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { testQuery(); } }); return composite; }
From source file:org.jboss.tools.jst.web.ui.palette.html.jquery.wizard.JQueryVersionPage.java
License:Open Source License
void createTextPreview(Composite parent) { text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL); text.setFont(JFaceResources.getTextFont()); text.setLayoutData(new GridData(GridData.FILL_BOTH)); /**/*from ww w . j av a 2 s . co m*/ * We set some initial content to the text widget to provide a reasonable default width * for that widget and for browser. We avoid setting width hint or other ways to * provide the default width, because text widget and browser should be resizable * and their content will be formatted to the available width. Also, initial width * is to depend on system font size so that initial content serves best to that purpose. */ text.setText( "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<html><body>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</body></html>"); previewPanel = text; }
From source file:org.jboss.tools.jst.web.ui.palette.html.wizard.AbstractNewHTMLWidgetWizardPage.java
License:Open Source License
void createTextPreview(Composite parent) { text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL); text.setFont(JFaceResources.getTextFont()); text.setLayoutData(new GridData(GridData.FILL_BOTH)); /**//from w w w. j a v a 2 s. co m * We set some initial content to the text widget to provide a reasonable default width * for that widget and for browser. We avoid setting width hint or other ways to * provide the default width, because text widget and browser should be resizable * and their content will be formatted to the available width. Also, initial width * is to depend on system font size so that initial content serves best to that purpose. */ text.setText( "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<html><body>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</body></html>"); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.gaf.GafOptionsPage.java
License:Open Source License
private void createCodeMappingCombo(final Group group, final Object[] availableCodes, final IObservableValue model) { final ComboViewer viewer = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY); viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); viewer.getControl().setFont(JFaceResources.getTextFont()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(availableCodes);//from w w w.j ava2s . c om viewer.setComparator(new ViewerComparableComparator()); final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer); final DataBinder dataBinder = new DataBinder(target, model); dataBinder.addTargetAfterGetValidator( new NotNullValidator<>(Object.class, IStatus.ERROR, Messages.getString("GafOptionsPage.15"))); //$NON-NLS-1$ m_binding.bindValue(dataBinder); }
From source file:org.kalypso.model.wspm.ui.commands.MousePositionChartHandler.java
License:Open Source License
public MousePositionChartHandler(final IChartComposite chart) { super(chart); final TitleTypeBean title = new TitleTypeBean(); title.setInsets(new Insets(2, 2, 2, 2)); title.setRotation(0);/*w ww . ja v a 2s . co m*/ title.setPositionHorizontal(ALIGNMENT.RIGHT); title.setTextAnchorX(ALIGNMENT.RIGHT); title.setPositionVertical(ALIGNMENT.TOP); title.setTextAnchorY(ALIGNMENT.BOTTOM); final IChartModel model = chart.getChartModel(); if (model == null) { final FontData fontData = JFaceResources.getTextFont().getFontData()[0]; final RGB rgbFill = new RGB(255, 255, 255); final RGB rgbText = new RGB(0, 0, 0); title.setTextStyle(new TextStyle(fontData.getHeight(), fontData.getName(), rgbText, rgbFill, FONTSTYLE.NORMAL, FONTWEIGHT.NORMAL, ALIGNMENT.LEFT, 255, true)); } else { title.setTextStyle(model.getSettings().getTextStyle()); } m_labelRenderer = new GenericChartLabelRenderer(title); }
From source file:org.netxms.ui.eclipse.agentmanager.widgets.AgentConfigEditor.java
License:Open Source License
/** * @param parent// ww w. j a va 2 s .c o m * @param style * @param editorStyle * @param rulerWidth */ public AgentConfigEditor(Composite parent, int style, int editorStyle, int rulerWidth) { super(parent, style); setLayout(new FillLayout()); editor = new SourceViewer(this, (rulerWidth > 0) ? new VerticalRuler(rulerWidth) : null, editorStyle); editor.configure(new AgentConfigSourceViewerConfiguration()); final TextViewerUndoManager undoManager = new TextViewerUndoManager(50); editor.setUndoManager(undoManager); undoManager.connect(editor); editor.getFindReplaceTarget(); editor.prependVerifyKeyListener(new VerifyKeyListener() { @Override public void verifyKey(VerifyEvent event) { if (!event.doit) return; if (event.stateMask == SWT.MOD1) { switch (event.character) { case ' ': editor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); event.doit = false; break; case 0x19: // Ctrl+Y undoManager.redo(); event.doit = false; break; case 0x1A: // Ctrl+Z undoManager.undo(); event.doit = false; break; } } else if (event.stateMask == SWT.NONE) { if (event.character == 0x09) { if (editor.getSelectedRange().y > 0) { editor.doOperation(ITextOperationTarget.SHIFT_RIGHT); event.doit = false; } } } else if (event.stateMask == SWT.SHIFT) { if (event.character == 0x09) { if (editor.getSelectedRange().y > 0) { editor.doOperation(ITextOperationTarget.SHIFT_LEFT); event.doit = false; } } } } }); StyledText control = editor.getTextWidget(); control.setFont(JFaceResources.getTextFont()); control.setWordWrap(false); }
From source file:org.netxms.ui.eclipse.filemanager.widgets.BaseFileViewer.java
License:Open Source License
/** * Create file viewer/*from ww w .jav a 2 s .c om*/ * * @param parent * @param style */ public BaseFileViewer(Composite parent, int style, IViewPart viewPart) { super(parent, style); this.viewPart = viewPart; setLayout(new FormLayout()); /*** Message bar ***/ messageBar = new Composite(this, SWT.NONE); messageBar.setBackground(SharedColors.getColor(SharedColors.MESSAGE_BAR_BACKGROUND, getDisplay())); messageBar.setForeground(SharedColors.getColor(SharedColors.MESSAGE_BAR_TEXT, getDisplay())); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.numColumns = 2; messageBar.setLayout(layout); messageBar.setVisible(false); messageBarLabel = new CLabel(messageBar, SWT.NONE); messageBarLabel.setBackground(messageBar.getBackground()); messageBarLabel.setForeground(messageBar.getForeground()); GridData gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.grabExcessHorizontalSpace = true; messageBarLabel.setLayoutData(gd); messageCloseButton = new Label(messageBar, SWT.NONE); messageCloseButton.setBackground(messageBar.getBackground()); messageCloseButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND)); messageCloseButton.setImage(SharedIcons.IMG_CLOSE); messageCloseButton.setToolTipText(Messages.get().BaseFileViewer_HideMessage); gd = new GridData(); gd.verticalAlignment = SWT.CENTER; messageCloseButton.setLayoutData(gd); messageCloseButton.addMouseListener(new MouseListener() { private boolean doAction = false; @Override public void mouseDoubleClick(MouseEvent e) { if (e.button == 1) doAction = false; } @Override public void mouseDown(MouseEvent e) { if (e.button == 1) doAction = true; } @Override public void mouseUp(MouseEvent e) { if ((e.button == 1) && doAction) hideMessage(); } }); Label separator = new Label(messageBar, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.horizontalSpan = 2; separator.setLayoutData(gd); FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); messageBar.setLayoutData(fd); /*** Text area ***/ text = new StyledText(this, SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getTextFont()); fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); fd.bottom = new FormAttachment(100, 0); text.setLayoutData(fd); text.addLineStyleListener(new LineStyleListener() { @Override public void lineGetStyle(LineStyleEvent event) { try { event.styles = styleLine(event.lineText); if (event.styles != null) { for (StyleRange r : event.styles) r.start += event.lineOffset; } } catch (Exception e) { // TODO: log } } }); /*** Search bar ***/ searchBar = new Composite(this, SWT.NONE); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 3; layout.marginBottom = 3; layout.numColumns = 3; searchBar.setLayout(layout); searchBar.setVisible(false); separator = new Label(searchBar, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.horizontalSpan = 3; separator.setLayoutData(gd); Label searchBarLabel = new Label(searchBar, SWT.LEFT); searchBarLabel.setText(Messages.get().BaseFileViewer_Find); searchBarLabel.setBackground(searchBar.getBackground()); searchBarLabel.setForeground(searchBar.getForeground()); gd = new GridData(); gd.horizontalAlignment = SWT.LEFT; gd.verticalAlignment = SWT.CENTER; gd.horizontalIndent = 5; searchBarLabel.setLayoutData(gd); Composite searchBarTextContainer = new Composite(searchBar, SWT.BORDER); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 3; layout.horizontalSpacing = 0; searchBarTextContainer.setLayout(layout); gd = new GridData(); gd.verticalAlignment = SWT.CENTER; gd.horizontalAlignment = SWT.LEFT; gd.widthHint = 400; searchBarTextContainer.setLayoutData(gd); searchBarText = new Text(searchBarTextContainer, SWT.NONE); searchBarText.setMessage(Messages.get().BaseFileViewer_FindInFile); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.CENTER; gd.grabExcessHorizontalSpace = true; searchBarText.setLayoutData(gd); searchBarText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { doSearch(true); } }); searchBarText.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { } @Override public void widgetDefaultSelected(SelectionEvent e) { doSearch(false); } }); searchBarTextContainer.setBackground(searchBarText.getBackground()); ToolBar searchButtons = new ToolBar(searchBarTextContainer, SWT.FLAT); gd = new GridData(); gd.verticalAlignment = SWT.FILL; gd.horizontalAlignment = SWT.LEFT; searchButtons.setLayoutData(gd); ToolItem item = new ToolItem(searchButtons, SWT.PUSH); item.setImage(SharedIcons.IMG_UP); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doReverseSearch(); } }); item = new ToolItem(searchButtons, SWT.PUSH); item.setImage(SharedIcons.IMG_DOWN); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doSearch(false); } }); searchCloseButton = new Label(searchBar, SWT.NONE); searchCloseButton.setBackground(searchBar.getBackground()); searchCloseButton.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND)); searchCloseButton.setImage(SharedIcons.IMG_CLOSE); searchCloseButton.setToolTipText(Messages.get().BaseFileViewer_Close); gd = new GridData(); gd.verticalAlignment = SWT.CENTER; gd.horizontalAlignment = SWT.RIGHT; gd.widthHint = 20; searchCloseButton.setLayoutData(gd); searchCloseButton.addMouseListener(new MouseListener() { private boolean doAction = false; @Override public void mouseDoubleClick(MouseEvent e) { if (e.button == 1) doAction = false; } @Override public void mouseDown(MouseEvent e) { if (e.button == 1) doAction = true; } @Override public void mouseUp(MouseEvent e) { if ((e.button == 1) && doAction) hideSearchBar(); } }); fd = new FormData(); fd.bottom = new FormAttachment(100, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); searchBar.setLayoutData(fd); }
From source file:org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor.java
License:Open Source License
/** * @param parent// www . ja v a 2 s. co m * @param style * @param editorStyle * @param showLineNumbers * @param hints */ public ScriptEditor(Composite parent, int style, int editorStyle, boolean showLineNumbers, String hints) { super(parent, style); hintText = hints; GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.verticalSpacing = 0; setLayout(layout); if (hints != null) { createHintsArea(); } proposalIcons[0] = Activator.getImageDescriptor("icons/function.gif").createImage(); //$NON-NLS-1$ proposalIcons[1] = Activator.getImageDescriptor("icons/var_global.gif").createImage(); //$NON-NLS-1$ proposalIcons[2] = Activator.getImageDescriptor("icons/var_local.gif").createImage(); //$NON-NLS-1$ proposalIcons[3] = Activator.getImageDescriptor("icons/constant.gif").createImage(); //$NON-NLS-1$ ruler = new CompositeRuler(); editor = new SourceViewer(this, ruler, editorStyle); editor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); editor.configure(new NXSLSourceViewerConfiguration(this)); if (showLineNumbers) ruler.addDecorator(0, new LineNumberRulerColumn()); final TextViewerUndoManager undoManager = new TextViewerUndoManager(50); editor.setUndoManager(undoManager); undoManager.connect(editor); editor.getFindReplaceTarget(); editor.prependVerifyKeyListener(new VerifyKeyListener() { @Override public void verifyKey(VerifyEvent event) { if (!event.doit) return; if (event.stateMask == SWT.MOD1) { switch (event.character) { case ' ': editor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); event.doit = false; break; case 0x19: // Ctrl+Y undoManager.redo(); event.doit = false; break; case 0x1A: // Ctrl+Z undoManager.undo(); event.doit = false; break; } } else if (event.stateMask == SWT.NONE) { if (event.character == 0x09) { if (editor.getSelectedRange().y > 0) { editor.doOperation(ITextOperationTarget.SHIFT_RIGHT); event.doit = false; } } } else if (event.stateMask == SWT.SHIFT) { if (event.character == 0x09) { if (editor.getSelectedRange().y > 0) { editor.doOperation(ITextOperationTarget.SHIFT_LEFT); event.doit = false; } } } } }); StyledText control = editor.getTextWidget(); control.setFont(JFaceResources.getTextFont()); control.setWordWrap(false); editor.setDocument(new NXSLDocument("")); //$NON-NLS-1$ }