@Override
  public void setValue(Object value) {
    setValueGeneric(value);
    if (isSetValueDone()) {
      return;
    }

    if (value == null) {
      textNode.setText(null);
      return;
    }
    assert value instanceof String;
    String val = (String) value;
    PrefixedValue prefixedValue = new PrefixedValue(val);
    String suffix = prefixedValue.getSuffix();

    // Handle i18n
    if (prefixedValue.isResourceKey()) {
      if (!i18nMode) {
        wrapInHBox();
        i18nMode = true;
      }
    } else if (i18nMode) {
      // no percent + i18nMode
      unwrapHBox();
      i18nMode = false;
    }

    // Handle multi-line
    if (containsLineFeed(prefixedValue.toString())) {
      if (i18nMode) {
        // multi-line + i18n ==> set as i18n only
        multiLineMode = false;
        switchToTextField();
      } else {
        if (!multiLineMode) {
          multiLineMode = true;
          switchToTextArea();
        }
      }
    } else {
      // no line feed
      if (multiLineMode) {
        multiLineMode = false;
        switchToTextField();
      }
    }

    if (i18nMode) {
      textNode.setText(suffix);
    } else {
      // We may have other special characters (@, $, ...) to display in the text field
      textNode.setText(prefixedValue.toString());
    }
    updateMenuItems();
  }
 @Override
 public void setValue(String styleSheet) {
   PrefixedValue prefixedValue = new PrefixedValue(styleSheet);
   itemType = prefixedValue.getType();
   handlePrefix(itemType);
   if (prefixedValue.getSuffix() != null) {
     stylesheetTf.setText(prefixedValue.getSuffix().trim());
   } else {
     // may happen if wrong style sheet
     stylesheetTf.setText(""); // NOI18N
   }
   updateButtons();
   updateOpenRevealMenuItems();
   currentValue = getValue();
 }
  @FXML
  void chooseStylesheet(ActionEvent event) {

    String[] extensions = {"*.css"}; // NOI18N
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(I18N.getString("inspector.select.css.title"));
    fileChooser
        .getExtensionFilters()
        .add(
            new FileChooser.ExtensionFilter(
                I18N.getString("inspector.select.css.filter"), Arrays.asList(extensions)));
    File file = fileChooser.showOpenDialog(root.getScene().getWindow());
    if ((file == null)) {
      return;
    }
    URL url;
    try {
      url = file.toURI().toURL();
    } catch (MalformedURLException ex) {
      throw new RuntimeException("Invalid URL", ex); // NOI18N
    }
    if (alreadyUsed(url.toExternalForm())) {
      System.err.println(
          I18N.getString("inspector.stylesheet.alreadyexist", url)); // should go to message panel
      return;
    }

    switchToItemList();
    // Add editor item
    String urlStr;
    if (fxmlFileLocation != null) {
      // If the document exists, make the type as document relative by default.
      urlStr = PrefixedValue.makePrefixedValue(url, fxmlFileLocation).toString();
      switchType(Type.DOCUMENT_RELATIVE_PATH);
    } else {
      urlStr = url.toExternalForm();
      switchType(Type.PLAIN_STRING);
    }
    addItem(new StylesheetItem(this, urlStr));

    // Workaround for RT-34863: Reload of an updated css file has no effect.
    // This reset the whole CSS from top. Would need to be moved on the FXOM side.
    Deprecation.reapplyCSS(root.getScene());

    userUpdateValueProperty(getValue());
  }
 private void switchType(Type type) {
   this.type = type;
   updateMenuItems();
   for (EditorItem editorItem : getEditorItems()) {
     assert editorItem instanceof StylesheetItem;
     StylesheetItem stylesheetItem = (StylesheetItem) editorItem;
     URL url = EditorUtils.getUrl(stylesheetItem.getValue(), fxmlFileLocation);
     String value = null;
     if ((url == null) || (type == Type.CLASSLOADER_RELATIVE_PATH)) {
       // In this case we empty the text field (i.e. suffix) content
       value = new PrefixedValue(type, "").toString(); // NOI18N
     } else if (type == Type.PLAIN_STRING) {
       value = url.toExternalForm();
     } else if (type == Type.DOCUMENT_RELATIVE_PATH) {
       value = PrefixedValue.makePrefixedValue(url, fxmlFileLocation).toString();
     }
     stylesheetItem.setValue(value);
     commit(stylesheetItem);
   }
 }