Search in sources :

Example 6 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.

the class CubridNewInfoEditorPart method createPartControl.

/**
	 * Create the editor content
	 *
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    String url = Platform.getNL().equals("ko_KR") ? CHECK_NEW_INFO_URL_KO : CHECK_NEW_INFO_URL_EN;
    try {
        Browser browser = new Browser(parent, SWT.NONE);
        browser.setUrl(url);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        Label label = new Label(parent, SWT.NONE);
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        try {
            IWebBrowser browser = support.getExternalBrowser();
            browser.openURL(new URL(CommonUITool.urlEncodeForSpaces(url.toCharArray())));
        } catch (Exception browserEx) {
            LOGGER.warn(browserEx.getMessage(), browserEx);
            label.setText(Messages.errCannotOpenExternalBrowser);
            return;
        }
        label.setText(Messages.errCannotOpenInternalBrowser);
    }
}
Also used : Label(org.eclipse.swt.widgets.Label) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL) Browser(org.eclipse.swt.browser.Browser) IWebBrowser(org.eclipse.ui.browser.IWebBrowser)

Example 7 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.

the class JdbcOptionComposite method createButtonComp.

/**
	 *
	 * Create button composite
	 *
	 * @param composite the composite
	 */
private void createButtonComp(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.NONE);
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        buttonComposite.setLayout(layout);
        buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    }
    Hyperlink link = new Hyperlink(buttonComposite, SWT.None);
    link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    link.setText(Messages.titleJdbcAdvancedOptionView);
    link.addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent e) {
            IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
            try {
                IWebBrowser br = browserSupport.createBrowser(null);
                br.openURL(new URL(Messages.msgCubridJdbcInfoUrl));
            } catch (Exception ignored) {
            }
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent e) {
        }
    });
    addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    addButton.setText(Messages.btnAdd);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem itemNew = new TableItem(jdbcInfoTv.getTable(), SWT.SINGLE);
            int newIndex = jdbcInfoTv.getTable().getItemCount() - 1;
            focusCell(itemNew, newIndex, 0);
        }
    });
    Button delButton = new Button(buttonComposite, SWT.PUSH);
    delButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    delButton.setText(Messages.btnDelete);
    delButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem[] selection = jdbcInfoTv.getTable().getSelection();
            if (selection == null || selection.length == 0) {
                return;
            }
            jdbcInfoTv.getTable().setSelection(-1);
            for (TableItem item : selection) {
                item.dispose();
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) Hyperlink(com.novocode.naf.swt.custom.Hyperlink)

Example 8 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.

the class NoticeDashboardPage method createFormText.

private FormText createFormText(Composite composite) {
    FormText text = toolkit.createFormText(composite, true);
    text.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            String href = (String) e.getHref();
            String url = CommonUITool.urlEncodeForSpaces(href);
            try {
                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                IWebBrowser browser = support.getExternalBrowser();
                browser.openURL(new URL(url));
            } catch (PartInitException e1) {
                LOGGER.error("Can not initialize web browser on the application.", e1);
            } catch (MalformedURLException e2) {
                LOGGER.error("The url {} is invalid.", url, e2);
            }
        }
    });
    return text;
}
Also used : MalformedURLException(java.net.MalformedURLException) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) FormText(org.eclipse.ui.forms.widgets.FormText) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 9 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.

the class GeneralInfoPage method createChartsetGroup.

/**
	 * Create chartset information group
	 *
	 * @param parent the parent composite
	 */
private void createChartsetGroup(Composite parent) {
    Group charsetGroup = new Group(parent, SWT.NONE);
    charsetGroup.setText(Messages.grpCharsetInfo);
    GridData gdCharsetGroup = new GridData(GridData.FILL_HORIZONTAL);
    charsetGroup.setLayoutData(gdCharsetGroup);
    GridLayout layoutCharsetGroup = new GridLayout();
    layoutCharsetGroup.numColumns = 3;
    charsetGroup.setLayout(layoutCharsetGroup);
    enIsoRadio = new Button(charsetGroup, SWT.RADIO);
    final GridData gdEnIsoRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
    enIsoRadio.setLayoutData(gdEnIsoRadio);
    enIsoRadio.setText(CHARSET_EN_US_ISO88591);
    enIsoRadio.setSelection(true);
    enUtfRadio = new Button(charsetGroup, SWT.RADIO);
    final GridData gdEnUtfRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
    enUtfRadio.setLayoutData(gdEnUtfRadio);
    enUtfRadio.setText(CHARSET_EN_US_UTF8);
    koEuckrRadio = new Button(charsetGroup, SWT.RADIO);
    final GridData gdKoEuckrRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
    koEuckrRadio.setLayoutData(gdKoEuckrRadio);
    koEuckrRadio.setText(CHARSET_KO_KR_EUCKR);
    koUtfRadio = new Button(charsetGroup, SWT.RADIO);
    final GridData gdKoUtfRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
    koUtfRadio.setLayoutData(gdKoUtfRadio);
    koUtfRadio.setText(CHARSET_KO_KR_UTF8);
    userDefinedRadio = new Button(charsetGroup, SWT.RADIO);
    final GridData gdUserDefinedRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
    koUtfRadio.setLayoutData(gdUserDefinedRadio);
    userDefinedRadio.setText(Messages.lblUserDefinedCharset);
    userDefinedRadio.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            Button btn = (Button) e.widget;
            userDefinedCharsetText.setEnabled(btn.getSelection());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    userDefinedCharsetText = new Text(charsetGroup, SWT.BORDER);
    final GridData gdDetailCombo = new GridData(SWT.FILL, SWT.CENTER, true, false);
    userDefinedCharsetText.setLayoutData(gdDetailCombo);
    userDefinedCharsetText.setEnabled(false);
    userDefinedCharsetText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            //TODO whether need check the input style?
            valid();
        }
    });
    Hyperlink link = new Hyperlink(charsetGroup, SWT.None);
    GridData gdLink = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gdLink.horizontalSpan = 3;
    link.setLayoutData(gdLink);
    link.setText(Messages.msgLocaleManual);
    link.addMouseListener(new MouseAdapter() {

        public void mouseUp(MouseEvent e) {
            IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
            try {
                IWebBrowser br = browserSupport.createBrowser(null);
                String url = Messages.msgLocaleManualUrl91;
                if (CompatibleUtil.isAfter930(server.getServerInfo())) {
                    url = Messages.msgLocaleManualUrl93;
                } else if (CompatibleUtil.isAfter920(server.getServerInfo())) {
                    url = Messages.msgLocaleManualUrl92;
                }
                br.openURL(new URL(url));
            } catch (Exception ignored) {
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) MouseEvent(org.eclipse.swt.events.MouseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(com.novocode.naf.swt.custom.Hyperlink)

Example 10 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project sling by apache.

the class AbstractOpenInBrowserHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection sel = HandlerUtil.getCurrentSelection(event);
    JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
    if (node == null) {
        return null;
    }
    Shell shell = HandlerUtil.getActiveShell(event);
    IModule module = ServerUtil.getModule(node.getProject());
    if (module == null) {
        MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
        return null;
    }
    IServer[] servers = ServerUtil.getServersByModule(module, new NullProgressMonitor());
    if (servers == null || servers.length == 0) {
        MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
        return null;
    }
    IServer server = servers[0];
    URL url;
    try {
        url = getUrlToOpen(node, server);
    } catch (MalformedURLException e) {
        StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Url is invalid", e), StatusManager.SHOW);
        return null;
    }
    try {
        IWorkbenchBrowserSupport browserSupport = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench().getBrowserSupport();
        browserSupport.createBrowser("org.apache.sling.ide.openOnServer").openURL(url);
    } catch (PartInitException e) {
        StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Failed creating browser instance", e), StatusManager.SHOW | StatusManager.LOG);
    }
    return null;
}
Also used : Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Shell(org.eclipse.swt.widgets.Shell) IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) MalformedURLException(java.net.MalformedURLException) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Aggregations

IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)13 URL (java.net.URL)12 IWebBrowser (org.eclipse.ui.browser.IWebBrowser)11 PartInitException (org.eclipse.ui.PartInitException)9 MalformedURLException (java.net.MalformedURLException)7 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)3 FormText (org.eclipse.ui.forms.widgets.FormText)3 Hyperlink (com.novocode.naf.swt.custom.Hyperlink)2 Status (org.eclipse.core.runtime.Status)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 Browser (org.eclipse.swt.browser.Browser)2