Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sar login #3134

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class Messages {
public static String inverseSelection;
public static String liveReadbackVsSetpoint;
public static String liveSetpoint;
public static String login;
public static String loggingFailedTitle;
public static String loggingFailed;
public static String loggingFailedCauseUnknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@

package org.phoebus.applications.saveandrestore.ui;

import javafx.application.Platform;
import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.image.ImageView;
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import org.phoebus.applications.saveandrestore.Messages;
import org.phoebus.applications.saveandrestore.SaveAndRestoreApplication;
import org.phoebus.applications.saveandrestore.model.Node;
import org.phoebus.applications.saveandrestore.model.NodeType;
Expand Down Expand Up @@ -202,17 +211,9 @@ public void updateItem(Node node, boolean empty) {
hBox.getChildren().add(new Label(node.getName()));
if (node.getUniqueId().equals(Node.ROOT_FOLDER_UNIQUE_ID)) {
setTooltip(new Tooltip(SaveAndRestoreService.getInstance().getServiceIdentifier()));
ContextMenu rootFolderContextMenu = new ContextMenu();
MenuItem newRootFolderMenuItem = new MenuItem(Messages.contextMenuNewFolder, new ImageView(ImageRepository.FOLDER));
newRootFolderMenuItem.setOnAction(ae -> saveAndRestoreController.createNewFolder());
rootFolderContextMenu.getItems().add(newRootFolderMenuItem);
rootFolderContextMenu.setOnShowing(event -> {
if (saveAndRestoreController.getUserIdentity().isNull().get()) {
Platform.runLater(() -> rootFolderContextMenu.hide());
}
});

if(saveAndRestoreController != null){
setContextMenu(rootFolderContextMenu);
setContextMenu(new ContextMenuRootFolder(saveAndRestoreController));
}

} else if (saveAndRestoreController != null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javafx.scene.image.ImageView;
import org.phoebus.applications.saveandrestore.Messages;
import org.phoebus.applications.saveandrestore.model.Node;
import org.phoebus.framework.workbench.ApplicationService;
import org.phoebus.ui.javafx.ImageCache;

/**
Expand All @@ -38,6 +39,9 @@ public abstract class ContextMenuBase extends ContextMenu {
protected MenuItem deleteNodesMenuItem;
protected MenuItem copyUniqueIdToClipboardMenuItem;

protected MenuItem loginMenuItem;
private static final String loginAppName = "credentials_management";

protected SimpleBooleanProperty multipleNodesSelectedProperty = new SimpleBooleanProperty();

protected SaveAndRestoreController saveAndRestoreController;
Expand Down Expand Up @@ -84,6 +88,12 @@ public ContextMenuBase(SaveAndRestoreController saveAndRestoreController) {
copyUniqueIdToClipboardMenuItem.setOnAction(ae -> saveAndRestoreController.copyUniqueNodeIdToClipboard());
copyUniqueIdToClipboardMenuItem.disableProperty().bind(multipleNodesSelectedProperty);

loginMenuItem = new MenuItem(Messages.login, ImageCache.getImageView(ImageCache.class, "/icons/credentials.png"));
loginMenuItem.setOnAction(ae -> {
ApplicationService.createInstance(loginAppName);
});
loginMenuItem.visibleProperty().bind(userIsAuthenticatedProperty.not());

// Controller may be null, e.g. when adding PVs from channel table
if(saveAndRestoreController != null){
setOnShowing(event -> runChecks());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public ContextMenuCompositeSnapshot(SaveAndRestoreController saveAndRestoreContr
userIsAuthenticatedProperty.not().get() || mayCopyProperty.not().get(),
userIsAuthenticatedProperty, mayCopyProperty));

getItems().addAll(editCompositeSnapshotMenuItem,
getItems().addAll(
loginMenuItem,
editCompositeSnapshotMenuItem,
copyMenuItem,
deleteNodesMenuItem,
copyUniqueIdToClipboardMenuItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public ContextMenuConfiguration(SaveAndRestoreController saveAndRestoreControlle
pasteMenuItem.setOnAction(ae -> saveAndRestoreController.pasteFromClipboard());
pasteMenuItem.disableProperty().bind(mayPasteProperty.not());

getItems().addAll(openConfigurationMenuItem,
getItems().addAll(
loginMenuItem,
openConfigurationMenuItem,
copyMenuItem,
pasteMenuItem,
deleteNodesMenuItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public ContextMenuFolder(SaveAndRestoreController saveAndRestoreController) {
mayPasteProperty.not().get() || userIsAuthenticatedProperty.not().get(),
mayPasteProperty, userIsAuthenticatedProperty));

getItems().addAll(newFolderMenuItem,
getItems().addAll(
loginMenuItem,
newFolderMenuItem,
renameNodeMenuItem,
pasteMenuItem,
deleteNodesMenuItem,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2020 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

package org.phoebus.applications.saveandrestore.ui;

import javafx.beans.binding.Bindings;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.phoebus.applications.saveandrestore.Messages;
import org.phoebus.applications.saveandrestore.model.Node;
import org.phoebus.ui.javafx.ImageCache;

/**
* Context menu for {@link Node}s of type {@link org.phoebus.applications.saveandrestore.model.NodeType#FOLDER}.
* All item actions require user to be authenticated, and if that is not the case,
* the context menu is hidden rather than showing a list of disabled context menu items.
*/
public class ContextMenuRootFolder extends ContextMenuBase {

public ContextMenuRootFolder(SaveAndRestoreController saveAndRestoreController) {
super(saveAndRestoreController);

MenuItem newFolderMenuItem = new MenuItem(Messages.contextMenuNewFolder, new ImageView(ImageRepository.FOLDER));
newFolderMenuItem.disableProperty().bind(Bindings.createBooleanBinding(() ->
multipleNodesSelectedProperty.get() || userIsAuthenticatedProperty.not().get(),
multipleNodesSelectedProperty, userIsAuthenticatedProperty));
newFolderMenuItem.setOnAction(ae -> saveAndRestoreController.createNewFolder());

getItems().addAll(
loginMenuItem,
newFolderMenuItem);

}

/**
* Execute common checks (see {@link ContextMenuBase#runChecks()}) and hides the menu
* if user is not authenticated.
*/
@Override
protected void runChecks() {
super.runChecks();
mayPasteProperty.set(saveAndRestoreController.mayPaste());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public ContextMenuSnapshot(SaveAndRestoreController saveAndRestoreController) {
copyMenuItem.setOnAction(action -> saveAndRestoreController.copySelectionToClipboard());
copyMenuItem.disableProperty().bind(mayCopyProperty.not());

getItems().addAll(deleteNodesMenuItem,
getItems().addAll(
loginMenuItem,
deleteNodesMenuItem,
compareSnapshotsMenuItem,
tagGoldenMenuItem,
tagWithComment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ liveReadbackVsSetpoint=Live Readback\n(? Live Setpoint)
liveSetpoint=Live Setpoint
logAction=Create Log Entry
logActionTooltip=Automatically create log entry when save or restore action completes
login=Login
loggingFailedTitle=Logging failed
loggingFailed=Unable to create log entry
loggingFailedCauseUnknown=Cause unknown, please check application logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ labelThreshold=\u0394 Seuil (%)
lastModifiedDate=Dernière modification
liveReadbackVsSetpoint=Retour en direct\n(? Consigne en direct)
liveSetpoint=Consigne en direct
login=Se connecter
loggingFailedTitle=Échec de la journalisation
loggingFailed=Impossible de créer une entrée de journal
loggingFailedCauseUnknown=Cause inconnue, veuillez vérifier les journaux de l'application
Expand Down
Loading