Search in sources :

Example 11 with HyperlinkEvent

use of org.eclipse.ui.forms.events.HyperlinkEvent in project tdi-studio-se by Talend.

the class NotificationsTab method createMessagePage.

/**
     * Creates the message page.
     */
private void createMessagePage() {
    messagePage = new Composite(this, SWT.NONE);
    messagePage.setLayout(new GridLayout(3, false));
    FormToolkit toolkit = new FormToolkit(Display.getDefault());
    toolkit.createLabel(messagePage, Messages.notificationsNotSubscribedMsg);
    Hyperlink hyperlink = toolkit.createHyperlink(messagePage, Messages.subscribeLinkLabel, SWT.NONE);
    toolkit.createLabel(messagePage, Messages.notificationsLabel);
    hyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            subscribeAction.run();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 12 with HyperlinkEvent

use of org.eclipse.ui.forms.events.HyperlinkEvent in project bndtools by bndtools.

the class MessagesPopupDialog method createDialogArea.

@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));
    for (int i = 0; i < messages.length; i++) {
        if (i > 0) {
            Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            separator.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
        }
        // Message Type Image Label
        Composite pnlTitle = new Composite(composite, SWT.NONE);
        pnlTitle.setLayout(new GridLayout(2, false));
        Label lblImage = new Label(pnlTitle, SWT.NONE);
        lblImage.setImage(getMessageImage(messages[i].getMessageType()));
        // Message Label
        StringBuilder builder = new StringBuilder();
        if (messages[i].getPrefix() != null) {
            builder.append(messages[i].getPrefix());
        }
        builder.append(messages[i].getMessage());
        Label lblText = new Label(pnlTitle, SWT.WRAP);
        lblText.setText(builder.toString());
        lblText.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT));
        lblText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        // Fix actions, if present
        Object data = messages[i].getData();
        IAction[] fixes;
        if (data instanceof IAction) {
            fixes = new IAction[] { (IAction) data };
        } else if (data instanceof IAction[]) {
            fixes = (IAction[]) data;
        } else {
            fixes = null;
        }
        if (fixes != null) {
            // new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            Composite pnlFixes = new Composite(composite, SWT.NONE);
            pnlFixes.setLayout(new GridLayout(3, false));
            Label lblFixes = new Label(pnlFixes, SWT.NONE);
            lblFixes.setText("Available Fixes:");
            lblFixes.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
            for (int j = 0; j < fixes.length; j++) {
                if (j > 0)
                    // Spacer
                    new Label(pnlFixes, SWT.NONE);
                new Label(pnlFixes, SWT.NONE).setImage(bulletImg);
                final IAction fix = fixes[j];
                Hyperlink fixLink = new Hyperlink(pnlFixes, SWT.NONE);
                hyperlinkGroup.add(fixLink);
                fixLink.setText(fix.getText());
                fixLink.setHref(fix);
                fixLink.addHyperlinkListener(new HyperlinkAdapter() {

                    @Override
                    public void linkActivated(HyperlinkEvent e) {
                        fix.run();
                        close();
                        // part.getSite().getPage().activate(part);
                        part.setFocus();
                    }
                });
                fixLink.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
            }
        }
    }
    return composite;
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) IAction(org.eclipse.jface.action.IAction) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 13 with HyperlinkEvent

use of org.eclipse.ui.forms.events.HyperlinkEvent in project bndtools by bndtools.

the class TemplateSelectionWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    //$NON-NLS-1$
    setImageDescriptor(Plugin.imageDescriptorFromPlugin("icons/bndtools-wizban.png"));
    GridData gd;
    Composite composite = new Composite(parent, SWT.NULL);
    setControl(composite);
    composite.setLayout(new GridLayout(1, false));
    Control headerControl = createHeaderControl(composite);
    if (headerControl != null)
        headerControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    new Label(composite, SWT.NONE).setText("Select Template:");
    tree = new Tree(composite, SWT.BORDER | SWT.FULL_SELECTION);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 150;
    tree.setLayoutData(gd);
    defaultTemplateImage = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/template.gif").createImage(parent.getDisplay());
    viewer = new TreeViewer(tree);
    contentProvider = new RepoTemplateContentProvider(false);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new RepoTemplateLabelProvider(loadedImages, defaultTemplateImage));
    viewer.addFilter(latestFilter);
    setTemplates(emptyTemplate != null ? Collections.singletonList(emptyTemplate) : Collections.<Template>emptyList());
    btnLatestOnly = new Button(composite, SWT.CHECK);
    btnLatestOnly.setText("Show latest versions only");
    btnLatestOnly.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    btnLatestOnly.setSelection(true);
    new Label(composite, SWT.NONE).setText("Description:");
    Composite cmpDescription = new Composite(composite, SWT.BORDER);
    cmpDescription.setBackground(tree.getBackground());
    txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false);
    FormText formText = new FormText(txtDescription, SWT.NO_FOCUS);
    txtDescription.setFormText(formText);
    txtDescription.setBackground(tree.getBackground());
    formText.setBackground(tree.getBackground());
    formText.setForeground(tree.getForeground());
    formText.setFont("fixed", JFaceResources.getTextFont());
    formText.setFont("italic", JFaceResources.getFontRegistry().getItalic(""));
    GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd_cmpDescription.heightHint = 25;
    cmpDescription.setLayoutData(gd_cmpDescription);
    GridLayout layout_cmpDescription = new GridLayout(1, false);
    cmpDescription.setLayout(layout_cmpDescription);
    GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_txtDescription.heightHint = 25;
    txtDescription.setLayoutData(gd_txtDescription);
    Hyperlink linkRetina = new Hyperlink(composite, SWT.NONE);
    linkRetina.setText("Why is this text blurred?");
    linkRetina.setUnderlined(true);
    linkRetina.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay()));
    linkRetina.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
            IWizardPage nextPage = getNextPage();
            if (nextPage != null && selected != null)
                getContainer().showPage(nextPage);
        }
    });
    btnLatestOnly.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean latestOnly = btnLatestOnly.getSelection();
            if (latestOnly)
                viewer.addFilter(latestFilter);
            else
                viewer.removeFilter(latestFilter);
        }
    });
    linkRetina.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent ev) {
            try {
                IWorkbenchBrowserSupport browser = PlatformUI.getWorkbench().getBrowserSupport();
                browser.getExternalBrowser().openURL(new URL("https://github.com/bndtools/bndtools/wiki/Blurry-Form-Text-on-High-Resolution-Displays"));
            } catch (Exception e) {
                log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", e));
            }
        }
    });
    txtDescription.getFormText().addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent ev) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL((String) ev.getHref()));
            } catch (Exception ex) {
                log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", ex));
            }
        }
    });
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ScrolledFormText(org.eclipse.ui.forms.widgets.ScrolledFormText) URL(java.net.URL) Template(org.bndtools.templating.Template) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Composite(org.eclipse.swt.widgets.Composite) FormText(org.eclipse.ui.forms.widgets.FormText) ScrolledFormText(org.eclipse.ui.forms.widgets.ScrolledFormText) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) IWizardPage(org.eclipse.jface.wizard.IWizardPage) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) OpenEvent(org.eclipse.jface.viewers.OpenEvent) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 14 with HyperlinkEvent

use of org.eclipse.ui.forms.events.HyperlinkEvent in project bndtools by bndtools.

the class AbstractTemplateSelectionWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(1, false));
    new Label(container, SWT.NONE).setText("Select Template:");
    tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_table.heightHint = 100;
    tree.setLayoutData(gd_table);
    viewer = new TreeViewer(tree);
    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setText("Description:");
    Composite cmpDescription = new Composite(container, SWT.BORDER);
    cmpDescription.setBackground(tree.getBackground());
    txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false);
    FormText formText = new FormText(txtDescription, SWT.NO_FOCUS);
    txtDescription.setFormText(formText);
    txtDescription.setBackground(tree.getBackground());
    formText.setBackground(tree.getBackground());
    formText.setForeground(tree.getForeground());
    formText.setFont("fixed", JFaceResources.getTextFont());
    formText.setFont("italic", JFaceResources.getFontRegistry().getItalic(""));
    GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd_cmpDescription.heightHint = 100;
    cmpDescription.setLayoutData(gd_cmpDescription);
    GridLayout layout_cmpDescription = new GridLayout(1, false);
    cmpDescription.setLayout(layout_cmpDescription);
    GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_txtDescription.heightHint = 100;
    txtDescription.setLayoutData(gd_txtDescription);
    viewer.setContentProvider(new CategorisedPrioritisedConfigurationElementTreeContentProvider(true));
    viewer.setLabelProvider(new ConfigElementLabelProvider(parent.getDisplay(), "icons/template.gif"));
    loadData();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object selected = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (selected instanceof IConfigurationElement)
                setSelectionFromConfigElement((IConfigurationElement) selected);
            else
                setSelectionFromConfigElement(null);
            updateUI();
        }
    });
    txtDescription.getFormText().addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent event) {
            IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
            try {
                IWebBrowser externalBrowser = browserSupport.getExternalBrowser();
                externalBrowser.openURL(new URL((String) event.getHref()));
            } catch (PartInitException e) {
                logger.logError("Error opening external browser.", e);
            } catch (MalformedURLException e) {
            // Ignore
            }
        }
    });
    updateUI();
}
Also used : MalformedURLException(java.net.MalformedURLException) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CategorisedPrioritisedConfigurationElementTreeContentProvider(org.bndtools.utils.eclipse.CategorisedPrioritisedConfigurationElementTreeContentProvider) ScrolledFormText(org.eclipse.ui.forms.widgets.ScrolledFormText) FormText(org.eclipse.ui.forms.widgets.FormText) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) ScrolledFormText(org.eclipse.ui.forms.widgets.ScrolledFormText) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ConfigElementLabelProvider(org.bndtools.core.ui.ConfigElementLabelProvider) Tree(org.eclipse.swt.widgets.Tree) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) PartInitException(org.eclipse.ui.PartInitException) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)14 Composite (org.eclipse.swt.widgets.Composite)13 GridLayout (org.eclipse.swt.layout.GridLayout)12 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)12 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)8 GridData (org.eclipse.swt.layout.GridData)7 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)6 Label (org.eclipse.swt.widgets.Label)5 URL (java.net.URL)4 PartInitException (org.eclipse.ui.PartInitException)4 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)3 FormText (org.eclipse.ui.forms.widgets.FormText)3 JpmPreferences (bndtools.preferences.JpmPreferences)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 IResource (org.eclipse.core.resources.IResource)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2