public static void disableInputs(Browser browser) {
   if (browser != null && !browser.isDisposed()) {
     String disableInputs =
         "function() {"
             + //$NON-NLS-1$
             "var inputs = document.getElementsByTagName('INPUT');"
             + //$NON-NLS-1$
             "for (var i = 0; i < inputs.length; i++) {"
             + //$NON-NLS-1$
             "inputs[i].blur();"
             + //$NON-NLS-1$ Disabling autofocus
             "inputs[i].disabled = true;"
             + //$NON-NLS-1$
             "}"
             + //$NON-NLS-1$
             "}"; //$NON-NLS-1$
     OS platform = PlatformUtil.getOs();
     if (OS.WINDOWS.equals(platform)) {
       browser.execute("(" + disableInputs + ")();"); // $NON-NLS-1$ //$NON-NLS-2$
     } else {
       int timeout = 30;
       if (OS.LINUX.equals(platform)) {
         timeout = 150; // timeout increased for old xulrunner
       }
       browser.execute(
           "(setTimeout("
               + disableInputs
               + ", "
               + timeout
               + "))();"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
     }
   }
 }
  /** *************************************************************** */
  public boolean addBrowser() {
    Browser browser2;
    browser2 = new Navegador(this.tabFolder, SWT.BORDER);
    browser2.setBounds(0, 0, 787, 691);
    this.itemT3.setControl(browser2);

    // METEMOS EL BROWSER EN LA TAB1
    this.itemT3.setControl(browser2); // prueba18-6-09
    // browser.setVisible(false);
    browser2.setUrl("www.google.es");

    this.tabFolder.setBounds(0, 0, 766, 691);
    this.tabFolder.pack();

    //		shell.open();
    //		while (!shell.isDisposed()) {
    //			if (!display.readAndDispatch())
    //				display.sleep();
    //		}
    //		display.dispose();
    browser2.execute("alert('no entra aki')");
    browser2.execute("alert('no entra aki')");

    return true;
  }
Beispiel #3
0
 public void displayContent(String textHtml) {
   Browser browser = getBrowser();
   if (textHtml != null) {
     browser.setText(textHtml);
   } else {
     browser.setText(HtmlUtils.getDefaultBody());
   }
 }
Beispiel #4
0
 @Override
 public synchronized void update(File result) {
   if (result == null) {
     browser.setText("<html/>");
   } else {
     browser.setUrl(result.toURI().toString());
   }
 }
Beispiel #5
0
  public BrowserExample(org.eclipse.swt.widgets.Composite parent, boolean top) {
    this.parent = parent;
    try {
      browser = new org.eclipse.swt.browser.Browser(parent, SWT.BORDER);
    } catch (org.eclipse.swt.SWTError e) {
      error = e;
      parent.setLayout(new org.eclipse.swt.layout.FillLayout());
      org.eclipse.swt.widgets.Label label =
          new org.eclipse.swt.widgets.Label(parent, SWT.CENTER | SWT.WRAP);
      label.setText(getResourceString("BrowserNotCreated"));
      parent.layout(true);
      return;
    }
    initResources();
    final org.eclipse.swt.widgets.Display display = parent.getDisplay();
    browser.setData("org.eclipse.swt.examples.browserexample.BrowserApplication", this);
    browser.addOpenWindowListener(
        new org.eclipse.swt.browser.OpenWindowListener() {
          public void open(org.eclipse.swt.browser.WindowEvent event) {
            org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
            if (icon != null) {
              shell.setImage(icon);
            }
            shell.setLayout(new org.eclipse.swt.layout.FillLayout());
            org.eclipse.swt.examples.browserexample.BrowserExample app =
                new org.eclipse.swt.examples.browserexample.BrowserExample(shell, false);
            app.setShellDecoration(icon, true);
            event.browser = app.getBrowser();
          }
        });
    if (top) {
      browser.setUrl(getResourceString("Startup"));
      show(false, null, null, true, true, true, true);
    } else {
      browser.addVisibilityWindowListener(
          new org.eclipse.swt.browser.VisibilityWindowListener() {
            public void hide(org.eclipse.swt.browser.WindowEvent e) {}

            public void show(org.eclipse.swt.browser.WindowEvent e) {
              org.eclipse.swt.browser.Browser browser = (org.eclipse.swt.browser.Browser) e.widget;
              org.eclipse.swt.examples.browserexample.BrowserExample app =
                  (org.eclipse.swt.examples.browserexample.BrowserExample)
                      browser.getData("org.eclipse.swt.examples.browserexample.BrowserApplication");
              app.show(true, e.location, e.size, e.addressBar, e.menuBar, e.statusBar, e.toolBar);
            }
          });
      browser.addCloseWindowListener(
          new org.eclipse.swt.browser.CloseWindowListener() {
            public void close(org.eclipse.swt.browser.WindowEvent event) {
              org.eclipse.swt.browser.Browser browser =
                  (org.eclipse.swt.browser.Browser) event.widget;
              org.eclipse.swt.widgets.Shell shell = browser.getShell();
              shell.close();
            }
          });
    }
  }
  @Override
  protected void initializeUi(Composite parent) {
    super.initializeUi(parent);

    // create container for label and svg browser
    Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
    setUiContainer(container);

    // create label
    StatusLabelEx label =
        getUiEnvironment().getFormToolkit().createStatusLabel(container, getScoutObject());

    // create browser that shows the SVG
    Browser browser = getUiEnvironment().getFormToolkit().createBrowser(container, SWT.NO_SCROLL);
    browser.addDisposeListener(
        new DisposeListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void widgetDisposed(DisposeEvent e) {
            getBrowserExtension().detach();
          }
        });
    browser.addLocationListener(
        new LocationAdapter() {
          private static final long serialVersionUID = 1L;

          @Override
          public void changed(LocationEvent event) {
            locationChangedFromUi(event);
          }
        });
    browser.addControlListener(
        new ControlListener() {

          private static final long serialVersionUID = 1L;

          @Override
          public void controlResized(ControlEvent e) {
            updateSvgDocument();
          }

          @Override
          public void controlMoved(ControlEvent e) {
            updateSvgDocument();
          }
        });
    setBrowserExtension(new BrowserExtension(browser));
    getBrowserExtension().attach();

    setUiLabel(label);
    setUiField(browser);

    // layout
    getUiContainer().setLayout(new LogicalGridLayout(1, 0));
  }
 /**
  * Create contents of the editor part
  *
  * @param parent
  */
 @Override
 public void createPartControl(Composite parent) {
   Composite container = new Composite(parent, SWT.NONE);
   this.setPartName(editInput.getName());
   container.setLayout(new FillLayout());
   Browser browser = new Browser(container, SWT.NONE);
   browser.setUrl(editInput.getUrl());
   browser.forward();
   //
 }
  public void test_changedLorg_eclipse_swt_browser_ProgressEvent() {
    Display display = Display.getCurrent();
    Shell shell = new Shell(display);
    Browser browser = new Browser(shell, SWT.NONE);
    browser.addProgressListener(
        new ProgressListener() {
          public void changed(ProgressEvent event) {}

          public void completed(ProgressEvent event) {}
        });
    shell.close();
  }
  public static void outlineSelectedElement(Browser browser, Long currentSelectionId) {
    if (browser != null && !browser.isDisposed()) {
      String styleAttributeSelector;
      if (currentSelectionId == null) {
        styleAttributeSelector = ""; // $NON-NLS-1$
      } else {
        styleAttributeSelector =
            "'["
                + VpvDomBuilder.ATTR_VPV_ID
                + "=\""
                + currentSelectionId
                + "\"] {outline: 1px solid blue; border: 1px solid blue;  z-index: 2147483638;}'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }

      String outlineJsFunction =
          "function() {"
              + //$NON-NLS-1$
              "var style=document.getElementById('"
              + VPV_SELECTION_STYLE_ID
              + "');"
              + //$NON-NLS-1$ //$NON-NLS-2$
              "if (!style) {"
              + //$NON-NLS-1$
              "style = document.createElement('STYLE');"
              + //$NON-NLS-1$
              "style.type = 'text/css';"
              + //$NON-NLS-1$
              "}"
              + //$NON-NLS-1$
              "style.id = '"
              + VPV_SELECTION_STYLE_ID
              + "';"
              + //$NON-NLS-1$ //$NON-NLS-2$
              "style.innerHTML = "
              + styleAttributeSelector
              + ";"
              + //$NON-NLS-1$ //$NON-NLS-2$
              "var head = document.head || document.getElementsByTagName('head')[0] ;"
              + //$NON-NLS-1$
              "head.appendChild(style);"
              + //$NON-NLS-1$
              "}"; //$NON-NLS-1$

      if (OS.WINDOWS.equals(PlatformUtil.getOs())) {
        browser.execute("(" + outlineJsFunction + ")();"); // $NON-NLS-1$ //$NON-NLS-2$
      } else {
        // JBIDE-17155 Visual Preview: no selection after element changed on Mac Os and Linux
        browser.execute(
            "(setTimeout(" + outlineJsFunction + ", 10))();"); // $NON-NLS-1$//$NON-NLS-2$
      }
    }
  }
  @Test
  public void test_changedLorg_eclipse_swt_browser_LocationEvent() {
    Display display = Display.getCurrent();
    Shell shell = new Shell(display);
    Browser browser = new Browser(shell, SWT.NONE);
    browser.addLocationListener(
        new LocationListener() {
          public void changed(LocationEvent event) {}

          public void changing(LocationEvent event) {}
        });
    shell.close();
  }
 @Override
 public void createControl(Composite parent) {
   Browser browser = new Browser(parent, SWT.NONE);
   browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   browser.setText(generateHtml(parent.getFont()));
   browser.addLocationListener(
       new LocationAdapter() {
         @Override
         public void changing(LocationEvent event) {
           event.doit = false;
           Program.launch(event.location);
         }
       });
 }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, true));

    final Browser browser;
    try {
      browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      display.dispose();
      return;
    }
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    browser.setLayoutData(data);

    Button headersButton = new Button(shell, SWT.PUSH);
    headersButton.setText("Send custom headers");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    headersButton.setLayoutData(data);
    headersButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "http://www.ericgiguere.com/tools/http-header-viewer.html",
                null,
                new String[] {"User-agent: SWT Browser", "Custom-header: this is just a demo"}));
    Button postDataButton = new Button(shell, SWT.PUSH);
    postDataButton.setText("Send post data");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    postDataButton.setLayoutData(data);
    postDataButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "https://bugs.eclipse.org/bugs/buglist.cgi",
                "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring",
                null));

    shell.setBounds(10, 10, 600, 600);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Beispiel #13
0
 public ClassWebPage(Composite parent, int style) {
   super(parent, style);
   // this.setSize(600, 500);
   final GridLayout gridLayoutAll = new GridLayout(1, false);
   gridLayoutAll.marginWidth = 0;
   gridLayoutAll.marginHeight = 0;
   this.setLayout(gridLayoutAll);
   browser = new Browser(this, SWT.NONE);
   //		setBrowserListener();
   browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   new CustomFunction(browser, "callJava");
   browser.setUrl(
       new File(StudioConfig.getUIPath()).getParent()
           + "/UI/system/components/designerCommon/propEdtorPages/styleClass/index.html");
 }
  protected boolean resolvePage(String contextId, boolean endpoint) {
    String contextName = contextId;
    IContext context = HelpSystem.getContext(contextName);
    if (context == null) {
      if (endpoint) {
        contextName = "org.fusesource.ide.camel.editor.endpoint";
      } else {
        contextName = "org.fusesource.ide.camel.editor.allEIPs";
        context = HelpSystem.getContext("");
      }
      context = HelpSystem.getContext(contextName);

      // Activator.getLogger().debug("Context ID " + contextId +
      // " is bad using default.");
    }
    if (context == null) {
      Activator.getLogger().warning("Could not find context: " + contextName);
      return false;
    }
    IHelpResource[] relatedTopics = context.getRelatedTopics();
    if (relatedTopics != null && relatedTopics.length > 0) {
      IHelpResource resource = relatedTopics[0];
      if (resource != null) {
        String helpUrl = resource.getHref();
        IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
        URL url = helpSystem.resolve(helpUrl, true);
        return browser.setUrl(url.toExternalForm());
      }
    }
    Activator.getLogger().warning("Could not find resource in context: " + contextName);
    return false;
  }
  public void createPartControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));

    browser = new Browser(comp, SWT.None);

    browser.setLayoutData(new GridData(GridData.FILL_BOTH));

    if (!browser.setUrl(url)) {
      MessageDialog.openError(
          this.getSite().getShell(),
          Messages.getString("BrowserEditor.6"), // $NON-NLS-1$
          Messages.getString("BrowserEditor.7")); // $NON-NLS-1$
    }
  }
 /** orion text setfocus */
 protected void setOrionTextFocus() {
   try {
     browserEditor.evaluate(EditorFunctionService.SET_FOCUS);
   } catch (Exception e) {
     // ignore exception
   }
 }
 /*
  * @see AbstractInfoView#setInput(Object)
  */
 protected void setInput(Object input) {
   String javadocHtml = (String) input;
   if (fIsUsingBrowserWidget) {
     if (javadocHtml != null && javadocHtml.length() > 0) {
       boolean RTL = (getSite().getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
       if (RTL) {
         StringBuffer buffer = new StringBuffer(javadocHtml);
         HTMLPrinter.insertStyles(buffer, new String[] {"direction:rtl"}); // $NON-NLS-1$
         javadocHtml = buffer.toString();
       }
     }
     fBrowser.setText(javadocHtml);
   } else {
     fPresentation.clear();
     Rectangle size = fText.getClientArea();
     try {
       javadocHtml =
           ((DefaultInformationControl.IInformationPresenterExtension) fPresenter)
               .updatePresentation(
                   getSite().getShell(), javadocHtml, fPresentation, size.width, size.height);
     } catch (IllegalArgumentException ex) {
       // the javadoc might no longer be valid
       return;
     }
     fText.setText(javadocHtml);
     TextPresentation.applyTextPresentation(fPresentation, fText);
   }
 }
 private nsIWebBrowser internalGetWebBrowser() {
   Object retVal = browser.getWebBrowser();
   if (retVal instanceof nsIWebBrowser) {
     return (nsIWebBrowser) retVal;
   }
   return null;
 }
 /** @see com.aptana.ide.editors.unified.ContributedBrowser#refresh() */
 public void refresh() {
   if (browser != null && !browser.isDisposed()) {
     clearCache();
     clearErrors();
     internalRefresh();
   }
 }
 public static void browserTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("A Browser");
   tab.setToolTipText("A Web browser");
   Browser browser = null;
   try {
     browser = new Browser(folder, SWT.NONE);
   } catch (SWTError e) {
     Label label = new Label(folder, SWT.BORDER);
     label.setText("Could not initialize browser");
     tab.setControl(label);
   }
   if (browser != null) {
     browser.setUrl("http://www.mindview.net");
     tab.setControl(browser);
   }
 }
  @Override
  public void createPartControl(Composite parent) {
    try {
      browser = new Browser(parent, SWT.NONE);
      browser.setText(StartingHelper.getHelper().getHtmlContent());
      browser.addLocationListener(new BrowserDynamicPartLocationListener());
      return;
    } catch (IOException e) {
      ExceptionHandler.process(e);
    } catch (Throwable t) {

      Exception ex =
          new Exception(
              "The internal web browser can not be access,the starting page won't be displayed");
      ExceptionHandler.process(ex);
    }
  }
  /**
   * Constructor.
   *
   * @param parent the parent composite
   * @param style the composite style
   */
  public RichTextComposite(Composite parent, int style) {
    super(parent, style);

    Composite container = new Composite(this, SWT.BORDER);
    GridLayout richTextLayout = new GridLayout();
    richTextLayout.marginWidth = 0;
    richTextLayout.marginHeight = 0;
    container.setLayout(richTextLayout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    commentsText = new RichText(container, SWT.NONE);
    commentsText.setEditable(false);
    commentsText.setLayoutData(new GridData(GridData.FILL_BOTH));

    // the Rich Text control is a Browser for sure.
    Browser browser = (Browser) commentsText.getControl();
    browser.addLocationListener(new URLLocationListener());
  }
Beispiel #23
0
 /**
  * Show the HTML page with a certain name in the browser. This method returns true if the HTML
  * page exists.
  */
 private boolean show(String name) {
   String url = resolveHTMLFile(name);
   if (url != null) {
     browser.setUrl(url);
     return true;
   }
   return false;
 }
Beispiel #24
0
  public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    body.setLayout(new FillLayout());

    browser = new Browser(body, SWT.FILL | SWT.BORDER);
    browser.setUrl("http://flylb1.github.io/TSParser/");

    parent.layout();
  }
 private static void scrollToId(Browser browser, Long currentSelectionId) {
   if (browser != null && !browser.isDisposed()) {
     if (currentSelectionId != null) {
       browser.execute(
           "(setTimeout(function() {"
               + //$NON-NLS-1$
               "var selectedElement = document.querySelector('["
               + VpvDomBuilder.ATTR_VPV_ID
               + "=\""
               + currentSelectionId
               + "\"]');"
               + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
               "selectedElement.scrollIntoView(true);"
               + //$NON-NLS-1$
               "}, 300))();"); //$NON-NLS-1$;
     }
   }
 }
 public static void disableLinks(Browser browser) {
   if (browser != null && !browser.isDisposed()) {
     browser.execute(
         "(setTimeout(function() { "
             + //$NON-NLS-1$
             "var anchors = document.getElementsByTagName('a');"
             + //$NON-NLS-1$
             "for (var i = 0; i < anchors.length; i++) {"
             + //$NON-NLS-1$
             "anchors[i].href = 'javascript: void(0);';"
             + //$NON-NLS-1$
             "anchors[i].target = '';"
             + //$NON-NLS-1$
             "};"
             + //$NON-NLS-1$
             "}, 10))();"); //$NON-NLS-1$
   }
 }
  @SuppressWarnings("serial")
  public DesignerEditorWidget(Composite parent) {
    super(parent, SWT.NONE);
    super.setLayout(new FillLayout());

    browser = new Browser(this, SWT.NONE);
    browser.setUrl(RWT.getRequest().getContextPath() + EDITOR_URL);
    browser.addProgressListener(
        new ProgressListener() {

          @Override
          public void completed(ProgressEvent event) {
            loaded = true;
            updateWidgetContents();
          }

          @Override
          public void changed(ProgressEvent event) {
            //
          }
        });

    // DO NOT REMOVE THIS
    new BrowserFunction(browser, "saveCalled") { // $NON-NLS-1$
      @Override
      public Object function(Object[] arguments) {
        if (listener != null) {
          listener.save();
        }
        return null;
      }
    };

    // DO NOT REMOVE THIS
    new BrowserFunction(browser, "dirtyChanged") { // $NON-NLS-1$
      @Override
      public Object function(Object[] arguments) {
        if (listener != null) {
          listener.dirtyStateChanged((Boolean) arguments[0]);
        }
        return null;
      }
    };
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    page.setLayout(layout);
    GridDataFactory df = GridDataFactory.fillDefaults();
    page.setLayoutData(df.create());

    /*Text t = new Text(page, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    t.setLayoutData(df.create());
    t.setText(monitor.getAgreementString());*/
    Browser browser = new Browser(page, SWT.NONE);
    browser.setText(monitor.getAgreementString());
    GridData data = df.create();
    data.widthHint = 400;
    data.heightHint = 400;
    browser.setLayoutData(data);
    return page;
  }
  public static boolean test(final int index) {
    if (verbose)
      System.out.println(
          "Javascript - verify execute() works on HTML rendered from memory with getText - script index "
              + index);

    AtomicBoolean passed = new AtomicBoolean(); // false on creation.

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Browser browser = new Browser(shell, SWT.NONE);

    final AtomicBoolean finished = new AtomicBoolean(); // initially false.

    browser.addProgressListener(
        new ProgressListener() {
          @Override
          public void changed(ProgressEvent event) {}

          @Override
          public void completed(ProgressEvent event) {
            if (verbose)
              runLoopTimer(display, shell, 1000); // slow down execution for visual inspection.

            passed.set(browser.execute(script[index]));

            if (verbose)
              runLoopTimer(display, shell, 1000); // slow down execution for visual inspection.
            finished.set(true);
          }
        });
    shell.open();
    browser.setText(html[index]);

    for (int i = 0; i < 5 && !passed.get() && !finished.get(); i++) {
      runLoopTimer(display, shell, 2);
      if (!display.isDisposed()) display.readAndDispatch();
    }
    display.dispose();
    return passed.get();
  }
Beispiel #30
0
 public void focus() {
   if (locationBar != null) {
     locationBar.setFocus();
   } else {
     if (browser != null) {
       browser.setFocus();
     } else {
       parent.setFocus();
     }
   }
 }