Skip to content

Commit

Permalink
[feature UnitexGramLab#124] Allow to select an open graph to explore …
Browse files Browse the repository at this point in the history
…paths

Activate Tools > Explore graph paths if at least one graph frame is open.
  • Loading branch information
selgueti committed May 17, 2022
1 parent f88ec95 commit f94c213
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions unitex/src/fr/umlv/unitex/frames/UnitexFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1139,22 +1139,8 @@ public void actionPerformed(ActionEvent e) {
explorePaths.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final GraphFrame f = GlobalProjectManager.search(null)
.getFrameManagerAs(InternalFrameManager.class)
.getCurrentFocusedGraphFrame();
if (f != null) {

if (f.getGraph() == null) {
JOptionPane.showMessageDialog(null,
"Cannot explore graph paths for graph with no name", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
else {
GlobalProjectManager.search(null)
.getFrameManagerAs(InternalFrameManager.class).newGraphPathFrame();
}
}
GlobalProjectManager.search(null)
.getFrameManagerAs(InternalFrameManager.class).newGraphPathFrame();
}
});

Expand Down Expand Up @@ -1214,6 +1200,25 @@ public void actionPerformed(ActionEvent e) {
tools.add(graphCollection);
tools.addSeparator();
tools.add(svn);
tools.addMenuListener(new MenuAdapter() {
@Override
public void menuSelected(MenuEvent e) {
final GraphFrame f = GlobalProjectManager.search(null)
.getFrameManagerAs(InternalFrameManager.class)
.getCurrentFocusedGraphFrame();
boolean existsFocusedGrFrame = f != null;
boolean existsAnyGrFrame = GlobalProjectManager.search(null)
.getFrameManagerAs(InternalFrameManager.class)
.getGraphFrames().size() != 0;
sortNodeLabel.setEnabled(existsFocusedGrFrame);
explorePaths.setEnabled(existsAnyGrFrame);
verifyBraces.setEnabled(existsFocusedGrFrame);
compileFST.setEnabled(existsFocusedGrFrame);
flatten.setEnabled(existsFocusedGrFrame);
graphCollection.setEnabled(existsFocusedGrFrame);
svn.setEnabled(existsFocusedGrFrame);
}
});
graphMenu.add(tools);
final JMenu format = new JMenu("Format");
final JMenuItem alignment = new JMenuItem("Alignment...");
Expand Down Expand Up @@ -1484,7 +1489,7 @@ public void menuSelected(MenuEvent e) {
printAll.setEnabled(existsAnyGrFrame);
undo.setEnabled(existsFocusedGrFrame);
redo.setEnabled(existsFocusedGrFrame);
tools.setEnabled(existsFocusedGrFrame);
tools.setEnabled(existsAnyGrFrame);
format.setEnabled(existsFocusedGrFrame);
zoom.setEnabled(existsFocusedGrFrame);
findAndReplace.setEnabled(existsAnyGrFrame);
Expand Down

0 comments on commit f94c213

Please sign in to comment.