List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.xmind.ui.internal.dialogs.ProgressDialogPart.java
License:LGPL
private Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setBackground(parent.getBackground()); button.setText(label);/* w ww.ja va 2 s.c o m*/ button.setFont(JFaceResources.getDialogFont()); button.setData(Integer.valueOf(id)); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { buttonPressed(((Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } setButtonLayoutData(button); return button; }
From source file:org.xtuml.bp.core.ui.dialogs.ScrolledTextDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { if (usePrintAndSave) { ((GridLayout) parent.getLayout()).numColumns++; Button printButton;/*from ww w . ja va2 s .co m*/ printButton = new Button(parent, SWT.PUSH); printButton.setText("Print..."); printButton.setFont(JFaceResources.getDialogFont()); printButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PrintDialog dialog = new PrintDialog(Display.getCurrent().getActiveShell()); PrinterData data = dialog.open(); if (null != data) { Printer printer = new Printer(data); if (printer.startJob("DowngradeList-Print")) { GC gc = new GC(printer); if (printer.startPage()) { gc.drawText(textContents, 0, 0); printer.endPage(); } printer.endJob(); } printer.dispose(); } } }); setButtonLayoutData(printButton); ((GridLayout) parent.getLayout()).numColumns++; Button saveasButton; saveasButton = new Button(parent, SWT.PUSH); saveasButton.setText("Save..."); saveasButton.setFont(JFaceResources.getDialogFont()); saveasButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); String filename = dialog.open(); if (!filename.isEmpty()) { FileWriter writer = null; try { writer = new FileWriter(filename); writer.write(textContents); } catch (IOException ioe) { System.err.println("Exception occured: File not saved!"); } finally { try { writer.close(); } catch (Exception ex) { } } } } }); setButtonLayoutData(saveasButton); } if (optionalText != null) { ((GridLayout) parent.getLayout()).numColumns++; optionalButton = new Button(parent, SWT.CHECK); optionalButton.setText(optionalText); optionalButton.setFont(JFaceResources.getDialogFont()); optionalButton.setSelection(false); setButtonLayoutData(optionalButton); } createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); if (allowCancel) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } }
From source file:org.zend.php.zendserver.deployment.ui.editors.ResourceListSection.java
License:Open Source License
private Button createButton(FormToolkit toolkit, Composite buttons, String message) { Button button = toolkit.createButton(buttons, message, SWT.NONE); GridData gd = new GridData(SWT.FILL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.TOP, true, false); button.setLayoutData(gd);// w w w .ja v a 2s .com // Set the default button size button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return button; }
From source file:ro.sync.ecss.extensions.commons.editor.URLChooserEditorSWT.java
License:Open Source License
/** * Initialize components./*from w w w. j a v a 2s . c om*/ * * @param context The current context. */ private void prepareComponents(AuthorInplaceContext context) { dispose(); // Create the components. urlChooserComposite = new Composite((Composite) context.getParentHost(), SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginWidth = gridLayout.marginHeight = 0; urlChooserComposite.setLayout(gridLayout); textViewer = new SourceViewer(urlChooserComposite, null, SWT.FILL | SWT.SINGLE | SWT.BORDER); textViewer.configure(new TextSourceViewerConfiguration(EditorsPlugin.getDefault().getPreferenceStore())); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.horizontalIndent = 0; gd.verticalIndent = 0; textViewer.getTextWidget().setLayoutData(gd); browseButton = new Button(urlChooserComposite, SWT.PUSH); gd = new GridData(SWT.NONE, SWT.FILL, false, true); // Add required listeners. textViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() { @Override public void verifyKey(VerifyEvent e) { switch (e.keyCode) { case SWT.ESC: // On ESC cancel the editing and do not commit the value. e.doit = false; cancelEditing(); break; } } }); // Add focus listener FocusListener focusListener = new FocusListener() { @Override public void focusLost(FocusEvent e) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (!urlChooserComposite.isDisposed() && !browseButton.isFocusControl() && !textViewer.getTextWidget().isFocusControl() && !isBrowsing) { // Just make sure we are in sync with the document. fireCommitValue(new EditingEvent((String) getValue())); } } }); } @Override public void focusGained(FocusEvent e) { } }; textViewer.getTextWidget().addFocusListener(focusListener); browseButton.addFocusListener(focusListener); // Add key listener browseButton.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.ESC: // On ESC cancel the editing and do not commit the value. e.doit = false; cancelEditing(); break; } } }); textViewer.setDocument(new Document("")); IDocumentListener docChangedListener = new IDocumentListener() { @Override public void documentAboutToBeChanged(DocumentEvent event) { // Not of interest. } @Override public void documentChanged(DocumentEvent event) { fireEditingOccured(); } }; textViewer.getDocument().addDocumentListener(docChangedListener); Font font = (Font) context.getArguments().get(InplaceEditorArgumentKeys.FONT); if (font != null) { swtFont = new org.eclipse.swt.graphics.Font(Display.getDefault(), new FontData(font.getName(), font.getSize(), font.getStyle())); } if (swtFont != null) { textViewer.getTextWidget().setFont(swtFont); } else { textViewer.getTextWidget().setFont(JFaceResources.getDialogFont()); } Color color = (Color) context.getArguments().get(InplaceEditorArgumentKeys.PROPERTY_COLOR); if (color != null) { foregroundColor = new org.eclipse.swt.graphics.Color(Display.getDefault(), color.getRed(), color.getGreen(), color.getBlue()); textViewer.getTextWidget().setForeground(foregroundColor); } // Assign an open icon on the browse button. InputStream resourceAsStream = URLChooserEditorSWT.class.getResourceAsStream("/images/Open16.gif"); ImageData imageResource = null; if (resourceAsStream != null) { imageResource = new ImageData(resourceAsStream); // EXM-32124 - Make sure the stream is closed after using it try { resourceAsStream.close(); } catch (IOException e1) { //Ignore } } // Create button image ImageDescriptor icon = null; if (imageResource != null) { icon = ImageDescriptor.createFromImageData(imageResource); } buttonImage = null; if (icon != null) { buttonImage = icon.createImage(); } if (buttonImage != null) { browseButton.setImage(buttonImage); } browseButton.setLayoutData(gd); setInitialValue(context); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { // Didn't work without an invoke later. if (textViewer.getTextWidget() != null) { textViewer.getTextWidget().showSelection(); } } }); textViewer.getUndoManager().reset(); }
From source file:si.gos.eclipse.parts.ActionPart.java
License:Open Source License
protected Button createButton(Composite parent, String label, int index, IWidgetFactory factory) { boolean visible = getAction(index).isVisible(); final Button button = factory.createButton(parent, label, SWT.PUSH); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.exclude = !visible;/*from w w w . j a v a 2s. c o m*/ button.setLayoutData(gd); button.setData(new Integer(index)); button.setVisible(visible); // add property change listener PartAction action = getAction(index); action.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String prop = event.getProperty(); if (prop.equals("enabled")) { button.setEnabled((Boolean) event.getNewValue()); } else if (prop.equals("visible")) { GridData gd = (GridData) button.getLayoutData(); gd.exclude = !(Boolean) event.getNewValue(); button.setLayoutData(gd); button.setVisible((Boolean) event.getNewValue()); button.getParent().layout(true, true); } else if (prop.equals("text")) { button.setText((String) event.getNewValue()); } } }); button.setData(ACTION_KEY, action); // Set the default button size button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return button; }
From source file:tinyos.dlrc.editors.nesc.information.QuickfixInformationControl.java
License:Open Source License
private void createCompletionProposalsControl(Composite parent, ICompletionProposal[] proposals, IQuickFixInformation input) {/*from w w w . j ava2s.co m*/ Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout2 = new GridLayout(1, false); layout2.marginHeight = 0; layout2.marginWidth = 0; layout2.verticalSpacing = 2; composite.setLayout(layout2); Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); separator.setLayoutData(gridData); Label quickFixLabel = new Label(composite, SWT.NONE); GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); layoutData.horizontalIndent = 4; quickFixLabel.setLayoutData(layoutData); String text; if (proposals.length == 1) { text = "There is one quickfix available"; } else { text = "There are " + proposals.length + " quickfixes available"; } quickFixLabel.setText(text); setColorAndFont(composite, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont()); createCompletionProposalsList(composite, proposals, input); }
From source file:tinyos.dlrc.editors.nesc.information.QuickfixInformationControl.java
License:Open Source License
private void createCompletionProposalsList(Composite parent, ICompletionProposal[] proposals, IQuickFixInformation input) {/*w w w . ja v a2 s . com*/ final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); scrolledComposite.setLayoutData(gridData); scrolledComposite.setExpandVertical(false); scrolledComposite.setExpandHorizontal(false); Composite composite = new Composite(scrolledComposite, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout = new GridLayout(3, false); layout.verticalSpacing = 2; composite.setLayout(layout); final Link[] links = new Link[proposals.length]; for (int i = 0; i < proposals.length; i++) { Label indent = new Label(composite, SWT.NONE); GridData gridData1 = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); gridData1.widthHint = 0; indent.setLayoutData(gridData1); links[i] = createCompletionProposalLink(composite, proposals[i], input); } owner.setFocus(links[0]); scrolledComposite.setContent(composite); setColorAndFont(scrolledComposite, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont()); Point contentSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT); composite.setSize(contentSize); Point constraints = owner.getSizeConstraints(); if (constraints != null && contentSize.x < constraints.x) { ScrollBar horizontalBar = scrolledComposite.getHorizontalBar(); int scrollBarHeight; if (horizontalBar == null) { Point scrollSize = scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT); scrollBarHeight = scrollSize.y - contentSize.y; } else { scrollBarHeight = horizontalBar.getSize().y; } gridData.heightHint = contentSize.y - scrollBarHeight; } for (int i = 0; i < links.length; i++) { final int index = i; final Link link = links[index]; link.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.ARROW_DOWN: if (index + 1 < links.length) { links[index + 1].setFocus(); } break; case SWT.ARROW_UP: if (index > 0) { links[index - 1].setFocus(); } break; default: break; } } public void keyReleased(KeyEvent e) { } }); link.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { int currentPosition = scrolledComposite.getOrigin().y; int hight = scrolledComposite.getSize().y; int linkPosition = link.getLocation().y; if (linkPosition < currentPosition) { if (linkPosition < 10) linkPosition = 0; scrolledComposite.setOrigin(0, linkPosition); } else if (linkPosition + 20 > currentPosition + hight) { scrolledComposite.setOrigin(0, linkPosition - hight + link.getSize().y); } } public void focusLost(FocusEvent e) { } }); } }
From source file:ts.eclipse.ide.internal.ui.preferences.TypeScriptMainPropertyPage.java
License:Open Source License
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setLayout(new GridLayout()); final IProject project = (IProject) getElement().getAdapter(IResource.class); if (project != null) { GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3;//from w ww . j a v a2 s.com final Button enableBuilderCheckbox = new Button(composite, SWT.CHECK); enableBuilderCheckbox.setFont(JFaceResources.getDialogFont()); enableBuilderCheckbox .setText(TypeScriptUIMessages.TypeScriptMainPropertyPage_enable_builder_checkbox_label); enableBuilderCheckbox.setLayoutData(gd); enableBuilderCheckbox.setSelection(TypeScriptResourceUtil.hasTypeScriptBuilder(project)); enableBuilderCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (TypeScriptResourceUtil.hasTypeScriptBuilder(project)) { try { TypeScriptResourceUtil.removeTypeScriptBuilder(project); } catch (CoreException e) { ErrorDialog.openError(getShell(), TypeScriptUIMessages.TypeScriptBuilder_Error_title, TypeScriptUIMessages.TypeScriptBuilder_disable_Error_message, e.getStatus()); } } else { try { TypeScriptResourceUtil.addTypeScriptBuilder(project); } catch (CoreException e) { ErrorDialog.openError(getShell(), TypeScriptUIMessages.TypeScriptBuilder_Error_title, TypeScriptUIMessages.TypeScriptBuilder_enable_Error_message, e.getStatus()); } } } }); Link description = new Link(composite, SWT.NONE); description .setText(TypeScriptUIMessages.TypeScriptMainPropertyPage_enable_builder_checkbox_description); description.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (COMPILE_LINK.equals(e.text)) { openProjectProperties(project, TypeScriptRuntimePreferencePage.PROP_ID); } else { // openProjectProperties(project, ValidationPreferencePage.PROP_ID); } } }); description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } return composite; }
From source file:ts.eclipse.ide.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected Button addRadioBox(Composite parent, String label, Key key, String[] values, int indent) { ControlData data = new ControlData(key, values); // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); // gd.horizontalSpan = 3; // gd.horizontalIndent = indent; Button checkBox = new Button(parent, SWT.RADIO); checkBox.setFont(JFaceResources.getDialogFont()); checkBox.setText(label);//w w w. ja v a 2 s .co m checkBox.setData(data); // checkBox.setLayoutData(gd); checkBox.addSelectionListener(getSelectionListener()); makeScrollableCompositeAware(checkBox); String currValue = getValue(key); checkBox.setSelection(data.getSelection(currValue) == 0); fCheckBoxes.add(checkBox); return checkBox; }
From source file:ts.eclipse.ide.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) { GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1); gd.horizontalIndent = indent;/*from w w w . j a v a 2 s . c om*/ Label labelControl = new Label(parent, SWT.LEFT); labelControl.setText(label); labelControl.setFont(JFaceResources.getDialogFont()); labelControl.setLayoutData(gd); Combo comboBox = newComboControl(parent, key, values, valueLabels); comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); fLabels.put(comboBox, labelControl); return comboBox; }