Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:21:19 -0400 (Wed, 26 Sep 2007)
New Revision: 3837
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
Log:
allowing event log to turn off and no longer log
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27
01:01:44 UTC (rev 3836)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27
01:21:19 UTC (rev 3837)
@@ -22,17 +22,56 @@
package org.jboss.ide.eclipse.as.core.extensions.events;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
+import org.osgi.service.prefs.BackingStoreException;
/**
*
* @author rob.stryker(a)jboss.com
*/
public class EventLogModel {
+ public static final String ENABLE_LOGGING_PREFERENCE =
"org.jboss.ide.eclipse.as.core.extensions.events.enableLogging";
+ public static boolean loggingEnabled = true;
+
+
+
+
+ public static void enableLogging() {
+ loggingEnabled = true;
+ IEclipsePreferences prefs = new
DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, true);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
JBossServerCorePlugin.PLUGIN_ID, "Saving preferences failed", e));
+ }
+ }
+
+ public static void disableLogging() {
+ loggingEnabled = false;
+ IEclipsePreferences prefs = new
DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, false);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
JBossServerCorePlugin.PLUGIN_ID, "Saving preferences failed", e));
+ }
+ ServerEventModel[] models = getModels();
+ for( int i = 0; i < models.length; i++ ) {
+ models[i].clearEvents();
+ }
+ }
+
public static final String JBOSS_EVENT_ROOT_TYPE = "jboss.event.root";
private static EventLogModel instance;
public static EventLogModel getDefault() {
@@ -49,6 +88,10 @@
return getDefault().getEventModel(serverId);
}
+ public static ServerEventModel[] getModels() {
+ return getDefault().getEventModels();
+ }
+
public static void markChanged(EventLogTreeItem item) {
SimpleTreeItem root = item.getRoot();
if( root != null && root instanceof EventLogRoot ) {
@@ -89,6 +132,10 @@
return m;
}
+ public ServerEventModel[] getEventModels() {
+ Collection c = serverToModel.values();
+ return (ServerEventModel[]) c.toArray(new ServerEventModel[c.size()]);
+ }
public static class ServerEventModel {
private String id;
@@ -144,5 +191,21 @@
public String getServerId() {
return model.getId();
}
+
+ public void addChild(SimpleTreeItem item) {
+ if( loggingEnabled )
+ super.addChild(item);
+ }
+
+ public void addChild(int loc, SimpleTreeItem item) {
+ if( loggingEnabled )
+ super.addChild(loc, item);
+ }
+
+ public void addChildren(SimpleTreeItem[] kids) {
+ if( loggingEnabled )
+ super.addChildren(kids);
+ }
+
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27
01:01:44 UTC (rev 3836)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27
01:21:19 UTC (rev 3837)
@@ -111,7 +111,7 @@
return true;
} else {
return false;
- }
+ }
}
protected void removeModule(IPath path) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-09-27
01:01:44 UTC (rev 3836)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-09-27
01:21:19 UTC (rev 3837)
@@ -61,6 +61,12 @@
children.add(loc, item);
}
+ public void addChildren(SimpleTreeItem[] kids) {
+ for( int i = 0; i < kids.length; i++ ) {
+ addChild(kids[i]);
+ }
+ }
+
public void deleteChildren() {
children.clear();
}
@@ -93,13 +99,7 @@
public void setData(Object data) {
this.data = data;
}
-
- public void addChildren(SimpleTreeItem[] kids) {
- for( int i = 0; i < kids.length; i++ ) {
- addChild(kids[i]);
- }
- }
-
+
public SimpleTreeItem getRoot() {
SimpleTreeItem item = this;
while(item.getParent() != null)
Show replies by date