Пример #1
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();
    }
  }
Пример #2
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();
 }