[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Mon Jun 2 22:16:14 UTC 2008
kawas
Mon Jun 2 18:16:14 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory dev.open-bio.org:/tmp/cvs-serv27551/src/main/org/biomoby/service/dashboard
Modified Files:
PerlMoSeSPanel.java
Log Message:
added ability for the panel to try and use the cvs version of perl moses if the perl module hasnt been already 'installed' on the machine. One caveat, is that users still have to run moses-install.pl locally on their machine to finalize the configuration of moses.
moby-live/Java/src/main/org/biomoby/service/dashboard PerlMoSeSPanel.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java 2008/05/30 15:49:30 1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java 2008/06/02 22:16:14 1.8
@@ -149,7 +149,7 @@
private boolean enable_moses_actions = true;
// is the user running windows
- private boolean is_windows_pc = false;
+ private boolean is_windows_pc = false, not_installed = false;
private Icon openFileIcon, openFileIconDis, closeFileIcon,
closeFileIconDis, saveFileIcon, saveFileIconDis,
@@ -169,7 +169,47 @@
if (System.getProperty("os.name").startsWith("Windows"))
is_windows_pc = true;
- // determine if perl & moses are installed
+
+ check_install();
+
+ // set up some default values
+ if (!enable_moses_actions){
+ File dir = AntModel.createFileName(
+ new String[]{
+ System.getProperty ("user.dir"),
+ "..",
+ "Perl",
+ "MOSES-MOBY"}
+ );
+ String s = "";
+ if (dir.exists() && dir.isDirectory()) {
+ File f = new File(dir, "lib");
+ // here, we set all values or none of them
+ if (f.exists() && f.isDirectory()) {
+ s = getPrefValue(PM_PERL_LIB_1, "");
+ if (s.equals("")) {
+ // never has been set - set it to cvs path
+ setPrefValue(PM_PERL_LIB_1, f.getPath());
+ }
+ // ignore PM_PERL_LIB_2
+ f = new File(dir, "bin");
+ if (f.exists() && f.isDirectory()) {
+ f = new File(f, "scripts");
+ if (f.exists() && f.isDirectory()) {
+ s = getPrefValue(PM_SCRIPTS_INSTALL_DIR, "");
+ if (s.equals("")) {
+ setPrefValue(PM_SCRIPTS_INSTALL_DIR, f.getPath());
+ }
+ }
+ }
+ }
+ }
+ // this value can be set irregardless of the others
+ s = getPrefValue(PM_PERL_INSTALL_DIR, "");
+ if (s.equals(""))
+ setPrefValue(PM_PERL_INSTALL_DIR, is_windows_pc ? "perl.exe" : "/usr/bin/perl");
+
+ }
}
/*
@@ -178,6 +218,33 @@
*/
private void check_install() {
String[] command;
+ ArrayList<String> prefix = new ArrayList<String>();
+ if (is_windows_pc) {
+ prefix.add("moses-cache-tester.bat");
+ command = prefix.toArray(new String[]{});
+ } else {
+ prefix.add("moses-cache-tester.pl");
+ command = prefix.toArray(new String[]{});
+ }
+ try {
+ Process process;
+ process = Runtime.getRuntime().exec(command);
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(process.getInputStream()));
+
+ while (br.readLine() != null) {
+ //System.out.println(line + System.getProperty("line.separator"));
+ }
+ process.waitFor();
+ enable_moses_actions = true;
+ } catch (Exception e) {
+ enable_moses_actions = false;
+ }
+ }
+
+ // private method that checks if moses is installed given user values
+ private void user_check_install() {
+ String[] command;
ArrayList<String> prefix = generatePerlPrefix();
if (is_windows_pc) {
prefix.add("moses-cache-tester.bat");
@@ -191,8 +258,8 @@
process = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(
new InputStreamReader(process.getInputStream()));
- String line = null;
- while ((line = br.readLine()) != null) {
+
+ while (br.readLine() != null) {
//System.out.println(line + System.getProperty("line.separator"));
}
process.waitFor();
@@ -245,7 +312,6 @@
public JComponent getComponent(PropertyChannel propertyChannel) {
setPropertyChannel(propertyChannel);
-
determineMoSeSDirectory();
// put some properties in the channel
propertyChannel.put(PM_GENERATING_BY_AUTHORITY, new Boolean(false));
@@ -254,6 +320,11 @@
propertyChannel.put(PM_SYNC_DATATYPES, new Boolean(false));
propertyChannel.put(PM_OVERWRITE, new Boolean(false));
propertyChannel.put(PM_CGI, new Boolean(false));
+
+ propertyChannel.put(PM_PERL_INSTALL_DIR, getPrefValue(PM_PERL_INSTALL_DIR, ""));
+ propertyChannel.put(PM_PERL_LIB_1, getPrefValue(PM_PERL_LIB_1, ""));
+ propertyChannel.put(PM_PERL_LIB_2, getPrefValue(PM_PERL_LIB_2, ""));
+ propertyChannel.put(PM_SCRIPTS_INSTALL_DIR, getPrefValue(PM_SCRIPTS_INSTALL_DIR, ""));
propertyChannel.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
@@ -336,7 +407,6 @@
private JPanel getMoSeSPanel() {
- check_install();
JPanel p = new JPanel (new GridBagLayout());
p.setBorder (createFatBorder
("Perl-MoSeS",
@@ -356,7 +426,7 @@
PM_SCRIPTS_INSTALL_DIR,
propertyChannel.getString(PM_SCRIPTS_INSTALL_DIR) + "/");
// check for the scripts
- check_install();
+ user_check_install();
if (enable_moses_actions) {
// we are good to go! enable buttons
syncBtn.setEnabled(enable_moses_actions);
@@ -377,10 +447,13 @@
});
JTextFieldWithHistory lib1 = createText (null, PM_PERL_LIB_1, PM_PERL_LIB_1);
+ lib1.setText(propertyChannel.getString(PM_PERL_LIB_1));
JTextFieldWithHistory lib2 = createText (null, PM_PERL_LIB_2, PM_PERL_LIB_2);
+ lib2.setText(propertyChannel.getString(PM_PERL_LIB_2));
JTextFieldWithHistory install_path = createText (null, PM_SCRIPTS_INSTALL_DIR, PM_SCRIPTS_INSTALL_DIR);
- install_path.setText(is_windows_pc ? "perl.exe" : "/usr/bin/perl");
+ install_path.setText(propertyChannel.getString(PM_SCRIPTS_INSTALL_DIR));
JTextFieldWithHistory perl_install_path = createText(null, PM_PERL_INSTALL_DIR, PM_PERL_INSTALL_DIR);
+ perl_install_path.setText(propertyChannel.getString(PM_PERL_INSTALL_DIR));
SwingUtils.addComponent(sPanel, new JLabel("Perl Path: "), 0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
SwingUtils.addComponent(sPanel, perl_install_path, 1, 0, 3, 1, HORI, NWEST, 1.0, 0.0);
More information about the MOBY-guts
mailing list