📄 testphone.java
字号:
package net.sourceforge.gjtapi.raw.emulator;
/*
Copyright (c) 2002 8x8 Inc. (www.8x8.com)
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
*/
import net.sourceforge.gjtapi.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.*;
import javax.telephony.*;
/**
* This is a simple implementation of RawPhone that provides a GUI interface.
* Currently simple calls may be made, received and disconnected.
* MVC is not currently implemented, but should be.
* Creation date: (2000-02-07 14:03:01)
* @author: Richard Deadman
*/
public class TestPhone extends JPanel implements PhoneListener, RawPhone {
class IvjEventHandler implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == TestPhone.this.getButton1())
connEtoC1();
if (e.getSource() == TestPhone.this.getButton2())
connEtoC2();
if (e.getSource() == TestPhone.this.getButton3())
connEtoC3();
if (e.getSource() == TestPhone.this.getButton4())
connEtoC4();
if (e.getSource() == TestPhone.this.getButton5())
connEtoC5();
if (e.getSource() == TestPhone.this.getButton6())
connEtoC6();
if (e.getSource() == TestPhone.this.getButton7())
connEtoC7();
if (e.getSource() == TestPhone.this.getButton8())
connEtoC8();
if (e.getSource() == TestPhone.this.getButton9())
connEtoC9();
if (e.getSource() == TestPhone.this.getButtonStar())
connEtoC10();
if (e.getSource() == TestPhone.this.getButton0())
connEtoC11();
if (e.getSource() == TestPhone.this.getButtonPound())
connEtoC12();
if (e.getSource() == TestPhone.this.getHookSwitch())
connEtoC13();
if (e.getSource() == TestPhone.this.getDialString())
connEtoC14();
if (e.getSource() == TestPhone.this.getDialButton())
connEtoC15();
if (e.getSource() == TestPhone.this.getHoldButton())
connEtoC16();
};
}
private JButton ivjButton0 = null;
private JButton ivjButton1 = null;
private JButton ivjButton2 = null;
private JButton ivjButton3 = null;
private JButton ivjButton4 = null;
private JButton ivjButton5 = null;
private JButton ivjButton6 = null;
private JButton ivjButton7 = null;
private JButton ivjButton8 = null;
private JButton ivjButton9 = null;
private JButton ivjButtonPound = null;
private JButton ivjButtonStar = null;
private JTextField ivjDialString = null;
IvjEventHandler ivjEventHandler = new IvjEventHandler();
private JToggleButton ivjHookSwitch = null;
private JTextField ivjStatusLine = null;
private JButton ivjDialButton = null;
private JLabel ivjPhoneLabel = null;
private PhoneManager manager = null;
private JButton ivjHoldButton = null;
private PhoneModel model;
public TestPhone(String addr, PhoneManager pm) {
super();
this.setManager(pm);
this.setModel(new PhoneModel(addr, this, this.getManager()));
initialize();
}
/**
* addLeg method comment.
*/
public boolean add(Leg leg) {
return this.getModel().add(leg);
// events?
}
/**
* Answer a ringing call
*/
public boolean answer() {
boolean result = this.getModel().answer();
if (result)
this.enable("Active", true, true, "Send");
return result;
}
/**
* Answer a ringing call
*/
public boolean answer(CallId id) {
boolean result = this.getModel().answer(id);
if (result)
this.enable("Active", true, true, "Send");
return result;
}
/**
* Append the given string to the undialed dial string
* Creation date: (2000-02-07 15:48:32)
* @author: Richard Deadman
*/
private void appendToDialString(String toBeDialed) {
if (this.getState() == RawPhone.IDLE)
return; // We don't allow digits when the phone is off-hook
javax.swing.text.Document d = this.getDialString().getDocument();
try {
d.insertString(d.getEndPosition().getOffset() - 1,toBeDialed, null);
} catch (javax.swing.text.BadLocationException ble) {
System.out.println("Bad Location: " + (d.getEndPosition().getOffset() - 1));
}
}
/**
* bridged method comment.
*/
public void bridged() {
this.enable("Bridged (ready to join)", true, true, "Send");
this.getHoldButton().setText("Join");
}
/**
* Dial 0
*/
public void button0_ActionEvents() {
this.appendToDialString("0");
return;
}
/**
* Send a 1 to the textField
*/
public void button1_ActionEvents() {
this.appendToDialString("1");
return;
}
/**
* Add 2...
*/
public void button2_ActionEvents() {
this.appendToDialString("2");
return;
}
/**
* Enter 3 as a dialed digit
*/
public void button3_ActionEvents() {
this.appendToDialString("3");
return;
}
/**
* Dial 4
*/
public void button4_ActionEvents() {
this.appendToDialString("4");
return;
}
/**
* Dial 5
*/
public void button5_ActionEvents() {
this.appendToDialString("5");
return;
}
/**
* Dial 6
*/
public void button6_ActionEvents() {
this.appendToDialString("6");
return;
}
/**
* Comment
*/
public void button7_ActionEvents() {
this.appendToDialString("7");
return;
}
/**
* Dial 8
*/
public void button8_ActionEvents() {
this.appendToDialString("8");
return;
}
/**
* Dial 9
*/
public void button9_ActionEvents() {
this.appendToDialString("9");
return;
}
/**
* Dial an octothorpe
*/
public void buttonPound_ActionEvents() {
this.appendToDialString("#");
return;
}
/**
* Dial an asterix
*/
public void buttonStar_ActionEvents() {
this.appendToDialString("*");
return;
}
/**
* I must have a Held and active call to conference.
*/
public boolean conference() {
boolean result = this.getModel().conference();
if (result) {
this.enable("Conference", true, true, "Send");
this.getHoldButton().setText("Hold");
} else
this.setStatus("Conference Failed");
return result;
}
/**
* The phone is now in an active call
*/
public void connected() {
this.enable("Active", true, true, "Send");
}
/**
* connEtoC1: (Button1.action. --> TestPhone.jButton1_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC1() {
try {
// user code begin {1}
// user code end
this.button1_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC10: (ButtonStar.action. --> TestPhone.buttonStar_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC10() {
try {
// user code begin {1}
// user code end
this.buttonStar_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC11: (Button0.action. --> TestPhone.button0_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC11() {
try {
// user code begin {1}
// user code end
this.button0_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC12: (ButtonPound.action. --> TestPhone.buttonPound_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC12() {
try {
// user code begin {1}
// user code end
this.buttonPound_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC13: (HookSwitch.action. --> TestPhone.hookSwitch_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC13() {
try {
// user code begin {1}
// user code end
this.hookSwitch_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC14: (DialString.action. --> TestPhone.dialString_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC14() {
try {
// user code begin {1}
// user code end
this.dialString_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC15: (DialButton.action. --> TestPhone.dialString_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC15() {
try {
// user code begin {1}
// user code end
this.dialString_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC16: (HoldButton.action. --> TestPhone.holdButton_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC16() {
try {
// user code begin {1}
// user code end
this.holdButton_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC2: (Button2.action. --> TestPhone.button2_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC2() {
try {
// user code begin {1}
// user code end
this.button2_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC3: (Button3.action. --> TestPhone.button3_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC3() {
try {
// user code begin {1}
// user code end
this.button3_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC4: (Button4.action. --> TestPhone.button4_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC4() {
try {
// user code begin {1}
// user code end
this.button4_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC5: (Button5.action. --> TestPhone.button5_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC5() {
try {
// user code begin {1}
// user code end
this.button5_ActionEvents();
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC6: (Button6.action. --> TestPhone.button6_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC6() {
try {
// user code begin {1}
// user code end
this.button6_ActionEvents();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -