Search in sources :

Example 1 with AddAxisCommand

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);
    }
}
Also used : AddAxisCommand(org.csstudio.trends.databrowser3.propsheet.AddAxisCommand) IPath(org.eclipse.core.runtime.IPath) AxisConfig(org.csstudio.trends.databrowser3.model.AxisConfig) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource)

Example 2 with AddAxisCommand

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;
}
Also used : AddAxisCommand(org.csstudio.trends.databrowser3.propsheet.AddAxisCommand) FormulaItem(org.csstudio.trends.databrowser3.model.FormulaItem) AxisConfig(org.csstudio.trends.databrowser3.model.AxisConfig) EditFormulaDialog(org.csstudio.trends.databrowser3.propsheet.EditFormulaDialog)

Aggregations

AxisConfig (org.csstudio.trends.databrowser3.model.AxisConfig)2 AddAxisCommand (org.csstudio.trends.databrowser3.propsheet.AddAxisCommand)2 ArchiveDataSource (org.csstudio.trends.databrowser3.model.ArchiveDataSource)1 FormulaItem (org.csstudio.trends.databrowser3.model.FormulaItem)1 EditFormulaDialog (org.csstudio.trends.databrowser3.propsheet.EditFormulaDialog)1 IPath (org.eclipse.core.runtime.IPath)1