List of usage examples for org.eclipse.jface.dialogs Dialog convertHorizontalDLUsToPixels
public static int convertHorizontalDLUsToPixels(FontMetrics fontMetrics, int dlus)
From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java
License:Open Source License
/** * Returns the number of pixels corresponding to the given number of horizontal dialog units. * <p>//from w ww .j a v a 2s . c o m * This method may only be called after <code>initializeDialogUnits</code> has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param dlus * the number of horizontal dialog units * @return the number of pixels */ protected int convertHorizontalDLUsToPixels(final int dlus) { // test for failure to initialize for backward compatibility if (m_fontMetrics == null) return 0; return Dialog.convertHorizontalDLUsToPixels(m_fontMetrics, dlus); }
From source file:org.kalypso.ui.rrm.internal.cm.idw.IdwWizardFeatureControl.java
License:Open Source License
private void setButtonData(final Button button) { final GC gc = new GC(button); gc.setFont(JFaceResources.getDialogFont()); final FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose();// w w w . jav a2 s. c o m final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); final int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, 30); final Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
From source file:org.kelvinst.psfimport.ui.importWizards.PsfImportWizardWorkingSetsSelectionPage.java
License:Open Source License
/** * Add this block to the <code>parent</parent> * /* www .j a v a 2s .c om*/ * @param parent * the parent to add the block to */ public void createContent(final Composite parent) { int numColumn = 3; Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); composite.setLayout(new GridLayout(3, false)); workingSetAutomagicModeButton = new Button(composite, SWT.CHECK); workingSetAutomagicModeButton.setText("Automagic mode"); GridData automagicData = new GridData(SWT.FILL, SWT.CENTER, true, false); automagicData.horizontalSpan = numColumn; workingSetAutomagicModeButton.setLayoutData(automagicData); workingSetEnableButton = new Button(composite, SWT.CHECK); workingSetEnableButton.setText("Add projec&t to working sets"); GridData enableData = new GridData(SWT.FILL, SWT.CENTER, true, false); enableData.horizontalSpan = numColumn; workingSetEnableButton.setLayoutData(enableData); workingSetEnableButton.setSelection(selectedWorkingSets.length > 0); workingSetLabel = new Label(composite, SWT.NONE); workingSetLabel.setText("W&orking sets:"); workingSetCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false); textData.horizontalSpan = numColumn - 2; textData.horizontalIndent = 0; workingSetCombo.setLayoutData(textData); workingSetSelectButton = new Button(composite, SWT.PUSH); workingSetSelectButton.setText("S&elect..."); workingSetSelectButton.setFont(JFaceResources.getDialogFont()); GC gc = new GC(workingSetSelectButton); gc.setFont(workingSetSelectButton.getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = workingSetSelectButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); workingSetSelectButton.setLayoutData(data); workingSetSelectButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { SimpleWorkingSetSelectionDialog dialog = new SimpleWorkingSetSelectionDialog(parent.getShell(), workingSetTypeIds, selectedWorkingSets, false); dialog.setMessage("The new project will be added to the selected working sets:"); if (dialog.open() == Window.OK) { IWorkingSet[] result = dialog.getSelection(); if (result != null && result.length > 0) { selectedWorkingSets = result; PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(result[0]); } else { selectedWorkingSets = EMPTY_WORKING_SET_ARRAY; } updateWorkingSetSelection(); } } }); workingSetEnableButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateEnableState(workingSetEnableButton.getSelection()); } }); updateEnableState(workingSetEnableButton.getSelection()); workingSetCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSelectedWorkingSets(); } }); workingSetCombo.setItems(getHistoryEntries()); if (selectedWorkingSets.length == 0 && workingSetSelectionHistory.size() > 0) { workingSetCombo.select(historyIndex(workingSetSelectionHistory.get(0))); updateSelectedWorkingSets(); } else { updateWorkingSetSelection(); } }
From source file:org.objectstyle.wolips.launching.ui.AbstractWOArgumentsTab.java
License:Open Source License
/** * Returns a width hint for a button control. *//*from w ww. j a va 2 s . c om*/ private static int getButtonWidthHint(Button button) { GC gc = new GC(button); gc.setFont(button.getFont()); FontMetrics fFontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.robovm.eclipse.internal.TemplateChooser.java
License:Open Source License
private GridLayout initGridLayout(GridLayout layout) { layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); layout.marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); layout.marginHeight = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN); return layout; }
From source file:org.rssowl.ui.internal.dialogs.bookmark.FeedDefinitionPage.java
License:Open Source License
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, false)); /* 1) Feed by Link */ if (!StringUtils.isSet(fInitialLink)) fInitialLink = loadInitialLinkFromClipboard(); boolean loadTitleFromFeed = fGlobalScope.getBoolean(DefaultPreferences.BM_LOAD_TITLE_FROM_FEED); fFeedByLinkButton = new Button(container, SWT.RADIO); fFeedByLinkButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); fFeedByLinkButton.setText(loadTitleFromFeed ? Messages.FeedDefinitionPage_CREATE_FEED : Messages.FeedDefinitionPage_CREATE_FEED_DIRECT); fFeedByLinkButton.setSelection(true); fFeedByLinkButton.addSelectionListener(new SelectionAdapter() { @Override// ww w . j ava2 s .c om public void widgetSelected(SelectionEvent e) { fFeedLinkInput.setEnabled(fFeedByLinkButton.getSelection()); fLoadTitleFromFeedButton.setEnabled(fFeedByLinkButton.getSelection()); fFeedLinkInput.setFocus(); getContainer().updateButtons(); } }); Composite textIndent = new Composite(container, SWT.NONE); textIndent.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); textIndent.setLayout(new GridLayout(1, false)); ((GridLayout) textIndent.getLayout()).marginLeft = 10; ((GridLayout) textIndent.getLayout()).marginBottom = 10; fFeedLinkInput = new Text(textIndent, SWT.BORDER); fFeedLinkInput.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); OwlUI.makeAccessible(fFeedLinkInput, fFeedByLinkButton); GC gc = new GC(fFeedLinkInput); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); int entryFieldWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.ENTRY_FIELD_WIDTH); gc.dispose(); ((GridData) fFeedLinkInput.getLayoutData()).widthHint = entryFieldWidth; //Required to avoid large spanning dialog for long Links fFeedLinkInput.setFocus(); if (StringUtils.isSet(fInitialLink) && !fInitialLink.equals(URIUtils.HTTP)) { fFeedLinkInput.setText(fInitialLink); fFeedLinkInput.selectAll(); onLinkChange(); } else { fFeedLinkInput.setText(URIUtils.HTTP); fFeedLinkInput.setSelection(URIUtils.HTTP.length()); } fFeedLinkInput.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().updateButtons(); onLinkChange(); } }); fLoadTitleFromFeedButton = new Button(textIndent, SWT.CHECK); fLoadTitleFromFeedButton.setText(Messages.FeedDefinitionPage_USE_TITLE_OF_FEED); fLoadTitleFromFeedButton.setSelection(loadTitleFromFeed); fLoadTitleFromFeedButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getContainer().updateButtons(); } }); /* 2) Feed by Keyword */ fFeedByKeywordButton = new Button(container, SWT.RADIO); fFeedByKeywordButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); fFeedByKeywordButton.setText(Messages.FeedDefinitionPage_CREATE_KEYWORD_FEED); fFeedByKeywordButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { fKeywordInput.setEnabled(fFeedByKeywordButton.getSelection()); if (fKeywordInput.isEnabled()) hookKeywordAutocomplete(); fKeywordInput.setFocus(); getContainer().updateButtons(); } }); textIndent = new Composite(container, SWT.NONE); textIndent.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); textIndent.setLayout(new GridLayout(1, false)); ((GridLayout) textIndent.getLayout()).marginLeft = 10; fKeywordInput = new Text(textIndent, SWT.BORDER); OwlUI.makeAccessible(fKeywordInput, fFeedByKeywordButton); fKeywordInput.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); fKeywordInput.setEnabled(false); fKeywordInput.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().updateButtons(); } }); /* Info Container */ Composite infoContainer = new Composite(container, SWT.None); infoContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); infoContainer.setLayout(LayoutUtils.createGridLayout(2, 0, 5)); Label infoImg = new Label(infoContainer, SWT.NONE); infoImg.setImage(OwlUI.getImage(infoImg, "icons/obj16/info.gif")); //$NON-NLS-1$ infoImg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); Link infoLink = new Link(infoContainer, SWT.NONE); infoLink.setText(Messages.FeedDefinitionPage_IMPORT_WIZARD_TIP); infoLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); infoLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { new ImportAction().openWizardForKeywordSearch(getShell()); } }); Dialog.applyDialogFont(container); setControl(container); }
From source file:org.rssowl.ui.internal.dialogs.NewsFilterDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { /* Separator */ new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL) .setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); /* Title *//*from w w w . ja v a 2 s . c o m*/ setTitle(Messages.NewsFilterDialog_NEWS_FILTER); /* Title Image */ setTitleImage(OwlUI.getImage(fResources, "icons/wizban/filter_wiz.png")); //$NON-NLS-1$ /* Title Message */ setMessage(Messages.NewsFilterDialog_DEFINE_SEARCH); /* Name Input Filed */ Composite container = new Composite(parent, SWT.None); container.setLayout(LayoutUtils.createGridLayout(2, 10, 5, 0, 5, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); Label nameLabel = new Label(container, SWT.NONE); nameLabel.setText(Messages.NewsFilterDialog_NAME); Composite nameContainer = new Composite(container, SWT.BORDER); nameContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); nameContainer.setLayout(LayoutUtils.createGridLayout(2, 0, 0)); nameContainer.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); fNameInput = new Text(nameContainer, SWT.SINGLE); OwlUI.makeAccessible(fNameInput, nameLabel); fNameInput.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); if (fEditedFilter != null) { fNameInput.setText(fEditedFilter.getName()); fNameInput.selectAll(); } fNameInput.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { setErrorMessage(null); } }); GC gc = new GC(fNameInput); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); int entryFieldWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.ENTRY_FIELD_WIDTH); gc.dispose(); ((GridData) fNameInput.getLayoutData()).widthHint = entryFieldWidth; //Required to avoid large spanning dialog for long Links ToolBar generateTitleBar = new ToolBar(nameContainer, SWT.FLAT); OwlUI.makeAccessible(generateTitleBar, Messages.NewsFilterDialog_CREATE_NAME_FROM_CONDITIONS); generateTitleBar.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); ToolItem generateTitleItem = new ToolItem(generateTitleBar, SWT.PUSH); generateTitleItem.setImage(OwlUI.getImage(fResources, "icons/etool16/info.gif")); //$NON-NLS-1$ generateTitleItem.setToolTipText(Messages.NewsFilterDialog_CREATE_NAME_FROM_CONDITIONS); generateTitleItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onGenerateName(); } }); /* Sashform dividing search definition from actions */ SashForm sashForm = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); /* Top Sash */ Composite topSash = new Composite(sashForm, SWT.NONE); topSash.setLayout(LayoutUtils.createGridLayout(2, 0, 0, 0, 0, false)); createConditionControls(topSash); /* Bottom Sash */ Composite bottomSash = new Composite(sashForm, SWT.NONE); bottomSash.setLayout(LayoutUtils.createGridLayout(1, 0, 0, 0, 0, false)); /* Label in between */ Composite labelContainer = new Composite(bottomSash, SWT.NONE); labelContainer.setLayout(LayoutUtils.createGridLayout(1, 10, 3, 0, 0, false)); ((GridLayout) labelContainer.getLayout()).marginBottom = 2; labelContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); Label explanationLabel = new Label(labelContainer, SWT.NONE); explanationLabel.setText(Messages.NewsFilterDialog_PERFORM_ACTIONS); /* Action Controls */ createActionControls(bottomSash); /* Separator */ new Label(bottomSash, SWT.SEPARATOR | SWT.HORIZONTAL) .setLayoutData(new GridData(SWT.FILL, SWT.END, true, false)); /* Set weights to even */ sashForm.setWeights(new int[] { 50, 50 }); applyDialogFont(parent); return parent; }
From source file:org.rssowl.ui.internal.util.NewsColumnSelectionControl.java
License:Open Source License
private GridData setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data);//from www . j ava 2 s . c o m return data; }
From source file:org.springframework.ide.eclipse.ui.SpringUIUtils.java
License:Open Source License
/** * Returns a button with the given label, indentation, enablement and selection listener. *//*ww w.j a v a 2 s .c om*/ public static Button createButton(Composite parent, String labelText, SelectionListener listener, int indentation, boolean enabled) { Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont()); button.setText(labelText); button.addSelectionListener(listener); button.setEnabled(enabled); FontMetrics fontMetrics = getFontMetrics(button); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); gd.horizontalIndent = indentation; button.setLayoutData(gd); return button; }
From source file:org.talend.repository.ui.wizards.metadata.connection.ldap.BaseWidgetUtils.java
License:Open Source License
/** * Creates a button under the given parent. The button width is set to the default width. * //w ww .j a v a2 s .co m * @param parent the parent * @param text the label of the button * @param span the horizontal span * @return the created button */ public static Button createButton(Composite parent, String text, int span) { GC gc = new GC(parent); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); Button button = new Button(parent, SWT.PUSH); GridData gd = new GridData(); gd.widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); button.setLayoutData(gd); button.setText(text); return button; }