Search in sources :

Example 11 with FormText

use of org.eclipse.ui.forms.widgets.FormText in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method displayUpdate.

private void displayUpdate(final SyndEntry entry, String severity, Composite composite, int pos, Control[] children) {
    ImageHyperlink link;
    FormText text;
    if (pos < children.length / 2) {
        link = (ImageHyperlink) children[pos * 2];
        link.setVisible(true);
        text = (FormText) children[pos * 2 + 1];
        text.setVisible(true);
    } else {
        link = toolkit.createImageHyperlink(composite, SWT.NONE);
        text = new FormText(composite, SWT.WRAP | SWT.MULTI | SWT.NO_BACKGROUND | SWT.NO_FOCUS);
        text.setHyperlinkSettings(toolkit.getHyperlinkGroup());
        final TableWrapData data = new TableWrapData();
        data.indent = UPDATE_INDENTATION;
        data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT;
        text.setLayoutData(data);
        text.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT;
            }
        });
        text.setBackground(toolkit.getColors().getBackground());
        text.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                if (e.data instanceof String) {
                    TasksUiUtil.openUrl((String) e.data);
                }
            }
        });
    }
    link.setText(entry.getTitle());
    TableWrapData linkData = new TableWrapData();
    if ("important".equals(severity)) {
        link.setImage(StsUiImages.getImage(StsUiImages.IMPORTANT));
        linkData.indent = 0;
    } else if ("warning".equals(severity)) {
        link.setImage(StsUiImages.getImage(StsUiImages.WARNING));
        linkData.indent = 0;
    } else {
        // link.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
        linkData.indent = UPDATE_INDENTATION - 1;
    }
    link.setLayoutData(linkData);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            String url = entry.getLink();
            if (url == null) {
                return;
            }
            TasksUiUtil.openUrl(url);
        }
    });
    String description = getDescription(entry);
    if (entry.getPublishedDate() != null && description.endsWith("</p></form>")) {
        String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate());
        description = description.replace("</p></form>", " (" + dateString + ")</p></form>");
    } else if (entry.getPublishedDate() != null) {
        String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate());
        description = description + " (" + dateString + ")";
    }
    text.setText(description, description.startsWith("<form>"), true);
    text.setForeground(feedColor);
    text.setBackground(toolkit.getColors().getBackground());
    addImages(text, description);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) PaintEvent(org.eclipse.swt.events.PaintEvent) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) PaintListener(org.eclipse.swt.events.PaintListener) FormText(org.eclipse.ui.forms.widgets.FormText) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 12 with FormText

use of org.eclipse.ui.forms.widgets.FormText in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method displayFeed.

private void displayFeed(SyndEntry entry, Composite composite, final Section section, final int pos, Control[] children) {
    ImageHyperlink link;
    FormText text;
    if (pos < children.length / 2) {
        link = (ImageHyperlink) children[pos * 2];
        link.setVisible(true);
        text = (FormText) children[pos * 2 + 1];
        text.setVisible(true);
    } else {
        final ImageHyperlink newLink = toolkit.createImageHyperlink(composite, SWT.NONE);
        feedControls.add(newLink);
        link = newLink;
        link.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                Object source = e.getSource();
                if (source instanceof ImageHyperlink && ((ImageHyperlink) source).getData() != null) {
                    SyndEntry entry = (SyndEntry) ((ImageHyperlink) source).getData();
                    String url = entry.getLink();
                    if (url == null) {
                        return;
                    }
                    int urlPos = url.indexOf("?");
                    String newUrl = url;
                    if (urlPos > 0) {
                        newUrl = url.substring(0, urlPos + 1) + url.substring(urlPos + 1).replaceAll("\\?", "&");
                    }
                    TasksUiUtil.openUrl(url);
                    prefStore.setValue(IIdeUiConstants.PREF_FEED_ENTRY_READ_STATE + ":" + newUrl, true);
                    IdeUiPlugin.getDefault().savePluginPreferences();
                    newLink.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
                }
            }
        });
        // text = new Text(composite, SWT.WRAP | SWT.MULTI |
        // SWT.NO_BACKGROUND);
        text = new FormText(composite, SWT.WRAP | SWT.MULTI | SWT.NO_BACKGROUND | SWT.NO_FOCUS);
        text.setHyperlinkSettings(toolkit.getHyperlinkGroup());
        feedControls.add(text);
        final TableWrapData data = new TableWrapData();
        data.indent = UPDATE_INDENTATION;
        data.maxWidth = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
        data.grabVertical = true;
        text.setLayoutData(data);
        text.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                data.maxWidth = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
            }
        });
        text.setForeground(feedColor);
        text.setBackground(toolkit.getColors().getBackground());
    }
    String title = entry.getTitle();
    Date entryDate = new Date(0);
    if (entry.getUpdatedDate() != null) {
        entryDate = entry.getUpdatedDate();
    } else {
        entryDate = entry.getPublishedDate();
    }
    String dateString = "";
    if (entryDate != null) {
        dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entryDate);
    }
    String entryAuthor = "";
    if (entry.getAuthor() != null && entry.getAuthor().trim() != "") {
        entryAuthor = " by " + entry.getAuthor();
    }
    if (dateString.length() > 0 && entryAuthor.length() > 0) {
        link.setText(removeHtmlEntities(title));
    }
    TableWrapData linkData = new TableWrapData();
    if (!prefStore.getBoolean(IIdeUiConstants.PREF_FEED_ENTRY_READ_STATE + ":" + entry.getLink())) {
        link.setImage(IdeUiPlugin.getImage(ICON_BLOG_INCOMING));
        linkData.indent = 0;
    } else {
        // link.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
        linkData.indent = UPDATE_INDENTATION - 1;
    }
    link.setLayoutData(linkData);
    link.setData(entry);
    String description = trimText(getDescription(entry));
    text.setText(description + " (" + dateString + entryAuthor + ")", false, false);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) PaintListener(org.eclipse.swt.events.PaintListener) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) FormText(org.eclipse.ui.forms.widgets.FormText) Date(java.util.Date) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 13 with FormText

use of org.eclipse.ui.forms.widgets.FormText in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method createOpenShiftApplicationControls.

private void createOpenShiftApplicationControls(FormToolkit toolkit, Composite parent, DataBindingContext dbc) {
    Composite container = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
    FormText title = toolkit.createFormText(container, false);
    title.setText("<b>OpenShift Application Destination (To)</b>", true, false);
    GridDataFactory.fillDefaults().span(3, 1).applyTo(title);
    GridDataFactory.fillDefaults().span(3, 1).applyTo(toolkit.createSeparator(container, SWT.HORIZONTAL));
    createResourceControls(container, dbc);
    createPodPathControls(container, dbc);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FormText(org.eclipse.ui.forms.widgets.FormText)

Example 14 with FormText

use of org.eclipse.ui.forms.widgets.FormText in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method createEclipseProjectControls.

protected void createEclipseProjectControls(FormToolkit toolkit, Composite parent, DataBindingContext dbc) {
    Composite container = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
    FormText title = toolkit.createFormText(container, false);
    title.setText("<b>Eclipse Project Source (From)</b>", true, false);
    GridDataFactory.fillDefaults().span(3, 1).applyTo(title);
    GridDataFactory.fillDefaults().span(3, 1).applyTo(toolkit.createSeparator(container, SWT.HORIZONTAL));
    createProjectControls(container, dbc);
    createProjectPathControls(container, dbc);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FormText(org.eclipse.ui.forms.widgets.FormText)

Example 15 with FormText

use of org.eclipse.ui.forms.widgets.FormText in project jbosstools-hibernate by jbosstools.

the class RevEngOverviewPage method createContentsSection.

private void createContentsSection() {
    String sectionTitle;
    sectionTitle = MapperMessages.RevEngOverviewPage_contents;
    Section section = createStaticSection(getManagedForm().getToolkit(), getManagedForm().getForm().getBody(), sectionTitle);
    Composite container = getManagedForm().getToolkit().createComposite(section, SWT.NONE);
    TableWrapLayout layout = new TableWrapLayout();
    layout.leftMargin = layout.rightMargin = layout.topMargin = layout.bottomMargin = 0;
    container.setLayout(layout);
    container.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    FormText text = createClient(container, MapperMessages.RevEngOverviewPage_the_content, getManagedForm().getToolkit());
    // text.setImage("page", EclipseImages.getImage(ImageConstants.)); //$NON-NLS-1$
    section.setClient(container);
// section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
// section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL,GridData.FILL_VERTICAL));
// getManagedForm().addPart(s);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) FormText(org.eclipse.ui.forms.widgets.FormText) Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

FormText (org.eclipse.ui.forms.widgets.FormText)19 Composite (org.eclipse.swt.widgets.Composite)12 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)10 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 GridData (org.eclipse.swt.layout.GridData)6 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)5 URL (java.net.URL)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 Tree (org.eclipse.swt.widgets.Tree)4 IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)3 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)3 ScrolledFormText (org.eclipse.ui.forms.widgets.ScrolledFormText)3 File (java.io.File)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2