List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.eclipse.equinox.internal.p2.ui.dialogs.RepositorySelectionGroup.java
License:Open Source License
private void setButtonLayoutData(Button button) { GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); GC gc = new GC(button); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fm = gc.getFontMetrics(); gc.dispose();/* w w w . j a v a2 s.c o m*/ int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
From source file:org.eclipse.equinox.p2.ui.InstalledSoftwarePage.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);/*from w w w.j ava 2 s. c om*/ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IProvHelpContextIds.INSTALLED_SOFTWARE); profileId = getProvisioningUI().getProfileId(); if (profileId == null) { IStatus status = getProvisioningUI().getPolicy().getNoProfileChosenStatus(); if (status != null) ProvUI.reportStatus(status, StatusManager.LOG); Text text = new Text(parent, SWT.WRAP | SWT.READ_ONLY); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); text.setText(ProvUIMessages.InstalledSoftwarePage_NoProfile); setControl(text); return; } Composite composite = new Composite(parent, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); int width = getDefaultWidth(composite); gd.widthHint = width; composite.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); // Table of installed IU's installedIUGroup = new InstalledIUGroup(getProvisioningUI(), composite, JFaceResources.getDialogFont(), profileId, getColumnConfig()); // we hook selection listeners on the viewer in createPageButtons because we // rely on the actions we create there getting selection events before we use // them to update button enablement. CopyUtils.activateCopy(this, installedIUGroup.getStructuredViewer().getControl()); gd = new GridData(SWT.FILL, SWT.FILL, true, false); gd.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_DESCRIPTION_HEIGHT); gd.widthHint = width; detailsArea = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY | SWT.WRAP); detailsArea.setBackground(detailsArea.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); detailsArea.setLayoutData(gd); setControl(composite); }
From source file:org.eclipse.gyrex.admin.ui.internal.helper.SwtUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * /*from w ww . j a v a 2 s . c o m*/ * @param button * the button * @return the width hint */ public static int getButtonWidthHint(final Button button) { button.setFont(JFaceResources.getDialogFont()); final PixelConverter converter = new PixelConverter(button); final int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.gyrex.admin.ui.internal.helper.SwtUtil.java
License:Open Source License
public static int getTableHeightHint(final Table table, final int rows) { if (table.getFont().equals(JFaceResources.getDefaultFont())) { table.setFont(JFaceResources.getDialogFont()); }//from w w w.j a va 2s. c o m int result = table.getItemHeight() * rows + table.getHeaderHeight(); if (table.getLinesVisible()) { result += table.getGridLineWidth() * (rows - 1); } return result; }
From source file:org.eclipse.gyrex.admin.ui.internal.wizards.dialogfields.StringButtonStatusDialogField.java
License:Open Source License
protected GridData gridDataForStatusLabel(final Control aControl, final int span) { final GridData gd = new GridData(); gd.horizontalAlignment = GridData.BEGINNING; gd.grabExcessHorizontalSpace = false; gd.horizontalIndent = 0;// w ww . j a v a 2 s .c o m if (fWidthHintString != null) { final GC gc = new GC(aControl); gc.setFont(JFaceResources.getDialogFont()); gd.widthHint = gc.textExtent(fWidthHintString).x; gc.dispose(); } else if (fWidthHint != -1) { gd.widthHint = fWidthHint; } else { gd.widthHint = SWT.DEFAULT; } return gd; }
From source file:org.eclipse.jdt.internal.debug.ui.jres.JREsEnvironmentLabelProvider.java
License:Open Source License
public Font getFont(Object element) { if (isStrictlyCompatible(element)) { if (fFont == null) { Font dialogFont = JFaceResources.getDialogFont(); FontData[] fontData = dialogFont.getFontData(); for (int i = 0; i < fontData.length; i++) { FontData data = fontData[i]; data.setStyle(SWT.BOLD); }//from ww w . j a v a 2 s .c om Display display = JDIDebugUIPlugin.getActiveWorkbenchShell().getDisplay(); fFont = new Font(display, fontData); } return fFont; } return null; }
From source file:org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage.java
License:Open Source License
/** * Create a new filter in the table (with the default 'new filter' value), * then open up an in-place editor on it. */// w w w .j ava 2 s . c o m private void editFilter() { // if a previous edit is still in progress, finish it if (fEditorText != null) validateChangeAndCleanup(); fNewStackFilter = fStackFilterContentProvider.addFilter(DEFAULT_NEW_FILTER_TEXT, true); fNewTableItem = fFilterTable.getItem(0); int textStyles = SWT.SINGLE | SWT.LEFT; /* * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=218193 * which won't get fixed (advice is to not use border). We still use a * border on platforms where it looks OK and nicer with a border. */ String platform = SWT.getPlatform(); if ("win32".equals(platform) || "gtk".equals(platform)) //$NON-NLS-1$ //$NON-NLS-2$ textStyles |= SWT.BORDER; fEditorText = new Text(fFilterTable, textStyles); fEditorText.setFont(JFaceResources.getDialogFont()); GridData gd = new GridData(GridData.FILL_BOTH); fEditorText.setLayoutData(gd); // set the editor fTableEditor.horizontalAlignment = SWT.LEFT; fTableEditor.grabHorizontal = true; fTableEditor.setEditor(fEditorText, fNewTableItem, 0); // get the editor ready to use fEditorText.setText(fNewStackFilter.getName()); fEditorText.selectAll(); setEditorListeners(fEditorText); fEditorText.setFocus(); }
From source file:org.eclipse.jdt.internal.ui.text.correction.NewCUCompletionUsingWizardProposal.java
License:Open Source License
public void apply(IDocument document) { NewElementWizard wizard = createWizard(); wizard.init(JavaPlugin.getDefault().getWorkbench(), new StructuredSelection(fCompilationUnit)); IType createdType = null;/* w ww . j a v a2 s . c o m*/ if (fShowDialog) { Shell shell = JavaPlugin.getActiveWorkbenchShell(); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create(); dialog.getShell().setText(CorrectionMessages.NewCUCompletionUsingWizardProposal_dialogtitle); configureWizardPage(wizard); if (dialog.open() == Window.OK) { createdType = (IType) wizard.getCreatedElement(); } } else { wizard.addPages(); try { NewTypeWizardPage page = configureWizardPage(wizard); page.createType(null); createdType = page.getCreatedType(); } catch (CoreException e) { JavaPlugin.log(e); } catch (InterruptedException e) { } } if (createdType != null) { IJavaElement container = createdType.getParent(); if (container instanceof ICompilationUnit) { container = container.getParent(); } if (!container.equals(fTypeContainer)) { // add import try { ImportRewrite rewrite = StubUtility.createImportRewrite(fCompilationUnit, true); rewrite.addImport(createdType.getFullyQualifiedName('.')); JavaModelUtil.applyEdit(fCompilationUnit, rewrite.rewriteImports(null), false, null); } catch (CoreException e) { } } fCreatedType = createdType; } }
From source file:org.eclipse.jdt.ui.actions.AbstractOpenWizardAction.java
License:Open Source License
@Override public void run() { Shell shell = getShell();// w ww . j ava 2s .c o m if (!doCreateProjectFirstOnEmptyWorkspace(shell)) { return; } try { INewWizard wizard = createWizard(); wizard.init(PlatformUI.getWorkbench(), getSelection()); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create(); int res = dialog.open(); if (res == Window.OK && wizard instanceof NewElementWizard) { fCreatedElement = ((NewElementWizard) wizard).getCreatedElement(); } notifyResult(res == Window.OK); } catch (CoreException e) { String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title; String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:org.eclipse.jpt.common.ui.internal.swt.widgets.TableTools.java
License:Open Source License
public static int calculateHeightHint(Table table, int rowCount) { if (table.getFont().equals(JFaceResources.getDefaultFont())) { table.setFont(JFaceResources.getDialogFont()); }//from w w w.j a va 2 s . co m int hint = table.getHeaderHeight() + (table.getItemHeight() * rowCount); if (table.getLinesVisible()) { hint += table.getGridLineWidth() * (rowCount - 1); } return hint; }