Search in sources :

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

Example 2 with 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();
}
Also used : ToolTip(org.eclipse.jface.window.ToolTip) TypedEvent(org.eclipse.swt.events.TypedEvent) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) ITag(org.eclipse.epp.mpc.core.model.ITag) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TypedEvent(org.eclipse.swt.events.TypedEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(java.beans.PropertyChangeEvent)

Example 3 with TypedEvent

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);
}
Also used : ToolTip(org.eclipse.jface.window.ToolTip) TypedEvent(org.eclipse.swt.events.TypedEvent) Point(org.eclipse.swt.graphics.Point) ITags(org.eclipse.epp.mpc.core.model.ITags) Point(org.eclipse.swt.graphics.Point) ITag(org.eclipse.epp.mpc.core.model.ITag)

Example 4 with TypedEvent

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);
    }
}
Also used : TypedEvent(org.eclipse.swt.events.TypedEvent) DisposeListener(org.eclipse.swt.events.DisposeListener) PropertyChangeListener(java.beans.PropertyChangeListener) Listener(org.eclipse.swt.widgets.Listener) StyledText(org.eclipse.swt.custom.StyledText) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TypedEvent(org.eclipse.swt.events.TypedEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(java.beans.PropertyChangeEvent)

Example 5 with TypedEvent

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

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