Skip to content

Commit

Permalink
[feature #124] Refactor spaces in Config.java
Browse files Browse the repository at this point in the history
  • Loading branch information
selgueti committed May 25, 2022
1 parent eadd9b0 commit d3bed0e
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions unitex/src/fr/umlv/unitex/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Config {
*/
private static File applicationDir;
private static File unitexToolLogger;

/**
* Path of the directory <code>.../Unitex</code>
*/
Expand Down Expand Up @@ -489,15 +489,15 @@ 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)
{
if (jFileChooser != null)
return jFileChooser;
jFileChooser = new JFileChooser();
final PersonalFileFilter fileFilter=new PersonalFileFilter(extension,
description);
description);
jFileChooser.addChoosableFileFilter(fileFilter);
jFileChooser.setFileFilter(fileFilter);
jFileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
Expand All @@ -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)
Expand Down Expand Up @@ -563,7 +563,7 @@ public static JFileChooser getTransducerListDialogBox() {
//transducerListDialogBox.setControlButtonsAreShown(false);
return transducerListDialogBox;
}

public static JFileChooser getExploreGraphOutputDialogBox() {
if (exploreGraphOutputDialogBox != null)
return exploreGraphOutputDialogBox;
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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" : ""));
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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();
}
};
Expand All @@ -976,7 +976,7 @@ protected void done() {
dlgProgress.setVisible(true);
}
}

// check if UnitexToolLogger exists
if(!UnitexToolLogger.exists()) {
JOptionPane.showMessageDialog(null,
Expand All @@ -986,7 +986,7 @@ protected void done() {
UnitexToolLogger.getName() + " not found",
JOptionPane.INFORMATION_MESSAGE);
}

return UnitexToolLogger;
}

Expand Down Expand Up @@ -1307,24 +1307,24 @@ private static void chooseInitialLanguage() {
final TreeSet<String> languages = new TreeSet<String>();
collectLanguage(getUnitexDir(), languages);
collectLanguage(getUserDir(), languages);

String [] langArr = languages.toArray(new String[0]);
int defaultLangIndex = -1;
String preferedLanguage = PreferencesManager.getUserPreferences().getPreferedLanguage();
if(preferedLanguage != null)
for(int i=0; i<langArr.length && defaultLangIndex == -1; i++)
if(preferedLanguage.equals(langArr[i]))
defaultLangIndex = i;

final JComboBox langList = new JComboBox(langArr);
if(defaultLangIndex != -1)
langList.setSelectedIndex(defaultLangIndex);

p.add(new JLabel("User: " + getUserName()));
p.add(new JLabel("Choose the language you want"));
p.add(new JLabel("to work on:"));
p.add(langList);

final JFrame frame = new JFrame();
frame.setAlwaysOnTop(true);
final String[] options = { "OK", "Exit" };
Expand All @@ -1336,7 +1336,7 @@ private static void chooseInitialLanguage() {
String selectedItem = (String) (langList.getSelectedItem());
setCurrentLanguage(selectedItem);
PreferencesManager.getUserPreferences().setPreferedLanguage(selectedItem);

}

/**
Expand Down

0 comments on commit d3bed0e

Please sign in to comment.