Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java98
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java94
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java24
3 files changed, 77 insertions, 139 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java
deleted file mode 100644
index a2bfe187fa..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.ui.internal.properties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jpt.common.ui.internal.WorkbenchTools;
-import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
-import org.eclipse.jpt.jaxb.core.JaxbWorkspace;
-import org.eclipse.jpt.jaxb.ui.JaxbWorkbench;
-
-/**
- * Treat the JAXB project as an "aspect" of the Eclipse project (IProject);
- * but the JAXB project is stored in the JAXB model, not the Eclipse project
- * itself....
- * We also need to listen for the JAXB project to be rebuilt if the user
- * changes the Eclipse project's JAXB platform (which is stored in the
- * Eclipse project's preferences).
- */
-class JaxbProjectModel
- extends AspectPropertyValueModelAdapter<IProject, JaxbProject> {
-
- /**
- * The JAXB project may also change via another page (notably, the project facets page).
- * In that case, the preference change occurs before we actually have another project,
- * so we must listen to the projects manager
- */
- private final JaxbProjectManager jaxbProjectManager;
- private final CollectionChangeListener projectManagerListener;
-
-
- JaxbProjectModel(PropertyValueModel<IProject> projectModel) {
- super(projectModel);
- this.jaxbProjectManager = this.getJaxbProjectManager();
- this.projectManagerListener = buildProjectManagerListener();
- }
-
- private CollectionChangeListener buildProjectManagerListener() {
- return new CollectionChangeAdapter() {
- // we are only looking for the project rebuild *add* event here so we can
- // determine if the platform has changed.
- // the other events are unimportant in this case
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- platformChanged();
- }
- };
- }
-
- void platformChanged() {
- this.aspectChanged();
- }
-
- @Override
- protected void engageSubject_() {
- if (this.jaxbProjectManager != null) {
- this.jaxbProjectManager.addCollectionChangeListener(JaxbProjectManager.JAXB_PROJECTS_COLLECTION, this.projectManagerListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- if (this.jaxbProjectManager != null) {
- this.jaxbProjectManager.removeCollectionChangeListener(JaxbProjectManager.JAXB_PROJECTS_COLLECTION, this.projectManagerListener);
- }
- }
-
- @Override
- protected JaxbProject buildValue_() {
- return (this.jaxbProjectManager == null) ? null : this.jaxbProjectManager.getJaxbProject(this.subject);
- }
-
- private JaxbProjectManager getJaxbProjectManager() {
- JaxbWorkspace jaxbWorkspace = this.getJaxbWorkspace();
- return (jaxbWorkspace == null) ? null : jaxbWorkspace.getJaxbProjectManager();
- }
-
- private JaxbWorkspace getJaxbWorkspace() {
- JaxbWorkbench jaxbWorkbench = this.getJaxbWorkbench();
- return (jaxbWorkbench == null) ? null : jaxbWorkbench.getJaxbWorkspace();
- }
-
- private JaxbWorkbench getJaxbWorkbench() {
- return WorkbenchTools.getAdapter(JaxbWorkbench.class);
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java
index 3288b65f2a..f1b6b2667a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java
@@ -14,20 +14,22 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jpt.common.core.internal.utility.ICUStringCollator;
import org.eclipse.jpt.common.ui.internal.WorkbenchTools;
import org.eclipse.jpt.common.ui.internal.properties.JptProjectPropertiesPage;
import org.eclipse.jpt.common.ui.internal.swt.bindings.SWTBindingTools;
import org.eclipse.jpt.common.utility.Association;
+import org.eclipse.jpt.common.utility.internal.closure.ClosureAdapter;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SetCollectionValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
@@ -36,6 +38,7 @@ import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.core.JaxbPreferences;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
@@ -43,6 +46,7 @@ import org.eclipse.jpt.jaxb.core.JaxbWorkspace;
import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformConfig;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformManager;
+import org.eclipse.jpt.jaxb.ui.JaxbProjectModel;
import org.eclipse.jpt.jaxb.ui.JaxbWorkbench;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiMessages;
import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
@@ -83,7 +87,7 @@ public class JaxbProjectPropertiesPage
@Override
protected void buildModels() {
- this.jaxbProjectModel = new JaxbProjectModel(this.projectModel);
+ this.jaxbProjectModel = this.buildJaxbProjectModel();
Association<ModifiablePropertyValueModel<JaxbPlatformConfig>, PropertyValueModel<Boolean>> platformAssoc = this.buildPlatformModel();
this.platformModel = platformAssoc.getKey();
@@ -92,10 +96,57 @@ public class JaxbProjectPropertiesPage
}
+ // ***** JAXB project model
+ private PropertyValueModel<JaxbProject> buildJaxbProjectModel() {
+ return PropertyValueModelTools.compound(this.buildJaxbProjectModelModel());
+ }
+
+ private PropertyValueModel<PropertyValueModel<JaxbProject>> buildJaxbProjectModelModel() {
+ return PropertyValueModelTools.transform(this.projectModel, JAXB_PROJECT_MODEL_TRANSFORMER);
+ }
+
+ private static final Transformer<IProject, PropertyValueModel<JaxbProject>> JAXB_PROJECT_MODEL_TRANSFORMER = new JaxbProjectModelTransformer();
+
+ /* CU private */ static class JaxbProjectModelTransformer
+ extends TransformerAdapter<IProject, PropertyValueModel<JaxbProject>>
+ {
+ @Override
+ public PropertyValueModel<JaxbProject> transform(IProject project) {
+ return project.getAdapter(JaxbProjectModel.class);
+ }
+ }
+
// ***** platform ID model
private Association<ModifiablePropertyValueModel<JaxbPlatformConfig>, PropertyValueModel<Boolean>> buildPlatformModel() {
- return PropertyValueModelTools.buffer(new PlatformModel(this.jaxbProjectModel), this.trigger);
+ return PropertyValueModelTools.buffer(this.buildPlatformModel_(), this.trigger);
+ }
+
+ private ModifiablePropertyValueModel<JaxbPlatformConfig> buildPlatformModel_() {
+ return PropertyValueModelTools.transform(this.jaxbProjectModel, JAXB_PROJECT_PLATFORM_CONFIG_TRANSFORMER, new JaxbProjectSetPlatformConfigClosure());
+ }
+
+ private static final TransformerAdapter<JaxbProject, JaxbPlatformConfig> JAXB_PROJECT_PLATFORM_CONFIG_TRANSFORMER = new JaxbProjectPlatformConfigTransformer();
+ static class JaxbProjectPlatformConfigTransformer
+ extends TransformerAdapter<JaxbProject, JaxbPlatformConfig>
+ {
+ @Override
+ public JaxbPlatformConfig transform(JaxbProject jaxbProject) {
+ return jaxbProject.getPlatform().getConfig();
+ }
+ }
+
+ class JaxbProjectSetPlatformConfigClosure
+ extends ClosureAdapter<JaxbPlatformConfig>
+ {
+ @Override
+ public void execute(JaxbPlatformConfig platformConfig) {
+ setJaxbProjectPlatformConfig(platformConfig);
+ }
+ }
+
+ void setJaxbProjectPlatformConfig(JaxbPlatformConfig platformConfig) {
+ JaxbPreferences.setJaxbPlatformID(this.jaxbProjectModel.getValue().getProject(), platformConfig.getId());
}
private PropertyChangeListener buildPlatformListener(){
@@ -309,41 +360,4 @@ public class JaxbProjectPropertiesPage
/* library provider */
// default validation is OK
}
-
-
- // ********** UI model adapters **********
-
- /**
- * Treat the JAXB platform as an "aspect" of the JAXB project.
- * The platform ID is stored in the project preferences.
- * The platform ID does not change for a JAXB project - if the user wants a
- * different platform, we build an entirely new JAXB project.
- */
- static class PlatformModel
- extends AspectPropertyValueModelAdapter<JaxbProject, JaxbPlatformConfig> {
-
- PlatformModel(PropertyValueModel<JaxbProject> jaxbProjectModel) {
- super(jaxbProjectModel);
- }
-
- @Override
- protected JaxbPlatformConfig buildValue_() {
- return this.subject.getPlatform().getConfig();
- }
-
- @Override
- public void setValue_(JaxbPlatformConfig newPlatform) {
- JaxbPreferences.setJaxbPlatformID(this.subject.getProject(), newPlatform.getId());
- }
-
- @Override
- protected void engageSubject_() {
- // the platform ID does not change
- }
-
- @Override
- protected void disengageSubject_() {
- // the platform ID does not change
- }
- }
}
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 aef04af6c3..2ff8515cd9 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
@@ -62,6 +62,7 @@ import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelToo
import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
@@ -69,11 +70,13 @@ import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
import org.eclipse.jpt.jaxb.core.JaxbWorkspace;
import org.eclipse.jpt.jaxb.core.SchemaEntry;
import org.eclipse.jpt.jaxb.core.xsd.XsdUtil;
+import org.eclipse.jpt.jaxb.ui.JaxbProjectModel;
import org.eclipse.jpt.jaxb.ui.JaxbWorkbench;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiMessages;
import org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.SelectFileOrXMLCatalogIdPanel;
@@ -120,7 +123,7 @@ public class JaxbSchemasPropertiesPage
super();
this.resourceManager = this.buildResourceManager();
this.projectModel = new SimplePropertyValueModel<>();
- this.jaxbProjectModel = new JaxbProjectModel(this.projectModel);
+ this.jaxbProjectModel = this.buildJaxbProjectModel();
this.trigger = PropertyValueModelTools.bufferedPropertyValueModelAdapterTrigger();
this.schemasModel = new SchemasModel(this.jaxbProjectModel, this.trigger);
this.schemasSelectionModel = new SimpleCollectionValueModel<>();
@@ -135,6 +138,25 @@ public class JaxbSchemasPropertiesPage
return JFaceResources.getResources();
}
+ private PropertyValueModel<JaxbProject> buildJaxbProjectModel() {
+ return PropertyValueModelTools.compound(this.buildJaxbProjectModelModel());
+ }
+
+ private PropertyValueModel<PropertyValueModel<JaxbProject>> buildJaxbProjectModelModel() {
+ return PropertyValueModelTools.transform(this.projectModel, JAXB_PROJECT_MODEL_TRANSFORMER);
+ }
+
+ private static final Transformer<IProject, PropertyValueModel<JaxbProject>> JAXB_PROJECT_MODEL_TRANSFORMER = new JaxbProjectModelTransformer();
+
+ /* CU private */ static class JaxbProjectModelTransformer
+ extends TransformerAdapter<IProject, PropertyValueModel<JaxbProject>>
+ {
+ @Override
+ public PropertyValueModel<JaxbProject> transform(IProject project) {
+ return project.getAdapter(JaxbProjectModel.class);
+ }
+ }
+
protected IProject getProject() {
return this.projectModel.getValue();
}

Back to the top