home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import com.sun.java.swing.ButtonModel;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JList;
- import com.sun.java.swing.JTable;
- import com.sun.java.swing.table.DefaultTableModel;
- import com.sun.java.swing.table.TableColumn;
- import com.sun.java.swing.table.TableColumnModel;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Insets;
- import java.util.Enumeration;
- import java.util.TooManyListenersException;
- import java.util.Vector;
-
- public class WizardViewDbList3 extends WizardViewAbstract {
- public static final int COLFIELDNAME = 0;
- public static final int COLFIELDTYPE = 1;
- public static final int COLFIELDLABEL = 2;
- public static final int LINK_TO_LIST = 1000;
- public static final int LINK_TO_DETAIL = 1001;
- private static WizardViewAbstract _instance = null;
- private WVPanelDbListLink _mainPanel;
- private TableColumn _columnAlias;
- private boolean _initFieldSpecColWidths = false;
-
- public WizardViewDbList3() {
- JTable table = this._mainPanel.getFieldSpecTable();
- TableColumnModel tcm = table.getColumnModel();
- this._columnAlias = tcm.getColumn(2);
- tcm.removeColumn(this._columnAlias);
- }
-
- public static WizardViewAbstract getInstance() {
- if (_instance == null) {
- _instance = new WizardViewDbList3();
- }
-
- return _instance;
- }
-
- protected void createMainPanel() {
- this._mainPanel = new WVPanelDbListLink();
- this.initListeners();
- }
-
- public WVPanelBase getMainPanel() {
- return this._mainPanel;
- }
-
- public int getSeqTemplateId() {
- int result = -1;
- ButtonModel buttonModel = this._mainPanel._btgTemplates.getSelection();
- if (buttonModel != null) {
- String actionCommand = buttonModel.getActionCommand();
- if (actionCommand.equals("radiobutton.linktodetail")) {
- result = 1;
- } else if (actionCommand.equals("radiobutton.linktolist")) {
- result = 0;
- }
- }
-
- return result;
- }
-
- private void resizeColumnsEqually(JTable table) {
- TableColumnModel tcm = table.getColumnModel();
- Container cont = ((Component)table).getParent();
- Insets insets = cont.getInsets();
- int width = ((Component)cont).getSize().width - insets.left - insets.right - 2;
- int colWidth = width / tcm.getColumnCount();
-
- for(int i = 0; i < tcm.getColumnCount(); ++i) {
- tcm.getColumn(i).setWidth(colWidth);
- }
-
- ((Container)table).invalidate();
- Container rootContainer = ((JComponent)table).getTopLevelAncestor();
- if (rootContainer != null) {
- rootContainer.validate();
- }
-
- ((Component)this).repaint();
- }
-
- public void updateFieldSpecTableColumnsVisibility() {
- JTable table = this._mainPanel.getFieldSpecTable();
- TableColumnModel tcm = table.getColumnModel();
- boolean show = this.getLinkOption() == 1000;
- if (show && this._columnAlias != null) {
- tcm.addColumn(this._columnAlias);
- this._columnAlias = null;
- this.resizeColumnsEqually(table);
- } else if (!show && this._columnAlias == null) {
- this._columnAlias = tcm.getColumn(2);
- tcm.removeColumn(this._columnAlias);
- this.resizeColumnsEqually(table);
- }
-
- }
-
- protected void initListeners() {
- try {
- this._mainPanel._l2tFieldSpec.addXferItemListener(new 1(this));
- } catch (TooManyListenersException e) {
- System.err.println(((Throwable)e).getMessage());
- }
-
- this._mainPanel._rdbLinkToDetail.addActionListener(new 2(this));
- this._mainPanel._rdbLinkToList.addActionListener(new 3(this));
- this._mainPanel.getFieldSpecTable().addComponentListener(new 4(this));
- }
-
- public void setDataType(Vector list) {
- Enumeration values = list.elements();
- this._mainPanel._cboDataType.removeAllItems();
-
- while(values.hasMoreElements()) {
- this._mainPanel._cboDataType.addItem((String)values.nextElement());
- }
-
- }
-
- public void setHyperlinkField(int hyperlinkField) {
- if (hyperlinkField < this._mainPanel._cboList.getItemCount()) {
- this._mainPanel._cboList.setSelectedIndex(hyperlinkField);
- } else {
- this._mainPanel._cboList.setSelectedIndex(0);
- }
-
- }
-
- public int getHyperlinkField() {
- return this._mainPanel._cboList.getSelectedIndex();
- }
-
- public void setHyperlinkPage(int hyperlinkPage) {
- }
-
- public int getHyperlinkPage() {
- return 1;
- }
-
- public DefaultTableModel getKeyFields() {
- return (DefaultTableModel)this._mainPanel.getFieldSpecTable().getModel();
- }
-
- public void setKeyFields(DefaultTableModel KFCollection) {
- this._mainPanel.getFieldSpecTable().setModel(KFCollection);
- }
-
- public JTable getFieldSpecTable() {
- return this._mainPanel.getFieldSpecTable();
- }
-
- public JList getFieldList() {
- return this._mainPanel.getFieldList();
- }
-
- public void setHLFieldList(String[] list) {
- this._mainPanel._cboList.removeAllItems();
-
- for(int i = 0; i < list.length; ++i) {
- this._mainPanel._cboList.addItem(list[i]);
- }
-
- }
-
- public int getLinkOption() {
- int result = 1001;
- ButtonModel selModel = this._mainPanel._btgTemplates.getSelection();
- if (selModel == this._mainPanel._rdbLinkToList.getModel()) {
- result = 1000;
- }
-
- return result;
- }
-
- public void setLinkOption(int option) {
- if (option == 1000) {
- this._mainPanel._btgTemplates.setSelected(this._mainPanel._rdbLinkToList.getModel(), true);
- } else if (option == 1001) {
- this._mainPanel._btgTemplates.setSelected(this._mainPanel._rdbLinkToDetail.getModel(), true);
- }
-
- }
-
- public void commit() {
- this._mainPanel._l2tFieldSpec.commitChanges();
- }
-
- // $FF: synthetic method
- static boolean access$0(WizardViewDbList3 $0) {
- return $0._initFieldSpecColWidths;
- }
-
- // $FF: synthetic method
- static WVPanelDbListLink access$1(WizardViewDbList3 $0) {
- return $0._mainPanel;
- }
-
- // $FF: synthetic method
- static void access$2(WizardViewDbList3 $0, JTable $1) {
- $0.resizeColumnsEqually($1);
- }
-
- // $FF: synthetic method
- static void access$3(WizardViewDbList3 $0, boolean $1) {
- $0._initFieldSpecColWidths = $1;
- }
- }
-