Skip to content
Permalink
Browse files
Generalized more dispatch code.
  • Loading branch information
mrg committed Jun 8, 2017
1 parent 039d075 commit 4b66c8b1f5e76f1c3f5cab0c724b6a9f6747b53e
Showing 14 changed files with 303 additions and 231 deletions.
@@ -20,12 +20,13 @@
package org.apache.cayenne.modeler.layout;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.cayenne.access.DataRowStore;
import org.apache.cayenne.event.JMSBridgeFactory;
import org.apache.cayenne.event.JavaGroupsBridgeFactory;
import org.apache.cayenne.modeler.adapters.DataDomainAdapter;
import org.apache.cayenne.modeler.notification.NotificationCenter;
import org.apache.cayenne.modeler.notification.event.DataDomainChangeEvent;
import org.apache.cayenne.modeler.notification.listener.DataDomainListener;
import org.apache.commons.lang3.StringUtils;
@@ -82,6 +83,8 @@

private DataDomainAdapter dataDomainAdapter;

private List<Binding<?>> bindings;

// Remote Change Notification groups.
private static final String RCN_NONE = "None";
private static final String RCN_JAVA_GROUPS = "JavaGroups Multicast";
@@ -155,97 +158,74 @@ public void setPropertyAdapter(final DataDomainAdapter dataDomainAdapter)
}

@Override
public void beginEditing()
public void initializeBindings()
{
LOGGER.debug("begin editing " + this);

// show(javaGroupsConfiguration, jmsConfiguration, customConfiguration);
bindings = new ArrayList<>();

nameTextField.textProperty().bindBidirectional(dataDomainAdapter.nameProperty());
objectValidationCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.validatingObjectsProperty());
bindings.add(new Binding<>(nameTextField.textProperty(), dataDomainAdapter.nameProperty()));
bindings.add(new Binding<>(objectValidationCheckBox.selectedProperty(), dataDomainAdapter.validatingObjectsProperty()));
bindings.add(new Binding<>(objectCacheSizeSpinner.getValueFactory().valueProperty(), dataDomainAdapter.sizeOfObjectCacheProperty().asObject()));
bindings.add(new Binding<>(useSharedCacheCheckBox.selectedProperty(), dataDomainAdapter.useSharedCacheProperty()));

objectCacheSizeSpinner.getValueFactory().valueProperty().bindBidirectional(dataDomainAdapter.sizeOfObjectCacheProperty().asObject());
useSharedCacheCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.useSharedCacheProperty());
// remoteChangeNotificationsCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.remoteChangeNotificationsProperty());

configureRemoteNotifications(dataDomainAdapter.getUseSharedCache());
bindings.add(new Binding<>(customTransportFactoryClass.textProperty(), dataDomainAdapter.eventBridgeFactoryProperty()));
bindings.add(new Binding<>(multicastAddressTextField.textProperty(), dataDomainAdapter.javaGroupsMulticastAddressProperty()));
bindings.add(new Binding<>(multicastPortTextField.textProperty(), dataDomainAdapter.javaGroupsMulticastPortProperty()));
bindings.add(new Binding<>(jmsConnectionFactoryNameTextField.textProperty(), dataDomainAdapter.jmsConnectionFactoryProperty()));
}

customTransportFactoryClass.textProperty().bindBidirectional(dataDomainAdapter.eventBridgeFactoryProperty());
multicastAddressTextField.textProperty().bindBidirectional(dataDomainAdapter.javaGroupsMulticastAddressProperty());
multicastPortTextField.textProperty().bindBidirectional(dataDomainAdapter.javaGroupsMulticastPortProperty());
jmsConnectionFactoryNameTextField.textProperty().bindBidirectional(dataDomainAdapter.jmsConnectionFactoryProperty());
@Override
public List<Binding<?>> getBindings()
{
return bindings;
}

@Deprecated
private void beginEditingNotCalled()
@Override
public void beginEditing()
{
LOGGER.debug("begin editing");
// LOGGER.debug("begin editing " + this);
DetailEditorSupport.super.beginEditing();
// show(javaGroupsConfiguration, jmsConfiguration, customConfiguration);

nameTextField.setText(getMainWindow().getCayenneProject().getDataDomainName());
nameTextField.textProperty().addListener((observable, oldValue, newValue) ->
{
getMainWindow().getCayenneProject().setDataDomainName(newValue);
final DataDomainChangeEvent ddce = new DataDomainChangeEvent(getMainWindow().getCayenneProject(), this, DataDomainChangeEvent.Type.NAME, oldValue, newValue);
NotificationCenter.broadcastProjectEvent(getMainWindow().getCayenneProject(), ddce);
// System.out.println("DataDomain Name Text Changed (newValue: " + newValue + ")");
});
// nameTextField.textProperty().bindBidirectional(dataDomainAdapter.nameProperty());
// objectValidationCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.validatingObjectsProperty());

objectValidationCheckBox.setSelected(getMainWindow().getCayenneProject().isDataDomainValidatingObjects());
objectValidationCheckBox.setOnAction((event) ->
{
final Boolean selected = objectValidationCheckBox.isSelected();
getMainWindow().getCayenneProject().setDataDomainValidatingObjects(selected);
final DataDomainChangeEvent ddce = new DataDomainChangeEvent(getMainWindow().getCayenneProject(), this, DataDomainChangeEvent.Type.VALIDATION, !selected, selected);
NotificationCenter.broadcastProjectEvent(getMainWindow().getCayenneProject(), ddce);
});
// objectCacheSizeSpinner.getValueFactory().valueProperty().bindBidirectional(dataDomainAdapter.sizeOfObjectCacheProperty().asObject());
// useSharedCacheCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.useSharedCacheProperty());
// remoteChangeNotificationsCheckBox.selectedProperty().bindBidirectional(dataDomainAdapter.remoteChangeNotificationsProperty());

configureRemoteNotifications(dataDomainAdapter.getUseSharedCache());

// BeanPathAdapter<CayenneModel> dataDomainAdapter = getDataDomainPropertyAdapterMap(getMainWindow().getCayenneModel());
// customTransportFactoryClass.textProperty().bindBidirectional(dataDomainAdapter.eventBridgeFactoryProperty());
// multicastAddressTextField.textProperty().bindBidirectional(dataDomainAdapter.javaGroupsMulticastAddressProperty());
// multicastPortTextField.textProperty().bindBidirectional(dataDomainAdapter.javaGroupsMulticastPortProperty());
// jmsConnectionFactoryNameTextField.textProperty().bindBidirectional(dataDomainAdapter.jmsConnectionFactoryProperty());
}

// @Override
// public void endEditing()
// {
// LOGGER.debug("end editing " + this);
//
// dataDomainAdapter.bindBidirectional("dataDomainName", dataDomainNameTextField.textProperty());
// dataDomainAdapter.bindBidirectional("dataDomainValidatingObjects", objectValidationCheckBox.selectedProperty());
// nameTextField.textProperty().unbindBidirectional(dataDomainAdapter.nameProperty());
// objectValidationCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.validatingObjectsProperty());
//
//// new ChangeListener<FieldPathValue>() {
//// @Override
//// public void changed(
//// ObservableValue<? extends FieldPathValue> observable,
//// FieldPathValue oldValue,
//// FieldPathValue newValue) {
//// dumpPojo(oldValue, newValue, personPA);
//// }
//// });
// objectCacheSizeSpinner.getValueFactory().valueProperty().unbindBidirectional(dataDomainAdapter.sizeOfObjectCacheProperty().asObject());
// useSharedCacheCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.useSharedCacheProperty());
//// remoteChangeNotificationsCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.remoteChangeNotificationsProperty());
//
// dataDomainAdapter.fieldPathValueProperty().addListener(changeObserver);

// Register for notifications.
NotificationCenter.addProjectListener(getMainWindow().getCayenneProject(), this);
}

@Override
public void endEditing()
{
LOGGER.debug("end editing " + this);

nameTextField.textProperty().unbindBidirectional(dataDomainAdapter.nameProperty());
objectValidationCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.validatingObjectsProperty());

objectCacheSizeSpinner.getValueFactory().valueProperty().unbindBidirectional(dataDomainAdapter.sizeOfObjectCacheProperty().asObject());
useSharedCacheCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.useSharedCacheProperty());
// remoteChangeNotificationsCheckBox.selectedProperty().unbindBidirectional(dataDomainAdapter.remoteChangeNotificationsProperty());

customTransportFactoryClass.textProperty().unbindBidirectional(dataDomainAdapter.eventBridgeFactoryProperty());
multicastAddressTextField.textProperty().unbindBidirectional(dataDomainAdapter.javaGroupsMulticastAddressProperty());
multicastPortTextField.textProperty().unbindBidirectional(dataDomainAdapter.javaGroupsMulticastPortProperty());
jmsConnectionFactoryNameTextField.textProperty().unbindBidirectional(dataDomainAdapter.jmsConnectionFactoryProperty());

// NotificationCenter.removeProjectListener(getMainWindow().getCayenneProject(), this);
//// BeanPathAdapter<CayenneModel> dataDomainAdapter = getDataDomainPropertyAdapterMap(getMainWindow().getCayenneModel());
////
//// dataDomainAdapter.fieldPathValueProperty().removeListener(changeObserver);
////
//// dataDomainAdapter.unBindBidirectional("dataDomainName", dataDomainNameTextField.textProperty());
//// dataDomainAdapter.unBindBidirectional("dataDomainValidatingObjects", objectValidationCheckBox.selectedProperty());
}
// customTransportFactoryClass.textProperty().unbindBidirectional(dataDomainAdapter.eventBridgeFactoryProperty());
// multicastAddressTextField.textProperty().unbindBidirectional(dataDomainAdapter.javaGroupsMulticastAddressProperty());
// multicastPortTextField.textProperty().unbindBidirectional(dataDomainAdapter.javaGroupsMulticastPortProperty());
// jmsConnectionFactoryNameTextField.textProperty().unbindBidirectional(dataDomainAdapter.jmsConnectionFactoryProperty());
//
//// NotificationCenter.removeProjectListener(getMainWindow().getCayenneProject(), this);
////// BeanPathAdapter<CayenneModel> dataDomainAdapter = getDataDomainPropertyAdapterMap(getMainWindow().getCayenneModel());
//////
////// dataDomainAdapter.fieldPathValueProperty().removeListener(changeObserver);
//////
////// dataDomainAdapter.unBindBidirectional("dataDomainName", dataDomainNameTextField.textProperty());
////// dataDomainAdapter.unBindBidirectional("dataDomainValidatingObjects", objectValidationCheckBox.selectedProperty());
// }


@Override
@@ -20,6 +20,8 @@
package org.apache.cayenne.modeler.layout;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy;
import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
@@ -33,7 +35,6 @@

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
@@ -86,6 +87,8 @@
private DataNodeAdapter dataNodeAdapter;
// private final DataNodeLayout parent;

private List<Binding<?>> bindings;

private static final String[] standardSchemaUpdateStrategies =
{
SkipSchemaUpdateStrategy.class.getName(),
@@ -162,11 +165,11 @@ public void initializeLayout()
});
}

public void tabChanged(final Event event)
{
LOGGER.debug("event: " + event);
getMainWindow().getCayenneProject().getDataMaps();
}
// public void tabChanged(final Event event)
// {
// LOGGER.debug("event: " + event);
// getMainWindow().getCayenneProject().getDataMaps();
// }

@Override
public void setPropertyAdapter(final DataNodeAdapter dataNodeAdapter)
@@ -175,14 +178,28 @@ public void setPropertyAdapter(final DataNodeAdapter dataNodeAdapter)
}

@Override
public void beginEditing()
public void initializeBindings()
{
nameTextField.textProperty().bindBidirectional(dataNodeAdapter.nameProperty());
bindings = new ArrayList<>();

bindings.add(new Binding<>(nameTextField.textProperty(), dataNodeAdapter.nameProperty()));
}

@Override
public void endEditing()
public List<Binding<?>> getBindings()
{
nameTextField.textProperty().unbindBidirectional(dataNodeAdapter.nameProperty());
return bindings;
}

// @Override
// public void beginEditing()
// {
// nameTextField.textProperty().bindBidirectional(dataNodeAdapter.nameProperty());
// }
//
// @Override
// public void endEditing()
// {
// nameTextField.textProperty().unbindBidirectional(dataNodeAdapter.nameProperty());
// }
}
@@ -25,8 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javafx.event.Event;

public class DataNodeDatabaseAdapterTabLayout
extends AbstractViewLayout
implements DetailEditorSupport<DataNodeAdapter>
@@ -47,25 +45,25 @@ public DataNodeDatabaseAdapterTabLayout(final MainWindowSupport parentComponent)
// super.initializeView();
// }

public void tabChanged(final Event event)
{
LOGGER.debug("event: " + event);
getMainWindow().getCayenneProject().getDataMaps();
}
// public void tabChanged(final Event event)
// {
// LOGGER.debug("event: " + event);
// getMainWindow().getCayenneProject().getDataMaps();
// }

@Override
public void setPropertyAdapter(final DataNodeAdapter dataNodeAdapter)
{
this.dataNodeAdapter = dataNodeAdapter;
}

@Override
public void beginEditing()
{
}

@Override
public void endEditing()
{
}
// @Override
// public void beginEditing()
// {
// }
//
// @Override
// public void endEditing()
// {
// }
}
@@ -25,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.Tab;
import javafx.scene.layout.AnchorPane;
@@ -83,36 +82,40 @@ public void setPropertyAdapter(final DataNodeAdapter dataNodeAdapter)
{
this.dataNodeAdapter = dataNodeAdapter;

dataNodeConfigurationTabLayout.setPropertyAdapter(dataNodeAdapter);
dataNodeDatabaseAdapterTabLayout.setPropertyAdapter(dataNodeAdapter);
dataNodePasswordEncoderTabLayout.setPropertyAdapter(dataNodeAdapter);
// dataNodeConfigurationTabLayout.setPropertyAdapter(dataNodeAdapter);
// dataNodeDatabaseAdapterTabLayout.setPropertyAdapter(dataNodeAdapter);
// dataNodePasswordEncoderTabLayout.setPropertyAdapter(dataNodeAdapter);
}

@Override
public void beginEditing()
{
LOGGER.debug("begin editing " + this);
DetailEditorSupport.super.beginEditing();

dataNodeConfigurationTabLayout.beginEditing();
dataNodeDatabaseAdapterTabLayout.beginEditing();
dataNodePasswordEncoderTabLayout.beginEditing();
dataNodeConfigurationTabLayout.showEditor(dataNodeAdapter);
dataNodeDatabaseAdapterTabLayout.showEditor(dataNodeAdapter);
dataNodePasswordEncoderTabLayout.showEditor(dataNodeAdapter);

// dataNodeConfigurationTabLayout.beginEditing();
// dataNodeDatabaseAdapterTabLayout.beginEditing();
// dataNodePasswordEncoderTabLayout.beginEditing();
}

@Override
public void endEditing()
{
LOGGER.debug("end editing " + this);
DetailEditorSupport.super.endEditing();

dataNodeConfigurationTabLayout.endEditing();
dataNodeDatabaseAdapterTabLayout.endEditing();
dataNodePasswordEncoderTabLayout.endEditing();
}

public void tabChanged(final Event event)
{
LOGGER.debug("event: " + event);
getMainWindow().getCayenneProject().getDataMaps();
}
// public void tabChanged(final Event event)
// {
// LOGGER.debug("event: " + event);
// getMainWindow().getCayenneProject().getDataMaps();
// }

public void disablePasswordEncoderTab()
{
@@ -110,13 +110,13 @@ public void setPropertyAdapter(final DataNodeAdapter dataNodeAdapter)
this.dataNodeAdapter = dataNodeAdapter;
}

@Override
public void beginEditing()
{
}

@Override
public void endEditing()
{
}
// @Override
// public void beginEditing()
// {
// }
//
// @Override
// public void endEditing()
// {
// }
}

0 comments on commit 4b66c8b

Please sign in to comment.