List of usage examples for org.eclipse.jface.resource JFaceResources getHeaderFont
public static Font getHeaderFont()
From source file:org.eclipse.scada.vi.details.swt.widgets.DataItemToolTip.java
License:Open Source License
@Override protected Composite createToolTipContentArea(final Event event, final Composite parent) { parent.setLayout(new FillLayout()); final Composite wrapper = new Composite(parent, SWT.NONE); wrapper.addDisposeListener(new DisposeListener() { @Override/* ww w. ja v a2s . com*/ public void widgetDisposed(final DisposeEvent e) { DataItemToolTip.this.resourceManager.dispose(); } }); final GridLayout layout = new GridLayout(2, false); layout.marginHeight = 10; layout.marginWidth = 10; layout.horizontalSpacing = 20; layout.verticalSpacing = 20; wrapper.setLayout(layout); wrapper.setBackground(wrapper.getDisplay().getSystemColor(SWT.COLOR_WHITE)); wrapper.setBackgroundMode(SWT.INHERIT_DEFAULT); this.headerLabel = new Label(wrapper, SWT.NONE); this.headerLabel.setText(this.item.getId()); this.headerLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); this.headerLabel.setFont(JFaceResources.getHeaderFont()); final Label warnIcon = new Label(wrapper, SWT.NONE); warnIcon.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); warnIcon.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_WARN_BIG)); this.text = new StyledText(wrapper, SWT.MULTI); this.text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); if (this.currentText != null) { this.text.setText(this.currentText.getString()); this.text.setStyleRanges(this.currentText.getStyleRanges()); } return wrapper; }
From source file:org.eclipse.scout.rt.ui.rap.util.ScoutFormToolkit.java
License:Open Source License
@Override public ScrolledForm createScrolledForm(Composite parent) { ScrolledForm form = new ScrolledForm(parent, SWT.V_SCROLL | SWT.WRAP | kit.getOrientation()); // form.setExpandHorizontal(true); // form.setExpandVertical(true); adapt(form, false, false);/*from w w w . ja v a 2s . c o m*/ form.setBackground(kit.getColors().getBackground()); form.setForeground(kit.getColors().getColor(IFormColors.TITLE)); form.setFont(JFaceResources.getHeaderFont()); return form; }
From source file:org.eclipse.swtbot.forms.finder.test.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it.//from w w w. j a v a2 s . c o m */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse Forms"); TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("This is an example of a form that is much longer and will need to wrap."); layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); toolkit.createLabel(form.getBody(), "Text field label:"); Text text = toolkit.createText(form.getBody(), ""); td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK); td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setText("Image link with no image"); ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ih.setText("Link with image and text"); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); eci.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); ec.setTextClient(eci); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText("Section title"); toolkit.createCompositeSeparator(section); section.setDescription("This is the description that goes below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append("<p>"); buf.append("Here is some plain text for the text to render; "); buf.append( "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); buf.append("</p>"); buf.append("<p>"); buf.append("<span color=\"header\" font=\"header\">This text is in header font and color.</span>"); buf.append("</p>"); buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); buf.append("We can also add <img href=\"image\"/> an image. "); buf.append("</p>"); buf.append("<li>A default (bulleted) list item.</li>"); buf.append("<li>Another bullet list item.</li>"); buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); buf.append( "<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); buf.append("</form>"); FormText rtext = toolkit.createFormText(form.getBody(), false); //rtext.setWhitespaceNormalized(false); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); rtext.setImage("image", JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_ERROR)); rtext.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); rtext.setFont("header", JFaceResources.getHeaderFont()); rtext.setFont("code", JFaceResources.getTextFont()); rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link active: " + e.getHref()); } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.ui.forms.article.views.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it.//from www . j a va 2 s . com */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText(Messages.getString("FormView.title")); //$NON-NLS-1$ TableWrapLayout layout = new TableWrapLayout(); //GridLayout layout = new GridLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), Messages.getString("FormView.link"), //$NON-NLS-1$ SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println(Messages.getString("FormView.linkMessage")); //$NON-NLS-1$ } }); link.setText(Messages.getString("FormView.longLink")); //$NON-NLS-1$ layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); //GridData gd = new GridData(); //gd.horizontalSpan = 2; //link.setLayoutData(gd); toolkit.createLabel(form.getBody(), Messages.getString("FormView.textLabel")); //$NON-NLS-1$ Text text = toolkit.createText(form.getBody(), ""); //$NON-NLS-1$ td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); //text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button button = toolkit.createButton(form.getBody(), Messages.getString("FormView.checkbox"), SWT.CHECK); //$NON-NLS-1$ td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); //gd = new GridData(); //gd.horizontalSpan = 2; //button.setLayoutData(gd); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); //eci.setImage(FormArticlePlugin.getDefault().getImageRegistry().get(FormArticlePlugin.IMG_SAMPLE)); ec.setTextClient(eci); ec.setText(Messages.getString("FormView.expandable")); //$NON-NLS-1$ String ctext = Messages.getString("FormView.expandableText") + //$NON-NLS-1$ Messages.getString("FormView.expandablText2") + //$NON-NLS-1$ Messages.getString("FormView.expandableText3") + //$NON-NLS-1$ Messages.getString("FormView.expandableText4"); //$NON-NLS-1$ Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText(Messages.getString("FormView.stitle")); //$NON-NLS-1$ section.setDescription(Messages.getString("FormView.sdesc")); //$NON-NLS-1$ Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, Messages.getString("FormView.radio1"), SWT.RADIO); //$NON-NLS-1$ button = toolkit.createButton(sectionClient, Messages.getString("FormView.radio2"), SWT.RADIO); //$NON-NLS-1$ section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); //$NON-NLS-1$ buf.append("<p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext1")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext2")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append("<p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext3")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext4")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext5")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext6")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext7")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext8")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext9")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext10")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext11")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext12")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext13")); //$NON-NLS-1$ buf.append("</form>"); //$NON-NLS-1$ FormText rtext = toolkit.createFormText(form.getBody(), true); rtext.setWhitespaceNormalized(true); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); rtext.setImage("image", //$NON-NLS-1$ FormArticlePlugin.getDefault().getImageRegistry().get(FormArticlePlugin.IMG_SAMPLE)); rtext.setColor("header", toolkit.getColors().getColor(FormColors.TITLE)); //$NON-NLS-1$ rtext.setFont("header", JFaceResources.getHeaderFont()); //$NON-NLS-1$ rtext.setFont("code", JFaceResources.getTextFont()); //$NON-NLS-1$ rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println(Messages.getString("FormView.lmessage") + e.getHref()); //$NON-NLS-1$ } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); */ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.ui.forms.examples.views.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it.//from w ww .ja v a 2s . com */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse Forms"); TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("This is an example of a form that is much longer and will need to wrap."); layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); toolkit.createLabel(form.getBody(), "Text field label:"); Text text = toolkit.createText(form.getBody(), ""); td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK); td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); ih.setText("Image Hyperlink with image and text"); td = new TableWrapData(); td.colspan = 2; ih.setLayoutData(td); enableHyperlink = toolkit.createButton(form.getBody(), "Hyperlink Enabled", SWT.CHECK); enableHyperlink.setSelection(true); enableHyperlink.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { ih.setEnabled(enableHyperlink.getSelection()); form.reflow(true); } public void widgetDefaultSelected(SelectionEvent e) { } }); td = new TableWrapData(); td.colspan = 2; enableHyperlink.setLayoutData(td); clearHyperlinkImage = toolkit.createButton(form.getBody(), "Hyperlink has image", SWT.CHECK); clearHyperlinkImage.setSelection(true); clearHyperlinkImage.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (clearHyperlinkImage.getSelection()) { ih.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); } else { ih.setImage(null); } form.reflow(true); } public void widgetDefaultSelected(SelectionEvent e) { } }); td = new TableWrapData(); td.colspan = 2; clearHyperlinkImage.setLayoutData(td); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); eci.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); ec.setTextClient(eci); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText("Section title"); toolkit.createCompositeSeparator(section); section.setDescription("This is the description that goes below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append("<p>"); buf.append("Here is some plain text for the text to render; "); buf.append( "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); buf.append("</p>"); buf.append("<p>"); buf.append("<span color=\"header\" font=\"header\">This text is in header font and color.</span>"); buf.append("</p>"); buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); buf.append("We can also add <img href=\"image\"/> an image. "); buf.append("</p>"); buf.append("<li>A default (bulleted) list item.</li>"); buf.append("<li>Another bullet list item.</li>"); buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); buf.append( "<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); buf.append("</form>"); FormText rtext = toolkit.createFormText(form.getBody(), false); //rtext.setWhitespaceNormalized(false); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); rtext.setImage("image", ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); rtext.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); rtext.setFont("header", JFaceResources.getHeaderFont()); rtext.setFont("code", JFaceResources.getTextFont()); rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link active: " + e.getHref()); } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.ui.internal.cheatsheets.composite.views.DescriptionPanel.java
License:Open Source License
public DescriptionPanel(ManagedForm mform, Composite parent) { FormToolkit toolkit = mform.getToolkit(); control = new Composite(parent, SWT.NULL); final GridLayout controlLayout = new GridLayout(); controlLayout.marginHeight = 0;//ww w . j a v a2s . com controlLayout.marginWidth = 0; control.setLayout(controlLayout); form = toolkit.createScrolledForm(control); panel = form.getBody(); form.setLayoutData(new GridData(GridData.FILL_BOTH)); toolkit.adapt(panel); TableWrapLayout layout = new TableWrapLayout(); panel.setLayout(layout); upperText = mform.getToolkit().createFormText(panel, false); mform.getToolkit().adapt(upperText, false, false); Composite separator = toolkit.createCompositeSeparator(panel); TableWrapData data = new TableWrapData(); data.align = TableWrapData.FILL; data.grabHorizontal = true; data.maxHeight = 1; separator.setLayoutData(data); lowerText = mform.getToolkit().createFormText(panel, false); mform.getToolkit().adapt(lowerText, false, false); upperText.marginWidth = 5; upperText.marginHeight = 5; upperText.setFont("header", JFaceResources.getHeaderFont()); //$NON-NLS-1$ upperText.setColor("title", toolkit.getColors().getColor(IFormColors.TITLE)); //$NON-NLS-1$ lowerText.marginWidth = 5; lowerText.marginHeight = 5; lowerText.setImage(START_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.COMPOSITE_TASK_START)); lowerText.setImage(SKIP_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.COMPOSITE_TASK_SKIP)); lowerText.setImage(GOTO_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.COMPOSITE_GOTO_TASK)); lowerText.setImage(REVIEW_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.COMPOSITE_TASK_REVIEW)); lowerText.setImage(WARNING_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.WARNING)); lowerText.setImage(INFORMATION_IMAGE, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.INFORMATION)); }
From source file:org.eclipse.ui.internal.ide.dialogs.WelcomeEditor.java
License:Open Source License
/** * Creates the wizard's title area.// www . j a v a 2 s . c o m * * @param parent the SWT parent for the title area composite * @return the created title area composite */ private Composite createTitleArea(Composite parent) { // Get the background color for the title area Display display = parent.getDisplay(); Color background = JFaceColors.getBannerBackground(display); Color foreground = JFaceColors.getBannerForeground(display); // Create the title area which will contain // a title, message, and image. Composite titleArea = new Composite(parent, SWT.NONE | SWT.NO_FOCUS); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; layout.numColumns = 2; titleArea.setLayout(layout); titleArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); titleArea.setBackground(background); // Message label final CLabel messageLabel = new CLabel(titleArea, SWT.LEFT) { protected String shortenText(GC gc, String text, int width) { if (gc.textExtent(text, SWT.DRAW_MNEMONIC).x <= width) { return text; } final String ellipsis = "..."; //$NON-NLS-1$ int ellipseWidth = gc.textExtent(ellipsis, SWT.DRAW_MNEMONIC).x; int length = text.length(); int end = length - 1; while (end > 0) { text = text.substring(0, end); int l1 = gc.textExtent(text, SWT.DRAW_MNEMONIC).x; if (l1 + ellipseWidth <= width) { return text + ellipsis; } end--; } return text + ellipsis; } }; JFaceColors.setColors(messageLabel, foreground, background); messageLabel.setText(getBannerTitle()); messageLabel.setFont(JFaceResources.getHeaderFont()); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.HEADER_FONT.equals(event.getProperty())) { messageLabel.setFont(JFaceResources.getHeaderFont()); } } }; messageLabel.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); JFaceResources.getFontRegistry().addListener(fontListener); GridData gd = new GridData(GridData.FILL_BOTH); messageLabel.setLayoutData(gd); // Title image Label titleImage = new Label(titleArea, SWT.LEFT); titleImage.setBackground(background); titleImage.setImage(PlatformUI.getWorkbench().getSharedImages() .getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER)); gd = new GridData(); gd.horizontalAlignment = GridData.END; titleImage.setLayoutData(gd); return titleArea; }
From source file:org.eclipse.ui.internal.intro.impl.swt.PageStyleManager.java
License:Open Source License
public static Font getHeaderFont() { return JFaceResources.getHeaderFont(); }
From source file:org.eclipse.ui.tests.forms.performance.FormsPerformanceTest.java
License:Open Source License
public void createPartControl(Composite parent, FormToolkit toolkit) { //Label l = new Label(parent, SWT.NULL); //l.setText ("a label"); ScrolledForm form;//from w w w.j a va 2s . co m form = toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse Forms"); TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("This is an example of a form that is much longer and will need to wrap."); layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); toolkit.createLabel(form.getBody(), "Text field label:"); Text text = toolkit.createText(form.getBody(), ""); td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK); td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); ih.setText("Image link with no image"); ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); //ih.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); ih.setText("Link with image and text"); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); //eci.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); ec.setTextClient(eci); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { //form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { //form.reflow(true); } }); section.setText("Section title"); toolkit.createCompositeSeparator(section); section.setDescription("This is the description that goes below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append("<p>"); buf.append("Here is some plain text for the text to render; "); buf.append( "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); buf.append("</p>"); buf.append("<p>"); buf.append("<span color=\"header\" font=\"header\">This text is in header font.</span>"); buf.append("</p>"); buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); buf.append("We can also add <img href=\"image\"/> an image. "); buf.append("</p>"); buf.append("<li>A default (bulleted) list item.</li>"); buf.append("<li>Another bullet list item.</li>"); buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); buf.append( "<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); buf.append("</form>"); FormText rtext = toolkit.createFormText(form.getBody(), false); //rtext.setWhitespaceNormalized(false); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); //rtext.setImage("image", ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); //rtext.setColor("header", JFaceColors.getErrorText(display)); rtext.setFont("header", JFaceResources.getHeaderFont()); rtext.setFont("code", JFaceResources.getTextFont()); rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link active: " + e.getHref()); } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ toolkit.paintBordersFor(form.getBody()); }
From source file:org.eclipse.ui.texteditor.InfoForm.java
License:Open Source License
/** * Handles the property change./*from w w w . j ava 2 s . co m*/ * * @param event the property change event object describing which property changed and how */ protected void handlePropertyChange(PropertyChangeEvent event) { if (fHeader != null) fHeader.setFont(JFaceResources.getHeaderFont()); if (fBanner != null) fBanner.setFont(JFaceResources.getBannerFont()); Control control = fScrolledComposite.getContent(); fScrolledComposite.setMinSize(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)); fScrolledComposite.setContent(control); fScrolledComposite.layout(true); fScrolledComposite.redraw(); }