You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by pm...@apache.org on 2007/08/01 16:57:27 UTC

svn commit: r561818 - in /geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui: Jres2gLauncher.java Jsrc2gLauncher.java

Author: pmcmahan
Date: Wed Aug  1 07:57:26 2007
New Revision: 561818

URL: http://svn.apache.org/viewvc?view=rev&rev=561818
Log:
GERONIMO-3342 add missing files from 559912 commit.  Patch provided by Erik Craig.

Added:
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java   (with props)
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java   (with props)

Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java?view=auto&rev=561818
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java (added)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java Wed Aug  1 07:57:26 2007
@@ -0,0 +1,161 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.j2g.ui;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.console.*;
+
+public class Jres2gLauncher extends ActionDelegate implements IViewActionDelegate {
+
+    /**
+     * Eclipse home.
+     */
+    private String eclipseHomePath;
+
+    /**
+     * Eclipse workspace.
+     */
+    private String eclipseWorkspacePath;
+
+    /**
+     * Geronimo Home.
+     */
+    private String geronimoHome;
+
+    /**
+     * Source directory.
+     */
+    private String sourceDir;
+
+    /**
+     * Web directory.
+     */
+    private String webDir = "";
+
+    public void run(IAction action) {
+        MessageConsole console = new MessageConsole("System Output", null);
+        ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
+        ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
+        MessageConsoleStream stream = console.newMessageStream();
+        System.setOut(new PrintStream(stream));
+        System.setErr(new PrintStream(stream));
+        String fdselected = new String();
+        MessageBox prompt = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                .getShell(), SWT.ICON_WARNING);
+        MessageBox yesNoBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                .getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+        DirectoryDialog fd = new DirectoryDialog(PlatformUI.getWorkbench()
+                .getActiveWorkbenchWindow().getShell(), SWT.OPEN);
+        String cmdOutput = null;
+        String[] cmd = new String[3];
+
+        // Check environment for eclipse home
+        eclipseHomePath = System.getenv("ECLIPSE_HOME");
+        if (eclipseHomePath == null) {
+            prompt.setMessage("'ECLIPSE_HOME' was not found in your environment.\n"
+                    + "Please set it and relaunch Eclipse.");
+            prompt.open();
+            return;
+        }
+
+        // Check environment for Workspace dir.
+        eclipseWorkspacePath = System.getenv("WORKSPACE");
+        if (eclipseWorkspacePath == null) {
+            prompt.setMessage("'WORKSPACE' was not found in your environment.\n"
+                    + "Please select the location of your temporary Eclipse Workspace now.");
+            prompt.open();
+            fd.setMessage("Select Eclipse Workspace directory");
+            fd.setText("Select Eclipse Workspace directory");
+            fd.setFilterPath(System.getProperty("user.home"));
+            fdselected = fd.open();
+            if (fdselected == null)
+                return;
+            eclipseWorkspacePath = fdselected;
+        }
+
+        // Select target directory
+        prompt.setMessage("Please select application root directory to convert.");
+        prompt.open();
+        fd.setMessage("Select application root directory");
+        fd.setText("Select application root directory");
+        fd.setFilterPath(System.getProperty("user.home"));
+        sourceDir = fd.open();
+        if (sourceDir == null)
+            return;
+        yesNoBox.setMessage("Jres2g is going to be executed on " + sourceDir + ".\n"
+                + "This process may take a while, and cause Eclipse to appear unresponsive.\n"
+                + "Continue?");
+        if (SWT.NO == yesNoBox.open()) {
+            return;
+        }
+
+        // Everything but windows uses this
+        if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") == -1) {
+            cmd[0] = "bash";
+            cmd[1] = "-c";
+        } else // This is just for windows
+        {
+            cmd[0] = "cmd";
+            cmd[1] = "/c";
+        }
+        cmd[2] = "java -classpath "
+                + eclipseHomePath
+                + System.getProperty("file.separator")
+                + "plugins"
+                + System.getProperty("file.separator")
+                + "org.eclipse.equinox.launcher_*.jar org.eclipse.equinox.launcher.Main -application org.apache.geronimo.j2g.resources.tool -data "
+                + eclipseWorkspacePath + " " + sourceDir;
+
+        System.out.println("Executing: " + cmd[2]);
+        try {
+            Process cmdProcess = Runtime.getRuntime().exec(cmd);
+
+            BufferedReader stdInput = new BufferedReader(new InputStreamReader(cmdProcess
+                    .getInputStream()));
+
+            BufferedReader stdError = new BufferedReader(new InputStreamReader(cmdProcess
+                    .getErrorStream()));
+
+            while ((cmdOutput = stdInput.readLine()) != null) {
+                System.out.println(cmdOutput);
+            }
+
+            while ((cmdOutput = stdError.readLine()) != null) {
+                System.out.println(cmdOutput);
+            }
+        } catch (IOException e) {
+            System.out.println("Error executing " + cmd[2]);
+            e.printStackTrace();
+        }
+    }
+
+    public void init(IViewPart view) {
+    }
+
+}

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jres2gLauncher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java?view=auto&rev=561818
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java (added)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java Wed Aug  1 07:57:26 2007
@@ -0,0 +1,183 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.j2g.ui;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.console.*;
+
+public class Jsrc2gLauncher extends ActionDelegate implements IViewActionDelegate {
+
+    /**
+     * Eclipse home.
+     */
+    private String eclipseHomePath;
+
+    /**
+     * Eclipse workspace.
+     */
+    private String eclipseWorkspacePath;
+
+    /**
+     * Geronimo Home.
+     */
+    private String geronimoHome;
+
+    /**
+     * Source directory.
+     */
+    private String sourceDir;
+
+    /**
+     * Web directory.
+     */
+    private String webDir = "";
+
+    public void run(IAction action) {
+        MessageConsole console = new MessageConsole("System Output", null);
+        ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
+        ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
+        MessageConsoleStream stream = console.newMessageStream();
+        System.setOut(new PrintStream(stream));
+        System.setErr(new PrintStream(stream));
+        String fdselected = new String();
+        MessageBox prompt = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                .getShell(), SWT.ICON_WARNING);
+        MessageBox yesNoBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                .getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+        DirectoryDialog fd = new DirectoryDialog(PlatformUI.getWorkbench()
+                .getActiveWorkbenchWindow().getShell(), SWT.OPEN);
+        String cmdOutput = null;
+        String[] cmd = new String[3];
+
+        // Check environment for eclipse home
+        eclipseHomePath = System.getenv("ECLIPSE_HOME");
+        if (eclipseHomePath == null) {
+            prompt.setMessage("'ECLIPSE_HOME' was not found in your environment.\n"
+                    + "Please select the location of your Eclipse SDK now.");
+            prompt.open();
+            fd.setMessage("Select Eclipse SDK directory");
+            fd.setText("Select Eclipse SDK directory");
+            fd.setFilterPath(System.getProperty("user.home"));
+            fdselected = fd.open();
+            if (fdselected == null)
+                return;
+            eclipseHomePath = fdselected;
+        }
+
+        // Check environment for Workspace dir.
+        eclipseHomePath = System.getenv("ECLIPSE_HOME");
+        if (eclipseHomePath == null) {
+            prompt.setMessage("'ECLIPSE_HOME' was not found in your environment.\n"
+                    + "Please set it and relaunch Eclipse.");
+            prompt.open();
+            return;
+        }
+
+        // Check environment for Geronimo Home
+        geronimoHome = System.getenv("GERONIMO_HOME");
+        if (geronimoHome == null) {
+            prompt.setMessage("'GERONIMO_HOME' was not found in your environment.\n"
+                    + "Please select the location of Geronimo now.");
+            prompt.open();
+            fd.setMessage("Select Geronimo directory");
+            fd.setText("Select Geronimo directory");
+            fd.setFilterPath(System.getProperty("user.home"));
+            fdselected = fd.open();
+            if (fdselected == null)
+                return;
+            geronimoHome = fdselected;
+        }
+
+        // Select target directories
+        prompt.setMessage("Please select application source directory to convert.");
+        prompt.open();
+        fd.setMessage("Select application source directory");
+        fd.setText("Select application source directory");
+        fd.setFilterPath(System.getProperty("user.home"));
+        sourceDir = fd.open();
+        if (sourceDir == null)
+            return;
+        yesNoBox.setMessage("Do you wish to convert web (JSP) sources as well?");
+        if (SWT.YES == yesNoBox.open()) {
+            webDir = " -web ";
+            fd.setMessage("Select web (JSP) source directory");
+            fd.setText("Select web (JSP) source directory");
+            fd.setFilterPath(System.getProperty("user.home"));
+            webDir = webDir + fd.open();
+        }
+        yesNoBox.setMessage("Jsrc2g is going to be executed with -src " + sourceDir + webDir
+                + ".\n"
+                + "This process may take a while, and cause Eclipse to appear unresponsive.\n"
+                + "Continue?");
+        if (SWT.NO == yesNoBox.open()) {
+            return;
+        }
+
+        // Everything but windows uses this
+        if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") == -1) {
+            cmd[0] = "bash";
+            cmd[1] = "-c";
+        } else // This is just for windows
+        {
+            cmd[0] = "cmd";
+            cmd[1] = "/c";
+        }
+        cmd[2] = "java -classpath "
+                + eclipseHomePath
+                + System.getProperty("file.separator")
+                + "plugins"
+                + System.getProperty("file.separator")
+                + "org.eclipse.equinox.launcher_*.jar org.eclipse.equinox.launcher.Main -application org.apache.geronimo.j2g.sources.tool -data "
+                + eclipseWorkspacePath + webDir + "-configuration " + eclipseHomePath
+                + System.getProperty("file.separator") + "configuration -src " + sourceDir
+                + " -geronimo " + geronimoHome;
+
+        System.out.println("Executing: " + cmd[2]);
+        try {
+            Process cmdProcess = Runtime.getRuntime().exec(cmd);
+            BufferedReader stdInput = new BufferedReader(new InputStreamReader(cmdProcess
+                    .getInputStream()));
+            BufferedReader stdError = new BufferedReader(new InputStreamReader(cmdProcess
+                    .getErrorStream()));
+            while ((cmdOutput = stdInput.readLine()) != null) {
+                System.out.println(cmdOutput);
+            }
+            while ((cmdOutput = stdError.readLine()) != null) {
+                System.out.println(cmdOutput);
+            }
+        } catch (IOException e) {
+            System.out.println("Error executing " + cmd[2]);
+            e.printStackTrace();
+        }
+    }
+
+    public void init(IViewPart view) {
+    }
+
+}

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.ui/src/org/apache/geronimo/j2g/ui/Jsrc2gLauncher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain