From fe095f69f00c570f266a5d7d418356b892d2e488 Mon Sep 17 00:00:00 2001 From: Brian Vosburgh Date: Wed, 27 Jul 2016 15:12:58 -0400 Subject: rename PropertyPluggablePropertyValueModelAdapter to TransformationPluggablePropertyValueModelAdapter --- ...PropertyPluggablePropertyValueModelAdapter.java | 134 --------------------- .../model/value/PropertyValueModelTools.java | 16 +-- ...ormationPluggablePropertyValueModelAdapter.java | 134 +++++++++++++++++++++ .../model/value/swing/RadioButtonModelAdapter.java | 2 +- 4 files changed, 143 insertions(+), 143 deletions(-) delete mode 100644 common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyPluggablePropertyValueModelAdapter.java create mode 100644 common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPluggablePropertyValueModelAdapter.java diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyPluggablePropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyPluggablePropertyValueModelAdapter.java deleted file mode 100644 index e09258e8c3..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyPluggablePropertyValueModelAdapter.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.internal.model.value; - -import org.eclipse.jpt.common.utility.internal.ObjectTools; -import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.transformer.Transformer; - -/** - * Adapt a {@link PropertyValueModel property value model} to - * another {@link PropertyValueModel property value model}, sorta. - *

- * This adapter is constructed with a {@link PropertyValueModel - * property value model} and a {@link Transformer transformer} that can - * transform the wrapped model's value to this model's derived value. - *

- * This is an adapter that can be used by a {@link PluggablePropertyValueModel}. - * - * @param the type of the wrapped model's value - * @param the type of the model's derived value - * - * @see PluggablePropertyValueModel - */ -public final class PropertyPluggablePropertyValueModelAdapter - implements PluggablePropertyValueModel.Adapter, PropertyChangeListener -{ - /** The wrapped model */ - private final PropertyValueModel propertyModel; - - /** Transformer that converts the wrapped model's value to this model's value. */ - private final Transformer transformer; - - /** The real adapter. */ - private final BasePluggablePropertyValueModel.Adapter.Listener listener; - - /** Cached copy of model's value. */ - /* package */ volatile V1 propertyModelValue; - - - // ********** constructors ********** - - public PropertyPluggablePropertyValueModelAdapter(Factory factory, BasePluggablePropertyValueModel.Adapter.Listener listener) { - super(); - if (factory == null) { - throw new NullPointerException(); - } - this.propertyModel = factory.propertyModel; - this.transformer = factory.transformer; - if (listener == null) { - throw new NullPointerException(); - } - this.listener = listener; - } - - - // ********** BasePluggablePropertyValueModel.Adapter ********** - - public V2 engageModel() { - this.propertyModel.addPropertyChangeListener(PropertyValueModel.VALUE, this); - this.propertyModelValue = this.propertyModel.getValue(); - return this.buildValue(); - } - - public V2 disengageModel() { - this.propertyModel.removePropertyChangeListener(PropertyValueModel.VALUE, this); - this.propertyModelValue = null; - return null; - } - - - // ********** PropertyChangeListener ********** - - @SuppressWarnings("unchecked") - public void propertyChanged(PropertyChangeEvent event) { - this.propertyModelValue = (V1) event.getNewValue(); - this.update(); - } - - - // ********** misc ********** - - private void update() { - this.listener.valueChanged(this.buildValue()); - } - - private V2 buildValue() { - return this.transformer.transform(this.propertyModelValue); - } - - @Override - public String toString() { - return ObjectTools.toString(this, this.buildValue()); - } - - - // ********** Factory ********** - - public static class Factory - implements PluggablePropertyValueModel.Adapter.Factory - { - /* CU private */ final PropertyValueModel propertyModel; - /* CU private */ final Transformer transformer; - - public Factory(PropertyValueModel propertyModel, Transformer transformer) { - super(); - if (propertyModel == null) { - throw new NullPointerException(); - } - this.propertyModel = propertyModel; - if (transformer == null) { - throw new NullPointerException(); - } - this.transformer = transformer; - } - - public PropertyPluggablePropertyValueModelAdapter buildAdapter(BasePluggablePropertyValueModel.Adapter.Listener listener) { - return new PropertyPluggablePropertyValueModelAdapter<>(this, listener); - } - - @Override - public String toString() { - return ObjectTools.toString(this); - } - } -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java index 1a50efd17f..f95fe94520 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java @@ -561,7 +561,7 @@ public final class PropertyValueModelTools { PropertyValueModel propertyModel, Transformer transformer ) { - return propertyValueModel(pluggablePropertyValueModelAdapterFactory(propertyModel, transformer)); + return propertyValueModel(transformationPluggablePropertyValueModelAdapterFactory(propertyModel, transformer)); } /** @@ -577,7 +577,7 @@ public final class PropertyValueModelTools { PropertyValueModel propertyModel, Transformer transformer ) { - return propertyValueModel(pluggablePropertyValueModelAdapterFactory_(propertyModel, transformer)); + return propertyValueModel(transformationPluggablePropertyValueModelAdapterFactory_(propertyModel, transformer)); } /** @@ -630,7 +630,7 @@ public final class PropertyValueModelTools { Transformer transformer, Closure setValueClosure ) { - return pluggableModifiablePropertyValueModel(pluggablePropertyValueModelAdapterFactory(propertyModel, transformer), setValueClosure); + return pluggableModifiablePropertyValueModel(transformationPluggablePropertyValueModelAdapterFactory(propertyModel, transformer), setValueClosure); } /** @@ -647,7 +647,7 @@ public final class PropertyValueModelTools { Transformer transformer, Closure setValueClosure ) { - return pluggableModifiablePropertyValueModel(pluggablePropertyValueModelAdapterFactory_(propertyModel, transformer), setValueClosure); + return pluggableModifiablePropertyValueModel(transformationPluggablePropertyValueModelAdapterFactory_(propertyModel, transformer), setValueClosure); } /** @@ -659,11 +659,11 @@ public final class PropertyValueModelTools { * * @see PluggablePropertyValueModel */ - public static PluggablePropertyValueModel.Adapter.Factory pluggablePropertyValueModelAdapterFactory( + public static PluggablePropertyValueModel.Adapter.Factory transformationPluggablePropertyValueModelAdapterFactory( PropertyValueModel propertyModel, Transformer transformer ) { - return pluggablePropertyValueModelAdapterFactory_(propertyModel, TransformerTools.nullCheck(transformer)); + return transformationPluggablePropertyValueModelAdapterFactory_(propertyModel, TransformerTools.nullCheck(transformer)); } /** @@ -674,11 +674,11 @@ public final class PropertyValueModelTools { * * @see PluggablePropertyValueModel */ - public static PluggablePropertyValueModel.Adapter.Factory pluggablePropertyValueModelAdapterFactory_( + public static PluggablePropertyValueModel.Adapter.Factory transformationPluggablePropertyValueModelAdapterFactory_( PropertyValueModel propertyModel, Transformer transformer ) { - return new PropertyPluggablePropertyValueModelAdapter.Factory<>(propertyModel, transformer); + return new TransformationPluggablePropertyValueModelAdapter.Factory<>(propertyModel, transformer); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPluggablePropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPluggablePropertyValueModelAdapter.java new file mode 100644 index 0000000000..dd69107a2e --- /dev/null +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPluggablePropertyValueModelAdapter.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2016 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.common.utility.internal.model.value; + +import org.eclipse.jpt.common.utility.internal.ObjectTools; +import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; +import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener; +import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.common.utility.transformer.Transformer; + +/** + * Adapt a {@link PropertyValueModel property value model} to + * another {@link PropertyValueModel property value model}, sorta. + *

+ * This adapter is constructed with a {@link PropertyValueModel + * property value model} and a {@link Transformer transformer} that can + * transform the wrapped model's value to this model's derived value. + *

+ * This is an adapter that can be used by a {@link PluggablePropertyValueModel}. + * + * @param the type of the wrapped model's value + * @param the type of the model's derived value + * + * @see PluggablePropertyValueModel + */ +public final class TransformationPluggablePropertyValueModelAdapter + implements PluggablePropertyValueModel.Adapter, PropertyChangeListener +{ + /** The wrapped model */ + private final PropertyValueModel propertyModel; + + /** Transformer that converts the wrapped model's value to this model's value. */ + private final Transformer transformer; + + /** The real adapter. */ + private final BasePluggablePropertyValueModel.Adapter.Listener listener; + + /** Cached copy of model's value. */ + /* package */ volatile V1 propertyModelValue; + + + // ********** constructors ********** + + public TransformationPluggablePropertyValueModelAdapter(Factory factory, BasePluggablePropertyValueModel.Adapter.Listener listener) { + super(); + if (factory == null) { + throw new NullPointerException(); + } + this.propertyModel = factory.propertyModel; + this.transformer = factory.transformer; + if (listener == null) { + throw new NullPointerException(); + } + this.listener = listener; + } + + + // ********** BasePluggablePropertyValueModel.Adapter ********** + + public V2 engageModel() { + this.propertyModel.addPropertyChangeListener(PropertyValueModel.VALUE, this); + this.propertyModelValue = this.propertyModel.getValue(); + return this.buildValue(); + } + + public V2 disengageModel() { + this.propertyModel.removePropertyChangeListener(PropertyValueModel.VALUE, this); + this.propertyModelValue = null; + return null; + } + + + // ********** PropertyChangeListener ********** + + @SuppressWarnings("unchecked") + public void propertyChanged(PropertyChangeEvent event) { + this.propertyModelValue = (V1) event.getNewValue(); + this.update(); + } + + + // ********** misc ********** + + private void update() { + this.listener.valueChanged(this.buildValue()); + } + + private V2 buildValue() { + return this.transformer.transform(this.propertyModelValue); + } + + @Override + public String toString() { + return ObjectTools.toString(this, this.buildValue()); + } + + + // ********** Factory ********** + + public static class Factory + implements PluggablePropertyValueModel.Adapter.Factory + { + /* CU private */ final PropertyValueModel propertyModel; + /* CU private */ final Transformer transformer; + + public Factory(PropertyValueModel propertyModel, Transformer transformer) { + super(); + if (propertyModel == null) { + throw new NullPointerException(); + } + this.propertyModel = propertyModel; + if (transformer == null) { + throw new NullPointerException(); + } + this.transformer = transformer; + } + + public TransformationPluggablePropertyValueModelAdapter buildAdapter(BasePluggablePropertyValueModel.Adapter.Listener listener) { + return new TransformationPluggablePropertyValueModelAdapter<>(this, listener); + } + + @Override + public String toString() { + return ObjectTools.toString(this); + } + } +} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java index 2e4c9ec29f..01e51aed1c 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java @@ -128,7 +128,7 @@ public class RadioButtonModelAdapter } private static PluggablePropertyValueModel.Adapter.Factory buildAdapterFactory(PropertyValueModel sharedValueModel, V buttonValue) { - return PropertyValueModelTools.pluggablePropertyValueModelAdapterFactory_(sharedValueModel, new GetTransformer<>(buttonValue)); + return PropertyValueModelTools.transformationPluggablePropertyValueModelAdapterFactory_(sharedValueModel, new GetTransformer<>(buttonValue)); } public void setValue(Boolean value) { -- cgit v1.2.3