use of com.sldeditor.ui.widgets.ExternalGraphicFilter in project sldeditor by robward-scisys.
the class ExternalGraphicDetails method buttonPressed.
/**
* Button pressed.
*
* @param buttonExternal the button external
*/
@Override
public void buttonPressed(Component buttonExternal) {
JFileChooser fc = new JFileChooser();
if (externalURL != null) {
String filename = externalURL.toExternalForm();
SLDDataInterface sldData = SLDEditorFile.getInstance().getSLDData();
if (RelativePath.hasHost(externalURL)) {
if (sldData != null) {
File currentFile = sldData.getSLDFile();
if (currentFile != null) {
fc.setCurrentDirectory(currentFile.getParentFile());
}
}
} else {
File currentFile = ExternalFilenames.getFile(sldData, filename);
if (currentFile.exists()) {
fc.setCurrentDirectory(currentFile.getParentFile());
}
}
}
fc.addChoosableFileFilter(new ExternalGraphicFilter());
int returnVal = fc.showOpenDialog(buttonExternal);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
userSelectedFileURL(fc.getSelectedFile().toURI().toURL());
} catch (MalformedURLException e1) {
ConsoleManager.getInstance().exception(this, e1);
}
}
}
Aggregations