Author: rob.stryker(a)jboss.com
Date: 2010-12-16 00:38:48 -0500 (Thu, 16 Dec 2010)
New Revision: 27533
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogReader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
Log:
JBIDE-7814 - updates to server log view
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2010-12-15
21:41:16 UTC (rev 27532)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2010-12-16
05:38:48 UTC (rev 27533)
@@ -15,12 +15,16 @@
import java.util.HashMap;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.osgi.service.prefs.BackingStoreException;
public class ServerLogger {
+ private static final String RELOG_ERROR_PREF_KEY = "package
org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger.RELOG_ERROR_PREF_KEY";
//$NON-NLS-1$
private static ServerLogger instance;
public static ServerLogger getDefault() {
if( instance == null ) {
@@ -56,6 +60,9 @@
map.put(server.getId(), log);
}
log.log(status);
+ if( shouldDoubleLogErrors() && status.getSeverity() == IStatus.ERROR) {
+ JBossServerCorePlugin.getDefault().getLog().log(status);
+ }
ArrayList<IServerLogListener> list = listeners.get(server.getId());
if( list != null ) {
@@ -66,6 +73,20 @@
}
}
+ public static boolean shouldDoubleLogErrors() {
+ IEclipsePreferences prefs = new
InstanceScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ return prefs.getBoolean(RELOG_ERROR_PREF_KEY, true);
+ }
+
+ public static void setDoubleLogErrors(boolean val) {
+ IEclipsePreferences prefs = new
InstanceScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(RELOG_ERROR_PREF_KEY, val);
+ try {
+ prefs.flush();
+ } catch( BackingStoreException bse) {
+ }
+ }
+
public static File getServerLogFile(IServer server) {
File f = JBossServerCorePlugin.getServerStateLocation(
server).append(IJBossToolingConstants.LOG).toFile();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2010-12-15
21:41:16 UTC (rev 27532)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2010-12-16
05:38:48 UTC (rev 27533)
@@ -231,6 +231,9 @@
public static String LogLabelProvider_SecondsAgo;
public static String LogLabelProvider_StartupShutdownEventType;
public static String LogLabelProvider_UnknownEventType;
+ public static String LogAction_AlsoLogErrorsToErrorLog;
+ public static String LogAction_DoNotLogErrorsToErrorLog;
+
public static String RequiredCredentialsDialog_IgnoreButton;
public static String RequiredCredentialsDialog_ShellText;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2010-12-15
21:41:16 UTC (rev 27532)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2010-12-16
05:38:48 UTC (rev 27533)
@@ -61,7 +61,7 @@
ServerContentProvider_ErrorInServersViewAnimation=Error in Servers view animation
ServerDialogHeading=JBoss Server
ServerLogView_ImportingLogTaskName=Importing Server Log
-ServerLogView_NoLogSelected=No Log Selected
+ServerLogView_NoLogSelected=Please select a server in the Servers View
#View's Module extension
DeleteModuleText=Remove
@@ -202,5 +202,8 @@
LogLabelProvider_SecondsAgo={0} seconds ago
LogLabelProvider_StartupShutdownEventType=Server Startup / Shutdown
LogLabelProvider_UnknownEventType=Unknown Event Type
+LogAction_AlsoLogErrorsToErrorLog=Also log errors to the Error Log
+LogAction_DoNotLogErrorsToErrorLog=Don't log errors to the Error Log
+
RequiredCredentialsDialog_IgnoreButton=Ignore
RequiredCredentialsDialog_ShellText=Server Credentials Required
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogReader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogReader.java 2010-12-15
21:41:16 UTC (rev 27532)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogReader.java 2010-12-16
05:38:48 UTC (rev 27533)
@@ -25,7 +25,7 @@
private static final int UNKNOWN_STATE = 70;
public static LogSession parseLogFile(File file, List entries, IMemento memento) {
- if (!file.exists())
+ if (file == null || !file.exists())
return null;
// if (memento.getString(LogView.P_USE_LIMIT).equals("true") //$NON-NLS-1$
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2010-12-15
21:41:16 UTC (rev 27532)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2010-12-16
05:38:48 UTC (rev 27533)
@@ -10,7 +10,6 @@
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -23,15 +22,15 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Policy;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -52,14 +51,19 @@
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.views.log.Messages;
import org.eclipse.ui.internal.views.log.SharedImages;
import org.eclipse.ui.part.FileEditorInput;
@@ -70,7 +74,7 @@
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-public class ServerLogView extends ViewPart implements IServerLogListener {
+public class ServerLogView extends ViewPart implements IServerLogListener,
ISelectionListener {
public static final String VIEW_ID =
"org.jboss.ide.eclipse.as.ui.view.serverLogView"; //$NON-NLS-1$
public final static byte MESSAGE = 0x0;
public final static byte DATE = 0x1;
@@ -90,7 +94,8 @@
private String fDirectory;
private IMemento fMemento;
private Action fDeleteLogAction, fOpenLogAction,
- fReadLogAction, fExportLogAction;
+ fReadLogAction, fExportLogAction,
+ fReLogErrorsAction;
private TreeColumn fColumn1;
private TreeColumn fColumn2;
private Comparator fComparator;
@@ -102,6 +107,8 @@
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
+ ISelectionService service = (ISelectionService)
getSite().getService(ISelectionService.class);
+ service.addSelectionListener(this);
if (memento == null)
this.fMemento = XMLMemento.createWriteRoot("SERVERLOGVIEW"); //$NON-NLS-1$
else
@@ -163,6 +170,10 @@
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
+ fReLogErrorsAction = createReLogErrorAction();
+ updateReLogActionText();
+ toolBarManager.add(fReLogErrorsAction);
+ toolBarManager.add(new Separator());
fExportLogAction = createExportLogAction();
toolBarManager.add(fExportLogAction);
toolBarManager.add(new Separator());
@@ -174,7 +185,6 @@
toolBarManager.add(fOpenLogAction);
fReadLogAction = createReadLogAction();
toolBarManager.add(fReadLogAction);
-
setLogFile(null);
}
@@ -227,6 +237,8 @@
}
public void dispose() {
+ ISelectionService service = (ISelectionService)
getSite().getService(ISelectionService.class);
+ service.removeSelectionListener(this);
super.dispose();
}
@@ -237,26 +249,38 @@
reloadLog();
}
- protected void reloadLog() {
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- monitor.beginTask(org.jboss.ide.eclipse.as.ui.Messages.ServerLogView_ImportingLogTaskName,
IProgressMonitor.UNKNOWN);
- List<AbstractEntry> entries = new ArrayList<AbstractEntry>();
- LogReader.parseLogFile(fInputFile, entries, fMemento);
+ private class ReloadLogJob extends Job {
+
+ public ReloadLogJob() {
+ super(org.jboss.ide.eclipse.as.ui.Messages.ServerLogView_ImportingLogTaskName);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ List<AbstractEntry> entries = new ArrayList<AbstractEntry>();
+ LogReader.parseLogFile(fInputFile, entries, fMemento);
+ if( !monitor.isCanceled()) {
elements.addAll(entries);
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run(){
+ asyncRefresh(false);
+ updateButtons();
+ }
+ });
}
- };
- ProgressMonitorDialog pmd = new ProgressMonitorDialog(getViewSite().getShell());
- try {
- pmd.run(true, true, op);
- } catch (InvocationTargetException e) { // do nothing
- } catch (InterruptedException e) { // do nothing
- } finally {
- asyncRefresh(false);
- updateButtons();
+ return Status.OK_STATUS;
}
}
+
+ private ReloadLogJob reloadJob = null;
+ protected void reloadLog() {
+ if( reloadJob != null && reloadJob.getResult() == null ) {
+ reloadJob.cancel();
+ }
+
+ reloadJob = new ReloadLogJob();
+ reloadJob.schedule();
+ }
private void updateButtons() {
fDeleteLogAction.setEnabled(exists(fInputFile));
@@ -428,6 +452,30 @@
return action;
}
+ private Action createReLogErrorAction() {
+ Action action = new Action("") {
+ public void run() {
+ handleLogErrorAction();
+ }
+ };
+ action.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_ERROR_ST_OBJ));
+ return action;
+ }
+
+ private void handleLogErrorAction() {
+ boolean currentVal = ServerLogger.shouldDoubleLogErrors();
+ ServerLogger.setDoubleLogErrors(!currentVal);
+ updateReLogActionText();
+ }
+
+ private void updateReLogActionText() {
+ String newVal = !ServerLogger.shouldDoubleLogErrors() ?
+ org.jboss.ide.eclipse.as.ui.Messages.LogAction_DoNotLogErrorsToErrorLog :
+ org.jboss.ide.eclipse.as.ui.Messages.LogAction_AlsoLogErrorsToErrorLog;
+ fReLogErrorsAction.setText(newVal);
+ fReLogErrorsAction.setToolTipText(newVal);
+ }
+
private Action createExportLogAction() {
Action action = new Action(Messages.LogView_export) {
public void run() {
@@ -640,5 +688,17 @@
};
}
}
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if( selection != null && selection instanceof IStructuredSelection ) {
+ IStructuredSelection sel2 = (IStructuredSelection)selection;
+ if( sel2.size() > 0 ) {
+ Object o = sel2.getFirstElement();
+ if( o instanceof IServer ) {
+ setServer((IServer)o);
+ }
+ }
+ }
+ }
}