ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r611752 [6/11] - in /ant/ivy/ivyde/trunk: ./ .settings/ doc/ doc/style/ src/java/org/apache/ivyde/eclipse/ src/java/org/apache/ivyde/eclipse/cpcontainer/ src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/ src/java/org/apache/ivyde/...
Date Mon, 14 Jan 2008 10:26:52 GMT
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java Mon Jan 14 02:26:37 2008
@@ -1,308 +1,337 @@
-/*
- * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
- * Copyright Jayasoft 2005 - All rights reserved
- * 
- * #SNAPSHOT#
- */
-package org.apache.ivyde.eclipse.ui.console;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ivy.util.Message;
-import org.apache.ivy.util.MessageLogger;
-import org.apache.ivy.util.MessageLoggerHelper;
-import org.apache.ivyde.eclipse.IvyPlugin;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
-
-/**
- * This class is used to deal with ivy output, and is largely insprired of
- * CVSOutputConsole for its implementation
- * 
- */
-public class IvyConsole extends MessageConsole implements MessageLogger {
-    private MessageConsoleStream[] streams = new MessageConsoleStream[5];
-    
-    private ConsoleDocument document;
-    private boolean initialized;
-    private boolean visible;
-    private boolean showOnMessage;
-    private IConsoleManager consoleManager;
-    
-    public IvyConsole() {
-        super("Ivy", IvyPlugin.getImageDescriptor("icons/logo16x16.gif")); //$NON-NLS-1$
-        consoleManager = ConsolePlugin.getDefault().getConsoleManager();
-        document = new ConsoleDocument();
-        Message.setDefaultLogger(this);
-    }
-
-    public void endProgress(String msg) {
-    }
-
-    public void progress() {
-    }
-
-    public void log(String msg, int level) {
-        appendLine(level, msg);
-    }        
-
-    public void rawlog(String msg, int level) {
-        appendLine(level, msg);
-    }
-    
-    
-    
-    /**
-     * Used to notify this console of lifecycle methods <code>init()</code>
-     * and <code>dispose()</code>.
-     */
-    public class MyLifecycle implements org.eclipse.ui.console.IConsoleListener {
-        public void consolesAdded(IConsole[] consoles) {
-            for (int i = 0; i < consoles.length; i++) {
-                IConsole console = consoles[i];
-                if (console == IvyConsole.this) {
-                    init();
-                }
-            }
-
-        }
-        public void consolesRemoved(IConsole[] consoles) {
-            for (int i = 0; i < consoles.length; i++) {
-                IConsole console = consoles[i];
-                if (console == IvyConsole.this) {
-                    ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this);
-                    dispose();
-                }
-            }
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.console.AbstractConsole#init()
-     */
-    protected void init() {
-        // Called when console is added to the console view
-        super.init();   
-        
-        //  Ensure that initialization occurs in the ui thread
-        Display.getDefault().asyncExec(new Runnable() {
-            public void run() {
-                initializeStreams();
-                dump();
-            }
-        });
-    }
-
-    /*
-     * Initialize thre streams of the console. Must be 
-     * called from the UI thread.
-     */
-    private void initializeStreams() {
-        synchronized(document) {
-            if (!initialized) {
-                for (int i=0; i<5; i++) {
-                    streams[i] = newMessageStream();
-                }
-
-                // install colors
-                Color color;
-
-                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_DEBUG_COLOR);
-                streams[Message.MSG_DEBUG].setColor(color);
-                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR);
-                streams[Message.MSG_VERBOSE].setColor(color);
-                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_INFO_COLOR);
-                streams[Message.MSG_INFO].setColor(color);
-                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_WARN_COLOR);
-                streams[Message.MSG_WARN].setColor(color);
-                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_ERROR_COLOR);
-                streams[Message.MSG_ERR].setColor(color);
-
-                initialized = true;
-            }
-        }
-    }
-
-    private void dump() {
-        synchronized(document) {
-            visible = true;
-            ConsoleDocument.ConsoleLine[] lines = document.getLines();
-            for (int i = 0; i < lines.length; i++) {
-                ConsoleDocument.ConsoleLine line = lines[i];
-                appendLine(line.type, line.line);
-            }
-            document.clear();
-        }
-    }
-    
-    private void appendLine(int level, String line) {
-        showConsole();
-        synchronized(document) {
-            if(visible) {
-                streams[level].println(line);
-            } else {
-                document.appendConsoleLine(level, line);
-            }
-        }
-    }
-
-    private void showConsole() {
-        show(false);
-    }
-    
-    /**
-     * Returns a color instance based on data from a preference field.
-     */
-    private Color createColor(Display display, String preference) {
-        RGB rgb = PreferenceConverter.getColor(IvyPlugin.getDefault().getPreferenceStore(), preference);
-        if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
-            if (IvyPlugin.PREF_CONSOLE_DEBUG_COLOR.equals(preference)) {
-                rgb = new RGB(180,180,255);
-            } else if (IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR.equals(preference)) {
-                rgb = new RGB(50,150,50);
-            } else if (IvyPlugin.PREF_CONSOLE_WARN_COLOR.equals(preference)) {
-                rgb = new RGB(255,80,20);
-            } else if (IvyPlugin.PREF_CONSOLE_ERROR_COLOR.equals(preference)) {
-                rgb = new RGB(255,0,0);
-            }
-        }
-        return new Color(display, rgb);
-    }
-
-    /**
-     * Show the console.
-     * @param showNoMatterWhat ignore preferences if <code>true</code>
-     */
-    public void show(boolean showNoMatterWhat) {
-        if(showNoMatterWhat || showOnMessage) {
-            if(!visible)
-                IvyConsoleFactory.showConsole();
-            else
-                consoleManager.showConsoleView(this);
-        }
-        
-    }
-
-    // MessageLogger implementation
-    private List problems = new ArrayList();
-
-    private List warns = new ArrayList();
-
-    private List errors = new ArrayList();
-
-    private boolean showProgress = true;
-    
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#debug(java.lang.String)
-     */
-    public void debug(String msg) {
-        log(msg, Message.MSG_DEBUG);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#verbose(java.lang.String)
-     */
-    public void verbose(String msg) {
-        log(msg, Message.MSG_VERBOSE);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#deprecated(java.lang.String)
-     */
-    public void deprecated(String msg) {
-        log("DEPRECATED: " + msg, Message.MSG_WARN);
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
-     */
-    public void info(String msg) {
-        log(msg, Message.MSG_INFO);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
-     */
-    public void rawinfo(String msg) {
-        rawlog(msg, Message.MSG_INFO);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#warn(java.lang.String)
-     */
-    public void warn(String msg) {
-        log("WARN: " + msg, Message.MSG_VERBOSE);
-        problems.add("WARN:  " + msg);
-        getWarns().add(msg);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#error(java.lang.String)
-     */
-    public void error(String msg) {
-        // log in verbose mode because message is appended as a problem, and will be
-        // logged at the end at error level
-        log("ERROR: " + msg, Message.MSG_VERBOSE);
-        problems.add("\tERROR: " + msg);
-        getErrors().add(msg);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#getProblems()
-     */
-    public List getProblems() {
-        return problems;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#sumupProblems()
-     */
-    public void sumupProblems() {
-        MessageLoggerHelper.sumupProblems(this);
-        clearProblems();
-    }
-
-    public void clearProblems() {
-        problems.clear();
-        warns.clear();
-        errors.clear();
-    }
-
-    public List getErrors() {
-        return errors;
-    }
-
-    public List getWarns() {
-        return warns;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#endProgress()
-     */
-    public void endProgress() {
-        endProgress("");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#isShowProgress()
-     */
-    public boolean isShowProgress() {
-        return showProgress;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ivy.util.MessageLogger#setShowProgress(boolean)
-     */
-    public void setShowProgress(boolean progress) {
-        showProgress = progress;
-    }
-}
+/*
+ * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
+ * Copyright Jayasoft 2005 - All rights reserved
+ * 
+ * #SNAPSHOT#
+ */
+package org.apache.ivyde.eclipse.ui.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ivy.util.Message;
+import org.apache.ivy.util.MessageLogger;
+import org.apache.ivy.util.MessageLoggerHelper;
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+
+/**
+ * This class is used to deal with ivy output, and is largely insprired of CVSOutputConsole for its
+ * implementation
+ */
+public class IvyConsole extends MessageConsole implements MessageLogger {
+    private MessageConsoleStream[] streams = new MessageConsoleStream[5];
+
+    private ConsoleDocument document;
+
+    private boolean initialized;
+
+    private boolean visible;
+
+    private boolean showOnMessage;
+
+    private IConsoleManager consoleManager;
+
+    public IvyConsole() {
+        super("Ivy", IvyPlugin.getImageDescriptor("icons/logo16x16.gif")); //$NON-NLS-1$
+        consoleManager = ConsolePlugin.getDefault().getConsoleManager();
+        document = new ConsoleDocument();
+        Message.setDefaultLogger(this);
+    }
+
+    public void endProgress(String msg) {
+    }
+
+    public void progress() {
+    }
+
+    public void log(String msg, int level) {
+        appendLine(level, msg);
+    }
+
+    public void rawlog(String msg, int level) {
+        appendLine(level, msg);
+    }
+
+    /**
+     * Used to notify this console of lifecycle methods <code>init()</code> and
+     * <code>dispose()</code>.
+     */
+    public class MyLifecycle implements org.eclipse.ui.console.IConsoleListener {
+        public void consolesAdded(IConsole[] consoles) {
+            for (int i = 0; i < consoles.length; i++) {
+                IConsole console = consoles[i];
+                if (console == IvyConsole.this) {
+                    init();
+                }
+            }
+
+        }
+
+        public void consolesRemoved(IConsole[] consoles) {
+            for (int i = 0; i < consoles.length; i++) {
+                IConsole console = consoles[i];
+                if (console == IvyConsole.this) {
+                    ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this);
+                    dispose();
+                }
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.console.AbstractConsole#init()
+     */
+    protected void init() {
+        // Called when console is added to the console view
+        super.init();
+
+        // Ensure that initialization occurs in the ui thread
+        Display.getDefault().asyncExec(new Runnable() {
+            public void run() {
+                initializeStreams();
+                dump();
+            }
+        });
+    }
+
+    /*
+     * Initialize thre streams of the console. Must be called from the UI thread.
+     */
+    private void initializeStreams() {
+        synchronized (document) {
+            if (!initialized) {
+                for (int i = 0; i < 5; i++) {
+                    streams[i] = newMessageStream();
+                }
+
+                // install colors
+                Color color;
+
+                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_DEBUG_COLOR);
+                streams[Message.MSG_DEBUG].setColor(color);
+                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR);
+                streams[Message.MSG_VERBOSE].setColor(color);
+                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_INFO_COLOR);
+                streams[Message.MSG_INFO].setColor(color);
+                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_WARN_COLOR);
+                streams[Message.MSG_WARN].setColor(color);
+                color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_ERROR_COLOR);
+                streams[Message.MSG_ERR].setColor(color);
+
+                initialized = true;
+            }
+        }
+    }
+
+    private void dump() {
+        synchronized (document) {
+            visible = true;
+            ConsoleDocument.ConsoleLine[] lines = document.getLines();
+            for (int i = 0; i < lines.length; i++) {
+                ConsoleDocument.ConsoleLine line = lines[i];
+                appendLine(line.type, line.line);
+            }
+            document.clear();
+        }
+    }
+
+    private void appendLine(int level, String line) {
+        showConsole();
+        synchronized (document) {
+            if (visible) {
+                streams[level].println(line);
+            } else {
+                document.appendConsoleLine(level, line);
+            }
+        }
+    }
+
+    private void showConsole() {
+        show(false);
+    }
+
+    /**
+     * Returns a color instance based on data from a preference field.
+     */
+    private Color createColor(Display display, String preference) {
+        RGB rgb = PreferenceConverter.getColor(IvyPlugin.getDefault().getPreferenceStore(),
+            preference);
+        if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
+            if (IvyPlugin.PREF_CONSOLE_DEBUG_COLOR.equals(preference)) {
+                rgb = new RGB(180, 180, 255);
+            } else if (IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR.equals(preference)) {
+                rgb = new RGB(50, 150, 50);
+            } else if (IvyPlugin.PREF_CONSOLE_WARN_COLOR.equals(preference)) {
+                rgb = new RGB(255, 80, 20);
+            } else if (IvyPlugin.PREF_CONSOLE_ERROR_COLOR.equals(preference)) {
+                rgb = new RGB(255, 0, 0);
+            }
+        }
+        return new Color(display, rgb);
+    }
+
+    /**
+     * Show the console.
+     * 
+     * @param showNoMatterWhat
+     *            ignore preferences if <code>true</code>
+     */
+    public void show(boolean showNoMatterWhat) {
+        if (showNoMatterWhat || showOnMessage) {
+            if (!visible)
+                IvyConsoleFactory.showConsole();
+            else
+                consoleManager.showConsoleView(this);
+        }
+
+    }
+
+    // MessageLogger implementation
+    private List problems = new ArrayList();
+
+    private List warns = new ArrayList();
+
+    private List errors = new ArrayList();
+
+    private boolean showProgress = true;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#debug(java.lang.String)
+     */
+    public void debug(String msg) {
+        log(msg, Message.MSG_DEBUG);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#verbose(java.lang.String)
+     */
+    public void verbose(String msg) {
+        log(msg, Message.MSG_VERBOSE);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#deprecated(java.lang.String)
+     */
+    public void deprecated(String msg) {
+        log("DEPRECATED: " + msg, Message.MSG_WARN);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
+     */
+    public void info(String msg) {
+        log(msg, Message.MSG_INFO);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
+     */
+    public void rawinfo(String msg) {
+        rawlog(msg, Message.MSG_INFO);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#warn(java.lang.String)
+     */
+    public void warn(String msg) {
+        log("WARN: " + msg, Message.MSG_VERBOSE);
+        problems.add("WARN:  " + msg);
+        getWarns().add(msg);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#error(java.lang.String)
+     */
+    public void error(String msg) {
+        // log in verbose mode because message is appended as a problem, and will be
+        // logged at the end at error level
+        log("ERROR: " + msg, Message.MSG_VERBOSE);
+        problems.add("\tERROR: " + msg);
+        getErrors().add(msg);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#getProblems()
+     */
+    public List getProblems() {
+        return problems;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#sumupProblems()
+     */
+    public void sumupProblems() {
+        MessageLoggerHelper.sumupProblems(this);
+        clearProblems();
+    }
+
+    public void clearProblems() {
+        problems.clear();
+        warns.clear();
+        errors.clear();
+    }
+
+    public List getErrors() {
+        return errors;
+    }
+
+    public List getWarns() {
+        return warns;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#endProgress()
+     */
+    public void endProgress() {
+        endProgress("");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#isShowProgress()
+     */
+    public boolean isShowProgress() {
+        return showProgress;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ivy.util.MessageLogger#setShowProgress(boolean)
+     */
+    public void setShowProgress(boolean progress) {
+        showProgress = progress;
+    }
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFactory.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFactory.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFactory.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFactory.java Mon Jan 14 02:26:37 2008
@@ -1,52 +1,46 @@
-/*
- * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
- * Copyright Jayasoft 2005 - All rights reserved
- * 
- * #SNAPSHOT#
- */
-package org.apache.ivyde.eclipse.ui.console;
-
-import org.apache.ivyde.eclipse.IvyPlugin;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleFactory;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.MessageConsole;
-
-
-public class IvyConsoleFactory implements IConsoleFactory {
-    public void openConsole() {
-        showConsole();
-    }
-    
-    public static void showConsole() {
-        IvyConsole console = IvyPlugin.getDefault().getConsole();
-        if (console != null) {
-            IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
-            IConsole[] existing = manager.getConsoles();
-            boolean exists = false;
-            for (int i = 0; i < existing.length; i++) {
-                if(console == existing[i])
-                    exists = true;
-            }
-            if(! exists)
-                manager.addConsoles(new IConsole[] {console});
-            manager.showConsoleView(console);
-        }
-    }
-    
-    public static void closeConsole() {
-        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
-        IvyConsole console = IvyPlugin.getDefault().getConsole();
-        if (console != null) {
-            manager.removeConsoles(new IConsole[] {console});
-            ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(console.new MyLifecycle());
-        }
-    }
-
-}
+/*
+ * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
+ * Copyright Jayasoft 2005 - All rights reserved
+ * 
+ * #SNAPSHOT#
+ */
+package org.apache.ivyde.eclipse.ui.console;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleFactory;
+import org.eclipse.ui.console.IConsoleManager;
+
+public class IvyConsoleFactory implements IConsoleFactory {
+    public void openConsole() {
+        showConsole();
+    }
+
+    public static void showConsole() {
+        IvyConsole console = IvyPlugin.getDefault().getConsole();
+        if (console != null) {
+            IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
+            IConsole[] existing = manager.getConsoles();
+            boolean exists = false;
+            for (int i = 0; i < existing.length; i++) {
+                if (console == existing[i])
+                    exists = true;
+            }
+            if (!exists)
+                manager.addConsoles(new IConsole[] {console});
+            manager.showConsoleView(console);
+        }
+    }
+
+    public static void closeConsole() {
+        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
+        IvyConsole console = IvyPlugin.getDefault().getConsole();
+        if (console != null) {
+            manager.removeConsoles(new IConsole[] {console});
+            ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(
+                console.new MyLifecycle());
+        }
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/IvyFileEditorInput.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/IvyFileEditorInput.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/IvyFileEditorInput.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/IvyFileEditorInput.java Mon Jan 14 02:26:37 2008
@@ -1,81 +1,81 @@
-package org.apache.ivyde.eclipse.ui.core;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPathEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IStorageEditorInput;
-
-public class IvyFileEditorInput implements IPathEditorInput, IStorageEditorInput, IFileEditorInput {
-    private IFile _ivyFile;
-    
-    public IvyFileEditorInput(IFile input) {
-        super();
-        _ivyFile = input;
-    }
-
-    public boolean exists() {
-        return _ivyFile.exists();
-    }
-
-    public ImageDescriptor getImageDescriptor() {
-        return null;
-    }
-
-    public String getName() {
-        return _ivyFile.getName();
-    }
-    
-    /* (non-Javadoc)
-     * Method declared on IEditorInput.
-     */
-    public String getToolTipText() {
-        return _ivyFile.getFullPath().makeRelative().toString();
-    }
-
-    /* (non-Javadoc)
-     * Method declared on IPathEditorInput
-     * @since 3.0
-     * @issue consider using an internal adapter for IPathEditorInput rather than adding this as API
-     */
-    public IPath getPath() {
-        return _ivyFile.getLocation();
-    }
-    
-
-    public String toString() {
-        return getClass().getName() + "(" + _ivyFile.getFullPath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    public Object getAdapter(Class adapter) {
-        return null;
-    }
-
-    public IPersistableElement getPersistable() {
-        return null;
-    }
-
-    public IStorage getStorage() throws CoreException {
-        return _ivyFile;
-    }
-    
-    public IFile getFile() {
-        return _ivyFile;
-    }
-    
-    public boolean equals(Object obj) {
-        if (! (obj instanceof IFileEditorInput)) {
-            return false;
-        }
-        IFileEditorInput o = (IFileEditorInput)obj;
-        return getFile().equals(o.getFile());
-    }
-    
-    public int hashCode() {
-        return getFile().hashCode();
-    }
-}
+package org.apache.ivyde.eclipse.ui.core;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+
+public class IvyFileEditorInput implements IPathEditorInput, IStorageEditorInput, IFileEditorInput {
+    private IFile _ivyFile;
+
+    public IvyFileEditorInput(IFile input) {
+        super();
+        _ivyFile = input;
+    }
+
+    public boolean exists() {
+        return _ivyFile.exists();
+    }
+
+    public ImageDescriptor getImageDescriptor() {
+        return null;
+    }
+
+    public String getName() {
+        return _ivyFile.getName();
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IEditorInput.
+     */
+    public String getToolTipText() {
+        return _ivyFile.getFullPath().makeRelative().toString();
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IPathEditorInput
+     * 
+     * @since 3.0 @issue consider using an internal adapter for IPathEditorInput rather than adding
+     *        this as API
+     */
+    public IPath getPath() {
+        return _ivyFile.getLocation();
+    }
+
+    public String toString() {
+        return getClass().getName() + "(" + _ivyFile.getFullPath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    public Object getAdapter(Class adapter) {
+        return null;
+    }
+
+    public IPersistableElement getPersistable() {
+        return null;
+    }
+
+    public IStorage getStorage() throws CoreException {
+        return _ivyFile;
+    }
+
+    public IFile getFile() {
+        return _ivyFile;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof IFileEditorInput)) {
+            return false;
+        }
+        IFileEditorInput o = (IFileEditorInput) obj;
+        return getFile().equals(o.getFile());
+    }
+
+    public int hashCode() {
+        return getFile().hashCode();
+    }
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/IvyFileEditorInput.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IValueProvider.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IValueProvider.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IValueProvider.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IValueProvider.java Mon Jan 14 02:26:37 2008
@@ -1,6 +1,5 @@
-package org.apache.ivyde.eclipse.ui.core.model;
-
-
-public interface IValueProvider {
-    String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile);
-}
+package org.apache.ivyde.eclipse.ui.core.model;
+
+public interface IValueProvider {
+    String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile);
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IValueProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyBooleanTagAttribute.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyBooleanTagAttribute.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyBooleanTagAttribute.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyBooleanTagAttribute.java Mon Jan 14 02:26:37 2008
@@ -1,33 +1,34 @@
-/*
- * This file is given under the licence found in LICENCE.TXT in the root directory of the project.
- * 
- * #SNAPSHOT#
- */
-package org.apache.ivyde.eclipse.ui.core.model;
-
-public class IvyBooleanTagAttribute extends IvyTagAttribute {
-
-    protected static final String[] BOOLEAN_VALUES = new String[] {"true", "false"};
-    private static final IValueProvider VALUE_PROVIDER = new IValueProvider() {    
-        public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
-            return BOOLEAN_VALUES;
-        }
-    
-    };
-
-    public IvyBooleanTagAttribute(String name, String doc, boolean mandatory) {
-        super(name, doc, mandatory);
-        setValueProvider(VALUE_PROVIDER);
-    }
-
-    public IvyBooleanTagAttribute(String name, String doc) {
-        super(name, doc);
-        setValueProvider(VALUE_PROVIDER);
-    }
-
-    public IvyBooleanTagAttribute(String name) {
-        super(name);
-        setValueProvider(VALUE_PROVIDER);
-    }
-    
-}
+/*
+ * This file is given under the licence found in LICENCE.TXT in the root directory of the project.
+ * 
+ * #SNAPSHOT#
+ */
+package org.apache.ivyde.eclipse.ui.core.model;
+
+public class IvyBooleanTagAttribute extends IvyTagAttribute {
+
+    protected static final String[] BOOLEAN_VALUES = new String[] {"true", "false"};
+
+    private static final IValueProvider VALUE_PROVIDER = new IValueProvider() {
+        public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
+            return BOOLEAN_VALUES;
+        }
+
+    };
+
+    public IvyBooleanTagAttribute(String name, String doc, boolean mandatory) {
+        super(name, doc, mandatory);
+        setValueProvider(VALUE_PROVIDER);
+    }
+
+    public IvyBooleanTagAttribute(String name, String doc) {
+        super(name, doc);
+        setValueProvider(VALUE_PROVIDER);
+    }
+
+    public IvyBooleanTagAttribute(String name) {
+        super(name);
+        setValueProvider(VALUE_PROVIDER);
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyBooleanTagAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyFile.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyFile.java?rev=611752&r1=611751&r2=611752&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyFile.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyFile.java Mon Jan 14 02:26:37 2008
@@ -1,400 +1,426 @@
-package org.apache.ivyde.eclipse.ui.core.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class IvyFile {
-    private static final Pattern ATTRIBUTE_NAME_PATTERN = Pattern.compile("[^\"]*\"[\\s]*=[\\s]*([\\w\\-]+)");
-    private static final Pattern QUALIFIER_PATTERN = Pattern.compile("[\\w\\-<]*");
-    private static final Pattern ATTRIBUTE_VALUE_PATTERN = Pattern.compile("([a-zA-Z0-9]+)[ ]*=[ ]*\"([^\"]*)\"");
-    private static final Pattern CONF_PATTERN = Pattern.compile("<[\\s]*conf[^>]+name=\"([^\"]+)");
-    private static final Pattern CONFIGURATIONS_END_PATTERN = Pattern.compile("</[\\s]*configurations[\\s]*>");
-    private static final Pattern CONFIGURATIONS_START_PATTERN = Pattern.compile("<[\\s]*configurations[\\s]*>");
-    private String _doc;
-    private int _currentOffset;
-
-    private String _reversed;
-    private String _projectName;
-    
-    public IvyFile(String projectName, String doc) {
-        this(projectName, doc, 0);
-    }
-    
-    public IvyFile(String projectName, String doc, int currentOffset) {
-        _projectName = projectName;
-        _doc = doc;
-        _reversed = new StringBuffer(doc).reverse().toString();
-        _currentOffset = currentOffset;
-    }
-    
-    public String[] getConfigurationNames() {
-        Pattern p = CONFIGURATIONS_START_PATTERN;
-        Matcher m = p.matcher(_doc);
-        if (m.find()) {
-            int start = m.end();
-            p = CONFIGURATIONS_END_PATTERN;
-            m = p.matcher(_doc);
-            int end = _doc.length();
-            if (m.find(start)) {
-                end = m.start();
-            }
-            p = CONF_PATTERN;
-            m = p.matcher(_doc);
-            List ret = new ArrayList();            
-            for (boolean found = m.find(start); found && m.end() < end; found = m.find()) {
-                ret.add(m.group(1));
-            }
-            return (String[])ret.toArray(new String[ret.size()]);
-        } else {
-            return new String[] {"default"};
-        }
-    }
-
-    public boolean inTag() {
-        return inTag(_currentOffset);
-    }
-    public boolean inTag(int documentOffset) {
-        int lastSpaceIndex = documentOffset;
-        boolean hasSpace = false;
-        while (true) {
-            // Read character backwards
-            if (documentOffset == 0) {
-                return false;
-            }
-            char c = _doc.charAt(--documentOffset);
-            if (Character.isWhitespace(c))
-                hasSpace = true;
-            if (c == '>' && (documentOffset == 0 || _doc.charAt(documentOffset - 1) != '-'))
-                return false;
-            if (c == '<' && (documentOffset+1 >= _doc.length() || (_doc.charAt(documentOffset + 1) != '!' && _doc.charAt(documentOffset + 1) != '?')))
-                return hasSpace;
-        }
-    }
-    
-    public String getTagName() {
-        return getTagName(_currentOffset);
-    }
-    
-    /**
-     * Return the tag for the position.
-     * Note : the documentoffset is considered to be in a tag ie in &lt; &gt;
-     * @param documentOffset
-     * @return
-     */
-    public String getTagName(int documentOffset) {
-        int offset = documentOffset;
-        int lastSpaceIndex = offset;
-        while (true) {
-            // Read character backwards
-            char c = _doc.charAt(--offset);
-            if (Character.isWhitespace(c)) {
-                lastSpaceIndex = offset;
-                continue;
-            }
-            if (c == '<')
-                return _doc.substring(offset + 1, lastSpaceIndex).trim();
-        }
-    }
-
-    public boolean readyForValue() {
-        return readyForValue(_currentOffset);
-    }
-    public boolean readyForValue(int documentOffset) {
-        return getAttributeName(documentOffset) != null;
-    }
-    
-    public int getStringIndexBackward(String string) {
-        return getStringIndexBackward(string, _currentOffset);
-    }
-
-    public int getStringIndexBackward(String string, int documentOffset) {
-        try {
-            String text = _doc.substring(0, documentOffset);
-            return text.lastIndexOf(string);
-        } catch (Exception e) {
-        }
-        return -1;
-    }
-    
-    public int getStringIndexForward(String string) {
-        return getStringIndexForward(string, _currentOffset);
-    }
-
-    public int getStringIndexForward(String string, int documentOffset) {
-        try {
-            return _doc.indexOf(string, documentOffset);
-        } catch (Exception e) {
-        }
-        return -1;
-    }
-    
-    public Map getAllAttsValues() {
-        return getAllAttsValues(_currentOffset);
-    }
-
-    public Map getAllAttsValues(int documentOffset) {
-        Map result = new HashMap();
-        
-        int offset = documentOffset;
-        int start = _reversed.indexOf('<', getReverseOffset(documentOffset));
-        if (start != -1) {
-            start = getReverseOffset(start);
-        } else {
-            start = 0;
-        }
-        int end;
-        if (_doc.charAt(documentOffset) == '>' && getAttributeName(documentOffset) == null) {
-            end = documentOffset + 1;
-        } else {
-            Pattern p = Pattern.compile("[^\\-]>");
-            Matcher m = p.matcher(_doc);
-            if (m.find(documentOffset)) {
-                end = m.end();
-            } else {
-                end = _doc.length();
-            }
-        }
-        Pattern regexp = ATTRIBUTE_VALUE_PATTERN;
-        try {
-            String tag = _doc.substring(start, end);
-            tag = tag.substring(tag.indexOf(' '));
-            Matcher m = regexp.matcher(tag);
-            while (m.find()) {
-                String key = m.group(1);
-                String val = m.group(2);
-                result.put(key, val);
-                if (m.end() + m.group(0).length() < tag.length()) {
-                    tag = tag.substring(m.end());
-                    m = regexp.matcher(tag);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return result;
-    }
-    
-//    public Map getAllAttsValues(int documentOffset) {
-//        Map result = new HashMap();
-//        int offset = documentOffset;
-//        int start = -1;
-//        int end = -1;
-//        char c = ' ';
-//        // move cursor at the begining of the tag
-//        while (c != '<') {
-//            try {
-//                c = _doc.charAt(--offset);
-//            } catch (IndexOutOfBoundsException e) {
-//                offset = 0;
-//                break;
-//            }
-//        }
-//        start = offset;
-//        offset = documentOffset;
-//        while (c != '>') {
-//            try {
-//                c = _doc.charAt(++offset);
-//            } catch (IndexOutOfBoundsException e) {
-//                break;
-//            }
-//        }
-//        end = offset;
-//        Pattern regexp = ATTRIBUTE_VALUE_PATTERN;
-//        try {
-//            String tag = _doc.substring(start, end);
-//            tag = tag.substring(tag.indexOf(' '));
-//            Matcher m = regexp.matcher(tag);
-//            while (m.find()) {
-//                String key = m.group(1);
-//                String val = m.group(2);
-//                result.put(key, val);
-//                if (m.end() + m.group(0).length() < tag.length()) {
-//                    tag = tag.substring(m.end());
-//                    m = regexp.matcher(tag);
-//                }
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        return result;
-//    }
-//    
-    public String getQualifier() {
-        return getQualifier(_currentOffset);
-    }
-    
-    /**
-     * Return the user typed string before calling completion
-     * stop on:<br>
-     * &lt; to match tag,<br/>
-     * space to found attribute name<br/>
-     * @param documentOffset
-     * @return
-     */
-    public String getQualifier(int documentOffset) {
-        Pattern p = QUALIFIER_PATTERN;
-        Matcher m = p.matcher(_reversed);
-        if (m.find(getReverseOffset(documentOffset))) {
-            return _doc.substring(getReverseOffset(m.end()), documentOffset);
-        } else {
-            return "";
-        }
-    }
-    
-    public String getAttributeValueQualifier() {
-        return getAttributeValueQualifier(_currentOffset);
-    }
-    
-    /**
-     * Return the user typed string before calling completion on attribute value
-     * stop on:<br>
-     * " to match value for attribute
-     * @param documentOffset
-     * @return
-     */
-    public String getAttributeValueQualifier(int documentOffset) {
-        int index = _reversed.indexOf("\"", getReverseOffset(documentOffset));
-        if (index == -1) {
-            return "";
-        } else {
-            return _doc.substring(getReverseOffset(index), documentOffset);
-        }
-    }
-    
-    /**
-     * Returns the attribute name corresponding to the value currently edited
-     * @return null if current offset is not in an attibute value
-     */
-    public String getAttributeName() {
-        return getAttributeName(_currentOffset);
-    }
-
-    public String getAttributeName(int documentOffset) {
-        Pattern p = ATTRIBUTE_NAME_PATTERN;
-        Matcher m = p.matcher(_reversed.substring(getReverseOffset(documentOffset)));
-        if (m.find() && m.start() == 0) {
-            String attName = new StringBuffer(m.group(1)).reverse().toString();
-            return attName;
-        } else {
-            return null;
-        }
-    }
-    
-    public String getParentTagName() {
-        return getParentTagName(_currentOffset);
-    }
-
-    public String getParentTagName(int documentOffset) {
-        int[] indexes = getParentTagIndex(documentOffset);
-        String foundParent = getString(indexes);
-        return foundParent == null ? null : foundParent.trim();
-    }
-
-    public String getString(int[] indexes) {
-        if (indexes != null) {
-            return _doc.substring(indexes[0], indexes[1]);
-        } else {
-            return null;
-        }
-    }
-    
-    public String getString(int start, int end) {
-        return _doc.substring(start, end);
-    }
-    
-    public int[] getParentTagIndex(int documentOffset) {
-        int offset = documentOffset;
-        int lastSpaceIndex = offset;
-        int parentEndTagIndex = -1;
-        boolean parentEndTagReached = false;
-        boolean inSimpleTag = false;
-        Stack stack = new Stack();
-        while (true) {
-            try {
-                char c = _doc.charAt(--offset);
-                if (c == '>' && _doc.charAt(offset - 1) != '-') {
-                    if (_doc.charAt(offset - 1) != '/') { // not a simple tag
-                        // System.out.println("parentEndTagReached:"+doc.get(documentOffset-15, 15));
-                        parentEndTagReached = true;
-                        parentEndTagIndex = offset;
-                        lastSpaceIndex = offset;
-                        // System.out.println("parentEndTagReached:"+doc.get(documentOffset-15, 15));
-                        continue;
-                    } else { // simple tag
-                        inSimpleTag = true;
-                    }
-                } else if (c == '<') {
-                    if (inSimpleTag) {// simple tag end
-                        inSimpleTag = false;
-                    } else if (_doc.charAt(offset + 1) == '/') { // closing tag
-                        if (parentEndTagReached) {
-                            parentEndTagReached = false;
-                            stack.push(_doc.substring(offset + 2, parentEndTagIndex).trim());
-                            lastSpaceIndex = offset + 2;
-                            continue;
-                        }
-                    } else {// opening tag
-                        if (_doc.charAt(offset + 1) != '!' && _doc.charAt(offset + 1) != '?') {// not a doc tag or xml
-                            if (!stack.isEmpty()) { // we found the closing tag before
-                                String closedName = (String) stack.peek();
-                                if (closedName.equalsIgnoreCase(_doc.substring(offset + 1, offset +1+ closedName.length()))) {
-                                    stack.pop();
-                                    continue;
-                                }
-                            } else {
-                                if (parentEndTagReached) {
-                                    return new int[] {offset+1, lastSpaceIndex};
-                                }
-                            }
-                        }
-                    }
-                } else if (Character.isWhitespace(c)) {
-                    lastSpaceIndex = offset;
-                    continue;
-                }
-            } catch (IndexOutOfBoundsException e) {
-                return null;
-            }
-        }
-    }
-
-    private int getReverseOffset(int documentOffset) {
-        return _doc.length() - documentOffset;
-    }
-
-    public int getOffset() {
-        return _currentOffset;
-    }
-
-    public int[] getParentTagIndex() {
-        return getParentTagIndex(_currentOffset);
-    }
-
-    public String getProjectName() {
-        return _projectName;
-    }
-
-    public String getOrganisation() {
-        Pattern p = Pattern.compile("<[\\s]*info[^>]*organisation[\\s]*=[\\s]*\"([^\"]+)");
-        Matcher m = p.matcher(_doc);
-        if (m.find()) {
-            return m.group(1);
-        }
-        return null;
-    }
-
-
-    public String getDependencyOrganisation() {
-        Map otherAttValues = getAllAttsValues();
-        return getDependencyOrganisation(otherAttValues);
-    }
-
-    public String getDependencyOrganisation(Map otherAttValues) {
-        return otherAttValues != null && otherAttValues.get("org") != null ? (String)otherAttValues.get("org") : getOrganisation();
-    }
-}
+package org.apache.ivyde.eclipse.ui.core.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class IvyFile {
+    private static final Pattern ATTRIBUTE_NAME_PATTERN = Pattern
+            .compile("[^\"]*\"[\\s]*=[\\s]*([\\w\\-]+)");
+
+    private static final Pattern QUALIFIER_PATTERN = Pattern.compile("[\\w\\-<]*");
+
+    private static final Pattern ATTRIBUTE_VALUE_PATTERN = Pattern
+            .compile("([a-zA-Z0-9]+)[ ]*=[ ]*\"([^\"]*)\"");
+
+    private static final Pattern CONF_PATTERN = Pattern.compile("<[\\s]*conf[^>]+name=\"([^\"]+)");
+
+    private static final Pattern CONFIGURATIONS_END_PATTERN = Pattern
+            .compile("</[\\s]*configurations[\\s]*>");
+
+    private static final Pattern CONFIGURATIONS_START_PATTERN = Pattern
+            .compile("<[\\s]*configurations[\\s]*>");
+
+    private String _doc;
+
+    private int _currentOffset;
+
+    private String _reversed;
+
+    private String _projectName;
+
+    public IvyFile(String projectName, String doc) {
+        this(projectName, doc, 0);
+    }
+
+    public IvyFile(String projectName, String doc, int currentOffset) {
+        _projectName = projectName;
+        _doc = doc;
+        _reversed = new StringBuffer(doc).reverse().toString();
+        _currentOffset = currentOffset;
+    }
+
+    public String[] getConfigurationNames() {
+        Pattern p = CONFIGURATIONS_START_PATTERN;
+        Matcher m = p.matcher(_doc);
+        if (m.find()) {
+            int start = m.end();
+            p = CONFIGURATIONS_END_PATTERN;
+            m = p.matcher(_doc);
+            int end = _doc.length();
+            if (m.find(start)) {
+                end = m.start();
+            }
+            p = CONF_PATTERN;
+            m = p.matcher(_doc);
+            List ret = new ArrayList();
+            for (boolean found = m.find(start); found && m.end() < end; found = m.find()) {
+                ret.add(m.group(1));
+            }
+            return (String[]) ret.toArray(new String[ret.size()]);
+        } else {
+            return new String[] {"default"};
+        }
+    }
+
+    public boolean inTag() {
+        return inTag(_currentOffset);
+    }
+
+    public boolean inTag(int documentOffset) {
+        int lastSpaceIndex = documentOffset;
+        boolean hasSpace = false;
+        while (true) {
+            // Read character backwards
+            if (documentOffset == 0) {
+                return false;
+            }
+            char c = _doc.charAt(--documentOffset);
+            if (Character.isWhitespace(c))
+                hasSpace = true;
+            if (c == '>' && (documentOffset == 0 || _doc.charAt(documentOffset - 1) != '-'))
+                return false;
+            if (c == '<'
+                    && (documentOffset + 1 >= _doc.length() || (_doc.charAt(documentOffset + 1) != '!' && _doc
+                            .charAt(documentOffset + 1) != '?')))
+                return hasSpace;
+        }
+    }
+
+    public String getTagName() {
+        return getTagName(_currentOffset);
+    }
+
+    /**
+     * Return the tag for the position. Note : the documentoffset is considered to be in a tag ie in
+     * &lt; &gt;
+     * 
+     * @param documentOffset
+     * @return
+     */
+    public String getTagName(int documentOffset) {
+        int offset = documentOffset;
+        int lastSpaceIndex = offset;
+        while (true) {
+            // Read character backwards
+            char c = _doc.charAt(--offset);
+            if (Character.isWhitespace(c)) {
+                lastSpaceIndex = offset;
+                continue;
+            }
+            if (c == '<')
+                return _doc.substring(offset + 1, lastSpaceIndex).trim();
+        }
+    }
+
+    public boolean readyForValue() {
+        return readyForValue(_currentOffset);
+    }
+
+    public boolean readyForValue(int documentOffset) {
+        return getAttributeName(documentOffset) != null;
+    }
+
+    public int getStringIndexBackward(String string) {
+        return getStringIndexBackward(string, _currentOffset);
+    }
+
+    public int getStringIndexBackward(String string, int documentOffset) {
+        try {
+            String text = _doc.substring(0, documentOffset);
+            return text.lastIndexOf(string);
+        } catch (Exception e) {
+        }
+        return -1;
+    }
+
+    public int getStringIndexForward(String string) {
+        return getStringIndexForward(string, _currentOffset);
+    }
+
+    public int getStringIndexForward(String string, int documentOffset) {
+        try {
+            return _doc.indexOf(string, documentOffset);
+        } catch (Exception e) {
+        }
+        return -1;
+    }
+
+    public Map getAllAttsValues() {
+        return getAllAttsValues(_currentOffset);
+    }
+
+    public Map getAllAttsValues(int documentOffset) {
+        Map result = new HashMap();
+
+        int offset = documentOffset;
+        int start = _reversed.indexOf('<', getReverseOffset(documentOffset));
+        if (start != -1) {
+            start = getReverseOffset(start);
+        } else {
+            start = 0;
+        }
+        int end;
+        if (_doc.charAt(documentOffset) == '>' && getAttributeName(documentOffset) == null) {
+            end = documentOffset + 1;
+        } else {
+            Pattern p = Pattern.compile("[^\\-]>");
+            Matcher m = p.matcher(_doc);
+            if (m.find(documentOffset)) {
+                end = m.end();
+            } else {
+                end = _doc.length();
+            }
+        }
+        Pattern regexp = ATTRIBUTE_VALUE_PATTERN;
+        try {
+            String tag = _doc.substring(start, end);
+            tag = tag.substring(tag.indexOf(' '));
+            Matcher m = regexp.matcher(tag);
+            while (m.find()) {
+                String key = m.group(1);
+                String val = m.group(2);
+                result.put(key, val);
+                if (m.end() + m.group(0).length() < tag.length()) {
+                    tag = tag.substring(m.end());
+                    m = regexp.matcher(tag);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    // public Map getAllAttsValues(int documentOffset) {
+    // Map result = new HashMap();
+    // int offset = documentOffset;
+    // int start = -1;
+    // int end = -1;
+    // char c = ' ';
+    // // move cursor at the begining of the tag
+    // while (c != '<') {
+    // try {
+    // c = _doc.charAt(--offset);
+    // } catch (IndexOutOfBoundsException e) {
+    // offset = 0;
+    // break;
+    // }
+    // }
+    // start = offset;
+    // offset = documentOffset;
+    // while (c != '>') {
+    // try {
+    // c = _doc.charAt(++offset);
+    // } catch (IndexOutOfBoundsException e) {
+    // break;
+    // }
+    // }
+    // end = offset;
+    // Pattern regexp = ATTRIBUTE_VALUE_PATTERN;
+    // try {
+    // String tag = _doc.substring(start, end);
+    // tag = tag.substring(tag.indexOf(' '));
+    // Matcher m = regexp.matcher(tag);
+    // while (m.find()) {
+    // String key = m.group(1);
+    // String val = m.group(2);
+    // result.put(key, val);
+    // if (m.end() + m.group(0).length() < tag.length()) {
+    // tag = tag.substring(m.end());
+    // m = regexp.matcher(tag);
+    // }
+    // }
+    // } catch (Exception e) {
+    // e.printStackTrace();
+    // }
+    // return result;
+    // }
+    //    
+    public String getQualifier() {
+        return getQualifier(_currentOffset);
+    }
+
+    /**
+     * Return the user typed string before calling completion stop on:<br>
+     * &lt; to match tag,<br/> space to found attribute name<br/>
+     * 
+     * @param documentOffset
+     * @return
+     */
+    public String getQualifier(int documentOffset) {
+        Pattern p = QUALIFIER_PATTERN;
+        Matcher m = p.matcher(_reversed);
+        if (m.find(getReverseOffset(documentOffset))) {
+            return _doc.substring(getReverseOffset(m.end()), documentOffset);
+        } else {
+            return "";
+        }
+    }
+
+    public String getAttributeValueQualifier() {
+        return getAttributeValueQualifier(_currentOffset);
+    }
+
+    /**
+     * Return the user typed string before calling completion on attribute value stop on:<br> " to
+     * match value for attribute
+     * 
+     * @param documentOffset
+     * @return
+     */
+    public String getAttributeValueQualifier(int documentOffset) {
+        int index = _reversed.indexOf("\"", getReverseOffset(documentOffset));
+        if (index == -1) {
+            return "";
+        } else {
+            return _doc.substring(getReverseOffset(index), documentOffset);
+        }
+    }
+
+    /**
+     * Returns the attribute name corresponding to the value currently edited
+     * 
+     * @return null if current offset is not in an attibute value
+     */
+    public String getAttributeName() {
+        return getAttributeName(_currentOffset);
+    }
+
+    public String getAttributeName(int documentOffset) {
+        Pattern p = ATTRIBUTE_NAME_PATTERN;
+        Matcher m = p.matcher(_reversed.substring(getReverseOffset(documentOffset)));
+        if (m.find() && m.start() == 0) {
+            String attName = new StringBuffer(m.group(1)).reverse().toString();
+            return attName;
+        } else {
+            return null;
+        }
+    }
+
+    public String getParentTagName() {
+        return getParentTagName(_currentOffset);
+    }
+
+    public String getParentTagName(int documentOffset) {
+        int[] indexes = getParentTagIndex(documentOffset);
+        String foundParent = getString(indexes);
+        return foundParent == null ? null : foundParent.trim();
+    }
+
+    public String getString(int[] indexes) {
+        if (indexes != null) {
+            return _doc.substring(indexes[0], indexes[1]);
+        } else {
+            return null;
+        }
+    }
+
+    public String getString(int start, int end) {
+        return _doc.substring(start, end);
+    }
+
+    public int[] getParentTagIndex(int documentOffset) {
+        int offset = documentOffset;
+        int lastSpaceIndex = offset;
+        int parentEndTagIndex = -1;
+        boolean parentEndTagReached = false;
+        boolean inSimpleTag = false;
+        Stack stack = new Stack();
+        while (true) {
+            try {
+                char c = _doc.charAt(--offset);
+                if (c == '>' && _doc.charAt(offset - 1) != '-') {
+                    if (_doc.charAt(offset - 1) != '/') { // not a simple tag
+                        // System.out.println("parentEndTagReached:"+doc.get(documentOffset-15,
+                        // 15));
+                        parentEndTagReached = true;
+                        parentEndTagIndex = offset;
+                        lastSpaceIndex = offset;
+                        // System.out.println("parentEndTagReached:"+doc.get(documentOffset-15,
+                        // 15));
+                        continue;
+                    } else { // simple tag
+                        inSimpleTag = true;
+                    }
+                } else if (c == '<') {
+                    if (inSimpleTag) {// simple tag end
+                        inSimpleTag = false;
+                    } else if (_doc.charAt(offset + 1) == '/') { // closing tag
+                        if (parentEndTagReached) {
+                            parentEndTagReached = false;
+                            stack.push(_doc.substring(offset + 2, parentEndTagIndex).trim());
+                            lastSpaceIndex = offset + 2;
+                            continue;
+                        }
+                    } else {// opening tag
+                        if (_doc.charAt(offset + 1) != '!' && _doc.charAt(offset + 1) != '?') {// not
+                            // a
+                            // doc
+                            // tag
+                            // or
+                            // xml
+                            if (!stack.isEmpty()) { // we found the closing tag before
+                                String closedName = (String) stack.peek();
+                                if (closedName.equalsIgnoreCase(_doc.substring(offset + 1, offset
+                                        + 1 + closedName.length()))) {
+                                    stack.pop();
+                                    continue;
+                                }
+                            } else {
+                                if (parentEndTagReached) {
+                                    return new int[] {offset + 1, lastSpaceIndex};
+                                }
+                            }
+                        }
+                    }
+                } else if (Character.isWhitespace(c)) {
+                    lastSpaceIndex = offset;
+                    continue;
+                }
+            } catch (IndexOutOfBoundsException e) {
+                return null;
+            }
+        }
+    }
+
+    private int getReverseOffset(int documentOffset) {
+        return _doc.length() - documentOffset;
+    }
+
+    public int getOffset() {
+        return _currentOffset;
+    }
+
+    public int[] getParentTagIndex() {
+        return getParentTagIndex(_currentOffset);
+    }
+
+    public String getProjectName() {
+        return _projectName;
+    }
+
+    public String getOrganisation() {
+        Pattern p = Pattern.compile("<[\\s]*info[^>]*organisation[\\s]*=[\\s]*\"([^\"]+)");
+        Matcher m = p.matcher(_doc);
+        if (m.find()) {
+            return m.group(1);
+        }
+        return null;
+    }
+
+    public String getDependencyOrganisation() {
+        Map otherAttValues = getAllAttsValues();
+        return getDependencyOrganisation(otherAttValues);
+    }
+
+    public String getDependencyOrganisation(Map otherAttValues) {
+        return otherAttValues != null && otherAttValues.get("org") != null ? (String) otherAttValues
+                .get("org")
+                : getOrganisation();
+    }
+}

Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/core/model/IvyFile.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message