/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.netsysit.view;
import de.netsysit.controller.ActionFactory;
import de.netsysit.controller.ActionFactory.ActionKey;
import de.netsysit.controller.ApplicationController;
import de.netsysit.policymanager.PolicyUtilities;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ResourceBundle;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
/**
*
* @author Ducksoul
*/
public class ApplicationView extends JPanel {
private static ResourceBundle rb = PolicyUtilities.getResourceBundle();
private JList appApplicationsLst = new JList();
private JScrollPane appApplicationsScroll = new JScrollPane(appApplicationsLst);
private JPanel appDetailsPnl = new JPanel();
private JLabel appNameLbl = new JLabel(rb.getString("name"));
private JLabel appALevelLbl = new JLabel(rb.getString("alevel"));
private JLabel appCLevelLbl = new JLabel(rb.getString("clevel"));
private JLabel appILevelLbl = new JLabel(rb.getString("ilevel"));
private JLabel appExpectRequestEncryptedLbl = new JLabel(rb.getString("expectrequest"));
private JLabel appReceiverListsLbl = new JLabel(rb.getString("receiverlists"));
private JTextField appNameTxt = new JTextField();
private JComboBox appALevelCombo = new JComboBox();
private JComboBox appCLevelCombo = new JComboBox();
private JComboBox appILevelCombo = new JComboBox();
private JCheckBox appExpectRequestEncryptedCheck = new JCheckBox();
private JList appReceiverListsLst = new JList();
private JScrollPane appReceiverListsScroll = new JScrollPane(appReceiverListsLst);
private JButton appJumpBtn = new JButton(ActionFactory.get(ActionKey.APP_JUMPTO));
private JButton appAddBtn = new JButton(ActionFactory.get(ActionKey.APP_ADDLIST));
private JButton appDeleteBtn = new JButton(ActionFactory.get(ActionKey.APP_DELETELIST));
public ApplicationView() {
ApplicationController apc = new ApplicationController(this);
init();
}
public JComboBox getAppALevelCombo() {
return appALevelCombo;
}
public JList getAppApplicationsLst() {
return appApplicationsLst;
}
public JComboBox getAppCLevelCombo() {
return appCLevelCombo;
}
public JCheckBox getAppExpectRequestEncryptedCheck() {
return appExpectRequestEncryptedCheck;
}
public JComboBox getAppILevelCombo() {
return appILevelCombo;
}
public JTextField getAppNameTxt() {
return appNameTxt;
}
public JList getAppReceiverListsLst() {
return appReceiverListsLst;
}
public JLabel getAppALevelLbl() {
return appALevelLbl;
}
public JLabel getAppCLevelLbl() {
return appCLevelLbl;
}
public JLabel getAppExpectRequestEncryptedLbl() {
return appExpectRequestEncryptedLbl;
}
public JLabel getAppILevelLbl() {
return appILevelLbl;
}
public JLabel getAppNameLbl() {
return appNameLbl;
}
public JLabel getAppReceiverListsLbl() {
return appReceiverListsLbl;
}
private void init() {
//eigentliche GUI erzeugen
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
appDetailsPnl.setLayout(gbl);
appApplicationsScroll.setMinimumSize(new Dimension(175, 1));
appApplicationsScroll.setPreferredSize(new Dimension(175, 1));
appNameTxt.setMinimumSize(new Dimension(175, 21));
appNameTxt.setPreferredSize(new Dimension(175, 21));
appALevelCombo.setMinimumSize(new Dimension(125, 21));
appALevelCombo.setPreferredSize(new Dimension(125, 21));
appCLevelCombo.setMinimumSize(new Dimension(125, 21));
appCLevelCombo.setPreferredSize(new Dimension(125, 21));
appILevelCombo.setMinimumSize(new Dimension(125, 21));
appILevelCombo.setPreferredSize(new Dimension(125, 21));
appReceiverListsScroll.setMinimumSize(new Dimension(175, 1));
appReceiverListsScroll.setPreferredSize(new Dimension(175, 1));
appAddBtn.setMinimumSize(new Dimension(125, 23));
appAddBtn.setPreferredSize(new Dimension(125, 23));
appJumpBtn.setMinimumSize(new Dimension(125, 23));
appJumpBtn.setPreferredSize(new Dimension(125, 23));
appDeleteBtn.setMinimumSize(new Dimension(125, 23));
appDeleteBtn.setPreferredSize(new Dimension(125, 23));
appNameTxt.setEnabled(false);
appALevelCombo.setEnabled(false);
appCLevelCombo.setEnabled(false);
appILevelCombo.setEnabled(false);
appExpectRequestEncryptedCheck.setEnabled(false);
PolicyUtilities.createLine(appDetailsPnl, gbl, appNameLbl, appNameTxt, 0, 15, 2);
PolicyUtilities.createLine(appDetailsPnl, gbl, appALevelLbl, appALevelCombo, 1);
PolicyUtilities.createLine(appDetailsPnl, gbl, appCLevelLbl, appCLevelCombo, 2);
PolicyUtilities.createLine(appDetailsPnl, gbl, appILevelLbl, appILevelCombo, 3);
PolicyUtilities.createLine(appDetailsPnl, gbl, appExpectRequestEncryptedLbl, appExpectRequestEncryptedCheck, 4);
PolicyUtilities.createLine(appDetailsPnl, gbl, appReceiverListsLbl, appReceiverListsScroll, 5);
PolicyUtilities.addSwingCompWest(appDetailsPnl, gbl, appJumpBtn, 5, 2, false);
PolicyUtilities.addSwingCompWest(appDetailsPnl, gbl, appAddBtn, 6, 2, false);
PolicyUtilities.addSwingCompWest(appDetailsPnl, gbl, appDeleteBtn, 7, 2, true);
ActionFactory.get(ActionFactory.ActionKey.APP_JUMPTO).setEnabled(false);
ActionFactory.get(ActionFactory.ActionKey.APP_DELETELIST).setEnabled(false);
ActionFactory.get(ActionFactory.ActionKey.APP_ADDLIST).setEnabled(false);
setLayout(new BorderLayout());
add(appApplicationsScroll, BorderLayout.WEST);
add(appDetailsPnl, BorderLayout.CENTER);
}
}