[logback-dev] svn commit: r1348 - in logbackPDE/trunk/plugins/ConsolePlugin: . src/main/java/ch/qos/logback/eclipse/actions src/main/java/ch/qos/logback/eclipse/dialog src/main/java/ch/qos/logback/eclipse/reciever src/main/java/ch/qos/logback/eclipse/views
noreply.seb at qos.ch
noreply.seb at qos.ch
Fri Feb 23 15:40:33 CET 2007
Author: seb
Date: Fri Feb 23 15:40:33 2007
New Revision: 1348
Added:
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackPreferencesAction.java
- copied, changed from r1344, /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackViewPatternAction.java
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java
- copied, changed from r1344, /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPatternDialog.java
Removed:
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackViewPatternAction.java
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPatternDialog.java
Modified:
logbackPDE/trunk/plugins/ConsolePlugin/ (props changed)
logbackPDE/trunk/plugins/ConsolePlugin/build.properties
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/reciever/SimpleSocketServer.java
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
logbackPDE/trunk/plugins/ConsolePlugin/todo.txt
Log:
Modified PatternLayout pref window to a general prefs window
Added the possibility to change the console's high water mark from the prefs window
Changed socket port
Added autoscroll to the console
Modified: logbackPDE/trunk/plugins/ConsolePlugin/build.properties
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/build.properties (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/build.properties Fri Feb 23 15:40:33 2007
@@ -3,4 +3,7 @@
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/
+ icons/,\
+ logbackPlugin.jar,\
+ lib/
+source.logbackPlugin.jar = src/main/java/
Copied: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackPreferencesAction.java (from r1344, /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackViewPatternAction.java)
==============================================================================
--- /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackViewPatternAction.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/actions/LogbackPreferencesAction.java Fri Feb 23 15:40:33 2007
@@ -2,31 +2,36 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.TextConsoleViewer;
import ch.qos.logback.classic.PatternLayout;
-import ch.qos.logback.eclipse.dialog.LogbackPatternDialog;
+import ch.qos.logback.eclipse.dialog.LogbackPreferencesDialog;
/**
* This action prompts the user for a string to setup the PatternLayout
*/
-public class LogbackViewPatternAction extends Action {
+public class LogbackPreferencesAction extends Action {
private final Shell shell;
private PatternLayout patternLayout;
+ private MessageConsole console;
- public LogbackViewPatternAction(Viewer viewer, PatternLayout layout, String text) {
+ public LogbackPreferencesAction(TextConsoleViewer viewer, PatternLayout layout, String text, MessageConsole console) {
super(text);
shell = viewer.getControl().getShell();
this.patternLayout = layout;
+ this.console = console;
}
public void run() {
- LogbackPatternDialog dialog = new LogbackPatternDialog(shell, patternLayout.getPattern());
+ LogbackPreferencesDialog dialog = new LogbackPreferencesDialog(shell, patternLayout.getPattern(), console.getHighWaterMark());
if (dialog.open() != InputDialog.OK)
return;
patternLayout.stop();
patternLayout.setPattern(dialog.getPattern());
patternLayout.start();
+
+ console.setWaterMarks(console.getLowWaterMark(), dialog.getHighWaterMark());
}
}
Copied: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java (from r1344, /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPatternDialog.java)
==============================================================================
--- /logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPatternDialog.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java Fri Feb 23 15:40:33 2007
@@ -3,6 +3,7 @@
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -15,18 +16,27 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import ch.qos.logback.eclipse.views.LogbackView;
+
/**
* A dialog that allows the user to change the pattern that is used to
* display the logging events
*/
-public class LogbackPatternDialog extends Dialog {
+public class LogbackPreferencesDialog extends Dialog {
+
+ private static String ERROR_MESSAGE = "The watermark cannot be lower than " + LogbackView.LOW_WATERMARK;
+
private String pattern;
-
+ private int highWaterMark;
+ private int tmpHighWaterMark;
+
private Text patternField;
+ private Text waterMarkField;
- public LogbackPatternDialog(Shell parentShell, String namePattern) {
+ public LogbackPreferencesDialog(Shell parentShell, String namePattern, int highWaterMark) {
super(parentShell);
this.pattern = namePattern;
+ this.highWaterMark = highWaterMark;
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE
| SWT.APPLICATION_MODAL);
@@ -53,6 +63,18 @@
bounds.width = 150;
patternField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ final Label infoLabel2 = new Label(container, SWT.NONE);
+ infoLabel2
+ .setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
+ infoLabel2.setText("Enter max number of chars to be displayed:");
+
+ final Label waterMarkLabel = new Label(container, SWT.NONE);
+ waterMarkLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+ waterMarkLabel.setText("Max number:");
+
+ waterMarkField = new Text(container, SWT.BORDER);
+ waterMarkField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+
initContent();
return container;
}
@@ -64,14 +86,35 @@
pattern = patternField.getText();
}
});
+
+ waterMarkField.setText(String.valueOf(highWaterMark));
+ waterMarkField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ tmpHighWaterMark = Integer.parseInt(waterMarkField.getText());
+ }
+ });
}
-
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText("Logback View PatternLayout options");
+ newShell.setText("Logback View options");
}
public String getPattern() {
return pattern;
}
+
+ public int getHighWaterMark() {
+ return highWaterMark;
+ }
+
+ @Override
+ protected void okPressed() {
+ if (tmpHighWaterMark > LogbackView.LOW_WATERMARK) {
+ highWaterMark = tmpHighWaterMark;
+ super.okPressed();
+ } else {
+ MessageDialog.openInformation(getShell(), "Logback View", ERROR_MESSAGE);
+ waterMarkField.setText(String.valueOf(highWaterMark));
+ }
+ }
}
Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/reciever/SimpleSocketServer.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/reciever/SimpleSocketServer.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/reciever/SimpleSocketServer.java Fri Feb 23 15:40:33 2007
@@ -14,7 +14,7 @@
*/
public class SimpleSocketServer implements Runnable {
- static int port = 1234;
+ static int port = 4321;
public void run() {
try {
@@ -27,4 +27,6 @@
PluginLogger.logError(e);
}
}
+
+
}
Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java Fri Feb 23 15:40:33 2007
@@ -11,7 +11,7 @@
import org.eclipse.ui.console.TextConsoleViewer;
import org.eclipse.ui.part.ViewPart;
-import ch.qos.logback.eclipse.actions.LogbackViewPatternAction;
+import ch.qos.logback.eclipse.actions.LogbackPreferencesAction;
import ch.qos.logback.eclipse.model.LoggingEventManager;
import ch.qos.logback.eclipse.reciever.SimpleSocketServer;
@@ -24,14 +24,17 @@
public class LogbackView extends ViewPart {
+ public static int LOW_WATERMARK = 400000;
+ public static int DEFAULT_HIGH_WATERMARK = 1000000;
+
private TextConsoleViewer viewer;
private MessageConsole myConsole;
private LoggingEventContentProvider provider;
private LoggingEventLabelProvider labelProvider;
private Action clearConsoleAction;
- private static String PL_ACTION_MESSAGE = "PatternLayout...";
- private LogbackViewPatternAction patternLayoutAction;
+ private static String PREF_ACTION_MESSAGE = "Preferences...";
+ private LogbackPreferencesAction preferencesAction;
public LogbackView() {
launchSocketServer();
@@ -40,12 +43,12 @@
public void createPartControl(Composite parent) {
myConsole = new MessageConsole("My Console", null);
- myConsole.setWaterMarks(600000, 1000000);
+ myConsole.setWaterMarks(LOW_WATERMARK, DEFAULT_HIGH_WATERMARK);
viewer = new TextConsoleViewer(parent, myConsole);
viewer.setEditable(false);
- provider = new LoggingEventContentProvider(myConsole);
+ provider = new LoggingEventContentProvider(myConsole, viewer);
labelProvider = new LoggingEventLabelProvider();
provider.setLabelProvider(labelProvider);
@@ -62,11 +65,11 @@
}
private void makeActions() {
- patternLayoutAction = new LogbackViewPatternAction(viewer, labelProvider.getPatternLayout(),
- PL_ACTION_MESSAGE);
+ preferencesAction = new LogbackPreferencesAction(viewer, labelProvider.getPatternLayout(),
+ PREF_ACTION_MESSAGE, myConsole);
IMenuManager menu = getViewSite().getActionBars().getMenuManager();
- menu.add(patternLayoutAction);
+ menu.add(preferencesAction);
clearConsoleAction = new Action() {
@@ -83,11 +86,6 @@
}
- // private void showMessage(String message) {
- // MessageDialog.openInformation(getSite().getShell(), "Logback View",
- // message);
- // }
-
private void launchSocketServer() {
new Thread(new SimpleSocketServer()).start();
}
Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java Fri Feb 23 15:40:33 2007
@@ -1,16 +1,19 @@
package ch.qos.logback.eclipse.views;
-import java.io.IOException;
-
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
+import org.eclipse.ui.console.TextConsoleViewer;
+import org.eclipse.ui.progress.WorkbenchJob;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.LoggingEvent;
-import ch.qos.logback.eclipse.PluginLogger;
import ch.qos.logback.eclipse.model.LoggingEventManagerEvent;
import ch.qos.logback.eclipse.model.LoggingEventManagerListener;
@@ -21,34 +24,49 @@
*/
public class LoggingEventContentProvider implements LoggingEventManagerListener {
- private MessageConsoleStream redStream;
- private MessageConsoleStream blackStream;
- private int count = 0;
- private static int MAX_COUNT = 1000;
+// private MessageConsoleStream redStream;
+// private MessageConsoleStream blackStream;
+// private int count = 0;
+// private static int MAX_COUNT = 1000;
+ private MessageConsole console;
+ private TextConsoleViewer viewer;
private Color cachedRed;
private Color cachedBlack;
private LabelProvider labelProvider;
- public LoggingEventContentProvider(MessageConsole console) {
+ public LoggingEventContentProvider(MessageConsole console, TextConsoleViewer viewer) {
Display display = Display.getCurrent();
cachedRed = new Color(display, 255, 0,0);
cachedBlack = new Color(display, 0, 0,0);
- redStream = console.newMessageStream();
- redStream.setColor(cachedRed);
- blackStream = console.newMessageStream();
- blackStream.setColor(cachedBlack);
- }
+ this.console = console;
+ this.viewer = viewer;
+// redStream = console.newMessageStream();
+// redStream.setColor(cachedRed);
+// blackStream = console.newMessageStream();
+// blackStream.setColor(cachedBlack);
+ }
+
+ WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ StyledText textWidget = viewer.getTextWidget();
+ if (textWidget != null) {
+ int lineCount = textWidget.getLineCount();
+ textWidget.setTopIndex(lineCount - 1);
+ }
+ return Status.OK_STATUS;
+ }
+};
public void dispose() {
cachedRed.dispose();
cachedBlack.dispose();
- try {
- redStream.close();
- blackStream.close();
- } catch (Exception e) {
- PluginLogger.logError(e);
- }
+// try {
+// redStream.close();
+// blackStream.close();
+// } catch (Exception e) {
+// PluginLogger.logError(e);
+// }
}
public void loggingEventsChanged(final LoggingEventManagerEvent event) {
@@ -69,25 +87,43 @@
private void updateViewer(final LoggingEventManagerEvent event) {
LoggingEvent le = (LoggingEvent) event.getItemsAdded()[0];
- if (le.getLevel().isGreaterOrEqual(Level.WARN)) {
- redStream.println(labelProvider.getText(le));
- } else {
- blackStream.println(labelProvider.getText(le));
- }
- count ++;
- if (count > MAX_COUNT) {
- flushStreams();
- }
+// if (le.getLevel().isGreaterOrEqual(Level.WARN)) {
+// redStream.println(labelProvider.getText(le));
+// } else {
+// blackStream.println(labelProvider.getText(le));
+// }
+// count ++;
+// if (count > MAX_COUNT) {
+// flushStreams();
+// }
- }
-
- private void flushStreams() {
+ MessageConsoleStream stream = console.newMessageStream();
+ //viewer.setRedraw(false);
try {
- blackStream.flush();
- redStream.flush();
+ if (le.getLevel().isGreaterOrEqual(Level.WARN)) {
+ stream.setColor(cachedRed);
+ }
+ stream.println(labelProvider.getText(le));
+ stream.close();
} catch (Exception e) {
- PluginLogger.logError(e);
+ //?
}
+ //viewer.revealRange(viewer.getBottomIndexEndOffset(), 1);
+ revealEndOfDocument();
+ //viewer.setRedraw(true);
+ }
+
+// private void flushStreams() {
+// try {
+// blackStream.flush();
+// redStream.flush();
+// } catch (Exception e) {
+// PluginLogger.logError(e);
+// }
+// }
+
+ private void revealEndOfDocument() {
+ revealJob.schedule(50);
}
public void setLabelProvider(LabelProvider provider) {
Modified: logbackPDE/trunk/plugins/ConsolePlugin/todo.txt
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/todo.txt (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/todo.txt Fri Feb 23 15:40:33 2007
@@ -4,6 +4,6 @@
Color one line each two lines with a gray background.
->LineStyleListener might do the trick (StyledText component).
-Make the viewer always display the latest lines added
+OK -> Make the viewer always display the latest lines added
Is it possible to use the logger without bringing the ErrorLog view up?
\ No newline at end of file
More information about the logback-dev
mailing list