Java 类org.eclipse.swt.browser.Browser 实例源码

项目:iTrace-Archive    文件:GazeHandlerFactory.java   
/**
 * Creates and returns a new IGazeHandler object from the specified object
 * and partRef, or returns null if no handler object is defined for that object.
 */
public static IGazeHandler createHandler(Object target,
        IWorkbenchPartReference partRef) {

    // create gaze handler for a StyledText widget within an EditorPart
    if (target instanceof StyledText &&
            partRef instanceof IEditorReference) {
        return new StyledTextGazeHandler(target); //can go back to using partRef

    } else if (target instanceof Browser) {
        //create gaze handler for a Browser Stack overflow and Bug Report widget
        //cannot get associated partRef
        return new BrowserGazeHandler(target);

    } else if (target instanceof Tree &&
            partRef instanceof IViewReference &&
            partRef.getTitle().equals("Project Explorer")) {
        //create gaze handler for a Project Explorer Tree
        return new ProjectExplorerGazeHandler(target, partRef);
    }

    return null;
}
项目:iTrace-Archive    文件:HandlerBindManager.java   
/**
   * Recursive helper function to find and bind Browser controls
   * @param control
   */
  private static void bind(Control control) {

    if (control instanceof Browser) {
    bindControl(null, control, false);
}

    //If composite, look through children.
      if (control instanceof Composite) {
          Composite composite = (Composite) control;

          Control[] children = composite.getChildren();
          if (children.length > 0 && children[0] != null) {
             for (Control curControl : children)
                 bind(curControl);
          }
      }
  }
项目:iTrace-Archive    文件:HandlerBindManager.java   
/**
   * Recursive helper function to find and unbind Browser controls
   * @param control
   */
  private static void unbind(Control control) {

    if (control instanceof Browser) {
    bindControl(null, control, true);
}

    //If composite, look through children
      if (control instanceof Composite) {
          Composite composite = (Composite) control;

          Control[] children = composite.getChildren();
          if (children.length > 0 && children[0] != null) {
             for (Control curControl : children)
                 unbind(curControl);
          }
      }
  }
项目:iTrace-Archive    文件:ControlView.java   
/**
 * Recursive helper function to find and set up Browser control managers
 * @param control
 */
private void setupBrowsers(Control control) {

    if (control instanceof Browser) {
        setupControls(null, control);
    }

    //If composite, look through children.
    if (control instanceof Composite) {
        Composite composite = (Composite) control;

        Control[] children = composite.getChildren();
        if (children.length > 0 && children[0] != null) {
           for (Control curControl : children)
               setupBrowsers(curControl);
        }
    }
}
项目:iTrace-Archive    文件:ControlView.java   
/**
 * Recursive function for setting up children controls for a control if it is
 * a composite and setting up the main control's manager.
 * @param part
 * @param control
 */
private void setupControls(IWorkbenchPart part, Control control) {
    //If composite, setup children controls.
    if (control instanceof Composite) {
        Composite composite = (Composite) control;

        Control[] children = composite.getChildren();
        if (children.length > 0 && children[0] != null) {
           for (Control curControl : children)
               setupControls(part, curControl);
        }
    }

    if (control instanceof StyledText) {
        //set up styled text manager if there is one
        setupStyledText((IEditorPart) part, (StyledText) control);

    } else if (control instanceof Browser) {
        //set up browser manager if there is one
        setupBrowser((Browser) control);
    }
    //TODO: no control set up for a ProjectExplorer, since there isn't an need for 
    //a Manager right now, might be needed in the future
}
项目:DarwinSPL    文件:DwprofileBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyexpressionBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyvalidityformulaBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HydatavalueBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HymappingBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyconstraintsBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HymanifestBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:http4e    文件:AboutDialog.java   
protected Control createDialogArea( Composite parent){
   Composite composite = (Composite) super.createDialogArea(parent);

   Browser browser = new Browser(composite, SWT.NONE);
   browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

   try {
      String html = new String(ResourceUtils.getBundleResourceBytes(CoreConstants.PLUGIN_UI, "resources/about.html"));
      html = html.replaceAll("currentYear", ""+Calendar.getInstance().get(Calendar.YEAR));
      browser.setText(html);

   } catch (Exception e) {
      setErrorMessage(e.getLocalizedMessage());
   }
   return composite;
}
项目:TranskribusSwtGui    文件:VersionsDiffBrowserDialog.java   
@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    GridLayout layout = new GridLayout(1, false);
    composite.setLayout(layout);

    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(data);

    Browser browser = new Browser(composite, SWT.NONE);
    browser.setText(browserString);
    browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    if (Util.isMac())
        browser.refresh();

    composite.pack();

    return composite;
}
项目:Sparrow    文件:TechnicalDebtView.java   
@Override
public void createPartControl(Composite parent) {
    browser = new Browser(parent, SWT.None);
    URL url;
    try {
        url = new URL("platform:/plugin/reFactor/resources/technical_debt.html");
        InputStream inputStream = url.openConnection().getInputStream();
        BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
        String inputLine = "";
        String html = "";
        while ((inputLine = in.readLine()) != null) {
            html += inputLine;
        }
        browser.setText(html);
        in.close();

    } catch (IOException e) {
        e.printStackTrace();
    }

    // try {
    // url = new URL("platform:/plugin/reFactor/resources/technical_debt.html");
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
}
项目:oauth2-useragent    文件:StandardWidgetToolkit.java   
public StandardWidgetToolkit(String... commandLineArgs) {
    this.swtRunnableFactory = RUNNABLE_FACTORY_OVERRIDE != null ? RUNNABLE_FACTORY_OVERRIDE : this;
    this.commandLineArgs = commandLineArgs;

    display = new Display();
    shell = new Shell(display);
    shell.setText("OAuth 2.0 Authorization Request");

    shell.setLayout(new FillLayout());
    Monitor monitor = display.getPrimaryMonitor();
    Rectangle bounds = monitor.getBounds();
    Dimension size = new Dimension((int) (bounds.width * 0.25), (int) (bounds.height * 0.55));
    shell.setSize(size.width, size.height);
    shell.setLocation((bounds.width - size.width) / 2, (bounds.height - size.height) / 2);

    Browser browser = new org.eclipse.swt.browser.Browser(shell, SWT.ON_TOP);

    swtInterceptingBrowser = new SwtInterceptingBrowser(browser, display, shell);
}
项目:scouter    文件:ServerStatusView.java   
public void createPartControl(final Composite parent) {
    shell = parent.getShell();

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gLayout = new GridLayout(1, true);
    gLayout.horizontalSpacing = 0;
    gLayout.marginHeight = 0;
    gLayout.marginWidth = 0;
    composite.setLayout(gLayout);

    Composite textComposite = new Composite(composite, SWT.NONE);
    textComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    textComposite.setLayout(new FillLayout());

    browser = new Browser(textComposite, SWT.BORDER);

}
项目:scouter    文件:MainProcessor.java   
public void viewThreadStack( String filter ) {
    if ( filter == null )
        return;

    StackFileInfo stackFileInfo = getSelectedStackFileInfo();
    if ( stackFileInfo == null )
        return;

    String filename = StackParser.getWorkingThreadFilename(stackFileInfo.getFilename());
    int stackStartLine = stackFileInfo.getParserConfig().getStackStartLine();
    if ( filename != null && filter != null ) {
        Browser broswer = getBrowser();
        if ( m_isExcludeStack )
            broswer.setText(HtmlUtils.filterThreadStack(filename, filter, stackFileInfo.getParserConfig().getExcludeStack(), stackStartLine));
        else
            broswer.setText(HtmlUtils.filterThreadStack(filename, filter, null, stackStartLine));
    }

}
项目:PDFReporter-Studio    文件:CSVExporterPreferencePage.java   
/**
 *
 */
public void createFieldEditors() {
    NStringFieldEditor tf = new NStringFieldEditor(CsvExporterConfiguration.PROPERTY_RECORD_DELIMITER,
            Messages.CSVExporterPreferencePage_3, 4, getFieldEditorParent());
    tf.setEmptyStringAllowed(false);
    tf.setTextLimit(10);
    addField(tf);
    HelpSystem.setHelp(tf.getTextControl(getFieldEditorParent()),
            StudioPreferencePage.REFERENCE_PREFIX + tf.getPreferenceName());

    tf = new NStringFieldEditor(CsvExporterConfiguration.PROPERTY_FIELD_DELIMITER,
            Messages.CSVExporterPreferencePage_4, 4, getFieldEditorParent());
    tf.setEmptyStringAllowed(false);
    tf.setTextLimit(10);
    addField(tf);
    HelpSystem.setHelp(tf.getTextControl(getFieldEditorParent()),
            StudioPreferencePage.REFERENCE_PREFIX + tf.getPreferenceName());

    Browser lbl = BrowserUtils.getSWTBrowserWidget(getFieldEditorParent(), SWT.MULTI);
    lbl.setText(Messages.CSVExporterPreferencePage_5);

    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    lbl.setLayoutData(gd);

}
项目:gama    文件:HtmlViewer.java   
@Override
public void createPartControl(final Composite parent) {
    final Composite compo = GamaToolbarFactory.createToolbars(this, parent);
    browser = new Browser(compo, SWT.NONE);
    browser.addProgressListener(new ProgressListener() {

        @Override
        public void changed(final ProgressEvent arg0) {}

        @Override
        public void completed(final ProgressEvent event) {
            checkButtons();
        }
    });
    parent.layout();
    openInput();
}
项目:JFaceUtils    文件:MapDialog.java   
public Composite createButtonBox(final Shell shell, final Browser browser) {
    final Composite buttonComposite = new Composite(shell, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(buttonComposite);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(buttonComposite);

    final Button closeButton = new Button(buttonComposite, SWT.PUSH);
    closeButton.setText(JFaceMessages.get("lbl.button.close"));
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.FILL).grab(true, false).minSize(SwtUtils.convertHorizontalDLUsToPixels(closeButton, IDialogConstants.BUTTON_WIDTH), SWT.DEFAULT).applyTo(closeButton);
    closeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent se) {
            shell.close();
        }
    });

    shell.setDefaultButton(closeButton);
    return buttonComposite;
}
项目:slr-toolkit    文件:BibtexEditor.java   
/**
 * Creates a browser for downloading the document which the bibtex entry
 * refers to. This only works if there is an URL or DOI in the bibtex entry.
 */
protected void createWebpage() {
    if (document.getUrl() == null && document.getDoi() == null) {
        return;
    }
    Composite localParent = getContainer();
    if (localParent == null) {
        localParent = parent;
    }
    Composite webcomposite = new Composite(localParent, SWT.NONE);
    FillLayout layout = new FillLayout();
    webcomposite.setLayout(layout);
    browser = new Browser(webcomposite, SWT.NONE);
    browser.setLayout(layout);
    webindex = addPage(webcomposite);
    setPageText(webindex, "Webpage");
}
项目:mytourbook    文件:SearchView.java   
private void createUI_10_SearchInternal(final Composite parent) {

        try {

            _browser = new Browser(parent, SWT.NONE);
            GridDataFactory.fillDefaults().grab(true, true).applyTo(_browser);

        } catch (final SWTError e) {
            StatusUtil.showStatus("Could not instantiate Browser: " + e.getMessage(), e);//$NON-NLS-1$
            return;
        }

        _browser.addLocationListener(new LocationAdapter() {
            @Override
            public void changing(final LocationEvent event) {
                SearchMgr.onBrowserLocation(event);
            }
        });

    }
项目:jo-widgets    文件:JoToSwtSnipped.java   
@Override
public void start(final IApplicationLifecycle lifecycle) {
    //create the root frame
    final IFrame frame = Toolkit.createRootFrame(BPF.frame("JoToSwt Snipped"), lifecycle);
    frame.setSize(1024, 768);
    frame.setLayout(FillLayout.get());

    //create a regular jo composite
    final IComposite joComposite = frame.add(BPF.composite());

    //get the native ui reference which must be a swt composite
    //because swt SPI impl is used
    final Composite swtComposite = (Composite) joComposite.getUiReference();
    swtComposite.setLayout(new org.eclipse.swt.layout.FillLayout());

    //create a swt browser
    final Browser browser = new Browser(swtComposite, SWT.NONE);
    browser.setUrl("http://www.jowidgets.org/");

    //set the root frame visible
    frame.setVisible(true);
}
项目:jo-widgets    文件:AbstractDesignationCallback.java   
@Override
public final boolean register(final Browser browser, final IDesignationListener<? super T> listener) {
    browserFunction = new BrowserFunction(browser, getCallbackName()) {
        @Override
        public Object function(final Object[] arguments) {
            super.function(arguments);
            final T result = createResult(arguments);
            getBrowser().getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    listener.onDesignation(result);
                }
            });
            return null;
        }
    };
    return browser.execute(getJsStartFunctionName() + "('" + getCallbackName() + "');");
}
项目:OpenSPIFe    文件:TemporalNodeToolTipPolicy.java   
@Override
public void activate() {
    Control parent = getViewer().getControl();
    Display display = WidgetUtils.getDisplay();

    tip = new Shell(parent.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
    tip.setBackground(display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
    tip.setLayout (new FillLayout());

    try {
        browser = new Browser(tip, SWT.NONE);
    } catch (SWTError e) {
        System.out.println("Could not instantiate Browser: " + e.getMessage());
        display.dispose();
        return;
    }

    updateBrowserText();
    super.activate();
}
项目:translationstudio8    文件:HtmlBrowserEditor.java   
@Override
public void createPartControl(Composite parent) {
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    cmp = new Composite(parent, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);

    browser = new Browser(cmp, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    browser.setUrl(htmlUrl);

    browser.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            getSite().getPart().setFocus();
            super.mouseDown(e);
        }
    });
}
项目:STAGE    文件:GeopaparazziUtilities.java   
/**
 * Set an image as browser content.
 * 
 * @param browser the browser to use.
 * @param imageId the id of the image to show.
 * @param imageName the name of the image to show.
 * @param dbFile the db to use.
 * @param IMAGE_KEY the image key.
 * @param SERVICE_HANDLER the service handler id.
 * @throws Exception
 */
public static void setImageInBrowser( Browser browser, long imageId, String imageName, File dbFile, String IMAGE_KEY,
        String SERVICE_HANDLER ) throws Exception {
    try (SqliteDb db = new SqliteDb()) {
        db.open(dbFile.getAbsolutePath());
        IJGTConnection connection = db.getConnection();
        byte[] imageData = DaoImages.getImageData(connection, imageId);
        InputStream imageStream = null;
        try {
            imageStream = new ByteArrayInputStream(imageData);
            BufferedImage bufferedImage = createImage(imageStream);
            // store the image in the UISession for the service handler
            RWT.getUISession().setAttribute(IMAGE_KEY, bufferedImage);
            // create the HTML with a single <img> tag.
            browser.setText(createHtml(IMAGE_KEY, SERVICE_HANDLER));
            // newImageFile.delete();
        } catch (Exception e) {
            // File newImageFile = File.createTempFile("stage" + new Date().getTime(),
            // imageName);
            // try (OutputStream outStream = new FileOutputStream(newImageFile)) {
            // outStream.write(imageData);
            // }
            e.printStackTrace();
        }
    }
}
项目:pdi-platform-utils-plugin    文件:BrowserBuilderTest.java   
@Test
public void testCreateWidget() throws Exception {
  String text = "browser-text"; //$NON-NLS-1$

  Browser browserMock = mock( Browser.class );
  doReturn( browserMock ).when( browserBuilderSpy ).createBrowser( any( Composite.class ), anyInt() );
  doReturn( text ).when( browserMock ).getText();
  doReturn( null ).when( browserBuilderSpy ).createFont( any( Composite.class ), any( FontData.class ) );

  browserBuilderSpy.setLabelText( text );
  Browser browser = browserBuilderSpy.createWidget( parent );

  assertEquals( text, browser.getText() );
  verify( browser, times( 1 ) ).setText( text );
  verify( browser, times( 1 ) ).setFont( any( Font.class ) );
}
项目:Environment    文件:IntroComposite.java   
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public IntroComposite(Composite parent, int style) {
    super(parent, style);
    setLayout(new FillLayout(SWT.HORIZONTAL));

    Bundle plugin = Activator.getDefault().getBundle();

    try {
        // Cache entire folder
        // (needed in product export, to cache files, so it is possible to
        // reference them)
        URL folder = FileLocator.find(plugin, new Path("html/"), null);
        FileLocator.toFileURL(folder);

        IPath relativePagePath = new Path("html/intro.html");
        URL fileInPlugin = FileLocator.find(plugin, relativePagePath, null);
        introUrl = FileLocator.toFileURL(fileInPlugin);
        Browser browser = new Browser(this, SWT.NONE);
        browser.setUrl(introUrl.toString());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
项目:Environment    文件:IntroComposite.java   
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public IntroComposite(Composite parent, int style) {
    super(parent, style);
    setLayout(new FillLayout(SWT.HORIZONTAL));

    Bundle plugin = Activator.getDefault().getBundle();

    try {
        // Cache entire folder
        // (needed in product export, to cache files, so it is possible to
        // reference them)
        URL folder = FileLocator.find(plugin, new Path("resources/html/"), null);
        FileLocator.toFileURL(folder);

        IPath relativePagePath = new Path("resources/html/intro.html");
        URL fileInPlugin = FileLocator.find(plugin, relativePagePath, null);
        introUrl = FileLocator.toFileURL(fileInPlugin);
        Browser browser = new Browser(this, SWT.NONE);
        browser.setUrl(introUrl.toString());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
项目:eclipsensis    文件:NSISBrowserUtility.java   
public static boolean isBrowserAvailable(Composite parent)
{
    if (!cAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            cIsAvailable= true;
        }
        catch (SWTError er) {
            cIsAvailable= false;
        }
        finally {
            cAvailabilityChecked= true;
        }

    }

    return cIsAvailable;
}
项目:SSDBAdmin    文件:ApiTab.java   
public ApiTab(CTabFolder tabFolder)
{
    super(tabFolder, SWT.NONE);
    String userDir = System.getProperty("user.dir");
    File folder = new File(userDir,"api");
    if(!folder.exists()) {
        folder.mkdirs();
    }
    for (String f : new String[] {"index.html","leftbar.html","content.html"}){
        localApiFile(folder,f);   
    }
    setText(" SSDB API ");
    setShowClose(true);
    Browser browser = new Browser(tabFolder, SWT.NONE);
    browser.setLayoutData(new FillLayout());
    String url = new File(folder,"index.html").getPath();
    browser.setUrl(url);  
    this.setControl(browser);

    tabFolder.setSelection(this);
}
项目:tmxeditor8    文件:HtmlBrowserEditor.java   
@Override
public void createPartControl(Composite parent) {
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    cmp = new Composite(parent, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);

    browser = new Browser(cmp, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    browser.setUrl(htmlUrl);

    browser.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            getSite().getPart().setFocus();
            super.mouseDown(e);
        }
    });
}
项目:birt    文件:StaticHTMLViewer.java   
private void createBrowserSection( Composite parent )
{
    browserContainer = toolkit.createComposite( parent );
    browserContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
    GridLayout layout = new GridLayout( );
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.numColumns = 1;
    browserContainer.setLayout( layout );

    browser = new Browser( browserContainer, SWT.NONE );
    browser.setLayoutData( new GridData( GridData.FILL_BOTH ) );

    browser.addLocationListener( new ReportLocationListener( this ) );
    sashForm.setMaximizedControl( browserContainer );
}
项目:birt    文件:WebViewer.java   
/**
 * Displays the specified url using eclipse SWT browser.
 * 
 * @param report
 *            report report
 * @param format
 *            report format
 * @param browser
 *            SWT browser instance
 * @param servletName
 *            servlet name to viewer report
 * @deprecated
 */
public static void display( String report, String format, Browser browser,
        String servletName )
{
    checkAdapter( );

    startWebApp( DEFAULT_WEBAPP.getName( ), report );
    browser.setUrl( createURL( DEFAULT_WEBAPP.getName( ),
            servletName,
            report,
            format,
            null,
            null,
            null,
            null ) + "&" + random.nextInt( ) ); //$NON-NLS-1$
}
项目:birt    文件:WebViewer.java   
/**
 * Cancel the process
 * 
 * @param browser
 */
public static void cancel( Browser browser )
{
    if ( browser == null || browser.isDisposed( ) )
    {
        return;
    }

    try
    {
        browser.execute( "try { if( birtProgressBar ){ birtProgressBar.cancel(); } } catch(e){}" ); //$NON-NLS-1$
    }
    catch ( Exception e )
    {
        LogUtil.logError( e.getLocalizedMessage( ), e );
    }
}
项目:Mailster    文件:GeneralConfigurationPage.java   
private void checkBrowser()
{
    // If OS is a Windows system and Xul is available, then give a chance to
    // use it.
    boolean xulAvailable = false;
    Shell testShell = new Shell();
    try
    {
        new Browser(testShell, SWT.BORDER | SWT.MOZILLA);            
        xulAvailable = true;
    }
    catch(SWTError e)
    {
    }
    finally
    {
        testShell.dispose();
    }

    isXulOptionnal = xulAvailable
            && System.getProperty("os.name").toLowerCase().startsWith("win");
}
项目:pmcms    文件:HTMLRenderRelativeMemory.java   
public static void main(String[] args) {
    if (InitializationManager.lock())
        System.exit(1);
    System.setProperty("data.dir", Constants.APPLICATION_DIR.getAbsolutePath());
    InitializationManager.start(new BasicConfigurator());
    /* Relative links: use the HTML base tag */
    String html = "<html><head>" + "<base href=\"http://127.0.0.1:8080/\" >" + "<title>HTML AutowiredConfigurationTests</title>"
            + " <link rel=\"stylesheet\" type=\"text/css\" href=\"sites/s-th.info/format.css\" /></head>"
            + "<body><a href=\"changelog\">local link</a></body></html>";

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Browser browser = new Browser(shell, SWT.NONE);
    browser.setText(html);
    shell.open();
    System.out.println(html);
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();

    ThreadController.getInstance().stopAllThreads();
    InitializationManager.end();
}
项目:q7.quality.mockups    文件:TreeWithTooltipSupport.java   
protected Composite createToolTipContentArea(Event event,
        Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayout l = new GridLayout(1, false);
    l.horizontalSpacing = 0;
    l.marginWidth = 0;
    l.marginHeight = 0;
    l.verticalSpacing = 0;

    comp.setLayout(l);
    Browser browser = new Browser(comp, SWT.BORDER);
    browser.setText(getText(event));
    browser.setLayoutData(new GridData(200, 150));

    return comp;
}