Search in sources :

Example 6 with TypedEvent

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);
}
Also used : TypedEvent(org.eclipse.swt.events.TypedEvent) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 7 with TypedEvent

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;
}
Also used : TypedEvent(org.eclipse.swt.events.TypedEvent) StyledText(org.eclipse.swt.custom.StyledText) StyleRange(org.eclipse.swt.custom.StyleRange)

Example 8 with TypedEvent

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);
}
Also used : TypedEvent(org.eclipse.swt.events.TypedEvent) TypedEvent(org.eclipse.swt.events.TypedEvent) Event(org.eclipse.swt.widgets.Event) Test(org.junit.Test)

Aggregations

TypedEvent (org.eclipse.swt.events.TypedEvent)8 StyledText (org.eclipse.swt.custom.StyledText)4 Event (org.eclipse.swt.widgets.Event)4 Point (org.eclipse.swt.graphics.Point)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 ITag (org.eclipse.epp.mpc.core.model.ITag)2 ToolTip (org.eclipse.jface.window.ToolTip)2 AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 Composite (org.eclipse.swt.widgets.Composite)2 Test (org.junit.Test)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 ITags (org.eclipse.epp.mpc.core.model.ITags)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1