
org.apache.cayenne.modeler.dialog.pref.DataSourcePreferences Maven / Gradle / Ivy
/*****************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
****************************************************************/
package org.apache.cayenne.modeler.dialog.pref;
import java.awt.Component;
import java.io.File;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.prefs.Preferences;
import java.util.stream.Collectors;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import org.apache.cayenne.datasource.DriverDataSource;
import org.apache.cayenne.map.event.MapEvent;
import org.apache.cayenne.modeler.FileClassLoadingService;
import org.apache.cayenne.modeler.event.DataSourceModificationEvent;
import org.apache.cayenne.modeler.pref.DBConnectionInfo;
import org.apache.cayenne.modeler.util.CayenneController;
import org.apache.cayenne.pref.CayennePreferenceEditor;
import org.apache.cayenne.pref.ChildrenMapPreference;
import org.apache.cayenne.pref.PreferenceEditor;
import org.apache.cayenne.swing.BindingBuilder;
import org.apache.cayenne.util.Util;
/**
* Editor for the local DataSources configured in preferences.
*
*/
public class DataSourcePreferences extends CayenneController {
protected DataSourcePreferencesView view;
protected String dataSourceKey;
protected Map dataSources;
protected ChildrenMapPreference dataSourcePreferences;
protected CayennePreferenceEditor editor;
public DataSourcePreferences(PreferenceDialog parentController) {
super(parentController);
this.view = new DataSourcePreferencesView(this);
PreferenceEditor editor = parentController.getEditor();
if (editor instanceof CayennePreferenceEditor) {
this.editor = (CayennePreferenceEditor) editor;
}
// init view data
this.dataSourcePreferences = getApplication().getCayenneProjectPreferences().getDetailObject(
DBConnectionInfo.class);
this.dataSources = dataSourcePreferences.getChildrenPreferences();
Object[] keys = dataSources.keySet().toArray();
Arrays.sort(keys);
DefaultComboBoxModel
© 2015 - 2025 Weber Informatics LLC | Privacy Policy