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();
  }
  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 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;
  }
Example #4
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;
 }
Example #5
0
 @Override
 public synchronized void update(File result) {
   if (result == null) {
     browser.setText("<html/>");
   } else {
     browser.setUrl(result.toURI().toString());
   }
 }
Example #6
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();
  }
Example #7
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();
            }
          });
    }
  }
 /**
  * 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();
   //
 }
Example #9
0
        public void widgetSelected(SelectionEvent e) {
          if (object.getParent() != null) {
            setObject(object.getParent());
            browser.setUrl(url);

            if (object.getParent().getNextSiblingTo(object.getLabel()) == null) {
              next.setEnabled(false);
            }
            if (object.getParent().getPrevSiblingTo(object.getLabel()) == null) {
              prev.setEnabled(false);
            }
          }
        }
Example #10
0
 /** Executes to start fight animation. */
 private void fight() {
   int result1, result2;
   try {
     // gets counts of hits for each search
     result1 = control.getNumberOfArticles(searchText.getText());
     result2 = control.getNumberOfArticles(searchText2.getText());
     // writes the html file
     Util.generateFight(result1, result2);
     // loads it in the browser
     browser.setUrl(new File("articlefight/articlefight.html").getAbsolutePath());
   } catch (ControlException e) {
   }
 }
Example #11
0
 public void widgetSelected(SelectionEvent e) {
   if (object.getParent() != null) {
     ICoverageObject sib = object.getParent().getNextSiblingTo(object.getLabel());
     if (sib == null) {
       return;
     }
     setObject(sib);
     browser.setUrl(url);
     prev.setEnabled(true);
     if (object.getParent().getNextSiblingTo(object.getLabel()) == null) {
       next.setEnabled(false);
     }
   }
 }
Example #12
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");
 }
  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$
    }
  }
 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);
   }
 }
  @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;
      }
    };
  }
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   shell.setText("Mozilla");
   final Browser browser;
   try {
     browser = new Browser(shell, SWT.MOZILLA);
   } catch (SWTError e) {
     System.out.println("Could not instantiate Browser: " + e.getMessage());
     display.dispose();
     return;
   }
   shell.open();
   browser.setUrl("http://mozilla.org");
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Example #17
0
  private Composite getFightPane(Composite parent) {
    // creates the composite to eventually return
    Composite composite = new Composite(parent, SWT.NONE);
    // sets its layout
    FormLayout layout = new FormLayout();
    FormData data;
    layout.spacing = 5;
    composite.setLayout(layout);
    // Let's create some controls!
    // search button
    final Button fightButton = new Button(composite, SWT.PUSH);
    fightButton.setText("Fight!");
    try {
      fightButton.setImage(new Image(null, new FileInputStream("images/search.png")));
    } catch (Exception e) {

    }
    fightButton.setToolTipText("Click here to see how many articles contain each search term");

    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(50, -50);
    data.width = 100;
    data.height = 30;
    fightButton.setLayoutData(data);
    // search text
    searchText = new Text(composite, SWT.SINGLE | SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(fightButton, 0);
    data.width = 150;
    data.height = 24;
    searchText.setLayoutData(data);
    // second search text
    searchText2 = new Text(composite, SWT.SINGLE | SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(fightButton, 0);
    data.width = 150;
    data.height = 24;
    searchText2.setLayoutData(data);
    // label
    label = new Label(composite, SWT.CENTER);
    label.setText("Enter two terms and click 'Fight!'");
    label.setFont(new Font(Display.getCurrent(), "", 16, SWT.BOLD));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(fightButton, 5);
    label.setLayoutData(data);
    // browser
    browser = new Browser(composite, SWT.BORDER);
    data = new FormData();
    data.left = new FormAttachment(50, -275);
    data.right = new FormAttachment(50, 275);
    data.top = new FormAttachment(label, 5);
    // data.bottom = new FormAttachment(100,0);
    data.height = 520;
    data.width = 550;
    browser.setLayoutData(data);
    // sets browser home page
    browser.setUrl("http://www.rssoap.com");
    // adds click listener to start animation
    fightButton.addMouseListener(
        new MouseListener() {
          public void mouseUp(MouseEvent e) {}

          public void mouseDown(MouseEvent e) {
            fight();
          }

          public void mouseDoubleClick(MouseEvent e) {}
        });
    return composite;
  }
Example #18
0
  private void initIcons(ApplicationFactory factory) {
    Composite center = null;
    if (Application.LICENSE == Install.PERSONAL) {
      center = new Composite(this, SWT.TRANSPARENCY_ALPHA);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      center.setLayoutData(gridData);

      GridLayout gridLayout = new GridLayout(2, false);
      center.setLayout(gridLayout);

      Browser widget = null;

      //      ClientLog.getInstance().setMessage(getShell(), new Exception( "buoc 1 da chay vao day
      // roi " + widget.toString()));

      try {
        widget = new Browser(center, SWT.NONE);
        //        ClientLog.getInstance().setMessage(getShell(), new Exception( " da chay vao day
        // roi " + widget.toString()));
      } catch (Exception e) {
        widget = new Browser(center, SWT.NONE);
        ClientLog.getInstance().setException(null, e);
      }
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.verticalSpan = 2;
      widget.setLayoutData(gridData);
      if (Application.GROUPS.length > 0 && Application.GROUPS[0].equals("XML")) {
        widget.setUrl("http://vietspider.org/webextractor/");
        toolbar.setText("http://vietspider.org/webextractor/");
      } else {
        widget.setUrl("http://nik.vn/tin/");
        //      widget.setUrl("http://*****:*****@SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            BrowserWidget browser = workspace.getTab().createItem();
            browser.viewPage();
          }
        };
    browserImageLink.addHyperlinkListener(listener);
    //    browserLink.addHyperlinkListener(listener);

    composite = createItem(top);
    final ImageHyperlink creatorImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    creatorImageLink.setImage(factory.loadImage("large.createsource.png"));
    //    creatorImageLink.setBackground(getBackground());
    creatorImageLink.setToolTipText(factory.getLabel("creatorLink"));
    //    final Hyperlink creatorLink = createLink(composite);
    //    creatorLink.setText(factory.getLabel("creatorLink"));
    //    creatorLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
            try {
              ChannelWizard wizard =
                  (ChannelWizard)
                      workspace.getTab().createTool(ChannelWizard.class, false, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(null, exp);
            }
            //        try {
            //          Creator creator = (Creator)workspace.getTab().createTool(
            //              Creator.class, false,  SWT.CLOSE);
            //          creator.selectData(new Worker[0], null, null);
            //        } catch (Exception exp) {
            //          ClientLog.getInstance().setException(null, exp);
            //        }
          }
        };
    creatorImageLink.addHyperlinkListener(listener);
    //    creatorLink.addHyperlinkListener(listener);

    ////////////////////////////////////////////////////////////////////////////////////////////////

    Composite bottom = new Composite(center, SWT.TRANSPARENCY_ALPHA);
    if (Application.LICENSE == Install.PERSONAL) {
      gridData = new GridData();
      gridData.widthHint = 350;
    } else {
      gridData = new GridData(GridData.FILL_BOTH);
    }
    bottom.setLayoutData(gridData);
    //    bottom.setBackground(getBackground());

    rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.pack = true;
    rowLayout.justify = true;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.marginLeft = 5;
    rowLayout.marginTop = 5;
    rowLayout.marginRight = 5;
    rowLayout.marginBottom = 5;
    rowLayout.spacing = 20;
    bottom.setLayout(rowLayout);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(top);
    } else {
      composite = createItem(bottom);
    }
    final ImageHyperlink crawlerImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    crawlerImageLink.setImage(factory.loadImage("large.crawler.png"));
    //    crawlerImageLink.setBackground(getBackground());
    crawlerImageLink.setToolTipText(factory.getLabel("crawlerLink"));
    //    final Hyperlink crawlerLink = createLink(composite);
    //    crawlerLink.setText(factory.getLabel("crawlerLink"));
    //    crawlerLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Crawler.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(getShell(), exp);
            }
          }
        };
    crawlerImageLink.addHyperlinkListener(listener);
    //    crawlerLink.addHyperlinkListener(listener);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(bottom);
      final ImageHyperlink monitorImageLink =
          new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
      monitorImageLink.setImage(factory.loadImage("large.log.png"));
      //      monitorImageLink.setBackground(getBackground());
      monitorImageLink.setToolTipText(factory.getLabel("logLink"));
      //      final Hyperlink monitorLink = createLink(composite);
      //      monitorLink.setText(factory.getLabel("monitorLink"));
      //      monitorLink.setForeground(color);
      listener =
          new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
              try {
                workspace.getTab().createTool(LogViewer2.class, true, SWT.CLOSE);
              } catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
      monitorImageLink.addHyperlinkListener(listener);
      //      monitorLink.addHyperlinkListener(listener);
    }

    /*if(Application.LICENSE  != Install.PERSONAL) {
          composite = createItem(bottom);
          final ImageHyperlink userImageLink =
            new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
          userImageLink.setImage(factory.loadImage("large.userfolder.png"));
    //      userImageLink.setBackground(getBackground());
          userImageLink.setToolTipText(factory.getLabel("userLink"));
    //      final Hyperlink userLink = createLink(composite);
    //      userLink.setText(factory.getLabel("userLink"));
    //      userLink.setForeground(color);
          listener = new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkEntered(HyperlinkEvent e) {
    //          userLink.setUnderlined(true);
            }

            @SuppressWarnings("unused")
            public void linkExited(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
    //          userLink.setFont(UIDATA.FONT_9VB);
            }
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
              try {
                workspace.getTab().createTool(Organization.class, true,  SWT.CLOSE);
              }catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
          userImageLink.addHyperlinkListener(listener);
    //      userLink.addHyperlinkListener(listener);
        }*/

    composite = createItem(bottom);

    final ImageHyperlink configImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    configImageLink.setImage(factory.loadImage("large.settingsfolder.png"));
    //    configImageLink.setBackground(getBackground());
    configImageLink.setToolTipText(factory.getLabel("configLink"));
    //    final Hyperlink configLink = createLink(composite);
    //    configLink.setText(factory.getLabel("configLink"));
    //    configLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        configLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Config.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(workspace.getShell(), exp);
            }
          }
        };
    configImageLink.addHyperlinkListener(listener);
  }
  private void _initFields() throws Exception {
    // m_browser.setUrl("file:///C:/WKSPs/Consolidado/SWT_ATM-Test/resources/page.html");
    m_browser.setUrl("");

    // m_browser.setUrl("http://localhost/jzbTest/page.html");
  }
Example #20
0
  private void createContent() {

    Shell parent = getParent();
    dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    GridLayout dialogShellLayout = new GridLayout();
    dialogShellLayout.makeColumnsEqualWidth = true;
    dialogShell.setText("Html Report browser");
    dialogShell.setLayout(dialogShellLayout);
    dialogShell.layout();
    dialogShell.pack();
    dialogShell.setSize(800, 600);

    browser = new Browser(dialogShell, SWT.NONE | SWT.BORDER);
    GridData browserLData = new GridData();
    browserLData.widthHint = 784;
    browserLData.heightHint = 500;
    browser.setLayoutData(browserLData);
    browser.setUrl(object.getHtmlPath());
    browser.addLocationListener(locationListener);

    comp = new Composite(dialogShell, SWT.NONE);
    GridLayout compLayout = new GridLayout();
    compLayout.makeColumnsEqualWidth = true;
    compLayout.numColumns = 4;
    compLayout.marginLeft = 330;
    compLayout.marginRight = 330;
    GridData compLData = new GridData();
    compLData.widthHint = 521;
    compLData.heightHint = 33;
    comp.setLayoutData(compLData);
    comp.setLayout(compLayout);

    prev = new Button(comp, SWT.PUSH | SWT.CENTER | SWT.FILL);
    GridData prevLData = new GridData();
    prev.setLayoutData(prevLData);
    prev.addSelectionListener(prevListener);
    prev.setImage(Activator.getImageDescriptor(Images.PREV).createImage());

    next = new Button(comp, SWT.PUSH | SWT.CENTER | SWT.FILL);
    GridData nextLData = new GridData();
    next.setLayoutData(nextLData);
    next.addSelectionListener(nextListener);
    next.setImage(Activator.getImageDescriptor(Images.NEXT).createImage());

    if (object.getParent() != null) {
      if (object.getParent().getNextSiblingTo(object.getLabel()) == null) {
        next.setEnabled(false);
      }
      if (object.getParent().getPrevSiblingTo(object.getLabel()) == null) {
        prev.setEnabled(false);
      }
    } else {
      next.setEnabled(false);
      prev.setEnabled(false);
    }

    home = new Button(comp, SWT.PUSH | SWT.CENTER | SWT.FILL);
    GridData homeLData = new GridData();
    home.setLayoutData(homeLData);
    home.addSelectionListener(homeListener);
    home.setImage(Activator.getImageDescriptor(Images.HOME).createImage());

    up = new Button(comp, SWT.PUSH | SWT.CENTER | SWT.FILL);
    GridData upLData = new GridData();
    up.setLayoutData(upLData);
    up.addSelectionListener(upListener);
    up.setImage(Activator.getImageDescriptor(Images.UP).createImage());

    dialogShell.setLocation(getParent().toDisplay(100, 100));
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls
   * (org.eclipse.swt.widgets.Composite,
   * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(
      final Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {

    this.parent = parent;
    this.toolkit = new FormToolkit(parent.getDisplay());
    super.createControls(parent, aTabbedPropertySheetPage);

    if (form != null && !form.isDisposed()) {
      try {
        form.dispose();
      } catch (Exception e) {
        // ignore any expose exceptions
      }
    }
    form = null;

    if (parent.isDisposed()) return;

    parent.setLayout(new GridLayout());
    // parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    form = toolkit.createForm(parent);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    form.setText(EditorMessages.propertiesDocumentationTitle);
    toolkit.decorateFormHeading(form);

    form.getBody().setLayout(new GridLayout(1, false));

    Composite sbody = form.getBody();

    ToolBar navBar = new ToolBar(sbody, SWT.NONE);
    toolkit.adapt(navBar);
    navBar.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
    final ToolItem back = new ToolItem(navBar, SWT.PUSH);
    back.setText("<");
    back.setEnabled(false);
    final ToolItem forward = new ToolItem(navBar, SWT.PUSH);
    forward.setText(">");
    forward.setEnabled(false);

    back.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.back();
          }
        });
    forward.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.forward();
          }
        });

    final LocationListener locationListener =
        new LocationListener() {
          public void changed(LocationEvent event) {
            Browser browser = (Browser) event.widget;
            back.setEnabled(browser.isBackEnabled());
            forward.setEnabled(browser.isForwardEnabled());
          }

          public void changing(LocationEvent event) {}
        };

    browser = new Browser(sbody, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    browser.setLayoutData(data);
    IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    URL url = helpSystem.resolve("org.fusesource.ide.help/index.html", true);
    browser.setUrl(url.toExternalForm());
    browser.addLocationListener(locationListener);

    // section.pack();
    // form.pack();
    form.layout(true, true);
    parent.layout(true, true);

    // in case of timing issues, lets do another layout just in case...
    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                if (form != null && !form.isDisposed()) {
                  form.layout(true, true);
                }
                if (parent != null && !parent.isDisposed()) {
                  parent.layout(true, true);
                }
              }
            });
  }
Example #22
0
  @SuppressWarnings("serial")
  public EditorWidget(final Composite parent, final boolean javaScriptEditor) {
    super(parent, SWT.NONE);
    super.setLayout(new FillLayout());

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

          @Override
          public void completed(final ProgressEvent event) {
            loaded = true;
            updateWidgetContents();
            if (javaScriptEditor && DebugModelFacade.getDebugModel() != null) {
              final DebugSessionModel session = DebugModelFacade.getDebugModel().getActiveSession();

              if (session != null && session.getCurrentLineBreak() != null) {
                final String filePath = session.getCurrentLineBreak().getBreakpoint().getFullPath();
                final String path =
                    CommonUtils.formatToRuntimePath(
                        ICommonConstants.ARTIFACT_TYPE.SCRIPTING_SERVICES, filePath);
                final int[] breakpoints =
                    DebugModelFacade.getDebugModel().getBreakpointsMetadata().getBreakpoints(path);

                loadBreakpoints(breakpoints);
              }
            }
          }

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

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

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

    // DO NOT REMOVE THIS
    new BrowserFunction(browser, "setBreakpoint") { // $NON-NLS-1$
      @Override
      public Object function(final Object[] arguments) {
        if ((listener != null) && (arguments[0] != null) && (arguments[0] instanceof Number)) {
          listener.setBreakpoint(((Number) arguments[0]).intValue());
        }
        return null;
      }
    };

    // DO NOT REMOVE THIS
    new BrowserFunction(browser, "clearBreakpoint") { // $NON-NLS-1$
      @Override
      public Object function(final Object[] arguments) {
        if ((listener != null) && (arguments[0] != null) && (arguments[0] instanceof Number)) {
          listener.clearBreakpoint(((Number) arguments[0]).intValue());
        }
        return null;
      }
    };
  }
Example #23
0
 public void widgetSelected(SelectionEvent e) {
   setObject(StatsTreeModel.getInstance().getRoot());
   browser.setUrl(url);
   next.setEnabled(false);
   prev.setEnabled(false);
 }
 public void buildUI(Composite parent) {
   browser = new Browser(parent, SWT.NONE);
   browser.setUrl("http://tieba.baidu.com/f?kw=%C8%FD%B9%FA%C8%AB%C3%E6%D5%BD%D5%F9");
 }
Example #25
0
 private void internalSetUrl(String url) {
   if (browser != null) {
     browser.setUrl(url);
   }
 }
  public static boolean test1(String url) {
    if (verbose)
      System.out.println(
          "javascript window.open with location and size parameters - args: "
              + url
              + "\n  Expected Event Sequence: Visibility.show");
    passed = false;

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Browser browser = new Browser(shell, SWT.NONE);
    browser.addOpenWindowListener(
        new OpenWindowListener() {
          public void open(WindowEvent event) {
            if (verbose) System.out.println("OpenWindow " + index);
            Shell newShell = new Shell(display);
            newShell.setLayout(new FillLayout());
            Browser browser = new Browser(newShell, SWT.NONE);
            browser.setData("index", new Integer(index));
            browser.addVisibilityWindowListener(
                new VisibilityWindowListener() {
                  public void hide(WindowEvent event) {}

                  public void show(WindowEvent event) {
                    Browser browser = (Browser) event.widget;
                    Shell parent = browser.getShell();
                    Point location = event.location;
                    Point size = event.size;
                    if (location != null) parent.setLocation(location);
                    if (size != null) parent.setSize(size);
                    int index = ((Integer) browser.getData("index")).intValue();
                    parent.setText("SWT Browser shell " + index);
                    parent.open();
                    if (index < 0) {
                      /* Certain browsers fire multiple show events for no good reason. Further show events
                       * are considered 'legal' as long as they don't contain size and location information.
                       */
                      if (location != null || size != null) {
                        if (verbose)
                          System.out.println(
                              "Failure - Browser " + index + " is receiving multiple show events");
                        passed = false;
                        shell.close();
                      } else {
                        if (verbose)
                          System.out.println(
                              "Unnecessary (but harmless) visibility.show event Browser " + index);
                      }
                    } else {
                      if (verbose)
                        System.out.println(
                            "Visibility.show browser "
                                + index
                                + " location "
                                + location
                                + " size "
                                + size);
                      browser.setData("index", new Integer(-100 - index));

                      /* Certain browsers include decorations in addition to the expected size.
                       * Accept sizes that are greater than or equal to the expected size.
                       * Certain browsers invent size or location when some parameters are missing.
                       * If we expect null for one of size or location, also accept non null answers.
                       */
                      Point expectedLocation = regressionBounds[index][0];
                      Point expectedSize = regressionBounds[index][1];
                      if (verbose)
                        System.out.println(
                            "Expected location " + expectedLocation + " size " + expectedSize);
                      boolean checkLocation =
                          (location == null && expectedLocation == null)
                              || (location != null && location.equals(expectedLocation)
                                  || (location != null && expectedLocation == null));
                      boolean checkSize =
                          (size == null && expectedSize == null)
                              || (size != null && size.equals(expectedSize))
                              || (size != null && expectedSize == null)
                              || (size != null
                                  && size.x >= expectedSize.x
                                  && size.y >= expectedSize.y);
                      if (!checkSize || !checkLocation) {
                        if (verbose) System.out.println("	Failure ");
                        passed = false;
                        shell.close();
                        return;
                      } else cntPassed++;
                    }
                  }
                });
            browser.addCloseWindowListener(
                new CloseWindowListener() {
                  public void close(WindowEvent event) {
                    cntClosed++;
                    if (verbose) System.out.println("Close");
                    Browser browser = (Browser) event.widget;
                    browser.getShell().close();
                    if (cntPassed == regressionBounds.length) passed = true;
                    if (cntClosed == regressionBounds.length) {
                      shell.close();
                      return;
                    }
                  }
                });
            event.browser = browser;
            index++;
          }
        });
    shell.open();
    browser.setUrl(url);

    boolean timeout = runLoopTimer(display, shell, 600);
    if (timeout) passed = false;
    display.dispose();
    return passed;
  }
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    shell.setLayout(gridLayout);
    ToolBar toolbar = new ToolBar(shell, SWT.NONE);
    ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
    itemBack.setText("Back");
    ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
    itemForward.setText("Forward");
    ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
    itemStop.setText("Stop");
    ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
    itemRefresh.setText("Refresh");
    ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
    itemGo.setText("Go");

    GridData data = new GridData();
    data.horizontalSpan = 3;
    toolbar.setLayoutData(data);

    Label labelAddress = new Label(shell, SWT.NONE);
    labelAddress.setText("Address");

    final Text location = new Text(shell, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    location.setLayoutData(data);

    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;
    }
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.horizontalSpan = 3;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);

    final Label status = new Label(shell, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);

    final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.END;
    progressBar.setLayoutData(data);

    /* event handling */
    Listener listener =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            ToolItem item = (ToolItem) event.widget;
            String string = item.getText();
            if (string.equals("Back")) browser.back();
            else if (string.equals("Forward")) browser.forward();
            else if (string.equals("Stop")) browser.stop();
            else if (string.equals("Refresh")) browser.refresh();
            else if (string.equals("Go")) browser.setUrl(location.getText());
          }
        };
    browser.addProgressListener(
        new ProgressListener() {
          @Override
          public void changed(ProgressEvent event) {
            if (event.total == 0) return;
            int ratio = event.current * 100 / event.total;
            progressBar.setSelection(ratio);
          }

          @Override
          public void completed(ProgressEvent event) {
            progressBar.setSelection(0);
          }
        });
    browser.addStatusTextListener(
        new StatusTextListener() {
          @Override
          public void changed(StatusTextEvent event) {
            status.setText(event.text);
          }
        });
    browser.addLocationListener(
        new LocationListener() {
          @Override
          public void changed(LocationEvent event) {
            if (event.top) location.setText(event.location);
          }

          @Override
          public void changing(LocationEvent event) {}
        });
    itemBack.addListener(SWT.Selection, listener);
    itemForward.addListener(SWT.Selection, listener);
    itemStop.addListener(SWT.Selection, listener);
    itemRefresh.addListener(SWT.Selection, listener);
    itemGo.addListener(SWT.Selection, listener);
    location.addListener(
        SWT.DefaultSelection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            browser.setUrl(location.getText());
          }
        });

    shell.open();
    browser.setUrl("http://eclipse.org");

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Example #28
0
 /**
  * Sets the url of the browser.
  *
  * @param url String
  */
 public void setURL(String url) {
   browser.setUrl(url);
 }