use of org.eclipse.swt.events.TypedEvent in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_events_TypedEvent method test_ConstructorLorg_eclipse_swt_widgets_Event.
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_Event() {
Event event = new Event();
event.widget = shell;
TypedEvent typedEvent = newTypedEvent(event);
assertNotNull(typedEvent);
}
use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class AbstractMarketplaceDiscoveryItem method createTagsTooltip.
private void createTagsTooltip(final StyledText tagsLink, final List<? extends ITag> tags) {
final ToolTip tooltip = new ToolTip(tagsLink, ToolTip.NO_RECREATE, false) {
@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
Composite result = new Composite(parent, SWT.NONE);
result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
result.setLayout(new GridLayout());
StyledText fullTagLinks = StyledTextHelper.createStyledTextLabel(result);
fullTagLinks.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fullTagLinks.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
for (int i = 0; i < MAX_TOTAL_TAGS && i < tags.size(); i++) {
ITag tag = tags.get(i);
String tagName = tag.getName();
StyledTextHelper.appendLink(fullTagLinks, tagName, tagName, SWT.NORMAL);
// $NON-NLS-1$
fullTagLinks.append(" ");
}
if (tags.size() > MAX_TOTAL_TAGS) {
// Limit shown tags to a hard maximum, because too many links
// can crash the StyledText widget (at least on Windows...)
fullTagLinks.append(ELLIPSIS);
}
new LinkListener() {
@Override
protected void selected(Object href, TypedEvent e) {
hide();
if (href != null) {
searchForTag(href.toString());
}
}
}.register(fullTagLinks);
GridData gridData = new GridData();
gridData.widthHint = tagsLink.getSize().x;
fullTagLinks.setLayoutData(gridData);
Dialog.applyDialogFont(result);
return result;
}
@Override
public Point getLocation(Point tipSize, Event event) {
Point size = tagsLink.getSize();
return tagsLink.toDisplay(0, size.y);
}
};
tagsLink.setData(tooltip);
tooltip.setHideOnMouseDown(false);
tooltip.setPopupDelay(0);
tooltip.activate();
}
use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class AbstractMarketplaceDiscoveryItem method createTagsLabel.
protected void createTagsLabel(Composite parent) {
tagsLink = StyledTextHelper.createStyledTextLabel(parent);
setWidgetId(tagsLink, WIDGET_ID_TAGS);
tagsLink.setEditable(false);
GridDataFactory.fillDefaults().indent(DESCRIPTION_MARGIN_LEFT, TAGS_MARGIN_TOP).span(3, 1).align(SWT.BEGINNING, SWT.BEGINNING).grab(true, false).applyTo(tagsLink);
ITags tagsObject = getCatalogItemNode().getTags();
if (tagsObject == null) {
return;
}
List<? extends ITag> tags = tagsObject.getTags();
if (tags.isEmpty()) {
return;
}
tags = new ArrayList<ITag>(tags);
// sort list so that technical tags are at the end
Collections.sort(tags, new Comparator<ITag>() {
public int compare(ITag o1, ITag o2) {
if (o1 == o2) {
return 0;
}
if (o1.getName().startsWith(FILE_EXTENSION_TAG_PREFIX)) {
if (o2.getName().startsWith(FILE_EXTENSION_TAG_PREFIX)) {
return 0;
}
return 1;
}
if (o2.getName().startsWith(FILE_EXTENSION_TAG_PREFIX)) {
return -1;
}
return 0;
}
});
boolean needsEllipsis = tags.size() > MAX_SHOWN_TAGS;
for (int i = 0; i < MAX_SHOWN_TAGS && i < tags.size(); i++) {
if (i > 0) {
// $NON-NLS-1$
tagsLink.append(" ");
}
ITag tag = tags.get(i);
String tagName = tag.getName();
StyledTextHelper.appendLink(tagsLink, tagName, tagName, SWT.NORMAL);
}
if (needsEllipsis) {
// $NON-NLS-1$
tagsLink.append(" ");
StyledTextHelper.appendLink(tagsLink, ELLIPSIS, ELLIPSIS, SWT.NORMAL);
createTagsTooltip(tagsLink, tags);
}
new LinkListener() {
@Override
protected void selected(Object href, TypedEvent e) {
if (href == ELLIPSIS) {
Object data = e.widget.getData();
if (data instanceof ToolTip) {
ToolTip tooltip = (ToolTip) data;
tooltip.show(new Point(0, 0));
}
} else if (href != null) {
searchForTag(href.toString());
}
}
}.register(tagsLink);
}
use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class AbstractMarketplaceDiscoveryItem method hookTooltip.
@Override
protected void hookTooltip(final Control parent, final Widget tipActivator, final Control exitControl, final Control titleControl, AbstractCatalogSource source, Overview overview, Image image) {
final OverviewToolTip toolTip = new OverviewToolTip(parent, browser, (MarketplaceCatalogSource) source, overview, image);
hookTooltip(toolTip, tipActivator, exitControl);
if (image != null) {
Listener listener = new Listener() {
public void handleEvent(Event event) {
toolTip.show(titleControl);
}
};
tipActivator.addListener(SWT.MouseHover, listener);
}
if (tipActivator instanceof StyledText) {
StyledText link = (StyledText) tipActivator;
new LinkListener() {
@Override
protected void selected(Object href, TypedEvent e) {
if (INFO_HREF.equals(href)) {
toolTip.show(titleControl);
}
}
}.register(link);
} else {
Listener selectionListener = new Listener() {
public void handleEvent(Event event) {
toolTip.show(titleControl);
}
};
tipActivator.addListener(SWT.Selection, selectionListener);
}
}
use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class AbstractMarketplaceDiscoveryItem method createProviderLabel.
protected StyledText createProviderLabel(Composite parent) {
StyledText providerLink = StyledTextHelper.createStyledTextLabel(parent);
// Link providerLink = new Link(parent, SWT.NONE);
setWidgetId(providerLink, WIDGET_ID_PROVIDER);
providerLink.setEditable(false);
GridDataFactory.fillDefaults().indent(DESCRIPTION_MARGIN_LEFT, DESCRIPTION_MARGIN_TOP).span(3, 1).align(SWT.BEGINNING, SWT.CENTER).grab(true, false).applyTo(providerLink);
// always disabled color to make it less prominent
providerLink.setForeground(resources.getColorDisabled());
String labelTemplate = Messages.DiscoveryItem_byProviderLicense;
String providerName = connector.getProvider();
LinkListener listener = new LinkListener() {
@Override
protected void selected(Object href, TypedEvent e) {
String searchTerm = href.toString();
if (searchTerm.contains(" ")) {
// $NON-NLS-1$
// $NON-NLS-1$//$NON-NLS-2$
searchTerm = "\"" + searchTerm + "\"";
}
searchForProvider(searchTerm);
}
};
configureProviderLink(providerLink, labelTemplate, providerName, null, listener);
return providerLink;
}
Aggregations