Exemplo n.º 1
0
 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$
     }
   }
 }
Exemplo n.º 2
0
  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$
      }
    }
  }
Exemplo n.º 3
0
  /** *************************************************************** */
  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;
  }
Exemplo n.º 4
0
 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$
   }
 }
Exemplo n.º 5
0
 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$;
     }
   }
 }
Exemplo n.º 6
0
  /** 调用js方法设置数据* */
  @SuppressWarnings("unchecked")
  private void init() {
    String currentValue = this.currentProp.getValue();
    String[] valueItems = currentValue.split(" ");
    Set<String> set = new HashSet<String>();
    for (String valueItem : valueItems) {
      set.add(valueItem);
    }
    Element staticData = currentProp.getDlgEditorConfig().element("static-data");
    StringBuffer sbf = new StringBuffer();
    if (staticData != null) {
      List<Element> eList = (currentProp.getDlgEditorConfig().element("static-data")).elements();
      for (Element e : eList) {
        List<Element> itemList = e.elements();
        StringBuffer itemsbf = new StringBuffer();
        boolean isSelected = set.contains(e.attributeValue("name"));
        for (Element item : itemList) {
          String selected = "";
          String name = item.attributeValue("name");
          if (isSelected && set.contains(name)) {
            selected = "checked:'checked',";
            set.remove(name);
          }
          itemsbf.append(
              ",{"
                  + selected
                  + "name:'"
                  + name
                  + "',label:'"
                  + item.attributeValue("label")
                  + "',isDefault:'"
                  + item.attributeValue("is-default")
                  + "'}");
        }
        String selected = "";
        String name = e.attributeValue("name");
        if (set.contains(name)) {
          selected = "checked:'checked',";
          set.remove(name);
        }
        sbf.append(
            ",{"
                + selected
                + "name:'"
                + name
                + "',label:'"
                + e.attributeValue("label")
                + "',items:["
                + itemsbf.toString()
                + "]}");
      }
    }
    Element e =
        ((XuiDataModel) this.currentProp.getOwerElement().getDataModel())
            .getConfig()
            .getCommonEditor("classList"); // 公共class
    String value = e.element("static-data").attributeValue("value");
    if (value != null) {
      String[] items = value.split(",");
      for (String item : items) {
        set.remove(item.split(":")[0]);
      }
    }

    String cusValue = "";
    for (String s : set) {
      cusValue += " " + s;
    }

    browser.execute(
        "init('"
            + currentValue
            + "',\"["
            + sbf.toString()
            + "]\",'"
            + cusValue.trim()
            + "','"
            + value
            + "');");
  }
Exemplo n.º 7
0
 public Object getReturnValue() {
   browser.execute("getValue();");
   Map<String, String> map = new HashMap<String, String>();
   map.put(this.currentProp.getName(), value);
   return map;
 }
 private void execute(String function, Object... arguments) {
   browser.execute(buildFunctionCall(function, arguments));
 }
Exemplo n.º 9
0
 public static void disableAlert(Browser browser) {
   browser.execute("window.alert = function() {};"); // $NON-NLS-1$
 }