本文整理汇总了Java中ca.sqlpower.sql.DataSourceCollection类的典型用法代码示例。如果您正苦于以下问题:Java DataSourceCollection类的具体用法?Java DataSourceCollection怎么用?Java DataSourceCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataSourceCollection类属于ca.sqlpower.sql包,在下文中一共展示了DataSourceCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataSourceTypeCopyPropertiesPanel
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
public DataSourceTypeCopyPropertiesPanel(JDBCDataSourceType type, DataSourceCollection collection) {
this.dsType = type;
List<JDBCDataSourceType> types = new ArrayList<JDBCDataSourceType>(collection.getDataSourceTypes());
types.remove(dsType);
dsTypesComboBox = new JComboBox(types.toArray());
dsTypesComboBox.setRenderer(new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel && value != null) {
((JLabel) c).setText(((JDBCDataSourceType) value).getName());
}
return c;
}
});
panel = buildUI();
}
示例2: setUp
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
dsType = new JDBCDataSourceType();
dsType.setName("Testing DS Name Shouldn't Change");
DataSourceCollection collection = new StubDataSourceCollection();
JDBCDataSourceType firstDSType = new JDBCDataSourceType();
firstDSType.setJdbcUrl("First Testing URL");
firstDSType.putProperty(JDBCDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS, String.valueOf(true));
firstDSType.setComment("First testing comment");
collection.addDataSourceType(firstDSType);
JDBCDataSourceType secondDSType = new JDBCDataSourceType();
secondDSType.setJdbcUrl("Second Testing URL");
secondDSType.putProperty(JDBCDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS, String.valueOf(false));
secondDSType.setComment("Second testing comment");
dsTypeCopyPanel = new DataSourceTypeCopyPropertiesPanel(dsType, collection);
}
示例3: setUp
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Sets up a MockJDBC database with one table in it called "table".
*/
@Override
protected void setUp() throws Exception {
logger.debug("=====setUp=====");
super.setUp();
DataSourceCollection<SPDataSource> dscol = new PlDotIni();
JDBCDataSourceType dstype = new JDBCDataSourceType();
dstype.setJdbcDriver("ca.sqlpower.testutil.MockJDBCDriver");
JDBCDataSource ds = new JDBCDataSource(dscol);
ds.setParentType(dstype);
ds.setUrl("jdbc:mock:name=refresh_test&tables=table");
ds.setUser("");
ds.setPass("");
db = new SQLDatabase(ds);
db.getConnection().close(); // just make sure the connection gets made
table = db.getTableByName("table");
}
示例4: setUp
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Sets up a MockJDBC database with nothing in it. Individual tests can specify
* the structure as required.
*/
@Override
protected void setUp() throws Exception {
logger.debug("=====setUp=====");
super.setUp();
DataSourceCollection<SPDataSource> dscol = new PlDotIni();
JDBCDataSourceType dstype = new JDBCDataSourceType();
dstype.setJdbcDriver("ca.sqlpower.testutil.MockJDBCDriver");
JDBCDataSource ds = new JDBCDataSource(dscol);
ds.setParentType(dstype);
ds.setUrl("jdbc:mock:name=refresh_test");
ds.setUser("");
ds.setPass("");
db = new SQLDatabase(ds);
db.getConnection().close(); // just make sure the connection gets made
con = MockJDBCDriver.getConnection("refresh_test");
assertNotNull(con);
}
示例5: tearDown
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
if (setupDB) {
try {
sqlx("SHUTDOWN");
db.disconnect();
db = null;
} catch (Exception ex) {
System.err.println("Shutdown failed. Test case probably modified the database connection! Retrying...");
DataSourceCollection<SPDataSource> dscol = new PlDotIni();
dscol.read(new File("pl.regression.ini"));
db.setDataSource(dscol.getDataSource("regression_test", JDBCDataSource.class));
sqlx("SHUTDOWN");
db.disconnect();
db = null;
}
}
}
示例6: getOracleDS
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Returns a new SPDataSource which is configured to connect to
* our Oracle 8i test database. The PL schema is in mm_test.
*/
public static JDBCDataSource getOracleDS() {
/*
* Setup information for Oracle
*/
DataSourceCollection<JDBCDataSource> pl = new SpecificDataSourceCollection<JDBCDataSource>(new PlDotIni(), JDBCDataSource.class);
try {
pl.read(new File("testbed/pl.regression.ini"));
} catch (IOException e) {
throw new RuntimeException("Could not read from the pl.regression.ini file", e);
}
logger.debug("data source type name for Test Oracle is " + pl.getDataSource("Test Oracle").getParentType().getName());
return pl.getDataSource("Test Oracle");
}
示例7: readPlDotIni
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
private static DataSourceCollection<JDBCDataSource> readPlDotIni(String plDotIniPath) throws IOException {
if (plDotIniPath == null) {
return null;
}
File pf = new File(plDotIniPath);
if (!pf.exists() || !pf.canRead()) {
return null;
}
DataSourceCollection pld = new PlDotIni();
// First, read the defaults
pld.read(SwingSessionContextImpl.class.getClassLoader().getResourceAsStream("ca/sqlpower/sql/default_database_types.ini"));
// Now, merge in the user's own config
pld.read(pf);
return pld;
}
示例8: WabitSessionContextImpl
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Creates a new Wabit session context.
*
* @param terminateWhenLastSessionCloses
* If this flag is true, this session context will halt the VM
* when its last session closes.
* @param useJmDNS
* If this flag is true, then this session will create a JmDNS
* instance for searching for Wabit servers.
* @param initialCollection
* The default collection of data sources for this context.
* @param dataSourceCollectionPath
* The path to the file representing the data source collection.
* This will be used to write changes to the collection to save
* the collection's state. If this is null then no data source
* collection files will be modified.
* @param writeDSCollectionPathToPrefs
* If true the location of the data source collection file will
* be saved to Java Prefs. If false the current location of the
* data source collection file will be left as is.
* @throws IOException
* If the startup configuration files can't be read
* @throws SQLObjectException
* If the pl.ini is invalid.
*/
public WabitSessionContextImpl(boolean terminateWhenLastSessionCloses, boolean useJmDNS,
DataSourceCollection<SPDataSource> initialCollection,
String dataSourceCollectionPath, boolean writeDSCollectionPathToPrefs)
throws IOException, SQLObjectException {
this.terminateWhenLastSessionCloses = terminateWhenLastSessionCloses;
dataSources = initialCollection;
this.writeDSCollectionPathToPrefs = writeDSCollectionPathToPrefs;
setPlDotIniPath(dataSourceCollectionPath);
if (useJmDNS) {
try {
jmdns = JmDNS.create();
} catch (Exception e) {
jmdns = null;
}
} else {
jmdns = null;
}
try {
manuallyConfiguredServers.addAll(readServersFromPrefs());
} catch (BackingStoreException ex) {
logger.error("Preferences unavailable! Not reading server infos from prefs.", ex);
}
}
示例9: createDatabaseUserPrompter
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
public UserPrompter createDatabaseUserPrompter(String question,
List<Class<? extends SPDataSource>> dsTypes,
UserPromptOptions optionType,
UserPromptResponse defaultResponseType, Object defaultResponse,
DataSourceCollection<SPDataSource> dsCollection,
String... buttonNames) {
return new DataSourceUserPrompter(question, optionType, defaultResponseType, (SPDataSource) defaultResponse,
owner, question, dsCollection, dsTypes, buttonNames);
}
示例10: ConnectionComboBoxModel
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Setup a new connection combo box model with the conections found in the
* PPLDotIni
*/
public ConnectionComboBoxModel(DataSourceCollection plini) {
this.plini = plini;
listenerList = new ArrayList<ListDataListener>();
connections = plini.getConnections();
plini.addDatabaseListChangeListener(this);
}
示例11: DataSourceTypeEditorPanel
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Creates a multi-tabbed panel with facilities for configuring all the
* database types defined in a particular data source collection.
*
* @param collection
* The data source collection to edit.
* @param serverBaseURI
* The base URI to the server the JDBC driver JAR files may be
* stored on. If the data source collection doesn't refer to any
* JAR files on a server, this URI may be specified as null.
* @param owner The Window that should own any dialogs created within the editor GUI.
* @see DataSourceTypeEditor
* @see DefaultDataSourceTypeDialogFactory
*/
public DataSourceTypeEditorPanel(final DataSourceCollection collection, final Window owner) {
jdbcPanel = new JDBCDriverPanel(collection.getServerBaseURI());
jdbcPanel.addDriverTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (e.getNewLeadSelectionPath() != null && e.getNewLeadSelectionPath().getPathCount() > JDBCDriverPanel.DRIVER_LEVEL) {
driverClass.setText(e.getNewLeadSelectionPath().getLastPathComponent().toString());
}
}
});
copyPropertiesButton = new JButton(new AbstractAction("Copy Properties...") {
public void actionPerformed(ActionEvent e) {
final DataSourceTypeCopyPropertiesPanel copyPropertiesPanel = new DataSourceTypeCopyPropertiesPanel(dsType, collection);
final JDialog d = DataEntryPanelBuilder.createDataEntryPanelDialog(
copyPropertiesPanel,
owner,
"Copy Properties",
DataEntryPanelBuilder.OK_BUTTON_LABEL);
d.pack();
d.setLocationRelativeTo(owner);
d.setVisible(true);
d.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
editDsType(dsType);
}
});
}
});
buildPanel();
editDsType(null);
}
示例12: DatabaseConnectionManager
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
/**
* Creates a new database connection manager with the default data source
* and data source type dialog factories.
*
* @param dsCollection The data source collection to manage
*/
public DatabaseConnectionManager(DataSourceCollection<SPDataSource> dsCollection) {
this(dsCollection,
new DefaultDataSourceDialogFactory(),
new DefaultDataSourceTypeDialogFactory(dsCollection),
(List<Action>) Collections.EMPTY_LIST);
}
示例13: NewDataSourceTypePanel
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
public NewDataSourceTypePanel(DataSourceTypeEditor editor, DataSourceCollection collection) {
this.editor = editor;
this.dsType = new JDBCDataSourceType();
dsType.setName(Messages.getString("DataSourceTypeEditor.defaultDataSourceName")); //$NON-NLS-1$
existingDSTypes = new JComboBox(collection.getDataSourceTypes().toArray());
existingDSTypes.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel && value != null) {
((JLabel) c).setText(((JDBCDataSourceType) value).getName());
}
return c;
}
});
blankOption = new JRadioButton(new AbstractAction("Blank") {
public void actionPerformed(ActionEvent e) {
existingDSTypes.setEnabled(false);
}
});
copyOption = new JRadioButton(new AbstractAction("Copy defaults from..") {
public void actionPerformed(ActionEvent e) {
existingDSTypes.setEnabled(true);
}
});
ButtonGroup optionGroup = new ButtonGroup();
optionGroup.add(blankOption);
optionGroup.add(copyOption);
blankOption.setSelected(true);
existingDSTypes.setEnabled(false);
panel = buildUI();
}
示例14: attach
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
public void attach(DataSourceCollection<JDBCDataSource> dsCollection) {
dsCollection.addDatabaseListChangeListener(this);
dsCollection.addUndoableEditListener(this);
for (JDBCDataSourceType jdst : dsCollection.getDataSourceTypes()) {
jdst.addPropertyChangeListener(this);
}
for (SPDataSource ds : dsCollection.getConnections()) {
ds.addPropertyChangeListener(this);
}
}
示例15: detach
import ca.sqlpower.sql.DataSourceCollection; //导入依赖的package包/类
public void detach(DataSourceCollection<JDBCDataSource> dsCollection) {
dsCollection.removeDatabaseListChangeListener(this);
dsCollection.removeUndoableEditListener(this);
for (JDBCDataSourceType jdst : dsCollection.getDataSourceTypes()) {
jdst.removePropertyChangeListener(this);
}
for (SPDataSource ds : dsCollection.getConnections()) {
ds.removePropertyChangeListener(this);
}
}