class SearchItemHandler extends MenuHandler {

  @Override
  public boolean onCreate(@NotNull ViewEditor editor,
                          @Nullable NlComponent parent,
                          @NotNull NlComponent newChild,
                          @NotNull InsertType type) {
    if (!super.onCreate(editor, parent, newChild, type)) {
      return false;
    }

    if (!type.equals(InsertType.CREATE)) {
      return true;
    }

    NlWriteCommandActionUtil.run(newChild, "", () -> {
      String value = editor.getMinSdkVersion().getApiLevel() < 11 ? "android.support.v7.widget.SearchView" : "android.widget.SearchView";
      // TODO: Adjust for correct namespace
      String namespace = editor.moduleDependsOnAppCompat() ? AUTO_URI : ANDROID_URI;
      newChild.setAttribute(namespace, "actionViewClass", value);
    });

    return true;
  }

}