当前位置: 首页>>代码示例>>Java>>正文


Java DataSourceCollection类代码示例

本文整理汇总了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();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:DataSourceTypeCopyPropertiesPanel.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:21,代码来源:DataSourceTypeCopyPropertiesPanelTest.java

示例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");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:21,代码来源:SQLTableLazyLoadTest.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:23,代码来源:RefreshTablesTest.java

示例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;
		}
	}
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:19,代码来源:DatabaseConnectedTestCase.java

示例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");
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:20,代码来源:DBTestUtil.java

示例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;
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:17,代码来源:DQguruEngineRunner.java

示例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);
       }
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:51,代码来源:WabitSessionContextImpl.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:10,代码来源:SwingUIUserPrompterFactory.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:11,代码来源:ConnectionComboBoxModel.java

示例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);
  }
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:50,代码来源:DataSourceTypeEditorPanel.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:13,代码来源:DatabaseConnectionManager.java

示例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();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:37,代码来源:NewDataSourceTypePanel.java

示例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);
    }
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:13,代码来源:DataSourceCollectionUpdater.java

示例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);
    }
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:13,代码来源:DataSourceCollectionUpdater.java


注:本文中的ca.sqlpower.sql.DataSourceCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。