Hi - this was a while ago, but I thought it might be worth a reply still...
On Tue, 15 May 2001 15:01:37 -0400, Daniel Hegyi wrote:
>For such large projects how do you solve version controlling? I'm using VAJ
>at work, because
>a) It manages changes to the code by keeping track of previous editions of
>the code
>
>b) It has a built-in EJB engine, so that I can test my beans without having
>to deploy them on WebSphere.
>
>VAJ's editor, however, is inferior to Emacs and JDE! Has anybody
>successfully linked Emacs and VAJ so that the code can be edited in Emacs?
Yep - it's pretty straightforward in fact. Have a look at this article :
http://www7.software.ibm.com/vad.nsf/Data/Document2335?OpenDocument&p=1&BCT=3&Footer=1
(I'm not totally sure if you need to register to read it - if you can't get
to this page, e-mail me and I'll send you the PDF).
This should give you the general techniques to create an external editor
class, and install it into the VAJ ide.
I use gnuclient to connect to emacs instead of running emacs directly.
This means I can connect to an already running emacs session, edit a class,
and press Ctrl-X # to return to Visual Age.
The actual editor class we use is as follows. Note there are a few hacky
bits, like the explicit path to get to gnuclient - this could probably be
cleaned up a lot...
package com.blah.blah.ivj;
import com.ibm.ivj.util.base.*;
import com.ibm.ivj.util.builders.*;
import java.io.*;
public class ExternalEditor
{
private static String editorName =
"c:\\apps\\emacs\\bin\\gnuclient.exe";
public static void main(String[] args)
{
try
{
Workspace theWS = ToolEnv.connectToWorkspace();
String exportData_fullClassName = args[1];
String exportData_className =
exportData_fullClassName
.substring( exportData_fullClassName.lastIndexOf('.')+1);
String exportData_directoryName = theWS.getTempDirectory();
String exportData_fileName = new
String(exportData_directoryName +
"\\" + exportData_className + ".java");
Project exportProject
= theWS.loadedTypeNamed(
exportData_fullClassName).getProject();
boolean exportSuccess
= doExport(theWS, exportData_fullClassName,
exportData_directoryName);
if (exportSuccess)
{
boolean successfullImport = false;
while (successfullImport == false)
{
// Run the editor
// Run passing the complete path to filename
Process exEd
= Runtime.getRuntime().exec(editorName
+ " " + '\"' + exportData_fileName + '\"');
// Wait for it to terminate
try
{
exEd.waitFor();
}
// If it's unexpectedly terminated.. try the import
// anyway but warn people on console
catch (InterruptedException e)
{
System.out.println("Editor was Interrupted!");
}
successfullImport= doImport(theWS, exportData_fileName,
exportData_className, exportData_directoryName,
exportProject) ;
}
}
}
catch(Exception ex)
{
System.out.println("Exception thrown! " + ex);
}
}
/** Exports the selected class to a java file
* @param theWS The current workspace
* @param exportData_fullClassName The full package + className
* @param exportData_directoryName The directory name to be exported to
*/
private static boolean doExport(Workspace theWS,
String exportData_fullClassName, String exportData_directoryName)
{
// Set up an Export Specification for IVJ
ExportCodeSpec exSpec = new ExportCodeSpec();
// Set the types to be exported
Type[] exportType = new Type[1];
exportType[0] = theWS.loadedTypeNamed( exportData_fullClassName);
exSpec.setTypes( exportType );
// Set up export defaults before we do the export
exSpec.useSubdirectories(false);
exSpec.overwriteFiles(true);
exSpec.includeClass(false);
exSpec.includeClassDebugInfo(false);
exSpec.includeJava(true);
exSpec.includeResources(false);
exSpec.setExportDirectory( exportData_directoryName );
// Export the java files associated with this class into the
directory
try
{
theWS.exportData(exSpec);
}
catch (IvjException e)
{
// If we encountered an error while exporting, return false so
that
// main can know about it.
return false;
}
// Else return true for successfull export
return true;
}
private static boolean doImport(Workspace theWS, String importFile,
String exportData_className, String exportData_directoryName, Project
exportProject)
{
// Set up importing to add the new files back into IVJ
ImportCodeSpec imSpec = new ImportCodeSpec();
// Work out name of Java file and set it to be imported
String importJavaFiles[] = new String[1];
importJavaFiles[0] = importFile;
imSpec.setJavaFiles( importJavaFiles);
// Set project to import into
imSpec.setDefaultProject( exportProject );
try
{
theWS.importData(imSpec);
}
catch (IvjException e)
{
System.out.println("Error doing Import!");
System.out.println("Errors reported were : ");
String[] errors = e.getErrors();
for (int i=0; i < errors.length; i++)
{
System.out.println(errors[i]);
}
System.out.println("Re-launching editor");
return false;
}
// Return true if import was a sucess
return true;
}
}
--
Kornelis Sietsma
Consultant
Candle Corporation
Phone: (+613) 9663 5455
Fax: (+613) 9663 5433
Mobile: 0401 188 596
email: [EMAIL PROTECTED]
personal email: [EMAIL PROTECTED]