Search in sources :

Example 21 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createHelpSection.

private void createHelpSection(Composite parent) {
    helpSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
    helpSection.setText("Help and Documentation");
    helpSection.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(helpSection);
    Composite composite = toolkit.createComposite(helpSection);
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
    Hyperlink link = toolkit.createHyperlink(composite, "Community Support Forums", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_SUPPORT_COMMUNITY));
        }
    });
    link = toolkit.createHyperlink(composite, "New and Noteworthy", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_NEW_AND_NOTEWORTHY));
        }
    });
    link = toolkit.createHyperlink(composite, "Issue and Bug Tracker", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_BUG_TRACKER));
        }
    });
    link = toolkit.createHyperlink(composite, "Extensions", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            try {
                IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
                FormEditor editor = (FormEditor) page.openEditor(DashboardEditorInput.INSTANCE, MultiPageDashboardEditor.EDITOR_ID);
                editor.setActivePage(DashboardExtensionsPage.ID);
            } catch (PartInitException ex) {
                StatusHandler.log(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "Could not open dashboard", ex));
            }
        }
    });
    link = toolkit.createHyperlink(composite, "SpringSource Commercial Support", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_SUPPORT_COMMERCIAL));
        }
    });
    link = toolkit.createHyperlink(composite, "Product Page", SWT_UNDERLINE_LINK);
    GridDataFactory.fillDefaults().applyTo(link);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_PRODUCT_PAGE));
        }
    });
    helpSection.setClient(composite);
    setUpExpandableSection(helpSection, IIdeUiConstants.PREF_HELP_SECTION_COLLAPSE, true);
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) FormEditor(org.eclipse.ui.forms.editor.FormEditor) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 22 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project webtools.sourceediting by eclipse.

the class XSDGraphViewerDialog method createInfoTextArea.

protected Control createInfoTextArea(Composite parent) {
    Composite infoComposite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    infoComposite.setLayout(gridLayout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    infoComposite.setLayoutData(gd);
    nsInfoLabel = new Label(infoComposite, SWT.LEFT);
    nsInfoLabel.setText(infoText);
    Font font = nsInfoLabel.getFont();
    FontData[] fontDatas = font.getFontData();
    for (int i = 0; i < fontDatas.length; i++) {
        fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
    }
    infoFont = new Font(nsInfoLabel.getDisplay(), fontDatas);
    nsInfoLabel.setFont(infoFont);
    gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
    nsInfoLabel.setLayoutData(gd);
    nsInfoLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
    link = new Hyperlink(infoComposite, SWT.RIGHT);
    // Remove mnemonic ampersand. It would be better to have a separate string in the future.
    String label = Messages._UI_ACTION_OPEN_IN_NEW_EDITOR.replaceAll("&", "");
    link.setText(label);
    link.setFont(infoFont);
    link.addHyperlinkListener(linkListener);
    return infoComposite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) Point(org.eclipse.swt.graphics.Point) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 23 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project liferay-ide by liferay.

the class ImportGlobalSettingsNotificationSink method showPopup.

@Override
public void showPopup() {
    if (popup != null) {
        popup.close();
    }
    Shell shell = new Shell(PlatformUI.getWorkbench().getDisplay());
    popup = new NotificationPopup(shell) {

        @Override
        protected void createContentArea(Composite parent) {
            super.createContentArea(parent);
            hookHyperlink(parent);
        }

        @Override
        protected String getPopupShellTitle() {
            return "Liferay IDE Notification";
        }

        private void hookHyperlink(Composite parent) {
            Hyperlink hyperlink = null;
            for (Control child : parent.getChildren()) {
                if (child instanceof Hyperlink) {
                    hyperlink = (Hyperlink) child;
                    hyperlink.addHyperlinkListener(new IHyperlinkListener() {

                        public void linkExited(HyperlinkEvent e) {
                        }

                        public void linkEntered(HyperlinkEvent e) {
                        }

                        public void linkActivated(HyperlinkEvent e) {
                            if (popup != null) {
                                popup.closeFade();
                            }
                        }
                    });
                    return;
                } else if (child instanceof Composite) {
                    hookHyperlink((Composite) child);
                }
            }
        }
    };
    popup.setFadingEnabled(isAnimationsEnabled());
    List<AbstractNotification> toDisplay = new ArrayList<AbstractNotification>(getNotifications());
    Collections.sort(toDisplay);
    popup.setContents(toDisplay);
    getNotifications().clear();
    popup.setBlockOnOpen(false);
    popup.setDelayClose(60 * 1000);
    popup.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) NotificationPopup(org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup) AbstractNotification(org.eclipse.mylyn.commons.notifications.core.AbstractNotification) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 24 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project egit by eclipse.

the class RepositoriesView method createEmptyArea.

/**
 * Create area shown when no repositories are present
 *
 * @param parent
 */
protected void createEmptyArea(Composite parent) {
    emptyArea = new Composite(parent, SWT.NONE);
    emptyArea.setBackgroundMode(SWT.INHERIT_FORCE);
    MenuManager manager = new MenuManager();
    manager.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager m) {
            getNavigatorActionService().fillContextMenu(m);
        }
    });
    getSite().registerContextMenu(manager, getCommonViewer());
    Menu menu = manager.createContextMenu(emptyArea);
    emptyArea.setMenu(menu);
    GridLayoutFactory.fillDefaults().applyTo(emptyArea);
    Composite infoArea = new Composite(emptyArea, SWT.NONE);
    infoArea.setMenu(menu);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, true).applyTo(infoArea);
    GridLayoutFactory.swtDefaults().applyTo(infoArea);
    Label messageLabel = new Label(infoArea, SWT.WRAP);
    messageLabel.setText(UIText.RepositoriesView_messsageEmpty);
    messageLabel.setMenu(menu);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(messageLabel);
    Composite optionsArea = new Composite(infoArea, SWT.NONE);
    optionsArea.setMenu(menu);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(optionsArea);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, true).applyTo(optionsArea);
    final FormToolkit toolkit = new FormToolkit(emptyArea.getDisplay());
    emptyArea.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            toolkit.dispose();
        }
    });
    final Color linkColor = JFaceColors.getHyperlinkText(emptyArea.getDisplay());
    Label addLabel = new Label(optionsArea, SWT.NONE);
    Image addImage = UIIcons.NEW_REPOSITORY.createImage();
    UIUtils.hookDisposal(addLabel, addImage);
    addLabel.setImage(addImage);
    Hyperlink addLink = toolkit.createHyperlink(optionsArea, UIText.RepositoriesView_linkAdd, SWT.WRAP);
    addLink.setForeground(linkColor);
    addLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            IHandlerService service = CommonUtils.getService(getViewSite(), IHandlerService.class);
            UIUtils.executeCommand(service, // $NON-NLS-1$
            "org.eclipse.egit.ui.RepositoriesViewAddRepository");
        }
    });
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(addLink);
    Label cloneLabel = new Label(optionsArea, SWT.NONE);
    Image cloneImage = UIIcons.CLONEGIT.createImage();
    UIUtils.hookDisposal(cloneLabel, cloneImage);
    cloneLabel.setImage(cloneImage);
    Hyperlink cloneLink = toolkit.createHyperlink(optionsArea, UIText.RepositoriesView_linkClone, SWT.WRAP);
    cloneLink.setForeground(linkColor);
    cloneLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            IHandlerService service = CommonUtils.getService(getViewSite(), IHandlerService.class);
            UIUtils.executeCommand(service, // $NON-NLS-1$
            "org.eclipse.egit.ui.RepositoriesViewClone");
        }
    });
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(cloneLink);
    Label createLabel = new Label(optionsArea, SWT.NONE);
    Image createImage = UIIcons.CREATE_REPOSITORY.createImage();
    UIUtils.hookDisposal(createLabel, createImage);
    createLabel.setImage(createImage);
    Hyperlink createLink = toolkit.createHyperlink(optionsArea, UIText.RepositoriesView_linkCreate, SWT.WRAP);
    createLink.setForeground(linkColor);
    createLink.setText(UIText.RepositoriesView_linkCreate);
    createLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            IHandlerService service = CommonUtils.getService(getViewSite(), IHandlerService.class);
            UIUtils.executeCommand(service, // $NON-NLS-1$
            "org.eclipse.egit.ui.RepositoriesViewCreateRepository");
        }
    });
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(createLink);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Image(org.eclipse.swt.graphics.Image) IMenuListener(org.eclipse.jface.action.IMenuListener) IHandlerService(org.eclipse.ui.handlers.IHandlerService) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 25 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink 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)

Aggregations

Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)28 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)18 Composite (org.eclipse.swt.widgets.Composite)17 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)16 GridLayout (org.eclipse.swt.layout.GridLayout)12 GridData (org.eclipse.swt.layout.GridData)11 Label (org.eclipse.swt.widgets.Label)8 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)7 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 ArrayList (java.util.ArrayList)4 EntityNameCombo (org.eclipse.jpt.jpa.ui.internal.details.EntityNameCombo)4 IdClassChooser (org.eclipse.jpt.jpa.ui.internal.details.IdClassChooser)4 HibernateTableComposite (org.jboss.tools.hibernate.jpt.ui.internal.details.HibernateTableComposite)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 AccessTypeComboViewer (org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComboViewer)3 PartInitException (org.eclipse.ui.PartInitException)3 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)3