use of org.csstudio.trends.databrowser3.propsheet.AddAxisCommand in project org.csstudio.display.builder by kasemir.
the class SampleImportAction method run.
@Override
public void run() {
// Prompt for file
final IPath path = SingleSourcePlugin.getUIHelper().openDialog(shell, SWT.OPEN, null, "*", NLS.bind(Messages.ImportActionFileSelectorTitleFmt, description));
if (path == null)
return;
try {
// Add to first empty axis, or create new axis
final AxisConfig axis = model.getEmptyAxis().orElseGet(() -> new AddAxisCommand(op_manager, model).getAxis());
// Add archivedatasource for "import:..." and let that load the file
final String url = ImportArchiveReaderFactory.createURL(type, path.toString());
final ArchiveDataSource imported = new ArchiveDataSource(url, 1, type);
// Add PV Item with data to model
AddModelItemCommand.forPV(shell, op_manager, model, type, Preferences.getScanPeriod(), axis, imported);
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
}
}
use of org.csstudio.trends.databrowser3.propsheet.AddAxisCommand in project org.csstudio.display.builder by kasemir.
the class AddPVAction method runWithSuggestedName.
/**
* Run the 'add PV' dialog with optional defaults
* @param name Suggested PV name, for example from drag-n-drop
* @param archive Archive data source for the new PV
* @return <code>true</code> if PV name was added, <code>false</code> if canceled by user
*/
public boolean runWithSuggestedName(final String name, final ArchiveDataSource archive) {
// Prompt for PV name
final AddPVDialog dlg = new AddPVDialog(shell, 1, model, formula);
dlg.setName(0, name);
if (dlg.open() != Window.OK)
return false;
// Did user select axis?
final AxisConfig axis;
if (dlg.getAxisIndex(0) >= 0)
axis = model.getAxis(dlg.getAxisIndex(0));
else
// Use first empty axis, or create a new one
axis = model.getEmptyAxis().orElseGet(() -> new AddAxisCommand(operations_manager, model).getAxis());
// Create item
if (formula) {
final Optional<AddModelItemCommand> command = AddModelItemCommand.forFormula(shell, operations_manager, model, dlg.getName(0), axis);
if (!command.isPresent())
return false;
// Open configuration dialog
final FormulaItem formula = (FormulaItem) command.get().getItem();
final EditFormulaDialog edit = new EditFormulaDialog(operations_manager, shell, formula);
edit.open();
} else
AddModelItemCommand.forPV(shell, operations_manager, model, dlg.getName(0), dlg.getScanPeriod(0), axis, archive);
return true;
}
Aggregations