H
handyeraser
Gast
Hallo zusammen habe folgenden Code:
nun möchte ich die for schleife auch noch um die Methode public void transform legen wie würdet ihr dass realisieren??
danke gruß marco
edited by thE_29: code tags eingebaut!
Code:
public XMLXSLTTransformer(Shell shell, List selections) {
this.shell = null;
workspace = null;
project = null;
selectedFile = null;
xsltFiles = new IFile[6];
packageName = null;
controllerName = null;
basicServerPaths = null;
basicProxyJunaPath = null;
basicProxyPath = null;
basicControllerPath = null;
basicXsltPath = null;
page = new XMLTransformerPreferencePage();
this.shell = shell;
for(Iterator iter = selections.iterator(); iter.hasNext();){
//Iterator iter = selections.iterator();
Object obj = iter.next();
if(obj instanceof IFile) {
selectedFile = (File)obj;
workspace = selectedFile.getWorkspace();
project = selectedFile.getWorkspace().getRoot().getProject(selectedFile.getFullPath().segment(0));
}
try {
readXMLControllerFile(selectedFile);
}
catch(ParserConfigurationException e1) {
e1.printStackTrace();
}
catch(SAXException e1) {
e1.printStackTrace(); }
catch(FactoryConfigurationError e1)
{
e1.printStackTrace(); }
catch(IOException e)
{
e.printStackTrace(); }
catch(CoreException e)
{
e.printStackTrace();
}
basicControllerPath = page.getBasicControllerPath().replace('.', '/');
basicProxyJunaPath = page.getBasicProxyJunaPath().replace('.', '/');
basicProxyPath = page.getBasicProxyPath().replace('.', '/');
basicServerPaths = (page.getBasicServerPath() + "." + packageName).replace('.', '/');
basicXsltPath = page.getBasicXsltPath().replace('.', '/');
IFolder xsltFolder = project.getFolder(basicXsltPath);
int i = 0;
xsltFiles[i++] = xsltFolder.getFile("Interface.xsl");
xsltFiles[i++] = xsltFolder.getFile("Bean.xsl");
xsltFiles[i++] = xsltFolder.getFile("Home.xsl");
xsltFiles[i++] = xsltFolder.getFile("Remote.xsl");
xsltFiles[i++] = xsltFolder.getFile("Proxy.xsl");
xsltFiles[i++] = xsltFolder.getFile("RemoteProxy.xsl");
}
}
public void transform()
throws InvocationTargetException, InterruptedException
{
final List outputFiles = new Vector();
if(MessageDialog.openQuestion(shell, "Generate Controller .... ", "Processing xml-file: " + selectedFile.getName() + " ?"))
{
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
dialog.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException
{
monitor.beginTask("Transformating...", 7);
try
{
String outputFileNames[] = {
"I" + controllerName + ".java", controllerName + "Bean.java", controllerName + "Home.java", controllerName + "Remote.java", controllerName + "ProxyJuna.java", controllerName + "Proxy.java"
};
int i = 0;
String fullQualifiedFileName = basicControllerPath + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
fullQualifiedFileName = basicServerPaths + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
fullQualifiedFileName = basicServerPaths + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
fullQualifiedFileName = basicServerPaths + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
fullQualifiedFileName = basicProxyJunaPath + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
fullQualifiedFileName = basicProxyPath + "/" + outputFileNames[i];
generateFile(xsltFiles[i], selectedFile, fullQualifiedFileName);
i++;
monitor.worked(i);
outputFiles.add(fullQualifiedFileName);
}
catch(Exception e)
{
MessageDialog.openError(shell, "Error", e.getMessage());
}
}
});
}
}
danke gruß marco
edited by thE_29: code tags eingebaut!