Package de.netsysit.view

Source Code of de.netsysit.view.MappingDialog

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.netsysit.view;

import de.netsysit.model.DataBaseModel;
import de.netsysit.model.PolicyMappingModel;
import de.netsysit.model.PolicyModel;
import de.netsysit.policymanager.PolicyManager;
import de.netsysit.policymanager.PolicyUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

/**
*
* @author Ducksoul
*/
public class MappingDialog {
    private ResourceBundle rb = PolicyUtilities.getResourceBundle();
    private DataBaseModel dbModel = PolicyManager.getPolicyModel();
    private PolicyMappingModel model = new PolicyMappingModel();
   
    private JPanel jMappingPanel = new JPanel();
    private JPanel jGesamtPanel = new JPanel();
    private JPanel jMessagePanel = new JPanel();
    private JLabel jMessageLabel = new JLabel();
    private JTable jMappingTable = new JTable();
   
    private PolicyModel dummy;
   
    public MappingDialog() {
       
        jMappingPanel.setLayout(new GridLayout(1, 1))
       
        jMappingTable.setModel(model);
        jMappingTable.setDefaultRenderer(Object.class, new MappingCellRenderer());
       
        dummy = PolicyUtilities.getDummyPolicy();
               
       
        TableColumn a = jMappingTable.getColumnModel().getColumn(1);
        DefaultComboBoxModel aModel = dbModel.getAPoliciesAsComboModel();
        aModel.addElement(dummy);
        JComboBox aCombo = new JComboBox(aModel);
        a.setCellEditor(new DefaultCellEditor(aCombo));
       
        TableColumn c = jMappingTable.getColumnModel().getColumn(2);
        DefaultComboBoxModel cModel = dbModel.getCPoliciesAsComboModel();
        cModel.addElement(dummy);
        JComboBox cCombo = new JComboBox(cModel);
        c.setCellEditor(new DefaultCellEditor(cCombo));
       
        TableColumn i = jMappingTable.getColumnModel().getColumn(3);
        DefaultComboBoxModel iModel = dbModel.getIPoliciesAsComboModel();
        iModel.addElement(dummy);
        JComboBox iCombo = new JComboBox(iModel);
        i.setCellEditor(new DefaultCellEditor(iCombo));
       
        jMappingPanel.add(jMappingTable);
        jMappingPanel.setBorder(BorderFactory.createLineBorder(Color.black));
       
        jMessageLabel.setText("Grundwerteinstellungen:");
       
        jMessagePanel.setLayout(new GridLayout(2, 2));
        jMessagePanel.add(jMessageLabel);
        jMessagePanel.add(new JSeparator(JSeparator.HORIZONTAL));
       
        jGesamtPanel.setLayout(new BorderLayout(0, 10));
        jGesamtPanel.add(jMessageLabel, BorderLayout.NORTH);
        jGesamtPanel.add(jMappingPanel, BorderLayout.CENTER);
       
    }
   
    public void showDialog() {    
        JOptionPane.showMessageDialog(null, jGesamtPanel, "Policy Grundwerte", JOptionPane.QUESTION_MESSAGE);      
    }
   
    public void refresh() {
        jMappingTable.setModel(new PolicyMappingModel());
               
        TableColumn a = jMappingTable.getColumnModel().getColumn(1);
        DefaultComboBoxModel aModel = dbModel.getAPoliciesAsComboModel();
        aModel.addElement(dummy);
        JComboBox aCombo = new JComboBox(aModel);
        a.setCellEditor(new DefaultCellEditor(aCombo));
       
        TableColumn c = jMappingTable.getColumnModel().getColumn(2);
        DefaultComboBoxModel cModel = dbModel.getCPoliciesAsComboModel();
        cModel.addElement(dummy);
        JComboBox cCombo = new JComboBox(cModel);
        c.setCellEditor(new DefaultCellEditor(cCombo));
       
        TableColumn i = jMappingTable.getColumnModel().getColumn(3);
        DefaultComboBoxModel iModel = dbModel.getIPoliciesAsComboModel();
        iModel.addElement(dummy);
        JComboBox iCombo = new JComboBox(iModel);
        i.setCellEditor(new DefaultCellEditor(iCombo));
    }
   
    public boolean getResult() {
        for(int i=1; i<=3; i++) {
            for(int j=1; j<=3; j++) {
                PolicyModel p = (PolicyModel) jMappingTable.getModel().getValueAt(i, j);
                if(p.equals(PolicyUtilities.getDummyPolicy())) {
                    return false;
                }
            }
        }
       
        return true;
    }
  
}
TOP

Related Classes of de.netsysit.view.MappingDialog

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.