All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.ide.common.DirectoryModelCN Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.ide.common;

import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;

import javax.swing.JFileChooser;
import javax.swing.plaf.basic.BasicDirectoryModel;

import com.scudata.dm.Env;

/**
 * Used to support file names sorted by language.
 *
 */
class DirectoryModelCN extends BasicDirectoryModel {

	private static final long serialVersionUID = 1L;

	/**
	 * Constructor
	 * 
	 * @param filechooser
	 */
	public DirectoryModelCN(JFileChooser filechooser) {
		super(filechooser);
	}

	/**
	 * Sort file names
	 */
	protected void sort(Vector v) {
		int l = v.size();
		if (l < 2)
			return;
		Collections.sort(v, new Comparator() {

			public int compare(File o1, File o2) {
				return Env.getCollator().compare(getName(o1), getName(o2));
			}

		});
	}

	/**
	 * Get file name/path
	 * 
	 * @param f
	 * @return
	 */
	private String getName(File f) {
		if (f.isDirectory()) {
			return f.getPath();
		} else {
			return f.getName();
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy