de.invation.code.toval.misc.wd.NewWorkingDirectoryAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TOVAL Show documentation
Show all versions of TOVAL Show documentation
TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.
The newest version!
package de.invation.code.toval.misc.wd;
import de.invation.code.toval.debug.SimpleDebugger;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.JFileChooser;
/**
*
* @author stocker
*/
public class NewWorkingDirectoryAction extends AbstractWorkingDirectoryAction {
private static final long serialVersionUID = 3421975574956233676L;
public NewWorkingDirectoryAction(Window parentWindow, AbstractWorkingDirectoryProperties properties) {
this(parentWindow, properties, null);
}
public NewWorkingDirectoryAction(Window parentWindow, AbstractWorkingDirectoryProperties properties, SimpleDebugger debugger) {
super(parentWindow, "New Directory", properties, debugger);
}
@Override
public void actionProcedure(ActionEvent e) throws Exception {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Choose location for new " + properties.getWorkingDirectoryDescriptor().toLowerCase());
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fileChooser.showOpenDialog(parent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
String directoryLocation = file.getAbsolutePath();
File dir = new File(directoryLocation + "/" + properties.getDefaultWorkingDirectoryName());
if (dir.exists()) {
int count = 1;
while ((dir = new File(directoryLocation + "/" + properties.getDefaultWorkingDirectoryName() + count)).exists()) {
count++;
}
}
dir.mkdir();
String workingDirectory = dir.getAbsolutePath() + "/";
addKnownWorkingDirectory(workingDirectory, true);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy