Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 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.editor.datanode;
 import  org.apache.cayenne.project.ProjectDataSource;
 public class JDBCDataSourceEditor extends DataSourceEditor {
     protected JDBCDataSourceView view;
     public JDBCDataSourceEditor(ProjectController parent,
             BindingDelegate nodeChangeProcessor) {
     public Component getView() {
         return ;
     protected void prepareBindings(BindingBuilder builder) {
         this. = new JDBCDataSourceView();
          = new ObjectBinding[6];
         [0] =
           builder.bindToTextField(.getUserName(), "node.dataSource.dataSourceInfo.userName");
         [1] =
           builder.bindToTextField(.getPassword(), "node.dataSource.dataSourceInfo.password");
         [2] =
           builder.bindToTextField(.getUrl(), "node.dataSource.dataSourceInfo.dataSourceUrl");
         [3] =
           builder.bindToTextField(.getDriver(), "node.dataSource.dataSourceInfo.jdbcDriver");
         [4] =
           builder.bindToTextField(.getMaxConnections(), "node.dataSource.dataSourceInfo.maxConnections");
         [5] =
           builder.bindToTextField(.getMinConnections(), "node.dataSource.dataSourceInfo.minConnections");
         builder.bindToAction(.getSyncWithLocal(),    "syncDataSourceAction()");

This action is called whenever the password location is changed in the GUI pulldown. It changes labels and editability of the password fields depending on the option that was selected.
     public void syncDataSourceAction() {
         CayenneModelerController mainController = getApplication().getFrameController();
         if (getNode() == null || getNode().getDataSource() == null) {
         ProjectDataSource projectDS = (ProjectDataSource) getNode().getDataSource();
         ProjectController parent = (ProjectControllergetParent();
         String key = parent.getDataNodePreferences().getLocalDataSource();
         if (key == null) {
             mainController.updateStatus("No Local DataSource selected for node...");
         DBConnectionInfo dataSource = (DBConnectionInfoparent
         if (dataSource != null) {
             if (dataSource.copyTo(projectDS.getDataSourceInfo())) {
            else {
                mainController.updateStatus("DataNode is up to date...");
        else {
            mainController.updateStatus("Invalid Local DataSource selected for node...");
New to GrepCode? Check out our FAQ X