From d7f4733466c9c788179ac72bfc4f477f12082761 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Thu, 15 Feb 2024 14:07:25 +0100 Subject: [PATCH 1/7] CSSTUDIO-2078 Add functionality to move axes to the right and left when right-clicking on an axis in the DataBrowser. --- .../trends/databrowser3/model/Model.java | 32 ++++++++ .../trends/databrowser3/ui/Perspective.java | 74 +++++++++++++------ .../ExchangeAxesUndoableAction.java | 37 ++++++++++ .../ui/properties/MoveAxisToTheLeft.java | 63 ++++++++++++++++ .../ui/properties/MoveAxisToTheRight.java | 63 ++++++++++++++++ 5 files changed, 245 insertions(+), 24 deletions(-) create mode 100644 app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/ExchangeAxesUndoableAction.java create mode 100644 app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java create mode 100644 app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java index 0de100615d..0d020907d0 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java @@ -395,6 +395,38 @@ public void removeAxis(final AxisConfig axis) fireAxisChangedEvent(Optional.empty()); } + public void exchangeAxes(int i, int j) { + int lowerIndex, higherIndex; + if (j == 0) { + return; + } + else if (j < i) { + lowerIndex = j; + higherIndex = i; + } + else { + lowerIndex = i; + higherIndex = j; + } + var lowerIndexAxis = getAxis(lowerIndex); + var higherIndexAxis = getAxis(higherIndex); + + axes.remove(lowerIndexAxis); + axes.remove(higherIndexAxis); + + axes.add(lowerIndex, higherIndexAxis); + axes.add(higherIndex, lowerIndexAxis); + + fireAxisChangedEvent(Optional.of(lowerIndexAxis)); + fireAxisChangedEvent(Optional.of(higherIndexAxis)); + + for (ModelItem item : items) { + if (item.getAxis() == lowerIndexAxis || item.getAxis() == higherIndexAxis) { + item.fireItemLookChanged(); // Prevents the "Axis" UI-setting (under the "Traces" tab) from sometimes not displaying in the UI when moving axes. + } + } + }; + /** @return How should plot rescale after archived data arrived? */ public ArchiveRescale getArchiveRescale() { diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java index f0c53d426d..23208ffee2 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java @@ -7,17 +7,20 @@ ******************************************************************************/ package org.csstudio.trends.databrowser3.ui; -import static org.csstudio.trends.databrowser3.Activator.logger; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; -import java.util.prefs.BackingStoreException; -import java.util.prefs.Preferences; -import java.util.stream.Collectors; - +import javafx.application.Platform; +import javafx.collections.ObservableList; +import javafx.geometry.Orientation; +import javafx.scene.Node; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.MenuItem; +import javafx.scene.control.SeparatorMenuItem; +import javafx.scene.control.SplitPane; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; +import javafx.scene.image.ImageView; +import javafx.scene.input.Dragboard; +import javafx.scene.input.TransferMode; +import org.csstudio.javafx.rtplot.internal.YAxisImpl; import org.csstudio.trends.databrowser3.Activator; import org.csstudio.trends.databrowser3.Messages; import org.csstudio.trends.databrowser3.imports.SampleImportAction; @@ -29,6 +32,8 @@ import org.csstudio.trends.databrowser3.ui.plot.ModelBasedPlot; import org.csstudio.trends.databrowser3.ui.plot.PlotListener; import org.csstudio.trends.databrowser3.ui.properties.AddPVorFormulaMenuItem; +import org.csstudio.trends.databrowser3.ui.properties.MoveAxisToTheLeft; +import org.csstudio.trends.databrowser3.ui.properties.MoveAxisToTheRight; import org.csstudio.trends.databrowser3.ui.properties.PropertyPanel; import org.csstudio.trends.databrowser3.ui.properties.RemoveUnusedAxes; import org.csstudio.trends.databrowser3.ui.sampleview.SampleView; @@ -45,19 +50,16 @@ import org.phoebus.ui.spi.ContextMenuEntry; import org.phoebus.ui.undo.UndoableActionManager; -import javafx.application.Platform; -import javafx.collections.ObservableList; -import javafx.geometry.Orientation; -import javafx.scene.Node; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.MenuItem; -import javafx.scene.control.SeparatorMenuItem; -import javafx.scene.control.SplitPane; -import javafx.scene.control.Tab; -import javafx.scene.control.TabPane; -import javafx.scene.image.ImageView; -import javafx.scene.input.Dragboard; -import javafx.scene.input.TransferMode; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; +import java.util.stream.Collectors; + +import static org.csstudio.trends.databrowser3.Activator.logger; /** Combined layout of all data browser components * @author Kay Kasemir @@ -221,6 +223,30 @@ private void createContextMenu() items.add(new SeparatorMenuItem()); items.add(new RemoveUnusedAxes(model, undo)); } + + var yAxes = plot.getPlot().getYAxes(); + int numberOfYAxes = yAxes.size(); + + for (int i=0; i) { + YAxisImpl yAxisImpl = (YAxisImpl) yAxis; + + var region = yAxisImpl.getBounds(); + + var axisX1 = region.x; + var axisX2 = region.x + region.width; + + var sceneX = event.getX(); + if (sceneX >= axisX1 && sceneX <= axisX2) { + MenuItem moveAxisToTheLeft = new MoveAxisToTheLeft(model, undo, i); + items.add(moveAxisToTheLeft); + MenuItem moveAxisToTheRight = new MoveAxisToTheRight(model, undo, i); + items.add(moveAxisToTheRight); + } + } + } + items.addAll(new SeparatorMenuItem(), show_search, show_properties, show_export, show_samples, show_waveform, refresh); menu.show(getScene().getWindow(), event.getScreenX(), event.getScreenY()); diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/ExchangeAxesUndoableAction.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/ExchangeAxesUndoableAction.java new file mode 100644 index 0000000000..888987aa14 --- /dev/null +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/ExchangeAxesUndoableAction.java @@ -0,0 +1,37 @@ +package org.csstudio.trends.databrowser3.ui.properties; + +import org.csstudio.trends.databrowser3.model.Model; +import org.phoebus.ui.undo.UndoableAction; + +public class ExchangeAxesUndoableAction extends UndoableAction { + Model model; + int axisIndex1; + int axisIndex2; + + /** + * @param name Name used to show action in undo/redo UI + * @param model Data Browser model containing the axes whose positions to exchange + * @param axisIndex1 Index of the first of the axes whose positions to exchange + * @param axisIndex2 Index of the second of the axes whose positions to exchange + */ + public ExchangeAxesUndoableAction(String name, + Model model, + int axisIndex1, + int axisIndex2) { + super(name); + this.model = model; + this.axisIndex1 = axisIndex1; + this.axisIndex2 = axisIndex2; + } + + @Override + public void run() { + model.exchangeAxes(axisIndex1, axisIndex2); + + } + + @Override + public void undo() { + model.exchangeAxes(axisIndex2, axisIndex1); + } +} \ No newline at end of file diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java new file mode 100644 index 0000000000..cb767c5e0c --- /dev/null +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java @@ -0,0 +1,63 @@ +package org.csstudio.trends.databrowser3.ui.properties; + +import javafx.scene.control.MenuItem; +import org.csstudio.trends.databrowser3.Activator; +import org.csstudio.trends.databrowser3.model.Model; +import org.phoebus.ui.undo.UndoableAction; +import org.phoebus.ui.undo.UndoableActionManager; + +import java.util.stream.Collectors; + +/** Action to move an axis to the left + */ +@SuppressWarnings("nls") +public class MoveAxisToTheLeft extends MenuItem +{ + /** @param model Model + * @param undoableActionManager Undo manager + * @param axisToMoveToTheLeft_index Index of axis to move to the left + */ + public MoveAxisToTheLeft(Model model, + UndoableActionManager undoableActionManager, + int axisToMoveToTheLeft_index) + { + super("Move Axis to the Left", Activator.getIcon("left")); + + var axisToMoveToTheLeft = model.getAxes().get(axisToMoveToTheLeft_index); + + int axisIndex1, axisIndex2; + + var allAxes = model.getAxes(); + + if (!axisToMoveToTheLeft.isOnRight()) { + // Axis to move to the left is located on the left side of the graph + var allAxesOnTheLeft = allAxes.stream().filter(axis -> !axis.isOnRight()).collect(Collectors.toList()); + int axisToMoveToTheLeft_index_allAxesOnTheLeft = allAxesOnTheLeft.indexOf(axisToMoveToTheLeft); + if (axisToMoveToTheLeft_index_allAxesOnTheLeft > 0) { + var axisOnTheLeft = allAxesOnTheLeft.get(axisToMoveToTheLeft_index_allAxesOnTheLeft - 1); + axisIndex1 = allAxes.indexOf(axisOnTheLeft); + axisIndex2 = axisToMoveToTheLeft_index; + UndoableAction moveAxisToTheLeft = new ExchangeAxesUndoableAction("Move Axis to the Left", + model, + axisIndex1, + axisIndex2); + setOnAction(actionEvent -> undoableActionManager.execute(moveAxisToTheLeft)); + } + } + else { + // Axis to move to the left is located on the right side of the graph + var allAxesOnTheRight = allAxes.stream().filter(axis -> axis.isOnRight()).collect(Collectors.toList()); + int axisToMoveToTheLeft_index_allAxesOnTheRight = allAxesOnTheRight.indexOf(axisToMoveToTheLeft); + if (axisToMoveToTheLeft_index_allAxesOnTheRight < allAxesOnTheRight.size() - 1) { + var axisOnTheLeft = allAxesOnTheRight.get(axisToMoveToTheLeft_index_allAxesOnTheRight + 1); // On the right side of the graph, axes are stored in "opposite" relative ordering + axisIndex1 = axisToMoveToTheLeft_index; + axisIndex2 = allAxes.indexOf(axisOnTheLeft); + UndoableAction moveAxisToTheLeft = new ExchangeAxesUndoableAction("Move Axis to the Left", + model, + axisIndex1, + axisIndex2); + setOnAction(actionEvent -> undoableActionManager.execute(moveAxisToTheLeft)); + } + } + } +} diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java new file mode 100644 index 0000000000..981c5c1bd2 --- /dev/null +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java @@ -0,0 +1,63 @@ +package org.csstudio.trends.databrowser3.ui.properties; + +import javafx.scene.control.MenuItem; +import org.csstudio.trends.databrowser3.Activator; +import org.csstudio.trends.databrowser3.model.Model; +import org.phoebus.ui.undo.UndoableAction; +import org.phoebus.ui.undo.UndoableActionManager; + +import java.util.stream.Collectors; + +/** Action to move an axis to the right + */ +@SuppressWarnings("nls") +public class MoveAxisToTheRight extends MenuItem +{ + /** @param model Model + * @param undoableActionManager Undo manager + * @param axisToMoveToTheRight_index Index of axis to move to the right + */ + public MoveAxisToTheRight(Model model, + UndoableActionManager undoableActionManager, + int axisToMoveToTheRight_index) + { + super("Move Axis to the Right", Activator.getIcon("right")); + + var axisToMoveToTheRight = model.getAxes().get(axisToMoveToTheRight_index); + + int axisIndex1, axisIndex2; + + var allAxes = model.getAxes(); + + if (!axisToMoveToTheRight.isOnRight()) { + // Axis to move to the right is located on the left side of the graph + var allAxesOnTheLeft = allAxes.stream().filter(axis -> !axis.isOnRight()).collect(Collectors.toList()); + int axisToMoveToTheRight_index_allAxesOnTheLeft = allAxesOnTheLeft.indexOf(axisToMoveToTheRight); + if (axisToMoveToTheRight_index_allAxesOnTheLeft < allAxesOnTheLeft.size() - 1) { + var axisOnTheRight = allAxesOnTheLeft.get(axisToMoveToTheRight_index_allAxesOnTheLeft + 1); + axisIndex1 = axisToMoveToTheRight_index; + axisIndex2 = allAxes.indexOf(axisOnTheRight); + UndoableAction moveAxisToTheRight = new ExchangeAxesUndoableAction("Move Axis to the Right", + model, + axisIndex1, + axisIndex2); + setOnAction(actionEvent -> undoableActionManager.execute(moveAxisToTheRight)); + } + } + else { + // Axis to move to the right is located on the right side of the graph + var allAxesOnTheRight = allAxes.stream().filter(axis -> axis.isOnRight()).collect(Collectors.toList()); + int axisToMoveToTheRight_index_allAxesOnTheRight = allAxesOnTheRight.indexOf(axisToMoveToTheRight); + if (axisToMoveToTheRight_index_allAxesOnTheRight > 0) { + var axisOnTheRight = allAxesOnTheRight.get(axisToMoveToTheRight_index_allAxesOnTheRight - 1); // On the right side of the graph, axes are stored in "opposite" relative ordering + axisIndex1 = allAxes.indexOf(axisOnTheRight); + axisIndex2 = axisToMoveToTheRight_index; + UndoableAction moveAxisToTheRight = new ExchangeAxesUndoableAction("Move Axis to the Right", + model, + axisIndex1, + axisIndex2); + setOnAction(actionEvent -> undoableActionManager.execute(moveAxisToTheRight)); + } + } + } +} From a6b8279089182dff9e9ba509be7b8aeaabfb8a2f Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Thu, 15 Feb 2024 14:13:53 +0100 Subject: [PATCH 2/7] CSSTUDIO-2078 Add separator for new axis options in the context menu, if one hasn't already been added. --- .../trends/databrowser3/ui/Perspective.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java index 23208ffee2..25cdfb7910 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java @@ -218,31 +218,40 @@ private void createContextMenu() items.add(menuItem); }); - if (model.getEmptyAxis().isPresent()) { - items.add(new SeparatorMenuItem()); - items.add(new RemoveUnusedAxes(model, undo)); - } - - var yAxes = plot.getPlot().getYAxes(); - int numberOfYAxes = yAxes.size(); - - for (int i=0; i) { - YAxisImpl yAxisImpl = (YAxisImpl) yAxis; + boolean separatorForAxisOptionsAdded = false; - var region = yAxisImpl.getBounds(); - - var axisX1 = region.x; - var axisX2 = region.x + region.width; + if (model.getEmptyAxis().isPresent()) + { + items.add(new SeparatorMenuItem()); + separatorForAxisOptionsAdded = true; + items.add(new RemoveUnusedAxes(model, undo)); + } - var sceneX = event.getX(); - if (sceneX >= axisX1 && sceneX <= axisX2) { - MenuItem moveAxisToTheLeft = new MoveAxisToTheLeft(model, undo, i); - items.add(moveAxisToTheLeft); - MenuItem moveAxisToTheRight = new MoveAxisToTheRight(model, undo, i); - items.add(moveAxisToTheRight); + var yAxes = plot.getPlot().getYAxes(); + int numberOfYAxes = yAxes.size(); + + for (int i=0; i) { + YAxisImpl yAxisImpl = (YAxisImpl) yAxis; + + var region = yAxisImpl.getBounds(); + + var axisX1 = region.x; + var axisX2 = region.x + region.width; + + var sceneX = event.getX(); + if (sceneX >= axisX1 && sceneX <= axisX2) { + if (!separatorForAxisOptionsAdded) { + items.add(new SeparatorMenuItem()); + separatorForAxisOptionsAdded = true; + } + MenuItem moveAxisToTheLeft = new MoveAxisToTheLeft(model, undo, i); + items.add(moveAxisToTheLeft); + MenuItem moveAxisToTheRight = new MoveAxisToTheRight(model, undo, i); + items.add(moveAxisToTheRight); + } } } } From 4341b59a32dabab1581701a513531479e5a51946 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Thu, 15 Feb 2024 14:21:25 +0100 Subject: [PATCH 3/7] CSSTUDIO-2078 Bugfix: updates the order of the axes in the UI under the "Value Axes" tab when moving axes to the left or to the right. --- .../main/java/org/csstudio/trends/databrowser3/model/Model.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java index 0d020907d0..5276aa85f0 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java @@ -419,6 +419,7 @@ else if (j < i) { fireAxisChangedEvent(Optional.of(lowerIndexAxis)); fireAxisChangedEvent(Optional.of(higherIndexAxis)); + fireAxisChangedEvent(Optional.empty()); // Updates the order of the axes in the UI under the "Value Axes" tab for (ModelItem item : items) { if (item.getAxis() == lowerIndexAxis || item.getAxis() == higherIndexAxis) { From 992e96d134caaf96680cb5dff9baf2827ff287f9 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Thu, 15 Feb 2024 14:34:24 +0100 Subject: [PATCH 4/7] CSSTUDIO-2078 Add "Delete Axis" option to the context menu when right-clicking on an empty axis. --- .../org/csstudio/trends/databrowser3/ui/Perspective.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java index 25cdfb7910..71e4804cdb 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java @@ -32,6 +32,7 @@ import org.csstudio.trends.databrowser3.ui.plot.ModelBasedPlot; import org.csstudio.trends.databrowser3.ui.plot.PlotListener; import org.csstudio.trends.databrowser3.ui.properties.AddPVorFormulaMenuItem; +import org.csstudio.trends.databrowser3.ui.properties.DeleteAxes; import org.csstudio.trends.databrowser3.ui.properties.MoveAxisToTheLeft; import org.csstudio.trends.databrowser3.ui.properties.MoveAxisToTheRight; import org.csstudio.trends.databrowser3.ui.properties.PropertyPanel; @@ -247,6 +248,12 @@ private void createContextMenu() items.add(new SeparatorMenuItem()); separatorForAxisOptionsAdded = true; } + + if (model.getFirstItemOnAxis(model.getAxes().get(i)) == null) { + // Axis is empty + items.add(new DeleteAxes(this, model, undo, Arrays.asList(model.getAxes().get(i)))); + } + MenuItem moveAxisToTheLeft = new MoveAxisToTheLeft(model, undo, i); items.add(moveAxisToTheLeft); MenuItem moveAxisToTheRight = new MoveAxisToTheRight(model, undo, i); From 617ec05ce30ba3009d1f5aa980cceb78d5aad576 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Thu, 15 Feb 2024 14:41:42 +0100 Subject: [PATCH 5/7] CSSTUDIO-2078 Add options to move axes to the left and right to the context menu of the axes-table under the "Value Axes" tab. --- .../csstudio/trends/databrowser3/ui/properties/AxesTab.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/AxesTab.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/AxesTab.java index 901d4c67fd..bf48b0d73f 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/AxesTab.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/AxesTab.java @@ -272,6 +272,12 @@ private void createContextMenu() if (selection.size() > 0) items.add(new DeleteAxes(axes_table, model, undo, selection)); + if (selection.size() == 1) { + int index = axes_table.getItems().indexOf(selection.get(0)); + items.add(new MoveAxisToTheLeft(model, undo, index)); + items.add(new MoveAxisToTheRight(model, undo, index)); + } + if (model.getEmptyAxis().isPresent()) items.add(new RemoveUnusedAxes(model, undo)); From 7973ddd735a3c3a3319c70050479f330391de6e8 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Fri, 16 Feb 2024 09:27:14 +0100 Subject: [PATCH 6/7] CSSTUDIO-2078 Add labels to messages.properties. --- .../main/java/org/csstudio/trends/databrowser3/Messages.java | 2 ++ .../trends/databrowser3/ui/properties/MoveAxisToTheLeft.java | 5 +++-- .../databrowser3/ui/properties/MoveAxisToTheRight.java | 5 +++-- .../org/csstudio/trends/databrowser3/messages.properties | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java index 6ae1f35e8f..d5c1f826fd 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java @@ -208,6 +208,8 @@ public class Messages LogScale, Miscellaneous, Model_Disconnected, + MoveAxisToTheLeft, + MoveAxisToTheRight, MoveItemDown, MoveItemUp, Name, diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java index cb767c5e0c..77885b5590 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheLeft.java @@ -2,6 +2,7 @@ import javafx.scene.control.MenuItem; import org.csstudio.trends.databrowser3.Activator; +import org.csstudio.trends.databrowser3.Messages; import org.csstudio.trends.databrowser3.model.Model; import org.phoebus.ui.undo.UndoableAction; import org.phoebus.ui.undo.UndoableActionManager; @@ -21,7 +22,7 @@ public MoveAxisToTheLeft(Model model, UndoableActionManager undoableActionManager, int axisToMoveToTheLeft_index) { - super("Move Axis to the Left", Activator.getIcon("left")); + super(Messages.MoveAxisToTheLeft, Activator.getIcon("left")); var axisToMoveToTheLeft = model.getAxes().get(axisToMoveToTheLeft_index); @@ -37,7 +38,7 @@ public MoveAxisToTheLeft(Model model, var axisOnTheLeft = allAxesOnTheLeft.get(axisToMoveToTheLeft_index_allAxesOnTheLeft - 1); axisIndex1 = allAxes.indexOf(axisOnTheLeft); axisIndex2 = axisToMoveToTheLeft_index; - UndoableAction moveAxisToTheLeft = new ExchangeAxesUndoableAction("Move Axis to the Left", + UndoableAction moveAxisToTheLeft = new ExchangeAxesUndoableAction(Messages.MoveAxisToTheLeft, model, axisIndex1, axisIndex2); diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java index 981c5c1bd2..a3082c431c 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MoveAxisToTheRight.java @@ -2,6 +2,7 @@ import javafx.scene.control.MenuItem; import org.csstudio.trends.databrowser3.Activator; +import org.csstudio.trends.databrowser3.Messages; import org.csstudio.trends.databrowser3.model.Model; import org.phoebus.ui.undo.UndoableAction; import org.phoebus.ui.undo.UndoableActionManager; @@ -21,7 +22,7 @@ public MoveAxisToTheRight(Model model, UndoableActionManager undoableActionManager, int axisToMoveToTheRight_index) { - super("Move Axis to the Right", Activator.getIcon("right")); + super(Messages.MoveAxisToTheRight, Activator.getIcon("right")); var axisToMoveToTheRight = model.getAxes().get(axisToMoveToTheRight_index); @@ -52,7 +53,7 @@ public MoveAxisToTheRight(Model model, var axisOnTheRight = allAxesOnTheRight.get(axisToMoveToTheRight_index_allAxesOnTheRight - 1); // On the right side of the graph, axes are stored in "opposite" relative ordering axisIndex1 = allAxes.indexOf(axisOnTheRight); axisIndex2 = axisToMoveToTheRight_index; - UndoableAction moveAxisToTheRight = new ExchangeAxesUndoableAction("Move Axis to the Right", + UndoableAction moveAxisToTheRight = new ExchangeAxesUndoableAction(Messages.MoveAxisToTheRight, model, axisIndex1, axisIndex2); diff --git a/app/databrowser/src/main/resources/org/csstudio/trends/databrowser3/messages.properties b/app/databrowser/src/main/resources/org/csstudio/trends/databrowser3/messages.properties index da2e1c39eb..f5f6059695 100644 --- a/app/databrowser/src/main/resources/org/csstudio/trends/databrowser3/messages.properties +++ b/app/databrowser/src/main/resources/org/csstudio/trends/databrowser3/messages.properties @@ -188,6 +188,8 @@ LiveSampleBufferSize=Buffer Size LogScale=Log. Scale Miscellaneous=Misc. Model_Disconnected=Disconnected +MoveAxisToTheLeft=Move Axis to the Left +MoveAxisToTheRight=Move Axis to the Right MoveItemDown=Move Down MoveItemUp=Move Up Name=Name From 077d75e3862edcd9490f201c82a3ea9dc800510f Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Fri, 16 Feb 2024 10:57:47 +0100 Subject: [PATCH 7/7] CSSTUDIO-2078 Bugfix: Condition should be i == j. --- .../main/java/org/csstudio/trends/databrowser3/model/Model.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java index 5276aa85f0..a47f544fa9 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/Model.java @@ -397,7 +397,7 @@ public void removeAxis(final AxisConfig axis) public void exchangeAxes(int i, int j) { int lowerIndex, higherIndex; - if (j == 0) { + if (i == j) { return; } else if (j < i) {