private void addControls() {
    int right = _application.getWidth();
    int bottom = _application.getHeight();

    addTextArea();

    SceneUtilities.addButton(
        this,
        "images/backButton.png",
        new Vector3D(60, bottom - 35),
        new TapAction() {
          @Override
          public void onTap() {
            _application.popScene();
          }
        });
    _okButton =
        SceneUtilities.addButton(
            this,
            "images/okButton.png",
            new Vector3D(right / 2, bottom - bottom / 3),
            new TapAction() {
              @Override
              public void onTap() {
                acceptPayment();
              }
            });
    _okButton.setEnabled(false);
  }
Beispiel #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!"));
        }
      }
    }
  }
Beispiel #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"));
    }
  }