From c99e37ca309fc5583d8959bfa5abe91561ee97bb Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Wed, 4 May 2022 11:43:50 +0200 Subject: [PATCH 1/7] [fix #128] Resolve NullPointerException Resolve NPE when clicking on Set File button (Explore Graph Paths menu) --- unitex/src/fr/umlv/unitex/config/Config.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unitex/src/fr/umlv/unitex/config/Config.java b/unitex/src/fr/umlv/unitex/config/Config.java index e82b404ee..652d8d154 100644 --- a/unitex/src/fr/umlv/unitex/config/Config.java +++ b/unitex/src/fr/umlv/unitex/config/Config.java @@ -570,6 +570,8 @@ public static JFileChooser getExploreGraphOutputDialogBox() { exploreGraphOutputDialogBox = new JFileChooser(); PersonalFileFilter txtFilter =new PersonalFileFilter("txt", "Text Files"); + if (sentenceDialogBox == null) + sentenceDialogBox = getSentenceDialogBox(); sentenceDialogBox.addChoosableFileFilter(txtFilter); sentenceDialogBox.setFileFilter(txtFilter); exploreGraphOutputDialogBox.setDialogType(JFileChooser.OPEN_DIALOG); From c43b2e205e712c0756d8fc41a1e89e2021dbb7a6 Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Tue, 17 May 2022 11:27:45 +0200 Subject: [PATCH 2/7] [feature #124] Allow to select an open graph to explore paths Activate Tools > Explore graph paths if at least one graph frame is open. --- .../fr/umlv/unitex/frames/UnitexFrame.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/unitex/src/fr/umlv/unitex/frames/UnitexFrame.java b/unitex/src/fr/umlv/unitex/frames/UnitexFrame.java index 45abc7bca..a3f294968 100644 --- a/unitex/src/fr/umlv/unitex/frames/UnitexFrame.java +++ b/unitex/src/fr/umlv/unitex/frames/UnitexFrame.java @@ -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(); } }); @@ -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..."); @@ -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); From 4c5f33c0473048ed8fb5701c3903ce9360a9a398 Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Tue, 17 May 2022 14:10:40 +0200 Subject: [PATCH 3/7] [feature #124] Change component inputGraphName Change type of inputGraphName to JCheckBox --- .../fr/umlv/unitex/frames/GraphPathFrame.java | 124 +++++++++++++----- .../unitex/frames/InternalFrameManager.java | 7 - 2 files changed, 89 insertions(+), 42 deletions(-) diff --git a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java index ddc2251ec..c5882dc22 100644 --- a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java +++ b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java @@ -21,6 +21,7 @@ package fr.umlv.unitex.frames; +import fr.umlv.unitex.common.project.manager.GlobalProjectManager; import fr.umlv.unitex.config.Config; import fr.umlv.unitex.config.ConfigManager; import fr.umlv.unitex.files.FileUtil; @@ -37,6 +38,7 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.text.ParseException; +import java.util.List; import java.util.Map; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; @@ -47,6 +49,8 @@ public class GraphPathFrame extends JInternalFrame { + private List graphFrames; + private GraphFrame currentFrame; MultiCommands preprocessCommands; Boolean flattenMode = false; String flattenDepth = "10"; @@ -95,9 +99,36 @@ public void contentsChanged(ListDataEvent e) { * Creates new form GPF */ public GraphPathFrame() { + currentFrame = GlobalProjectManager.search(null) + .getFrameManagerAs(InternalFrameManager.class) + .getCurrentFocusedGraphFrame(); + graphFrames = GlobalProjectManager.search(null) + .getFrameManagerAs(InternalFrameManager.class) + .getGraphFrames(); + setGraphPathFrame(); + } + + private void setGraphPathFrame() { + if (graphFrames.isEmpty()) { + throw new AssertionError("graphFrames should not be empty in construction of GraphPathFrame"); + } + if (currentFrame == null) { + currentFrame = graphFrames.get(0); + } initComponents(); + setOutputFileDefaultName(currentFrame); } + /** + * This method return an empty string if the selected graph is null or unsaved, otherwise the selected graph name + * */ + private String getSelectedGraphName() { + GraphFrame graphFrame = (GraphFrame) inputGraphName.getSelectedItem(); + if (graphFrame == null || graphFrame.getGraph() == null) { + return ""; + } + return FileUtil.getFileNameWithoutExtension(graphFrame.getGraph()); + } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -111,7 +142,7 @@ private void initComponents() { buttonGroup2 = new javax.swing.ButtonGroup(); graphFileLabel = new javax.swing.JLabel(); outputFileLabel = new javax.swing.JLabel(); - inputGraphName = new javax.swing.JTextField(); + inputGraphName = new javax.swing.JComboBox(); outputFileName = new javax.swing.JTextField(); setFileButton = new javax.swing.JButton(); optionSeparator = new javax.swing.JSeparator(); @@ -150,7 +181,6 @@ private void initComponents() { outputFileLabel.setText("Output file:"); inputGraphName.setEditable(false); - inputGraphName.setText("jTextField1"); inputGraphName.setPreferredSize(new java.awt.Dimension(70, 25)); inputGraphName.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -402,62 +432,86 @@ private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- }//GEN-LAST:event_cancelButtonActionPerformed private void exploreRecButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exploreRecButtonActionPerformed + String selectedGraphName = getSelectedGraphName(); + if (selectedGraphName.isEmpty()) { + outputFileName.setText(""); + return; + } if(!makeDicCheckBox.isSelected()) { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-recursive-paths.txt"); + outputFileName.setText(selectedGraphName + "-recursive-paths.txt"); } else { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-recursive-paths.dic"); + outputFileName.setText(selectedGraphName + "-recursive-paths.dic"); } }//GEN-LAST:event_exploreRecButtonActionPerformed private void inputGraphNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputGraphNameActionPerformed - // TODO add your handling code here: + GraphFrame f = (GraphFrame) inputGraphName.getSelectedItem(); + setOutputFileDefaultName(f); }//GEN-LAST:event_inputGraphNameActionPerformed private void exploreIndepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exploreIndepButtonActionPerformed + String selectedGraphName = getSelectedGraphName(); + if (selectedGraphName.isEmpty()) { + outputFileName.setText(""); + return; + } if(!makeDicCheckBox.isSelected()) { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-paths.txt"); + outputFileName.setText(selectedGraphName + "-paths.txt"); } else { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-paths.dic"); + outputFileName.setText(selectedGraphName + "-paths.dic"); } }//GEN-LAST:event_exploreIndepButtonActionPerformed private void makeDicCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputGraphNameActionPerformed + String selectedGraphName = getSelectedGraphName(); if(makeDicCheckBox.isSelected()) { separateOutputsButton.setEnabled(false); alternateOutputsButton.setEnabled(false); ignoreOutputsButton.setEnabled(false); separateOutputsButton.setSelected(true); + if (selectedGraphName.isEmpty()) { + outputFileName.setText(""); + return; + } if(exploreRecButton.isSelected()) { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-recursive-paths.dic"); + outputFileName.setText(selectedGraphName + "-recursive-paths.dic"); } else { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-paths.dic"); + outputFileName.setText(selectedGraphName+ "-paths.dic"); } } else { separateOutputsButton.setEnabled(true); alternateOutputsButton.setEnabled(true); ignoreOutputsButton.setEnabled(true); + if (selectedGraphName.isEmpty()) { + outputFileName.setText(""); + return; + } if(exploreRecButton.isSelected()) { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-recursive-paths.txt"); + outputFileName.setText(selectedGraphName + "-recursive-paths.txt"); } else { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-paths.txt"); + outputFileName.setText(selectedGraphName + "-paths.txt"); } } }//GEN-LAST:event_inputGraphNameActionPerformed private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed + if (currentFrame == null || currentFrame.getGraph() == null) { + JOptionPane.showMessageDialog(UnitexFrame.mainFrame, + "Cannot explore graph paths for graph with no name, saved your graph before", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + if (outputFileName.getText().isEmpty()) { + JOptionPane.showMessageDialog(UnitexFrame.mainFrame, + "Cannot explore graph paths with empty file output", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } Fst2ListCommand cmd = new Fst2ListCommand(); final Grf2Fst2Command grfCmd = new Grf2Fst2Command(); File fst2; @@ -469,7 +523,7 @@ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR maxSeqSpinner.commitEdit(); n = (Integer) maxSeqSpinner.getValue(); } catch (final NumberFormatException | ParseException e) { - JOptionPane.showMessageDialog(null, + JOptionPane.showMessageDialog(UnitexFrame.mainFrame, "You must specify a valid limit", "Error", JOptionPane.ERROR_MESSAGE); return; @@ -494,14 +548,15 @@ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR if ( !checkLoopsCheckbox.isSelected() ) { cmd = cmd.noLoopCheck(); } + String selectedGraphName = getSelectedGraphName(); // check if flatten was checked or not if( !flattenCheckbox.isSelected() ) { - grfCmd.grf(new File(inputGraphName.getText())) + grfCmd.grf(new File(selectedGraphName)) .enableLoopAndRecursionDetection(true).repositories() .emitEmptyGraphWarning().displayGraphNames(); } else if ( preprocessCommands == null ) { // if no specific option were given, preprocess with default - File graphFile = new File(inputGraphName.getText()); + File graphFile = new File(selectedGraphName); String name_fst2 = FileUtil.getFileNameWithoutExtension(graphFile); name_fst2 = name_fst2 + ".fst2"; final MultiCommands commands = new MultiCommands(); @@ -516,8 +571,7 @@ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR Launcher.exec(preprocessCommands, false); } - fst2 = new File(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + ".fst2"); + fst2 = new File(FileUtil.getFileNameWithoutExtension(selectedGraphName) + ".fst2"); if (exploreRecButton.isSelected()) { // set file to user input list = new File(outputFileName.getText()); @@ -527,9 +581,7 @@ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR // if we change it here ShowPathsDo will throw a FileNotFoundException // we will rename the file once the UnitexToolLogger process has completed // alternatively that process could be changed to remove the hard coding - list = new File( - FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "autolst.txt"); + list = new File(selectedGraphName + "autolst.txt"); cmd = cmd.listsOfSubgraph(fst2); } final MultiCommands commands = new MultiCommands(); @@ -542,7 +594,7 @@ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR }//GEN-LAST:event_runButtonActionPerformed private void flattenOptionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_flattenOptionButtonActionPerformed - File graphFile = new File(inputGraphName.getText()); + File graphFile = new File(inputGraphName.getSelectedItem().toString()); Map flattenOptions = UnitexFrame .flattenGraph(graphFile,flattenMode,flattenDepth); if( flattenOptions != null ) { @@ -634,18 +686,20 @@ public void toDo(boolean success) { } void setInputGraphName(String string) { - inputGraphName.setText(string); } - public void setOutputFileDefaultName(String graphFileName) { + private void setOutputFileDefaultName(GraphFrame graphFrame) { + if (graphFrame == null || graphFrame.getGraph() == null) { + outputFileName.setText(""); + return; + } + String graphName = FileUtil.getFileNameWithoutExtension(graphFrame.getGraph().getPath()); String extension = makeDicCheckBox.isSelected() ? ".dic" : ".txt"; if(exploreRecButton.isSelected()) { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-recursive-paths" + extension); + outputFileName.setText(graphName + "-recursive-paths" + extension); } else { - outputFileName.setText(FileUtil.getFileNameWithoutExtension(inputGraphName - .getText()) + "-paths" + extension); + outputFileName.setText(graphName + "-paths" + extension); } } @@ -679,7 +733,7 @@ private void openOutputFile() { private javax.swing.JLabel graphFileLabel; private javax.swing.JButton helpButton; private javax.swing.JRadioButton ignoreOutputsButton; - private javax.swing.JTextField inputGraphName; + private javax.swing.JComboBox inputGraphName; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JCheckBox maxSeqCheckbox; private javax.swing.JSpinner maxSeqSpinner; diff --git a/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java b/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java index 4e355f162..70dc90ee7 100644 --- a/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java +++ b/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java @@ -656,17 +656,10 @@ public void closeConstructSeqTfstFrame() { } public GraphPathFrame newGraphPathFrame() { - final GraphFrame gf = getCurrentFocusedGraphFrame(); - if (gf == null) { - return null; - } final GraphPathFrame d = (GraphPathFrame) setup(graphPathFrameFactory .newFrame(),true); if (d == null) return null; - final File f = gf.getGraph(); - d.setInputGraphName(f.getAbsolutePath()); - d.setOutputFileDefaultName(f.getAbsolutePath()); d.setVisible(true); return d; } From 43186b4129fbc0bd69546d1943cab092e7dfd51d Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Tue, 17 May 2022 14:53:50 +0200 Subject: [PATCH 4/7] [feature #124] Add opens graphs to inputGraphName ComboBox GraphPathFrame is now an observer of GraphFrame --- .../fr/umlv/unitex/frames/GraphPathFrame.java | 62 ++++++++++++++++++- .../unitex/frames/InternalFrameManager.java | 2 + 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java index c5882dc22..9ed502d0d 100644 --- a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java +++ b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java @@ -38,17 +38,23 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.text.ParseException; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; +import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; -public class GraphPathFrame extends JInternalFrame { +public class GraphPathFrame extends JInternalFrame implements + MultiInstanceFrameFactoryObserver { private List graphFrames; private GraphFrame currentFrame; MultiCommands preprocessCommands; @@ -116,6 +122,7 @@ private void setGraphPathFrame() { currentFrame = graphFrames.get(0); } initComponents(); + fillComboBox(); setOutputFileDefaultName(currentFrame); } @@ -657,6 +664,59 @@ void close() { outputArea.getModel().removeListDataListener(listListener); } + @Override + public void onUpdate(ArrayList frames) { + if (frames == null || frames.isEmpty()) { + dispose(); + return; + } + graphFrames = frames; + currentFrame = GlobalProjectManager.search(null).getFrameManagerAs(InternalFrameManager.class) + .getCurrentFocusedGraphFrame(); + if (currentFrame == null || currentFrame.getGraph() == null) { + currentFrame = graphFrames.get(0); + } + fillComboBox(); + setOutputFileDefaultName(currentFrame); + } + + private void fillComboBox() { + ComboBoxToolTipRenderer renderer = new ComboBoxToolTipRenderer(); + ArrayList tooltips = new ArrayList(); + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (GraphFrame f : graphFrames) { + model.addElement(f); + if (f.getGraph() == null) { + tooltips.add(f.toString()); + } + else { + tooltips.add(f.getGraph().getPath()); + } + } + renderer.setTooltips(tooltips); + inputGraphName.setRenderer(renderer); + inputGraphName.setModel(model); + } + + public class ComboBoxToolTipRenderer extends DefaultListCellRenderer { + + private ArrayList tooltips; + @Override + public JComponent getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + JComponent comp = (JComponent) super.getListCellRendererComponent(list, + value, index, isSelected, cellHasFocus); + + if (-1 < index && null != value && null != tooltips) { + list.setToolTipText(tooltips.get(index)); + } + return comp; + } + public void setTooltips(ArrayList tooltips) { + this.tooltips = tooltips; + } + } + class ShowPathsDo implements ToDo { private final File name; diff --git a/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java b/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java index 70dc90ee7..b20c61620 100644 --- a/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java +++ b/unitex/src/fr/umlv/unitex/frames/InternalFrameManager.java @@ -20,6 +20,7 @@ */ package fr.umlv.unitex.frames; +import fr.umlv.unitex.common.project.manager.GlobalProjectManager; import java.beans.PropertyVetoException; import java.io.File; import java.util.ArrayList; @@ -661,6 +662,7 @@ public GraphPathFrame newGraphPathFrame() { if (d == null) return null; d.setVisible(true); + GlobalProjectManager.search(null).getFrameManagerAs(InternalFrameManager.class).addObserver(d); return d; } From f371ee86059625665206c6700f5e9b3e487d5da4 Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Tue, 17 May 2022 15:02:22 +0200 Subject: [PATCH 5/7] [feature #124] Review of error message --- unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java index 9ed502d0d..c1d9d05d3 100644 --- a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java +++ b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java @@ -509,7 +509,7 @@ private void makeDicCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//G private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed if (currentFrame == null || currentFrame.getGraph() == null) { JOptionPane.showMessageDialog(UnitexFrame.mainFrame, - "Cannot explore graph paths for graph with no name, saved your graph before", "Error", + "Cannot explore graph paths for graph with no name, save the graph first", "Error", JOptionPane.ERROR_MESSAGE); return; } From eadd9b0448235724d7e9a08c2a8188fb036b7da9 Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Tue, 17 May 2022 15:10:11 +0200 Subject: [PATCH 6/7] [feature #124] The currentFrame is not necessary the selected frame --- unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java index c1d9d05d3..f1603632c 100644 --- a/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java +++ b/unitex/src/fr/umlv/unitex/frames/GraphPathFrame.java @@ -507,7 +507,8 @@ private void makeDicCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//G }//GEN-LAST:event_inputGraphNameActionPerformed private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed - if (currentFrame == null || currentFrame.getGraph() == null) { + if (inputGraphName.getSelectedItem() == null || + ((GraphFrame) inputGraphName.getSelectedItem()).getGraph() == null) { JOptionPane.showMessageDialog(UnitexFrame.mainFrame, "Cannot explore graph paths for graph with no name, save the graph first", "Error", JOptionPane.ERROR_MESSAGE); From d3bed0ea96c9d0c2a342a9461275524f9c8701f8 Mon Sep 17 00:00:00 2001 From: Sofian El Guetibi Date: Wed, 25 May 2022 11:41:44 +0200 Subject: [PATCH 7/7] [feature #124] Refactor spaces in Config.java --- unitex/src/fr/umlv/unitex/config/Config.java | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/unitex/src/fr/umlv/unitex/config/Config.java b/unitex/src/fr/umlv/unitex/config/Config.java index f458d676a..8d66de3cc 100644 --- a/unitex/src/fr/umlv/unitex/config/Config.java +++ b/unitex/src/fr/umlv/unitex/config/Config.java @@ -76,7 +76,7 @@ public class Config { */ private static File applicationDir; private static File unitexToolLogger; - + /** * Path of the directory .../Unitex */ @@ -489,7 +489,7 @@ public static JFileChooser getFileEditionDialogBox() { fileEditionDialogBox.setDialogTitle("Select a file to edit"); return fileEditionDialogBox; } - + public static JFileChooser initializeJFileChooser(JFileChooser jFileChooser, String extension, String description, String subfolder) { @@ -497,7 +497,7 @@ public static JFileChooser initializeJFileChooser(JFileChooser jFileChooser, return jFileChooser; jFileChooser = new JFileChooser(); final PersonalFileFilter fileFilter=new PersonalFileFilter(extension, - description); + description); jFileChooser.addChoosableFileFilter(fileFilter); jFileChooser.setFileFilter(fileFilter); jFileChooser.setDialogType(JFileChooser.OPEN_DIALOG); @@ -507,7 +507,7 @@ public static JFileChooser initializeJFileChooser(JFileChooser jFileChooser, jFileChooser.setDialogTitle("Select a file to edit"); return jFileChooser; } - + public static JFileChooser getFileEditionDialogBox(String extension) { JFileChooser chooser; if(extension == null) @@ -563,7 +563,7 @@ public static JFileChooser getTransducerListDialogBox() { //transducerListDialogBox.setControlButtonsAreShown(false); return transducerListDialogBox; } - + public static JFileChooser getExploreGraphOutputDialogBox() { if (exploreGraphOutputDialogBox != null) return exploreGraphOutputDialogBox; @@ -847,7 +847,7 @@ public static String getUnitexToolLoggerSemVer() { try { CommandBuilder cmd = new VersionInfoCommand().getSemver(); String[] comm = cmd.getCommandArguments(true); - + final Process p = Runtime.getRuntime().exec(comm); final BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream(), "UTF8")); @@ -887,13 +887,13 @@ private static void setApplicationDir(String appPath, File s) { /** * Setup the UnitexToolLogger executable - * + * * @param path * external programs directory * * @author martinec */ - public static File setupUnitexToolLogger(File path) { + public static File setupUnitexToolLogger(File path) { // define the default unitexToolLogger path File UnitexToolLogger = new File(path, "UnitexToolLogger" + (Config.getSystem() == Config.WINDOWS_SYSTEM ? ".exe" : "")); @@ -902,7 +902,7 @@ public static File setupUnitexToolLogger(File path) { // Windows, try to install it if(!UnitexToolLogger.exists() && Config.getSystem() != Config.WINDOWS_SYSTEM) { - // define the default setup script path + // define the default setup script path File setupScript = new File(path, "install" + File.separatorChar + "setup"); if(setupScript.exists()) { // setup ProcessBuilder @@ -912,36 +912,36 @@ public static File setupUnitexToolLogger(File path) { StringBuilder sb = new StringBuilder(); sb.append(setupScript.getAbsolutePath()).append(' '); sb.append("> ").append("install" + File.separatorChar + "setup.log"); - String cmd[] = new String[] { "sh", "-c", sb.toString() }; + String cmd[] = new String[] { "sh", "-c", sb.toString() }; final ProcessBuilder pb = new ProcessBuilder(cmd); - + // Java 7+ only //final ProcessBuilder pb = new ProcessBuilder(setupScript.getAbsolutePath()); //pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); pb.directory(path); pb.redirectErrorStream(true); - + // show a "Please wait" message dialog. This was adapted from // @source http://www.coding-dude.com/wp/java/modal-progress-bar-dialog-java-swing java.awt.Frame f=null; final JDialog dlgProgress = new JDialog(f, "Please wait until installation is finished", true); dlgProgress.setAlwaysOnTop(true); - + JLabel lblStatus = new JLabel("Compiling " + UnitexToolLogger.getName() + "..."); - + JProgressBar pbProgress = new JProgressBar(0, 100); pbProgress.setIndeterminate(true); dlgProgress.add(BorderLayout.NORTH, lblStatus); dlgProgress.add(BorderLayout.CENTER, pbProgress); - + // prevent the user from closing the dialog dlgProgress.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dlgProgress.setSize(400, 90); - + // center on screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dlgProgress.setLocation((screenSize.width - dlgProgress.getWidth()) / 2, @@ -952,20 +952,20 @@ public static File setupUnitexToolLogger(File path) { @Override protected Void doInBackground() throws Exception { // execute the setup script - try { + try { // star script Process p = pb.start(); // wait to finish p.waitFor(); } catch (Exception e) { // do nothing - } + } return null; } @Override protected void done() { - //close the modal dialog + //close the modal dialog dlgProgress.dispose(); } }; @@ -976,7 +976,7 @@ protected void done() { dlgProgress.setVisible(true); } } - + // check if UnitexToolLogger exists if(!UnitexToolLogger.exists()) { JOptionPane.showMessageDialog(null, @@ -986,7 +986,7 @@ protected void done() { UnitexToolLogger.getName() + " not found", JOptionPane.INFORMATION_MESSAGE); } - + return UnitexToolLogger; } @@ -1307,7 +1307,7 @@ private static void chooseInitialLanguage() { final TreeSet languages = new TreeSet(); collectLanguage(getUnitexDir(), languages); collectLanguage(getUserDir(), languages); - + String [] langArr = languages.toArray(new String[0]); int defaultLangIndex = -1; String preferedLanguage = PreferencesManager.getUserPreferences().getPreferedLanguage(); @@ -1315,16 +1315,16 @@ private static void chooseInitialLanguage() { for(int i=0; i