Several problems/bugs fixed: BLD200411022115
authorjlahoda@netbeans.org
Tue, 02 Nov 2004 15:19:08 +0000
changeset 5395c707683da19e
parent 5394 e756bb3a03fa
child 5396 af75eccaa584
Several problems/bugs fixed:
1. Not working xdvi target
2. Not working project's settings dialog for show and build default targets
3. Changes in project's settings not propagated until restart
4. \bibliography and \usepackage argument parts can be separated by commas
5. The arguments (free or error correction) does not end at paragraph end (\n\n), needs more investigation
contrib/latex/ant/src/org/netbeans/modules/latex/ant/tasks/XDVIAntTask.java
contrib/latex/core/src/org/netbeans/modules/latex/model/command/parser/CommandParser.java
contrib/latex/core/test/unit/data/ErrorDetectionAndCorrectionTest/NoErrorTest.tex
contrib/latex/core/test/unit/data/TreeConstructionTest/freearg3.tex
contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testNoError.pass
contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testTest3-best.pass
contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testTest3.pass
contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/TreeConstructionTest/testFreearg1.pass
contrib/latex/core/test/unit/src/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest.java
contrib/latex/editor/src/org/netbeans/modules/latex/editor/AnalyseBib.java
contrib/latex/editor/src/org/netbeans/modules/latex/editor/FileOpen.java
contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.form
contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.java
contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/ProjectSettings.java
contrib/latex/guiproject/test/unit/src/org/netbeans/modules/latex/guiproject/data/main2.tex
contrib/latex/model/src/org/netbeans/modules/latex/model/resources/generic_commands.xml
     1.1 --- a/contrib/latex/ant/src/org/netbeans/modules/latex/ant/tasks/XDVIAntTask.java	Sun Oct 31 21:38:19 2004 +0000
     1.2 +++ b/contrib/latex/ant/src/org/netbeans/modules/latex/ant/tasks/XDVIAntTask.java	Tue Nov 02 15:19:08 2004 +0000
     1.3 @@ -17,6 +17,7 @@
     1.4  import java.io.File;
     1.5  import java.io.IOException;
     1.6  import org.apache.tools.ant.BuildException;
     1.7 +import org.apache.tools.ant.Project;
     1.8  import org.apache.tools.ant.Task;
     1.9  import org.apache.tools.ant.taskdefs.Execute;
    1.10  import org.apache.tools.ant.types.Commandline;
    1.11 @@ -94,6 +95,8 @@
    1.12      }
    1.13  
    1.14      public void execute() throws BuildException {
    1.15 +        log("XDVIAntTask.execute: mainFile= " + mainFile + ", dviFile=" + dviFile, Project.MSG_DEBUG);
    1.16 +        
    1.17          if (mainFile == null && dviFile == null)
    1.18              throw new BuildException("Exactly one of mainfile or dvifile has to be set!");
    1.19  
    1.20 @@ -110,8 +113,17 @@
    1.21                  baseName = mainFile;
    1.22              
    1.23              dviFile = baseName + ".dvi";
    1.24 +            
    1.25 +            File absoluteDVIFile = Utilities.resolveFile(getProject(), dviFile);
    1.26 +            
    1.27 +            if (!absoluteDVIFile.exists())
    1.28 +                throw new BuildException("Mainfile does not exist!");
    1.29 +
    1.30 +            dviFile = absoluteDVIFile.getAbsolutePath();
    1.31          }
    1.32          
    1.33 +        log("XDVIAntTask.execute: computed dviFile=" + dviFile, Project.MSG_DEBUG);
    1.34 +        
    1.35          cmdLine.addArguments(Commandline.translateCommandline(arguments));
    1.36          
    1.37          if (fileName != null) {
    1.38 @@ -138,7 +150,7 @@
    1.39          exec.setAntRun(getProject());
    1.40          
    1.41          try {
    1.42 -            exec.spawn();//execute();
    1.43 +            exec./*spawn();//*/execute();
    1.44          } catch (IOException e) {
    1.45              throw new BuildException(e);
    1.46          }
     2.1 --- a/contrib/latex/core/src/org/netbeans/modules/latex/model/command/parser/CommandParser.java	Sun Oct 31 21:38:19 2004 +0000
     2.2 +++ b/contrib/latex/core/src/org/netbeans/modules/latex/model/command/parser/CommandParser.java	Tue Nov 02 15:19:08 2004 +0000
     2.3 @@ -269,11 +269,23 @@
     2.4          
     2.5          if (param.hasAttribute("use-file-argument")) {
     2.6              String   extensionsString = param.getAttribute("use-file-argument-extensions");
     2.7 -            String   fileName = ani.getText().toString();
     2.8 -            FileObject file = findFile(fileName, extensionsString);
     2.9 +            String   separator        = param.getAttribute("files-separator");
    2.10 +            String   fileNames        = ani.getText().toString();
    2.11              
    2.12 -            if (file != null) {
    2.13 -                ((NBDocumentNodeImpl) ani.getDocumentNode()).addUsedFile(file);
    2.14 +            String[] fileNamesArray = null;
    2.15 +            
    2.16 +            if (separator != null) {
    2.17 +                fileNamesArray = fileNames.split(separator);
    2.18 +            } else {
    2.19 +                fileNamesArray = new String[] {fileNames};
    2.20 +            }
    2.21 +                
    2.22 +            for (int cntr = 0; cntr < fileNamesArray.length; cntr++) {
    2.23 +                FileObject file = findFile(fileNamesArray[cntr], extensionsString);
    2.24 +                
    2.25 +                if (file != null) {
    2.26 +                    ((NBDocumentNodeImpl) ani.getDocumentNode()).addUsedFile(file);
    2.27 +                }
    2.28              }
    2.29          }
    2.30      }
    2.31 @@ -377,7 +389,7 @@
    2.32              if (param.hasAttribute(Command.Param.ATTR_NO_PARSE))
    2.33                  handleAddArgument(cni, currentArgument, (ArgumentNodeImpl) parseBalancedText(input, ani, true /*!!!!!!*/));
    2.34              else
    2.35 -                handleAddArgument(cni, currentArgument, (ArgumentNodeImpl) parseGroup(input, ani, true, freeText, true /*!!!!!!*/));
    2.36 +                handleAddArgument(cni, currentArgument, (ArgumentNodeImpl) parseGroup(input, ani, true, freeText, true/*!!!!!!*/));
    2.37              
    2.38              currentArgument++;
    2.39              
    2.40 @@ -399,11 +411,16 @@
    2.41  
    2.42          if ("\\usepackage".equals(cni.getCommand().getCommand())) {//TODO: this is quite obsolette way :-)
    2.43              if (cni.getArgumentCount() == cni.getCommand().getArgumentCount()) {
    2.44 +                String collectionsSpecification = cni.getArgument(1).getText().toString();
    2.45 +                String[] collections = collectionsSpecification.split(",");
    2.46                  CommandCollection coll = new CommandCollection();
    2.47                  
    2.48 -                coll.addPackageContent(cni.getArgument(1).getText().toString());
    2.49 +                for (int cntr = 0; cntr < collections.length; cntr++) {
    2.50 +                    coll.addPackageContent(collections[cntr]);
    2.51 +                }
    2.52 +                
    2.53                  cni.setCommandCollection(coll);
    2.54 -                currentCommandDefiningNode = cni;
    2.55 +                currentCommandDefiningNode = cni;                
    2.56              }
    2.57          }
    2.58          
    2.59 @@ -562,13 +579,13 @@
    2.60              Command cmd = findCommand(parent, input, read.getText());
    2.61              return cmd != null ? cmd.isPARLike() : false;
    2.62          } else
    2.63 -            return read.getId() == TexLanguage.PARAGRAPH_END;
    2.64 +            return false;//read.getId() == TexLanguage.PARAGRAPH_END;
    2.65      }
    2.66      
    2.67      private boolean isFreeTextEnd(Token read, ParserInput input, Node parent) {
    2.68          return    read.getId() == TexLanguage.COMP_BRACKET_RIGHT
    2.69 -               /*|| read.getId() == TexLanguage.COMP_BRACKET_LEFT
    2.70 -               || read.getId() == TexLanguage.PARAGRAPH_END*/
    2.71 +               /*|| read.getId() == TexLanguage.COMP_BRACKET_LEFT*/
    2.72 +               /*|| read.getId() == TexLanguage.PARAGRAPH_END*/
    2.73                 || isPAREnd(read, input, parent);
    2.74      }
    2.75      
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/contrib/latex/core/test/unit/data/ErrorDetectionAndCorrectionTest/NoErrorTest.tex	Tue Nov 02 15:19:08 2004 +0000
     3.3 @@ -0,0 +1,14 @@
     3.4 +\documentclass{article}
     3.5 +
     3.6 +\newcommand{\test}[1]{}
     3.7 +
     3.8 +\begin{document}
     3.9 +
    3.10 +\test{
    3.11 +
    3.12 +
    3.13 +
    3.14 +
    3.15 +}
    3.16 +
    3.17 +\end{document}
     4.1 --- a/contrib/latex/core/test/unit/data/TreeConstructionTest/freearg3.tex	Sun Oct 31 21:38:19 2004 +0000
     4.2 +++ b/contrib/latex/core/test/unit/data/TreeConstructionTest/freearg3.tex	Tue Nov 02 15:19:08 2004 +0000
     4.3 @@ -3,5 +3,9 @@
     4.4  \begin{document}
     4.5  test\huge{ test} test test
     4.6  
     4.7 +
     4.8 +
     4.9 +
    4.10 +
    4.11  test
    4.12  \end{document}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testTest3-best.pass	Tue Nov 02 15:19:08 2004 +0000
     5.3 @@ -0,0 +1,2 @@
     5.4 +(8:0):Missing closing bracket added.
     5.5 +(8:13):Missing closing bracket added.
     6.1 --- a/contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testTest3.pass	Sun Oct 31 21:38:19 2004 +0000
     6.2 +++ b/contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest/testTest3.pass	Tue Nov 02 15:19:08 2004 +0000
     6.3 @@ -1,2 +1,2 @@
     6.4  (8:0):Missing closing bracket added.
     6.5 -(8:13):Missing closing bracket added.
     6.6 +(10:0):Missing closing bracket added.
     7.1 --- a/contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/TreeConstructionTest/testFreearg1.pass	Sun Oct 31 21:38:19 2004 +0000
     7.2 +++ b/contrib/latex/core/test/unit/data/goldenfiles/org/netbeans/modules/latex/command/parser/TreeConstructionTest/testFreearg1.pass	Tue Nov 02 15:19:08 2004 +0000
     7.3 @@ -49,12 +49,12 @@
     7.4  <CommandNodeImpl name="\huge">
     7.5  <positions>
     7.6  <position><![CDATA[Position:[file=freearg1.tex, line=3, column=4, offset=46]]]></position>
     7.7 -<position><![CDATA[Position:[file=freearg1.tex, line=3, column=24, offset=66]]]></position>
     7.8 +<position><![CDATA[Position:[file=freearg1.tex, line=7, column=0, offset=74]]]></position>
     7.9  </positions>
    7.10  <ArgumentNodeImpl>
    7.11  <positions>
    7.12  <position><![CDATA[Position:[file=freearg1.tex, line=3, column=10, offset=52]]]></position>
    7.13 -<position><![CDATA[Position:[file=freearg1.tex, line=3, column=24, offset=66]]]></position>
    7.14 +<position><![CDATA[Position:[file=freearg1.tex, line=7, column=0, offset=74]]]></position>
    7.15  </positions>
    7.16  </ArgumentNodeImpl>
    7.17  </CommandNodeImpl>
     8.1 --- a/contrib/latex/core/test/unit/src/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest.java	Sun Oct 31 21:38:19 2004 +0000
     8.2 +++ b/contrib/latex/core/test/unit/src/org/netbeans/modules/latex/command/parser/ErrorDetectionAndCorrectionTest.java	Tue Nov 02 15:19:08 2004 +0000
     8.3 @@ -84,6 +84,10 @@
     8.4      public void testTest5() throws Exception {
     8.5          performTest("Test5.tex");
     8.6      }
     8.7 +    
     8.8 +    public void testNoError() throws Exception {
     8.9 +        performTest("NoErrorTest.tex");
    8.10 +    }
    8.11  
    8.12      public void performTest(String testFileName) throws Exception {
    8.13  //        doTest("org/netbeans/test/latex/parser/data/testfiles/ErrorDetectionAndCorrection/" + name + ".tex");
     9.1 --- a/contrib/latex/editor/src/org/netbeans/modules/latex/editor/AnalyseBib.java	Sun Oct 31 21:38:19 2004 +0000
     9.2 +++ b/contrib/latex/editor/src/org/netbeans/modules/latex/editor/AnalyseBib.java	Tue Nov 02 15:19:08 2004 +0000
     9.3 @@ -18,6 +18,7 @@
     9.4  import java.util.ArrayList;
     9.5  import java.util.Iterator;
     9.6  import java.util.List;
     9.7 +import java.util.StringTokenizer;
     9.8  import org.netbeans.modules.latex.model.bibtex.BiBTeXModel;
     9.9  import org.netbeans.modules.latex.model.bibtex.Entry;
    9.10  import org.netbeans.modules.latex.model.bibtex.PublicationEntry;
    9.11 @@ -105,15 +106,20 @@
    9.12              node.traverse(new DefaultTraverseHandler() {
    9.13                  public boolean commandStart(CommandNode node) {
    9.14                      if ("\\bibliography".equals(node.getCommand().getCommand())) {
    9.15 -                        String bibFileName = node.getArgument(0).getText().toString();
    9.16 -                        Object file        = source.getMainFile();
    9.17 +                        String          bibFileNames = node.getArgument(0).getText().toString();
    9.18 +                        StringTokenizer divider      = new StringTokenizer(bibFileNames, ",");
    9.19                          
    9.20 -                        try {
    9.21 -                            result.addAll(getDefault().getReferences(file, bibFileName));
    9.22 -                        } catch (IOException e) {
    9.23 -                            ErrorManager.getDefault().notifyInformational(e);
    9.24 -                        } catch (IllegalArgumentException e) {
    9.25 -                            ErrorManager.getDefault().notifyInformational(e);
    9.26 +                        while (divider.hasMoreTokens()) {
    9.27 +                            String bibFileName  = divider.nextToken();
    9.28 +                            Object file         = source.getMainFile();
    9.29 +                            
    9.30 +                            try {
    9.31 +                                result.addAll(getDefault().getReferences(file, bibFileName));
    9.32 +                            } catch (IOException e) {
    9.33 +                                ErrorManager.getDefault().notifyInformational(e);
    9.34 +                            } catch (IllegalArgumentException e) {
    9.35 +                                ErrorManager.getDefault().notifyInformational(e);
    9.36 +                            }
    9.37                          }
    9.38                      }
    9.39                      
    10.1 --- a/contrib/latex/editor/src/org/netbeans/modules/latex/editor/FileOpen.java	Sun Oct 31 21:38:19 2004 +0000
    10.2 +++ b/contrib/latex/editor/src/org/netbeans/modules/latex/editor/FileOpen.java	Tue Nov 02 15:19:08 2004 +0000
    10.3 @@ -64,6 +64,8 @@
    10.4      private static class NBFileOpen extends FileOpen {
    10.5          
    10.6          public JTextComponent assureOpen(File fileName) {
    10.7 +            fileName = FileUtil.normalizeFile(fileName);
    10.8 +            
    10.9              FileObject toOpenFO = FileUtil.toFileObject(fileName);
   10.10              
   10.11              if (toOpenFO == null)
    11.1 --- a/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.form	Sun Oct 31 21:38:19 2004 +0000
    11.2 +++ b/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.form	Tue Nov 02 15:19:08 2004 +0000
    11.3 @@ -7,7 +7,7 @@
    11.4      <Component class="javax.swing.JLabel" name="jLabel1">
    11.5        <Properties>
    11.6          <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
    11.7 -          <Connection code="getDefaultItemDisplayName()" type="code"/>
    11.8 +          <Connection code="label&#xa;        " type="code"/>
    11.9          </Property>
   11.10        </Properties>
   11.11        <Constraints>
    12.1 --- a/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.java	Sun Oct 31 21:38:19 2004 +0000
    12.2 +++ b/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/BuildPanel.java	Tue Nov 02 15:19:08 2004 +0000
    12.3 @@ -14,21 +14,31 @@
    12.4   */
    12.5  package org.netbeans.modules.latex.guiproject.ui;
    12.6  
    12.7 +import java.beans.BeanInfo;
    12.8 +import java.beans.IntrospectionException;
    12.9 +import java.beans.Introspector;
   12.10 +import java.beans.PropertyDescriptor;
   12.11 +import java.lang.reflect.InvocationTargetException;
   12.12 +import java.lang.reflect.Method;
   12.13  import java.util.Collection;
   12.14  import javax.swing.DefaultComboBoxModel;
   12.15 +import org.netbeans.modules.latex.guiproject.LaTeXGUIProject;
   12.16 +import org.openide.ErrorManager;
   12.17  
   12.18  /**
   12.19   *
   12.20   * @author Jan Lahoda
   12.21   */
   12.22 -public class BuildPanel extends javax.swing.JPanel {
   12.23 +public class BuildPanel extends javax.swing.JPanel implements StorableSettingsPresenter {
   12.24      
   12.25 -    private String defaultItemDisplayName;
   12.26 +    private String label;
   12.27 +    private String propertyName;
   12.28      private Collection targets;
   12.29      
   12.30      /** Creates new form BuildPanel */
   12.31 -    public BuildPanel(String defaultItemDisplayName, Collection targets) {
   12.32 -        this.defaultItemDisplayName = defaultItemDisplayName;
   12.33 +    public BuildPanel(String label, Collection targets, String propertyName) {
   12.34 +        this.label = label;
   12.35 +        this.propertyName = propertyName;
   12.36          this.targets = targets;
   12.37          
   12.38          initComponents();
   12.39 @@ -47,7 +57,8 @@
   12.40  
   12.41          setLayout(new java.awt.GridBagLayout());
   12.42  
   12.43 -        jLabel1.setText(getDefaultItemDisplayName());
   12.44 +        jLabel1.setText(label
   12.45 +        );
   12.46          gridBagConstraints = new java.awt.GridBagConstraints();
   12.47          gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
   12.48          gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 3);
   12.49 @@ -68,11 +79,91 @@
   12.50      private javax.swing.JLabel jLabel1;
   12.51      // End of variables declaration//GEN-END:variables
   12.52      
   12.53 +    private PropertyDescriptor findPropertyDescriptor(BeanInfo info, String propertyName) {
   12.54 +        PropertyDescriptor[] pds = info.getPropertyDescriptors();
   12.55 +        
   12.56 +        for (int cntr = 0; cntr < pds.length; cntr++) {
   12.57 +            PropertyDescriptor pd = pds[cntr];
   12.58 +            if (propertyName.equals(pd.getName()))
   12.59 +                return pd;
   12.60 +        }
   12.61 +        
   12.62 +        return null;
   12.63 +    }
   12.64 +    
   12.65 +    public void load(ProjectSettings settings) {
   12.66 +        try {
   12.67 +            BeanInfo propertySettingsInfo = Introspector.getBeanInfo(ProjectSettings.class);
   12.68 +            PropertyDescriptor property = findPropertyDescriptor(propertySettingsInfo, propertyName);
   12.69 +            
   12.70 +            assert property != null;
   12.71 +            assert property.getReadMethod() != null;
   12.72 +            assert property.getWriteMethod() != null;
   12.73 +            
   12.74 +            Method read = property.getReadMethod();
   12.75 +            String defaultTarget = (String) read.invoke(settings, new Object[0]);
   12.76 +            
   12.77 +            jComboBox1.setSelectedItem(defaultTarget);
   12.78 +        } catch (IntrospectionException e) {
   12.79 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
   12.80 +            
   12.81 +            ErrorManager.getDefault().annotate(ex, e);
   12.82 +            throw ex;
   12.83 +        } catch (IllegalAccessException e) {
   12.84 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
   12.85 +            
   12.86 +            ErrorManager.getDefault().annotate(ex, e);
   12.87 +            throw ex;
   12.88 +        } catch (IllegalArgumentException e) {
   12.89 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
   12.90 +            
   12.91 +            ErrorManager.getDefault().annotate(ex, e);
   12.92 +            throw ex;
   12.93 +        } catch (InvocationTargetException e) {
   12.94 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
   12.95 +            
   12.96 +            ErrorManager.getDefault().annotate(ex, e);
   12.97 +            throw ex;
   12.98 +        }
   12.99 +    }
  12.100 +    
  12.101 +    public void store(ProjectSettings settings) {
  12.102 +        try {
  12.103 +            BeanInfo propertySettingsInfo = Introspector.getBeanInfo(ProjectSettings.class);
  12.104 +            PropertyDescriptor property = findPropertyDescriptor(propertySettingsInfo, propertyName);
  12.105 +            
  12.106 +            assert property != null;
  12.107 +            assert property.getReadMethod() != null;
  12.108 +            assert property.getWriteMethod() != null;
  12.109 +            
  12.110 +            Method write = property.getWriteMethod();
  12.111 +            
  12.112 +            write.invoke(settings, new Object[] {jComboBox1.getSelectedItem()});
  12.113 +        } catch (IntrospectionException e) {
  12.114 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
  12.115 +            
  12.116 +            ErrorManager.getDefault().annotate(ex, e);
  12.117 +            throw ex;
  12.118 +        } catch (IllegalAccessException e) {
  12.119 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
  12.120 +            
  12.121 +            ErrorManager.getDefault().annotate(ex, e);
  12.122 +            throw ex;
  12.123 +        } catch (IllegalArgumentException e) {
  12.124 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
  12.125 +            
  12.126 +            ErrorManager.getDefault().annotate(ex, e);
  12.127 +            throw ex;
  12.128 +        } catch (InvocationTargetException e) {
  12.129 +            IllegalStateException ex = new IllegalStateException(e.getMessage());
  12.130 +            
  12.131 +            ErrorManager.getDefault().annotate(ex, e);
  12.132 +            throw ex;
  12.133 +        }
  12.134 +    }
  12.135 +    
  12.136      private Collection getBuildCommandsList() {
  12.137          return targets;
  12.138      }
  12.139 -    
  12.140 -    private String getDefaultItemDisplayName() {
  12.141 -        return defaultItemDisplayName;
  12.142 -    }
  12.143 +
  12.144  }
    13.1 --- a/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/ProjectSettings.java	Sun Oct 31 21:38:19 2004 +0000
    13.2 +++ b/contrib/latex/guiproject/src/org/netbeans/modules/latex/guiproject/ui/ProjectSettings.java	Tue Nov 02 15:19:08 2004 +0000
    13.3 @@ -14,6 +14,7 @@
    13.4   */
    13.5  package org.netbeans.modules.latex.guiproject.ui;
    13.6  
    13.7 +import java.awt.Dialog;
    13.8  import java.io.IOException;
    13.9  import java.io.InputStream;
   13.10  import java.io.OutputStream;
   13.11 @@ -21,16 +22,23 @@
   13.12  import java.util.WeakHashMap;
   13.13  import org.netbeans.modules.latex.guiproject.EditableProperties;
   13.14  import org.netbeans.modules.latex.guiproject.LaTeXGUIProject;
   13.15 +import org.openide.DialogDescriptor;
   13.16 +import org.openide.DialogDisplayer;
   13.17  import org.openide.ErrorManager;
   13.18 +import org.openide.filesystems.FileAttributeEvent;
   13.19 +import org.openide.filesystems.FileChangeListener;
   13.20 +import org.openide.filesystems.FileEvent;
   13.21  import org.openide.filesystems.FileLock;
   13.22  import org.openide.filesystems.FileObject;
   13.23 +import org.openide.filesystems.FileRenameEvent;
   13.24 +import org.openide.filesystems.FileUtil;
   13.25  
   13.26  
   13.27  /**
   13.28   *
   13.29   * @author Jan Lahoda
   13.30   */
   13.31 -public class ProjectSettings {
   13.32 +public class ProjectSettings implements FileChangeListener {
   13.33      
   13.34      private String   latexCommand;
   13.35      private String   sourceSpecialsCommand;
   13.36 @@ -48,8 +56,16 @@
   13.37      private LaTeXGUIProject project;
   13.38      
   13.39      /** Creates a new instance of ProjectSettings */
   13.40 -    /*package private, for tests!*/ ProjectSettings(LaTeXGUIProject project) {
   13.41 +    /*package private, for tests!*/ ProjectSettings(LaTeXGUIProject project, /*only for tests, for other purposes default to true:*/boolean listenOnFileChanges) {
   13.42          this.project = project;
   13.43 +        
   13.44 +        if (listenOnFileChanges) {
   13.45 +            //install listener to the settings file, so we are notified on changes:
   13.46 +            FileObject settingsFile = getSettingsFile();
   13.47 +            
   13.48 +            settingsFile.addFileChangeListener(FileUtil.weakFileChangeListener(this, settingsFile));
   13.49 +        }
   13.50 +        
   13.51          load();
   13.52      }
   13.53      
   13.54 @@ -86,13 +102,18 @@
   13.55          defaultShowCommand  = getProperty(p, "default-show-target", "show");
   13.56      }
   13.57      
   13.58 -    private void load() {
   13.59 -        FileObject settings = project.getProjectDirectory().getFileObject("build-settings.properties");
   13.60 +    private FileObject getSettingsFile() {
   13.61 +        return project.getProjectDirectory().getFileObject("build-settings.properties");
   13.62 +    }
   13.63 +    
   13.64 +    private synchronized void load() {
   13.65 +        FileObject settings = getSettingsFile();
   13.66          
   13.67          InputStream ins = null;
   13.68          try {
   13.69              ins = settings.getInputStream();
   13.70              loadFrom(ins);
   13.71 +            modified = false;
   13.72          } catch (IOException e) {
   13.73              ErrorManager.getDefault().notify(e);
   13.74          } finally {
   13.75 @@ -117,13 +138,17 @@
   13.76          return argumentsString.toString();
   13.77      }
   13.78      
   13.79 -    private void save() {
   13.80 -        FileObject settings = project.getProjectDirectory().getFileObject("build-settings.properties");
   13.81 +    private boolean writing = false;
   13.82 +    
   13.83 +    private synchronized void save() {
   13.84 +        FileObject settings = getSettingsFile();
   13.85          FileLock lock = null;
   13.86          
   13.87          InputStream ins = null;
   13.88          OutputStream outs = null;
   13.89          try {
   13.90 +            writing = true;
   13.91 +            
   13.92              EditableProperties p = new EditableProperties();
   13.93              
   13.94              ins = settings.getInputStream();
   13.95 @@ -154,6 +179,8 @@
   13.96              outs.close();
   13.97              
   13.98              outs = null;
   13.99 +            
  13.100 +            modified = false;
  13.101          } catch (IOException e) {
  13.102              ErrorManager.getDefault().notify(e);
  13.103          } finally {
  13.104 @@ -174,6 +201,8 @@
  13.105              
  13.106              if (lock != null)
  13.107                  lock.releaseLock();
  13.108 +            
  13.109 +            writing = false;
  13.110          }
  13.111      }
  13.112      
  13.113 @@ -183,7 +212,7 @@
  13.114          ProjectSettings s = (ProjectSettings) project2Settings.get(p);
  13.115          
  13.116          if (s == null) {
  13.117 -            s = new ProjectSettings(p);
  13.118 +            s = new ProjectSettings(p, true);
  13.119              project2Settings.put(p, s);
  13.120          }
  13.121          
  13.122 @@ -194,7 +223,7 @@
  13.123          return latexCommand;
  13.124      }
  13.125      
  13.126 -    public void setLatexCommand(String latexCommand) {
  13.127 +    public synchronized void setLatexCommand(String latexCommand) {
  13.128          this.latexCommand = latexCommand;
  13.129          this.modified = true;
  13.130      }
  13.131 @@ -203,7 +232,7 @@
  13.132          return bibtexCommand;
  13.133      }
  13.134      
  13.135 -    public void setBiBTeXCommand(String bibtexCommand) {
  13.136 +    public synchronized void setBiBTeXCommand(String bibtexCommand) {
  13.137          this.bibtexCommand = bibtexCommand;
  13.138          this.modified = true;
  13.139      }
  13.140 @@ -212,7 +241,7 @@
  13.141          return sourceSpecialsCommand;
  13.142      }
  13.143      
  13.144 -    public void setSourceSpecialsCommand(String sourceSpecialsCommand) {
  13.145 +    public synchronized void setSourceSpecialsCommand(String sourceSpecialsCommand) {
  13.146          this.sourceSpecialsCommand = sourceSpecialsCommand;
  13.147          this.modified = true;
  13.148      }
  13.149 @@ -221,7 +250,7 @@
  13.150          return useSourceSpecials;
  13.151      }
  13.152      
  13.153 -    public void setUseSourceSpecials(boolean useSourceSpecials) {
  13.154 +    public synchronized void setUseSourceSpecials(boolean useSourceSpecials) {
  13.155          this.useSourceSpecials = useSourceSpecials;
  13.156          this.modified = true;
  13.157      }
  13.158 @@ -230,7 +259,7 @@
  13.159          return latexArguments;
  13.160      }
  13.161      
  13.162 -    public void setLaTeXArguments(String[] arguments) {
  13.163 +    public synchronized void setLaTeXArguments(String[] arguments) {
  13.164          this.latexArguments = arguments;
  13.165          this.modified = true;
  13.166      }
  13.167 @@ -239,12 +268,12 @@
  13.168          return bibtexArguments;
  13.169      }
  13.170      
  13.171 -    public void setBiBTeXArguments(String[] arguments) {
  13.172 +    public synchronized void setBiBTeXArguments(String[] arguments) {
  13.173          this.bibtexArguments = arguments;
  13.174          this.modified = true;
  13.175      }
  13.176      
  13.177 -    public boolean isModified() {
  13.178 +    public synchronized boolean isModified() {
  13.179          return modified;
  13.180      }
  13.181      
  13.182 @@ -263,7 +292,7 @@
  13.183          return defaultBuildCommand;
  13.184      }
  13.185  
  13.186 -    public void setDefaultBuildCommand(String defaultBuildCommand) {
  13.187 +    public synchronized void setDefaultBuildCommand(String defaultBuildCommand) {
  13.188          this.defaultBuildCommand = defaultBuildCommand;
  13.189          modified = true;
  13.190      }
  13.191 @@ -272,8 +301,49 @@
  13.192          return defaultShowCommand;
  13.193      }
  13.194  
  13.195 -    public void setDefaultShowCommand(String defaultShowCommand) {
  13.196 +    public synchronized void setDefaultShowCommand(String defaultShowCommand) {
  13.197          this.defaultShowCommand = defaultShowCommand;
  13.198          modified = true;
  13.199      }
  13.200 +
  13.201 +    public void fileRenamed(FileRenameEvent fe) {
  13.202 +        //don't know how to react on this
  13.203 +    }
  13.204 +
  13.205 +    public void fileAttributeChanged(FileAttributeEvent fe) {
  13.206 +        //ignored
  13.207 +    }
  13.208 +
  13.209 +    public void fileFolderCreated(FileEvent fe) {
  13.210 +        //ignored
  13.211 +    }
  13.212 +
  13.213 +    public void fileDeleted(FileEvent fe) {
  13.214 +        //don't know how to react on this
  13.215 +    }
  13.216 +
  13.217 +    public void fileDataCreated(FileEvent fe) {
  13.218 +        //should not happen?
  13.219 +    }
  13.220 +
  13.221 +    public synchronized void fileChanged(FileEvent fe) {
  13.222 +        System.err.println("fileChanged(" + fe + ")");
  13.223 +        
  13.224 +        if (writing)
  13.225 +            return ;
  13.226 +        
  13.227 +        if (!isModified()) {
  13.228 +            load();
  13.229 +            return ;
  13.230 +        }
  13.231 +        
  13.232 +        DialogDescriptor dd = new DialogDescriptor("The settings for LaTeX project: " + project.getDisplayName() + " has been changed on disk and are also changed in memory. Drop the in-memory changes?", "External modification");
  13.233 +        Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
  13.234 +        
  13.235 +        dialog.show();
  13.236 +        
  13.237 +        if (dd.getValue() == DialogDescriptor.OK_OPTION) {
  13.238 +            load();
  13.239 +        }
  13.240 +    }
  13.241  }
    14.1 --- a/contrib/latex/guiproject/test/unit/src/org/netbeans/modules/latex/guiproject/data/main2.tex	Sun Oct 31 21:38:19 2004 +0000
    14.2 +++ b/contrib/latex/guiproject/test/unit/src/org/netbeans/modules/latex/guiproject/data/main2.tex	Tue Nov 02 15:19:08 2004 +0000
    14.3 @@ -4,7 +4,6 @@
    14.4  \include{included2a.tex}
    14.5  \include{included2b.tex}
    14.6  
    14.7 -\bibliography{bibdatabase2a}
    14.8 -\bibliography{bibdatabase2b}
    14.9 +\bibliography{bibdatabase2a,bibdatabase2b}
   14.10  
   14.11  \end{document}
    15.1 --- a/contrib/latex/model/src/org/netbeans/modules/latex/model/resources/generic_commands.xml	Sun Oct 31 21:38:19 2004 +0000
    15.2 +++ b/contrib/latex/model/src/org/netbeans/modules/latex/model/resources/generic_commands.xml	Tue Nov 02 15:19:08 2004 +0000
    15.3 @@ -323,6 +323,7 @@
    15.4      <attribute name="#code" value="true" />
    15.5      <attribute name="use-file-argument" value="true" />
    15.6      <attribute name="use-file-argument-extensions" value="bib" />
    15.7 +    <attribute name="files-separator" value="," />
    15.8    </argument>
    15.9  </command>
   15.10