Example usage for org.eclipse.jface.resource JFaceResources getTextFont

List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getTextFont.

Prototype

public static Font getTextFont() 

Source Link

Document

Returns JFace's text font.

Usage

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   w  w w.  java2s.  co m*/
 */
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  .java 2s .  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);

    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.about.AboutSystemPage.java

License:Open Source License

public void createControl(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IWorkbenchHelpContextIds.SYSTEM_SUMMARY_DIALOG);

    Composite outer = createOuterComposite(parent);

    text = new Text(outer, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.NO_FOCUS | SWT.H_SCROLL);
    text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = convertVerticalDLUsToPixels(300);
    gridData.widthHint = convertHorizontalDLUsToPixels(400);
    text.setLayoutData(gridData);/*  w  w w  . java  2s. c  o m*/
    text.setFont(JFaceResources.getTextFont());
    fetchConfigurationInfo(text);
    setControl(outer);
}

From source file:org.eclipse.ui.internal.dialogs.AboutSystemDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite outer = (Composite) super.createDialogArea(parent);

    text = new Text(outer, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.NO_FOCUS | SWT.H_SCROLL);
    text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = convertVerticalDLUsToPixels(300);
    gridData.widthHint = convertHorizontalDLUsToPixels(400);
    text.setLayoutData(gridData);/* w ww .jav a 2 s . c  o  m*/
    text.setText(ConfigurationInfo.getSystemSummary());
    text.setFont(JFaceResources.getTextFont());
    return outer;
}

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  ww  .j  a  v a 2s.c  o 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.AbstractTextEditor.java

License:Open Source License

/**
 * Initializes the given viewer's font.//w  ww. j a  va 2 s  . com
 *
 * @param viewer the viewer
 * @since 2.0
 */
private void initializeViewerFont(ISourceViewer viewer) {

    boolean isSharedFont = true;
    Font font = null;
    String symbolicFontName = getSymbolicFontName();

    if (symbolicFontName != null)
        font = JFaceResources.getFont(symbolicFontName);
    else if (fPreferenceStore != null) {
        // Backward compatibility
        if (fPreferenceStore.contains(JFaceResources.TEXT_FONT)
                && !fPreferenceStore.isDefault(JFaceResources.TEXT_FONT)) {
            FontData data = PreferenceConverter.getFontData(fPreferenceStore, JFaceResources.TEXT_FONT);

            if (data != null) {
                isSharedFont = false;
                font = new Font(viewer.getTextWidget().getDisplay(), data);
            }
        }
    }
    if (font == null)
        font = JFaceResources.getTextFont();

    if (!font.equals(fSourceViewer.getTextWidget().getFont())) {
        setFont(viewer, font);

        disposeFont();
        if (!isSharedFont)
            fFont = font;
    } else if (!isSharedFont) {
        font.dispose();
    }
}

From source file:org.eclipse.wst.common.snippets.internal.VariableInsertionDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(getDialogTitle());
    SnippetsPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(parent,
            IHelpContextIds.DIALOG_INSERT_VARITEM);

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*from   ww w. j  a  v a  2s . c  o m*/
    layout.makeColumnsEqualWidth = true;
    layout.horizontalSpacing += 2;
    layout.verticalSpacing += 2;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(parent.getFont());

    GridData doubleWide = new GridData(GridData.FILL_BOTH);
    doubleWide.horizontalSpan = 2;
    Text instructions = new Text(composite, SWT.WRAP | SWT.LEFT);
    instructions.setBackground(composite.getBackground());
    doubleWide.heightHint = instructions.getFont().getFontData()[0].getHeight() * 3;
    instructions.setLayoutData(doubleWide);
    instructions.setText(SnippetsMessages.Edit_Instruction);
    instructions.setEditable(false);

    Text tableLabel = new Text(composite, SWT.NONE);
    tableLabel.setBackground(composite.getBackground());
    tableLabel.setText(SnippetsMessages.Variables__4);
    tableLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableLabel.setEditable(false);

    Text descriptionBoxLabel = new Text(composite, SWT.NONE);
    descriptionBoxLabel.setBackground(composite.getBackground());
    descriptionBoxLabel.setText(SnippetsMessages.Description_of_variable__5);
    descriptionBoxLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    descriptionBoxLabel.setEditable(false);

    // pity we can't just use a PropertySheetPage, but the column headers
    // aren't customizable
    fTableViewer = new StringPropertyTableViewer();
    fTableViewer.setColumnNames(new String[] { SnippetsMessages.Variable_Name_6, SnippetsMessages.Value_7 });
    fTableViewer.setEditFirstColumn(false);
    fTableViewer.createContents(composite);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = fTableViewer.getTable().getItemHeight() * 5;
    fTableViewer.getControl().setLayoutData(data);
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISnippetVariable variable = null;
            if (fTableViewer.getSelection() != null) {
                variable = getVariable(fTableViewer.getSelection());
            }
            fDescriptionPane.setText(variable != null ? variable.getDescription() : ""); //$NON-NLS-1$
            fDescriptionPane.setHorizontalPixel(2);
            fDescriptionPane.redraw();
        }
    });
    fTableViewer.addValueChangedListener(new ValueChangedListener() {
        public void valueChanged(String key, String property, String oldValue, String newValue) {
            update();
        }
    });

    fDescriptionPane = new StyledText(composite,
            SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
    fDescriptionPane.setLayoutData(new GridData(GridData.FILL_BOTH));
    fDescriptionPane.setEnabled(true);
    fDescriptionPane.setEditable(false);
    fDescriptionPane.addVerifyKeyListener(createVerifyListener(fDescriptionPane));
    fDescriptionPane.setFont(JFaceResources.getDialogFont());
    setAccessible(fDescriptionPane, SnippetsMessages.Description_of_variable__5);

    doubleWide = new GridData(GridData.FILL_BOTH);
    doubleWide.horizontalSpan = 2;
    Text previewLabel = new Text(composite, SWT.NULL);
    previewLabel.setBackground(composite.getBackground());
    previewLabel.setText(SnippetsMessages.Preview__9);
    previewLabel.setEditable(false);

    doubleWide = new GridData(GridData.FILL_BOTH);
    doubleWide.horizontalSpan = 2;
    doubleWide.heightHint = parent.getDisplay().getClientArea().height / 6;
    doubleWide.widthHint = parent.getDisplay().getClientArea().width / 8;
    fPreviewPane = new StyledText(composite, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    fPreviewPane.addVerifyKeyListener(createVerifyListener(fPreviewPane));
    fPreviewPane.addLineStyleListener(new LineStyleListener() {
        public void lineGetStyle(LineStyleEvent event) {
            // System.out.println("hilight: " + event.lineOffset);
        }
    });
    fPreviewPane.setEnabled(true);
    fPreviewPane.setEditable(false);
    fPreviewPane.setFont(JFaceResources.getTextFont());
    fPreviewPane.setLayoutData(doubleWide);
    setAccessible(fPreviewPane, SnippetsMessages.Preview__9);

    if (fItem != null) {
        fTableViewer.clear();
        populateTableViewer();
        fTableViewer.refresh();
    }

    addContents(composite);

    update();
    fTableViewer.getControl().setFocus();
    return composite;
}

From source file:org.eclipse.wst.ide.remote.ui.internal.viewers.ByteViewer.java

License:Open Source License

/** (non-Javadoc)
 * @see ContentViewer#init(Composite)//  w  w w .  j a  v  a 2s. co  m
 */
public void init(Composite parent) {
    byteViewerBodyComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    GridData data = new GridData(
            GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING);
    data.horizontalSpan = 2;

    byteViewerBodyComposite.setLayoutData(data);
    byteViewerBodyComposite.setLayout(layout);

    // This additional layout helps with aligning the text boxes in
    // org.eclipse.wst.ide.remote.ui.internal.view.MonitorView
    Composite request = new Composite(byteViewerBodyComposite, SWT.NONE);
    GridLayout layout2 = new GridLayout();
    layout2.numColumns = 2;
    request.setLayout(layout2);

    encodingLabel = new Label(request, SWT.NONE);
    encodingLabel.setText(NLS.bind(Messages.viewEncoding, ""));
    encodingCombo = new Combo(request, SWT.RIGHT);

    // Add the default option
    encodingCombo.add(NLS.bind(Messages.defaultEncodingOption, ""));
    // Select the default option
    encodingCombo.select(0);

    if (encodings != null) {
        int size = encodings.length;
        for (int i = 0; i < size; i++) {
            encodingCombo.add(encodings[i]);
        }
    }

    encodingCombo.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent me) {
            encodingType = encodingCombo.getText();
            if (contentArray != null) {
                setContent(contentArray);
            }
        }

    });

    text = new Text(byteViewerBodyComposite,
            SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    Display display = byteViewerBodyComposite.getDisplay();
    text.setLayoutData(data);
    text.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    text.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
    text.setFont(JFaceResources.getTextFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(text, ContextIds.VIEW_RESPONSE);
}

From source file:org.eclipse.wst.ide.remote.ui.internal.viewers.HeaderViewer.java

License:Open Source License

/**
 * Create a new header viewer./*from w  ww. jav a  2 s.c o  m*/
 * 
 * @param parent
 * @param message
 */
public HeaderViewer(Composite parent, byte message) {
    displayHeader = true;
    hidden = false;

    headerComp = new Composite(parent, SWT.NONE);
    layout = new MonitorStackLayout();
    headerComp.setLayout(layout);

    headerText = new Text(headerComp, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    Display display = headerComp.getDisplay();
    headerText.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    headerText.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
    headerText.setFont(JFaceResources.getTextFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(headerText, ContextIds.VIEW_RESPONSE);

    headerLabel = new Text(headerComp, SWT.READ_ONLY);

    layout.topControl = headerText;

    rr = null;
    msg = message;

    //if (msg==REQUEST_HEADER)
    //headerLabel.setText(NLS.bind(Messages.headerLabel1,""));
    //else if(msg==RESPONSE_HEADER)
    headerText.setText(NLS.bind(Messages.headerLabel2, ""));

    setDisplayHeader(false);
}

From source file:org.eclipse.wst.internet.monitor.ui.internal.viewers.ByteViewer.java

License:Open Source License

/** (non-Javadoc)
 * @see ContentViewer#init(Composite)//from w  w  w. jav  a 2 s .  c om
 */
public void init(Composite parent) {
    byteViewerBodyComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    GridData data = new GridData(
            GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING);
    data.horizontalSpan = 2;

    byteViewerBodyComposite.setLayoutData(data);
    byteViewerBodyComposite.setLayout(layout);

    // This additional layout helps with aligning the text boxes in
    // org.eclipse.wst.internet.monitor.ui.internal.view.MonitorView
    Composite request = new Composite(byteViewerBodyComposite, SWT.NONE);
    GridLayout layout2 = new GridLayout();
    layout2.numColumns = 2;
    request.setLayout(layout2);

    encodingLabel = new Label(request, SWT.NONE);
    encodingLabel.setText(NLS.bind(Messages.viewEncoding, ""));
    encodingCombo = new Combo(request, SWT.RIGHT);

    // Add the default option
    encodingCombo.add(NLS.bind(Messages.defaultEncodingOption, ""));
    // Select the default option
    encodingCombo.select(0);

    if (encodings != null) {
        int size = encodings.length;
        for (int i = 0; i < size; i++) {
            encodingCombo.add(encodings[i]);
        }
    }

    encodingCombo.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent me) {
            encodingType = encodingCombo.getText();
            if (contentArray != null) {
                setContent(contentArray);
            }
        }

    });

    text = new Text(byteViewerBodyComposite,
            SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    Display display = byteViewerBodyComposite.getDisplay();
    text.setLayoutData(data);
    text.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    text.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
    text.setFont(JFaceResources.getTextFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(text, ContextIds.VIEW_RESPONSE);
}