List of usage examples for org.eclipse.jface.dialogs Dialog convertHorizontalDLUsToPixels
public static int convertHorizontalDLUsToPixels(FontMetrics fontMetrics, int dlus)
From source file:org.eclipse.gmt.modisco.jm2t.internal.ui.util.SWTUtil.java
License:Open Source License
/** * Convert DLUs to pixels.//w ww . ja v a 2s . c o m * * @param comp a component * @param x pixels * @return dlus */ public static int convertHorizontalDLUsToPixels(Composite comp, int x) { if (fontMetrics == null) initializeDialogUnits(comp); return Dialog.convertHorizontalDLUsToPixels(fontMetrics, x); }
From source file:org.eclipse.jdt.internal.debug.ui.launcher.SourceLookupBlock.java
License:Open Source License
private GridData getButtonGridData(Button button, FontMetrics fontMetrics) { GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return gd;//from w w w . ja v a2 s . c om }
From source file:org.eclipse.jdt.internal.debug.ui.propertypages.ExceptionFilterEditor.java
License:Open Source License
private static GridData getButtonGridData(Button button) { GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); GC gc = new GC(button); gc.setFont(button.getFont());// w ww . java 2 s . co m FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return gd; }
From source file:org.eclipse.jst.jsf.ui.internal.validation.PixelConverter.java
License:Open Source License
int convertHorizontalDLUsToPixels(int dlus) { return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); }
From source file:org.eclipse.riena.ui.swt.utils.UIControlsFactory.java
License:Open Source License
/** * Inspect the given {@link Button} widget and return the recommended width, * in pixels, so that the Button is wide enough to show it's contents * (image, text, etc.).//from ww w .jav a 2 s . c o m * * @param button * a Button instance; never null * @return suggested width; in pixels */ public static int getWidthHint(final Button button) { final GC gc = new GC(button.getDisplay()); try { final FontMetrics fm = gc.getFontMetrics(); final int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); final Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); return Math.max(widthHint, minSize.x); } finally { gc.dispose(); } }
From source file:org.eclipse.sirius.common.ui.tools.api.dialog.AbstractFolderSelectionDialog.java
License:Open Source License
/** * {@inheritDoc}// w w w. j ava2 s . c om * * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createDialogArea(final Composite parent) { final Composite result = (Composite) super.createDialogArea(parent); getTreeViewer().addSelectionChangedListener(this); getTreeViewer().expandToLevel(2); fNewFolderButton = new Button(result, SWT.PUSH); fNewFolderButton.setText("New Folder"); fNewFolderButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { newFolderButtonPressed(); } }); fNewFolderButton.setFont(parent.getFont()); fNewFolderButton.setLayoutData(new GridData()); // Modified by Obeo (copy/paste // org.eclipse.pde.internal.ui.util.SWTUtil.setButtonDimensionHint(Button) Dialog.applyDialogFont(fNewFolderButton); final Object gd = fNewFolderButton.getLayoutData(); if (gd instanceof GridData) { if (fNewFolderButton.getFont().equals(JFaceResources.getDefaultFont())) { fNewFolderButton.setFont(JFaceResources.getDialogFont()); } final GC gc = new GC(fNewFolderButton); gc.setFont(fNewFolderButton.getFont()); final FontMetrics fFontMetrics = gc.getFontMetrics(); gc.dispose(); final int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); ((GridData) gd).widthHint = Math.max(widthHint, fNewFolderButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); } Dialog.applyDialogFont(result); return result; }
From source file:org.eclipse.team.internal.ui.dialogs.DialogArea.java
License:Open Source License
protected int convertHorizontalDLUsToPixels(int dlus) { return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus); }
From source file:org.eclipse.team.internal.ui.synchronize.ConfigureSynchronizeScheduleComposite.java
License:Open Source License
protected void createMainDialogArea(Composite parent) { GC gc = new GC(parent); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose();//from www .ja va2 s .c o m final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; gridLayout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); gridLayout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); setLayout(gridLayout); setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite area = this; createWrappingLabel(area, NLS.bind(TeamUIMessages.ConfigureRefreshScheduleDialog_1, new String[] { Utils.shortenText(SynchronizeView.MAX_NAME_LENGTH, schedule.getParticipant().getName()) }), 0, 3); enableBackgroundRefresh = new Button(area, SWT.CHECK); GridData gridData = new GridData(); gridData.horizontalSpan = 3; enableBackgroundRefresh.setLayoutData(gridData); enableBackgroundRefresh.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3); enableBackgroundRefresh.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { updateEnablements(); } public void widgetDefaultSelected(SelectionEvent e) { } }); synchronizeAt = createIndentedLabel(area, TeamUIMessages.ConfigureRefreshScheduleDialog_3a, 20); startTime = new DateTime(area, SWT.TIME | SWT.BORDER); gridData = new GridData(); gridData.horizontalSpan = 2; startTime.setLayoutData(gridData); repeatEvery = createIndentedButton(area, TeamUIMessages.ConfigureRefreshScheduleDialog_4, 20); repeatEvery.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { updateEnablements(); } public void widgetDefaultSelected(SelectionEvent e) { } }); timeInterval = new Text(area, SWT.BORDER | SWT.RIGHT); gridData = new GridData(); gridData.widthHint = 35; timeInterval.setLayoutData(gridData); timeInterval.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateEnablements(); } }); timeInterval.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { String string = e.text; char[] chars = new char[string.length()]; string.getChars(0, chars.length, chars, 0); for (int i = 0; i < chars.length; i++) { if (!('0' <= chars[i] && chars[i] <= '9')) { e.doit = false; return; } } } }); hoursOrMinutes = new Combo(area, SWT.READ_ONLY); hoursOrMinutes.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5, TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // hoursOrMinutes.setLayoutData(new GridData()); final Label label = new Label(area, SWT.WRAP); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; label.setLayoutData(gridData); label.setText(NLS.bind(TeamUIMessages.ConfigureRefreshScheduleDialog_2, new String[] { SubscriberRefreshSchedule.refreshEventAsString(schedule.getLastRefreshEvent()) })); initializeValues(); updateEnablements(); }
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 www .j a v a 2 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.ide.markers.compatibility.api.FilterConfigurationArea.java
License:Open Source License
/** * Set the standard button data for the button. * @param button// w w w.ja va 2s . c om */ protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(getFontMetrics(), IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }