[logback-dev] svn commit: r1459 - in logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse: dialog reciever
noreply.seb at qos.ch
noreply.seb at qos.ch
Mon Mar 26 21:19:58 CEST 2007
Author: seb
Date: Mon Mar 26 21:19:58 2007
New Revision: 1459
Modified:
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/reciever/SimpleSocketServer.java
Log:
Font selection now uses a combo box
Better error reporting from SocketServer
Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/dialog/LogbackPreferencesDialog.java Mon Mar 26 21:19:58 2007
@@ -1,15 +1,21 @@
package ch.qos.logback.eclipse.dialog;
+import java.util.ArrayList;
+import java.util.List;
+
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;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@@ -29,7 +35,7 @@
private Text patternField;
private Text portField;
- private Text fontField;
+ private Combo fontCombo;
private Text fontSizeField;
public LogbackPreferencesDialog(Shell parentShell, String namePattern, int serverPort, String fontName
@@ -89,9 +95,18 @@
fontLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
fontLabel.setText("Select the font to use");
- fontField = new Text(container, SWT.BORDER);
- fontField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
+ fontCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
+
+ FontData[] fdArray = Display.getDefault().getFontList(null, true);
+ List<String> namesList = new ArrayList<String>();
+ for (int i = 0; i < fdArray.length; i++) {
+ String name = fdArray[i].getName();
+ if (!namesList.contains(name)) {
+ fontCombo.add(fdArray[i].getName());
+ namesList.add(name);
+ }
+ }
+
final Label sizeLabel = new Label(container, SWT.NONE);
sizeLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
sizeLabel.setText("Enter font size");
@@ -122,12 +137,12 @@
}
});
- fontField.setText(fontName);
- fontField.addModifyListener(new ModifyListener() {
+ fontCombo.select(fontCombo.indexOf(fontName));
+ fontCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- fontName = fontField.getText();
+ fontName = fontCombo.getItem(fontCombo.getSelectionIndex());
}
- });
+ });
}
protected void configureShell(Shell newShell) {
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 Mon Mar 26 21:19:58 2007
@@ -9,8 +9,8 @@
import ch.qos.logback.eclipse.PluginLogger;
/**
- * A simple {@link SocketNode} based server that recieves the logging
- * events and redirects them to the LoggingEventManager
+ * A simple {@link SocketNode} based server that recieves the logging events and
+ * redirects them to the LoggingEventManager
*
* @author Ceki Gülcü
* @author Sébastien Pennec
@@ -22,19 +22,22 @@
private int port = 4321;
private ServerSocket serverSocket;
-
+
+ public SimpleSocketServer() {
+ }
+
public void run() {
startAndLoop();
}
-
+
public void setPort(int port) {
this.port = port;
}
-
+
public int getPort() {
return port;
}
-
+
public void restart() {
try {
serverSocket.close();
@@ -43,7 +46,7 @@
PluginLogger.logError(e);
}
}
-
+
private void startAndLoop() {
try {
serverSocket = new ServerSocket(port);
@@ -51,28 +54,31 @@
Socket socket = serverSocket.accept();
new Thread(new SocketNode(socket)).start();
}
+ } catch (java.net.BindException e) {
+ String errorMessage = "The port " + port + " is already in use.";
+ PluginLogger.logError(errorMessage, e);
} catch (Exception e) {
PluginLogger.logError(e);
}
}
-
+
public void saveState(IMemento memento) {
IMemento mem = memento.createChild(TAG_SERVER);
mem.putInteger(TAG_PORT, port);
}
-
+
public void init(IMemento memento) {
IMemento mem = memento.getChild(TAG_SERVER);
- if (mem == null) {
+ if (mem == null) {
return;
}
-
+
int newPort = mem.getInteger(TAG_PORT);
-
+
if (newPort != 0) {
this.port = newPort;
}
-
+
}
-
+
}
More information about the logback-dev
mailing list