use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class DiscoveryItem method createInstallButtons.
@Override
protected void createInstallButtons(Composite parent) {
// prevent the button from changing the layout of the title
Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().indent(0, BUTTONBAR_MARGIN_TOP).align(SWT.TRAIL, SWT.FILL).applyTo(composite);
int numColumns = 1;
boolean installed = connector.isInstalled();
final String url = getCatalogItemNode().getUrl();
if (installed && getViewer().getContentType() != ContentType.INSTALLED && getViewer().getContentType() != ContentType.SELECTION) {
Button alreadyInstalledButton = new Button(composite, SWT.PUSH | SWT.BOLD);
setWidgetId(alreadyInstalledButton, WIDGET_ID_ALREADY_INSTALLED);
alreadyInstalledButton.setText(Messages.DiscoveryItem_AlreadyInstalled);
// $NON-NLS-1$
alreadyInstalledButton.setFont(JFaceResources.getFontRegistry().getItalic(""));
Point preferredSize = alreadyInstalledButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// Give a bit of extra padding for italic font
int preferredWidth = preferredSize.x + 10;
GridDataFactory.swtDefaults().align(SWT.TRAIL, SWT.CENTER).minSize(preferredWidth, SWT.DEFAULT).hint(preferredWidth, SWT.DEFAULT).grab(false, true).applyTo(alreadyInstalledButton);
alreadyInstalledButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
// show installed tab
getViewer().setContentType(ContentType.INSTALLED);
// then scroll to item
getViewer().reveal(DiscoveryItem.this);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
} else if (hasInstallMetadata()) {
DropDownButton dropDown = new DropDownButton(composite, SWT.PUSH);
Button button = dropDown.getButton();
setWidgetId(button, WIDGET_ID_ACTION);
Point preferredSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// Give a bit of extra padding for bold or italic font
int preferredWidth = preferredSize.x + 10;
GridDataFactory.swtDefaults().align(SWT.TRAIL, SWT.CENTER).minSize(preferredWidth, SWT.DEFAULT).grab(false, true).applyTo(button);
buttonController = new ItemButtonController(getViewer(), this, dropDown);
} else if (browser != null && url != null && !"".equals(url.trim())) {
// $NON-NLS-1$
installInfoLink = StyledTextHelper.createStyledTextLabel(composite);
setWidgetId(installInfoLink, WIDGET_ID_LEARNMORE);
installInfoLink.setToolTipText(Messages.DiscoveryItem_installInstructionsTooltip);
StyledTextHelper.appendLink(installInfoLink, Messages.DiscoveryItem_installInstructions, Messages.DiscoveryItem_installInstructions, SWT.BOLD);
new LinkListener() {
@Override
protected void selected(Object href, TypedEvent e) {
browser.openUrl(url);
}
}.register(installInfoLink);
GridDataFactory.swtDefaults().align(SWT.TRAIL, SWT.CENTER).grab(false, true).applyTo(installInfoLink);
} else {
Label placeholder = new Label(composite, SWT.NONE);
// $NON-NLS-1$
placeholder.setText(" ");
GridDataFactory.swtDefaults().align(SWT.TRAIL, SWT.CENTER).grab(false, true).applyTo(placeholder);
}
GridLayoutFactory.fillDefaults().numColumns(numColumns).margins(0, 0).extendedMargins(0, 5, 0, 0).spacing(5, 0).applyTo(composite);
}
use of org.eclipse.swt.events.TypedEvent in project epp.mpc by eclipse.
the class FavoriteListDiscoveryItem method createSublineLabel.
@Override
protected StyledText createSublineLabel(Composite parent) {
StyledText subline = super.createSublineLabel(parent);
if (connector.getOwnerProfileUrl() != null) {
StyleRange range = new StyleRange(0, subline.getText().length(), subline.getForeground(), null, SWT.NONE);
// reset styling
subline.setStyleRange(range);
configureProviderLink(subline, "by {0}", connector.getOwner(), connector.getOwnerProfileUrl(), new LinkListener() {
@Override
protected void selected(Object href, TypedEvent event) {
WorkbenchUtil.openUrl((String) href, IWorkbenchBrowserSupport.AS_EXTERNAL);
}
});
}
return subline;
}
use of org.eclipse.swt.events.TypedEvent in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_events_TypedEvent method test_toString.
@Test
public void test_toString() {
Event event = new Event();
event.widget = shell;
TypedEvent typedEvent = newTypedEvent(event);
assertNotNull(typedEvent.toString());
assertTrue(typedEvent.toString().length() > 0);
}
Aggregations