Java tutorial
// Description: Java 7 Swing Ask Delete JPanel implementation for SecSession. /* * CF Customer Information Managerment template 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.cfinternet.v2_0.CFInternetSwing; 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.cfinternet.v2_0.CFInternet.*; import net.sourceforge.msscodefactory.cfinternet.v2_0.CFInternetObj.*; /** * CFInternetSwingSecSessionAskDeleteJPanel Swing Ask Delete JPanel implementation * for SecSession. */ public class CFInternetSwingSecSessionAskDeleteJPanel extends CFJPanel implements ICFInternetSwingSecSessionJPanelCommon { protected ICFInternetSwingSchema 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 ICFInternetSwingSecSessionJPanelCommon) { ICFInternetSwingSecSessionJPanelCommon jpanelCommon = (ICFInternetSwingSecSessionJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "frame", frame, "ICFInternetSwingSecSessionJPanelCommon"); } 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 ICFInternetSwingSecSessionJPanelCommon) { ICFInternetSwingSecSessionJPanelCommon jpanelCommon = (ICFInternetSwingSecSessionJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown); ICFInternetSecSessionEditObj editObj = (ICFInternetSecSessionEditObj) jpanelCommon .getSwingFocusAsSecSession().getEdit(); if (editObj != null) { editObj.endEdit(); } } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "frame", frame, "ICFInternetSwingSecSessionJPanelCommon"); } 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 CFInternetSwingSecSessionAskDeleteJPanel(ICFInternetSwingSchema argSchema, ICFInternetSecSessionObj 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 Session?"); actionOk = new ActionOk(); actionCancel = new ActionCancel(); buttonOk = new JButton(actionOk); buttonCancel = new JButton(actionCancel); attrJPanel = argSchema.getSecSessionFactory().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 ICFInternetSwingSchema getSwingSchema() { return (swingSchema); } public void setSwingFocus(ICFLibAnyObj2 value) { final String S_ProcName = "setSwingFocus"; if ((value == null) || (value instanceof ICFInternetSecSessionObj)) { super.setSwingFocus(value); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "value", value, "ICFInternetSecSessionObj"); } } public ICFInternetSecSessionObj getSwingFocusAsSecSession() { return ((ICFInternetSecSessionObj) getSwingFocus()); } public void setSwingFocusAsSecSession(ICFInternetSecSessionObj value) { swingFocus = value; if (attrJPanel != null) { ((ICFInternetSwingSecSessionJPanelCommon) 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) { ((ICFInternetSwingSecSessionJPanelCommon) attrJPanel).setPanelMode(value); } } }