📄 accreditdevsoisp.java
字号:
/*
* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
package vocal.userEditor;
import vocal.comm.VPPNoSuchFileException;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import java.util.Vector;
import java.io.IOException;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
* Presents the screen which allows the account data (feature configuration,
* user info, marshal info) for an end user to be edited. <p>
* It lays out a series of panels which implement the DataEditor interface to
* actually perform data input, display and validation.<p>
* This class is used both from the StandAloneUserEditor when and end user edits
* his own account and from the Editor when an administrator manages end user
* accounts. When used from StandAloneUserEditor, setShowAdmin(false) is called
* and all DataEditors are notified to remove fileds which should only be
* accessible to an administrator, not the end user.<p>
*/
public class AccreditDevsOisp extends JPanel implements Buttons, EditorModes,
WindowListener
{
private int mode = ADD_NEW_MODE;
private JPanel buttonPanel;
private JButton ok;
private JButton cancel;
private JButton changePassword;
private UserInfo userInfo;
private int lastButtonClicked = BUTTON_NONE;
private JDialog passwordScreen = null;
private PasswordPanel passwordPanel;
private String userName;
private AliasPanel aliases;
private IdentityInfo identity;
private MarshalInfo marshal;
private FeatureCallReturn callReturn;
private boolean showAdmin = false;
private boolean showUser = true;
private AccreditDevsOisp()
{
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(new EmptyBorder(5, 5, 5, 5));
}
public AccreditDevsOisp(final PServerInterface psInterface)
throws IOException, VPPNoSuchFileException
{
this();
passwordPanel = new PasswordPanel(psInterface.getConnection());
userInfo = new UserInfo();
add(userInfo);
aliases = new AliasPanel(psInterface);
add(aliases);
try
{
identity = new IdentityInfo(psInterface.getMarshalGroups());
add(identity);
}
catch (SAXException e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(this.getTopLevelAncestor(),
"Could not get list of marshal groups because:\n\n" + e);
}
try
{
marshal = new MarshalInfo(psInterface.getMarshalGroups());
add(marshal);
}
catch (SAXException e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(this.getTopLevelAncestor(),
"Could not get list of marshal groups because:\n\n" + e);
}
/*
try
{
String[] featureTypes = psInterface.getFeatureTypes();
for (int i = 0; i < featureTypes.length; i++)
{
if (featureTypes[i].equals("ForwardAllCalls")
|| featureTypes[i].equals("ForwardNoAnswerBusy")
|| featureTypes[i].equals("CallBlocking")
|| featureTypes[i].equals("CallScreening")
|| featureTypes[i].equals("CallReturn")
|| featureTypes[i].equals("CallerIdBlocking"))
{
String[] groupNames = psInterface.getFeatureGroups(featureTypes[i]);
Feature panel = Feature.createFeature(featureTypes[i], groupNames,
psInterface);
if (FeatureCallReturn.class.isInstance(panel))
{
callReturn = (FeatureCallReturn) panel;
}
else
{
add(panel);
}
}
}
if (callReturn != null)
{
add(callReturn);
}
}
catch (SAXException e)
{
throw new IOException("Could not load list of feature types because: \n"
+ e);
}
*/
ok = new JButton("Ok");
// tool tip gets hidden by frame, so leaving it out
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (isAllDataValid())
{
lastButtonClicked = UserPanel.BUTTON_OK;
// get the frame which contains this panel and hide it
AccreditDevsOisp.this.getTopLevelAncestor().setVisible(false);
}
}
});
cancel = new JButton("Cancel");
// tool tip gets hidden by frame, so leaving it out
cancel.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
lastButtonClicked = UserPanel.BUTTON_CANCEL;
// get the frame which contains this panel and hide it
AccreditDevsOisp.this.getTopLevelAncestor().setVisible(false);
}
});
/*
changePassword = new JButton("Change Password");
changePassword.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (passwordScreen == null)
{
Container parent = UserPanel.this.getTopLevelAncestor();
if (JDialog.class.isInstance(parent))
{
passwordScreen = new JDialog((JDialog) parent, "Change password",
false);
}
else if (JFrame.class.isInstance(parent))
{
passwordScreen = new JDialog((JFrame) parent, "Change password",
false);
}
passwordScreen.setContentPane(passwordPanel);
passwordScreen.pack();
passwordScreen.setModal(true);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
passwordScreen.setLocation((d.width - passwordScreen.getSize().width)
/ 2, (d.height - passwordScreen.getSize().height) / 2);
}
passwordPanel.setUserId(userName);
passwordScreen.setVisible(true);
}
});
*/
buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
//buttonPanel.add(changePassword);
buttonPanel.add(Box.createHorizontalGlue());
buttonPanel.add(ok);
buttonPanel.add(Box.createHorizontalStrut(5));
buttonPanel.add(cancel);
add(buttonPanel);
setMode(this.EDIT_EXISTING_MODE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -