/** Method to find and add the roots of the machine to the list. Called for WBFile.computer */ public void dispDrives() { // Fill window with root directories File[] f = File.listRoots(); for (int i = 0; i < f.length; i++) { WBFile tmpFile = new WBFile(scene, f[i]); fileSelector.addListElement(tmpFile); currDispFiles.add(tmpFile); tmpFile.setIcon("directory"); } lookInText.setText(" Computer"); }
/** * 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")); } }
public void Make(AbstractMTApplication mtApplication, String name) { /// Create map provider menu \\\ IFont font = FontManager.getInstance() .createFont(mtApplication, "SansSerif.Bold", 15, MTColor.WHITE, MTColor.WHITE); MTRoundRectangle mapMenu = new MTRoundRectangle(0, 0, 0, 220, 335, 20, 20, mtApplication); mapMenu.setFillColor(new MTColor(35, 35, 35, 180)); mapMenu.setStrokeColor(new MTColor(35, 35, 35, 180)); mapMenu.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f)); mapMenu.translateGlobal(new Vector3D(-mtApplication.width / 2f - 80, 0)); MTRectangle drawing = new MTRectangle(0, 0, 200, 200, mtApplication); StartTiamat.general.addChild(mapMenu); System.out.println("added menu"); float cellWidth = 155; float cellHeight = 40; MTColor cellFillColor = new MTColor(new MTColor(0, 0, 0, 210)); MTColor cellPressedFillColor = new MTColor(new MTColor(20, 20, 20, 220)); MTList list = new MTList(0, 0, 152, 4 * cellHeight + 4 * 3, mtApplication); list.setChildClip(null); list.setNoFill(true); list.setNoStroke(true); list.unregisterAllInputProcessors(); list.setAnchor(PositionAnchor.CENTER); list.setPositionRelativeToParent(mapMenu.getCenterPointLocal()); mapMenu.addChild(list); for (int i = 0; i < StartTiamat.functions.size(); i++) { Tiamat.Templates template = StartTiamat.functions.get(i); list.addListElement( this.createListCell( mtApplication, template.getName(), template.getFunction(), font, cellWidth, cellHeight, cellFillColor, cellPressedFillColor)); } ; MultiPurposeInterpolator in = new MultiPurposeInterpolator(0, 170, 700, 0.1f, 0.7f, 1); final Animation slideOut = new Animation("slide out animation", in, mapMenu); slideOut.addAnimationListener( new IAnimationListener() { public void processAnimationEvent(AnimationEvent ae) { float delta = ae.getCurrentStepDelta(); ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0)); switch (ae.getId()) { case AnimationEvent.ANIMATION_ENDED: doSlideIn = true; animationRunning = false; break; } } }); final Animation slideIn = new Animation("slide out animation", in, mapMenu); slideIn.addAnimationListener( new IAnimationListener() { public void processAnimationEvent(AnimationEvent ae) { float delta = -ae.getCurrentStepDelta(); ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0)); switch (ae.getId()) { case AnimationEvent.ANIMATION_ENDED: doSlideIn = false; animationRunning = false; break; } } }); mapMenu.unregisterAllInputProcessors(); mapMenu.registerInputProcessor(new TapProcessor(mtApplication, 50)); mapMenu.addGestureListener( TapProcessor.class, new IGestureEventListener() { public boolean processGestureEvent(MTGestureEvent ge) { if (((TapEvent) ge).getTapID() == TapEvent.BUTTON_CLICKED) { if (!animationRunning) { animationRunning = true; if (doSlideIn) { slideIn.start(); } else { slideOut.start(); } } } return false; } }); }