use of pcgen.pluginmgr.messages.RequestOpenPlayerCharacterMessage in project pcgen by PCGen.
the class InitiativePlugin method fileOpen.
/**
* Handles the clicking of the <b>Add </b> button on the GUI.
*/
public void fileOpen() {
JFileChooser chooser = ImagePreview.decorateWithImagePreview(new JFileChooser());
File defaultFile = new File(PCGenSettings.getPcgDir());
if (defaultFile.exists()) {
chooser.setCurrentDirectory(defaultFile);
}
// TODO should probably handle zip pcg
String[] pcgs = { "pcg", "pcp" };
String[] init = { "gmi", "init" };
FileFilter ff = new FileNameExtensionFilter("Initiative Export", init);
chooser.addChoosableFileFilter(ff);
chooser.addChoosableFileFilter(new FileNameExtensionFilter("PCGen File", pcgs));
chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
chooser.setFileFilter(ff);
chooser.setMultiSelectionEnabled(true);
Cursor originalCursor = theView.getCursor();
theView.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int option = chooser.showOpenDialog(theView);
if (option == JFileChooser.APPROVE_OPTION) {
File[] pcFiles = chooser.getSelectedFiles();
for (File pcFile : pcFiles) {
if (PCGFile.isPCGenCharacterOrPartyFile(pcFile)) {
messageHandler.handleMessage(new RequestOpenPlayerCharacterMessage(this, pcFile, false));
//loadPCG(pcFiles[i]);
} else if (pcFile.toString().endsWith(".init") || pcFile.toString().endsWith(".gmi")) {
loadINIT(pcFile);
}
}
/* loop through selected files */
theView.refreshTable();
} else {
/* this means the file is invalid */
}
theView.setCursor(originalCursor);
}
use of pcgen.pluginmgr.messages.RequestOpenPlayerCharacterMessage in project pcgen by PCGen.
the class PCGTrackerPlugin method handleOpen.
/**
* Handles the clicking of the <b>Add</b> button on the GUI.
*/
public void handleOpen() {
File defaultFile = new File(PCGenSettings.getPcgDir());
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(defaultFile);
String[] pcgs = { FILENAME_PCG, FILENAME_PCP };
FileFilter ff = new FileNameExtensionFilter(LanguageBundle.getString("in_pcgen_file"), //$NON-NLS-1$
pcgs);
chooser.addChoosableFileFilter(ff);
chooser.setFileFilter(ff);
chooser.setMultiSelectionEnabled(true);
Component component = GMGenSystem.inst;
Cursor originalCursor = component.getCursor();
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int option = chooser.showOpenDialog(GMGenSystem.inst);
if (option == JFileChooser.APPROVE_OPTION) {
for (File selectedFile : chooser.getSelectedFiles()) {
if (PCGFile.isPCGenCharacterOrPartyFile(selectedFile)) {
messageHandler.handleMessage(new RequestOpenPlayerCharacterMessage(this, selectedFile, false));
}
}
} else {
/* this means the file is invalid */
}
GMGenSystem.inst.setCursor(originalCursor);
}
Aggregations