com.ibm.as400.vaccess.VSysvalArrayDialog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
The newest version!
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: VSysvalArrayDialog.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2000 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.vaccess;
import com.ibm.as400.access.SystemValue;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JList;
import javax.swing.BoxLayout;
import javax.swing.Box;
import javax.swing.JTabbedPane;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JRadioButton;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.Frame;
import java.awt.Component;
import java.util.Vector;
import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import com.ibm.as400.access.AS400Exception;
/**
* The VsysvalArrayDialog class defines a dialog
* for the user to modify system values of
* array type.
**/
class VSysvalArrayDialog
extends JDialog
implements ActionListener,
ListSelectionListener,
KeyListener
{
private static final String copyright = "Copyright (C) 1997-2000 International Business Machines Corporation and others.";
// Private data.
private VSystemValue systemValue_;
private JButton addButton_;
private JButton removeButton_;
private JButton changeButton_;
private JButton okButton_;
private JButton cancelButton_;
private JButton applyButton_;
private JList list_;
private JTextField textField_;
private Vector vector_;
private Frame parent_;
private boolean changed_;
// MRI
final private static String okButtonText_;
final private static String cancelButtonText_;
final private static String applyButtonText_;
final private static String modifyDialogTitle_;
final private static String modifyActionTab_;
final private static String valueName_;
final private static String valueDescription_;
final private static String valueInformation_;
final private static String addButtonText_;
final private static String removeButtonText_;
final private static String changeButtonText_;
static
{
okButtonText_ = (String)ResourceLoader.getText("DLG_OK");
cancelButtonText_ = (String)ResourceLoader.getText("DLG_CANCEL");
applyButtonText_ = (String)ResourceLoader.getText("DLG_APPLY");
modifyDialogTitle_ = (String)ResourceLoader.getText("DLG_MODIFY_0"); // @C1C
modifyActionTab_ = (String)ResourceLoader.getText("ACTION_MODIFY");
valueName_ = (String)ResourceLoader.getText("COLUMN_NAME");
valueDescription_ = (String)ResourceLoader.getText("COLUMN_DESCRIPTION");
valueInformation_ = (String)ResourceLoader.getText("COLUMN_VALUE");
addButtonText_ = (String)ResourceLoader.getText("DLG_ADD");
removeButtonText_ = (String)ResourceLoader.getText("DLG_REMOVE");
changeButtonText_ = (String)ResourceLoader.getText("DLG_CHANGE");
}
/**
* Constructs a VSysvalArrayDialog object. it creates a dialog to modify
* the array value.
* @param frame The parent Frame object.
* @param sysval The SystemValue object.
*
**/
public VSysvalArrayDialog(Frame frame, VSystemValue sysval)
{
super(frame, ResourceLoader.substitute(modifyDialogTitle_, sysval.getName()),true); // @C1C
parent_ = frame;
systemValue_ = sysval;
vector_ = new Vector();
Object[] obj = null;
obj = (Object[])systemValue_.getValue();
for (int i=0;i 0)
{
vector_.addElement(text);
list_.setListData(vector_);
changed_ = true;
list_.setSelectedValue(text,true);
changeButton_.setEnabled(false);
applyButton_.setEnabled(true);
}
}
// Remove
else if(source.equals(removeButton_))
{
index = list_.getSelectedIndex();
if (index!=-1)
{
vector_.removeElementAt(index);
list_.setListData(vector_);
changed_ = true;
applyButton_.setEnabled(true);
int size = vector_.size();
if (index0)
list_.setSelectedIndex(size-1);
if (list_.getSelectedIndex()==-1)
{
removeButton_.setEnabled(false);
changeButton_.setEnabled(false);
}
}
}
// Change
else if(source.equals(changeButton_))
{
index = list_.getSelectedIndex();
text = textField_.getText();
if (index!=-1)
{
if (vector_.indexOf(text)==-1)
{
vector_.setElementAt(text,index);
list_.setListData(vector_); // this is to refresh the list
changed_ = true;
applyButton_.setEnabled(true);
changeButton_.setEnabled(false);
}
}
}
// OK
else if(source.equals(okButton_))
{
if (changed_)
{
int count = vector_.size();
String[] value= new String[count];
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy