Search in sources :

Example 6 with IHyperlinkListener

use of org.eclipse.ui.forms.events.IHyperlinkListener in project tmdm-studio-se by Talend.

the class StoredProcedureMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // $NON-NLS-1$
        descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
        descriptionText.addModifyListener(this);
        // Procedure
        Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
        storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
        storedProcedureGroup.setLayout(new GridLayout(1, true));
        storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
        procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
        procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        procedureViewer.addTextListener(this);
        WidgetUtils.initRedoUndo(procedureViewer);
        refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
        refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        refreshCacheBtn.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                markDirty();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                markDirty();
            }
        });
        /**
         **********************************************************
         * Execute Stored Procedure
         ***********************************************************
         */
        createCompDropTarget();
        Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
        resultsGroup.setLayout(new GridLayout(4, false));
        // data cluster
        Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
        dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {

            public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                if (!isLocalInput()) {
                    TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
                    TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
                    (new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
                }
            }
        });
        dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
        Button executeButton = new Button(resultsGroup, SWT.PUSH);
        executeButton.setText(Messages.StoredProcedureMainPage_9);
        executeButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                executeProcedure();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
        "                                                                                                           ", SWT.NULL);
        resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
            }
        });
        hookContextMenu();
        refreshData();
        dataClusterCombo.select(0);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditXObjectAction(com.amalto.workbench.actions.EditXObjectAction) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 7 with IHyperlinkListener

use of org.eclipse.ui.forms.events.IHyperlinkListener 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 8 with IHyperlinkListener

use of org.eclipse.ui.forms.events.IHyperlinkListener in project jbosstools-hibernate by jbosstools.

the class RevEngOverviewPage method createClient.

private FormText createClient(Composite section, String content, FormToolkit toolkit) {
    FormText text = toolkit.createFormText(section, true);
    try {
        text.setText(content, true, false);
    } catch (SWTException e) {
        text.setText(e.getMessage(), false, false);
    }
    section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    text.addHyperlinkListener(new IHyperlinkListener() {

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            String href = (String) e.getHref();
            getEditor().setActivePage(href);
        }
    });
    return text;
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) SWTException(org.eclipse.swt.SWTException) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) FormText(org.eclipse.ui.forms.widgets.FormText) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener)

Aggregations

IHyperlinkListener (org.eclipse.ui.forms.events.IHyperlinkListener)8 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)7 Composite (org.eclipse.swt.widgets.Composite)4 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)3 ArrayList (java.util.ArrayList)2 AbstractNotification (org.eclipse.mylyn.commons.notifications.core.AbstractNotification)2 NotificationPopup (org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Shell (org.eclipse.swt.widgets.Shell)2 FormText (org.eclipse.ui.forms.widgets.FormText)2 EditXObjectAction (com.amalto.workbench.actions.EditXObjectAction)1 TreeObject (com.amalto.workbench.models.TreeObject)1 TreeParent (com.amalto.workbench.models.TreeParent)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1