Exemplo n.º 1
0
  @SuppressWarnings("nls")
  private void setOrientation(int orientationAngle, Device device) {
    Point size = BrowserSimUtil.getSizeInDesktopPixels(device);
    Point browserSize;
    if (orientationAngle == SpecificPreferences.ORIENTATION_LANDSCAPE
        || orientationAngle == SpecificPreferences.ORIENTATION_LANDSCAPE_INVERTED) {
      browserSize = new Point(size.y, size.x);
    } else {
      browserSize = size;
    }

    Rectangle clientArea = BrowserSimUtil.getMonitorClientArea(skin.getShell().getMonitor());
    skin.setOrientationAndSize(orientationAngle, browserSize, resizableSkinSizeAdvisor);
    BrowserSimUtil.fixShellLocation(skin.getShell(), clientArea);
    getBrowser()
        .execute(
            "window.orientation = "
                + orientationAngle
                + ";"
                + "(function(){"
                + "var event = document.createEvent('Event');"
                + "event.initEvent('orientationchange', false, false);" // http://jsbin.com/azefow/6
                                                                        //
                                                                        // https://developer.mozilla.org/en/DOM/document.createEvent
                + "window.dispatchEvent(event);"
                + "if (typeof window.onorientationchange === 'function') {"
                + "window.onorientationchange(event);"
                + "}"
                + "})();");
  }
  public static void launchBrowserSim(String initialUrl) {
    Activator.getDefault().countLaunchEvent();
    List<String> parameters = new ArrayList<String>();

    parameters.add(NOT_STANDALONE);
    if (initialUrl != null) {
      parameters.add(initialUrl);
    }

    IVMInstall jvm = getSelectedVM();
    if (jvm == null) { // no suitable vm
      ExternalProcessLauncher.showErrorDialog(Messages.BrowserSim);
    } else {
      String jvmPath = jvm.getInstallLocation().getAbsolutePath();
      String jrePath =
          jvm.getInstallLocation().getAbsolutePath() + File.separator + "jre"; // $NON-NLS-1$

      List<String> bundles = getBundles();

      if (!ExternalProcessLauncher.isGTK2()
          || (!BrowserSimUtil.isJavaFxAvailable(jvmPath)
              && !BrowserSimUtil.isJavaFxAvailable(jrePath))) {
        bundles.add("org.jboss.tools.vpe.browsersim.javafx.mock"); // $NON-NLS-1$
      }

      ExternalProcessLauncher.launchAsExternalProcess(
          bundles,
          RESOURCES_BUNDLES,
          BROWSERSIM_CALLBACKS,
          BROWSERSIM_CLASS_NAME,
          parameters,
          Messages.BrowserSim,
          jvm);
    }
  }
 public IPadPageTitleStyledText(Composite parent, ImageList imageList) {
   super(parent, (IS_OSX ? SWT.MULTI : SWT.SINGLE) | SWT.WRAP);
   setBackgroundImage(imageList.getImage(BD + "page-title-background.png"));
   setEditable(false);
   setEnabled(false);
   setMargins(16, IS_OSX ? 7 : 6, 16, 0);
   setAlignment(SWT.CENTER);
   setLineSpacing(27);
   font = createFont(this.getDisplay(), SWT.BOLD);
   setFont(font);
   BrowserSimUtil.addDisposeListener(this, font);
   foregroundColor = new Color(this.getDisplay(), 64, 64, 64);
   setForeground(foregroundColor);
   BrowserSimUtil.addDisposeListener(this, foregroundColor);
 }
Exemplo n.º 4
0
  private void setSelectedDevice(Boolean refreshRequired) {
    final Device device =
        commonPreferences.getDevices().get(specificPreferences.getSelectedDeviceId());
    if (device == null) {
      skin.getShell().close();
    } else {
      Class<? extends BrowserSimSkin> newSkinClass =
          BrowserSimUtil.getSkinClass(device, specificPreferences.getUseSkins());
      String oldSkinUrl = null;
      if (newSkinClass != skin.getClass()) {
        oldSkinUrl = skin.getBrowser().getUrl();
        Point currentLocation = skin.getShell().getLocation();
        skin.getBrowser().removeProgressListener(progressListener);
        skin.getBrowser().getShell().dispose();
        initSkin(newSkinClass, currentLocation);
        fireSkinChangeEvent();
      }
      setOrientation(specificPreferences.getOrientationAngle(), device);

      skin.getBrowser().setDefaultUserAgent(device.getUserAgent());

      if (oldSkinUrl != null) {
        skin.getBrowser().setUrl(oldSkinUrl); // skin (and browser instance) is changed
      } else if (!Boolean.FALSE.equals(refreshRequired)) {
        getBrowser()
            .refresh(); // only user agent and size of the browser is changed and orientation is not
                        // changed
      }

      skin.getShell().open();
    }
  }
Exemplo n.º 5
0
  public void open(SpecificPreferences sp, String url) {
    if (url == null) {
      url = homeUrl;
    }

    specificPreferences = sp;
    initObservers();
    Device defaultDevice =
        commonPreferences.getDevices().get(specificPreferences.getSelectedDeviceId());
    if (defaultDevice == null) {
      System.out.println("Could not find selected device in devices list");
      String id;
      try {
        id = commonPreferences.getDevices().keySet().iterator().next();
      } catch (NoSuchElementException e) {
        commonPreferences = CommonPreferencesStorage.INSTANCE.loadDefault();
        id = commonPreferences.getDevices().keySet().iterator().next();
      }
      specificPreferences.setSelectedDeviceId(id);
      defaultDevice = commonPreferences.getDevices().get(id);
    }

    initSkin(
        BrowserSimUtil.getSkinClass(defaultDevice, specificPreferences.getUseSkins()),
        specificPreferences.getLocation());
    setSelectedDevice(null);
    controlHandler.goToAddress(url);

    instances.add(BrowserSim.this);
    skin.getShell().open();
  }
Exemplo n.º 6
0
 public void reinitSkin() {
   final Device device =
       commonPreferences.getDevices().get(specificPreferences.getSelectedDeviceId());
   Class<? extends BrowserSimSkin> newSkinClass =
       BrowserSimUtil.getSkinClass(device, specificPreferences.getUseSkins());
   String oldSkinUrl = skin.getBrowser().getUrl();
   Point currentLocation = skin.getShell().getLocation();
   skin.getBrowser().removeProgressListener(progressListener);
   skin.getBrowser().getShell().dispose();
   initSkin(newSkinClass, currentLocation);
   setOrientation(specificPreferences.getOrientationAngle(), device);
   skin.getBrowser().setDefaultUserAgent(device.getUserAgent());
   skin.getBrowser().setUrl(oldSkinUrl);
   skin.getShell().open();
 }