Example #1
0
 /**
  * @param syntax will contain Vis tags and attributes supporting extra form validators from {@link
  *     com.kotcrab.vis.ui.util.form.FormValidator} class.
  */
 public static void registerFileValidators(final LmlSyntax syntax) {
   // Validator tags:
   syntax.addTagProvider(
       new DirectoryValidatorLmlTagProvider(), "directoryValidator", "isDirectory");
   syntax.addTagProvider(
       new EmptyDirectoryContentValidatorLmlTagProvider(),
       "emptyDirectoryValidator",
       "isDirectoryEmpty");
   syntax.addTagProvider(new FileValidatorLmlTagProvider(), "fileValidator", "isFile");
   syntax.addTagProvider(
       new NotEmptyDirectoryContentValidatorLmlTagProvider(),
       "notEmptyDirectoryValidator",
       "isDirectoryNotEmpty");
   // FileExistsValidator attributes:
   syntax.addAttributeProcessor(new ErrorIfRelativeEmptyLmlAttribute(), "errorIfRelativeEmpty");
   syntax.addAttributeProcessor(new FileExistsLmlAttribute(), "exists");
   syntax.addAttributeProcessor(new RelativeToFileLmlAttribute(), "relativeTo");
 }
Example #2
0
  /**
   * @param syntax will contain Vis attributes and tags connected with {@link
   *     com.kotcrab.vis.ui.widget.file.FileChooser} widget.
   */
  public static void registerFileChooser(final LmlSyntax syntax) {
    // Simplified FileChooser attributes, allowing to quickly add a simple file chooser to any
    // widget:
    syntax.addAttributeProcessor(
        new AnyFileChooserLmlAttribute(), "fileAndDirectoryChooser", "anyFileChooser");
    syntax.addAttributeProcessor(new DirectoryChooserLmlAttribute(), "directoryChooser");
    syntax.addAttributeProcessor(new FileChooserLmlAttribute(), "fileChooser");

    // FileChooser tag:
    syntax.addTagProvider(new FileChooserLmlTagProvider(), "fileChooser");
    // FileChooser attributes:
    syntax.addAttributeProcessor(new DirectoryLmlAttribute(), "directory");
    syntax.addAttributeProcessor(
        new FileChooserListenerLmlAttribute(), "listener", "fileChooserListener");
    syntax.addAttributeProcessor(new FileDeleterLmlAttribute(), "fileDeleter");
    syntax.addAttributeProcessor(new FileFilterLmlAttribute(), "fileFilter");
    syntax.addAttributeProcessor(new GroupMultiSelectKeyLmlAttribute(), "groupMultiSelectKey");
    syntax.addAttributeProcessor(new IconProviderLmlAttribute(), "iconProvider");
    syntax.addAttributeProcessor(new ModeLmlAttribute(), "mode");
    syntax.addAttributeProcessor(new MultiSelectKeyLmlAttribute(), "multiSelectKey");
    syntax.addAttributeProcessor(new SelectionModeLmlAttribute(), "selectionMode", "select");
    syntax.addAttributeProcessor(
        new WatchFilesLmlAttribute(), "watchingFilesEnabled", "watchFiles", "watch");
    // Note: FileChooser#addFavorite(FileHandle) is not supported through LML attributes; this is a
    // design choice,
    // as it would be extremely awkward to use when registering multiple files. It would require a
    // lot of attributes
    // (for each file type), aliases/arrays parsing (for multiple files) or extra awkward syntax,
    // which might be
    // problematic or restricting in attributes. If you want to register attributes, use onCreate or
    // onClose
    // attributes, which allow you to get a reference to the FileChooser during parsing, and
    // register favorites
    // manually.
  }