Пример создания своего интерфейса в клиенте
Материал из BiTel WiKi
Lda (Обсуждение | вклад) |
Lda (Обсуждение | вклад) |
||
| Строка 18: | Строка 18: | ||
== Создание библиотеки для клиента == | == Создание библиотеки для клиента == | ||
| + | Срабатывает при выборе пункта меню "Мой Модуль". | ||
<pre> | <pre> | ||
/* | /* | ||
| Строка 37: | Строка 38: | ||
ShellFrame.getFrame().getTabbedPane().addTab(new Manager()); | ShellFrame.getFrame().getTabbedPane().addTab(new Manager()); | ||
} | } | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Создает окошко и вставляет в него 2 таба. | ||
| + | <pre> | ||
| + | /* | ||
| + | * To change this template, choose Tools | Templates | ||
| + | * and open the template in the editor. | ||
| + | */ | ||
| + | package ru.lda.billing.client.myModule; | ||
| + | |||
| + | import bitel.billing.ShellFrame; | ||
| + | import bitel.billing.module.common.BGTabPanel; | ||
| + | import java.awt.GridBagConstraints; | ||
| + | import java.awt.GridBagLayout; | ||
| + | import java.awt.Insets; | ||
| + | import javax.swing.JTabbedPane; | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * @author lda | ||
| + | */ | ||
| + | public class Manager extends BGTabPanel{ | ||
| + | private JTabbedPane tabbed = new JTabbedPane(); | ||
| + | private Export ex; | ||
| + | private Import imp; | ||
| + | public Manager() | ||
| + | { | ||
| + | super("myModule", "Мой модуль"); | ||
| + | this.parentFrame = ShellFrame.getFrame(); | ||
| + | this.module = "myModule.manager"; | ||
| + | this.ex = new Export(); | ||
| + | this.imp = new Import(); | ||
| + | try{ | ||
| + | jbInit(); | ||
| + | }catch (Exception ex){ | ||
| + | ex.printStackTrace(); | ||
| + | } | ||
| + | } | ||
| + | private void jbInit() throws Exception{ | ||
| + | |||
| + | this.tabbed.addTab("Вызрузка данных", this.ex); | ||
| + | this.tabbed.addTab("Загрузка данных", this.imp); | ||
| + | setLayout(new GridBagLayout()); | ||
| + | add(this.tabbed, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | } | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Таб для выгрузки данных. При нажатии на кнопку "запуск" вызывается экшен на сервере bitel.billing.server.myModule.action.ActionExport. | ||
| + | <pre> | ||
| + | /* | ||
| + | * To change this template, choose Tools | Templates | ||
| + | * and open the template in the editor. | ||
| + | */ | ||
| + | package ru.lda.billing.client.myModule; | ||
| + | |||
| + | import bitel.billing.module.admin.TransferManager; | ||
| + | import bitel.billing.module.common.BGComboBox; | ||
| + | import bitel.billing.module.common.BGControlPanelMonth; | ||
| + | import bitel.billing.module.common.BGTitleBorder; | ||
| + | import bitel.billing.module.common.ComboBoxItem; | ||
| + | import bitel.billing.module.common.Request; | ||
| + | import java.awt.Component; | ||
| + | import java.awt.Dimension; | ||
| + | import java.awt.GridBagConstraints; | ||
| + | import java.awt.GridBagLayout; | ||
| + | import java.awt.Insets; | ||
| + | import java.awt.event.ActionEvent; | ||
| + | import java.awt.event.ActionListener; | ||
| + | import javax.swing.Box; | ||
| + | import javax.swing.DefaultComboBoxModel; | ||
| + | import javax.swing.JButton; | ||
| + | import javax.swing.JLabel; | ||
| + | import javax.swing.JOptionPane; | ||
| + | import javax.swing.JPanel; | ||
| + | import javax.swing.JTextField; | ||
| + | import org.w3c.dom.Document; | ||
| + | import ru.bitel.bgbilling.client.common.BGUPanel; | ||
| + | import ru.bitel.bgbilling.client.util.ClientUtils; | ||
| + | import ru.bitel.common.Utils; | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * @author lda | ||
| + | */ | ||
| + | public class Export extends BGUPanel{ | ||
| + | private BGControlPanelMonth period_P = new BGControlPanelMonth(); | ||
| + | private JTextField protoEmail_TF = new JTextField(); | ||
| + | private String module = "myModule.Export"; | ||
| + | private BGComboBox TypeCombo = new BGComboBox(); | ||
| + | public Export() { | ||
| + | } | ||
| + | protected void jbInit(){ | ||
| + | JPanel jPanel1 = new JPanel(); | ||
| + | BGTitleBorder bGTitleBorder1 = new BGTitleBorder(); | ||
| + | BGTitleBorder bGTitleBorder4 = new BGTitleBorder(); | ||
| + | BGTitleBorder bGTitleBorder5 = new BGTitleBorder(); | ||
| + | |||
| + | DefaultComboBoxModel model = new DefaultComboBoxModel(); | ||
| + | |||
| + | model.addElement(new ComboBoxItem("1", "Подготовить реестр документов")); | ||
| + | model.addElement(new ComboBoxItem("2", "Выгрузить реестр документов")); | ||
| + | model.addElement(new ComboBoxItem("3", "Очистить реестр документов")); | ||
| + | |||
| + | TypeCombo.setModel(model); | ||
| + | |||
| + | JPanel jPanel2 = new JPanel(); | ||
| + | |||
| + | JPanel jPanel3 = new JPanel(); | ||
| + | |||
| + | JLabel jLabel1 = new JLabel(); | ||
| + | |||
| + | JButton jButton1 = new JButton(); | ||
| + | |||
| + | Component component1 = Box.createHorizontalStrut(8); | ||
| + | Component component2 = Box.createGlue(); | ||
| + | setLayout(new GridBagLayout()); | ||
| + | bGTitleBorder1.setTitle(" Месяц "); | ||
| + | jPanel1.setLayout(new GridBagLayout()); | ||
| + | bGTitleBorder4.setTitleName(" Пуск "); | ||
| + | bGTitleBorder5.setTitleName(" Тип "); | ||
| + | jPanel2.setBorder(bGTitleBorder5); | ||
| + | jPanel2.setLayout(new GridBagLayout()); | ||
| + | jPanel2.add(TypeCombo, new GridBagConstraints(0, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 5, 5, 5), 0, 0)); | ||
| + | jPanel3.setBorder(bGTitleBorder4); | ||
| + | jPanel3.setLayout(new GridBagLayout()); | ||
| + | jLabel1.setText("Выслать протокол на:"); | ||
| + | this.protoEmail_TF.setMaximumSize(new Dimension(2147483647, 2147483647)); | ||
| + | this.protoEmail_TF.setMinimumSize(new Dimension(4, 24)); | ||
| + | this.protoEmail_TF.setPreferredSize(new Dimension(200, 24)); | ||
| + | this.protoEmail_TF.setToolTipText(""); | ||
| + | this.protoEmail_TF.setText(""); | ||
| + | |||
| + | jButton1.setText("Запуск"); | ||
| + | jButton1.addActionListener(new ActionListener(){ | ||
| + | public void actionPerformed(ActionEvent e){ | ||
| + | saveUserEmail(module, protoEmail_TF.getText().trim()); | ||
| + | sendRequest(); | ||
| + | } | ||
| + | }); | ||
| + | jPanel1.setBorder(null); | ||
| + | this.period_P.setBorder(bGTitleBorder1); | ||
| + | this.period_P.setDebugGraphicsOptions(0); | ||
| + | jPanel3.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 17, 0, new Insets(0, 5, 5, 0), 0, 0)); | ||
| + | jPanel3.add(jButton1, new GridBagConstraints(3, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 0, 5, 5), 0, 0)); | ||
| + | jPanel3.add(component1, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(component2, new GridBagConstraints(1, 1, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | jPanel3.add(this.protoEmail_TF, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 6, 5, 0), 0, 0)); | ||
| + | jPanel1.add(this.period_P, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel3, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel2, new GridBagConstraints(1, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 11, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | setData(); | ||
| + | } | ||
| + | public void setData(){ | ||
| + | this.protoEmail_TF.setText(getUserEmail(this.module)); | ||
| + | } | ||
| + | private void sendRequest(){ | ||
| + | Request request = new Request(); | ||
| + | request.setModule("myModule"); | ||
| + | request.setAction("Export"); | ||
| + | |||
| + | String email = protoEmail_TF.getText(); | ||
| + | request.setAttribute("mail", email); | ||
| + | request.setAttribute("type", ClientUtils.getIdFromComboBox(TypeCombo)); | ||
| + | request.setAttribute("date", ((BGControlPanelMonth)period_P).getDateString()); | ||
| + | |||
| + | if (Utils.isBlankString(email)){ | ||
| + | JOptionPane.showMessageDialog(this, "Укажите почтовый ящик!", "Ошибка", 0); | ||
| + | return; | ||
| + | } | ||
| + | Document doc = TransferManager.getDocument(request); | ||
| + | if (ClientUtils.checkStatus(this, doc)){ | ||
| + | JOptionPane.showMessageDialog(this, "Задача запущена, результат будет \nотправлен на указанный EMail", "Задача запущена", 1); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Таб для загрузки данных. При нажатии на кнопку "запуск" вызывается экшен на сервере bitel.billing.server.myModule.action.ActionImport. | ||
| + | <pre> | ||
| + | /* | ||
| + | * To change this template, choose Tools | Templates | ||
| + | * and open the template in the editor. | ||
| + | */ | ||
| + | package ru.lda.billing.client.myModule; | ||
| + | |||
| + | import bitel.billing.module.admin.TransferManager; | ||
| + | import bitel.billing.module.common.BGComboBox; | ||
| + | import bitel.billing.module.common.BGControlPanelMonth; | ||
| + | import bitel.billing.module.common.BGTitleBorder; | ||
| + | import bitel.billing.module.common.ComboBoxItem; | ||
| + | import bitel.billing.module.common.Request; | ||
| + | import java.awt.Component; | ||
| + | import java.awt.Dimension; | ||
| + | import java.awt.GridBagConstraints; | ||
| + | import java.awt.GridBagLayout; | ||
| + | import java.awt.Insets; | ||
| + | import java.awt.event.ActionEvent; | ||
| + | import java.awt.event.ActionListener; | ||
| + | import javax.swing.Box; | ||
| + | import javax.swing.DefaultComboBoxModel; | ||
| + | import javax.swing.JButton; | ||
| + | import javax.swing.JLabel; | ||
| + | import javax.swing.JOptionPane; | ||
| + | import javax.swing.JPanel; | ||
| + | import javax.swing.JTextField; | ||
| + | import org.w3c.dom.Document; | ||
| + | import ru.bitel.bgbilling.client.common.BGUPanel; | ||
| + | import ru.bitel.bgbilling.client.util.ClientUtils; | ||
| + | import ru.bitel.common.Utils; | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * @author lda | ||
| + | */ | ||
| + | public class Import extends BGUPanel{ | ||
| + | private BGControlPanelMonth period_P = new BGControlPanelMonth(); | ||
| + | private JTextField protoEmail_TF = new JTextField(); | ||
| + | private String module = "myModule.Import"; | ||
| + | private BGComboBox TypeCombo = new BGComboBox(); | ||
| + | public Import() { | ||
| + | } | ||
| + | protected void jbInit(){ | ||
| + | JPanel jPanel1 = new JPanel(); | ||
| + | BGTitleBorder bGTitleBorder1 = new BGTitleBorder(); | ||
| + | BGTitleBorder bGTitleBorder4 = new BGTitleBorder(); | ||
| + | |||
| + | BGTitleBorder bGTitleBorder5 = new BGTitleBorder(); | ||
| + | |||
| + | DefaultComboBoxModel model = new DefaultComboBoxModel(); | ||
| + | |||
| + | model.addElement(new ComboBoxItem("1", "Загрузить данных")); | ||
| + | |||
| + | TypeCombo.setModel(model); | ||
| + | |||
| + | JPanel jPanel2 = new JPanel(); | ||
| + | |||
| + | JPanel jPanel3 = new JPanel(); | ||
| + | |||
| + | JLabel jLabel1 = new JLabel(); | ||
| + | |||
| + | JButton jButton1 = new JButton(); | ||
| + | |||
| + | Component component1 = Box.createHorizontalStrut(8); | ||
| + | Component component2 = Box.createGlue(); | ||
| + | setLayout(new GridBagLayout()); | ||
| + | bGTitleBorder1.setTitle(" Месяц "); | ||
| + | jPanel1.setLayout(new GridBagLayout()); | ||
| + | bGTitleBorder4.setTitleName(" Пуск "); | ||
| + | bGTitleBorder5.setTitleName(" Тип "); | ||
| + | jPanel2.setBorder(bGTitleBorder5); | ||
| + | jPanel2.setLayout(new GridBagLayout()); | ||
| + | jPanel2.add(TypeCombo, new GridBagConstraints(0, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 5, 5, 5), 0, 0)); | ||
| + | jPanel3.setBorder(bGTitleBorder4); | ||
| + | jPanel3.setLayout(new GridBagLayout()); | ||
| + | jLabel1.setText("Выслать протокол на:"); | ||
| + | this.protoEmail_TF.setMaximumSize(new Dimension(2147483647, 2147483647)); | ||
| + | this.protoEmail_TF.setMinimumSize(new Dimension(4, 24)); | ||
| + | this.protoEmail_TF.setPreferredSize(new Dimension(200, 24)); | ||
| + | this.protoEmail_TF.setToolTipText(""); | ||
| + | this.protoEmail_TF.setText(""); | ||
| + | |||
| + | jButton1.setText("Запуск"); | ||
| + | jButton1.addActionListener(new ActionListener(){ | ||
| + | public void actionPerformed(ActionEvent e){ | ||
| + | saveUserEmail(module, protoEmail_TF.getText().trim()); | ||
| + | sendRequest(); | ||
| + | } | ||
| + | }); | ||
| + | jPanel1.setBorder(null); | ||
| + | this.period_P.setBorder(bGTitleBorder1); | ||
| + | this.period_P.setDebugGraphicsOptions(0); | ||
| + | jPanel3.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 17, 0, new Insets(0, 5, 5, 0), 0, 0)); | ||
| + | jPanel3.add(jButton1, new GridBagConstraints(3, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 0, 5, 5), 0, 0)); | ||
| + | jPanel3.add(component1, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(component2, new GridBagConstraints(1, 1, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | jPanel3.add(this.protoEmail_TF, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 6, 5, 0), 0, 0)); | ||
| + | jPanel1.add(this.period_P, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel3, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel2, new GridBagConstraints(1, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 11, 1, new Insets(0, 0, 0, 0), 0, 0)); | ||
| + | setData(); | ||
| + | } | ||
| + | public void setData(){ | ||
| + | this.protoEmail_TF.setText(getUserEmail(this.module)); | ||
| + | } | ||
| + | private void sendRequest(){ | ||
| + | Request request = new Request(); | ||
| + | request.setModule("myModule"); | ||
| + | request.setAction("Import"); | ||
| + | |||
| + | String email = protoEmail_TF.getText(); | ||
| + | request.setAttribute("mail", email); | ||
| + | request.setAttribute("type", ClientUtils.getIdFromComboBox(TypeCombo)); | ||
| + | request.setAttribute("date", ((BGControlPanelMonth)period_P).getDateString()); | ||
| + | |||
| + | if (Utils.isBlankString(email)){ | ||
| + | JOptionPane.showMessageDialog(this, "Укажите почтовый ящик!", "Ошибка", 0); | ||
| + | return; | ||
| + | } | ||
| + | Document doc = TransferManager.getDocument(request); | ||
| + | if (ClientUtils.checkStatus(this, doc)){ | ||
| + | JOptionPane.showMessageDialog(this, "Задача запущена, результат будет \nотправлен на указанный EMail", "Задача запущена", 1); | ||
| + | } | ||
| + | } | ||
} | } | ||
</pre> | </pre> | ||
Версия 09:30, 14 марта 2013
Пример создания своего интерфейса в клиенте
Введение
Рассажу как сделать свой интерфейс в клиенте биллинга на примере создания заготовки для обмена с некой сторонней абстрактной системой.
Задача стоит так. В клиенте должны быть: менюшка для выбора месаца, типа обмена, строка для указания почтового ящика (для уведомления о результате обмена) и кнопочки "Запуск". Выгрузка и загрузка данных должны быть разделены. При нажатии на кнопку "Запуск" вызывается экшен на сервере.
Редактируем data/menu.xml
в раздел "Договор" добавляем:
<menuItem id="myModule" className="ru.lda.billing.client.myModule.Action" title="Мой Модуль"/>
После этого в меню клиента появится новый пункт "Мой Модуль".
Создание библиотеки для клиента
Срабатывает при выборе пункта меню "Мой Модуль".
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ru.lda.billing.client.myModule;
import bitel.billing.ShellFrame;
import bitel.billing.module.common.BillingAction;
import javax.swing.JFrame;
/**
*
* @author lda
*/
public class Action implements BillingAction{
public void doAction(JFrame frame, String key){
ShellFrame.getFrame().getTabbedPane().addTab(new Manager());
}
}
Создает окошко и вставляет в него 2 таба.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ru.lda.billing.client.myModule;
import bitel.billing.ShellFrame;
import bitel.billing.module.common.BGTabPanel;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JTabbedPane;
/**
*
* @author lda
*/
public class Manager extends BGTabPanel{
private JTabbedPane tabbed = new JTabbedPane();
private Export ex;
private Import imp;
public Manager()
{
super("myModule", "Мой модуль");
this.parentFrame = ShellFrame.getFrame();
this.module = "myModule.manager";
this.ex = new Export();
this.imp = new Import();
try{
jbInit();
}catch (Exception ex){
ex.printStackTrace();
}
}
private void jbInit() throws Exception{
this.tabbed.addTab("Вызрузка данных", this.ex);
this.tabbed.addTab("Загрузка данных", this.imp);
setLayout(new GridBagLayout());
add(this.tabbed, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
}
}
Таб для выгрузки данных. При нажатии на кнопку "запуск" вызывается экшен на сервере bitel.billing.server.myModule.action.ActionExport.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ru.lda.billing.client.myModule;
import bitel.billing.module.admin.TransferManager;
import bitel.billing.module.common.BGComboBox;
import bitel.billing.module.common.BGControlPanelMonth;
import bitel.billing.module.common.BGTitleBorder;
import bitel.billing.module.common.ComboBoxItem;
import bitel.billing.module.common.Request;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.w3c.dom.Document;
import ru.bitel.bgbilling.client.common.BGUPanel;
import ru.bitel.bgbilling.client.util.ClientUtils;
import ru.bitel.common.Utils;
/**
*
* @author lda
*/
public class Export extends BGUPanel{
private BGControlPanelMonth period_P = new BGControlPanelMonth();
private JTextField protoEmail_TF = new JTextField();
private String module = "myModule.Export";
private BGComboBox TypeCombo = new BGComboBox();
public Export() {
}
protected void jbInit(){
JPanel jPanel1 = new JPanel();
BGTitleBorder bGTitleBorder1 = new BGTitleBorder();
BGTitleBorder bGTitleBorder4 = new BGTitleBorder();
BGTitleBorder bGTitleBorder5 = new BGTitleBorder();
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement(new ComboBoxItem("1", "Подготовить реестр документов"));
model.addElement(new ComboBoxItem("2", "Выгрузить реестр документов"));
model.addElement(new ComboBoxItem("3", "Очистить реестр документов"));
TypeCombo.setModel(model);
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
Component component1 = Box.createHorizontalStrut(8);
Component component2 = Box.createGlue();
setLayout(new GridBagLayout());
bGTitleBorder1.setTitle(" Месяц ");
jPanel1.setLayout(new GridBagLayout());
bGTitleBorder4.setTitleName(" Пуск ");
bGTitleBorder5.setTitleName(" Тип ");
jPanel2.setBorder(bGTitleBorder5);
jPanel2.setLayout(new GridBagLayout());
jPanel2.add(TypeCombo, new GridBagConstraints(0, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 5, 5, 5), 0, 0));
jPanel3.setBorder(bGTitleBorder4);
jPanel3.setLayout(new GridBagLayout());
jLabel1.setText("Выслать протокол на:");
this.protoEmail_TF.setMaximumSize(new Dimension(2147483647, 2147483647));
this.protoEmail_TF.setMinimumSize(new Dimension(4, 24));
this.protoEmail_TF.setPreferredSize(new Dimension(200, 24));
this.protoEmail_TF.setToolTipText("");
this.protoEmail_TF.setText("");
jButton1.setText("Запуск");
jButton1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
saveUserEmail(module, protoEmail_TF.getText().trim());
sendRequest();
}
});
jPanel1.setBorder(null);
this.period_P.setBorder(bGTitleBorder1);
this.period_P.setDebugGraphicsOptions(0);
jPanel3.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 17, 0, new Insets(0, 5, 5, 0), 0, 0));
jPanel3.add(jButton1, new GridBagConstraints(3, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 0, 5, 5), 0, 0));
jPanel3.add(component1, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
add(component2, new GridBagConstraints(1, 1, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
jPanel3.add(this.protoEmail_TF, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 6, 5, 0), 0, 0));
jPanel1.add(this.period_P, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel3, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel2, new GridBagConstraints(1, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 11, 1, new Insets(0, 0, 0, 0), 0, 0));
setData();
}
public void setData(){
this.protoEmail_TF.setText(getUserEmail(this.module));
}
private void sendRequest(){
Request request = new Request();
request.setModule("myModule");
request.setAction("Export");
String email = protoEmail_TF.getText();
request.setAttribute("mail", email);
request.setAttribute("type", ClientUtils.getIdFromComboBox(TypeCombo));
request.setAttribute("date", ((BGControlPanelMonth)period_P).getDateString());
if (Utils.isBlankString(email)){
JOptionPane.showMessageDialog(this, "Укажите почтовый ящик!", "Ошибка", 0);
return;
}
Document doc = TransferManager.getDocument(request);
if (ClientUtils.checkStatus(this, doc)){
JOptionPane.showMessageDialog(this, "Задача запущена, результат будет \nотправлен на указанный EMail", "Задача запущена", 1);
}
}
}
Таб для загрузки данных. При нажатии на кнопку "запуск" вызывается экшен на сервере bitel.billing.server.myModule.action.ActionImport.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ru.lda.billing.client.myModule;
import bitel.billing.module.admin.TransferManager;
import bitel.billing.module.common.BGComboBox;
import bitel.billing.module.common.BGControlPanelMonth;
import bitel.billing.module.common.BGTitleBorder;
import bitel.billing.module.common.ComboBoxItem;
import bitel.billing.module.common.Request;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.w3c.dom.Document;
import ru.bitel.bgbilling.client.common.BGUPanel;
import ru.bitel.bgbilling.client.util.ClientUtils;
import ru.bitel.common.Utils;
/**
*
* @author lda
*/
public class Import extends BGUPanel{
private BGControlPanelMonth period_P = new BGControlPanelMonth();
private JTextField protoEmail_TF = new JTextField();
private String module = "myModule.Import";
private BGComboBox TypeCombo = new BGComboBox();
public Import() {
}
protected void jbInit(){
JPanel jPanel1 = new JPanel();
BGTitleBorder bGTitleBorder1 = new BGTitleBorder();
BGTitleBorder bGTitleBorder4 = new BGTitleBorder();
BGTitleBorder bGTitleBorder5 = new BGTitleBorder();
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement(new ComboBoxItem("1", "Загрузить данных"));
TypeCombo.setModel(model);
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
Component component1 = Box.createHorizontalStrut(8);
Component component2 = Box.createGlue();
setLayout(new GridBagLayout());
bGTitleBorder1.setTitle(" Месяц ");
jPanel1.setLayout(new GridBagLayout());
bGTitleBorder4.setTitleName(" Пуск ");
bGTitleBorder5.setTitleName(" Тип ");
jPanel2.setBorder(bGTitleBorder5);
jPanel2.setLayout(new GridBagLayout());
jPanel2.add(TypeCombo, new GridBagConstraints(0, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 5, 5, 5), 0, 0));
jPanel3.setBorder(bGTitleBorder4);
jPanel3.setLayout(new GridBagLayout());
jLabel1.setText("Выслать протокол на:");
this.protoEmail_TF.setMaximumSize(new Dimension(2147483647, 2147483647));
this.protoEmail_TF.setMinimumSize(new Dimension(4, 24));
this.protoEmail_TF.setPreferredSize(new Dimension(200, 24));
this.protoEmail_TF.setToolTipText("");
this.protoEmail_TF.setText("");
jButton1.setText("Запуск");
jButton1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
saveUserEmail(module, protoEmail_TF.getText().trim());
sendRequest();
}
});
jPanel1.setBorder(null);
this.period_P.setBorder(bGTitleBorder1);
this.period_P.setDebugGraphicsOptions(0);
jPanel3.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 17, 0, new Insets(0, 5, 5, 0), 0, 0));
jPanel3.add(jButton1, new GridBagConstraints(3, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 0, 5, 5), 0, 0));
jPanel3.add(component1, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
add(component2, new GridBagConstraints(1, 1, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
jPanel3.add(this.protoEmail_TF, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(0, 6, 5, 0), 0, 0));
jPanel1.add(this.period_P, new GridBagConstraints(0, 0, 1, 1, 1.0D, 1.0D, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel3, new GridBagConstraints(2, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel2, new GridBagConstraints(1, 0, 1, 1, 1.0D, 0.0D, 11, 2, new Insets(0, 0, 0, 0), 0, 0));
add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 11, 1, new Insets(0, 0, 0, 0), 0, 0));
setData();
}
public void setData(){
this.protoEmail_TF.setText(getUserEmail(this.module));
}
private void sendRequest(){
Request request = new Request();
request.setModule("myModule");
request.setAction("Import");
String email = protoEmail_TF.getText();
request.setAttribute("mail", email);
request.setAttribute("type", ClientUtils.getIdFromComboBox(TypeCombo));
request.setAttribute("date", ((BGControlPanelMonth)period_P).getDateString());
if (Utils.isBlankString(email)){
JOptionPane.showMessageDialog(this, "Укажите почтовый ящик!", "Ошибка", 0);
return;
}
Document doc = TransferManager.getDocument(request);
if (ClientUtils.checkStatus(this, doc)){
JOptionPane.showMessageDialog(this, "Задача запущена, результат будет \nотправлен на указанный EMail", "Задача запущена", 1);
}
}
}
