List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.bbaw.pdr.ae.view.main.editors.PersonEditorDialog.java
License:Open Source License
/** * Creates the ok button./* w ww .j a v a 2 s.c o m*/ * @param parent the parent * @param id the id * @param label the label * @param defaultButton the default button * @return the button */ protected final Button createOkButton(final Composite parent, final int id, final String label, final boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; _saveButton = new Button(parent, SWT.PUSH); _saveButton.setText(label); _saveButton.setFont(JFaceResources.getDialogFont()); _saveButton.setData(new Integer(id)); _saveButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { if (isValidInput()) { okPressed(); } } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(_saveButton); } } setButtonLayoutData(_saveButton); return _saveButton; }
From source file:org.bbaw.pdr.ae.view.main.editors.ReferenceGenreEditor.java
License:Open Source License
/** * meth creates the OK button./* w w w . j av a 2s .c o m*/ * @param parent parent composite * @param id id * @param label label of button * @param defaultButton is default * @return okButton */ protected final Button createOkButton(final Composite parent, final int id, final String label, final boolean defaultButton) { // increment the number of columns in the button bar ((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() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("OK pressed"); //$NON-NLS-1$ if (isValidInput()) { okPressed(); } } }); setButtonLayoutData(button); return button; }
From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java
License:Open Source License
/** * Creates the ok button.// w w w. j ava 2s . c o m * @param parent the parent * @param id the id * @param label the label * @param defaultButton the default button * @return the button */ protected final Button createOkButton(final Composite parent, final int id, final String label, final boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; _savebutton = new Button(parent, SWT.PUSH); _savebutton.setText(label); _savebutton.setFont(JFaceResources.getDialogFont()); _savebutton.setData(new Integer(id)); _savebutton.setEnabled(_mayWrite); _savebutton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { if (isValidInput()) { okPressed(); } } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(_savebutton); } } setButtonLayoutData(_savebutton); return _savebutton; }
From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.wizards.CloudFoundryServiceWizardPage1.java
License:Open Source License
protected void initializeDialogUnits(Control testControl) { // Compute and store a font metric GC gc = new GC(testControl); gc.setFont(JFaceResources.getDialogFont()); fontMetrics = gc.getFontMetrics();//w w w.j a va2 s. c o m gc.dispose(); }
From source file:org.csstudio.alarm.beast.ui.actions.EditAAItemDialog.java
License:Open Source License
@SuppressWarnings("nls") @Override//from w ww . j av a 2 s. c o m protected void okPressed() { rowData[0] = titleText == null ? "" : titleText.getText().trim(); rowData[1] = detailsText == null ? "" : detailsText.getText().trim(); rowData[2] = delayText == null ? "" : delayText.getText().trim(); try { if (rowData[1] != null && !rowData[1].isEmpty()) { NotifierUtils.performValidation(rowData[1]); } showingError = false; super.okPressed(); } catch (Exception e) { if (!showingError) { // Message image @ left final Label messageImageLabel = new Label(header, SWT.NONE); messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR)); GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); gridData.widthHint = 30; messageImageLabel.setLayoutData(gridData); messageImageLabel.pack(); // Message label @ right messageLabel = new Text(header, SWT.WRAP); messageLabel.setBackground(header.getBackground()); messageLabel.setForeground(parent_composite.getDisplay().getSystemColor(SWT.COLOR_RED)); messageLabel.setFont(JFaceResources.getDialogFont()); header.setVisible(true); showingError = true; } String message = e.getMessage(); // Cut long messages GC gc = new GC(messageLabel); int charWidth = gc.getFontMetrics().getAverageCharWidth(); int parentWidth = parent_composite.getSize().x; int msgLength = message.length(); int parentMaxLength = (parentWidth - 70) / charWidth; if (msgLength > parentMaxLength) { int nbLines = (msgLength / parentMaxLength) + 1; StringBuilder sb = new StringBuilder(); int index = 0; while (index < nbLines) { int beginIndex = index * parentMaxLength; int endIndex = (index + 1) * parentMaxLength; if (endIndex > msgLength) endIndex = msgLength; sb.append(message.substring(beginIndex, endIndex)); if (index < nbLines - 1) sb.append("\n"); index++; } message = sb.toString(); } messageLabel.setText(message); messageLabel.pack(); header.pack(); parent_composite.layout(); getShell().layout(); } }
From source file:org.dadacoalition.yedit.preferences.tasktag.SWTUtil.java
License:Open Source License
/** * Returns a height hint for a button control. * @deprecated/*from ww w.ja v a 2s .co m*/ * @see IDialogConstants#BUTTON_HEIGHT */ @Deprecated public static int getButtonHeigthHint(Button button) { if (button.getFont().equals(JFaceResources.getDefaultFont())) button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); }
From source file:org.dafoe.ontologiclevel.Dialog.AnnotationDialog2.java
License:Open Source License
/** * Create contents of the button bar.// w w w. j ava 2s . co m * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(IDialogConstants.OK_LABEL); button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(IDialogConstants.OK_ID)); GridData GD = new GridData(GridData.FILL_HORIZONTAL); GD.widthHint = 56; button.setLayoutData(GD); Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } //createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,true); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (ontoObject == null) { setReturnCode(CANCEL); close(); } else { try { if (CreerAnnotation()) { setReturnCode(OK); close(); } } catch (Exception exec) { exec.printStackTrace(); } } } }); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:org.dafoe.ontologiclevel.Dialog.ChangeRangeDataTypeDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(IDialogConstants.OK_LABEL); button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(IDialogConstants.OK_ID)); GridData GD = new GridData(GridData.FILL_HORIZONTAL); GD.widthHint = 56;/*from w ww . jav a 2s. c o m*/ button.setLayoutData(GD); Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } //createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,true); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (CreerPropriete()) { setReturnCode(OK); close(); } } }); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:org.dafoe.ontologiclevel.Dialog.ChoixClasse.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(IDialogConstants.OK_LABEL); button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(IDialogConstants.OK_ID)); GridData GD = new GridData(GridData.FILL_HORIZONTAL); GD.widthHint = 56;/* ww w . j a v a 2 s.co m*/ button.setLayoutData(GD); Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } //createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,true); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { if (tree.getSelection().length > 0) { TreeItem it = tree.getSelection()[0]; if (it.getData() != null) { selectedClasse = (IClass) it.getData(); setReturnCode(OK); close(); } } } catch (Exception exec) { exec.printStackTrace(); } } }); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:org.dafoe.ontologiclevel.Dialog.ChoixInverse.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(IDialogConstants.OK_LABEL); button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(IDialogConstants.OK_ID)); GridData GD = new GridData(GridData.FILL_HORIZONTAL); GD.widthHint = 56;//from w w w . jav a 2 s.c om button.setLayoutData(GD); Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } //createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,true); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { if (tree.getSelection().length > 0) { TreeItem it = tree.getSelection()[0]; if (it.getData() != null) { selectedProperty = (IObjectProperty) it.getData(); setReturnCode(OK); close(); } } } catch (Exception exec) { exec.printStackTrace(); } } }); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }