List of usage examples for org.eclipse.jface.resource JFaceResources getFont
public static Font getFont(String symbolicName)
From source file:org.apache.directory.studio.openldap.config.acl.widgets.OpenLdapAclSourceEditorComposite.java
License:Apache License
/** * Creates and configures the source editor. * */// w ww .jav a2 s . c o m private void createSourceEditor() { // create source editor sourceEditor = new SourceViewer(this, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); // setup basic configuration configuration = new OpenLdapAclSourceViewerConfiguration(); sourceEditor.configure(configuration); // set text font Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); sourceEditor.getTextWidget().setFont(font); // setup document IDocument document = new Document(); sourceEditor.setDocument(document); }
From source file:org.apache.directory.studio.schemaeditor.view.dialogs.MessageDialogWithTextarea.java
License:Apache License
@Override protected Control createCustomArea(Composite parent) { textArea = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); textArea.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = convertHorizontalDLUsToPixels((int) (IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2)); gd.heightHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 4); textArea.setLayoutData(gd);/* w ww . j a v a 2 s . com*/ //textArea.setBackground( parent.getBackground() ); textArea.setText(detailMessage); return textArea; }
From source file:org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditorSourceCodePage.java
License:Apache License
/** * {@inheritDoc}/*from w w w . java 2 s.c o m*/ */ protected void createFormContent(IManagedForm managedForm) { super.createFormContent(managedForm); ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; form.getBody().setLayout(layout); toolkit.paintBordersFor(form.getBody()); // SOURCE CODE Field schemaSourceViewer = new SchemaSourceViewer(form.getBody(), null, null, false, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 10; schemaSourceViewer.getTextWidget().setLayoutData(gd); // set text font Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); schemaSourceViewer.getTextWidget().setFont(font); IDocument document = new Document(); schemaSourceViewer.setDocument(document); // Initialization from the "input" attribute type fillInUiFields(); // Listeners initialization addListeners(); // Help Context for Dynamic Help PlatformUI.getWorkbench().getHelpSystem().setHelp(form, PluginConstants.PLUGIN_ID + "." + "attribute_type_editor"); //$NON-NLS-1$ //$NON-NLS-2$ initialized = true; }
From source file:org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditorSourceCodePage.java
License:Apache License
/** * {@inheritDoc}/*from ww w .j ava 2 s. c o m*/ */ protected void createFormContent(IManagedForm managedForm) { super.createFormContent(managedForm); ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; form.getBody().setLayout(layout); toolkit.paintBordersFor(form.getBody()); // SOURCE CODE Field schemaSourceViewer = new SchemaSourceViewer(form.getBody(), null, null, false, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 10; schemaSourceViewer.getTextWidget().setLayoutData(gd); // set text font Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); schemaSourceViewer.getTextWidget().setFont(font); IDocument document = new Document(); schemaSourceViewer.setDocument(document); // Initialization from the "input" object class fillInUiFields(); // Listeners initialization addListeners(); // Help Context for Dynamic Help PlatformUI.getWorkbench().getHelpSystem().setHelp(form, PluginConstants.PLUGIN_ID + "." + "object_class_editor"); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:org.apache.directory.studio.schemaeditor.view.editors.schema.SchemaEditorSourceCodePage.java
License:Apache License
/** * {@inheritDoc}/*www. j a va 2 s.com*/ */ protected void createFormContent(IManagedForm managedForm) { schema = ((SchemaEditor) getEditor()).getSchema(); ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); GridLayout layout = new GridLayout(); form.getBody().setLayout(layout); toolkit.paintBordersFor(form.getBody()); // SOURCE CODE Field schemaSourceViewer = new SchemaSourceViewer(form.getBody(), null, null, false, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 10; schemaSourceViewer.getTextWidget().setLayoutData(gd); schemaSourceViewer.getTextWidget().setEditable(false); // set text font Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); schemaSourceViewer.getTextWidget().setFont(font); IDocument document = new Document(); schemaSourceViewer.setDocument(document); // Initializes the UI from the schema fillInUiFields(); // Help Context for Dynamic Help PlatformUI.getWorkbench().getHelpSystem().setHelp(form, PluginConstants.PLUGIN_ID + "." + "schema_editor"); //$NON-NLS-1$ //$NON-NLS-2$ initialized = true; }
From source file:org.apache.sling.ide.eclipse.ui.views.JcrPropertiesView.java
License:Apache License
/** * This is a callback that will allow us * to create the viewer and initialize it. *//*from w ww . jav a 2 s .c o m*/ public void createPartControl(Composite parent) { SyncDirManager.registerUpdateListener(new UpdateHandler() { @Override public void syncDirUpdated(SyncDir syncDir) { refreshContent(); } }); mainControl = new Composite(parent, SWT.NONE); final GridLayout gridLayout = new GridLayout(1, true); mainControl.setLayout(gridLayout); if (getViewSite() != null) { titleLabel = new Label(mainControl, SWT.WRAP); titleLabel.setText(""); GridData data = new GridData(GridData.FILL_HORIZONTAL); titleLabel.setLayoutData(data); Label horizontalLine = new Label(mainControl, SWT.SEPARATOR | SWT.HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL); horizontalLine.setLayoutData(data); } 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); if (titleLabel != null) { titleLabel.setFont(font); } Composite tableParent = new Composite(mainControl, SWT.NONE); // tableParent.setBackground(new Color(Display.getDefault(), 100,20,180)); GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); tableLayoutData.widthHint = 1; // shrink to min - table settings will resize to correct ratios tableLayoutData.heightHint = SWT.DEFAULT; tableParent.setLayoutData(tableLayoutData); TableColumnLayout tableLayout = new TableColumnLayout() { @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point p = super.computeSize(composite, wHint, hHint, flushCache); return new Point(p.x, p.y); } }; tableParent.setLayout(tableLayout); viewer = new TableViewer(tableParent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HIDE_SELECTION | SWT.FULL_SELECTION); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer), new CellNavigationStrategy()); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { resetLastValueEdited(); return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK; TableViewerEditor.create(viewer, focusCellManager, actSupport, features); viewer.getTable().setLinesVisible(true); viewer.getTable().setHeaderVisible(true); viewer.setContentProvider(new ViewContentProvider()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection iss = (IStructuredSelection) selection; if (iss.isEmpty()) { deleteAction.setEnabled(false); } else { deleteAction.setEnabled(true); } } else { deleteAction.setEnabled(false); } } }); CellLabelProvider clp = new JcrCellLabelProvider(viewer); TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.NONE); column0.getColumn().setText("Name"); column0.getColumn().setResizable(true); column0.getColumn().setWidth(200); tableLayout.setColumnData(column0.getColumn(), new ColumnWeightData(30, 140)); final TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE); column1.getColumn().setText("Type"); column1.getColumn().setResizable(true); column1.getColumn().setWidth(300); column1.setLabelProvider(clp); tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(10, 80)); final TableViewerColumn column2 = new TableViewerColumn(viewer, SWT.NONE); column2.getColumn().setText("Value"); column2.getColumn().setResizable(true); column2.getColumn().setWidth(300); tableLayout.setColumnData(column2.getColumn(), new ColumnWeightData(70, 220)); final TableViewerColumn column3 = new TableViewerColumn(viewer, SWT.NONE); column3.getColumn().setText("Protected"); column3.getColumn().setResizable(true); column3.getColumn().setWidth(300); column3.setLabelProvider(clp); tableLayout.setColumnData(column3.getColumn(), new ColumnWeightData(5, 57)); final TableViewerColumn column4 = new TableViewerColumn(viewer, SWT.NONE); column4.getColumn().setText("Mandatory"); column4.getColumn().setResizable(true); column4.getColumn().setWidth(300); column4.setLabelProvider(clp); tableLayout.setColumnData(column4.getColumn(), new ColumnWeightData(5, 62)); final TableViewerColumn column5 = new TableViewerColumn(viewer, SWT.NONE); column5.getColumn().setText("Multiple"); column5.getColumn().setResizable(true); column5.getColumn().setWidth(300); column5.setLabelProvider(clp); tableLayout.setColumnData(column5.getColumn(), new ColumnWeightData(5, 82)); final TableViewerColumn column6 = new TableViewerColumn(viewer, SWT.NONE); column6.getColumn().setText("Auto Created"); column6.getColumn().setResizable(true); column6.getColumn().setWidth(300); column6.setLabelProvider(clp); tableLayout.setColumnData(column6.getColumn(), new ColumnWeightData(5, 77)); column0.setLabelProvider(clp); column0.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.NAME)); column1.setLabelProvider(clp); column1.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.TYPE)); column2.setLabelProvider(clp); column2.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.VALUE)); column5.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.MULTIPLE)); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.apache.sling.ide.eclipse-ui.viewer"); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); listener = new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection iss = (IStructuredSelection) selection; Object firstElem = iss.getFirstElement(); if (firstElem instanceof JcrNode) { JcrNode jcrNode = (JcrNode) firstElem; setInput(jcrNode); return; } } } }; if (getViewSite() != null) { getViewSite().getPage().addSelectionListener(listener); final ISelection selection = getViewSite().getPage().getSelection(); Display.getCurrent().asyncExec(new Runnable() { @Override public void run() { listener.selectionChanged(null, selection); } }); } }
From source file:org.cfeclipse.cfml.preferences.CFPreviewerUpdater.java
License:Open Source License
/** * Creates a source preview updater for the given viewer, configuration and preference store. * * @param viewer the viewer//from w w w .j a va 2s . c o m * @param configuration the configuration * @param preferenceStore the preference store */ public CFPreviewerUpdater(final SourceViewer viewer, final CFConfiguration configuration, final IPreferenceStore preferenceStore) { initializeViewerColors(viewer, preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { /* * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT .equals(property)) { initializeViewerColors(viewer, preferenceStore); } /* if (configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); viewer.invalidateTextPresentation(); } */ if (FormattingPreferences.affectsFormatting(event)) { format(viewer, preferenceStore); } } /** * @param viewer * @param preferenceStore */ private void format(final SourceViewer sourceViewer, final IPreferenceStore store) { String contents = loadPreviewContentFromFile("FormatPreviewCode.txt"); FormattingPreferences prefs = new FormattingPreferences(); prefs.setPreferenceStore(store); CFMLFormattingStrategy formatter = new CFMLFormattingStrategy(); contents = formatter.format(contents, prefs, "", false); viewer.getDocument().set(contents); } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { /* * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) */ public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.cfeclipse.cfml.preferences.CodeFormatterPreferencePage.java
License:Open Source License
private Control createPreviewer(Composite parent) { fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); fEditor = new CFMLEditor(); ColorManager colorMan = new ColorManager(); CFConfiguration configuration = new CFConfiguration(colorMan, fEditor); fPreviewViewer.configure(configuration); fPreviewViewer.setEditable(false);//from w w w . ja va2 s .c o m Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() }); fPreviewerUpdater = new CFPreviewerUpdater(fPreviewViewer, configuration, store); String content = loadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$ content = formatContent(content, store); //IDocument document = new Document(content); ICFDocument document = new ICFDocument(content); new CFDocumentSetupParticipant().setup(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
From source file:org.codehaus.groovy.eclipse.ui.console.GroovyConsole.java
License:Apache License
public GroovyConsole() { super("Groovy Event Trace Console", CONSOLE_TYPE, null, true); Font font = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT); setFont(font);/* ww w. j a v a 2 s. c o m*/ partitioner.connect(getDocument()); }
From source file:org.dafoe.corpuslevel.ui.views.PhraseOccurenceLabelProvider.java
License:Open Source License
@Override protected void paint(Event event, Object element) { // TODO Auto-generated method stub ISentence phrase = (ISentence) element; Display display = view.GetViewer().getControl().getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(phrase.getContent()); TextStyle plain = new TextStyle(JFaceResources.getFont(JFaceResources.DEFAULT_FONT), display.getSystemColor(SWT.COLOR_LIST_FOREGROUND), null); TextStyle italic = new TextStyle(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT), display.getSystemColor(SWT.COLOR_BLUE), null); Font newFont = new Font(display, "Arial", 9, SWT.BOLD); //$NON-NLS-1$ TextStyle font = new TextStyle(newFont, display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLUE)); List<ITermOccurrence> occurences = view.GetListOccurence(phrase); if (occurences != null) { for (int i = 0; i < occurences.size(); i++) { ITermOccurrence occ = occurences.get(i); int pos = occ.getPosition(); // int len = occ.getLength(); layout.setStyle(font, pos, pos + len - 1); }/*w ww . j a v a 2 s . c o m*/ } // layout.setStyle(plain, 0, 2); // layout.setStyle(italic, 3, 5); // layout.setStyle(font, 6, phrase.getText().length() - 1); layout.draw(event.gc, event.x, event.y); if (this.columv.getColumn().getWidth() < event.gc.textExtent(phrase.getContent()).x + 10) { this.columv.getColumn().setWidth(event.gc.textExtent(phrase.getContent()).x + 10); } }