List of usage examples for org.eclipse.jface.resource JFaceResources getBannerFont
public static Font getBannerFont()
From source file:com.nokia.cdt.internal.debug.launch.newwizard.AbstractLaunchWizardSection.java
License:Open Source License
protected void createSection(Composite parent, int acceleratorIndex) { Composite composite = new Composite(parent, SWT.NONE); GC gc = new GC(parent); int INDENT = gc.getAdvanceWidth('m') * 4; gc.dispose();//ww w. jav a 2 s . c om GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 0).applyTo(composite); // spacing Label spacer = new Label(composite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(spacer); Label titleLabel = new Label(composite, SWT.NONE); titleLabel.setText(sectionName); titleLabel.setFont(JFaceResources.getBannerFont()); GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(titleLabel); descriptionLabel = new Label(composite, SWT.WRAP); GridDataFactory.fillDefaults().grab(true, true).indent(INDENT, 0).hint(350, SWT.DEFAULT) .applyTo(descriptionLabel); String label = MessageFormat.format("{0}&{1}", //$NON-NLS-1$ CHANGE_LABEL.substring(0, acceleratorIndex), CHANGE_LABEL.substring(acceleratorIndex)); changeButton = new Button(composite, SWT.PUSH); changeButton.setText(label); Point minSize = changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); GridDataFactory.defaultsFor(changeButton).grab(false, false).hint(minSize.x + INDENT, SWT.DEFAULT) .indent(6, 0).applyTo(changeButton); changeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doChange(); if (changeListener != null) changeListener.changed(); } }); composite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { descriptionLabel.pack(); } }); this.control = composite; control.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dispose(); } }); validate(); updateUI(); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.editors.PromptDialog.java
License:Open Source License
public void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) { Shell parent = getParent();/*from ww w. j a va2 s .co m*/ final Shell shell = new Shell(parent, SWT.SHEET | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); if (title != null) shell.setText(title); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout); Label label = new Label(shell, SWT.WRAP | SWT.BOLD); label.setText(text); label.setFont(JFaceResources.getBannerFont()); GridData data = new GridData(); Monitor monitor = parent.getMonitor(); int maxWidth = monitor.getBounds().width * 2 / 3; int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; data.widthHint = Math.min(width, maxWidth); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; data.horizontalIndent = 15; data.verticalIndent = 15; label.setLayoutData(data); valueText = new Text(shell, SWT.BORDER); valueTextDecorator = createDecorator(valueText, "initial"); valueTextDecorator.setMarginWidth(5); valueTextDecorator.hide(); valueText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateStatus(); } }); if (value[0] != null) valueText.setText(value[0]); data = new GridData(); width = valueText.computeSize(500, SWT.DEFAULT).x; if (width > maxWidth) data.widthHint = maxWidth; else data.widthHint = width; data.minimumWidth = 300; data.horizontalAlignment = GridData.FILL; data.horizontalIndent = 15; data.grabExcessHorizontalSpace = true; valueText.setTextLimit(200); valueText.setLayoutData(data); buttons = new Button[3]; Listener listener = new Listener() { public void handleEvent(Event event) { if (buttons[0] != null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; value[0] = valueText.getText(); result[0] = event.widget == buttons[1] ? 1 : 0; shell.close(); } }; if (check != null) { buttons[0] = new Button(shell, SWT.CHECK); buttons[0].setText(check); buttons[0].setSelection(checkValue[0] != 0); data = new GridData(); data.horizontalAlignment = GridData.BEGINNING; data.horizontalIndent = 15; buttons[0].setLayoutData(data); } Composite composite = new Composite(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.CENTER; composite.setLayoutData(data); composite.setLayout(new GridLayout(2, true)); buttons[1] = new Button(composite, SWT.PUSH); buttons[1].setText(SWT.getMessage("SWT_OK")); //$NON-NLS-1$ buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); buttons[1].addListener(SWT.Selection, listener); buttons[2] = new Button(composite, SWT.PUSH); buttons[2].setText(SWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); buttons[2].addListener(SWT.Selection, listener); // make RETURN trigger OK shell.setDefaultButton(buttons[1]); // update status based on current value updateStatus(); shell.pack(); shell.open(); Display display = parent.getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
From source file:com.siemens.ct.mp3m.ui.presentation.Title.java
License:Open Source License
/** * Paint the title/*from w ww .ja va 2s.c om*/ */ public void paintControl(PaintEvent e) { Rectangle clientArea = getBounds(); Image img = new Image(e.display, clientArea.width, clientArea.height); GC gc = new GC(img); gc.setForeground(colorTop); gc.setBackground(colorBottom); gc.fillGradientRectangle(0, 0, clientArea.width, clientArea.height, true); if (part != null) { gc.setFont(JFaceResources.getBannerFont()); gc.setForeground(colorText); String dirty = ""; if (part.isDirty()) { dirty = "*"; } String text = shortenText(gc, dirty + part.getTitle(), clientArea.width - 30); gc.drawText(text, 5, 2, true); if (part.isCloseable()) { if (isCloseSelected) { gc.drawImage(closeSelectedImage, clientArea.width - 20, 2); } else { gc.drawImage(closeUnselectedImage, clientArea.width - 20, 2); } } } e.gc.drawImage(img, 0, 0); gc.dispose(); img.dispose(); }
From source file:ext.org.eclipse.jdt.internal.ui.jarpackager.JarManifestWizardPage.java
License:Open Source License
/** * Creates a new label with a bold font. * * @param parent the parent control//from w w w .j ava2 s . com * @param text the label text * @param bold bold or not * @return the new label control */ protected Label createLabel(Composite parent, String text, boolean bold) { Label label = new Label(parent, SWT.NONE); if (bold) label.setFont(JFaceResources.getBannerFont()); label.setText(text); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; label.setLayoutData(data); return label; }
From source file:ext.org.eclipse.jdt.internal.ui.jarpackagerfat.FatJarPackageWizardPage.java
License:Open Source License
/** * Creates a new label with an optional bold font. * /*from w ww. java 2s.co m*/ * @param parent the parent control * @param text the label text * @param bold bold or not * @return the new label control */ protected Label createLabel(Composite parent, String text, boolean bold) { Label label = new Label(parent, SWT.NONE); if (bold) label.setFont(JFaceResources.getBannerFont()); label.setText(text); GridData gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); label.setLayoutData(gridData); return label; }
From source file:name.schedenig.eclipse.grepconsole.view.notifications.GrepConsoleNotificationStyle.java
License:Open Source License
/** * Refreshes the style's properties based on the current preferences. *///from ww w .ja v a 2 s . c o m public void refresh() { Display display = manager.getDisplay(); RGB rgb = GrepConsoleUtil.getNotificationForegroundColor(); if (rgb != null) { setForeground(new Color(display, rgb), true); } else { setForeground(null, false); } rgb = GrepConsoleUtil.getNotificationBackgroundColor(); if (rgb != null) { setBackground(new Color(display, rgb), true); } else { setBackground(null, false); } IPreferenceStore prefs = activator.getPreferenceStore(); if (prefs.getString(Activator.PREFS_NOTIFICATION_TITLE_FONT).length() == 0) { setTitleFont(JFaceResources.getBannerFont(), false); } else { Font titleFont = new Font(display, PreferenceConverter.getFontData(prefs, Activator.PREFS_NOTIFICATION_TITLE_FONT)); setTitleFont(titleFont, true); } if (prefs.getString(Activator.PREFS_NOTIFICATION_MESSAGE_FONT).length() == 0) { setMessageFont(JFaceResources.getDialogFont(), false); } else { Font messageFont = new Font(display, PreferenceConverter.getFontData(prefs, Activator.PREFS_NOTIFICATION_MESSAGE_FONT)); setMessageFont(messageFont, true); } }
From source file:net.bioclipse.browser.editors.BrowserText.java
License:Open Source License
private void fillContent(Composite parent, Color bg) { GridLayout layout = new GridLayout(); layout.verticalSpacing = 10;/* ww w .j a v a 2s . c o m*/ parent.setLayout(layout); title = new Label(parent, SWT.WRAP); title.setText("Rich Browser"); title.setFont(JFaceResources.getHeaderFont()); title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); title.setBackground(bg); link = new Link(parent, SWT.WRAP); link.setText("Parent"); link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); link.setToolTipText("Parent page"); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { BusyIndicator.showWhile(link.getDisplay(), new Runnable() { public void run() { doOpenExternal(); } }); } }); link.setBackground(bg); sep = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); exTitle = new Label(parent, SWT.NULL); exTitle.setBackground(bg); exTitle.setFont(JFaceResources.getBannerFont()); exTitle.setText("Rich browser"); exTitle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text = new Label(parent, SWT.WRAP); text.setText("Rich browser"); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text.setBackground(bg); button = new Button(parent, SWT.PUSH); updateButtonText(); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleException(); } }); exception = new Text(parent, SWT.MULTI); loadExceptionText(); GridData gd = new GridData(GridData.FILL_BOTH); gd.exclude = true; exception.setLayoutData(gd); }
From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java
License:Open Source License
/** * Creates the dialog's title area.// www.jav a2 s . c om * * @param parent * the SWT parent for the title area widgets * @return Control with the highest x axis value. */ private Control createTitleArea(Composite parent) { // add a dispose listener parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (titleAreaColor != null) { titleAreaColor.dispose(); } } }); // Determine the background color of the title bar Display display = parent.getDisplay(); Color background; Color foreground; if (titleAreaRGB != null) { titleAreaColor = new Color(display, titleAreaRGB); background = titleAreaColor; foreground = null; } else { background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); } parent.setBackground(background); int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // Dialog image @ right titleImageLabel = new Label(parent, SWT.CENTER); titleImageLabel.setBackground(background); if (titleAreaImage == null) titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER)); else titleImageLabel.setImage(titleAreaImage); FormData imageData = new FormData(); imageData.top = new FormAttachment(0, 0); // 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 titleImageLabel.setLayoutData(imageData); // Title label @ top, left titleLabel = new Label(parent, SWT.LEFT); JFaceColors.setColors(titleLabel, foreground, background); titleLabel.setFont(JFaceResources.getBannerFont()); titleLabel.setText(" ");//$NON-NLS-1$ FormData titleData = new FormData(); titleData.top = new FormAttachment(0, verticalSpacing); titleData.right = new FormAttachment(titleImageLabel); titleData.left = new FormAttachment(0, horizontalSpacing); titleLabel.setLayoutData(titleData); // Message image @ bottom, left messageImageLabel = new Label(parent, SWT.CENTER); messageImageLabel.setBackground(background); // Message label @ bottom, center messageLabel = new Label(parent, SWT.WRAP | SWT.READ_ONLY); JFaceColors.setColors(messageLabel, foreground, background); messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ messageLabel.setFont(JFaceResources.getDialogFont()); messageLabel.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; // Filler labels leftFillerLabel = new Label(parent, SWT.CENTER); leftFillerLabel.setBackground(background); bottomFillerLabel = new Label(parent, SWT.CENTER); bottomFillerLabel.setBackground(background); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); determineTitleImageLargest(); if (titleImageLargest) return titleImageLabel; return messageLabel; }
From source file:net.mldonkey.g2gui.view.pref.G2GuiPref.java
License:Open Source License
protected void createFieldEditors() { Composite composite = getFieldEditorParent(); StringFieldEditor hostNameField = new StringFieldEditor("hostname", "Hostname", composite); hostNameField.setPreferenceStore(this.getPreferenceStore()); hostNameField.fillIntoGrid(composite, 2); addField(hostNameField);/*from w w w . j a v a2 s. co m*/ hostNameField.load(); StringFieldEditor portField = new StringFieldEditor("port", "Port", composite); portField.setPreferenceStore(this.getPreferenceStore()); portField.fillIntoGrid(composite, 2); addField(portField); portField.load(); StringFieldEditor userNameField = new StringFieldEditor("username", "Username", composite); userNameField.setPreferenceStore(this.getPreferenceStore()); userNameField.fillIntoGrid(composite, 2); addField(userNameField); userNameField.load(); StringFieldEditor passwordField = new StringFieldEditor("password", "Password", composite); passwordField.getTextControl(composite).setEchoChar('*'); passwordField.fillIntoGrid(composite, 2); passwordField.setPreferenceStore(this.getPreferenceStore()); addField(passwordField); passwordField.load(); GCJFileFieldEditor executableField = new GCJFileFieldEditor("coreExecutable", G2GuiResources.getString("PREF_CORE_EXEC"), true, composite); executableField.setPreferenceStore(this.getPreferenceStore()); addField(executableField); executableField.load(); if (VersionCheck.isWin32()) { executableField.setFileExtensions(new String[] { "*.exe;*.bat" }); } else { executableField.setFileExtensions(new String[] { "*" }); } FieldEditor mulitpleInstancesEditor = new BooleanFieldEditor("allowMultipleInstances", G2GuiResources.getString("PREF_ALLOW_MULIPLE"), composite); mulitpleInstancesEditor.setPreferenceStore(this.getPreferenceStore()); mulitpleInstancesEditor.fillIntoGrid(composite, 2); addField(mulitpleInstancesEditor); mulitpleInstancesEditor.load(); ExtendedBooleanFieldEditor advancedModeEditor = new ExtendedBooleanFieldEditor("advancedMode", "Advanced user mode (*)", composite); advancedModeEditor.setPreferenceStore(this.getPreferenceStore()); advancedModeEditor.fillIntoGrid(composite, 2); addField(advancedModeEditor); advancedModeEditor.load(); // Make this a little more obvious Button b = advancedModeEditor.getChangeControl(composite); b.setFont(JFaceResources.getBannerFont()); b.setToolTipText(G2GuiResources.getString("PREF_ADVANCED_TOOLTIP")); b.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_BLUE)); ((GridLayout) composite.getLayout()).numColumns = 2; }
From source file:net.refractions.udig.context.internal.MapExportPage.java
License:Open Source License
/** * Creates a new label with a bold font. * * @param parent the parent control/*from w ww .j a v a 2 s. c o m*/ * @param text the label text * @return the new label control */ protected Label createBoldLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); label.setFont(JFaceResources.getBannerFont()); label.setText(text); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; label.setLayoutData(data); return label; }