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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations