List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java
License:Open Source License
/** * Creates a new button with the given id. * <p>/*from w ww. j a v a 2s .c om*/ * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers it for * selection events including button presses, and registers default buttons with its shell. The button id is stored as * the button's client data. If the button id is <code>IDialogConstants.CANCEL_ID</code>, the new button will be * accessible from <code>getCancelButton()</code>. If the button id is <code>IDialogConstants.OK_ID</code>, the new * button will be accesible from <code>getOKButton()</code>. Note that the parent's layout is assumed to be a * <code>GridLayout</code> and the number of columns in this layout is incremented. Subclasses may override. * </p> * * @param parent * the parent composite * @param id * the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids) * @param defaultLabel * the label from the button * @param defaultButton * <code>true</code> if the button is to be the default button, and <code>false</code> otherwise * @param handlerMethod * (java) name of the method which handles this button. Must be of kind 'public void xxx()' * @return the new button */ protected Button createButton(final Composite parent, final int id, final String defaultLabel, final String handlerMethod, final boolean defaultButton) { final Integer buttonID = new Integer(id); final String label = m_buttonLabels.containsKey(buttonID) ? (String) m_buttonLabels.get(buttonID) : defaultLabel; // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; final Button button = new Button(parent, SWT.PUSH); button.setText(label); button.setFont(JFaceResources.getDialogFont()); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { buttonPressed(handlerMethod); } }); if (m_useDefaultButton && defaultButton) { final Shell shell = parent.getShell(); if (shell != null) shell.setDefaultButton(button); } m_buttons.put(buttonID, button); setButtonLayoutData(button); return button; }
From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java
License:Open Source License
/** * Initializes the computation of horizontal and vertical dialog units based on the size of current font. * <p>/*from ww w .j a va 2s . c o m*/ * This method must be called before any of the dialog unit based conversion methods are called. * </p> * * @param control * a control from which to obtain the current font */ protected void initializeDialogUnits(final Control control) { // Compute and store a font metric final GC gc = new GC(control); gc.setFont(JFaceResources.getDialogFont()); m_fontMetrics = gc.getFontMetrics(); gc.dispose(); }
From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java
License:Open Source License
/** * Creates the dialog's title area./*ww w. j a v a2 s. co m*/ * * @param parent * the SWT parent for the title area widgets * @return Control with the highest x axis value. */ private Control createTitleArea(final Composite parent) { // remeber parent in order to change its colors m_parent = parent; // Determine the background color of the title bar final Display display = parent.getDisplay(); m_defaultTitleBackground = JFaceColors.getBannerBackground(display).getRGB(); m_defaultTitleForeground = JFaceColors.getBannerForeground(display).getRGB(); final int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); final int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // Dialog image @ right m_titleImage = new Label(parent, SWT.CENTER); m_titleImage.setImage(JFaceResources.getImage(TitleAreaDialog.DLG_IMG_TITLE_BANNER)); final FormData imageData = new FormData(); imageData.top = new FormAttachment(0, verticalSpacing); // Note: do not use horizontalSpacing on the right as that would be a // regression from // the R2.x style where there was no margin on the right and images are // flush to the right // hand side. see reopened comments in 41172 imageData.right = new FormAttachment(100, 0); // horizontalSpacing m_titleImage.setLayoutData(imageData); // Title label @ top, left m_titleLabel = new Label(parent, SWT.LEFT); m_titleLabel.setFont(JFaceResources.getBannerFont()); m_titleLabel.setText(" ");//$NON-NLS-1$ final FormData titleData = new FormData(); titleData.top = new FormAttachment(0, verticalSpacing); titleData.right = new FormAttachment(m_titleImage); titleData.left = new FormAttachment(0, horizontalSpacing); m_titleLabel.setLayoutData(titleData); // Message image @ bottom, left m_messageImageLabel = new Label(parent, SWT.CENTER); // Message label @ bottom, center m_messageLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY); m_messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ m_messageLabel.setFont(JFaceResources.getDialogFont()); // Filler labels m_leftFillerLabel = new Label(parent, SWT.CENTER); m_bottomFillerLabel = new Label(parent, SWT.CENTER); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); determineTitleImageLargest(); if (m_titleImageLargest) return m_titleImage; return m_messageLabel; }
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();//from w w w . j a v a 2 s. co 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> * //from w w w. ja v a 2 s. co m * @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.knime.ext.textprocessing.preferences.NewSearchEngineDialog.java
License:Open Source License
/** * Creates "OK" button and handles the use input. * @param parent the parent composite//ww w . j a v a 2 s . c o m * @param id the button id * @param label The button label * @param defaultButton if {@code true} button is the default button. * @return the "OK" button. */ protected Button createOkButton(final Composite parent, final int id, final String label, final boolean defaultButton) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(label); button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(id)); button.addSelectionListener(new SelectionAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(final SelectionEvent event) { if (isValidInput()) { okPressed(); } } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } setButtonLayoutData(button); return button; }
From source file:org.l2x6.eircc.ui.editor.AbstractIrcEditor.java
License:Open Source License
/** * Initializes the given viewer's font.// ww w . jav a 2 s.c om * * @param viewer * the viewer * @since 2.0 */ private void initializeViewerFont(ISourceViewer viewer) { boolean isSharedFont = true; Font font = null; String symbolicFontName = JFaceResources.DIALOG_FONT; if (symbolicFontName != null) font = JFaceResources.getFont(symbolicFontName); if (font == null) font = JFaceResources.getDialogFont(); if (!font.equals(logViewer.getTextWidget().getFont())) { setFont(viewer, font); disposeFont(); if (!isSharedFont) fFont = font; } else if (!isSharedFont) { font.dispose(); } }
From source file:org.mailster.gui.prefs.ConfigurationDialog.java
License:Open Source License
/** * Creates the wizard's title area.//w w w. j a v a2s. c om * * @param parent the SWT parent for the title area composite * @return the created title area composite */ protected Composite createTitleArea(Composite parent) { /* * Create the title area which will contai a title, message, and image. */ int margins = 2; Composite titleArea = new Composite(parent, SWT.NONE); FormLayout layout = new FormLayout(); layout.marginHeight = 5; layout.marginWidth = margins; titleArea.setLayout(layout); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.verticalAlignment = SWT.TOP; titleArea.setLayoutData(layoutData); /* Message label */ this.messageArea = new DialogMessageArea(); this.messageArea.createContents(titleArea); titleArea.addControlListener(new ControlAdapter() { /** * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ public void controlResized(ControlEvent e) { updateMessage(); } }); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) updateMessage(); if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) { updateMessage(); Font dialogFont = JFaceResources.getDialogFont(); updateTreeFont(dialogFont); Control[] children = ((Composite) buttonBar).getChildren(); for (int i = 0; i < children.length; i++) children[i].setFont(dialogFont); } } }; titleArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); JFaceResources.getFontRegistry().addListener(fontListener); this.messageArea.setTitleLayoutData(this.createMessageAreaData()); this.messageArea.setMessageLayoutData(this.createMessageAreaData()); return (titleArea); }
From source file:org.modelio.api.ui.ModelioDialog.java
License:Apache License
@objid("bc2b30b7-120f-11e2-b5c6-002564c97630") @Override/* ww w . j a v a2 s . c o m*/ protected Control createContents(Composite parent) { Composite contents = new Composite(parent, 0); contents.setLayoutData(new GridData(1808)); initializeDialogUnits(contents); FormLayout layout = new FormLayout(); contents.setLayout(layout); this.workArea = new Composite(contents, SWT.NONE); GridLayout childLayout = new GridLayout(); childLayout.marginHeight = 0; childLayout.marginWidth = 0; childLayout.verticalSpacing = 0; this.workArea.setLayout(childLayout); Control top = createTitleArea(contents); resetWorkAreaAttachments(top); this.workArea.setFont(JFaceResources.getDialogFont()); initializeDialogUnits(this.workArea); this.dialogArea = createDialogArea(this.workArea); this.buttonBar = createButtonBar(this.workArea); ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin("org.modelio.ui", "icons/headerleft.png"); Image image = imageDescriptor.createImage(); setTitleLeftImage(image); init(); return contents; }
From source file:org.modelio.api.ui.ModelioDialog.java
License:Apache License
@objid("bc2b30d0-120f-11e2-b5c6-002564c97630") private Control createTitleArea(Composite parent) { this.titleArea = new Composite(parent, SWT.NONE); initializeDialogUnits(this.titleArea); FormData titleAreaData = new FormData(); titleAreaData.top = new FormAttachment(0, 0); titleAreaData.left = new FormAttachment(0, 0); titleAreaData.right = new FormAttachment(100, 0); this.titleArea.setLayoutData(titleAreaData); FormLayout layout = new FormLayout(); this.titleArea.setLayout(layout); this.titleArea.addDisposeListener(new DisposeListener() { @Override//from w w w . jav a2 s . co m public void widgetDisposed(DisposeEvent e) { if (ModelioDialog.this.titleAreaColor != null) ModelioDialog.this.titleAreaColor.dispose(); } }); org.eclipse.swt.widgets.Display display = this.titleArea.getDisplay(); Color background; Color foreground; if (this.titleAreaRGB != null) { this.titleAreaColor = new Color(display, this.titleAreaRGB); background = this.titleAreaColor; foreground = null; } else { background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); } int verticalSpacing = convertVerticalDLUsToPixels(1); int horizontalSpacing = convertHorizontalDLUsToPixels(4); this.titleArea.setBackground(background); this.titleRightImageLabel = new Label(this.titleArea, SWT.NONE); this.titleRightImageLabel.setBackground(background); if (this.titleRightImage != null && !this.titleRightImage.isDisposed()) this.titleRightImageLabel.setImage(this.titleRightImage); this.titleLeftImageLabel = new Label(this.titleArea, SWT.NONE); this.titleLeftImageLabel.setBackground(background); if (this.titleLeftImage == null || this.titleLeftImage.isDisposed()) this.titleLeftImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER)); else this.titleLeftImageLabel.setImage(this.titleLeftImage); FormData rightImageData = new FormData(); rightImageData.top = new FormAttachment(0, 0); rightImageData.right = new FormAttachment(100, 0); this.titleRightImageLabel.setLayoutData(rightImageData); FormData leftImageData = new FormData(); leftImageData.top = new FormAttachment(0, 0); leftImageData.left = new FormAttachment(0, 0); this.titleLeftImageLabel.setLayoutData(leftImageData); this.titleLabel = new Label(this.titleArea, SWT.NONE); JFaceColors.setColors(this.titleLabel, foreground, background); this.titleLabel.setFont(JFaceResources.getBannerFont()); this.titleLabel.setText(" "); FormData titleData = new FormData(); titleData.left = new FormAttachment(this.titleLeftImageLabel, 5); titleData.top = new FormAttachment(0, verticalSpacing); titleData.right = new FormAttachment(this.titleRightImageLabel, -5); this.titleLabel.setLayoutData(titleData); this.messageImageLabel = new Label(this.titleArea, SWT.NONE); this.messageImageLabel.setBackground(background); this.messageLabel = new Text(this.titleArea, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); //this.messageLabel.setEnabled(false); this.messageLabel.setEditable(false); JFaceColors.setColors(this.messageLabel, foreground, background); this.messageLabel.setFont(JFaceResources.getDialogFont()); this.messageLabelHeight = this.messageLabel.computeSize(-1, -1).y; this.leftFillerLabel = new Label(this.titleArea, SWT.NONE); this.leftFillerLabel.setBackground(background); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); determineTitleImageLargest(); return this.titleArea; }