geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r575227 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding: BrandingSupport.java DefaultBranding.java
Date Thu, 13 Sep 2007 08:55:32 GMT
Author: jdillon
Date: Thu Sep 13 01:55:32 2007
New Revision: 575227

URL: http://svn.apache.org/viewvc?rev=575227&view=rev
Log:
Add BrandingSupport

Added:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/BrandingSupport.java
      - copied, changed from r575199, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/BrandingSupport.java
(from r575199, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/BrandingSupport.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/BrandingSupport.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java&r1=575199&r2=575227&rev=575227&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/BrandingSupport.java
Thu Sep 13 01:55:32 2007
@@ -20,46 +20,23 @@
 package org.apache.geronimo.gshell.branding;
 
 import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 
-import org.apache.geronimo.gshell.ansi.Buffer;
-import org.apache.geronimo.gshell.ansi.Code;
-import org.apache.geronimo.gshell.ansi.RenderWriter;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.StringUtils;
-import jline.Terminal;
-
-//
-// FIXME: Move this to a seperate module so that folks can omit this and use their own easily
-//
 
 /**
- * Provides the default branding for GShell.
+ * Support for {@link Branding} implementations.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Branding.class, hint="default")
-public class DefaultBranding
+public abstract class BrandingSupport
     implements Branding
 {
-    @Requirement
-    private VersionLoader versionLoader;
-
-    @Requirement
-    private Terminal terminal;
-
-    public String getName() {
-        return "gshell";
-    }
-
     public String getDisplayName() {
-        return "GShell";
+        return StringUtils.capitalise(getName());
     }
 
     public String getProgramName() {
-        return System.getProperty("program.name", "gsh");
+        return System.getProperty("program.name", getName());
     }
 
     public File getUserDirectory() {
@@ -72,93 +49,12 @@
 
     public File getSharedDirectory() {
         //
-        // FIXME: This is not very portable :-(
+        // FIXME: Need to get the home directory of the shell here...  Can't use ShellInfo,
since it depends on the Branding
         //
-        
-        File dir = new File("/etc", getName());
-
-        return dir.getAbsoluteFile();
-    }
-
-    public String getAbout() {
-        StringWriter writer = new StringWriter();
-        PrintWriter out = new RenderWriter(writer);
-
-        out.println("For information about @|cyan GShell|, visit:");
-        out.println("    @|bold http://geronimo.apache.org/gshell.html| ");
-        out.flush();
-
-        return writer.toString();
-    }
-
-    public String getVersion() {
-        return versionLoader.getVersion();
-    }
-
-    /*
-    // Figlet font name: ???
-    private static final String[] BANNER = {
-        "   ____ ____  _          _ _ ",
-        "  / ___/ ___|| |__   ___| | |",
-        " | |  _\\___ \\| '_ \\ / _ \\ | |",
-        " | |_| |___) | | | |  __/ | |",
-        "  \\____|____/|_| |_|\\___|_|_|",
-    };
-    */
-
-    // Figlet font name: Georgia11
-    private static final String[] BANNER = {
-        "                          ,,                 ,,    ,,",
-        "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM",
-        " .dP'     `M  ,MI    \"Y   MM                 MM    MM",
-        " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM",
-        " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM",
-        " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM",
-        " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM",
-        "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML."
-    };
-
-    /*
-    // Figlet font name: Georgia11
-    private static final String[] BANNER = {
-        "                          ,,                 ,,    ,,             ..",
-        "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM              `bq",
-        " .dP'     `M  ,MI    \"Y   MM                 MM    MM                YA",
-        " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM                `Mb",
-        " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM      mmmmmmmmm  8M",
-        " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM                 8M",
-        " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM      mmmmmmmmm ,M9",
-        "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML.              dM",
-        "                                                                   .pY"
-    };
-    */
-    
-    public String getWelcomeBanner() {
-        StringWriter writer = new StringWriter();
-        PrintWriter out = new RenderWriter(writer);
-        Buffer buff = new Buffer();
-
-        for (String line : BANNER) {
-            buff.attrib(line, Code.CYAN);
-            out.println(buff);
-        }
-        
-        out.println();
-        out.println(" @|bold GShell| (" + getVersion() + ")");
-        out.println();
-        out.println("Type '@|bold help|' for more information.");
-
-        // If we can't tell, or have something bogus then use a reasonable default
-        int width = terminal.getTerminalWidth();
-        if (width < 1) {
-            width = 80;
-        }
-        
-        out.print(StringUtils.repeat("-", width - 1));
 
-        out.flush();
+        File dir = new File("/etc");
 
-        return writer.toString();
+        return dir.getAbsoluteFile();
     }
 
     public String getProfileScriptName() {
@@ -175,7 +71,7 @@
 
     public String getPropertyName(final String name) {
         assert name != null;
-        
+
         return getName() + "." + name;
     }
 
@@ -185,7 +81,7 @@
 
     public String getProperty(final String name, final String defaultValue) {
         String value = getProperty(name);
-        
+
         if (value == null) {
             return defaultValue;
         }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java?rev=575227&r1=575226&r2=575227&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
Thu Sep 13 01:55:32 2007
@@ -19,21 +19,16 @@
 
 package org.apache.geronimo.gshell.branding;
 
-import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
+import jline.Terminal;
 import org.apache.geronimo.gshell.ansi.Buffer;
 import org.apache.geronimo.gshell.ansi.Code;
 import org.apache.geronimo.gshell.ansi.RenderWriter;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.StringUtils;
-import jline.Terminal;
-
-//
-// FIXME: Move this to a seperate module so that folks can omit this and use their own easily
-//
 
 /**
  * Provides the default branding for GShell.
@@ -42,7 +37,7 @@
  */
 @Component(role=Branding.class, hint="default")
 public class DefaultBranding
-    implements Branding
+    extends BrandingSupport
 {
     @Requirement
     private VersionLoader versionLoader;
@@ -62,24 +57,6 @@
         return System.getProperty("program.name", "gsh");
     }
 
-    public File getUserDirectory() {
-        File userHome = new File(System.getProperty("user.home"));
-
-        File dir = new File(userHome, "." + getName());
-
-        return dir.getAbsoluteFile();
-    }
-
-    public File getSharedDirectory() {
-        //
-        // FIXME: This is not very portable :-(
-        //
-        
-        File dir = new File("/etc", getName());
-
-        return dir.getAbsoluteFile();
-    }
-
     public String getAbout() {
         StringWriter writer = new StringWriter();
         PrintWriter out = new RenderWriter(writer);
@@ -159,37 +136,5 @@
         out.flush();
 
         return writer.toString();
-    }
-
-    public String getProfileScriptName() {
-        return getName() + ".profile";
-    }
-
-    public String getInteractiveScriptName() {
-        return getName() + ".rc";
-    }
-
-    public String getHistoryFileName() {
-        return getName() + ".history";
-    }
-
-    public String getPropertyName(final String name) {
-        assert name != null;
-        
-        return getName() + "." + name;
-    }
-
-    public String getProperty(final String name) {
-        return System.getProperty(getPropertyName(name));
-    }
-
-    public String getProperty(final String name, final String defaultValue) {
-        String value = getProperty(name);
-        
-        if (value == null) {
-            return defaultValue;
-        }
-
-        return value;
     }
 }



Mime
View raw message