src.com.ibm.as400.vaccess.SQLQueryFieldsPane Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400-jdk8 Show documentation
Show all versions of jt400-jdk8 Show documentation
The Open Source version of the IBM Toolbox for Java
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: SQLQueryFieldsPane.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 javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.io.IOException;
import java.sql.Types;
import java.util.Vector;
/**
The SQLQueryFieldsPane class represents a panel which
contains a fields table,
used for a page of the SQLQueryBuilderPane notebook.
**/
abstract class SQLQueryFieldsPane
extends JPanel
{
private static final String copyright = "Copyright (C) 1997-2000 International Business Machines Corporation and others.";
// This class is not meant to be serialized, it should be transient.
// This class has items marked transient even though it is not
// serializable because otherwise errors were received when
// serializing objects that contained this class (even though they
// were transient instances. readObject() was added to be safe.
// GUI components
protected SQLMetaDataTablePane fields_;
protected SQLMetaDataTableModel fieldModel_;
protected SQLQueryBuilderPane parent_;
// Indicates if fieldModel_ has changed.
protected boolean fieldsChanged_ = false;
// Listen to changes in the fields table.
transient protected FieldListener_ fieldListener_ = null;
/**
Constructs a SQLQuerySelectPane object.
init must be called to build the GUI contents.
@param parent The parent of this panel.
**/
public SQLQueryFieldsPane (SQLQueryBuilderPane parent)
{
super();
parent_ = parent;
fieldModel_ = parent_.fields_;
// Add listener to changes to table fields.
fieldListener_ = new FieldListener_();
parent_.addFieldListener(fieldListener_);
}
/**
Returns the name of the field at the given row.
@param index The row of field.
@return The name of the field at the given row.
**/
protected String fieldName(int index)
{
return (String)
(fieldModel_.getValueAt(index, SQLMetaDataTableModel.FIELD_NAME_));
}
/**
Returns the names of the fields which are characters.
@return The names of the character fields.
**/
protected String[] getCharacterFieldNames()
{
int numRows = fieldModel_.getRowCount();
Vector results = new Vector();
for (int i=0; i 1) // if double click
{
// Get the object that was double clicked, if any.
int row = table.rowAtPoint(event.getPoint());
if (row != -1) // -1 means no object under mouse
{
rowPicked(row);
}
}
}
}
);
}
/**
Update the fieldModel if needed.
**/
public void update()
{
if (fieldsChanged_)
{
// Build new model.
fieldModel_ = parent_.fields_;
// Set table to use new model.
fields_.setDataModel(fieldModel_);
fieldsChanged_ = false;
}
}
/**
Class to listen for property changes on the fields contained in the
tables associated with the query.
**/
/* private */ class FieldListener_ //@B0C - made package scope
implements PropertyChangeListener, java.io.Serializable //@B0C - made serializable
{
public void propertyChange(PropertyChangeEvent event)
{
fieldsChanged_ = true;
}
}
}