List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.eclipse.tm4e.ui.internal.preferences.GrammarPreferencePage.java
License:Open Source License
/** * Create grammar list content./*from ww w .ja v a 2s .c o m*/ * * @param parent */ private void createGrammarListContent(Composite parent) { Composite tableComposite = new Composite(parent, SWT.NONE); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 360; data.heightHint = convertHeightInCharsToPixels(10); tableComposite.setLayoutData(data); TableColumnLayout columnLayout = new TableColumnLayout(); tableComposite.setLayout(columnLayout); Table table = new Table(tableComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); table.setHeaderVisible(true); table.setLinesVisible(true); GC gc = new GC(getShell()); gc.setFont(JFaceResources.getDialogFont()); ColumnViewerComparator viewerComparator = new ColumnViewerComparator(); grammarViewer = new TableViewer(table); TableColumn column1 = new TableColumn(table, SWT.NONE); column1.setText(TMUIMessages.GrammarPreferencePage_column_scopeName); int minWidth = computeMinimumColumnWidth(gc, TMUIMessages.GrammarPreferencePage_column_scopeName); columnLayout.setColumnData(column1, new ColumnWeightData(2, minWidth, true)); column1.addSelectionListener(new ColumnSelectionAdapter(column1, grammarViewer, 0, viewerComparator)); TableColumn column2 = new TableColumn(table, SWT.NONE); column2.setText(TMUIMessages.GrammarPreferencePage_column_path); minWidth = computeMinimumColumnWidth(gc, TMUIMessages.GrammarPreferencePage_column_path); columnLayout.setColumnData(column2, new ColumnWeightData(2, minWidth, true)); column2.addSelectionListener(new ColumnSelectionAdapter(column2, grammarViewer, 1, viewerComparator)); TableColumn column3 = new TableColumn(table, SWT.NONE); column3.setText(TMUIMessages.GrammarPreferencePage_column_pluginId); minWidth = computeMinimumColumnWidth(gc, TMUIMessages.GrammarPreferencePage_column_pluginId); columnLayout.setColumnData(column3, new ColumnWeightData(2, minWidth, true)); column3.addSelectionListener(new ColumnSelectionAdapter(column3, grammarViewer, 2, viewerComparator)); gc.dispose(); grammarViewer.setLabelProvider(new GrammarDefinitionLabelProvider()); grammarViewer.setContentProvider(new GrammarDefinitionContentProvider()); grammarViewer.setComparator(viewerComparator); grammarViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent e) { IStructuredSelection selection = grammarViewer.getStructuredSelection(); if (selection.isEmpty()) { return; } IGrammarDefinition definition = (IGrammarDefinition) (selection).getFirstElement(); // Update button grammarRemoveButton.setEnabled(definition.getPluginId() != null); themeAssociationsWidget.getNewButton().setEnabled(false); themeAssociationsWidget.getRemoveButton().setEnabled(false); // Select grammar selectGrammar(definition); } private void selectGrammar(IGrammarDefinition definition) { String scopeName = definition.getScopeName(); // Fill "General" tab fillGeneralTab(scopeName); // Fill "Content type" tab fillContentTypeTab(scopeName); // Fill "Theme" tab IThemeAssociation selectedAssociation = fillThemeTab(definition); // Fill preview fillPreview(scopeName, selectedAssociation); } private void fillGeneralTab(String scopeName) { IGrammar grammar = grammarRegistryManager.getGrammarForScope(scopeName); grammarInfoWidget.refresh(grammar); } private void fillContentTypeTab(String scopeName) { // Load the content type binding for the given grammar String[] contentTypes = grammarRegistryManager.getContentTypesForScope(scopeName); contentTypesWidget.setInput(contentTypes); } private IThemeAssociation fillThemeTab(IGrammarDefinition definition) { IThemeAssociation selectedAssociation = null; IStructuredSelection oldSelection = (IStructuredSelection) themeAssociationsWidget.getSelection(); // Load the theme associations for the given grammar IThemeAssociation[] themeAssociations = themeAssociationsWidget.setGrammarDefinition(definition); // Try to keep selection if (!oldSelection.isEmpty() && Arrays.asList(themeAssociations).contains(oldSelection.getFirstElement())) { selectedAssociation = (IThemeAssociation) oldSelection.getFirstElement(); themeAssociationsWidget.setSelection(oldSelection); } else { selectedAssociation = themeAssociations != null && themeAssociations.length > 0 ? themeAssociations[0] : null; if (selectedAssociation != null) { themeAssociationsWidget.setSelection(new StructuredSelection(selectedAssociation)); } } return selectedAssociation; } private void fillPreview(String scopeName, IThemeAssociation selectedAssociation) { // Preview the grammar IGrammar grammar = grammarRegistryManager.getGrammarForScope(scopeName); if (selectedAssociation != null) { setPreviewTheme(selectedAssociation.getThemeId()); } previewViewer.setGrammar(grammar); // Snippet ISnippet[] snippets = snippetManager.getSnippets(scopeName); if (snippets != null && snippets.length > 0) { // TODO: manage list of snippet for the given scope. previewViewer.setText(snippets[0].getContent()); } } }); // Specify default sorting table.setSortColumn(column1); table.setSortDirection(viewerComparator.getDirection()); BidiUtils.applyTextDirection(grammarViewer.getControl(), BidiUtils.BTD_DEFAULT); Composite buttons = new Composite(parent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); grammarNewButton = new Button(buttons, SWT.PUSH); grammarNewButton.setText(TMUIMessages.Button_new); grammarNewButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); grammarNewButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { add(); } private void add() { // Open import wizard for TextMate grammar. TextMateGrammarImportWizard wizard = new TextMateGrammarImportWizard(false); wizard.setGrammarRegistryManager(grammarRegistryManager); WizardDialog dialog = new WizardDialog(getShell(), wizard); if (dialog.open() == Window.OK) { // User grammar was saved, refresh the list of grammar and // select the created grammar. IGrammarDefinition created = wizard.getCreatedDefinition(); grammarViewer.refresh(); grammarViewer.setSelection(new StructuredSelection(created)); } } }); grammarRemoveButton = new Button(buttons, SWT.PUSH); grammarRemoveButton.setText(TMUIMessages.Button_remove); grammarRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); grammarRemoveButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { remove(); } private void remove() { Collection<IGrammarDefinition> definitions = getSelectedUserGrammarDefinitions(); if (!definitions.isEmpty()) { for (IGrammarDefinition definition : definitions) { grammarRegistryManager.unregisterGrammarDefinition(definition); } grammarViewer.refresh(); } } }); }
From source file:org.eclipse.tm4e.ui.internal.preferences.ThemePreferencePage.java
License:Open Source License
/** * Create the theme list content.//from www . j av a 2 s .co m * * @param parent */ private void createThemesContent(Composite parent) { GridLayout layout; Composite tableComposite = new Composite(parent, SWT.NONE); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 360; data.heightHint = convertHeightInCharsToPixels(10); tableComposite.setLayoutData(data); TableColumnLayout columnLayout = new TableColumnLayout(); tableComposite.setLayout(columnLayout); Table table = new Table(tableComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); table.setHeaderVisible(true); table.setLinesVisible(true); GC gc = new GC(getShell()); gc.setFont(JFaceResources.getDialogFont()); ColumnViewerComparator viewerComparator = new ColumnViewerComparator(); themeViewer = new TableViewer(table); TableColumn column1 = new TableColumn(table, SWT.NONE); column1.setText(TMUIMessages.ThemePreferencePage_column_name); int minWidth = computeMinimumColumnWidth(gc, TMUIMessages.ThemePreferencePage_column_name); columnLayout.setColumnData(column1, new ColumnWeightData(2, minWidth, true)); column1.addSelectionListener(new ColumnSelectionAdapter(column1, themeViewer, 0, viewerComparator)); TableColumn column2 = new TableColumn(table, SWT.NONE); column2.setText(TMUIMessages.ThemePreferencePage_column_path); minWidth = computeMinimumColumnWidth(gc, TMUIMessages.ThemePreferencePage_column_path); columnLayout.setColumnData(column2, new ColumnWeightData(2, minWidth, true)); column2.addSelectionListener(new ColumnSelectionAdapter(column2, themeViewer, 1, viewerComparator)); TableColumn column3 = new TableColumn(table, SWT.NONE); column3.setText(TMUIMessages.ThemePreferencePage_column_pluginId); minWidth = computeMinimumColumnWidth(gc, TMUIMessages.ThemePreferencePage_column_pluginId); columnLayout.setColumnData(column3, new ColumnWeightData(2, minWidth, true)); column3.addSelectionListener(new ColumnSelectionAdapter(column3, themeViewer, 2, viewerComparator)); gc.dispose(); themeViewer.setLabelProvider(new ThemeLabelProvider()); themeViewer.setContentProvider(new ThemeContentProvider()); themeViewer.setComparator(viewerComparator); themeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent e) { // Fill Theme details ITheme theme = ((ITheme) ((IStructuredSelection) themeViewer.getSelection()).getFirstElement()); darkThemeButton.setSelection(theme.isDark()); defaultThemeButton.setSelection(theme.isDefault()); preview(); } }); // Specify default sorting table.setSortColumn(column1); table.setSortDirection(viewerComparator.getDirection()); BidiUtils.applyTextDirection(themeViewer.getControl(), BidiUtils.BTD_DEFAULT); Composite buttons = new Composite(parent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); themeNewButton = new Button(buttons, SWT.PUSH); themeNewButton.setText(TMUIMessages.Button_new); themeNewButton.setLayoutData(getButtonGridData(themeNewButton)); themeNewButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { // add(); } }); themeRemoveButton = new Button(buttons, SWT.PUSH); themeRemoveButton.setText(TMUIMessages.Button_remove); themeRemoveButton.setLayoutData(getButtonGridData(themeRemoveButton)); themeRemoveButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { // remove(); } }); }
From source file:org.eclipse.ui.dialogs.WorkingSetConfigurationBlock.java
License:Open Source License
private GridData setButtonLayoutData(Button button) { button.setFont(JFaceResources.getDialogFont()); GC gc = new GC(button); gc.setFont(button.getFont());/*from ww w . j ava2 s .c o m*/ FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); return data; }
From source file:org.eclipse.ui.examples.fieldassist.FieldAssistTestDialog.java
License:Open Source License
GridData getMultiLineTextFieldGridData() { int margin = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); GridData data = new GridData(); data.horizontalAlignment = SWT.FILL; data.verticalAlignment = SWT.FILL;/*from w ww . j a v a 2 s . c o m*/ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + margin; data.heightHint = JFaceResources.getDialogFont().getFontData()[0].getHeight() * 5; data.horizontalIndent = margin; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; return data; }
From source file:org.eclipse.ui.ide.markers.compatibility.api.FilterConfigurationArea.java
License:Open Source License
/** * Initialise {@link FontMetrics} for the receiver. * /*from w w w . jav a2 s .c om*/ * @param control */ protected void initializeFontMetrics(Control control) { GC gc = new GC(control); gc.setFont(JFaceResources.getDialogFont()); fontMetrics = gc.getFontMetrics(); gc.dispose(); }
From source file:org.eclipse.ui.ide.markers.compatibility.internal.DescriptionConfigurationArea.java
License:Open Source License
/** * Create the group for the description filter. * /* w ww . j a v a2s .c o m*/ * @param parent */ private void createDescriptionGroup(Composite parent) { Composite descriptionComposite = new Composite(parent, SWT.NONE); descriptionComposite.setLayout(new GridLayout(3, false)); descriptionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label descriptionLabel = new Label(descriptionComposite, SWT.NONE); descriptionLabel.setText(MarkerMessages.filtersDialog_descriptionLabel); descriptionCombo = new Combo(descriptionComposite, SWT.READ_ONLY); descriptionCombo.add(MarkerMessages.filtersDialog_contains); descriptionCombo.add(MarkerMessages.filtersDialog_doesNotContain); // Prevent Esc and Return from closing the dialog when the combo is // active. descriptionCombo.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) { e.doit = false; } } }); GC gc = new GC(descriptionComposite); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); descriptionText = new Text(descriptionComposite, SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); data.widthHint = Dialog.convertWidthInCharsToPixels(fontMetrics, 25); descriptionText.setLayoutData(data); }
From source file:org.eclipse.ui.internal.about.BundleSigningInfo.java
License:Open Source License
public Control createContents(Composite parent) { composite = new Composite(parent, SWT.BORDER); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0;// www . j ava 2s. co m layout.marginWidth = 0; composite.setLayout(layout); // date { Label label = new Label(composite, SWT.NONE); label.setText(WorkbenchMessages.BundleSigningTray_Signing_Date); GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); date = new Text(composite, SWT.READ_ONLY); GC gc = new GC(date); gc.setFont(JFaceResources.getDialogFont()); Point size = gc.stringExtent(DateFormat.getDateTimeInstance().format(new Date())); data.widthHint = size.x; gc.dispose(); date.setText(WorkbenchMessages.BundleSigningTray_Working); date.setLayoutData(data); } // signer { Label label = new Label(composite, SWT.NONE); label.setText(WorkbenchMessages.BundleSigningTray_Signing_Certificate); GridData data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); data.horizontalSpan = 2; data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalSpan = 2; certificate = new StyledText(composite, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); certificate.setText(WorkbenchMessages.BundleSigningTray_Working); certificate.setLayoutData(data); } Dialog.applyDialogFont(composite); startJobs(); // start the jobs that will prime the content return composite; }
From source file:org.eclipse.ui.internal.activities.ws.ActivityEnabler.java
License:Open Source License
/** * Create the controls./*from w w w.j a v a2s. c om*/ * * @param parent * the parent in which to create the controls. * @return the composite in which the controls exist. */ public Control createControl(Composite parent) { GC gc = new GC(parent); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(createGridLayoutWithoutMargins(1, fontMetrics)); new Label(composite, SWT.NONE).setText(strings.getProperty(ActivitiesPreferencePage.ACTIVITY_NAME, ActivityMessages.ActivityEnabler_activities) + ':'); dualViewer = new CheckboxTreeViewer(composite); dualViewer.setComparator(new ViewerComparator()); dualViewer.setLabelProvider(new ActivityCategoryLabelProvider()); dualViewer.setContentProvider(provider); dualViewer.setInput(activitySupport); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); dualViewer.getControl().setLayoutData(data); Composite buttonComposite = new Composite(composite, SWT.NONE); buttonComposite.setLayout(createGridLayoutWithoutMargins(2, fontMetrics)); Button selectAllButton = new Button(buttonComposite, SWT.PUSH); selectAllButton.setText(ActivityMessages.ActivityEnabler_selectAll); selectAllButton.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { toggleTreeEnablement(true); } }); setButtonLayoutData(selectAllButton, fontMetrics); Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); deselectAllButton.setText(ActivityMessages.ActivityEnabler_deselectAll); deselectAllButton.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { toggleTreeEnablement(false); } }); setButtonLayoutData(deselectAllButton, fontMetrics); new Label(composite, SWT.NONE).setText(ActivityMessages.ActivityEnabler_description); descriptionText = new Text(composite, SWT.READ_ONLY | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 5); descriptionText.setLayoutData(data); setInitialStates(); dualViewer.addCheckStateListener(checkListener); dualViewer.addSelectionChangedListener(selectionListener); dualViewer.setSelection(new StructuredSelection()); Dialog.applyDialogFont(composite); return composite; }
From source file:org.eclipse.ui.internal.dialogs.BundleSigningTray.java
License:Open Source License
protected Control createContents(Composite parent) { Composite content = new Composite(parent, SWT.NONE); content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout = new GridLayout(2, false); content.setLayout(layout);// w w w .j av a2s.c o m // date Color backgroundColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); { Label label = new Label(content, SWT.NONE); label.setText(WorkbenchMessages.BundleSigningTray_Signing_Date); GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); date = new Text(content, SWT.READ_ONLY); GC gc = new GC(date); gc.setFont(JFaceResources.getDialogFont()); Point size = gc.stringExtent(DateFormat.getDateTimeInstance().format(new Date())); data.widthHint = size.x; gc.dispose(); date.setText(WorkbenchMessages.BundleSigningTray_Working); date.setLayoutData(data); date.setBackground(backgroundColor); } // signer { Label label = new Label(content, SWT.NONE); label.setText(WorkbenchMessages.BundleSigningTray_Signing_Certificate); GridData data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); data.horizontalSpan = 2; data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalSpan = 2; certificate = new StyledText(content, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); certificate.setText(WorkbenchMessages.BundleSigningTray_Working); certificate.setLayoutData(data); } // problems // { // Label label = new Label(content, SWT.NONE); // label.setText("Problems:"); //$NON-NLS-1$ // // } Dialog.applyDialogFont(content); startJobs(); // start the jobs that will prime the content return content; }
From source file:org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.java
License:Open Source License
protected Control createTreeAreaContents(Composite parent) { Composite leftArea = new Composite(parent, SWT.NONE); leftArea.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); leftArea.setFont(parent.getFont());// www . j av a 2 s.c o m GridLayout leftLayout = new GridLayout(); leftLayout.numColumns = 1; leftLayout.marginHeight = 0; leftLayout.marginTop = IDialogConstants.VERTICAL_MARGIN; leftLayout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN; leftLayout.horizontalSpacing = 0; leftLayout.verticalSpacing = 0; leftArea.setLayout(leftLayout); // Build the tree an put it into the composite. TreeViewer viewer = createTreeViewer(leftArea); setTreeViewer(viewer); updateTreeFont(JFaceResources.getDialogFont()); GridData viewerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); viewer.getControl().getParent().setLayoutData(viewerData); layoutTreeAreaControl(leftArea); return leftArea; }