Exemple #1
0
 /**
  * Method to set filter to be used and takes in to account the possibility of not finishing the
  * tap+hold gesture.
  *
  * @param filter
  */
 public void setFileFilter(WBFileFilter filter) {
   if (currFilter == null) currFilter = filter;
   if (currSelectedFilter != currFilter && currSelectedFilter != null) {
     currSelectedFilter.setStrokeColor(new MTColor(0, 0, 0, 0));
     currSelectedFilter.setNoFill(true);
   }
   if (currFilter != filter) {
     currFilter = filter;
   }
 }
Exemple #2
0
 /** Method to refresh the file list when a new filter is selected. */
 public void refreshDirectory() {
   changeDirectory(currDir);
   typeText.setText(currFilter.getTextBox().getText());
   if (currFilter.isNoFill()) {
     currFilter.setNoFill(false);
     currFilter.setStrokeColor(new MTColor(0, 0, 0, 150));
     currFilter.setStrokeWeight(2);
     currFilter.setNoStroke(false);
   }
   types.setVisible(false);
   typesShown = false;
 }
Exemple #3
0
  /**
   * Method to remove all currently displayed files and show the specified directory's contents
   *
   * @param dir
   */
  public void changeDirectory(WBFile dir) {
    for (WBFile target : currDispFiles) {
      fileSelector.removeListElement(target);
    }
    if (dir.isComputer()) {
      dispDrives();
      currDir = dir;
      currLookInIcon.setTexture(
          scene
              .getMTApplication()
              .loadImage(
                  System.getProperty("user.dir")
                      + File.separator
                      + "ktsi"
                      + File.separator
                      + "ch"
                      + File.separator
                      + "mitoco"
                      + File.separator
                      + "data"
                      + File.separator
                      + "filechooser"
                      + File.separator
                      + "computer.png"));
    } else {
      // Fill window with directory contents
      if (dir.getFile().getPath() != null) {
        if (dir.getFile().isDirectory()) {
          boolean allFiles = false;
          if (currFilter.getFilter() == null) allFiles = true;
          ArrayList<File> list = new ArrayList<File>(Arrays.asList(dir.getFile().listFiles()));
          int target = 0;
          int size = list.size();
          // First add directories
          for (int i = 0; i < size; i++) {
            if (list.get(target).isDirectory()) {
              WBFile tmpDir = new WBFile(scene, list.get(target));
              fileSelector.addListElement(tmpDir);
              tmpDir.setIcon("directory");
              currDispFiles.add(tmpDir);
              list.remove(list.get(target));
            } else target++;
          }

          target = 0;
          size = list.size();
          // Then add images
          if (allFiles || currFilter.getFilter() == images) {
            for (int i = 0; i < size; i++) {
              if (images.accept(list.get(target))) {
                WBFile tmpImage = new WBFile(scene, list.get(target));
                fileSelector.addListElement(tmpImage);
                tmpImage.setIcon("image");
                currDispFiles.add(tmpImage);
                list.remove(list.get(target));
              } else target++;
            }
          }

          target = 0;
          size = list.size();
          // Then add videos
          if (allFiles || currFilter.getFilter() == videos) {
            for (int i = 0; i < size; i++) {
              if (videos.accept(list.get(target))) {
                WBFile tmpMovie = new WBFile(scene, list.get(target));
                fileSelector.addListElement(tmpMovie);
                tmpMovie.setIcon("video");
                currDispFiles.add(tmpMovie);
                list.remove(list.get(target));
              } else target++;
            }
          }
          target = 0;
          size = list.size();
          if (allFiles || currFilter.getFilter() == xml) {
            for (int i = 0; i < size; i++) {
              if (xml.accept(list.get(target))) {
                WBFile tmpXml = new WBFile(scene, list.get(target));
                fileSelector.addListElement(tmpXml);
                tmpXml.setIcon("xml");
                currDispFiles.add(tmpXml);
                list.remove(list.get(target));
              } else target++;
            }
          }

          target = 0;
          size = list.size();
          if (allFiles || currFilter.getFilter() == pdf) {
            for (int i = 0; i < size; i++) {
              if (pdf.accept(list.get(target))) {
                WBFile tmpPdf = new WBFile(scene, list.get(target));
                fileSelector.addListElement(tmpPdf);
                tmpPdf.setIcon("pdf");
                currDispFiles.add(tmpPdf);
                list.remove(list.get(target));
              } else target++;
            }
          }

          if (allFiles) {
            for (File file : list) {
              WBFile tmpFile = new WBFile(scene, file);
              fileSelector.addListElement(tmpFile);
              tmpFile.setIcon("");
              currDispFiles.add(tmpFile);
            }
          }
        }
        currDir = dir;
        // File system root
        if (currDir.getFile().getParent() == null) {
          lookInText.setText("     " + currDir.getFile().getAbsolutePath());
          currLookInIcon.setTexture(
              scene
                  .getMTApplication()
                  .loadImage(
                      System.getProperty("user.dir")
                          + File.separator
                          + "ktsi"
                          + File.separator
                          + "ch"
                          + File.separator
                          + "mitoco"
                          + File.separator
                          + "data"
                          + File.separator
                          + "filechooser"
                          + File.separator
                          + "drive.png"));
        }
        // Top desktop
        else if (stopAtDesktop
            && currDir.getFile().getPath().toString().compareTo(top.getFile().getPath().toString())
                == 0) {
          lookInText.setText("     " + currDir.getName());
          currLookInIcon.setTexture(
              scene
                  .getMTApplication()
                  .loadImage(
                      System.getProperty("user.dir")
                          + File.separator
                          + "ktsi"
                          + File.separator
                          + "ch"
                          + File.separator
                          + "mitoco"
                          + File.separator
                          + "data"
                          + File.separator
                          + "filechooser"
                          + File.separator
                          + "desktop.png"));
        }
        // Normal desktop
        else {
          lookInText.setText("     " + currDir.getName());
          currLookInIcon.setTexture(
              scene
                  .getMTApplication()
                  .loadImage(
                      System.getProperty("user.dir")
                          + File.separator
                          + "ktsi"
                          + File.separator
                          + "ch"
                          + File.separator
                          + "mitoco"
                          + File.separator
                          + "data"
                          + File.separator
                          + "filechooser"
                          + File.separator
                          + "folder.png"));
        }
      }
    }
    // Enable back button
    if (prevDirs.size() == 1) { // Minimize the times the image is loaded
      backButton.setEnabled(true);
      backButton.setTexture(
          scene
              .getMTApplication()
              .loadImage(
                  System.getProperty("user.dir")
                      + File.separator
                      + "ktsi"
                      + File.separator
                      + "ch"
                      + File.separator
                      + "mitoco"
                      + File.separator
                      + "data"
                      + File.separator
                      + "filechooser"
                      + File.separator
                      + "back.png"));
    }
  }