Package com.commander4j.app

Source Code of com.commander4j.app.JDialogDataIDProperties

package com.commander4j.app;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import com.commander4j.db.JDBDataIDs;
import com.commander4j.db.JDBLanguage;
import com.commander4j.gui.JButton4j;
import com.commander4j.gui.JLabel4j_std;
import com.commander4j.gui.JTextField4j;
import com.commander4j.sys.Common;
import com.commander4j.util.JHelp;
import com.commander4j.util.JUtility;

public class JDialogDataIDProperties extends javax.swing.JDialog {
  private static final long serialVersionUID = 1;

  private JButton4j jButtonClose;
  private JButton4j jButtonHelp;
  private JButton4j jButtonUpdate;
  private JTextField4j jTextFieldDescription;
  private JLabel4j_std jLabel3;
  private JTextField4j jTextFieldType;
  private JLabel4j_std jLabel1;
  private JDBDataIDs mt = new JDBDataIDs(Common.selectedHostID, Common.sessionID);
  private String ltype;
  private JDBLanguage lang = new JDBLanguage(Common.selectedHostID, Common.sessionID);
  private JDesktopPane desktopPane = new JDesktopPane();

  public JDialogDataIDProperties(JFrame frame, String typ) {

    super(frame, "Data ID Properties", ModalityType.APPLICATION_MODAL);

    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setTitle("Data ID Properties");
    this.setResizable(false);
    this.setSize(459, 168);

    Dimension screensize = Common.mainForm.getSize();

    Dimension formsize = getSize();
    int leftmargin = ((screensize.width - formsize.width) / 2);
    int topmargin = ((screensize.height - formsize.height) / 2);

    setLocation(leftmargin, topmargin);

    getContentPane().setBackground(Color.LIGHT_GRAY);
    getContentPane().setLayout(null);

    desktopPane.setBackground(Common.color_edit_properties);
    desktopPane.setBounds(0, 0, 469, 156);
    getContentPane().add(desktopPane);

    initGUI();

    final JHelp help = new JHelp();
    help.enableHelpOnButton(jButtonHelp, JUtility.getHelpSetIDforModule("FRM_ADMIN_DATA_IDS"));

    SwingUtilities.invokeLater(new Runnable() {
      public void run()
      {
        jTextFieldDescription.requestFocus();
        jTextFieldDescription.setCaretPosition(jTextFieldDescription.getText().length());
      }
    });

    jTextFieldType.setText(typ);
    setTitle(getTitle() + " - " + typ);
    ltype = typ;

    mt.setID(ltype);
    mt.getProperties();

    jTextFieldType.setText(mt.getID());
    jTextFieldDescription.setText(mt.getDescription());

    jButtonUpdate.setEnabled(false);
  }

  private void initGUI()
  {
    try
    {

      {
        getContentPane().add(desktopPane, BorderLayout.CENTER);
        {
          jLabel1 = new JLabel4j_std();
          desktopPane.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jLabel1.setText(lang.get("lbl_Data_ID"));
          jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
          jLabel1.setHorizontalTextPosition(SwingConstants.RIGHT);
          jLabel1.setBounds(6, 17, 175, 21);
        }
        {
          jTextFieldType = new JTextField4j();
          desktopPane.add(jTextFieldType, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jTextFieldType.setHorizontalAlignment(SwingConstants.LEFT);
          jTextFieldType.setEditable(false);
          jTextFieldType.setEnabled(false);
          jTextFieldType.setBounds(185, 17, 104, 21);
        }
        {
          jLabel3 = new JLabel4j_std();
          desktopPane.add(jLabel3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jLabel3.setText(lang.get("lbl_Description"));
          jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
          jLabel3.setHorizontalTextPosition(SwingConstants.RIGHT);
          jLabel3.setBounds(6, 49, 175, 21);
        }
        {
          jTextFieldDescription = new JTextField4j();
          desktopPane.add(jTextFieldDescription, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jTextFieldDescription.setBounds(185, 49, 238, 21);
          jTextFieldDescription.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent evt)
            {
              jButtonUpdate.setEnabled(true);
            }
          });
          jTextFieldDescription.setFocusCycleRoot(true);
        }
        {
          jButtonUpdate = new JButton4j(Common.icon_update);
          desktopPane.add(jButtonUpdate, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jButtonUpdate.setEnabled(false);
          jButtonUpdate.setText(lang.get("btn_Save"));
          jButtonUpdate.setMnemonic(lang.getMnemonicChar());
          jButtonUpdate.setHorizontalTextPosition(SwingConstants.RIGHT);
          jButtonUpdate.setBounds(46, 91, 112, 32);
          jButtonUpdate.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt)
            {
              mt.setDescription(jTextFieldDescription.getText());

              mt.update();
              jButtonUpdate.setEnabled(false);
            }
          });
        }
        {
          jButtonHelp = new JButton4j(Common.icon_help);
          desktopPane.add(jButtonHelp);
          jButtonHelp.setText(lang.get("btn_Help"));
          jButtonHelp.setMnemonic(lang.getMnemonicChar());
          jButtonHelp.setBounds(165, 91, 112, 32);
        }
        {
          jButtonClose = new JButton4j(Common.icon_close);
          desktopPane.add(jButtonClose, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jButtonClose.setText(lang.get("btn_Close"));
          jButtonClose.setMnemonic(lang.getMnemonicChar());
          jButtonClose.setBounds(284, 91, 112, 32);
          jButtonClose.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt)
            {
              dispose();
            }
          });
        }

      }
    } catch (Exception e)
    {
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of com.commander4j.app.JDialogDataIDProperties

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.