You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2009/09/22 15:38:12 UTC

svn commit: r817660 - in /ant/ivy/ivyde/trunk: ./ org.apache.ivyde.eclipse/icons/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/ org.apache.ivyde.eclipse/src/java/org/a...

Author: hibou
Date: Tue Sep 22 13:38:11 2009
New Revision: 817660

URL: http://svn.apache.org/viewvc?rev=817660&view=rev
Log:
IVYDE-205 :
 - add an option that will filter the log level in the console view
 - set the default log level to INFO

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/icons/log_level.png   (with props)
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java   (with props)
Modified:
    ant/ivy/ivyde/trunk/CHANGES.txt
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsolePageParticipant.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java

Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Tue Sep 22 13:38:11 2009
@@ -9,6 +9,7 @@
 - NEW: File resource listener on Ivy files launches resolve when it detects modifications (IVYDE-199) (thanks to Jon Schneider)
 - NEW: Add an option in the container to automatically laucnh a resolve before each launch (IVYDE-204)
 - NEW: "Reverse Dependency Explorer" View for synchronizing revisions across multiple projects in a workspace (IVYDE-195) (thanks to Jon Schneider)
+- NEW: Make the Ivy console filter on the logging level (IVYDE-205)
 
 - FIX: "Ivy Settings Path" Browse button results in an incorrectly formatted URL (IVYDE-191) (thanks to Jon Schneider)
 - FIX: Workspace Resolver Prevents Source Download (IVYDE-188) (thanks to Phillip Webb)

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/icons/log_level.png
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/icons/log_level.png?rev=817660&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/icons/log_level.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Tue Sep 22 13:38:11 2009
@@ -96,12 +96,6 @@
         super.start(context);
         this.bundleContext = context;
         log(IStatus.INFO, "starting IvyDE plugin", null);
-        try {
-            console = new IvyConsole();
-        } catch (RuntimeException e) {
-            // Don't let the console bring down the CVS UI
-            log(IStatus.ERROR, "Errors occurred starting the Ivy console", e);
-        }
         javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
         prefStoreHelper = new IvyDEPreferenceStoreHelper(getPreferenceStore());
         getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
@@ -131,6 +125,13 @@
             }
         });
 
+        try {
+            console = new IvyConsole();
+        } catch (RuntimeException e) {
+            // Don't let the console bring down the IvyDE UI
+            log(IStatus.ERROR, "Errors occurred starting the Ivy console", e);
+        }
+
         // Listen for project open/close events to auto-update inter-project dependencies
         IWorkspace workspace = ResourcesPlugin.getWorkspace();
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java Tue Sep 22 13:38:11 2009
@@ -64,11 +64,23 @@
 
     private IConsoleManager consoleManager;
 
+    private int logLevel;
+
     public IvyConsole() {
         super("Ivy", IvyPlugin.getImageDescriptor("icons/logo16x16.gif")); //$NON-NLS-1$
         consoleManager = ConsolePlugin.getDefault().getConsoleManager();
         document = new ConsoleDocument();
         Message.setDefaultLogger(this);
+        logLevel = IvyPlugin.getPreferenceStoreHelper().getIvyConsoleLogLevel();
+    }
+
+    public void setLogLevel(int logLevel) {
+        this.logLevel = logLevel;
+        IvyPlugin.getPreferenceStoreHelper().setIvyConsoleLogLevel(logLevel);
+    }
+
+    public int getLogLevel() {
+        return logLevel;
     }
 
     public void endProgress(String msg) {
@@ -168,6 +180,10 @@
     }
 
     private void appendLine(int level, String line) {
+        if (level > logLevel) {
+            // log message filtered by its level
+            return;
+        }
         showConsole();
         synchronized (document) {
             if (visible) {

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java?rev=817660&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java Tue Sep 22 13:38:11 2009
@@ -0,0 +1,83 @@
+/*
+ *  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.ivyde.eclipse.ui.console;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+
+public class IvyConsoleFilterAction extends Action implements IMenuCreator {
+
+    private static final String[] LOG_LEVEL_MESSAGES = {"error", "warning", "info", "verbose",
+            "debug"};
+
+    private Menu fMenu;
+
+    private IvyConsole console;
+
+    public IvyConsoleFilterAction(IvyConsole console) {
+        this.console = console;
+        setText("Log filter");
+        setToolTipText("Filter the log level of the Ivy console");
+        setImageDescriptor(IvyPlugin.getImageDescriptor("/icons/log_level.png"));
+        setMenuCreator(this);
+    }
+
+    public void dispose() {
+        if (fMenu != null) {
+            fMenu.dispose();
+        }
+        console = null;
+    }
+
+    public Menu getMenu(Menu parent) {
+        return null;
+    }
+
+    public Menu getMenu(Control parent) {
+        if (fMenu != null) {
+            fMenu.dispose();
+        }
+
+        fMenu = new Menu(parent);
+        for (int i = 0; i < 5; i++) {
+            final int logLevel = i;
+            Action action = new Action(LOG_LEVEL_MESSAGES[i]) {
+                public void run() {
+                    console.setLogLevel(logLevel);
+                }
+            };
+            action.setChecked(console.getLogLevel() == i);
+            addActionToMenu(fMenu, action);
+        }
+        return fMenu;
+    }
+
+    private void addActionToMenu(Menu parent, Action action) {
+        ActionContributionItem item = new ActionContributionItem(action);
+        item.fill(parent, -1);
+    }
+
+    public void run() {
+        // nothing to do
+    }
+
+}

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

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsoleFilterAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsolePageParticipant.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsolePageParticipant.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsolePageParticipant.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsolePageParticipant.java Tue Sep 22 13:38:11 2009
@@ -28,14 +28,21 @@
 
     private CloseConsoleAction closeAction;
 
+    private IvyConsoleFilterAction filterLogAction;
+
     public void init(IPageBookViewPage page, IConsole console) {
-        closeAction = new IvyConsoleRemoveAction(console);
         IToolBarManager manager = page.getSite().getActionBars().getToolBarManager();
+
+        closeAction = new IvyConsoleRemoveAction(console);
         manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, closeAction);
+
+        filterLogAction = new IvyConsoleFilterAction((IvyConsole) console);
+        manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, filterLogAction);
     }
 
     public void dispose() {
         closeAction = null;
+        filterLogAction = null;
     }
 
     public Object getAdapter(Class adapter) {
@@ -43,9 +50,11 @@
     }
 
     public void activated() {
+        // nothing to do
     }
 
     public void deactivated() {
+        // nothing to do
     }
 
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java Tue Sep 22 13:38:11 2009
@@ -182,4 +182,12 @@
     public void setAutoResolveOnChange(boolean autoResolveChange) {
         prefStore.setValue(PreferenceConstants.AUTO_RESOLVE_ON_CHANGE, autoResolveChange);
     }
+
+    public int getIvyConsoleLogLevel() {
+        return prefStore.getInt(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL);
+    }
+
+    public void setIvyConsoleLogLevel(int logLevel) {
+        prefStore.setValue(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, logLevel);
+    }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java Tue Sep 22 13:38:11 2009
@@ -79,4 +79,6 @@
     public static final String AUTO_RESOLVE_ON_CLOSE = "autoResolve.close";
 
     public static final String AUTO_RESOLVE_ON_CHANGE = "autoResolve.change";
+
+    public static final String IVY_CONSOLE_LOG_LEVEL = "ivyConsole.logLevel";
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java?rev=817660&r1=817659&r2=817660&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java Tue Sep 22 13:38:11 2009
@@ -17,6 +17,7 @@
  */
 package org.apache.ivyde.eclipse.ui.preferences;
 
+import org.apache.ivy.util.Message;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.ContainerMappingSetup;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
@@ -58,6 +59,8 @@
 
     public static final String DEFAULT_JAVADOC_SUFFIXES = "-javadoc,-javadocs,-doc,-docs";
 
+    public static final int DEFAULT_IVY_CONSOLE_LOG_MESSAGE = Message.MSG_INFO;
+
     public static final ContainerMappingSetup DEFAULT_CONTAINER_MAPPING_SETUP =
         new ContainerMappingSetup();
 
@@ -155,6 +158,8 @@
         store.setDefault(PreferenceConstants.AUTO_RESOLVE_ON_CLOSE, DEFAULT_AUTO_RESOLVE_ON_CLOSE);
         store.setDefault(PreferenceConstants.AUTO_RESOLVE_ON_OPEN, DEFAULT_AUTO_RESOLVE_ON_OPEN);
         store.setDefault(PreferenceConstants.AUTO_RESOLVE_ON_CHANGE, DEFAULT_AUTO_RESOLVE_ON_CHANGE);
+
+        store.setDefault(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, DEFAULT_IVY_CONSOLE_LOG_MESSAGE);
     }
 
 }