📄 dbconnectionstablemodel.java
字号:
/**
* ========================================================================================
* JFreeReport Designer : a graphical designer for JFreeReport - a free Java report library
* ========================================================================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner (taquera@sherito.org);
*
* (C) Copyright 2003, by Heiko Evermann (heiko@evermann.de) and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
package org.jfree.designer.db;
import java.util.ArrayList;
import org.jfree.ui.SortableTableModel;
/**
* @author hev
* <p/>
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates. To enable and disable the creation of type
* comments go to Window>Preferences>Java>Code Generation.
*/
public final class DBConnectionsTableModel
extends SortableTableModel
{
private final ArrayList dbConnections;
public DBConnectionsTableModel ()
{
dbConnections = new ArrayList();
}
public final void setModell (final ArrayList newList)
{
if (newList == null)
{
throw new NullPointerException();
}
dbConnections.clear();
dbConnections.addAll(newList);
}
public final void addDBConnection (final ConnectionEntry dbConnection)
{
if (dbConnection == null)
{
throw new NullPointerException();
}
dbConnections.add(dbConnection);
fireTableDataChanged();
}
public final void removeDBConnection (final int nIdx)
{
dbConnections.remove(nIdx);
fireTableDataChanged();
}
public final int getRowCount ()
{
return dbConnections.size();
}
/**
* @see javax.swing.table.TableModel#getColumnCount()
*/
public final int getColumnCount ()
{
return 3;
}
/**
* Returns the name of the specified column.
*/
public final String getColumnName (final int columnIndex)
{
switch (columnIndex)
{
case 0:
return "Connection name";
case 1:
return "User name";
case 2:
return "URL";
default:
throw new IndexOutOfBoundsException();
}
}
/**
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
public final Object getValueAt (final int rowIndex, final int columnIndex)
{
final ConnectionEntry entry = (ConnectionEntry) dbConnections.get(rowIndex);
switch (columnIndex)
{
case 0:
return entry.getName();
case 1:
return entry.getUsername();
case 2:
return entry.getUrl();
default:
throw new IndexOutOfBoundsException();
}
}
public final ConnectionEntry getDBConnection (final int rowIndex)
{
return (ConnectionEntry) dbConnections.get(rowIndex);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -