Package org.rssowl.ui.internal.util

Examples of org.rssowl.ui.internal.util.CBrowser


      }
    });
  }

  private void createBrowser(Composite parent) {
    fBrowser = new CBrowser(parent, SWT.NONE);
    if (fInput.getUrl() != null)
      fBrowser.setUrl(fInput.getUrl());
    if (StringUtils.isSet(fInput.getUrl()) && !URIUtils.ABOUT_BLANK.equals(fInput.getUrl()))
      setBusy(true);
    fBrowser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
View Full Code Here


  /*
   * Executes JavaScript in the Browser to navigate between News.
   */
  void navigate(boolean next, boolean unread) {
    CBrowser browser = fViewer.getBrowser();
    if (browser.shouldDisableScript())
      browser.setScriptDisabled(false);

    /* Create JavaScript to Execute */
    StringBuffer js = new StringBuffer();
    if (browser.isIE())
      js.append("var scrollPosY = document.body.scrollTop; "); //$NON-NLS-1$
    else
      js.append("var scrollPosY = window.pageYOffset; "); //$NON-NLS-1$
    js.append("var body = document.getElementById(\"owlbody\"); "); //$NON-NLS-1$
    js.append("var divs = body.childNodes; "); //$NON-NLS-1$

    /* Next News */
    if (next) {
      js.append("  for (var i = 1; i < divs.length; i++) { "); //$NON-NLS-1$
      js.append("    if (divs[i].nodeType != 1) { "); //$NON-NLS-1$
      js.append("      continue; "); //$NON-NLS-1$
      js.append("    } "); //$NON-NLS-1$
      js.append("    var divPosY = divs[i].offsetTop; "); //$NON-NLS-1$
      if (unread) {
        js.append("  if (divPosY > scrollPosY && divs[i].className == \"newsitemUnread\") { "); //$NON-NLS-1$
      } else
        js.append("  if (divPosY > scrollPosY) { "); //$NON-NLS-1$
      js.append("      divs[i].scrollIntoView(); "); //$NON-NLS-1$
      js.append("      break; "); //$NON-NLS-1$
      js.append("    } "); //$NON-NLS-1$
      js.append("  } "); //$NON-NLS-1$
    }

    /* Previous News */
    else {
      js.append("  for (var i = divs.length - 1; i >= 0; i--) { "); //$NON-NLS-1$
      js.append("    if (divs[i].nodeType != 1) { "); //$NON-NLS-1$
      js.append("      continue; "); //$NON-NLS-1$
      js.append("    } "); //$NON-NLS-1$
      js.append("    var divPosY = divs[i].offsetTop; "); //$NON-NLS-1$
      if (unread) {
        js.append("  if (divPosY < scrollPosY - 10 && divs[i].className == \"newsitemUnread\") { "); //$NON-NLS-1$
      } else
        js.append("  if (divPosY < scrollPosY - 10) { "); //$NON-NLS-1$
      js.append("      divs[i].scrollIntoView(); "); //$NON-NLS-1$
      js.append("      break; "); //$NON-NLS-1$
      js.append("    } "); //$NON-NLS-1$
      js.append("  } "); //$NON-NLS-1$
    }

    /* See if the Scroll Position Changed at all and handle */
    String actionId;
    if (next) {
      if (unread)
        actionId = NewsBrowserViewer.NEXT_UNREAD_NEWS_HANDLER_ID;
      else
        actionId = NewsBrowserViewer.NEXT_NEWS_HANDLER_ID;
    } else {
      if (unread)
        actionId = NewsBrowserViewer.PREVIOUS_UNREAD_NEWS_HANDLER_ID;
      else
        actionId = NewsBrowserViewer.PREVIOUS_NEWS_HANDLER_ID;
    }

    if (browser.isIE())
      js.append("var newScrollPosY = document.body.scrollTop; "); //$NON-NLS-1$
    else
      js.append("var newScrollPosY = window.pageYOffset; "); //$NON-NLS-1$

    js.append("if (scrollPosY == newScrollPosY) { "); //$NON-NLS-1$
    js.append("  window.location.href = \"").append(ILinkHandler.HANDLER_PROTOCOL + actionId).append("\"; "); //$NON-NLS-1$ //$NON-NLS-2$
    js.append("} "); //$NON-NLS-1$

    try {
      browser.getControl().execute(js.toString());
    } finally {
      if (browser.shouldDisableScript())
        browser.setScriptDisabled(true);
    }
  }
View Full Code Here

   * @param parent
   * @param style
   * @param site
   */
  public NewsBrowserViewer(Composite parent, int style, IWorkbenchPartSite site) {
    fBrowser = new CBrowser(parent, style);
    fSite = site;
    fIsEmbedded = (fSite != null);
    hookControl(fBrowser.getControl());
    hookNewsContextMenu();
    hookAttachmentsContextMenu();
View Full Code Here

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    /* Browser to preview News */
    fBrowser = new CBrowser(composite, SWT.NONE);
    fBrowser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fBrowser.setScriptDisabled(true);
    fBrowser.getControl().addKeyListener(new KeyAdapter() {
      @Override
      public void keyPressed(KeyEvent e) {
View Full Code Here

   * @return <code>true</code> if the news browser viewer of this feed view is
   * showing the contents of a website and <code>false</code> otherwise.
   */
  public boolean isBrowserShowingNews() {
    if (fNewsBrowserControl != null && fNewsBrowserControl.getViewer() != null) {
      CBrowser browser = fNewsBrowserControl.getViewer().getBrowser();
      if (browser != null && browser.getControl() != null && !browser.getControl().isDisposed()) {
        String url = browser.getControl().getUrl();
        return StringUtils.isSet(url) && ApplicationServer.getDefault().isNewsServerUrl(url);
      }
    }

    return false;
View Full Code Here

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    /* Browser to preview News */
    fBrowser = new CBrowser(composite, SWT.NONE);
    fBrowser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fBrowser.setScriptDisabled(true);
    fBrowser.getControl().addKeyListener(new KeyAdapter() {
      @Override
      public void keyPressed(KeyEvent e) {
View Full Code Here

   * showing the contents of a website and <code>false</code> otherwise.
   */
  public boolean isBrowserShowingNews() {
    if (fNewsBrowserControl != null && fNewsBrowserControl.getViewer() != null) {
      if (isBrowserViewerVisible()) {
        CBrowser browser = fNewsBrowserControl.getViewer().getBrowser();
        if (browser != null && browser.getControl() != null && !browser.getControl().isDisposed()) {
          String url = browser.getControl().getUrl();
          return StringUtils.isSet(url) && ApplicationServer.getDefault().isNewsServerUrl(url);
        }
      }
    }

View Full Code Here

   * @param style the style of the {@link Browser} in this viewer.
   * @param site the {@link IFeedViewSite} if this viewer is being used from a
   * {@link FeedView} or <code>null</code> otherwise.
   */
  public NewsBrowserViewer(Composite parent, int style, IFeedViewSite site) {
    fBrowser = new CBrowser(parent, style);
    fBrowser.setCanOpenLinksInTabs(true);
    fViewModel = new NewsBrowserViewModel(this);
    fSite = site;
    fIsEmbedded = (fSite != null);
    hookControl(fBrowser.getControl());
View Full Code Here

      }
    });
  }

  private void createBrowser(Composite parent) {
    fBrowser = new CBrowser(parent, SWT.NONE);
    if (fInput.getUrl() != null)
      fBrowser.setUrl(fInput.getUrl());
    if (StringUtils.isSet(fInput.getUrl()) && !URIUtils.ABOUT_BLANK.equals(fInput.getUrl()))
      setBusy(true);
    fBrowser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.util.CBrowser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.