Tutorials - Basic CSTA Application
From Open CSTA
- This tutorial started 7 January 2009.
Contents |
Create Netbeans Desktop Application
- Create a Basic Desktop Application, making the buttons, text fields and other GUI elements you would like to put into it.
My HandyCSTATestTool for this looks something like the thumbnail on the right.
Add CSTA Application interface
- A netbeans Desktop Application has a XXXXXXView class (the GUI elements) and an XXXXXXApp class. The App class needs to implement a CSTAApplication.
public class HandyCSTATestToolApp extends SingleFrameApplication implements CSTAApplication{
CSTAApplication is in the org.opencsta.apps.objects package.
Implement interface methods
- A CSTAApplication must implement 3 methods to handle events: call events, agent events, telephone data service events.
public void CSTACallEventReceived(CallEvent event){
}
public void CSTAAgentEventReceived(AgentEvent event){
}
public void TDSDataReceived(String dev, String code, String data){
}
- Fix the imports
import org.opencsta.apps.objects.CSTAApplication; import org.opencsta.servicedescription.common.AgentEvent; import org.opencsta.servicedescription.common.CallEvent;
CSTA Logic
- Declare the CSTAFunctions variable, still in the App class.
private static CSTAFunctions csta;
- Create the object before showing the GUI
@Override protected void startup() { //this line is provided by the IDE
csta = new CSTAClient3000() ; //THIS LINE WAS INSERTED BY US
show(new HandyCSTATestToolView(this)); //this line is provided by the IDE
} //this line is provided by the IDE
- Create a getter method so the GUI elements can call the CSTA functions
public static CSTAFunctions getCSTA() {
return csta;
}
Make Call Button
- In Design mode, double click the make call button to create a function.
- Get a handle on the CSTA functions object from the app
- Get the from textfield text value
- Get the to textfield text value
- MakeCall( from, to )
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//make call
HandyCSTATestToolApp.getApplication().getCSTA().MakeCall(this.jTextField1.getText(),this.jTextField2.getText() ) ;
}
