Java tutorial
// Description: Java 7 Swing Ask Delete JPanel implementation for MajorVersion. /* * 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.*; /** * CFCrmSwingMajorVersionAskDeleteJPanel Swing Ask Delete JPanel implementation * for MajorVersion. */ public class CFCrmSwingMajorVersionAskDeleteJPanel extends CFJPanel implements ICFCrmSwingMajorVersionJPanelCommon { 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 ICFCrmSwingMajorVersionJPanelCommon) { ICFCrmSwingMajorVersionJPanelCommon jpanelCommon = (ICFCrmSwingMajorVersionJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "frame", frame, "ICFCrmSwingMajorVersionJPanelCommon"); } 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 ICFCrmSwingMajorVersionJPanelCommon) { ICFCrmSwingMajorVersionJPanelCommon jpanelCommon = (ICFCrmSwingMajorVersionJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown); ICFCrmMajorVersionEditObj editObj = (ICFCrmMajorVersionEditObj) jpanelCommon .getSwingFocusAsMajorVersion().getEdit(); if (editObj != null) { editObj.endEdit(); } } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "frame", frame, "ICFCrmSwingMajorVersionJPanelCommon"); } 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 CFCrmSwingMajorVersionAskDeleteJPanel(ICFCrmSwingSchema argSchema, ICFCrmMajorVersionObj 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 MajorVersion?"); actionOk = new ActionOk(); actionCancel = new ActionCancel(); buttonOk = new JButton(actionOk); buttonCancel = new JButton(actionCancel); attrJPanel = argSchema.getMajorVersionFactory().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 ICFCrmMajorVersionObj)) { super.setSwingFocus(value); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "value", value, "ICFCrmMajorVersionObj"); } } public ICFCrmMajorVersionObj getSwingFocusAsMajorVersion() { return ((ICFCrmMajorVersionObj) getSwingFocus()); } public void setSwingFocusAsMajorVersion(ICFCrmMajorVersionObj value) { swingFocus = value; if (attrJPanel != null) { ((ICFCrmSwingMajorVersionJPanelCommon) 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) { ((ICFCrmSwingMajorVersionJPanelCommon) attrJPanel).setPanelMode(value); } } }