use of org.phoebus.ui.dialog.OpenFileDialog in project phoebus by ControlSystemStudio.
the class SampleImportAction method run.
private void run() {
// Prompt for file
final File the_file = new OpenFileDialog().promptForFile(getParentPopup().getOwnerWindow(), Messages.ImportTitle, null, null);
if (the_file == null)
return;
try {
// Add to first empty axis, or create new axis
final AxisConfig axis = model.getEmptyAxis().orElseGet(() -> new AddAxisCommand(op_manager, model).getAxis());
// Data source for "import:..." will load the file
final String url = ImportArchiveReaderFactory.createURL(type, the_file.toString());
final ArchiveDataSource imported = new ArchiveDataSource(url, type);
// Add PV Item with data to model
AddModelItemCommand.forPV(op_manager, model, type, Preferences.scan_period, axis, imported);
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(Messages.Error, "Cannot import " + the_file, ex);
}
}
use of org.phoebus.ui.dialog.OpenFileDialog in project phoebus by ControlSystemStudio.
the class OpenAbout method import_preferences.
/**
* Prompt for settings.ini to import, then offer restart
*/
private void import_preferences() {
final DockPane parent = DockPane.getActiveDockPane();
final ExtensionFilter[] ini = new ExtensionFilter[] { new ExtensionFilter("Preference settings.ini", List.of("*.ini")) };
final File file = new OpenFileDialog().promptForFile(parent.getScene().getWindow(), Messages.Open, null, ini);
if (file == null)
return;
JobManager.schedule("Load preferences", monitor -> {
PropertyPreferenceLoader.load(new FileInputStream(file));
Platform.runLater(() -> {
final Alert restart = new Alert(AlertType.CONFIRMATION);
restart.setHeaderText("Restart to activate loaded settings");
restart.setContentText("For performance reasons, preference settings are only loaded once on startup.\n" + "Exit application so you can then start it again?");
restart.getDialogPane().setPrefSize(500, 300);
restart.setResizable(true);
DialogHelper.positionDialog(restart, parent, -400, -300);
if (restart.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK)
System.exit(0);
});
});
}
use of org.phoebus.ui.dialog.OpenFileDialog in project phoebus by ControlSystemStudio.
the class PhoebusApplication method fileOpen.
/**
* Open file dialog to open a resource
*
* @param stage Parent stage
* @param prompt Prompt for application (if there are multiple options), or use default app?
*/
private void fileOpen(final Stage stage, final boolean prompt) {
final File the_file = new OpenFileDialog().promptForFile(stage, Messages.Open, last_opened_file, null);
if (the_file == null)
return;
last_opened_file = the_file;
openResource(ResourceParser.getURI(the_file), prompt);
}
use of org.phoebus.ui.dialog.OpenFileDialog in project phoebus by ControlSystemStudio.
the class FileUtil method openFileDialog.
/**
*Open a file select dialog.
* @param inWorkspace true if it is a workspace file dialog; Otherwise, it is a local
* file system file dialog.
* @return the full file path. Or null if it is cancelled.
*/
public static String openFileDialog(boolean inWorkspace) {
final Window window = null;
File selected = new OpenFileDialog().promptForFile(window, "Open File", null, null);
if (selected == null)
return null;
return selected.getPath();
}
use of org.phoebus.ui.dialog.OpenFileDialog in project phoebus by ControlSystemStudio.
the class LoadModelAction method run.
@Override
public void run(final DisplayEditor ignored, final boolean selected) {
File file = new OpenFileDialog().promptForFile(window, Messages.LoadDisplay, editor.getFile(), FilenameSupport.file_extensions);
if (file == null)
return;
file = FileExtensionUtil.enforceFileExtension(file, DisplayModel.FILE_EXTENSION);
editor.loadModel(file);
}
Aggregations