Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java27
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaClass.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaEnum.java27
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaType.java17
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingKeyImageDescriptorTransformer.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java)26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/navigator/ELJaxbNavigatorItemLabelProviderFactory.java22
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemContentProviderFactory.java24
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemLabelProviderFactory.java121
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingKeyImageDescriptorTransformer.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java)20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java43
10 files changed, 213 insertions, 125 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java
index 7871e76d6f..e994e89dc5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java
@@ -1,14 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2011 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
- *******************************************************************************/
+ * Copyright (c) 2011, 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.jaxb.core.context;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateAdapter;
+import org.eclipse.jpt.common.utility.predicate.Predicate;
import org.eclipse.jpt.jaxb.core.xsd.XsdTypeDefinition;
/**
@@ -46,6 +48,15 @@ public interface JaxbTypeMapping
String XML_TRANSIENT_PROPERTY = "xmlTransient"; //$NON-NLS-1$
boolean isXmlTransient();
+ Predicate<JaxbTypeMapping> XML_TRANSIENT_PREDICATE = new XmlTransientPredicate();
+ class XmlTransientPredicate
+ extends PredicateAdapter<JaxbTypeMapping>
+ {
+ @Override
+ public boolean evaluate(JaxbTypeMapping mapping) {
+ return mapping.isXmlTransient();
+ }
+ }
// ***** XmlType.name and XmlType.namespace *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaClass.java
index b302beecec..b06335425b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaClass.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaClass.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2011, 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.
@@ -34,6 +34,15 @@ public interface JavaClass
JavaResourceType getJavaResourceType();
public JavaClassMapping getMapping();
+ Transformer<JavaClass, JavaClassMapping> MAPPING_TRANSFORMER = new MappingTransformer();
+ class MappingTransformer
+ extends TransformerAdapter<JavaClass, JavaClassMapping>
+ {
+ @Override
+ public JavaClassMapping transform(JavaClass javaClass) {
+ return javaClass.getMapping();
+ }
+ }
// ***** XmlRegistry *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaEnum.java
index b9b61bd3d4..c60285a7bd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaEnum.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaEnum.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011 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
- *******************************************************************************/
+ * Copyright (c) 2011, 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.jaxb.core.context.java;
import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
/**
* Represents a java enum with JAXB metadata (specified or implied).
@@ -31,4 +33,13 @@ public interface JavaEnum
JavaResourceEnum getJavaResourceType();
public JavaEnumMapping getMapping();
+ Transformer<JavaEnum, JavaEnumMapping> MAPPING_TRANSFORMER = new MappingTransformer();
+ class MappingTransformer
+ extends TransformerAdapter<JavaEnum, JavaEnumMapping>
+ {
+ @Override
+ public JavaEnumMapping transform(JavaEnum javaEnum) {
+ return javaEnum.getMapping();
+ }
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaType.java
index 2f9dfbf912..a858e7fd66 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/java/JavaType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2010, 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.
@@ -12,6 +12,8 @@ package org.eclipse.jpt.jaxb.core.context.java;
import java.util.List;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.utility.internal.predicate.CriterionPredicate;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
@@ -58,7 +60,7 @@ public interface JavaType
// ***** type mapping *****
- final String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$
+ String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$
/**
* Return the mapping of this type.
@@ -67,11 +69,20 @@ public interface JavaType
* or if this type is default mapped.
*/
JavaTypeMapping getMapping();
+ Transformer<JavaType, JavaTypeMapping> MAPPING_TRANSFORMER = new MappingTransformer();
+ class MappingTransformer
+ extends TransformerAdapter<JavaType, JavaTypeMapping>
+ {
+ @Override
+ public JavaTypeMapping transform(JavaType javaType) {
+ return javaType.getMapping();
+ }
+ }
// ***** default mapped *****
- final String DEFAULT_MAPPED_PROPERTY = "defaultMapped"; //$NON-NLS-1$
+ String DEFAULT_MAPPED_PROPERTY = "defaultMapped"; //$NON-NLS-1$
/**
* Return true if this type is mapped by reference.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingKeyImageDescriptorTransformer.java
index ddb51cff33..30bb0f34d7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingKeyImageDescriptorTransformer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2011, 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.
@@ -10,14 +10,28 @@
package org.eclipse.jpt.jaxb.eclipselink.ui.internal;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiImages;
-import org.eclipse.jpt.jaxb.ui.internal.JaxbMappingImageHelper;
+import org.eclipse.jpt.jaxb.ui.internal.JaxbMappingKeyImageDescriptorTransformer;
-public class ELJaxbMappingImageHelper {
-
- public static ImageDescriptor imageDescriptorForAttributeMapping(String mappingKey) {
+public class ELJaxbMappingKeyImageDescriptorTransformer
+ extends TransformerAdapter<String, ImageDescriptor>
+{
+ private static final Transformer<String, ImageDescriptor> INSTANCE = new ELJaxbMappingKeyImageDescriptorTransformer();
+
+ public static Transformer<String, ImageDescriptor> instance() {
+ return INSTANCE;
+ }
+
+ private ELJaxbMappingKeyImageDescriptorTransformer() {
+ super();
+ }
+
+ @Override
+ public ImageDescriptor transform(String mappingKey) {
if (ELJaxbMappingKeys.XML_INVERSE_REFERENCE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
return JptJaxbEclipseLinkUiImages.XML_INVERSE_REFERENCE;
}
@@ -28,6 +42,6 @@ public class ELJaxbMappingImageHelper {
return JptJaxbEclipseLinkUiImages.XML_TRANSFORMATION;
}
- return JaxbMappingImageHelper.imageDescriptorForAttributeMapping(mappingKey);
+ return JaxbMappingKeyImageDescriptorTransformer.instance().transform(mappingKey);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/navigator/ELJaxbNavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/navigator/ELJaxbNavigatorItemLabelProviderFactory.java
index d8dae4d52c..7e98d1caf5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/navigator/ELJaxbNavigatorItemLabelProviderFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/navigator/ELJaxbNavigatorItemLabelProviderFactory.java
@@ -15,7 +15,6 @@ import org.eclipse.jpt.common.ui.internal.jface.ModelItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.internal.jface.StaticItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
-import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
@@ -27,7 +26,7 @@ import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmJavaType;
import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmTypeMapping;
import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmXmlEnum;
import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiImages;
-import org.eclipse.jpt.jaxb.eclipselink.ui.internal.ELJaxbMappingImageHelper;
+import org.eclipse.jpt.jaxb.eclipselink.ui.internal.ELJaxbMappingKeyImageDescriptorTransformer;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiImages;
import org.eclipse.jpt.jaxb.ui.internal.AbstractNavigatorItemLabelProviderFactory;
@@ -68,8 +67,8 @@ public class ELJaxbNavigatorItemLabelProviderFactory
}
@Override
- protected ImageDescriptor buildJavaPersistentAttributeImageDescriptor(String mappingKey) {
- return ELJaxbMappingImageHelper.imageDescriptorForAttributeMapping(mappingKey);
+ protected Transformer<String, ImageDescriptor> getMappingKeyImageDescriptorTransformer() {
+ return ELJaxbMappingKeyImageDescriptorTransformer.instance();
}
protected ItemExtendedLabelProvider buildOxmFileLabelProvider(OxmFile file, ItemExtendedLabelProvider.Manager manager) {
@@ -164,7 +163,10 @@ public class ELJaxbNavigatorItemLabelProviderFactory
}
protected PropertyValueModel<ImageDescriptor> buildOxmJavaAttributeImageDescriptorModel(OxmJavaAttribute item) {
- return PropertyValueModelTools.transform(this.buildOxmJavaAttributeMappingKeyModel(item), MAPPING_KEY_IMAGE_DESCRIPTOR_TRANSFORMER);
+ return PropertyValueModelTools.transform(
+ this.buildOxmJavaAttributeMappingKeyModel(item),
+ ELJaxbMappingKeyImageDescriptorTransformer.instance()
+ );
}
protected PropertyValueModel<String> buildOxmJavaAttributeMappingKeyModel(OxmJavaAttribute item) {
@@ -178,16 +180,6 @@ public class ELJaxbNavigatorItemLabelProviderFactory
JaxbPersistentAttribute.MAPPING_TRANSFORMER
);
}
-
- protected static final Transformer<String, ImageDescriptor> MAPPING_KEY_IMAGE_DESCRIPTOR_TRANSFORMER = new MappingKeyImageDescriptorTransformer();
- protected static final class MappingKeyImageDescriptorTransformer
- extends TransformerAdapter<String, ImageDescriptor>
- {
- @Override
- public ImageDescriptor transform(String mappingKey) {
- return ELJaxbMappingImageHelper.imageDescriptorForAttributeMapping(mappingKey);
- }
- }
protected PropertyValueModel<String> buildOxmJavaAttributeTextModel(OxmJavaAttribute item) {
return PropertyValueModelTools.modelAspectAdapter(
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemContentProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemContentProviderFactory.java
index e97054f394..82cf53a38a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemContentProviderFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemContentProviderFactory.java
@@ -18,7 +18,7 @@ import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapterXXXX;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
@@ -125,12 +125,11 @@ public abstract class AbstractNavigatorItemContentProviderFactory
}
protected PropertyValueModel<JavaClassMapping> buildMappingModel(JavaClass javaClass) {
- return new PropertyAspectAdapterXXXX<JavaClass, JavaClassMapping>(JavaType.MAPPING_PROPERTY, javaClass) {
- @Override
- protected JavaClassMapping buildValue_() {
- return this.subject.getMapping();
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ javaClass,
+ JavaType.MAPPING_PROPERTY,
+ JavaClass.MAPPING_TRANSFORMER
+ );
}
protected CollectionValueModel<JavaPersistentAttribute> buildAttributesModel(
@@ -169,11 +168,10 @@ public abstract class AbstractNavigatorItemContentProviderFactory
}
protected PropertyValueModel<JavaEnumMapping> buildMappingModel(JavaEnum javaEnum) {
- return new PropertyAspectAdapterXXXX<JavaEnum, JavaEnumMapping>(JavaType.MAPPING_PROPERTY, javaEnum) {
- @Override
- protected JavaEnumMapping buildValue_() {
- return this.subject.getMapping();
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ javaEnum,
+ JavaType.MAPPING_PROPERTY,
+ JavaEnum.MAPPING_TRANSFORMER
+ );
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemLabelProviderFactory.java
index 0f429c9266..3878ffc727 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemLabelProviderFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/AbstractNavigatorItemLabelProviderFactory.java
@@ -17,16 +17,18 @@ import org.eclipse.jpt.common.ui.internal.jface.StaticItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.model.value.PluggablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapterXXXX;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
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;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.java.JavaClass;
import org.eclipse.jpt.jaxb.core.context.java.JavaClassMapping;
import org.eclipse.jpt.jaxb.core.context.java.JavaEnum;
@@ -139,9 +141,9 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
protected final JavaClass javaClass;
protected final PluggablePropertyValueModel.Adapter.Listener<ImageDescriptor> listener;
- protected final PropertyValueModel<Boolean> xmlRegistryModel;
- protected volatile Boolean xmlRegistry;
- protected final PropertyChangeListener xmlRegistryListener;
+ protected final PropertyValueModel<Boolean> xmlRegistryIsPresentModel;
+ protected volatile Boolean xmlRegistryIsPresent;
+ protected final PropertyChangeListener xmlRegistryIsPresentListener;
protected final PropertyValueModel<JavaClassMapping> mappingModel;
protected volatile JavaClassMapping mapping;
@@ -163,8 +165,8 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
}
this.listener = listener;
- this.xmlRegistryModel = this.buildXmlRegistryModel();
- this.xmlRegistryListener = this.buildXmlRegistryListener();
+ this.xmlRegistryIsPresentModel = this.buildXmlRegistryIsPresentModel();
+ this.xmlRegistryIsPresentListener = this.buildXmlRegistryIsPresentListener();
this.mappingModel = this.buildMappingModel();
this.mappingListener = this.buildMappingListener();
@@ -173,37 +175,38 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
this.xmlTransientListener = buildXmlTransientListener();
}
- protected PropertyValueModel<Boolean> buildXmlRegistryModel() {
- return new PropertyAspectAdapterXXXX<JavaClass, Boolean>(JavaClass.XML_REGISTRY_PROPERTY, this.javaClass) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.getXmlRegistry() != null);
- }
- };
+ protected PropertyValueModel<Boolean> buildXmlRegistryIsPresentModel() {
+ return PropertyValueModelTools.valueIsNotNull(this.buildXmlRegistryModel());
+ }
+
+ protected PropertyValueModel<XmlRegistry> buildXmlRegistryModel() {
+ return PropertyValueModelTools.modelAspectAdapter(
+ this.javaClass,
+ JavaClass.XML_REGISTRY_PROPERTY,
+ JavaClass.XML_REGISTRY_TRANSFORMER
+ );
}
protected PropertyValueModel<JavaClassMapping> buildMappingModel() {
- return new PropertyAspectAdapterXXXX<JavaClass, JavaClassMapping> (JavaType.MAPPING_PROPERTY, this.javaClass) {
- @Override
- protected JavaClassMapping buildValue_() {
- return this.subject.getMapping();
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ this.javaClass,
+ JavaType.MAPPING_PROPERTY,
+ JavaClass.MAPPING_TRANSFORMER
+ );
}
protected PropertyValueModel<Boolean> buildXmlTransientModel() {
- return new PropertyAspectAdapterXXXX<JavaClassMapping, Boolean>(this.mappingModel, JaxbTypeMapping.XML_TRANSIENT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isXmlTransient());
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ this.mappingModel,
+ JaxbTypeMapping.XML_TRANSIENT_PROPERTY,
+ JaxbTypeMapping.XML_TRANSIENT_PREDICATE
+ );
}
- protected PropertyChangeListener buildXmlRegistryListener() {
+ protected PropertyChangeListener buildXmlRegistryIsPresentListener() {
return new PropertyChangeListener() {
public void propertyChanged(PropertyChangeEvent event) {
- JavaClassImageDescriptorModelAdapter.this.xmlRegistry = (Boolean) event.getNewValue();
+ JavaClassImageDescriptorModelAdapter.this.xmlRegistryIsPresent = (Boolean) event.getNewValue();
JavaClassImageDescriptorModelAdapter.this.update();
}
};
@@ -235,15 +238,15 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
if ((this.mapping != null) && ObjectTools.equals(this.xmlTransient, Boolean.TRUE)) {
return JptJaxbUiImages.JAXB_TRANSIENT_CLASS;
}
- if (ObjectTools.equals(this.xmlRegistry, Boolean.TRUE)) {
+ if (ObjectTools.equals(this.xmlRegistryIsPresent, Boolean.TRUE)) {
return JptJaxbUiImages.JAXB_REGISTRY;
}
return JptJaxbUiImages.JAXB_CLASS;
}
public ImageDescriptor engageModel() {
- this.xmlRegistryModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.xmlRegistryListener);
- this.xmlRegistry = this.xmlRegistryModel.getValue();
+ this.xmlRegistryIsPresentModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.xmlRegistryIsPresentListener);
+ this.xmlRegistryIsPresent = this.xmlRegistryIsPresentModel.getValue();
this.mappingModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.mappingListener);
this.mapping = this.mappingModel.getValue();
this.xmlTransientModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.xmlTransientListener);
@@ -252,8 +255,8 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
}
public ImageDescriptor disengageModel() {
- this.xmlRegistryModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.xmlRegistryListener);
- this.xmlRegistry = null;
+ this.xmlRegistryIsPresentModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.xmlRegistryIsPresentListener);
+ this.xmlRegistryIsPresent = null;
this.mappingModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.mappingListener);
this.mapping = null;
this.xmlTransientModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.xmlTransientListener);
@@ -343,12 +346,11 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
protected PropertyValueModel<JavaEnumMapping> buildMappingModel() {
- return new PropertyAspectAdapterXXXX<JavaEnum, JavaEnumMapping> (JavaType.MAPPING_PROPERTY, this.javaEnum) {
- @Override
- protected JavaEnumMapping buildValue_() {
- return this.subject.getMapping();
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ this.javaEnum,
+ JavaType.MAPPING_PROPERTY,
+ JavaEnum.MAPPING_TRANSFORMER
+ );
}
protected PropertyChangeListener buildMappingListener() {
@@ -361,12 +363,11 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
}
protected PropertyValueModel<Boolean> buildXmlTransientModel() {
- return new PropertyAspectAdapterXXXX<JavaEnumMapping, Boolean>(this.mappingModel, JaxbTypeMapping.XML_TRANSIENT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isXmlTransient());
- }
- };
+ return PropertyValueModelTools.modelAspectAdapter(
+ this.mappingModel,
+ JaxbTypeMapping.XML_TRANSIENT_PROPERTY,
+ JaxbTypeMapping.XML_TRANSIENT_PREDICATE
+ );
}
protected PropertyChangeListener buildXmlTransientListener() {
@@ -467,22 +468,30 @@ public abstract class AbstractNavigatorItemLabelProviderFactory
}
public PropertyValueModel<ImageDescriptor> buildJavaPersistentAttributeImageDescriptorModel(JavaPersistentAttribute item) {
- return new PropertyAspectAdapterXXXX<JavaPersistentAttribute, ImageDescriptor>(PropertyValueModelTools.staticModel(item), IMAGE_ASPECT_NAMES) {
- @Override
- protected ImageDescriptor buildValue_() {
- return AbstractNavigatorItemLabelProviderFactory.this.buildJavaPersistentAttributeImageDescriptor(this.subject.getMappingKey());
- }
- };
+ return PropertyValueModelTools.transform(
+ this.buildJavaPersistentAttributeMappingKeyModel(item),
+ this.getMappingKeyImageDescriptorTransformer()
+ );
}
- protected ImageDescriptor buildJavaPersistentAttributeImageDescriptor(String mappingKey) {
- return JaxbMappingImageHelper.imageDescriptorForAttributeMapping(mappingKey);
+ protected Transformer<String, ImageDescriptor> getMappingKeyImageDescriptorTransformer() {
+ return JaxbMappingKeyImageDescriptorTransformer.instance();
}
- protected static final String[] IMAGE_ASPECT_NAMES = new String[] {
- JavaPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY,
- JaxbPersistentAttribute.MAPPING_PROPERTY
- };
+ public PropertyValueModel<String> buildJavaPersistentAttributeMappingKeyModel(JavaPersistentAttribute item) {
+ return PropertyValueModelTools.transform(
+ this.buildJavaPersistentAttributeMappingModel(item),
+ JaxbAttributeMapping.KEY_TRANSFORMER
+ );
+ }
+
+ public PropertyValueModel<JaxbAttributeMapping> buildJavaPersistentAttributeMappingModel(JavaPersistentAttribute item) {
+ return PropertyValueModelTools.modelAspectAdapter(
+ item,
+ JaxbPersistentAttribute.MAPPING_PROPERTY,
+ JaxbPersistentAttribute.MAPPING_TRANSFORMER
+ );
+ }
public PropertyValueModel<String> buildJavaPersistentAttributeTextModel(JavaPersistentAttribute item) {
return PropertyValueModelTools.staticModel(this.buildJavaPersistentAttributeText(item));
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingKeyImageDescriptorTransformer.java
index 7e9866962b..c6a169850b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingKeyImageDescriptorTransformer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2011, 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.
@@ -10,12 +10,26 @@
package org.eclipse.jpt.jaxb.ui.internal;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiImages;
-public class JaxbMappingImageHelper {
+public class JaxbMappingKeyImageDescriptorTransformer
+ extends TransformerAdapter<String, ImageDescriptor>
+{
+ private static final Transformer<String, ImageDescriptor> INSTANCE = new JaxbMappingKeyImageDescriptorTransformer();
- public static ImageDescriptor imageDescriptorForAttributeMapping(String mappingKey) {
+ public static Transformer<String, ImageDescriptor> instance() {
+ return INSTANCE;
+ }
+
+ private JaxbMappingKeyImageDescriptorTransformer() {
+ super();
+ }
+
+ @Override
+ public ImageDescriptor transform(String mappingKey) {
if (MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY == mappingKey) {
return JptJaxbUiImages.NULL_ATTRIBUTE_MAPPING;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java
index f355f46dcf..ca85850e5e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java
@@ -51,6 +51,7 @@ import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter;
import org.eclipse.jpt.common.ui.internal.swt.bindings.SWTBindingTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.closure.BiClosureTools;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterable.SingleElementIterable;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
@@ -619,9 +620,27 @@ public class JaxbSchemasPropertiesPage
private String namespace;
final static String NAMESPACE_PROPERTY = "namespace"; //$NON-NLS-1$
+ public static final Transformer<Schema, String> NAMESPACE_TRANSFORMER = new NamespaceTransformer();
+ public static final class NamespaceTransformer
+ extends TransformerAdapter<Schema, String>
+ {
+ @Override
+ public String transform(Schema schema) {
+ return schema.getNamespace();
+ }
+ }
private String location;
final static String LOCATION_PROPERTY = "location"; //$NON-NLS-1$
+ public static final Transformer<Schema, String> LOCATION_TRANSFORMER = new LocationTransformer();
+ public static final class LocationTransformer
+ extends TransformerAdapter<Schema, String>
+ {
+ @Override
+ public String transform(Schema schema) {
+ return schema.getLocation();
+ }
+ }
String getNamespace() {
@@ -689,21 +708,21 @@ public class JaxbSchemasPropertiesPage
}
private ModifiablePropertyValueModel<String> buildNamespaceCellModel(Schema subject) {
- return new PropertyAspectAdapterXXXX<Schema, String>(Schema.NAMESPACE_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return this.subject.getNamespace();
- }
- };
+ return PropertyValueModelTools.modifiableModelAspectAdapter(
+ subject,
+ Schema.NAMESPACE_PROPERTY,
+ Schema.NAMESPACE_TRANSFORMER,
+ BiClosureTools.nullBiClosure()
+ );
}
private ModifiablePropertyValueModel<String> buildLocationCellModel(Schema subject) {
- return new PropertyAspectAdapterXXXX<Schema, String>(Schema.LOCATION_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return this.subject.getLocation();
- }
- };
+ return PropertyValueModelTools.modifiableModelAspectAdapter(
+ subject,
+ Schema.LOCATION_PROPERTY,
+ Schema.LOCATION_TRANSFORMER,
+ BiClosureTools.nullBiClosure()
+ );
}
}

Back to the top