Package tiled.mapeditor.util

Examples of tiled.mapeditor.util.TiledFileFilter


    {
        // Start at the location of the most recently loaded map file
        String startLocation =
                TiledConfiguration.node("recent").get("file0", null);

        TiledFileFilter byExtensionFilter =
                new TiledFileFilter(TiledFileFilter.FILTER_EXT);
        TiledFileFilter tmxFilter =
                new TiledFileFilter(TiledFileFilter.FILTER_TMX);

        JFileChooser chooser = new ConfirmingFileChooser(startLocation);
        chooser.setAcceptAllFileFilterUsed(false);
        chooser.addChoosableFileFilter(byExtensionFilter);
        chooser.addChoosableFileFilter(tmxFilter);

        MapWriter[] writers = editor.getPluginLoader().getWriters();
        for (int i = 0; i < writers.length; i++) {
            try {
                chooser.addChoosableFileFilter(new TiledFileFilter(writers[i]));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        chooser.setFileFilter(byExtensionFilter);

        int result = chooser.showSaveDialog(editor.getAppFrame());
        if (result == JFileChooser.APPROVE_OPTION)
        {
            savingCancelled = false;
            TiledFileFilter saver = (TiledFileFilter) chooser.getFileFilter();
            String selectedFile = chooser.getSelectedFile().getAbsolutePath();
            saveFile(saver, selectedFile);
        }
        else {
            savingCancelled = true;
View Full Code Here


        try {
            MapReader[] readers = editor.getPluginLoader().getReaders();
            for(int i = 0; i < readers.length; i++) {
                /*chooser.addChoosableFileFilter(new TiledFileFilter(
                            readers[i].getFilter(), readers[i].getName()));*/
              chooser.addChoosableFileFilter(new TiledFileFilter(readers[i]));
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(editor.getAppFrame(),
                    "Error while loading plugins: " + e.getLocalizedMessage(),
                    OPEN_ERROR_TITLE,
                    JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }

        chooser.addChoosableFileFilter(
                new TiledFileFilter(TiledFileFilter.FILTER_TMX));

        int ret = chooser.showOpenDialog(editor.getAppFrame());
        if (ret == JFileChooser.APPROVE_OPTION) {
            editor.loadMap(chooser.getSelectedFile().getAbsolutePath());
        }
View Full Code Here

        // todo: Fix the case where the plugin cannot be determined by the
        // todo: current filename. This can happen when the user has used
        // todo: "Save As" to save the file using a non-standard extension.
        if (filePath != null) {
            // The plugin is determined by the extention.
            saveFile(new TiledFileFilter(TiledFileFilter.FILTER_EXT),
                     filePath);
        }
        else {
            super.actionPerformed(e);
        }
View Full Code Here

            JFileChooser ch = new JFileChooser(map.getFilename());

            MapWriter[] writers = PluginClassLoader.getInstance().getWriters();
            for (int i = 0; i < writers.length; i++) {
                try {
                    ch.addChoosableFileFilter(new TiledFileFilter(
                                writers[i].getFilter(), writers[i].getName()));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            ch.addChoosableFileFilter
              (new TiledFileFilter(TiledFileFilter.FILTER_TSX));
            int ret = ch.showSaveDialog(this);
            if (ret == JFileChooser.APPROVE_OPTION) {
                String filename = ch.getSelectedFile().getAbsolutePath();
                if(filename.indexOf(".") == -1)
                  filename += "." + ((TiledFileFilter)ch.getFileFilter()).getDefaultExtension();
View Full Code Here

        JFileChooser ch = new JFileChooser(startLocation);

        try {
            MapReader[] readers = PluginClassLoader.getInstance().getReaders();
            for(int i = 0; i < readers.length; i++) {
                ch.addChoosableFileFilter(new TiledFileFilter(
                            readers[i].getFilter(), readers[i].getName()));
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this,
                    "Error while loading plugins: " + e.getMessage(),
                    "Error while loading map",
                    JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }

        ch.addChoosableFileFilter(
                new TiledFileFilter(TiledFileFilter.FILTER_TMX));

        int ret = ch.showOpenDialog(this);
        if (ret == JFileChooser.APPROVE_OPTION) {
            myBrush = new CustomBrush(
                    MapHelper.loadMap(ch.getSelectedFile().getAbsolutePath()));
View Full Code Here

           
          } else {
            //reference to an outside tileset? Hmm.
            JFileChooser ch = new JFileChooser();
            try {
          ch.addChoosableFileFilter(new TiledFileFilter(getFilter(), getName()));
        } catch (Exception e) {
          e.printStackTrace();
        }
       
        int ret = ch.showSaveDialog();
View Full Code Here

TOP

Related Classes of tiled.mapeditor.util.TiledFileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.