List of usage examples for org.eclipse.jface.resource JFaceResources DIALOG_FONT
String DIALOG_FONT
To view the source code for org.eclipse.jface.resource JFaceResources DIALOG_FONT.
Click Source Link
"org.eclipse.jface.dialogfont"
). From source file:de.walware.statet.r.internal.ui.rhelp.RHelpUIServlet.java
License:Open Source License
@Override public void propertyChange(final PropertyChangeEvent event) { if (event.getProperty().equals("de.walware.workbench.themes.DocViewFont") //$NON-NLS-1$ || event.getProperty().equals("de.walware.workbench.themes.DocViewBackgroundColor") //$NON-NLS-1$ || event.getProperty().equals("de.walware.workbench.themes.DocViewColor") //$NON-NLS-1$ || event.getProperty().equals(JFaceResources.DIALOG_FONT) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals("searchResultIndicationColor")) { //$NON-NLS-1$ updateStyles();//from w ww.j a v a2s .co m } }
From source file:de.walware.statet.r.ui.rtool.RElementInfoHoverCreator.java
License:Open Source License
@Override public Point computeSizeConstraints(final int widthInChars, final int heightInChars) { final int titleWidth = LayoutUtil.hintWidth(fTitleText, JFaceResources.DIALOG_FONT, widthInChars); final int titleHeight = fTitleText.getLineHeight(); final int infoWidth = LayoutUtil.hintWidth(fInfoText, PREF_DETAIL_PANE_FONT, widthInChars); final int infoHeight = fInfoText.getLineHeight() * (heightInChars); return new Point(Math.max(titleWidth, infoWidth), titleHeight + LayoutUtil.defaultVSpacing() + infoHeight); }
From source file:eclipse.spellchecker.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns, Key key) { ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); excomposite.setText(label);/* w w w . j av a 2 s .c om*/ if (key != null) { excomposite.setData(key); } excomposite.setExpanded(false); excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1)); excomposite.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { expandedStateChanged((ExpandableComposite) e.getSource()); } }); fExpandableComposites.add(excomposite); makeScrollableCompositeAware(excomposite); return excomposite; }
From source file:edu.tum.in.bruegge.epd.emfstore.dialog.util.scm.SCMLabelProvider.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . j a v a2s. c o m*/ */ @Override public Font getFont(Object element) { if (!(element instanceof TreeNode)) { return null; } Object value = ((TreeNode) element).getValue(); Font italic = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT); Font bold = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); // if (getText(findTopParent((TreeNode) // element)).equals(LOCAL_REVISION)) { // return italic; // } String text = getText(element); if (text == null) { text = ""; } if (value instanceof HistoryInfo) { if (text.equals(LOCAL_REVISION)) { return italic; } HistoryInfo historyInfo = (HistoryInfo) value; if (historyInfo.getPrimerySpec().getIdentifier() == WorkspaceManager.getProjectSpace(project) .getBaseVersion().getIdentifier()) { return bold; } } else if (value instanceof ModelElementId) { if (text.equals(ELEMENT_NOT_FOUND)) { return italic; } } if (((TreeNode) element).getParent() != null && ((TreeNode) element).getParent().getValue() instanceof AbstractOperation) { AbstractOperation op = (AbstractOperation) ((TreeNode) element).getParent().getValue(); if ((value instanceof ModelElementId && value.equals(op.getModelElementId()))) { return bold; } if (value instanceof EObject) { EObject modelElement = (EObject) value; Project project = ModelUtil.getProject(modelElement); if (project != null && project.getModelElementId(modelElement).equals(op.getModelElementId())) { return bold; } } } return null; }
From source file:egovframework.hdev.imp.ide.pages.SelectProjectPage.java
License:Apache License
/** * ? ?/*from ww w . ja v a2 s. c o m*/ * @param SelectProjectPage * @param control void */ private void createNoteControl(Composite control) { Composite noteControl = new Composite(control, SWT.None); noteControl.setLayout(new GridLayout(2, false)); noteControl.setLayoutData(new GridData()); noteName = new Label(noteControl, SWT.BOLD | SWT.TOP); noteName.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); noteName.setText(DeviceAPIMessages.SELECT_PROJECT_PAGE_NOTE); noteContent = new Label(noteControl, SWT.BOLD | SWT.TOP); noteContent.setText(DeviceAPIMessages.SELECT_PROJECT_PAGE_NOTE_CONTENTS); }
From source file:gov.nasa.ensemble.common.ui.ide.navigator.EnsembleFilteredTree.java
License:Open Source License
/** * Return a bold font if the given element matches the given pattern. * Clients can opt to call this method from a Viewer's label provider to get * a bold font for which to highlight the given element in the tree. * //from w ww . j a v a2 s .c om * @param element * element for which a match should be determined * @param tree * FilteredTree in which the element resides * @param filter * PatternFilter which determines a match * * @return bold font */ public static Font getBoldFont(Object element, EnsembleFilteredTree tree, EnsemblePatternFilter filter) { String filterText = tree.getFilterString(); if (filterText == null) { return null; } // Do nothing if it's empty string String initialText = tree.getInitialText(); if (!filterText.equals("") && !filterText.equals(initialText)) {//$NON-NLS-1$ if (tree.getPatternFilter() != filter) { boolean initial = initialText != null && initialText.equals(filterText); if (initial) { filter.setPattern(null); } else if (filterText != null) { filter.setPattern(filterText); } } if (filter.isElementVisible(tree.getViewer(), element) && filter.isLeafMatch(tree.getViewer(), element)) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); } } return null; }
From source file:melnorme.lang.ide.ui.editor.hover.BrowserControlCreator.java
License:Open Source License
@Override public IInformationControl doCreateInformationControl(Shell parent) { if (!org.eclipse.jface.internal.text.html.BrowserInformationControl.isAvailable(parent)) { return new DefaultInformationControl(parent, true); } else {/*from w ww . ja v a 2 s.c om*/ return doCreateBrowserInformationControl(parent, JFaceResources.DIALOG_FONT); } }
From source file:name.schedenig.eclipse.grepconsole.view.items.EditableItemsPanel.java
License:Open Source License
/** * Creates the GUI content.// ww w. j av a 2 s .co m */ private void init() { addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { colorRegistry.disposeColors(); } }); headerFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);// JFaceResources.getHeaderFont(); colorRegistry = new ColorRegistry(Activator.getDefault().getColorRegistry()); clipboard = new Clipboard(getDisplay()); setLayoutData(new GridData(GridData.FILL_BOTH)); FormLayout layout = new FormLayout(); setLayout(layout); panelTreeAndButtons = new Composite(this, SWT.NONE); new GridLayoutBuilder(panelTreeAndButtons, 2, false).setMargins(0).apply(); treePanel = new ItemsTreePanel(panelTreeAndButtons, SWT.BORDER); treePanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 10)); treePanel.addListener(this); hookTreeDragAndDrop(); Tree tree = treePanel.getTree(); treeMenu = new Menu(tree); treeMenu.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { refreshMenuItems(); } }); miCut = new MenuItem(treeMenu, SWT.PUSH); miCut.setText(Messages.EditableItemsPanel_cut); miCut.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doCopy(true); } }); miCopy = new MenuItem(treeMenu, SWT.PUSH); miCopy.setText(Messages.EditableItemsPanel_copy); miCopy.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doCopy(false); } }); miPaste = new MenuItem(treeMenu, SWT.PUSH); miPaste.setText(Messages.EditableItemsPanel_paste); miPaste.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doPaste(); } }); tree.setMenu(treeMenu); tree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL) { doRemove(); e.doit = false; } else if (e.keyCode == SWT.F2) { doEdit(); e.doit = false; } else if (e.keyCode == 'c' && (e.stateMask & SWT.MOD1) != 0) { doCopy(false); e.doit = false; } else if (e.keyCode == 'x' && (e.stateMask & SWT.MOD1) != 0) { doCopy(true); e.doit = false; } else if (e.keyCode == 'v' && (e.stateMask & SWT.MOD1) != 0) { doPaste(); } } }); btnAddFolder = new Button(panelTreeAndButtons, SWT.PUSH); btnAddFolder.setText(Messages.EditableItemsPanel_add_folder); btnAddFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAddFolder(); } }); btnAddExpression = new Button(panelTreeAndButtons, SWT.PUSH); btnAddExpression.setText(Messages.EditableItemsPanel_add_expression); btnAddExpression.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddExpression.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAddExpression(null); } }); btnEdit = new Button(panelTreeAndButtons, SWT.PUSH); btnEdit.setText(Messages.EditableItemsPanel_edit); btnEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnEdit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doEdit(); } }); btnRemove = new Button(panelTreeAndButtons, SWT.PUSH); btnRemove.setText(Messages.EditableItemsPanel_remove); btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRemove(); } }); btnLoad = new Button(panelTreeAndButtons, SWT.PUSH); btnLoad.setText(Messages.EditableItemsPanel_load); btnLoad.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnLoad.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doLoad(); } }); btnSaveSelected = new Button(panelTreeAndButtons, SWT.PUSH); btnSaveSelected.setText(Messages.EditableItemsPanel_save_selected); btnSaveSelected.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnSaveSelected.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doSave(false); } }); btnSaveAll = new Button(panelTreeAndButtons, SWT.PUSH); btnSaveAll.setText(Messages.EditableItemsPanel_save_all); btnSaveAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnSaveAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doSave(true); } }); sash = new Sash(this, SWT.HORIZONTAL | SWT.SMOOTH); labelPreview = new Label(this, SWT.NONE); labelPreview.setFont(headerFont); labelPreview.setText(Messages.EditableItemsPanel_preview); grepLineStyleListener = new GrepLineStyleListener(getShell(), null); grepLineStyleListener.setColorRegistry(colorRegistry); stPreview = new StyledText(this, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); stPreview.addLineStyleListener(grepLineStyleListener); stPreview.setFont(JFaceResources.getTextFont()); menuPreview = new Menu(stPreview); miAddExpressionFromPreview = new MenuItem(menuPreview, SWT.PUSH); miAddExpressionFromPreview.setText(Messages.EditableItemsPanel_add_expression); miAddExpressionFromPreview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAddExpression(stPreview.getSelectionText()); } }); miLoadDefault = new MenuItem(menuPreview, SWT.PUSH); miLoadDefault.setText(Messages.EditableItemsPanel_load_default); miLoadDefault.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doLoadDefaultPreview(); } }); miSaveDefault = new MenuItem(menuPreview, SWT.PUSH); miSaveDefault.setText(Messages.EditableItemsPanel_save_default); miSaveDefault.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doSaveDefaultPreview(); } }); new MenuItem(menuPreview, SWT.SEPARATOR); new PreviewColorHandler(stPreview, menuPreview); menuPreview.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Set<AbstractGrepModelElement> selection = treePanel.getSelectedElements(); boolean hasSelection = selection != null && !selection.isEmpty(); String text = stPreview.getSelectionText(); miAddExpressionFromPreview.setEnabled(hasSelection && text != null && text.length() > 0); super.menuShown(e); } }); stPreview.setMenu(menuPreview); int preferredPreviewHeight = ((getDisplay().getDPI().y * JFaceResources.getTextFont().getFontData()[0].getHeight()) / 72) * 4; FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.bottom = new FormAttachment(sash, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); panelTreeAndButtons.setLayoutData(fd); fd = new FormData(); fd.bottom = new FormAttachment(100, -sash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - preferredPreviewHeight); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); sash.setLayoutData(fd); fd = new FormData(); fd.top = new FormAttachment(sash, 5); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); //fd.bottom = new FormAttachment(100, 0); labelPreview.setLayoutData(fd); fd = new FormData(); fd.top = new FormAttachment(labelPreview, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); fd.bottom = new FormAttachment(100, 0); stPreview.setLayoutData(fd); sash.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Rectangle sashBounds = sash.getBounds(); Rectangle clientArea = getClientArea(); setSashPosition(-(clientArea.height - sashBounds.height - e.y)); } }); addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { int height = getSize().y; FormData fd = (FormData) sash.getLayoutData(); int min = -height + 50; if (min > 0) { min = 0; } if (fd.bottom.offset <= min) { setSashPosition(min); } } }); if (sashPosition != null) { setSashPosition(sashPosition); } refreshButtons(); if (previewText == null || previewText.trim().length() == 0) { stPreview.setText(Activator.getDefault().getPreviewText()); } else { stPreview.setText(previewText); } }
From source file:name.schedenig.eclipse.grepconsole.view.items.ExpressionDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) *///w w w.j a va 2 s . c o m @Override protected Control createDialogArea(Composite parent) { headerFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); parent.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (colorRegistry != null) { colorRegistry.disposeColors(); } } }); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, Activator.PLUGIN_ID + ".edit_expression"); //$NON-NLS-1$ colorRegistry = new ColorRegistry(Activator.getDefault().getColorRegistry()); clipboard = new Clipboard(parent.getDisplay()); Composite composite = parent; new GridLayoutBuilder(composite, 1, false).apply(); panelHeader = createHeaderPanel(composite); panelHeader.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); tabs = new TabFolder(composite, SWT.TOP); tabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tiGeneral = new TabItem(tabs, SWT.NONE); tiGeneral.setText(Messages.ExpressionDialog_general); panelGeneral = createGeneralPanel(tabs); tiGeneral.setControl(panelGeneral); tiStyles = new TabItem(tabs, SWT.NONE); tiStyles.setText(Messages.ExpressionDialog_styles_links); tiGrepView = new TabItem(tabs, SWT.NONE); tiGrepView.setText(Messages.ExpressionDialog_grep_view); panelGrepView = createGrepViewPanel(tabs); tiGrepView.setControl(panelGrepView); tiNotifications = new TabItem(tabs, SWT.NONE); tiNotifications.setText(Messages.ExpressionDialog_notifications_tab); panelNotifications = createNotificationsPanel(tabs); tiNotifications.setControl(panelNotifications); tiStatistics = new TabItem(tabs, SWT.NONE); tiStatistics.setText(Messages.ExpressionDialog_statistics_tab); panelStatistics = createStatisticsPanel(tabs); tiStatistics.setControl(panelStatistics); panelStyleTables = new SashForm(tabs, SWT.HORIZONTAL); panelStyleTables.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tiStyles.setControl(panelStyleTables); panelStyleAssignments = new Composite(panelStyleTables, SWT.NONE); panelStyleAssignments.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayoutBuilder builder = new GridLayoutBuilder(panelStyleAssignments, 3, false).setMarginRight(0); builder.apply(); GridLayout panelStyleAssignmentsLayout = builder.getLayout(); panelStyleTables.setSashWidth(((GridLayout) panelStyleAssignments.getLayout()).marginLeft); tableStyleAssignments = new Table(panelStyleAssignments, SWT.BORDER | SWT.FULL_SELECTION); tableStyleAssignments.setHeaderVisible(true); tableStyleAssignments.setLinesVisible(false); tableStyleAssignments.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); viewerStyleAssignments = new TableViewer(tableStyleAssignments); viewerStyleAssignments.setContentProvider(new StyleAssignmentsContentProvider()); groupLabelProvider = new StyleAssignmentsGroupLabelProvider(viewerStyleAssignments); colGroup = new TableViewerColumn(viewerStyleAssignments, SWT.LEFT); colGroup.getColumn().setText(Messages.ExpressionDialog_column_group); colGroup.getColumn().setWidth(130); colGroup.setLabelProvider(groupLabelProvider); colStyle = new TableViewerColumn(viewerStyleAssignments, SWT.LEFT); colStyle.getColumn().setText(Messages.ExpressionDialog_column_style); colStyle.getColumn().setWidth(130); colStyle.setLabelProvider(new StyleAssignmentsStyleLabelProvider(viewerStyleAssignments)); colLink = new TableViewerColumn(viewerStyleAssignments, SWT.RIGHT); colLink.getColumn().setText(Messages.ExpressionDialog_link); colLink.getColumn().setWidth(70); colLink.setLabelProvider(new StyleAssignmentsLinkLabelProvider(viewerStyleAssignments)); ColumnViewerToolTipSupport.enableFor(viewerStyleAssignments); menuGroups = new Menu(tableStyleAssignments); miCopyLink = new MenuItem(menuGroups, SWT.PUSH); miCopyLink.setText(Messages.ExpressionDialog_copy_link); miCopyLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { copyLink(); } }); miPasteLink = new MenuItem(menuGroups, SWT.PUSH); miPasteLink.setText(Messages.ExpressionDialog_paste_link); miPasteLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { pasteLink(); } }); menuGroups.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Integer group = getSelectedGroup((IStructuredSelection) viewerStyleAssignments.getSelection()); miCopyLink.setEnabled(group != null && getGroup(group).getLink() != null); miPasteLink.setEnabled(group != null); } }); tableStyleAssignments.setMenu(menuGroups); viewerStyleAssignments.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { groupSelected(getSelectedGroup((IStructuredSelection) event.getSelection())); } }); TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewerStyleAssignments, new FocusCellOwnerDrawHighlighter(viewerStyleAssignments)); ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy( viewerStyleAssignments) { protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { // Enable editor only with mouse double click if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) { EventObject source = event.sourceEvent; if (source instanceof MouseEvent && ((MouseEvent) source).button == 3) { return false; } return true; } return false; } }; TableViewerEditor.create(viewerStyleAssignments, focusCellManager, activationSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); EditingSupport nameEditingSupport = new EditingSupport(viewerStyleAssignments) { @Override protected void setValue(Object element, Object value) { String s = ((String) value).trim(); if (s.length() == 0) { s = null; } getGroup((Integer) element).setName(s); viewerStyleAssignments.refresh(element); updateDuplicateGroupNames(); } @Override protected Object getValue(Object element) { GrepGroup group = getGroup((Integer) element); return group.getName() == null ? "" : group.getName(); //$NON-NLS-1$ } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor(viewerStyleAssignments.getTable()); } @Override protected boolean canEdit(Object element) { return true; } }; colGroup.setEditingSupport(nameEditingSupport); DoubleClickEditingSupport styleEditingSupport = new DoubleClickEditingSupport(viewerStyleAssignments) { @Override protected void doEdit(Object value) { Integer group = getSelectedGroup((IStructuredSelection) viewerStyleAssignments.getSelection()); final GrepStyle style = getGroup(group).getStyle(); getShell().getDisplay().asyncExec(new Runnable() { public void run() { if (style == null) { panelAvailableStyles.doNewStyle(); } else { panelAvailableStyles.doEditStyle(style); } } }); } }; colStyle.setEditingSupport(styleEditingSupport); colLink.setEditingSupport(new DoubleClickEditingSupport(viewerStyleAssignments) { @Override protected void doEdit(Object value) { final Integer groupIndex = getSelectedGroup( (IStructuredSelection) viewerStyleAssignments.getSelection()); final GrepGroup group = getGroup(groupIndex); getShell().getDisplay().asyncExec(new Runnable() { public void run() { LinkDialog dlg = new LinkDialog(getShell(), groupIndex < workItem.getGroups().length); dlg.setLink(group.getLink()); if (dlg.open() == LinkDialog.OK) { group.setLink(dlg.getLink()); viewerStyleAssignments.refresh(); } } }); } }); cbRemoveOriginalStyle = new Button(panelStyleAssignments, SWT.CHECK); cbRemoveOriginalStyle.setText(Messages.ExpressionDialog_remove_original_style); cbRemoveOriginalStyle.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1)); cbRemoveOriginalStyle.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { workItem.setRemoveOriginalStyle(cbRemoveOriginalStyle.getSelection()); refreshPreview(); } }); grepLineStyleListener = new GrepLineStyleListener(getShell(), null); grepLineStyleListener.setColorRegistry(colorRegistry); labelPreview = new Label(panelStyleAssignments, SWT.NONE); labelPreview.setFont(headerFont); labelPreview.setText(Messages.ExpressionDialog_preview); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); gridData.verticalIndent = 10; labelPreview.setLayoutData(gridData); stPreview = new StyledText(panelStyleAssignments, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); gd.heightHint = ((parent.getDisplay().getDPI().y * JFaceResources.getTextFont().getFontData()[0].getHeight()) / 72) * 4; stPreview.setLayoutData(gd); stPreview.addLineStyleListener(grepLineStyleListener); stPreview.setFont(JFaceResources.getTextFont()); menuPreview = new Menu(stPreview); miAddExpressionFromPreview = new MenuItem(menuPreview, SWT.PUSH); miAddExpressionFromPreview.setText(Messages.ExpressionDialog_use_as_expression); miAddExpressionFromPreview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setExpression(stPreview.getSelectionText()); } }); miAddUnlessExpressionFromPreview = new MenuItem(menuPreview, SWT.PUSH); miAddUnlessExpressionFromPreview.setText(Messages.ExpressionDialog_use_as_unless_expression); miAddUnlessExpressionFromPreview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setUnlessExpression(stPreview.getSelectionText()); } }); miLoadDefault = new MenuItem(menuPreview, SWT.PUSH); miLoadDefault.setText(Messages.ExpressionDialog_load_default); miLoadDefault.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doLoadDefaultPreview(); } }); miSaveDefault = new MenuItem(menuPreview, SWT.PUSH); miSaveDefault.setText(Messages.ExpressionDialog_save_default); miSaveDefault.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doSaveDefaultPreview(); } }); menuPreview.addMenuListener(new MenuAdapter() { @Override public void menuShown(MenuEvent e) { String text = stPreview.getSelectionText(); miAddExpressionFromPreview.setEnabled(text != null && text.length() > 0); super.menuShown(e); } }); new MenuItem(menuPreview, SWT.SEPARATOR); new PreviewColorHandler(stPreview, menuPreview); stPreview.setMenu(menuPreview); panelAvailableStyles = new StylesPanel(panelStyleTables, SWT.NONE) { @Override protected void doStylesSelected(Collection<GrepStyle> styles) { btnAssignStyle.setEnabled(styles.size() == 1); super.doStylesSelected(styles); } protected void createButtons(Composite parent) { btnAssignStyle = new Button(parent, SWT.PUSH); btnAssignStyle.setText(Messages.ExpressionDialog_assign); btnAssignStyle.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAssignStyle(panelAvailableStyles.getSelectedStyle()); } }); super.createButtons(parent); }; }; GridLayout panelAvailableStylesLayout = (GridLayout) panelAvailableStyles.getLayout(); panelAvailableStylesLayout.marginLeft = panelStyleAssignmentsLayout.marginRight; panelAvailableStylesLayout.marginRight = panelStyleAssignmentsLayout.marginLeft; panelAvailableStylesLayout.marginWidth = panelStyleAssignmentsLayout.marginWidth; panelAvailableStylesLayout.marginHeight = panelStyleAssignmentsLayout.marginHeight; panelAvailableStylesLayout.marginTop = panelStyleAssignmentsLayout.marginTop; panelAvailableStylesLayout.marginBottom = panelStyleAssignmentsLayout.marginBottom; panelAvailableStyles.setIncludeNullStyle(true); panelAvailableStyles.addListener(this); if (workItem != null) { panelAvailableStyles.setRoot(workItem.getRoot()); } textExpression.setFocus(); return composite; }
From source file:name.schedenig.eclipse.grepconsole.view.items.ItemLabelProvider.java
License:Open Source License
/** * Returns the font to use for a specific element. * /*from w w w .j av a 2 s . co m*/ * For groups, a bold version of the default font is returned. For all other * items, <code>null</code> is returned. * * @param element Element. * * @return Font, or <code>null</code>. */ public Font getFont(Object element) { if (element instanceof GrepExpressionFolder) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); } else { return JFaceResources.getDialogFont(); } }