Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
feat: edit entry for server node contextual menu
Browse files Browse the repository at this point in the history
  • Loading branch information
le-yams committed Apr 30, 2024
1 parent 8674349 commit 9513442
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void mousePressed(MouseEvent event) {
case SERVER_NODE -> {
var serverNode = (ServerNode) node;
tree.setSelectionRow(selectedRow);
var popupMenu = new ServerContextualPopup(treeModel, serverNode);
var popupMenu = new ServerContextualPopup(treeModel, serverNode, () -> editAction(null));
popupMenu.show(event.getComponent(), event.getX(), event.getY());
}
case STORE_NODE -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.le_yams.openfga4intellij.servers.ui.tree;

import com.intellij.icons.AllIcons;
import com.intellij.ui.AnActionButtonRunnable;

import javax.swing.*;
import java.awt.event.ActionEvent;
Expand All @@ -11,17 +12,27 @@ public class ServerContextualPopup extends JPopupMenu {

private final ServerNode serverNode;
private final OpenFgaTreeModel model;
private final Runnable editServerAction;

public ServerContextualPopup(OpenFgaTreeModel model, ServerNode serverNode) {
public ServerContextualPopup(OpenFgaTreeModel model, ServerNode serverNode, Runnable editServerAction) {
this.model = model;
this.serverNode = serverNode;
this.editServerAction = editServerAction;

add(editServerMenuItem());
addSeparator();
add(refreshMenuItem());
addSeparator();
add(copyNameMenuItem());
add(copyUrlMenuItem());
}

private JMenuItem editServerMenuItem() {
var refreshMenuItem = new JMenuItem("edit", AllIcons.Actions.Edit);
refreshMenuItem.addActionListener(e -> editServerAction.run());
return refreshMenuItem;
}

private JMenuItem refreshMenuItem() {
var refreshMenuItem = new JMenuItem("refresh", AllIcons.Actions.Refresh);
refreshMenuItem.addActionListener(this::refresh);
Expand Down

0 comments on commit 9513442

Please sign in to comment.