List of usage examples for org.eclipse.jface.resource JFaceResources getDefaultFont
public static Font getDefaultFont()
From source file:org.eclipse.debug.internal.ui.views.breakpoints.WorkingSetCategory.java
License:Open Source License
public FontData getFont(Object element) { if (isDefault()) { FontData[] fontData = JFaceResources.getDefaultFont().getFontData(); if (fontData != null && fontData.length > 0) { FontData data = fontData[0]; data.setStyle(SWT.BOLD);/*from www.ja va2 s . c o m*/ return data; } } return null; }
From source file:org.eclipse.e4.ui.internal.progress.DetailedProgressViewer.java
License:Open Source License
/** * Create a new instance of the receiver with a control that is a child of * parent with style style.// www .java 2s.c om * * @param parent * @param style */ public DetailedProgressViewer(Composite parent, int style) { scrolled = new ScrolledComposite(parent, SWT.V_SCROLL | style); int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); scrolled.getVerticalBar().setIncrement(height * 2); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); control = new Composite(scrolled, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; control.setLayout(layout); control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.addFocusListener(new FocusAdapter() { private boolean settingFocus = false; /* * (non-Javadoc) * * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) { if (!settingFocus) { // Prevent new focus events as a result this update // occurring settingFocus = true; setFocus(); settingFocus = false; } } }); control.addControlListener(new ControlListener() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) */ public void controlMoved(ControlEvent e) { updateVisibleItems(); } /* * (non-Javadoc) * * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) */ public void controlResized(ControlEvent e) { updateVisibleItems(); } }); scrolled.setContent(control); hookControl(control); noEntryArea = new Composite(scrolled, SWT.NONE); noEntryArea.setLayout(new GridLayout()); Text noEntryLabel = new Text(noEntryArea, SWT.SINGLE); noEntryLabel.setText(ProgressMessages.ProgressView_NoOperations); noEntryLabel.setBackground(noEntryArea.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); GridData textData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); noEntryLabel.setLayoutData(textData); noEntryLabel.setEditable(false); }
From source file:org.eclipse.e4.ui.progress.internal.DetailedProgressViewer.java
License:Open Source License
/** * Create a new instance of the receiver with a control that is a child of * parent with style style./*www . j a v a 2 s . c o m*/ * * @param parent * @param style */ public DetailedProgressViewer(Composite parent, int style, IProgressService progressService, FinishedJobs finishedJobs) { this.progressService = progressService; this.finishedJobs = finishedJobs; scrolled = new ScrolledComposite(parent, SWT.V_SCROLL | style); int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); scrolled.getVerticalBar().setIncrement(height * 2); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); control = new Composite(scrolled, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; control.setLayout(layout); control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.addFocusListener(new FocusAdapter() { private boolean settingFocus = false; @Override public void focusGained(FocusEvent e) { if (!settingFocus) { // Prevent new focus events as a result this update // occurring settingFocus = true; setFocus(); settingFocus = false; } } }); control.addControlListener(new ControlListener() { @Override public void controlMoved(ControlEvent e) { updateVisibleItems(); } @Override public void controlResized(ControlEvent e) { updateVisibleItems(); } }); // TODO E4 - missing e4 replacement // PlatformUI.getWorkbench().getHelpSystem().setHelp(control, // IWorkbenchHelpContextIds.RESPONSIVE_UI); scrolled.setContent(control); hookControl(control); noEntryArea = new Composite(scrolled, SWT.NONE); noEntryArea.setLayout(new GridLayout()); noEntryArea.setBackground(noEntryArea.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); Text noEntryLabel = new Text(noEntryArea, SWT.SINGLE); noEntryLabel.setText(ProgressMessages.ProgressView_NoOperations); noEntryLabel.setBackground(noEntryArea.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); GridData textData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); noEntryLabel.setLayoutData(textData); noEntryLabel.setEditable(false); // TODO E4 - missing e4 replacement // PlatformUI.getWorkbench().getHelpSystem().setHelp(noEntryLabel, // IWorkbenchHelpContextIds.RESPONSIVE_UI); }
From source file:org.eclipse.ecf.internal.example.collab.ui.LineChatClientView.java
License:Open Source License
public LineChatClientView(EclipseCollabSharedObject lch, LineChatView view, String name, String initText, String downloaddir) {// w ww. j a va 2 s . co m super(); this.lch = lch; this.view = view; this.name = name; this.teamChat = new TeamChat(this, view.tabFolder, SWT.NULL, initText); this.userdata = lch.getUser(); this.downloaddir = downloaddir; users = new ArrayList(); teamChat.getTableViewer().setInput(users); if (userdata != null) addUser(userdata); ClientPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ClientPlugin.PREF_DISPLAY_TIMESTAMP)) { showTimestamp = ((Boolean) event.getNewValue()).booleanValue(); } } }); JFaceResources.getColorRegistry().put(ViewerToolTip.HEADER_BG_COLOR, new RGB(255, 255, 255)); JFaceResources.getFontRegistry().put(ViewerToolTip.HEADER_FONT, JFaceResources.getFontRegistry() .getBold(JFaceResources.getDefaultFont().getFontData()[0].getName()).getFontData()); final ToolTip toolTip = new ViewerToolTip(teamChat.getTableViewer().getControl()); toolTip.setHideOnMouseDown(false); toolTip.setPopupDelay(200); }
From source file:org.eclipse.ecf.salvo.ui.internal.editor.ArticlePaneLabelProvider.java
License:Open Source License
public Font getFont(Object element, int columnIndex) { IArticle article = (IArticle) ((ISalvoResource) element).getObject(); if (columnIndex == 0) { if (!article.isRead()) { return unreadArticle; }// ww w.j a v a2s . c om if (!article.isReplyRead()) { return unreadReplies; } } return JFaceResources.getDefaultFont(); }
From source file:org.eclipse.ecf.salvo.ui.notifications.SalvoNotificationPopup.java
License:Open Source License
@Override protected void createContentArea(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); {//from w w w .jav a 2 s . co m Composite imageComposite = new Composite(composite, SWT.NULL); imageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); imageComposite.setLayout(new GridLayout(1, false)); // Image Label lblImage = new Label(imageComposite, SWT.NONE); lblImage.setImage(Activator.getDefault().getImageRegistry().get("news.gif")); lblImage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // No of Articles Label lblNumOfArticles = new Label(imageComposite, SWT.NONE); Font font = JFaceResources.getBannerFont(); FontData fd = font.getFontData()[0]; fd.setStyle(SWT.BOLD); lblNumOfArticles.setFont(new Font(font.getDevice(), fd)); lblNumOfArticles.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblNumOfArticles.setText(Integer.toString(articles.length)); } { Composite txtComposite = new Composite(composite, SWT.NULL); txtComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); txtComposite.setLayout(new GridLayout(1, false)); if (articles.length < 10) { for (int i = 0; i < articles.length; i++) { Label dataLabel = new Label(txtComposite, SWT.None); dataLabel.setText(DecoderUtil.decodeEncodedWords(articles[i].getSubject())); dataLabel.setBackground(parent.getBackground()); } } else { for (int i = 0; i < 10; i++) { Label dataLabel = new Label(txtComposite, SWT.None); dataLabel.setText(DecoderUtil.decodeEncodedWords(articles[i].getSubject())); dataLabel.setBackground(parent.getBackground()); } Label lastDataLabel = new Label(txtComposite, SWT.None); lastDataLabel.setText("and " + (articles.length - 10) + " other articles received....."); lastDataLabel.setBackground(parent.getBackground()); Font font = JFaceResources.getDefaultFont(); FontData fd = font.getFontData()[0]; fd.setStyle(SWT.BOLD | SWT.ITALIC); lastDataLabel.setFont(new Font(font.getDevice(), fd)); } } }
From source file:org.eclipse.egit.ui.internal.preferences.ConfigurationEditorComponent.java
License:Open Source License
/** * @return the control being created//from w w w .j a va 2s .co m */ public Control createContents() { final Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout(1, false)); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); if (editableConfig instanceof FileBasedConfig) { Composite locationPanel = new Composite(main, SWT.NONE); locationPanel.setLayout(new GridLayout(3, false)); GridDataFactory.fillDefaults().grab(true, false).applyTo(locationPanel); Label locationLabel = new Label(locationPanel, SWT.NONE); locationLabel.setText(UIText.ConfigurationEditorComponent_ConfigLocationLabel); // GridDataFactory.fillDefaults().applyTo(locationLabel); location = new Text(locationPanel, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(location); location.setEditable(false); Button openEditor = new Button(locationPanel, SWT.PUSH); // GridDataFactory.fillDefaults().applyTo(openEditor); openEditor.setText(UIText.ConfigurationEditorComponent_OpenEditorButton); openEditor.setToolTipText(UIText.ConfigurationEditorComponent_OpenEditorTooltip); openEditor.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IFileStore store = EFS.getLocalFileSystem() .getStore(new Path(((FileBasedConfig) editableConfig).getFile().getAbsolutePath())); try { IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID); } catch (PartInitException ex) { Activator.handleError(ex.getMessage(), ex, true); } } }); } tv = new TreeViewer(main, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); Tree tree = tv.getTree(); GridDataFactory.fillDefaults().hint(100, 60).grab(true, true).applyTo(tree); TreeColumn key = new TreeColumn(tree, SWT.NONE); key.setText(UIText.ConfigurationEditorComponent_KeyColumnHeader); key.setWidth(150); TreeColumn value = new TreeColumn(tree, SWT.NONE); value.setText(UIText.ConfigurationEditorComponent_ValueColumnHeader); value.setWidth(250); tv.setContentProvider(new ConfigEditorContentProvider()); Font defaultFont; if (useDialogFont) defaultFont = JFaceResources.getDialogFont(); else defaultFont = JFaceResources.getDefaultFont(); tv.setLabelProvider(new ConfigEditorLabelProvider(defaultFont)); tree.setHeaderVisible(true); tree.setLinesVisible(true); // if section or subsection is selected, we show the remove button Composite buttonPanel = new Composite(main, SWT.NONE); buttonPanel.setLayout(new GridLayout(2, false)); GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel); final Button newEntry = new Button(buttonPanel, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(newEntry); newEntry.setText(UIText.ConfigurationEditorComponent_NewValueButton); newEntry.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String suggestedKey; IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); Object first = sel.getFirstElement(); if (first instanceof Section) suggestedKey = ((Section) first).name + DOT; else if (first instanceof SubSection) { SubSection sub = (SubSection) first; suggestedKey = sub.parent.name + DOT + sub.name + DOT; } else if (first instanceof Entry) { Entry entry = (Entry) first; if (entry.sectionparent != null) suggestedKey = entry.sectionparent.name + DOT; else suggestedKey = entry.subsectionparent.parent.name + DOT + entry.subsectionparent.name + DOT; } else suggestedKey = null; AddConfigEntryDialog dlg = new AddConfigEntryDialog(getShell(), editableConfig, suggestedKey); if (dlg.open() == Window.OK) { StringTokenizer st = new StringTokenizer(dlg.getKey(), DOT); if (st.countTokens() == 2) { editableConfig.setString(st.nextToken(), null, st.nextToken(), dlg.getValue()); markDirty(); } else if (st.countTokens() == 3) { editableConfig.setString(st.nextToken(), st.nextToken(), st.nextToken(), dlg.getValue()); markDirty(); } else Activator.handleError(UIText.ConfigurationEditorComponent_WrongNumberOfTokensMessage, null, true); } } }); remove = new Button(buttonPanel, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(remove); remove.setText(UIText.ConfigurationEditorComponent_RemoveAllButton); remove.setToolTipText(UIText.ConfigurationEditorComponent_RemoveAllTooltip); remove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); Object first = sel.getFirstElement(); if (first instanceof Section) { Section section = (Section) first; if (MessageDialog.openConfirm(getShell(), UIText.ConfigurationEditorComponent_RemoveSectionTitle, NLS.bind(UIText.ConfigurationEditorComponent_RemoveSectionMessage, section.name))) { editableConfig.unsetSection(section.name, null); markDirty(); } } else if (first instanceof SubSection) { SubSection section = (SubSection) first; if (MessageDialog.openConfirm(getShell(), UIText.ConfigurationEditorComponent_RemoveSubsectionTitle, NLS.bind(UIText.ConfigurationEditorComponent_RemoveSubsectionMessage, section.parent.name + DOT + section.name))) { editableConfig.unsetSection(section.parent.name, section.name); markDirty(); } } else { Activator.handleError(UIText.ConfigurationEditorComponent_NoSectionSubsectionMessage, null, true); } super.widgetSelected(e); } }); // if an entry is selected, then we show the value plus change button Composite valuePanel = new Composite(main, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(valuePanel); valuePanel.setLayout(new GridLayout(3, false)); new Label(valuePanel, SWT.NONE).setText(UIText.ConfigurationEditorComponent_ValueLabel); valueText = new Text(valuePanel, SWT.BORDER); valueText.setText(UIText.ConfigurationEditorComponent_NoEntrySelectedMessage); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(valueText); // make the buttons equal width Composite buttonContainer = new Composite(valuePanel, SWT.NONE); buttonContainer.setLayout(new GridLayout(3, true)); changeValue = new Button(buttonContainer, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(changeValue); changeValue.setText(UIText.ConfigurationEditorComponent_ChangeButton); changeValue.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); Object first = sel.getFirstElement(); if (first instanceof Entry) { Entry entry = (Entry) first; entry.changeValue(valueText.getText()); markDirty(); } } }); deleteValue = new Button(buttonContainer, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(deleteValue); deleteValue.setText(UIText.ConfigurationEditorComponent_DeleteButton); deleteValue.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); Object first = sel.getFirstElement(); if (first instanceof Entry) { Entry entry = (Entry) first; entry.removeValue(); markDirty(); } } }); addValue = new Button(buttonContainer, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(addValue); addValue.setText(UIText.ConfigurationEditorComponent_AddButton); addValue.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); Object first = sel.getFirstElement(); if (first instanceof Entry) { Entry entry = (Entry) first; entry.addValue(valueText.getText()); markDirty(); } } }); tv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateEnablement(); } }); valueText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (valueText.getText().length() == 0) { setErrorMessage(UIText.ConfigurationEditorComponent_EmptyStringNotAllowed); changeValue.setEnabled(false); } else { setErrorMessage(null); changeValue.setEnabled(true); } } }); initControlsFromConfig(); return main; }
From source file:org.eclipse.epf.diagram.core.util.DiagramCoreUtil.java
License:Open Source License
/** * Set the default font for this preference store. * @param store IPreferenceStore/*ww w. ja va2 s . c om*/ */ public static void setDefaultFontPreference(IPreferenceStore store) { FontData fontDataArray[] = JFaceResources.getDefaultFont().getFontData(); FontData fontData = fontDataArray[0]; fontData.setHeight(DiagramConstants.DEFAULT_FONT_SIZE); fontData.setName(DiagramConstants.DEFAULT_FONT_NAME); PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_DEFAULT_FONT, fontData); }
From source file:org.eclipse.equinox.internal.p2.ui.discovery.util.ControlListViewer.java
License:Open Source License
/** * Create a new instance of the receiver with a control that is a child of parent with style style. * /*w w w. j a va 2 s . com*/ * @param parent * @param style */ public ControlListViewer(Composite parent, int style) { scrolled = new ScrolledComposite(parent, style | SWT.VERTICAL); int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); scrolled.getVerticalBar().setIncrement(height * 2); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); // bug 311276: can cause unintended scrolling of viewer //scrolled.setShowFocusedControl(true); control = new Composite(scrolled, SWT.NONE) { // @Override // public boolean setFocus() { // forceFocus(); // return true; // } @Override public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { updateSize(control); } } }; GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.horizontalSpacing = 0; layout.verticalSpacing = 0; control.setLayout(layout); control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.setBackgroundMode(SWT.INHERIT_FORCE); control.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { updateVisibleItems(); } public void controlResized(ControlEvent e) { updateVisibleItems(); } }); scrolled.setContent(control); hookControl(control); noEntryArea = new Composite(scrolled, SWT.NONE); doCreateNoEntryArea(noEntryArea); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); scrolled.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { updateSize(scrolled.getContent()); } }); control.addTraverseListener(new TraverseListener() { private boolean handleEvent = true; public void keyTraversed(TraverseEvent event) { if (!handleEvent) { return; } switch (event.detail) { case SWT.TRAVERSE_ARROW_PREVIOUS: { Control[] children = control.getChildren(); if (children.length > 0) { boolean selected = false; for (int i = 0; i < children.length; i++) { ControlListItem item = (ControlListItem) children[i]; if (item.isSelected()) { selected = true; if (i > 0) { setSelection(new StructuredSelection(children[i - 1].getData()), true); } break; } } if (!selected) { setSelection(new StructuredSelection(children[children.length - 1].getData()), true); } } break; } case SWT.TRAVERSE_ARROW_NEXT: { Control[] children = control.getChildren(); if (children.length > 0) { boolean selected = false; for (int i = 0; i < children.length; i++) { ControlListItem item = (ControlListItem) children[i]; if (item.isSelected()) { selected = true; if (i < children.length - 1) { setSelection(new StructuredSelection(children[i + 1].getData()), true); } break; } } if (!selected) { setSelection(new StructuredSelection(children[0].getData()), true); } } break; } default: handleEvent = false; event.doit = true; Control control = ControlListViewer.this.control; Shell shell = control.getShell(); while (control != null) { if (control.traverse(event.detail)) { break; } if (!event.doit || control == shell) { break; } control = control.getParent(); } handleEvent = true; break; } } }); }
From source file:org.eclipse.gmf.runtime.common.ui.preferences.FontFieldEditor.java
License:Open Source License
/** * Returns the change button for this field editor. * * @param parent The Composite to create the button in if required. * @return the change button/*from w w w . j a v a 2 s . c om*/ */ protected Button getChangeControl(Composite parent) { if (changeFontButton == null) { changeFontButton = new Button(parent, SWT.PUSH); if (changeButtonText != null) changeFontButton.setText(changeButtonText); changeFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog fontDialog = new FontDialog(changeFontButton.getShell()); if (chosenFont != null) fontDialog.setFontList(chosenFont); FontData font = fontDialog.open(); if (font != null) { FontData[] oldFont = chosenFont; if (oldFont == null) oldFont = JFaceResources.getDefaultFont().getFontData(); setPresentsDefaultValue(false); FontData[] newData = new FontData[1]; newData[0] = font; updateFont(newData); fireValueChanged(VALUE, oldFont[0], font); } } }); changeFontButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { changeFontButton = null; } }); changeFontButton.setFont(parent.getFont()); setButtonLayoutData(changeFontButton); } else { checkParent(changeFontButton, parent); } return changeFontButton; }