Search in sources :

Example 1 with OpenFileDialog

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);
    }
}
Also used : AddAxisCommand(org.csstudio.trends.databrowser3.ui.properties.AddAxisCommand) AxisConfig(org.csstudio.trends.databrowser3.model.AxisConfig) OpenFileDialog(org.phoebus.ui.dialog.OpenFileDialog) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) File(java.io.File)

Example 2 with OpenFileDialog

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);
        });
    });
}
Also used : DockPane(org.phoebus.ui.docking.DockPane) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) OpenFileDialog(org.phoebus.ui.dialog.OpenFileDialog) Alert(javafx.scene.control.Alert) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with OpenFileDialog

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);
}
Also used : OpenFileDialog(org.phoebus.ui.dialog.OpenFileDialog) File(java.io.File)

Example 4 with OpenFileDialog

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();
}
Also used : Window(javafx.stage.Window) OpenFileDialog(org.phoebus.ui.dialog.OpenFileDialog) File(java.io.File)

Example 5 with OpenFileDialog

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);
}
Also used : OpenFileDialog(org.phoebus.ui.dialog.OpenFileDialog) File(java.io.File)

Aggregations

File (java.io.File)5 OpenFileDialog (org.phoebus.ui.dialog.OpenFileDialog)5 FileInputStream (java.io.FileInputStream)1 Alert (javafx.scene.control.Alert)1 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)1 Window (javafx.stage.Window)1 ArchiveDataSource (org.csstudio.trends.databrowser3.model.ArchiveDataSource)1 AxisConfig (org.csstudio.trends.databrowser3.model.AxisConfig)1 AddAxisCommand (org.csstudio.trends.databrowser3.ui.properties.AddAxisCommand)1 DockPane (org.phoebus.ui.docking.DockPane)1