net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmSwing.CFCrmSwingSecGroupMemberAskDeleteJPanel.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmSwing.CFCrmSwingSecGroupMemberAskDeleteJPanel.java

Source

// Description: Java 7 Swing Ask Delete JPanel implementation for SecGroupMember.

/*
 *   CF Customer Relations Management model
 *
 *   Copyright (c) 2010-2014 Mark Sobkow
 *   
 *      Licensed under the Apache License, Version 2.0 (the "License");
 *      you may not use this file except in compliance with the License.
 *      You may obtain a copy of the License at
 *   
 *          http://www.apache.org/licenses/LICENSE-2.0
 *   
 *      Unless required by applicable law or agreed to in writing, software
 *      distributed under the License is distributed on an "AS IS" BASIS,
 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *      See the License for the specific language governing permissions and
 *      limitations under the License.
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmSwing;

import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.*;
import net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmObj.*;

/**
 *   CFCrmSwingSecGroupMemberAskDeleteJPanel Swing Ask Delete JPanel implementation
 *   for SecGroupMember.
 */
public class CFCrmSwingSecGroupMemberAskDeleteJPanel extends CFJPanel
        implements ICFCrmSwingSecGroupMemberJPanelCommon {
    protected ICFCrmSwingSchema swingSchema = null;
    protected JTextArea textAreaMessage = null;

    protected class ActionOk extends AbstractAction {
        public ActionOk() {
            super();
            putValue(Action.NAME, "Ok");
            setEnabled(true);
        }

        public void actionPerformed(ActionEvent e) {
            final String S_ProcName = "actionPerformed";
            Container cont = getParent();
            while ((cont != null) && (!(cont instanceof JInternalFrame))) {
                cont = cont.getParent();
            }
            if (cont != null) {
                JInternalFrame frame = (JInternalFrame) cont;
                if (frame instanceof ICFCrmSwingSecGroupMemberJPanelCommon) {
                    ICFCrmSwingSecGroupMemberJPanelCommon jpanelCommon = (ICFCrmSwingSecGroupMemberJPanelCommon) frame;
                    jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete);
                } else {
                    throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                            "frame", frame, "ICFCrmSwingSecGroupMemberJPanelCommon");
                }
                try {
                    frame.setClosed(true);
                } catch (Exception x) {
                }
            }
        }
    }

    protected class ActionCancel extends AbstractAction {
        public ActionCancel() {
            super();
            putValue(Action.NAME, "Cancel");
            setEnabled(true);
        }

        public void actionPerformed(ActionEvent e) {
            final String S_ProcName = "actionPerformed";
            Container cont = getParent();
            while ((cont != null) && (!(cont instanceof JInternalFrame))) {
                cont = cont.getParent();
            }
            if (cont != null) {
                JInternalFrame frame = (JInternalFrame) cont;
                if (frame instanceof ICFCrmSwingSecGroupMemberJPanelCommon) {
                    ICFCrmSwingSecGroupMemberJPanelCommon jpanelCommon = (ICFCrmSwingSecGroupMemberJPanelCommon) frame;
                    jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown);
                    ICFCrmSecGroupMemberEditObj editObj = (ICFCrmSecGroupMemberEditObj) jpanelCommon
                            .getSwingFocusAsSecGroupMember().getEdit();
                    if (editObj != null) {
                        editObj.endEdit();
                    }
                } else {
                    throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                            "frame", frame, "ICFCrmSwingSecGroupMemberJPanelCommon");
                }
                try {
                    frame.setClosed(true);
                } catch (Exception x) {
                }
            }
        }
    }

    protected Action actionOk = null;
    protected Action actionCancel = null;
    protected JButton buttonOk = null;
    protected JButton buttonCancel = null;
    protected JScrollPane scrollPane = null;
    protected JPanel attrJPanel = null;

    public CFCrmSwingSecGroupMemberAskDeleteJPanel(ICFCrmSwingSchema argSchema, ICFCrmSecGroupMemberObj argFocus) {
        super();
        final String S_ProcName = "construct-schema-focus";
        if (argSchema == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                    "argSchema");
        }
        // argFocus is optional; focus may be set later during execution as
        // conditions of the runtime change.
        swingSchema = argSchema;
        swingFocus = argFocus;
        // Construct the various objects
        textAreaMessage = new JTextArea("Are you sure you want to delete this Security Group Member?");
        actionOk = new ActionOk();
        actionCancel = new ActionCancel();
        buttonOk = new JButton(actionOk);
        buttonCancel = new JButton(actionCancel);
        attrJPanel = argSchema.getSecGroupMemberFactory().newAttrJPanel(argFocus);
        scrollPane = new CFHSlaveJScrollPane(attrJPanel);
        // Lay out the widgets
        setSize(1024, 480);
        Dimension min = new Dimension(480, 300);
        setMinimumSize(min);
        add(textAreaMessage);
        textAreaMessage.setBounds(0, 0, 1024, 50);
        int xparts = (768 - (2 * 125)) / 3;
        add(buttonOk);
        buttonOk.setBounds(xparts, 55, 125, 40);
        add(buttonCancel);
        buttonCancel.setBounds(xparts + 125 + xparts, 55, 125, 40);
        add(scrollPane);
        scrollPane.setBounds(0, 100, 1024, 480 - 100);
    }

    public ICFCrmSwingSchema getSwingSchema() {
        return (swingSchema);
    }

    public void setSwingFocus(ICFLibAnyObj2 value) {
        final String S_ProcName = "setSwingFocus";
        if ((value == null) || (value instanceof ICFCrmSecGroupMemberObj)) {
            super.setSwingFocus(value);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "value",
                    value, "ICFCrmSecGroupMemberObj");
        }
    }

    public ICFCrmSecGroupMemberObj getSwingFocusAsSecGroupMember() {
        return ((ICFCrmSecGroupMemberObj) getSwingFocus());
    }

    public void setSwingFocusAsSecGroupMember(ICFCrmSecGroupMemberObj value) {
        swingFocus = value;
        if (attrJPanel != null) {
            ((ICFCrmSwingSecGroupMemberJPanelCommon) attrJPanel).setSwingFocus(value);
        }
    }

    public void doLayout() {
        Dimension sz = getSize();
        textAreaMessage.setBounds(0, 0, sz.width, 50);
        int xparts = (sz.width - (2 * 125)) / 3;
        buttonOk.setBounds(xparts, 55, 125, 40);
        buttonCancel.setBounds(xparts + 125 + xparts, 55, 125, 40);
        scrollPane.setBounds(0, 100, sz.width, sz.height - 100);
        scrollPane.doLayout();
    }

    public void setPanelMode(CFJPanel.PanelMode value) {
        final String S_ProcName = "setPanelMode";
        CFJPanel.PanelMode oldMode = getPanelMode();
        if (oldMode == value) {
            return;
        }
        if ((value != CFJPanel.PanelMode.Unknown) && (value != CFJPanel.PanelMode.View)
                && (value != CFJPanel.PanelMode.Delete)) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "AskDeleteJPanels only support PanelMode Unknown, View or Delete");
        }
        super.setPanelMode(value);
        if (attrJPanel != null) {
            ((ICFCrmSwingSecGroupMemberJPanelCommon) attrJPanel).setPanelMode(value);
        }
    }
}