com.ibm.as400.vaccess.VSystemValueGroup 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: VSystemValueGroup.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 com.ibm.as400.access.SystemValueList;
import com.ibm.as400.access.AS400;
import java.io.ObjectInputStream;
import javax.swing.tree.TreeNode;
import javax.swing.Icon;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.Icon;
import java.beans.VetoableChangeListener;
import java.beans.PropertyChangeListener;
import javax.swing.table.TableColumnModel;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
/**
* The VSystemValueGroup class defines the representation of a
* system value group on a server for use in various models
* and panes in this package.
* You must explicitly call load() to load the information from
* the server.
*
* Most errors are reported as ErrorEvents rather than
* throwing exceptions. Users should listen for ErrorEvents
* in order to diagnose and recover from error conditions.
*
*
VSystemValueGroup objects generate the following events:
*
* - ErrorEvent
*
- PropertyChangeEvent
*
- VObjectEvent
*
- WorkingEvent
*
**/
class VSystemValueGroup implements VNode
{
private static final String copyright = "Copyright (C) 1997-2000 International Business Machines Corporation and others.";
// Private data.
private VSystemValueList systemValueList_;
private int group_;
private String groupName_;
private String groupDescription_;
private VNode parent_ = null;
private boolean loaded_ = false;
private Vector systemValues_;
private VObject[] detailsChildren_;
private VPropertiesPane propertiesPane_;
// Event support.
private ErrorEventSupport errorEventSupport_;
private VObjectEventSupport objectEventSupport_;
private WorkingEventSupport workingEventSupport_;
// This one is for refreshing all other date and time values
// if one of them should change.
private VObjectListener_ dateTimeListener_;
// Static data.
static public final String VALUE_PROPERTY = "Value";
private static TableColumnModel detailsColumnModel_;
// MRI
private static String nameColumnHeader_;
private static String descriptionColumnHeader_;
private static String valueColumnHeader_;
private static String description_;
private static Icon icon16_;
private static Icon icon32_;
/**
* Static initializer
**/
static
{
nameColumnHeader_ = (String)ResourceLoader.getText("COLUMN_NAME");
valueColumnHeader_ = (String)ResourceLoader.getText("COLUMN_VALUE");
descriptionColumnHeader_ = (String)ResourceLoader.getText("COLUMN_DESCRIPTION");
description_ = (String)ResourceLoader.getText("COLUMN_GROUP");
icon16_= ResourceLoader.getIcon("VSystemValueGroup16.gif", description_);
icon32_= ResourceLoader.getIcon("VSystemValueGroup32.gif", description_);
detailsColumnModel_= new DefaultTableColumnModel();
int i = 0;
// These are the columns to display for the children.
// The children are VSystemValues.
// Name column.
VTableColumn vTable1= new VTableColumn(i++, NAME_PROPERTY);
vTable1.setCellRenderer(((TableCellRenderer)new VObjectCellRenderer()));
vTable1.setHeaderRenderer(((TableCellRenderer)new VObjectHeaderRenderer()));
vTable1.setHeaderValue(nameColumnHeader_);
vTable1.setPreferredCharWidth(10);
detailsColumnModel_.addColumn(((TableColumn)vTable1));
// Value column.
VTableColumn vTable2= new VTableColumn(i++, VALUE_PROPERTY);
vTable2.setCellRenderer(((TableCellRenderer)new VObjectCellRenderer()));
vTable2.setHeaderRenderer(((TableCellRenderer)new VObjectHeaderRenderer()));
vTable2.setHeaderValue(valueColumnHeader_);
vTable2.setPreferredCharWidth(15);
detailsColumnModel_.addColumn(((TableColumn)vTable2));
// Description column
VTableColumn vTable3= new VTableColumn(i++, DESCRIPTION_PROPERTY);
vTable3.setCellRenderer(((TableCellRenderer)new VObjectCellRenderer()));
vTable3.setHeaderRenderer(((TableCellRenderer)new VObjectHeaderRenderer()));
vTable3.setHeaderValue(descriptionColumnHeader_);
vTable3.setPreferredCharWidth(40);
detailsColumnModel_.addColumn(((TableColumn)vTable3));
}
/**
* Constructs a VSystemValueGroup object.
* @param systemValueList The SystemValueList object.
* @param group The group type.
**/
public VSystemValueGroup(VSystemValueList systemValueList, int group)
{
systemValueList_ = systemValueList;
group_ = group;
groupName_ = SystemValueList.getGroupName(group_);
groupDescription_ = SystemValueList.getGroupDescription(group_);
parent_ = systemValueList;
errorEventSupport_= new ErrorEventSupport(this);
objectEventSupport_= new VObjectEventSupport(this);
workingEventSupport_= new WorkingEventSupport(this);
dateTimeListener_ = new VObjectListener_();
propertiesPane_= new VSystemValueGroupPropertiesPane(this);
propertiesPane_.addErrorListener(errorEventSupport_);
propertiesPane_.addVObjectListener(objectEventSupport_);
propertiesPane_.addWorkingListener(workingEventSupport_);
propertiesPane_.addVObjectListener(dateTimeListener_);
systemValues_ = new Vector();
detailsChildren_= new VSystemValue[0];
loaded_ = false;
}
/**
* Adds the specified error listener
* to receive error event from this
* component.
* @param listener The error listener.
**/
public void addErrorListener(ErrorListener listener)
{
errorEventSupport_.addErrorListener(listener);
}
/**
* Adds the specified VObject listener
* to receive VObject event from this
* component.
* @param listener The VObject listener.
**/
public void addVObjectListener(VObjectListener listener)
{
objectEventSupport_.addVObjectListener(listener);
}
/**
* Adds the specified working listener
* to receive working event from this
* component.
* @param listener The working listener.
**/
public void addWorkingListener(WorkingListener listener)
{
workingEventSupport_.addWorkingListener(listener);
}
/**
* Returns the children of the node.
*
* @return The children.
**/
public Enumeration children()
{
return (Enumeration)(new VEnumeration((VNode)this));
}
/**
* Returns the list of actions that can be performed.
*
* @return Always null. There are no actions.
*
**/
public VAction[] getActions()
{
return null;
}
/**
* Indicates if the node allows children.
*
* @return Always false.
**/
public boolean getAllowsChildren()
{
return false;
}
/**
* Returns the child node at the specified index.
*
* @param index The index.
* @return Always null.
**/
public TreeNode getChildAt(int index)
{
return null;
}
/**
* Returns the number of children.
*
* @return The number of the children.
**/
public int getChildCount()
{
return 0;
}
/**
* Returns the description.
* @return The description.
**/
public String getDescription()
{
return groupDescription_;
}
/**
* Returns the default action.
*
* @return Always null. There is no default action.
**/
public VAction getDefaultAction()
{
return null;
}
/**
* Returns the child for the details at the specified index.
*
* @param index The index.
* @return The child, or null if the index is not
* valid.
**/
public VObject getDetailsChildAt(int index)
{
if (index < 0 || index >= detailsChildren_.length)
return null;
loadChildren();
return detailsChildren_[index];
}
/**
* Returns the number of children for the details.
*
* @return The number of children for the details.
**/
public int getDetailsChildCount()
{
loadChildren();
return detailsChildren_.length;
}
/**
* Returns the table column model to use in the details
* when representing the children. This column model
* describes the details values for the children.
*
* @return The details column model.
**/
public TableColumnModel getDetailsColumnModel()
{
return detailsColumnModel_;
}
/**
* Returns the index of the specified child for the details.
*
* @param vObject The details child.
* @return The index, or -1 if the child is not found
* in the details.
**/
public int getDetailsIndex(VObject vObject)
{
loadChildren();
for (int i=0; i
* NAME_PROPERTY
* DESCRIPTION_PROPERTY
*
* @return The property value, or null if the
* property identifier is not recognized.
**/
public Object getPropertyValue(Object object)
{
if (object == NAME_PROPERTY)
{
return groupName_;
}
if (object == DESCRIPTION_PROPERTY)
{
return groupDescription_;
}
return null;
}
/**
* Returns the text. This is the system value group name
*
* @return The text which is the system value group name.
**/
public String getText()
{
return groupName_;
}
/**
* Indicates if the node is a leaf.
*
* @return Always true.
**/
public boolean isLeaf()
{
return true;
}
/**
* Indicates if the details children are sortable.
*
* @return Always false.
**/
public boolean isSortable()
{
return false;
}
/**
* Loads information about the object from the server.
**/
public void load()
{
workingEventSupport_.fireStartWorking();
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy