| 
      
      
      From: <ox-...@us...> - 2003-06-18 12:21:30
      
     | 
| Update of /cvsroot/sheets/sheets
In directory sc8-pr-cvs1:/tmp/cvs-serv13022
Modified Files:
	Sheets.sheets sheets.mf todo.txt 
Log Message:
1. Added new feature to automatically format code using the Jalopy formatting engine.  (Just right click on a java fragment and choose "auto format").
2. Fixed a bug in the extend class wizard with single line comments.
3. Updated InstallAnywhere to install legal documents, as well as the latest jars needed for Jalopy.
Index: Sheets.sheets
===================================================================
RCS file: /cvsroot/sheets/sheets/Sheets.sheets,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** Sheets.sheets	16 Jun 2003 20:40:00 -0000	1.62
--- Sheets.sheets	18 Jun 2003 12:20:55 -0000	1.63
***************
*** 5160,5163 ****
--- 5160,5164 ----
   import org.browsecode.sheets.*;
   import org.browsecode.sheets.archive.*;
+  import org.browsecode.sheets.archive.Project;
   import org.browsecode.sheets.graph.*;
   import java.lang.ref.*;
***************
*** 5172,5175 ****
--- 5173,5178 ----
   import org.apache.bcel.util.*;
   import org.apache.bcel.classfile.*;
+  import de.hunsicker.jalopy.*;
+  import de.hunsicker.jalopy.storage.*;
  section file-header-for nkramer:655
   nkramer:1852
***************
*** 48164,48168 ****
                                new UncommentSelection(),
                                new TransformFieldToMethod(),
!                               new ExtendClassMethods()
                              };
   }
--- 48167,48173 ----
                                new UncommentSelection(),
                                new TransformFieldToMethod(),
!                               new ExtendClassMethods(),
!                               new AutoFormatFragment(),
!                               new AutoFormatClass()
                              };
   }
***************
*** 53874,53877 ****
--- 53879,53885 ----
     if (type == Viewer.NAVIGATION)
       new GotoFragmentReferences().addToMenu(menu, omit);
+    if (type == Viewer.COMPONENT && !(this instanceof JavaClassFragment)
+          && !(this instanceof JavaFileHeaderFragment))
+      new AutoFormatFragment().addToMenu(menu, omit);
     super.fillContextMenu(menu, type);
   }
***************
*** 53884,53889 ****
       String[] omit = {"java"};
       new GraphJavaHierarchy().addToMenu(menu, omit);
!    } else if (type == Viewer.CONTENTS)
       new ExtendClassMethods().addToMenu(menu, new String[]{"class"});
     super.fillContextMenu(menu, type);
   }
--- 53892,53899 ----
       String[] omit = {"java"};
       new GraphJavaHierarchy().addToMenu(menu, omit);
!    } else if (type == Viewer.CONTENTS) {
!      new AutoFormatClass().addToMenu(menu, null);
       new ExtendClassMethods().addToMenu(menu, new String[]{"class"});
+    }
     super.fillContextMenu(menu, type);
   }
***************
*** 58079,58084 ****
         if (inSingleLineComment && c == '\\n') { // single line comment end
           inSingleLineComment = false;
!          if (commentStartsWithReturn)
!            newHeader.setLength(newHeader.length() - 1);
           commentStartsWithReturn = false;
         } else if (inMultiLineComment && c == '/' && lastc == '*') { // multi line comment end
--- 58089,58094 ----
         if (inSingleLineComment && c == '\\n') { // single line comment end
           inSingleLineComment = false;
!          if (!commentStartsWithReturn)
!            newHeader.append(c);
           commentStartsWithReturn = false;
         } else if (inMultiLineComment && c == '/' && lastc == '*') { // multi line comment end
***************
*** 58147,58165 ****
  section text rgs:10756
   protected void ExtendClassMethods.execute (ViewPanel pane, Viewer compView) {
!    if (compView instanceof JavaViewer
!          && compView.getFragment() instanceof JavaClassFragment) {
!      ExtendJavaClassDialog dialog 
!        = new ExtendJavaClassDialog(Sheets.getRootFrame(), 
!                                    (JavaClassFragment)compView.getFragment());
!      if (dialog.result != null) {
!        JavaViewer view = (JavaViewer) compView;
!        int lastLine = view.dispLines.length - 1;
!        String repl = view.dispLines[lastLine] + dialog.result;
!        view.replaceMultiLines(lastLine, 0,
!                               StringSplitter.split(repl, '\\n'));
!        view.select(0, lastLine + 2, 0, lastLine + 2);
!      }
!    } else
       Console.beep();
   }
  object rgs:10763
--- 58157,58175 ----
  section text rgs:10756
   protected void ExtendClassMethods.execute (ViewPanel pane, Viewer compView) {
!    if (!(compView instanceof JavaViewer
!          && compView.getFragment() instanceof JavaClassFragment)) {
       Console.beep();
+      return;
+    }
+    ExtendJavaClassDialog dialog = new ExtendJavaClassDialog(Sheets.getRootFrame(), 
+                                  (JavaClassFragment)compView.getFragment());
+    if (dialog.result != null) {
+      JavaViewer view = (JavaViewer) compView;
+      int lastLine = view.dispLines.length - 1;
+      String repl = view.dispLines[lastLine] + dialog.result;
+      view.replaceMultiLines(lastLine, 0,
+                             StringSplitter.split(repl, '\\n'));
+      view.select(0, lastLine + 2, 0, lastLine + 2);
+    }
   }
  object rgs:10763
***************
*** 82506,82509 ****
--- 82516,82652 ----
   the machine you are running on.  Use this variable to override the default
   line terminator.
+ object schin:1280
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1280
+  class AutoFormatFragment extends ChangeContainerCommand
+ section exports schin:1280
+  schin:1283
+  schin:1281
+  schin:1282
+  schin:1284
+  schin:1289
+  schin:1290
+  schin:1288
+ object schin:1281
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1281
+  public String AutoFormatFragment.getName() {
+    return "auto-format-fragment";
+  }
+ object schin:1282
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1282
+  protected void AutoFormatFragment.execute(ViewPanel pane, Viewer compView) {
+    if (!(compView.getFragment() instanceof JavaFragment)) {
+      Console.beep();
+      return;
+    }
+    
+    JavaFragment frag = (JavaFragment)compView.getFragment();
+    if (compView.isBeingEdited()) {
+      JavaViewer view = (JavaViewer)compView;
+      autoFormat(frag, view);
+    } else {
+      autoFormat(frag);
+    }
+  }
+ object schin:1283
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1283
+  static Jalopy AutoFormatFragment.jalopy;
+ object schin:1284
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1284
+  static void AutoFormatFragment.createJalopy() {
+    if (jalopy != null)
+      return;
+    jalopy = new Jalopy();
+    jalopy.setFileFormat("\\n");
+  }
+ object schin:1285
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1285
+  class AutoFormatClass extends ChangeContainerCommand
+ section exports schin:1285
+  schin:1286
+  schin:1287
+ object schin:1286
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1286
+  protected void AutoFormatClass.execute (ViewPanel pane, Viewer compView) {
+    if (!(compView.getFragment() instanceof JavaClassFragment))
+      return;
+    
+    JavaClassFragment javaClass = (JavaClassFragment)compView.getFragment();
+    PVector members = javaClass.getMembers();
+    AutoFormatFragment autoFormat = new AutoFormatFragment();
+    for (int i=0; i<members.size(); i++) {
+      JavaFragment member = (JavaFragment)members.elementAt(i);
+      AutoFormatFragment.autoFormat(member);
+    }
+  }
+ object schin:1287
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1287
+  public String AutoFormatClass.getName () {
+    return "auto-format-class";
+  }
+ object schin:1288
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1288
+  protected static void AutoFormatFragment.autoFormat(JavaFragment frag) {
+    String input = frag.toString(Fragment.FULL, false, false);
+    String output = autoFormat(input);
+    if (output == null) {
+      Console.beep();
+      return;
+    }
+    frag.replaceWith(output, false, false, null);
+  }
+ object schin:1289
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1289
+  static String AutoFormatFragment.autoFormat(String input) {
+    createJalopy();
+    String wrappedInput = "public class wrapper {\\n" + input + "\\n}\\n";
+    StringBuffer output = new StringBuffer();
+    
+    Convention.getInstance().putInt(ConventionKeys.INDENT_SIZE, Profile.standardJavaIndent);
+    jalopy.setInput(wrappedInput, "");
+    jalopy.setOutput(output);
+    jalopy.format();
+    if (output.length() == 0)
+      return null;
+    
+    return output.toString().substring(23, output.length() - 3);
+  }
+ object schin:1290
+  pkg=org.browsecode.javaStuff
+  type=java
+ section text schin:1290
+  protected static void AutoFormatFragment.autoFormat(JavaFragment frag, JavaViewer view) {
+    String[] lines = view.toEditableLines();
+    String joinedLines = StringSplitter.join(lines, '\\n');
+    
+    // hack to get rid of unparsable portions of name
+    joinedLines = joinedLines.replaceFirst(frag.getName(view.showingWith("java class name"), view.showingWith("java package name"), false), frag.getName(false, false, false));
+    
+    String output = autoFormat(joinedLines);
+    if (output == null) {
+      Console.beep();
+      return;
+    }
+    view.replaceMultiLines(0, lines.length - 1, JavaFragment.adjustLines(output, (short)(Profile.standardJavaIndent + 1)));
+  }
  object sjc:1
   pkg=org.browsecode.sheets.dicer
***************
*** 97959,97962 ****
--- 98102,98118 ----
   nkramer:29073
   nkramer:29071
+  lightWeight:separator
+  schin:1280
+  schin:1283
+  schin:1284
+  schin:1289
+  schin:1290
+  schin:1288
+  schin:1281
+  schin:1282
+  lightWeight:separator
+  schin:1285
+  schin:1286
+  schin:1287
  object nkramer:2685
   title=JSTExpression
Index: sheets.mf
===================================================================
RCS file: /cvsroot/sheets/sheets/sheets.mf,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sheets.mf	31 Oct 2002 20:15:23 -0000	1.3
--- sheets.mf	18 Jun 2003 12:20:56 -0000	1.4
***************
*** 2,4 ****
  Main-Class: org.browsecode.sheets.Sheets
  Created-By: 1.2 (Sun Microsystems Inc.)
! Class-Path: ox.jar pat.jar kunststoff.jar jlfgr-1_0.jar antlr.jar bcel.jar
--- 2,4 ----
  Main-Class: org.browsecode.sheets.Sheets
  Created-By: 1.2 (Sun Microsystems Inc.)
! Class-Path: ox.jar kunststoff.jar jlfgr-1_0.jar antlrall.jar bcel.jar jalopy.jar log4j
Index: todo.txt
===================================================================
RCS file: /cvsroot/sheets/sheets/todo.txt,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** todo.txt	12 Jun 2003 05:13:18 -0000	1.28
--- todo.txt	18 Jun 2003 12:20:56 -0000	1.29
***************
*** 51,54 ****
--- 51,59 ----
  * Refresh problem on main sheet after wizard closes
  
+ File Mapping:
+ * Should go directly to the file opened after import
+ * Should suppress the sheets starting dialog and the file import progress dialog
+ * Should be intelligent about reimporting the same file twice
+ 
  Nice ideas:
  Extend methods dialog should have an easy way to insert appropriate constructors.
 |