예제 #1
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;
 }
예제 #2
0
  /**
   * Method that opens the currently selected file -- triggered by tapping the "Open" button or
   * finishing the tap+hold gesture
   */
  public void openSelected() {
    File file = currFile.getFile();
    if (!file.exists() && !FileSystemView.getFileSystemView().isDrive(currFile.getFile())) {
      scene
          .getGuiOverlay()
          .addChild(new WBErrorMessage(scene.getMTApplication(), "File does not exist!"));
    } else if (file.isDirectory()) {
      // Set whether the up button will disable when it reaches desktop
      if (currFile.isBelowComp()) stopAtDesktop = false;
      if (currFile == top || currFile.isDesktopLookIn()) stopAtDesktop = true;
      // Up should always be disabled when the back button stack is empty
      // and obviously if we are at the top
      if (prevDirs.size() == 0 && currFile == top) {
        currFile.setStrokeColor(new MTColor(0, 0, 0, 0));
        currFile.setNoFill(true);
        if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false);
      } else {
        prevDirs.push(currDir);
        changeDirectory(currFile);
        if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false);
        currFile.setStrokeColor(new MTColor(0, 0, 0, 0));
        currFile.setNoFill(true);
        // Disable up button if at top
        if (currFile == top) {
          upButton.setEnabled(false);
          upButton.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
                          + "noUpFolder.png"));
        } else {
          upButton.setEnabled(true);
          upButton.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
                          + "upFolder.png"));
        }
      }
    } else {
      // Add video

      if (videos.accept(file) && !file.isDirectory()) {

        MTMovieClip clip = new MTMovieClip(file.getPath(), new Vertex(20, 20, 0), scene);
        clip.setName(file.getName());
        clip.setUseDirectGL(true);
        clip.setHeightXYGlobal(300);
        clip.addGestureListener(DragProcessor.class, new InertiaDragAction());
        // scene.getLassoProcessor().addClusterable(clip); //make clip lasso-able
        scene.getCanvas().addChild(clip);
        System.out.println("Opening: " + file.getName() + ".");
        // Update settings
        // scene.updateSettings(clip);

        toggleFileChooser();
      }
      // Add image
      else if (images.accept(file) && !file.isDirectory()) {
        System.out.println("FileChooser: ImageLoad: " + MitocoScene.getImageload());
        if (MitocoScene.getImageload()) {
          PImage texture = scene.getMTApplication().loadImage(file.getPath());
          WBImage photo = new WBImage(texture, scene);
          photo.setName(file.getName());
          photo.setNoFill(true);
          photo.setNoStroke(true);
          photo.setDisplayCloseButton(true);
          photo.setHeightXYGlobal(300);
          photo.addGestureListener(DragProcessor.class, new InertiaDragAction());
          // scene.getLassoProcessor().addClusterable(photo); //make photo lasso-able
          scene.getCanvas().addChild(photo);
          MitocoScene.setImageload(false);
        } else {
          selectionPath = file.getPath();
        }
        toggleFileChooser();
        System.out.println("Opening: " + file.getName() + ".");
        // Update settings
        // scene.updateSettings(photo);

      }
      // Add xml
      else if (xml.accept(file) && !file.isDirectory()) {
        selectionPath = file.getPath();
        scene.drawXMLload(getSelectionPath());
        MitocoScene.setImageload(false);
        toggleFileChooser();
      } else if (pdf.accept(file) && !file.isDirectory()) {
        selectionPath = file.getPath();
        PDFViewer testpdf =
            new PDFViewer((MTApplication) (scene.getMTApplication()), "Test", selectionPath);
        scene.getCanvas().addChild(testpdf);
        testpdf.setVisible(true);
        testpdf.sendToFront();
        MitocoScene.setImageload(false);
        // scene.drawXMLload(getSelectionPath());
        toggleFileChooser();
      } else if (powerpoints.accept(file) && !file.isDirectory()) {
        /*
            		// Run powerpoint to image conversion thread.
        int numberOfSlides = 0;
        try{
        numberOfSlides = PowerpointToImageConverter.powerPointToImageConversion(file.getCanonicalPath());
        }catch(Exception e){}

        // Add powerpoint images to scene.
        ArrayList<File> slides = new ArrayList<File>();
        for(int i = 0; i < numberOfSlides; i++) {
        	slides.add(new File("slide-" + (i+1) + ".png"));
        }
            		WBSlideShow photo = new WBSlideShow(scene, slides);
                	photo.setName(file.getName());
                	photo.setNoFill(true);
                	photo.setNoStroke(true);
                	photo.setDisplayCloseButton(true);
                	photo.setHeightXYGlobal(300);
                	photo.addGestureListener(DragProcessor.class, new InertiaDragAction());
        			scene.getLassoProcessor().addClusterable(photo); //make photo lasso-able
        			scene.addToMediaLayer(photo);
                	*/
        selectionPath = file.getPath();
        // scene.drawXMLload(getSelectionPath());
        toggleFileChooser();
      }

      // FIXME see WBSlideShow and WBImage for needed changes
      // Add slideshow
      /*else if(file.length == 1 && file[0].isDirectory()){
      	//Remove all non-image files
      	File[] holder = file[0].listFiles();
      	ArrayList<File> dir = createArrayList(holder);
      	for(int index=0; index<dir.size(); index++) {
      		System.out.println("List contains: "+dir.get(index).getName());
      		if(!dir.get(index).canExecute()
             			|| !images.accept(dir.get(index))
             			|| dir.get(index).isDirectory()){
      			System.out.println("removing "+dir.get(index).getName());
      			dir.remove(index);
      		}
      	}
      	if(dir.size() > 0) {
         		WBSlideShow show = new WBSlideShow(scene.getApp(),dir);
         		scene.getMediaLayer().addChild(show);
         		show.setName(file[i].getName());
         		show.setNoFill(true);
         		show.setDisplayCloseButton(true);
         		show.setHeightXYGlobal(300);
         		show.addGestureListener(DragProcessor.class, new InertiaDragAction());
      		scene.getLassoProcessor().addClusterable(show); //make show lasso-able
             	System.out.println("Opening: " + file[i].getName() + ".");
             	//Update settings
             	scene.updateSettings(show);
      	}
      	else {
      		scene.getCanvas().addChild(new WBErrorMessage(scene,
      "There weren't any images in that folder!"));
      	}
      } */
      else {
        // Unreadable drive
        if (FileSystemView.getFileSystemView().isDrive(currFile.getFile())) {
          scene
              .getGuiOverlay()
              .addChild(new WBErrorMessage(scene.getMTApplication(), "Drive cannot be read from!"));
          currFile.setStrokeColor(new MTColor(0, 0, 0, 0));
          currFile.setNoFill(true);
          if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false);
        }
        // Unsupported file type
        else {
          scene
              .getGuiOverlay()
              .addChild(
                  new WBErrorMessage(scene.getMTApplication(), "Can't open file of that type!"));
        }
      }
    }
  }