Skip to content

Commit

Permalink
Merge pull request ControlSystemStudio#3000 from ControlSystemStudio/…
Browse files Browse the repository at this point in the history
…CSSTUDIO-2072

CSSTUDIO-2072 Modified and extended functionality to paste several PV names (with an optional display name) into the Data Browser
  • Loading branch information
abrahamwolk authored Nov 21, 2024
2 parents a2e804d + 652952d commit 30cc0f5
Show file tree
Hide file tree
Showing 15 changed files with 360 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@
******************************************************************************/
package org.csstudio.trends.databrowser3;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import javafx.scene.Node;
import javafx.scene.control.DialogPane;
import javafx.scene.control.ScrollPane;
import javafx.stage.Window;
import javafx.util.Pair;
import org.csstudio.trends.databrowser3.model.AxisConfig;
import org.csstudio.trends.databrowser3.model.Model;
import org.csstudio.trends.databrowser3.ui.AddModelItemCommand;
import org.csstudio.trends.databrowser3.ui.AddPVDialog;
import org.phoebus.framework.jobs.NamedThreadFactory;
import org.phoebus.ui.dialog.DialogHelper;
import org.phoebus.ui.javafx.ImageCache;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.phoebus.ui.undo.UndoableActionManager;

/** Global Data Browser helper
* @author Kay Kasemir
Expand Down Expand Up @@ -71,6 +86,53 @@ public static ImageView getIcon(final String base_name)
return new ImageView(getImage(base_name));
}

public static void addPVsToPlotDialog(List<String> pvNames,
UndoableActionManager undoableActionManager,
Model model,
Node nodeToPositionDialogOver)
{
// Offer potential PV name in dialog so user can edit/cancel
// sim://sine sim://ramp sim://noise
AddPVDialog addPVDialog = new AddPVDialog(pvNames.size(), model, false);

{ // Set layout of addPVDialog:
int addPVDialogWidth = 750;
int addPVDialogHeight = 600;

Window addPVDialowWindow = addPVDialog.getDialogPane().getScene().getWindow();
addPVDialowWindow.setWidth(addPVDialogWidth);
addPVDialowWindow.setHeight(addPVDialogHeight);
addPVDialog.setResizable(false);

DialogPane dialogPane = addPVDialog.getDialogPane();
dialogPane.setPrefWidth(addPVDialogWidth);
dialogPane.setPrefHeight(addPVDialogHeight);
dialogPane.setMaxWidth(Double.MAX_VALUE);
dialogPane.setMaxHeight(Double.MAX_VALUE);

DialogHelper.positionDialog(addPVDialog, nodeToPositionDialogOver, (int) -addPVDialowWindow.getWidth()/2, (int) -addPVDialowWindow.getHeight()/2);
}

for (int i=0; i<pvNames.size(); ++i) {
addPVDialog.setNameAndDisplayName(i, pvNames.get(i));
}

if (!addPVDialog.showAndWait().orElse(false)) {
return;
}

for (int i=0; i<pvNames.size(); ++i) {
AxisConfig axis = addPVDialog.getOrCreateAxis(model, undoableActionManager, addPVDialog.getAxisIndex(i));
AddModelItemCommand.forPV(undoableActionManager,
model,
addPVDialog.getName(i),
addPVDialog.getDisplayName(i),
addPVDialog.getScanPeriod(i),
axis,
null);
}
}

/*
public static void main(String[] args) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Messages
AddFormula_NameTT,
AddItemErrorFmt,
AddPV,
AddPVs,
AddPVsFromTheClipboard,
AddPV_Axis,
AddPV_AxisTT,
AddPVMsg,
Expand Down Expand Up @@ -63,6 +65,7 @@ public class Messages
CursorValueTT,
DataBrowser,
DataBrowserMenuPath,
DefaultDisplayName,
DeleteAxis,
DeleteAxisWarningFmt,
DeleteItem,
Expand Down Expand Up @@ -222,6 +225,8 @@ public class Messages
NewPlotFileCreateFailed,
NewPlotOverwriteExisting,
NewPlotOverwriteExistingTitle,
NoEachPVIsAssignedAnValueAxisIndividually,
NoPVsFoundInTheClipboard,
NotApplicable,
OpenExportView,
OpenPropertiesView,
Expand Down Expand Up @@ -284,6 +289,7 @@ public class Messages
StatisticsSum,
StatisticsSampleCount,
StatusColumn,
TheClipboardDoesNotContainPVs,
TimeAxis,
TimeColumn,
TitleFontLbl,
Expand All @@ -306,6 +312,7 @@ public class Messages
UseAxisName,
UseLines,
UsePoints,
UseTheSameValueAxisForAllAddedPVs,
UseTraceNames,
UseUnixTimeStamp,
ValueAxes,
Expand All @@ -318,7 +325,8 @@ public class Messages
WaveformTimeSelector,
WaveformTimestamp,
WaveformView,
WaveformViewSelect;
WaveformViewSelect,
YesAllPVsAreAddedToTheAxis;
// ---
// --- Keep alphabetically sorted and 'in sync' with messages.properties!
// ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.text.MessageFormat;
import java.util.Optional;

import org.csstudio.trends.databrowser3.Activator;
import org.csstudio.trends.databrowser3.Messages;
Expand Down Expand Up @@ -64,7 +65,7 @@ private void run()
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);
type, Optional.empty(), Preferences.scan_period, axis, imported);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public static class TimePreset
/** Setting */
@Preference public static boolean config_dialog_supported;

@Preference
public static boolean assign_pvs_from_clipboard_to_the_same_axis_by_default;


@Preference
public static String value_axis_label_policy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.csstudio.trends.databrowser3.ui;

import java.text.MessageFormat;
import java.util.Optional;

import org.csstudio.trends.databrowser3.Messages;
import org.csstudio.trends.databrowser3.model.ArchiveDataSource;
Expand All @@ -34,6 +35,7 @@ public class AddModelItemCommand extends UndoableAction
* @param operations_manager OperationsManager where command will be reg'ed
* @param model Model were PV is to be added
* @param pv_name Name of new PV
* @param optional_display_name Optional Display Name to associate with the PV
* @param period scan period
* @param axis Axis
* @param archive Archive data source
Expand All @@ -43,6 +45,7 @@ public static AddModelItemCommand forPV(
final UndoableActionManager operations_manager,
final Model model,
final String pv_name,
final Optional<String> optional_display_name,
final double period,
final AxisConfig axis,
final ArchiveDataSource archive)
Expand All @@ -52,6 +55,9 @@ public static AddModelItemCommand forPV(
try
{
item = new PVItem(pv_name, period);
if (optional_display_name.isPresent()) {
item.setDisplayName(optional_display_name.get());
}
if (archive != null)
item.addArchiveDataSource(archive);
else
Expand Down
Loading

0 comments on commit 30cc0f5

Please sign in to comment.