Author: pedro.r.santos
Date: Tue Dec 16 08:26:59 2008
New Revision: 322
Added:
trunk/SMS2OSC/nbproject/private/config.properties
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.form
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTableMouseAdapter.java
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/S2O.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnection.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnectionTimeout.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OConnectingPopUp.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.form
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscClient.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscListener.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscServer.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/parser/S2OSMSParser.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OCommPortList.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OProperties.java
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTextAreaHandler.java
Log:
Tabela de Sms acabado
Teste de envio e recepção de sms implementado
Mensagens de log actualizadas
Added: trunk/SMS2OSC/nbproject/private/config.properties
==============================================================================
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/S2O.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/S2O.java (original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/S2O.java Tue Dec 16 08:26:59
2008
@@ -8,6 +8,7 @@
import pt.citar.diablu.sms2osc.bluetooth.S2OBTConnection;
import pt.citar.diablu.sms2osc.gui.S2OConnectingPopUp;
import pt.citar.diablu.sms2osc.gui.S2OGUI;
+import pt.citar.diablu.sms2osc.gui.S2OMessagePopUp;
import pt.citar.diablu.sms2osc.osc.S2OOscClient;
import pt.citar.diablu.sms2osc.osc.S2OOscServer;
import pt.citar.diablu.sms2osc.parser.S2OSMSParser;
@@ -15,65 +16,50 @@
import pt.citar.diablu.sms2osc.util.S2OProperties;
import pt.citar.diablu.sms2osc.util.S2OTextAreaHandler;
-
public class S2O {
private Logger logger;
private S2OCommPortList commPortList;
private S2OProperties properties;
-
-
-
private S2OGUI gui;
private S2OConnectingPopUp connectionPopUpGui;
+ private S2OMessagePopUp messagePopUp;
private S2OTextAreaHandler textAreaHandler;
private FileHandler fileHandler;
private S2OOscServer oscServer;
private S2OOscClient oscClient;
-
-
-
-
private S2OSMSParser smsParser;
private S2OBTConnection btConnection;
public Thread btConnectionThread;
-
-
- public S2O()
- {
+
+ public S2O() {
logger = Logger.getLogger("pt.citar.diablu.sms2osc");
properties = new S2OProperties(this);
commPortList = new S2OCommPortList();
gui = new S2OGUI(this);
setupLogger();
-
+
+ messagePopUp = new S2OMessagePopUp();
properties.loadProperties();
oscServer = new S2OOscServer(this);
oscClient = new S2OOscClient(this);
-
+
smsParser = new S2OSMSParser(this, properties.useParser());
- if(smsParser.isActive())
- {
+ if (smsParser.isActive()) {
smsParser.getCommands(properties.getCommands());
}
btConnection = new S2OBTConnection(this, properties.getGateway(),
this.getGui().getCommPort(), 57600, "", "");
-
-
-
-
}
-
-
+
public static void main(String[] args) {
-
+
S2O s2o = new S2O();
s2o.gui.setVisible(true);
}
-
- private void setupLogger()
- {
+
+ private void setupLogger() {
logger.setLevel(Level.ALL);
-
+
textAreaHandler = new S2OTextAreaHandler(gui.getLogTextArea());
try {
fileHandler = new FileHandler("logs.txt");
@@ -86,7 +72,7 @@
logger.addHandler(textAreaHandler);
logger.addHandler(fileHandler);
-
+
}
public S2OGUI getGui() {
@@ -101,7 +87,6 @@
return btConnectionThread;
}
-
public S2OProperties getProperties() {
return properties;
}
@@ -117,7 +102,7 @@
public S2OOscClient getOscClient() {
return oscClient;
}
-
+
public S2OTextAreaHandler getTextAreaHandler() {
return textAreaHandler;
}
@@ -146,19 +131,7 @@
this.btConnection = btConnection;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ public S2OMessagePopUp getMessagePopUp() {
+ return messagePopUp;
+ }
}
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnection.java
==============================================================================
---
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnection.java
(original)
+++
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnection.java
Tue Dec 16 08:26:59 2008
@@ -1,4 +1,3 @@
-
package pt.citar.diablu.sms2osc.bluetooth;
import de.sciss.net.OSCMessage;
@@ -7,7 +6,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.smslib.GatewayException;
import org.smslib.IInboundMessageNotification;
import org.smslib.IOutboundMessageNotification;
@@ -20,7 +18,6 @@
import org.smslib.TimeoutException;
import org.smslib.modem.SerialModemGateway;
-
public class S2OBTConnection implements Runnable {
String id;
@@ -31,9 +28,8 @@
Service srv;
S2O s2o;
boolean connected;
- boolean connecting;
SerialModemGateway gateway;
-
+
public S2OBTConnection(S2O s2o, String id, String port, int baud,
String manufacturer, String model) {
this.s2o = s2o;
this.id = id;
@@ -42,18 +38,18 @@
this.manufacturer = manufacturer;
this.model = model;
this.connected = false;
- this.connecting = false;
+
}
public void startConnection() {
try {
-
- this.connecting = true;
+
+
List<InboundMessage> msgList;
-
+
InboundNotification inboundNotification = new
InboundNotification();
OutboundNotification outboundNotification = new
OutboundNotification();
-
+
srv = new Service();
gateway = new SerialModemGateway(id, port, baud, manufacturer,
model);
@@ -63,13 +59,15 @@
srv.setInboundNotification(inboundNotification);
srv.addGateway(gateway);
srv.startService();
- System.out.println(" Modem Information: build2");
+
+
+ /*System.out.println(" Modem Information: build2");
System.out.println(" Manufacturer: " +
gateway.getManufacturer());
System.out.println(" Model: " + gateway.getModel());
System.out.println(" Serial No: " + gateway.getSerialNo());
System.out.println(" SIM IMSI: " + gateway.getImsi());
System.out.println(" Signal Level: " +
gateway.getSignalLevel() + "%");
- System.out.println(" Battery Level: " +
gateway.getBatteryLevel() + "%");
+ System.out.println(" Battery Level: " +
gateway.getBatteryLevel() + "%");*/
msgList = new ArrayList<InboundMessage>();
srv.readMessages(msgList, MessageClasses.ALL);
@@ -77,55 +75,67 @@
System.out.println(msg);
}
this.connected = true;
-
+ s2o.getConnectionPopUpGui().connected();
+
} catch (TimeoutException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
- this.connecting = false;
+ s2o.getLogger().log(Level.WARNING, ex.getMessage());
+ this.stopConnection();
+ s2o.getConnectionPopUpGui().connectionFailed();
} catch (GatewayException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
- this.connecting = false;
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
+ this.stopConnection();
+
+ s2o.getConnectionPopUpGui().connectionFailed();
+
} catch (SMSLibException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
- this.connecting = false;
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
+
+ s2o.getConnectionPopUpGui().connectionFailed();
+
} catch (IOException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
- this.connecting = false;
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
+
+ s2o.getConnectionPopUpGui().connectionFailed();
+
} catch (InterruptedException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
- this.connecting = false;
+ s2o.getLogger().log(Level.WARNING, ex.getMessage());
+ this.stopConnection();
+ s2o.getConnectionPopUpGui().connectionStopped();
+
}
}
public void sendMessage(String smsRecipient, String smsBody) {
try {
+ s2o.getGui().addMessageRow(smsRecipient, "Outbound", smsBody);
OutboundMessage msg;
msg = new OutboundMessage(smsRecipient, smsBody);
srv.sendMessage(msg);
} catch (TimeoutException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.WARNING, ex.getMessage());
} catch (GatewayException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (IOException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (InterruptedException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
public void stopConnection() {
try {
-
+ this.connected = false;
srv.stopService();
gateway.stopGateway();
} catch (TimeoutException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (GatewayException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (IOException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (InterruptedException ex) {
-
Logger.getLogger(S2OBTConnection.class.getName()).log(Level.SEVERE, null,
ex);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
@@ -135,7 +145,7 @@
System.out.println("Sending message through: " + gatewayId);
System.out.println("To: " + msg.getRecipient());
System.out.println("Body:\n" + msg);
-
+
}
}
@@ -146,41 +156,33 @@
if (msgType == MessageTypes.INBOUND) {
System.out.println(">>> New Inbound message detected from
Gateway: " + gatewayId);
s2o.getGui().addMessageRow(msg.getOriginator(), "Inbound",
msg.getText());
- if(s2o.getSmsParser().isActive())
- {
+ if (s2o.getSmsParser().isActive()) {
s2o.getSmsParser().parse(msg.getText());
- }
- else
- {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/sms", new Object[] { msg.getOriginator(),
msg.getText()}));
+ } else {
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/sms", new Object[]{msg.getOriginator(),
msg.getText()}));
System.out.println("Message: " + msg.getText());
}
try {
srv.deleteMessage(msg);
} catch (Exception e) {
-
- System.out.println("Oops!!! Something gone bad...");
- e.printStackTrace();
+
+ System.out.println("Oops!!! Something gone bad...");
+ e.printStackTrace();
}
+
}
-
+
}
}
-
- public void connect()
- {
- S2OBTConnectionTimeout timeout = new S2OBTConnectionTimeout(s2o,
15);
+
+ public void run() {
+ S2OBTConnectionTimeout timeout = new S2OBTConnectionTimeout(s2o,
20000);
Thread to = new Thread(timeout);
to.start();
this.startConnection();
- timeout.setConnected(true);
to.interrupt();
}
- public void run() {
- connect();
- }
-
public void setPort(String port) {
this.port = port;
}
@@ -192,7 +194,4 @@
public String getPort() {
return port;
}
-
-
-
}
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnectionTimeout.java
==============================================================================
---
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnectionTimeout.java
(original)
+++
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/bluetooth/S2OBTConnectionTimeout.java
Tue Dec 16 08:26:59 2008
@@ -1,54 +1,35 @@
-
package pt.citar.diablu.sms2osc.bluetooth;
import pt.citar.diablu.sms2osc.S2O;
-public class S2OBTConnectionTimeout implements Runnable{
-
+public class S2OBTConnectionTimeout implements Runnable {
+
int timeout;
boolean interrupted;
- boolean connected;
Thread btConnect;
S2O s2o;
-
- public S2OBTConnectionTimeout(S2O s2o, int timeout)
- {
+
+ public S2OBTConnectionTimeout(S2O s2o, int timeout) {
this.timeout = timeout;
this.s2o = s2o;
- this.connected = false;
+
}
public void run() {
- this.connected = false;
- System.out.println("timeout");
+
+
try {
Thread.sleep(timeout * 1000);
- if(!interrupted)
- {
+ if (!interrupted) {
s2o.getBtConnectionThread().interrupt();
- }
- s2o.getConnectionPopUpGui().connectionFailed();
+ }
} catch (InterruptedException ex) {
-
//Logger.getLogger(S2OBTConnectionTimeout.class.getName()).log(Level.SEVERE,
null, ex);
- System.out.println("timeout stopped");
- if(connected)
- s2o.getConnectionPopUpGui().connected();
- else
- s2o.getConnectionPopUpGui().connectionFailed();
-
-
-
}
-
- }
-
- public void setConnected(boolean connected) {
- this.connected = connected;
}
+}
-
-
+
-}
+
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OConnectingPopUp.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OConnectingPopUp.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OConnectingPopUp.java
Tue Dec 16 08:26:59 2008
@@ -1,40 +1,25 @@
-/*
- *
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/*
- * S2OConnectingPopUp.java
- *
- * Created on 9/Dez/2008, 11:08:11
- */
package pt.citar.diablu.sms2osc.gui;
-//import javax.swing.JFrame;
+import java.util.logging.Level;
+import javax.swing.JFrame;
import pt.citar.diablu.sms2osc.S2O;
-/**
- *
- * @author Raspa
- */
+
public class S2OConnectingPopUp extends javax.swing.JFrame {
S2O s2o;
String commPort;
- /** Creates new form S2OConnectingPopUp */
public S2OConnectingPopUp(S2O s2o, String commPort) {
this.s2o = s2o;
this.commPort = commPort;
initComponents();
- //this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
messageLabel.setText("Establishing Connection on port " +
commPort);
okButton.setVisible(false);
}
-
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
Code">//GEN-BEGIN:initComponents
private void initComponents() {
@@ -97,7 +82,7 @@
s2o.getGui().setVisible(true);
this.setVisible(false);
s2o.getGui().setGatewayConnectionState(false);
-
+
}//GEN-LAST:event_cancelButtonActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_okButtonActionPerformed
@@ -105,39 +90,37 @@
this.setVisible(false);
}//GEN-LAST:event_okButtonActionPerformed
- public void connected()
- {
+ public void connected() {
cancelButton.setVisible(false);
okButton.setVisible(true);
messageLabel.setText("Connection established on port " + commPort);
s2o.getGui().setGatewayConnectionState(true);
+ s2o.getLogger().log(Level.WARNING, "Connection established on
port " + commPort);
+
}
- public void connectionFailed()
- {
+ public void connectionFailed() {
cancelButton.setVisible(false);
okButton.setVisible(true);
messageLabel.setText("Connection failed on port " + commPort);
s2o.getGui().setGatewayConnectionState(false);
+ s2o.getLogger().log(Level.WARNING, "Connection failed on port " +
commPort);
}
- public void connectionStopped()
- {
+ public void connectionStopped() {
this.setVisible(true);
cancelButton.setVisible(false);
okButton.setVisible(true);
messageLabel.setText("Connection stopped port " +
s2o.getBtConnection().getPort());
s2o.getGui().setGatewayConnectionState(false);
+ s2o.getLogger().log(Level.WARNING, "Connection stopped on port "
+ commPort);
}
-
-
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JLabel messageLabel;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
-
}
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.form
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.form (original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.form Tue Dec 16
08:26:59 2008
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.6"
type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <NonVisualComponents>
+ <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
+ </Component>
+ </NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
@@ -27,7 +31,7 @@
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="S2OTabbedPane" min="-2" max="-2" attributes="0"/>
+ <Component id="S2OTabbedPane" alignment="0" pref="256"
max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
@@ -62,10 +66,10 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2"
attributes="0">
- <Component id="GatewayPanel" alignment="0"
max="32767" attributes="1"/>
<Component id="OSCPanel" alignment="0"
max="32767" attributes="1"/>
+ <Component id="GatewayPanel" alignment="0"
max="32767" attributes="1"/>
</Group>
- <EmptySpace max="32767" attributes="0"/>
+ <EmptySpace pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -83,29 +87,22 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
+ <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="YourAppPane" linkSize="8"
min="-2" max="-2" attributes="0"/>
- <EmptySpace type="unrelated" max="-2"
attributes="0"/>
+ <EmptySpace min="-2" pref="10" max="-2"
attributes="0"/>
<Component id="SMS2OSCPanel" linkSize="8"
min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
- <Group type="102" alignment="1" attributes="0">
- <EmptySpace pref="327" max="32767"
attributes="0"/>
- <Component id="OSCConnectButton" min="-2"
max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- </Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" attributes="0">
- <Group type="103" groupAlignment="0" max="-2"
attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Group type="103" groupAlignment="1"
attributes="0">
+ <Component id="SMS2OSCPanel" alignment="0"
max="32767" attributes="1"/>
<Component id="YourAppPane" alignment="1"
max="32767" attributes="1"/>
- <Component id="SMS2OSCPanel" alignment="1"
max="32767" attributes="1"/>
</Group>
- <EmptySpace pref="32" max="32767"
attributes="0"/>
- <Component id="OSCConnectButton" min="-2"
max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -155,7 +152,7 @@
<Component id="YAPortjLabel"
alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="YAPortTextField"
alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace max="32767" attributes="0"/>
+ <EmptySpace pref="66" max="32767"
attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -189,19 +186,6 @@
</Component>
</SubComponents>
</Container>
- <Component class="javax.swing.JButton"
name="OSCConnectButton">
- <Properties>
- <Property name="text" type="java.lang.String"
value="Start Server"/>
- <Property name="horizontalTextPosition" type="int"
value="4"/>
- <Property name="verticalTextPosition" type="int"
value="3"/>
- </Properties>
- <AccessibilityProperties>
- <Property name="AccessibleContext.accessibleName"
type="java.lang.String" value=""/>
- </AccessibilityProperties>
- <Events>
- <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="OSCConnectButtonActionPerformed"/>
- </Events>
- </Component>
<Container class="javax.swing.JPanel" name="SMS2OSCPanel">
<Properties>
<Property name="border"
type="javax.swing.border.Border"
editor="org.netbeans.modules.form.editors2.BorderEditor">
@@ -214,11 +198,16 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="S2OPortLabel" min="-2"
pref="70" max="-2" attributes="0"/>
+ <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
- <Component id="S2OPortTextField" pref="89"
max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="0"
attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="S2OPortLabel"
min="-2" pref="70" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="S2OPortTextField"
pref="89" max="32767" attributes="0"/>
+ </Group>
+ <Component id="OSCConnectButton"
alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -231,7 +220,9 @@
<Component id="S2OPortLabel"
alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="S2OPortTextField"
alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace pref="37" max="32767"
attributes="0"/>
+ <EmptySpace pref="58" max="32767"
attributes="0"/>
+ <Component id="OSCConnectButton" min="-2"
max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -250,6 +241,19 @@
</Property>
</Properties>
</Component>
+ <Component class="javax.swing.JButton"
name="OSCConnectButton">
+ <Properties>
+ <Property name="text" type="java.lang.String"
value="Start Server"/>
+ <Property name="horizontalTextPosition" type="int"
value="4"/>
+ <Property name="verticalTextPosition" type="int"
value="3"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleName"
type="java.lang.String" value=""/>
+ </AccessibilityProperties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="OSCConnectButtonActionPerformed"/>
+ </Events>
+ </Component>
</SubComponents>
</Container>
</SubComponents>
@@ -350,7 +354,7 @@
</Container>
</SubComponents>
</Container>
- <Container class="javax.swing.JPanel" name="jPanel2">
+ <Container class="javax.swing.JPanel" name="SMSPannel">
<Constraints>
<Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"
value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="SMSs">
@@ -364,7 +368,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
- <Component id="jScrollPane2" pref="634" max="32767"
attributes="0"/>
+ <Component id="SMSTableScrollPane" pref="634"
max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -373,21 +377,21 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
- <Component id="jScrollPane2" pref="194" max="32767"
attributes="0"/>
+ <Component id="SMSTableScrollPane" pref="206"
max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
- <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+ <Container class="javax.swing.JScrollPane"
name="SMSTableScrollPane">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean"
value="true"/>
</AuxValues>
<Layout
class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
- <Component class="javax.swing.JTable" name="jTable1">
+ <Component class="javax.swing.JTable" name="SMSTable">
<Properties>
<Property name="model"
type="javax.swing.table.TableModel"
editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="3" rowCount="20">
@@ -425,7 +429,7 @@
</Container>
</SubComponents>
</Container>
- <Container class="javax.swing.JPanel" name="jPanel1">
+ <Container class="javax.swing.JPanel" name="logPannel">
<Constraints>
<Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"
value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Log">
@@ -440,8 +444,8 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="jScrollPane1" alignment="0"
pref="634" max="32767" attributes="0"/>
- <Component id="jComboBox1" alignment="1"
min="-2" max="-2" attributes="0"/>
+ <Component id="logScrollPane" pref="634"
max="32767" attributes="0"/>
+ <Component id="LevelComboBox" alignment="1"
min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -451,16 +455,16 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
- <Component id="jScrollPane1" min="-2" pref="161"
max="-2" attributes="0"/>
- <EmptySpace pref="13" max="32767" attributes="0"/>
- <Component id="jComboBox1" min="-2" max="-2"
attributes="0"/>
+ <Component id="logScrollPane" min="-2" pref="161"
max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
+ <Component id="LevelComboBox" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
- <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <Container class="javax.swing.JScrollPane"
name="logScrollPane">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean"
value="true"/>
</AuxValues>
@@ -475,19 +479,19 @@
</Component>
</SubComponents>
</Container>
- <Component class="javax.swing.JComboBox" name="jComboBox1">
+ <Component class="javax.swing.JComboBox" name="LevelComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel"
editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new
javax.swing.DefaultComboBoxModel(new String[] { "SEVERE",
"WARNING", "INFO", "CONFIG",
"FINE", "FINER", "FINEST" })" type="code"/>
</Property>
</Properties>
<Events>
- <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="jComboBox1ActionPerformed"/>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="LevelComboBoxActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
- <Container class="javax.swing.JPanel" name="jPanel3">
+ <Container class="javax.swing.JPanel" name="TestPanel">
<Constraints>
<Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"
value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Test">
@@ -499,15 +503,111 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="654" max="32767"
attributes="0"/>
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="numberLabel" min="-2"
max="-2" attributes="1"/>
+ <EmptySpace type="separate" max="-2"
attributes="0"/>
+ <Component id="numberTextField" min="-2"
pref="138" max="-2" attributes="0"/>
+ </Group>
+ <Component id="messageScrollPane" alignment="0"
pref="634" max="32767" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="outRadioButton" min="-2"
max="-2" attributes="0"/>
+ <EmptySpace pref="462" max="32767"
attributes="0"/>
+ <Component id="sendButton" min="-2" max="-2"
attributes="0"/>
+ </Group>
+ <Component id="inRadioButton" alignment="0"
min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="messageLabel" pref="565"
max="32767" attributes="1"/>
+ <EmptySpace min="69" pref="69" max="69"
attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="216" max="32767"
attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="9" max="-2"
attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="numberLabel" alignment="3"
min="-2" max="-2" attributes="0"/>
+ <Component id="numberTextField" alignment="3"
min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="messageLabel" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace type="unrelated" max="-2"
attributes="0"/>
+ <Component id="messageScrollPane" min="-2" pref="85"
max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="6" max="-2"
attributes="0"/>
+ <Component id="inRadioButton" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="outRadioButton" alignment="3"
min="-2" max="-2" attributes="0"/>
+ <Component id="sendButton" alignment="3"
min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="29" max="-2"
attributes="0"/>
+ </Group>
</Group>
</DimensionLayout>
</Layout>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane"
name="messageScrollPane">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean"
value="true"/>
+ </AuxValues>
+
+ <Layout
class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea"
name="messageTextArea">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="rows" type="int" value="5"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JLabel" name="messageLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String"
value="Message:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JRadioButton"
name="outRadioButton">
+ <Properties>
+ <Property name="buttonGroup"
type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Send
to Cell Phone"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JRadioButton"
name="inRadioButton">
+ <Properties>
+ <Property name="buttonGroup"
type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="selected" type="boolean" value="true"/>
+ <Property name="text" type="java.lang.String" value="Send
to Application"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="inRadioButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="sendButton">
+ <Properties>
+ <Property name="text" type="java.lang.String"
value="Send"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="sendButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="numberLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String"
value="Number:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField"
name="numberTextField">
+ </Component>
+ </SubComponents>
</Container>
</SubComponents>
</Container>
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.java (original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OGUI.java Tue Dec 16
08:26:59 2008
@@ -1,53 +1,45 @@
-
package pt.citar.diablu.sms2osc.gui;
-import java.awt.Point;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
+import de.sciss.net.OSCMessage;
import java.util.logging.Level;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
import javax.swing.JTextArea;
import pt.citar.diablu.sms2osc.*;
import pt.citar.diablu.sms2osc.bluetooth.S2OBTConnection;
+import pt.citar.diablu.sms2osc.util.S2OTableMouseAdapter;
public class S2OGUI extends javax.swing.JFrame {
S2O s2o;
int rowNumber = 0;
boolean isGatewayConnected = false;
-
+ private S2OTableMouseAdapter tableMouseAdapter;
+
public S2OGUI(S2O s2o) {
this.s2o = s2o;
initComponents();
setCommPorts();
+ tableMouseAdapter = new S2OTableMouseAdapter(s2o);
+
+ SMSTable.addMouseListener(tableMouseAdapter);
+
+ }
- jTable1.addMouseListener(new MouseAdapter(){
- @Override
- public void mouseClicked(MouseEvent e){
- if (e.getClickCount() == 2){
- Point p = e.getPoint();
- int row = jTable1.rowAtPoint(p);
- System.out.println((String)jTable1.getValueAt(row,0));
- System.out.println((String)jTable1.getValueAt(row,1));
- System.out.println((String)jTable1.getValueAt(row,2));
- }
- }
- } );
- }
-
- private void setCommPorts()
- {
- for(String port: s2o.getCommPortList().getCommPorts())
+ private void setCommPorts() {
+ for (String port : s2o.getCommPortList().getCommPorts()) {
CommPorts.addItem(port);
+ }
CommPorts.setSelectedItem(s2o.getProperties().getComPort());
-
-
+
+
}
-
-
+
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
Code">//GEN-BEGIN:initComponents
private void initComponents() {
+ buttonGroup1 = new javax.swing.ButtonGroup();
S2OTabbedPane = new javax.swing.JTabbedPane();
ConnectionPanel = new javax.swing.JPanel();
OSCPanel = new javax.swing.JPanel();
@@ -56,24 +48,32 @@
YAHostnameLabel = new javax.swing.JLabel();
YAPortjLabel = new javax.swing.JLabel();
YAPortTextField = new javax.swing.JTextField();
- OSCConnectButton = new javax.swing.JButton();
SMS2OSCPanel = new javax.swing.JPanel();
S2OPortLabel = new javax.swing.JLabel();
S2OPortTextField = new javax.swing.JTextField();
+ OSCConnectButton = new javax.swing.JButton();
GatewayPanel = new javax.swing.JPanel();
CommPorts = new javax.swing.JComboBox();
Connect = new javax.swing.JButton();
CommPortLabel = new javax.swing.JLabel();
CommPortLabel1 = new javax.swing.JLabel();
BaudRateFormatedTextField = new javax.swing.JFormattedTextField();
- jPanel2 = new javax.swing.JPanel();
- jScrollPane2 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- jPanel1 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
+ SMSPannel = new javax.swing.JPanel();
+ SMSTableScrollPane = new javax.swing.JScrollPane();
+ SMSTable = new javax.swing.JTable();
+ logPannel = new javax.swing.JPanel();
+ logScrollPane = new javax.swing.JScrollPane();
logTextArea = new javax.swing.JTextArea();
- jComboBox1 = new javax.swing.JComboBox();
- jPanel3 = new javax.swing.JPanel();
+ LevelComboBox = new javax.swing.JComboBox();
+ TestPanel = new javax.swing.JPanel();
+ messageScrollPane = new javax.swing.JScrollPane();
+ messageTextArea = new javax.swing.JTextArea();
+ messageLabel = new javax.swing.JLabel();
+ outRadioButton = new javax.swing.JRadioButton();
+ inRadioButton = new javax.swing.JRadioButton();
+ sendButton = new javax.swing.JButton();
+ numberLabel = new javax.swing.JLabel();
+ numberTextField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@@ -124,9 +124,16 @@
.addGroup(YourAppPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(YAPortjLabel)
.addComponent(YAPortTextField,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ .addContainerGap(66, Short.MAX_VALUE))
);
+
SMS2OSCPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("SMS2OSC"));
+
+ S2OPortLabel.setText("Port:");
+
+
S2OPortTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
+ S2OPortTextField.setText(s2o.getProperties().getOutgoingPort() );
+
OSCConnectButton.setText("Start Server");
OSCConnectButton.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
OSCConnectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
@@ -136,22 +143,18 @@
}
});
-
SMS2OSCPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("SMS2OSC"));
-
- S2OPortLabel.setText("Port:");
-
-
S2OPortTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
- S2OPortTextField.setText(s2o.getProperties().getOutgoingPort() );
-
javax.swing.GroupLayout SMS2OSCPanelLayout = new
javax.swing.GroupLayout(SMS2OSCPanel);
SMS2OSCPanel.setLayout(SMS2OSCPanelLayout);
SMS2OSCPanelLayout.setHorizontalGroup(
SMS2OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(SMS2OSCPanelLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(S2OPortLabel,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(S2OPortTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
+ .addGroup(SMS2OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(SMS2OSCPanelLayout.createSequentialGroup()
+ .addComponent(S2OPortLabel,
javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(S2OPortTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
+ .addComponent(OSCConnectButton,
javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
SMS2OSCPanelLayout.setVerticalGroup(
@@ -161,9 +164,13 @@
.addGroup(SMS2OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(S2OPortLabel)
.addComponent(S2OPortTextField,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(37, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
58,
Short.MAX_VALUE)
+ .addComponent(OSCConnectButton)
+ .addContainerGap())
);
+ OSCConnectButton.getAccessibleContext().setAccessibleName("");
+
javax.swing.GroupLayout OSCPanelLayout = new
javax.swing.GroupLayout(OSCPanel);
OSCPanel.setLayout(OSCPanelLayout);
OSCPanelLayout.setHorizontalGroup(
@@ -171,30 +178,22 @@
.addGroup(OSCPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(YourAppPane,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGap(10, 10, 10)
.addComponent(SMS2OSCPanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
OSCPanelLayout.createSequentialGroup()
- .addContainerGap(327, Short.MAX_VALUE)
- .addComponent(OSCConnectButton)
- .addContainerGap())
);
OSCPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {SMS2OSCPanel, YourAppPane});
OSCPanelLayout.setVerticalGroup(
OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(OSCPanelLayout.createSequentialGroup()
- .addGroup(OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
- .addComponent(YourAppPane,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
- .addComponent(SMS2OSCPanel,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
32,
Short.MAX_VALUE)
- .addComponent(OSCConnectButton)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
OSCPanelLayout.createSequentialGroup()
+ .addGroup(OSCPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(SMS2OSCPanel,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(YourAppPane,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap())
);
- OSCConnectButton.getAccessibleContext().setAccessibleName("");
-
GatewayPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Gateway"));
Connect.setText("Connect");
@@ -266,14 +265,14 @@
.addGroup(ConnectionPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(ConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
- .addComponent(GatewayPanel,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
- .addComponent(OSCPanel,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ .addComponent(OSCPanel,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(GatewayPanel,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ .addContainerGap(23, Short.MAX_VALUE))
);
S2OTabbedPane.addTab("Connection", ConnectionPanel);
- jTable1.setModel(new javax.swing.table.DefaultTableModel(
+ SMSTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
@@ -315,81 +314,139 @@
return canEdit [columnIndex];
}
});
- jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
- jTable1.getTableHeader().setReorderingAllowed(false);
- jScrollPane2.setViewportView(jTable1);
- jTable1.getColumnModel().getColumn(0).setResizable(false);
- jTable1.getColumnModel().getColumn(0).setPreferredWidth(100);
- jTable1.getColumnModel().getColumn(1).setResizable(false);
- jTable1.getColumnModel().getColumn(1).setPreferredWidth(100);
- jTable1.getColumnModel().getColumn(2).setResizable(false);
- jTable1.getColumnModel().getColumn(2).setPreferredWidth(600);
-
- javax.swing.GroupLayout jPanel2Layout = new
javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
-
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
+ SMSTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
+ SMSTable.getTableHeader().setReorderingAllowed(false);
+ SMSTableScrollPane.setViewportView(SMSTable);
+ SMSTable.getColumnModel().getColumn(0).setResizable(false);
+ SMSTable.getColumnModel().getColumn(0).setPreferredWidth(100);
+ SMSTable.getColumnModel().getColumn(1).setResizable(false);
+ SMSTable.getColumnModel().getColumn(1).setPreferredWidth(100);
+ SMSTable.getColumnModel().getColumn(2).setResizable(false);
+ SMSTable.getColumnModel().getColumn(2).setPreferredWidth(600);
+
+ javax.swing.GroupLayout SMSPannelLayout = new
javax.swing.GroupLayout(SMSPannel);
+ SMSPannel.setLayout(SMSPannelLayout);
+ SMSPannelLayout.setHorizontalGroup(
+
SMSPannelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(SMSPannelLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
+ .addComponent(SMSTableScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
.addContainerGap())
);
- jPanel2Layout.setVerticalGroup(
-
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
+ SMSPannelLayout.setVerticalGroup(
+
SMSPannelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
SMSPannelLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+ .addComponent(SMSTableScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
.addContainerGap())
);
- S2OTabbedPane.addTab("SMSs", jPanel2);
+ S2OTabbedPane.addTab("SMSs", SMSPannel);
logTextArea.setColumns(20);
logTextArea.setRows(5);
- jScrollPane1.setViewportView(logTextArea);
+ logScrollPane.setViewportView(logTextArea);
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new
String[]
{ "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" }));
- jComboBox1.addActionListener(new java.awt.event.ActionListener() {
+ LevelComboBox.setModel(new javax.swing.DefaultComboBoxModel(new
String[]
{ "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" }));
+ LevelComboBox.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox1ActionPerformed(evt);
+ LevelComboBoxActionPerformed(evt);
}
});
- javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
-
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
- .addComponent(jComboBox1,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ javax.swing.GroupLayout logPannelLayout = new
javax.swing.GroupLayout(logPannel);
+ logPannel.setLayout(logPannelLayout);
+ logPannelLayout.setHorizontalGroup(
+
logPannelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(logPannelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(logPannelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(logScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
+ .addComponent(LevelComboBox,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
- jPanel1Layout.setVerticalGroup(
-
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 161,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
13,
Short.MAX_VALUE)
- .addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
+ logPannelLayout.setVerticalGroup(
+
logPannelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(logPannelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(logScrollPane,
javax.swing.GroupLayout.PREFERRED_SIZE, 161,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(LevelComboBox,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(30, Short.MAX_VALUE))
);
- S2OTabbedPane.addTab("Log", jPanel1);
+ S2OTabbedPane.addTab("Log", logPannel);
+
+ messageTextArea.setColumns(20);
+ messageTextArea.setRows(5);
+ messageScrollPane.setViewportView(messageTextArea);
+
+ messageLabel.setText("Message:");
+
+ buttonGroup1.add(outRadioButton);
+ outRadioButton.setText("Send to Cell Phone");
+
+ buttonGroup1.add(inRadioButton);
+ inRadioButton.setSelected(true);
+ inRadioButton.setText("Send to Application");
+ inRadioButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inRadioButtonActionPerformed(evt);
+ }
+ });
+
+ sendButton.setText("Send");
+ sendButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ sendButtonActionPerformed(evt);
+ }
+ });
+
+ numberLabel.setText("Number:");
- javax.swing.GroupLayout jPanel3Layout = new
javax.swing.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
-
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 654, Short.MAX_VALUE)
+ javax.swing.GroupLayout TestPanelLayout = new
javax.swing.GroupLayout(TestPanel);
+ TestPanel.setLayout(TestPanelLayout);
+ TestPanelLayout.setHorizontalGroup(
+
TestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(TestPanelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(TestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(TestPanelLayout.createSequentialGroup()
+ .addComponent(numberLabel)
+ .addGap(18, 18, 18)
+ .addComponent(numberTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 138,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(messageScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
+ .addGroup(TestPanelLayout.createSequentialGroup()
+ .addComponent(outRadioButton)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
462,
Short.MAX_VALUE)
+ .addComponent(sendButton))
+ .addComponent(inRadioButton)
+ .addGroup(TestPanelLayout.createSequentialGroup()
+ .addComponent(messageLabel,
javax.swing.GroupLayout.DEFAULT_SIZE, 565, Short.MAX_VALUE)
+ .addGap(69, 69, 69)))
+ .addContainerGap())
);
- jPanel3Layout.setVerticalGroup(
-
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 216, Short.MAX_VALUE)
+ TestPanelLayout.setVerticalGroup(
+
TestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(TestPanelLayout.createSequentialGroup()
+ .addGap(9, 9, 9)
+ .addGroup(TestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(numberLabel)
+ .addComponent(numberTextField,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(messageLabel)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(messageScrollPane,
javax.swing.GroupLayout.PREFERRED_SIZE, 85,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(6, 6, 6)
+ .addComponent(inRadioButton)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(TestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(outRadioButton)
+ .addComponent(sendButton))
+ .addGap(29, 29, 29))
);
- S2OTabbedPane.addTab("Test", jPanel3);
+ S2OTabbedPane.addTab("Test", TestPanel);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -399,7 +456,7 @@
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(S2OTabbedPane,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(S2OTabbedPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
);
pack();
@@ -411,8 +468,8 @@
s2o.getBtConnection().stopConnection();
s2o.getConnectionPopUpGui().connectionStopped();
} else {
-
- s2o.setBtConnection(new S2OBTConnection(s2o, "lala",
CommPorts.getSelectedItem().toString(), 57600, "", ""));
+
+ s2o.setBtConnection(new S2OBTConnection(s2o, "gateway",
CommPorts.getSelectedItem().toString(), 57600, "", ""));
s2o.setBtConnectionThread(new Thread(s2o.getBtConnection()));
s2o.getBtConnection().setPort(CommPorts.getSelectedItem().toString());
s2o.getProperties().setProperty("ComPort",
CommPorts.getSelectedItem().toString());
@@ -428,16 +485,36 @@
}//GEN-LAST:event_ConnectActionPerformed
private void OSCConnectButtonActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_OSCConnectButtonActionPerformed
-if(!s2o.getOscServer().isConnected())
+ if (!s2o.getOscServer().isConnected()) {
s2o.getOscServer().start();
- else
+ } else {
s2o.getOscServer().stop();
+ }
}//GEN-LAST:event_OSCConnectButtonActionPerformed
-private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_jComboBox1ActionPerformed
- s2o.getLogger().setLevel(Level.parse((String)
jComboBox1.getSelectedItem()));
-}//GEN-LAST:event_jComboBox1ActionPerformed
+private void LevelComboBoxActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_LevelComboBoxActionPerformed
+ s2o.getLogger().setLevel(Level.parse((String)
LevelComboBox.getSelectedItem()));
+}//GEN-LAST:event_LevelComboBoxActionPerformed
+
+private void sendButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_sendButtonActionPerformed
+ if (inRadioButton.isSelected()) {
+ s2o.getGui().addMessageRow(numberTextField.getText(), "Inbound",
messageTextArea.getText());
+ if (s2o.getSmsParser().isActive()) {
+ s2o.getSmsParser().parse(messageTextArea.getText());
+ } else {
+ s2o.getOscClient().send(new OSCMessage("/diablu/sms2osc/sms",
new Object[]{numberTextField.getText(), messageTextArea.getText()}));
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/sms " + numberTextField.getText() + " " +
messageTextArea.getText());
+ }
+ } else if (outRadioButton.isSelected()) {
+ if (s2o.getBtConnection().isConnected()) {
+ s2o.getBtConnection().sendMessage(numberTextField.getText(),
messageTextArea.getText());
+ }
+ }
+}//GEN-LAST:event_sendButtonActionPerformed
+private void inRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_inRadioButtonActionPerformed
+ // TODO add your handling code here:
+}//GEN-LAST:event_inRadioButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JFormattedTextField BaudRateFormatedTextField;
@@ -447,28 +524,36 @@
private javax.swing.JButton Connect;
private javax.swing.JPanel ConnectionPanel;
private javax.swing.JPanel GatewayPanel;
+ private javax.swing.JComboBox LevelComboBox;
private javax.swing.JButton OSCConnectButton;
private javax.swing.JPanel OSCPanel;
private javax.swing.JLabel S2OPortLabel;
private javax.swing.JTextField S2OPortTextField;
private javax.swing.JTabbedPane S2OTabbedPane;
private javax.swing.JPanel SMS2OSCPanel;
+ private javax.swing.JPanel SMSPannel;
+ private javax.swing.JTable SMSTable;
+ private javax.swing.JScrollPane SMSTableScrollPane;
+ private javax.swing.JPanel TestPanel;
private javax.swing.JLabel YAHostnameLabel;
private javax.swing.JTextField YAHostnameTextField;
private javax.swing.JTextField YAPortTextField;
private javax.swing.JLabel YAPortjLabel;
private javax.swing.JPanel YourAppPane;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JTable jTable1;
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.JRadioButton inRadioButton;
+ private javax.swing.JPanel logPannel;
+ private javax.swing.JScrollPane logScrollPane;
private javax.swing.JTextArea logTextArea;
+ private javax.swing.JLabel messageLabel;
+ private javax.swing.JScrollPane messageScrollPane;
+ private javax.swing.JTextArea messageTextArea;
+ private javax.swing.JLabel numberLabel;
+ private javax.swing.JTextField numberTextField;
+ private javax.swing.JRadioButton outRadioButton;
+ private javax.swing.JButton sendButton;
// End of variables declaration//GEN-END:variables
-
public String getHostname() {
return YAHostnameTextField.getText();
}
@@ -480,66 +565,58 @@
public String getServerPort() {
return S2OPortTextField.getText();
}
-
- public void serverButtonStop(boolean b) {
- if(b)
+
+ public void serverButtonStop(boolean bool) {
+ if (bool) {
OSCConnectButton.setText("Stop Server");
- else
+ } else {
OSCConnectButton.setText("Start Server");
+ }
}
public JTextArea getLogTextArea() {
return logTextArea;
}
-
- public void addMessageRow(String number, String direction, String
message)
- {
- if(rowNumber < 20)
- {
- jTable1.getModel().setValueAt(number, rowNumber,0);
- jTable1.getModel().setValueAt(direction, rowNumber,1);
- jTable1.getModel().setValueAt(message, rowNumber,2);
- jTable1.changeSelection(rowNumber, 0, false, false);
+
+ public void addMessageRow(String number, String direction, String
message) {
+ if (rowNumber < 20) {
+ SMSTable.getModel().setValueAt(number, rowNumber, 0);
+ SMSTable.getModel().setValueAt(direction, rowNumber, 1);
+ SMSTable.getModel().setValueAt(message, rowNumber, 2);
+ SMSTable.changeSelection(rowNumber, 0, false, false);
rowNumber++;
- }
- else
- {
- for(int i = 0; i < 19; i++)
- {
-
jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(i+1, 0), i,0);
-
jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(i+1, 1), i,1);
-
jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(i+1, 2), i,2);
+ } else {
+ for (int i = 0; i < 19; i++) {
+
SMSTable.getModel().setValueAt(SMSTable.getModel().getValueAt(i + 1, 0), i,
0);
+
SMSTable.getModel().setValueAt(SMSTable.getModel().getValueAt(i + 1, 1), i,
1);
+
SMSTable.getModel().setValueAt(SMSTable.getModel().getValueAt(i + 1, 2), i,
2);
}
- jTable1.getModel().setValueAt(number, 19,0);
- jTable1.getModel().setValueAt(direction,19,1);
- jTable1.getModel().setValueAt(message, 19,2);
- jTable1.changeSelection(19, 0, false, false);
+ SMSTable.getModel().setValueAt(number, 19, 0);
+ SMSTable.getModel().setValueAt(direction, 19, 1);
+ SMSTable.getModel().setValueAt(message, 19, 2);
+ SMSTable.changeSelection(19, 0, false, false);
rowNumber++;
}
}
- public String getCommPort()
- {
+ public String getCommPort() {
return CommPorts.getSelectedItem().toString();
}
- public void setGatewayConnectionState(boolean state)
- {
+ public void setGatewayConnectionState(boolean state) {
this.isGatewayConnected = state;
- if(state)
- {
+ if (state) {
this.Connect.setText("Stop Connection");
- System.out.println("true");
- }
- else
- {
+ } else {
this.Connect.setText("Connect");
- System.out.println("false");
}
}
+ public JTable getSmsTable() {
+ return SMSTable;
+ }
+
-
}
Added: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.form
==============================================================================
--- (empty file)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.form Tue
Dec 16 08:26:59 2008
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7"
type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer"
value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName"
type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean"
value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode"
type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean"
value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget"
type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle"
type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean"
value="false"/>
+ <AuxValue name="FormSettings_variablesModifier"
type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="numberLabel" min="-2" max="-2"
attributes="1"/>
+ <EmptySpace type="separate" max="-2"
attributes="0"/>
+ <Group type="103" groupAlignment="0"
attributes="0">
+ <Component id="direction" alignment="0"
min="-2" max="-2" attributes="0"/>
+ <Component id="number" alignment="0"
pref="260" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="directionLabel" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace pref="286" max="32767"
attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="messageLabel" max="32767"
attributes="1"/>
+ <EmptySpace min="-2" pref="286" max="-2"
attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="messageScrollPanel" pref="322"
max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="closeButton" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="numberLabel" alignment="3" min="-2"
max="-2" attributes="0"/>
+ <Component id="number" alignment="3" min="-2" max="-2"
attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="directionLabel" alignment="3" min="-2"
max="-2" attributes="0"/>
+ <Component id="direction" alignment="3" min="-2"
max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="messageLabel" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="messageScrollPanel" min="-2" pref="82"
max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="closeButton" min="-2" max="-2"
attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="numberLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Number :"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="number">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="jLabel2"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="messageLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Message:"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="messageScrollPanel">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean"
value="true"/>
+ </AuxValues>
+
+ <Layout
class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea" name="messageTextArea">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="lineWrap" type="boolean" value="true"/>
+ <Property name="rows" type="int" value="5"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="closeButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Close"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="closeButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="directionLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Direction:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="direction">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="jLabel5"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
Added: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.java
==============================================================================
--- (empty file)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/gui/S2OMessagePopUp.java Tue
Dec 16 08:26:59 2008
@@ -0,0 +1,131 @@
+package pt.citar.diablu.sms2osc.gui;
+
+import javax.swing.JFrame;
+
+public class S2OMessagePopUp extends javax.swing.JFrame {
+
+ public S2OMessagePopUp() {
+ initComponents();
+ this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ }
+
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated
Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ numberLabel = new javax.swing.JLabel();
+ number = new javax.swing.JLabel();
+ messageLabel = new javax.swing.JLabel();
+ messageScrollPanel = new javax.swing.JScrollPane();
+ messageTextArea = new javax.swing.JTextArea();
+ closeButton = new javax.swing.JButton();
+ directionLabel = new javax.swing.JLabel();
+ direction = new javax.swing.JLabel();
+
+
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ numberLabel.setText("Number :");
+
+ number.setText("jLabel2");
+
+ messageLabel.setText("Message:");
+
+ messageTextArea.setColumns(20);
+ messageTextArea.setEditable(false);
+ messageTextArea.setLineWrap(true);
+ messageTextArea.setRows(5);
+ messageScrollPanel.setViewportView(messageTextArea);
+
+ closeButton.setText("Close");
+ closeButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ closeButtonActionPerformed(evt);
+ }
+ });
+
+ directionLabel.setText("Direction:");
+
+ direction.setText("jLabel5");
+
+ javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(numberLabel)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(direction)
+ .addComponent(number,
javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))
+ .addContainerGap())
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(directionLabel)
+ .addContainerGap(286, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(messageLabel,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addGap(286, 286, 286))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(messageScrollPanel,
javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
+ .addContainerGap()))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
+ .addComponent(closeButton)
+ .addContainerGap())))
+ );
+ layout.setVerticalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(numberLabel)
+ .addComponent(number))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(directionLabel)
+ .addComponent(direction))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(messageLabel)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(messageScrollPanel,
javax.swing.GroupLayout.PREFERRED_SIZE, 82,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(closeButton)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void closeButtonActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_closeButtonActionPerformed
+ this.setVisible(false);
+}//GEN-LAST:event_closeButtonActionPerformed
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton closeButton;
+ private javax.swing.JLabel direction;
+ private javax.swing.JLabel directionLabel;
+ private javax.swing.JLabel messageLabel;
+ private javax.swing.JScrollPane messageScrollPanel;
+ private javax.swing.JTextArea messageTextArea;
+ private javax.swing.JLabel number;
+ private javax.swing.JLabel numberLabel;
+ // End of variables declaration//GEN-END:variables
+
+ public void setDirection(String direction) {
+ if (direction == null) {
+ this.direction.setText("Unknown");
+ } else {
+ this.direction.setText(direction);
+ }
+ }
+
+ public void setNumber(String number) {
+ this.number.setText(number);
+ }
+
+ public void setMessage(String message) {
+ messageTextArea.setText(message);
+ }
+}
+
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscClient.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscClient.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscClient.java Tue Dec
16 08:26:59 2008
@@ -1,23 +1,18 @@
-
-
package pt.citar.diablu.sms2osc.osc;
-
import de.sciss.net.OSCClient;
import de.sciss.net.OSCMessage;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.util.logging.Level;
import pt.citar.diablu.sms2osc.S2O;
+public class S2OOscClient {
-public class S2OOscClient{
-
private OSCClient oscClient;
private S2O s2o;
-
-
- public S2OOscClient(S2O s2o)
- {
+
+ public S2OOscClient(S2O s2o) {
try {
this.s2o = s2o;
if (s2o.getProperties().useLoopback()) {
@@ -25,30 +20,28 @@
} else {
oscClient = OSCClient.newUsing(OSCClient.UDP);
}
-
+ s2o.getLogger().log(Level.INFO, "OSC Client Ready");
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
-
- public void send(OSCMessage oscMessage)
- {
+
+ public void send(OSCMessage oscMessage) {
String message = oscMessage.getName();
for (int i = 0; i < oscMessage.getArgCount(); i++) {
message += " " + oscMessage.getArg(i);
}
-
+
try {
InetSocketAddress isa = new
InetSocketAddress(s2o.getGui().getHostname(),
Integer.parseInt(s2o.getGui().getClientPort()));
oscClient.setTarget(isa);
oscClient.start();
oscClient.send(oscMessage);
oscClient.stop();
-
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent: " +
message);
+
} catch (IOException ex) {
- ex.printStackTrace();
-
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
-
-
}
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscListener.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscListener.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscListener.java Tue
Dec 16 08:26:59 2008
@@ -4,12 +4,9 @@
import de.sciss.net.OSCListener;
import de.sciss.net.OSCMessage;
import java.net.SocketAddress;
+import java.util.logging.Level;
import pt.citar.diablu.sms2osc.S2O;
-/**
- *
- * @author Raspa
- */
public class S2OOscListener implements OSCListener {
S2O s2o;
@@ -19,15 +16,15 @@
}
public void messageReceived(OSCMessage msg, SocketAddress sender, long
time) {
- System.out.println(msg.getName());
+ s2o.getLogger().log(Level.INFO, "OSC message received: " +
msg.getName());
if(msg.getName().compareTo("/diablu/sms2osc/sendsms") == 0)
sendSms(msg);
}
private void sendSms(OSCMessage msg)
{
- s2o.getBtConnection().sendMessage((String) msg.getArg(0), (String)
msg.getArg(1));
- System.out.println("sent message");
+ s2o.getBtConnection().sendMessage((String) msg.getArg(0), (String)
msg.getArg(1));
+
}
}
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscServer.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscServer.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/osc/S2OOscServer.java Tue Dec
16 08:26:59 2008
@@ -5,6 +5,7 @@
import de.sciss.net.OSCServer;
import java.io.IOException;
+import java.util.logging.Level;
import pt.citar.diablu.sms2osc.S2O;
@@ -30,13 +31,13 @@
oscServer.start();
connected = true;
s2o.getGui().serverButtonStop(connected);
- s2o.getProperties().setProperty("RemoteIP",
s2o.getGui().getHostname());
- s2o.getProperties().setProperty("IncomingPort",
s2o.getGui().getClientPort());
s2o.getProperties().setProperty("OutgoingPort",
s2o.getGui().getServerPort());
+ s2o.getLogger().log(Level.INFO, "OSC Server started on port "
+ s2o.getGui().getServerPort());
} catch (IOException ex) {
oscServer.dispose();
connected = false;
s2o.getGui().serverButtonStop(!connected);
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
@@ -49,6 +50,7 @@
s2o.getGui().serverButtonStop(connected);
break;
}
+ s2o.getLogger().log(Level.INFO, "OSC Server stopped");
}
public boolean isConnected() {
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/parser/S2OSMSParser.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/parser/S2OSMSParser.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/parser/S2OSMSParser.java Tue
Dec 16 08:26:59 2008
@@ -3,6 +3,7 @@
import de.sciss.net.OSCMessage;
import java.util.HashMap;
import java.util.StringTokenizer;
+import java.util.logging.Level;
import pt.citar.diablu.sms2osc.S2O;
public class S2OSMSParser {
@@ -28,7 +29,6 @@
String command;
while (st.hasMoreTokens()) {
command = st.nextToken();
-
System.out.println(s2o.getProperties().getCommandString(command));
commands.put(command,
s2o.getProperties().getCommandString(command));
}
}
@@ -48,22 +48,23 @@
if (value.length() == 0) {
if (!st.hasMoreTokens()) {
s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/" + command));
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/" + command);
} else {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError1", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/argumentsError" + msg);
}
} else {
for (int i = 0; i < value.length(); i++) {
- System.out.println("lsls");
if (st.hasMoreTokens()) {
c = value.charAt(i);
switch (c) {
case 'i': {
try {
arguments[i] =
Integer.parseInt(st.nextToken());
- System.out.println(arguments[i]);
break;
} catch (NumberFormatException ex) {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError2", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+ s2o.getLogger().log(Level.INFO, "OSC
Message Sent: /diablu/sms2osc/argumentsError" + msg);
return;
}
}
@@ -75,21 +76,21 @@
String decimal =
floatSt.nextToken();
f += Integer.parseInt(decimal) /
(Math.pow(10.0, decimal.length()));
arguments[i] = f;
- System.out.println(arguments[i]);
break;
}
} catch (NumberFormatException ex) {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError3", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+ s2o.getLogger().log(Level.INFO, "OSC
Message Sent: /diablu/sms2osc/argumentsError" + msg);
return;
}
}
case 'w': {
if (st.hasMoreTokens()) {
arguments[i] = st.nextToken();
- System.out.println(arguments[i]);
break;
} else {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError4", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+ s2o.getLogger().log(Level.INFO, "OSC
Message Sent: /diablu/sms2osc/argumentsError" + msg);
return;
}
}
@@ -105,7 +106,6 @@
}
}
arguments[i] = s;
- System.out.println(arguments[i]);
break;
}
case 'c': {
@@ -114,14 +114,15 @@
if (s.length() == 1) {
String l = "" + s.charAt(0);
arguments[i] = l;
- System.out.println(arguments[i]);
break;
} else {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError5", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+
s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/argumentsError" + msg);
return;
}
} else {
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandError", new Object[]{msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/argumentsError", new Object[]{msg}));
+ s2o.getLogger().log(Level.INFO, "OSC
Message Sent: /diablu/sms2osc/argumentsError" + msg);
return;
}
}
@@ -129,10 +130,11 @@
}
}
s2o.getOscClient().send(new OSCMessage("/diablu/sms2osc/"
+ command, arguments));
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/" + command + " " + msg.substring(command.length() + 1,
msg.length()));
}
} else {
- System.out.println("Command does not exist: " + command);
- s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandNotFounf", new Object[] {command, msg}));
+ s2o.getOscClient().send(new
OSCMessage("/diablu/sms2osc/commandNotFound", new Object[]{command}));
+ s2o.getLogger().log(Level.INFO, "OSC Message Sent:
/diablu/sms2osc/commandNotFound" + command);
}
}
}
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OCommPortList.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OCommPortList.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OCommPortList.java Tue
Dec 16 08:26:59 2008
@@ -5,27 +5,29 @@
import org.smslib.helper.CommPortIdentifier;
public class S2OCommPortList {
-
+
Vector<String> portList;
-
- public S2OCommPortList()
- {
+
+ public S2OCommPortList() {
portList = new Vector<String>();
Enumeration pList = CommPortIdentifier.getPortIdentifiers();
- while(pList.hasMoreElements())
-
portList.add(((CommPortIdentifier)pList.nextElement()).getName());
+ CommPortIdentifier commPort;
+ while (pList.hasMoreElements()) {
+ commPort = (CommPortIdentifier) pList.nextElement();
+ if (commPort.getPortType() == 1) {
+ portList.add(commPort.getName());
+ }
+ }
}
-
- public Vector<String> getCommPorts()
- {
+
+ public Vector<String> getCommPorts() {
return portList;
}
-
- public String getFirst()
- {
- if(portList.size() > 0)
+
+ public String getFirst() {
+ if (portList.size() > 0) {
return portList.elementAt(0);
+ }
return "";
}
-
}
Modified: trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OProperties.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OProperties.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OProperties.java Tue
Dec 16 08:26:59 2008
@@ -6,6 +6,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
+import java.util.logging.Level;
import pt.citar.diablu.sms2osc.S2O;
public class S2OProperties {
@@ -36,10 +37,12 @@
properties.store(fos, "SMS2OSC Configuration");
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} finally {
try {
fos.close();
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
} else {
@@ -47,68 +50,63 @@
fis = new FileInputStream(file);
properties.load(fis);
} catch (FileNotFoundException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} finally {
try {
fis.close();
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
}
}
-
- public String getRemoteIP()
- {
+
+ public String getRemoteIP() {
return properties.getProperty("RemoteIP", "127.0.0.1");
}
-
- public String getIncomingPort()
- {
+
+ public String getIncomingPort() {
return properties.getProperty("IncomingPort", "12000");
}
- public String getOutgoingPort()
- {
+ public String getOutgoingPort() {
return properties.getProperty("OutgoingPort", "12001");
}
-
- public String getGateway()
- {
+
+ public String getGateway() {
return properties.getProperty("Gateway", "sms2osc");
}
- public String getComPort()
- {
+ public String getComPort() {
return properties.getProperty("ComPort",
s2o.getCommPortList().getFirst());
}
-
- public boolean useLoopback()
- {
-
if(properties.getProperty("UseLoopback", "false").compareToIgnoreCase("true")
== 1)
+
+ public boolean useLoopback() {
+ if
(properties.getProperty("UseLoopback", "false").compareToIgnoreCase("true")
== 1) {
return true;
+ }
return false;
}
-
- public boolean useParser()
- {
-
if(properties.getProperty("UseParser", "false").compareToIgnoreCase("true")
== 0)
+
+ public boolean useParser() {
+ if
(properties.getProperty("UseParser", "false").compareToIgnoreCase("true")
== 0) {
return true;
+ }
return false;
}
-
- public String getCommands()
- {
+
+ public String getCommands() {
return properties.getProperty("Commands", "");
}
-
- public String getCommandString(String command)
- {
+
+ public String getCommandString(String command) {
return properties.getProperty(command, "");
}
- public void setProperty(String key, String value)
- {
+ public void setProperty(String key, String value) {
File file = new File("config.ini");
FileOutputStream fos = null;
@@ -118,21 +116,20 @@
properties.store(fos, "SMS2OSC Configuration");
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
} finally {
try {
fos.close();
} catch (IOException ex) {
+ s2o.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
}
- public String getBaudRate()
- {
+ public String getBaudRate() {
return properties.getProperty("BaudRate", "57600");
}
-
-
}
Added:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTableMouseAdapter.java
==============================================================================
--- (empty file)
+++
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTableMouseAdapter.java
Tue Dec 16 08:26:59 2008
@@ -0,0 +1,27 @@
+package pt.citar.diablu.sms2osc.util;
+
+import java.awt.Point;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import pt.citar.diablu.sms2osc.S2O;
+
+public class S2OTableMouseAdapter extends MouseAdapter {
+
+ S2O s2o;
+
+ public S2OTableMouseAdapter(S2O s2o) {
+ this.s2o = s2o;
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ Point p = e.getPoint();
+ int row = s2o.getGui().getSmsTable().rowAtPoint(p);
+ s2o.getMessagePopUp().setNumber((String)
s2o.getGui().getSmsTable().getValueAt(row, 0));
+ s2o.getMessagePopUp().setDirection((String)
s2o.getGui().getSmsTable().getValueAt(row, 1));
+ s2o.getMessagePopUp().setMessage((String)
s2o.getGui().getSmsTable().getValueAt(row, 2));
+ s2o.getMessagePopUp().setVisible(true);
+ }
+ }
+}
Modified:
trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTextAreaHandler.java
==============================================================================
--- trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTextAreaHandler.java
(original)
+++ trunk/SMS2OSC/src/pt/citar/diablu/sms2osc/util/S2OTextAreaHandler.java
Tue Dec 16 08:26:59 2008
@@ -6,14 +6,13 @@
import java.util.logging.LogRecord;
import javax.swing.JTextArea;
+public class S2OTextAreaHandler extends Handler {
-public class S2OTextAreaHandler extends Handler{
-
private static int MAXLOGS = 20;
private JTextArea textArea;
private Level level;
private Vector<LogRecord> logs;
-
+
public S2OTextAreaHandler(JTextArea textArea) {
this.textArea = textArea;
logs = new Vector<LogRecord>();
@@ -22,20 +21,21 @@
@Override
public void publish(LogRecord record) {
-
- if(logs.size() == MAXLOGS)
+
+ if (logs.size() == MAXLOGS) {
logs.remove(0);
- if(level.intValue() <= record.getLevel().intValue())
- {
+ }
+ if (level.intValue() <= record.getLevel().intValue()) {
textArea.setText("");
logs.add(record);
-
- for(int i = 0; i < logs.size(); i++)
- { if(i != 0)
+
+ for (int i = 0; i < logs.size(); i++) {
+ if (i != 0) {
textArea.append("\n");
+ }
textArea.append(logs.elementAt(i).getMessage());
textArea.setCaretPosition(textArea.getText().length());
- }
+ }
}
}
@@ -48,10 +48,9 @@
public void close() throws SecurityException {
throw new UnsupportedOperationException("Not supported yet.");
}
-
+
@Override
public void setLevel(Level level) {
this.level = level;
}
-
}