diff options
15 files changed, 867 insertions, 40 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/.classpath b/jpa/plugins/org.eclipse.jpt.jaxb.ui/.classpath index a1d4f10a15..bd4371771c 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/.classpath +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/.classpath @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> + <accessrules> + <accessrule kind="accessible" pattern="org/eclipse/wst/**"/> + <accessrule kind="accessible" pattern="org/eclipse/jst/**"/> + </accessrules> + </classpathentry> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="property_files"/> <classpathentry kind="output" path="bin"/> diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.jaxb.ui/.settings/org.eclipse.jdt.core.prefs index 7e50a8f1f3..7a34f4bbcf 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,5 @@ #Mon Feb 08 18:48:37 EST 2010 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF index 8e8d066cc9..ce81953fd2 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF @@ -11,25 +11,39 @@ Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.4.0,4.0.0)", + org.eclipse.help;bundle-version="[3.5.0,4.0.0)", org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)", org.eclipse.jface;bundle-version="[3.4.0,4.0.0)", + org.eclipse.jpt.jaxb.core;bundle-version="[1.0.0,2.0.0)", + org.eclipse.jpt.core;bundle-version="[2.3.0,3.0.0)", org.eclipse.jpt.ui;bundle-version="[2.0.0,3.0.0)", org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)", + org.eclipse.jst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)", + org.eclipse.jst.common.project.facet.ui;bundle-version="[1.4.200,2.0.0)", org.eclipse.ui;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)", - org.eclipse.jpt.core;bundle-version="[2.3.0,3.0.0)", - org.eclipse.help;bundle-version="[3.5.0,4.0.0)", - org.eclipse.wst.xml.core;bundle-version="[1.1.500,2.0.0)", + org.eclipse.wst.common.frameworks;bundle-version="[1.2.0,2.0.0)", + org.eclipse.wst.common.frameworks.ui;bundle-version="[1.2.0,2.0.0)", + org.eclipse.wst.common.modulecore;bundle-version="[1.2.100,2.0.0)", + org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)", + org.eclipse.wst.common.project.facet.ui;bundle-version="[1.4.200,2.0.0)", org.eclipse.wst.common.ui;bundle-version="[1.1.500,2.0.0)", org.eclipse.wst.common.frameworks;bundle-version="[1.2.0,2.0.0)", - org.eclipse.wst.common.uriresolver;bundle-version="[1.1.401,2.0.0)" -Export-Package: org.eclipse.jpt.jaxb.core.internal;x-internal:=true, - org.eclipse.jpt.jaxb.ui;x-internal:=true, - org.eclipse.jpt.jaxb.ui.internal;x-internal:=true, - org.eclipse.jpt.jaxb.ui.internal.actions;x-internal:=true, - org.eclipse.jpt.jaxb.ui.internal.filters;x-internal:=true, - org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen;x-internal:=true, - org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen;x-internal:=true + org.eclipse.wst.common.uriresolver;bundle-version="[1.1.401,2.0.0)", + org.eclipse.wst.web.ui;bundle-version="[1.1.400,2.0.0)", + org.eclipse.wst.xml.core;bundle-version="[1.1.500,2.0.0)" +Export-Package: org.eclipse.jpt.jaxb.core.internal, + org.eclipse.jpt.jaxb.ui, + org.eclipse.jpt.jaxb.ui.internal, + org.eclipse.jpt.jaxb.ui.internal.actions, + org.eclipse.jpt.jaxb.ui.internal.filters, + org.eclipse.jpt.jaxb.ui.internal.wizards, + org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen, + org.eclipse.jpt.jaxb.ui.internal.wizards.facet, + org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model, + org.eclipse.jpt.jaxb.ui.internal.wizards.proj, + org.eclipse.jpt.jaxb.ui.internal.wizards.proj.model, + org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen Import-Package: com.ibm.icu.text;version="4.0.1" diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/build.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/build.properties index c822d05074..b2eea6d8ff 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/build.properties +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/build.properties @@ -15,7 +15,7 @@ output.. = bin/ bin.includes = .,\ META-INF/,\ about.html,\ + icons/,\ plugin.xml,\ - plugin.properties,\ - icons/ + plugin.properties jars.compile.order = . diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties index dab4226f65..7759e2cf32 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties @@ -19,10 +19,10 @@ # ==================================================================== # %%% END OF TRANSLATED PROPERTIES %%% # ==================================================================== -pluginName= Dali Java Persistence Tools - JAXB Support - UI +pluginName= Dali Java Persistence Tools - JAXB UI providerName=Eclipse Web Tools Platform -jpaWizardCategoryName = JAXB +jaxbWizardCategoryName = JAXB generateJaxbClasses = JAXB Classes... @@ -30,4 +30,7 @@ generateSchemaFromClassesName = Schema from JAXB Classes generateSchemaFromClassesDesc = Generate a Schema from JAXB classes generateClassesFromSchemaName = JAXB Classes from Schema -generateClassesFromSchemaDesc = Generate JAXB Classes from a Schema
\ No newline at end of file +generateClassesFromSchemaDesc = Generate JAXB Classes from a Schema + +newJaxbProjectWizardName = JAXB Project +newJaxbProjectWizardDesc = Create a JAXB project
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml index 70458524c5..eb698f0cc7 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml @@ -1,13 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.2"?> -<plugin> +<?eclipse version="3.2"?>
<!-- + Copyright (c) 2010 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 + --> +<plugin> + + <extension + point="org.eclipse.core.runtime.adapters"> + + <factory + class="org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetInstallConfigToDataModelAdapterFactory" + adaptableType="org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig"> + <adapter type="org.eclipse.wst.common.frameworks.datamodel.IDataModel"/> + </factory> + + </extension> + + <extension point="org.eclipse.ui.newWizards"> <category id="org.eclipse.jpt.jaxb" - name="%jpaWizardCategoryName"/> + name="%jaxbWizardCategoryName"/> <wizard id="org.eclipse.jpt.jaxb.ui.wizard.generateSchemaFromClasses" @@ -28,27 +49,60 @@ <description>%generateClassesFromSchemaDesc</description> </wizard> + <!-- will need to specify a final perspective once we have a jaxb perspective --> + <wizard + id="org.eclipse.jpt.jaxb.ui.wizard.newJaxbProject" + name="%newJaxbProjectWizardName" + icon="icons/full/etool16/new_jaxb_project_wiz.gif" + category="org.eclipse.jpt.jaxb" + project="true"> + <description>%newJaxbProjectWizardDesc</description> + <class class="org.eclipse.jpt.jaxb.ui.internal.wizards.proj.JaxbProjectWizard"> + <parameter name="menuIndex" value="35"/> + </class> + </wizard> + </extension> - + + <extension point="org.eclipse.ui.popupMenus"> - <!-- contributions to the "Generate" submenu --> - <objectContribution - id="org.eclipse.jpt.ui.xsdFileActions" - objectClass="org.eclipse.core.resources.IFile" - nameFilter="*.xsd"> - <filter - name="projectNature" - value="org.eclipse.jdt.core.javanature"> - </filter> - <action - id="org.eclipse.jpt.jaxb.ui.generateJaxbClasses" - label="%generateJaxbClasses" - menubarPath="generateMenuId/GenerateXML" - class="org.eclipse.jpt.jaxb.ui.internal.actions.GenerateClassesAction"> - </action> - </objectContribution> + <!-- contributions to the "Generate" submenu --> + <objectContribution + id="org.eclipse.jpt.ui.xsdFileActions" + objectClass="org.eclipse.core.resources.IFile" + nameFilter="*.xsd"> + <filter + name="projectNature" + value="org.eclipse.jdt.core.javanature"> + </filter> + <action + id="org.eclipse.jpt.jaxb.ui.generateJaxbClasses" + label="%generateJaxbClasses" + menubarPath="generateMenuId/GenerateXML" + class="org.eclipse.jpt.jaxb.ui.internal.actions.GenerateClassesAction"> + </action> + </objectContribution> + </extension> - + + + <extension + point="org.eclipse.wst.common.project.facet.ui.images"> + + <image facet="jpt.jaxb" path="icons/full/etool16/jaxb_facet.gif"/> + + </extension> + + + <extension + point="org.eclipse.wst.common.project.facet.ui.wizardPages"> + + <wizard-pages action="jpt.jaxb.install"> + <page class="org.eclipse.jpt.jaxb.ui.internal.wizards.facet.JaxbFacetInstallPage"/> + </wizard-pages> + + </extension> + </plugin> diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties index 787e2c03e7..57d0312591 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties @@ -127,3 +127,16 @@ SchemaGeneratorWizard_generateSchemaTask = Generating schema {0} #NewSchemaFileWizardPage NewSchemaFileWizardPage_errorNotJavaProject = Not a Java project + + +JaxbProjectWizard_title = New JAXB Project + +JaxbProjectWizard_firstPage_title = JAXB Project +JaxbProjectWizard_firstPage_desc = Configure JAXB project settings. + +JaxbFacetWizardPage_title = JAXB Facet +JaxbFacetWizardPage_desc = Configure JAXB settings. +JaxbFacetWizardPage_platformLabel = &Platform +JaxbFacetWizardPage_jaxbImplementationLabel = JAXB implementation + +JaxbFacetDataModel_validatePlatformNotSpecified = Platform must be specified diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java index 84d58cfb98..da2f756036 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java @@ -123,10 +123,28 @@ public class JptJaxbUiMessages { public static String SchemaGeneratorWizard_generateSchemaTask; - public static String NewSchemaFileWizardPage_errorNotJavaProject; + // new project wizard + + public static String JaxbProjectWizard_title; + + public static String JaxbProjectWizard_firstPage_title; + public static String JaxbProjectWizard_firstPage_desc; + + + // facet page + + public static String JaxbFacetWizardPage_title; + public static String JaxbFacetWizardPage_desc; + public static String JaxbFacetWizardPage_platformLabel; + public static String JaxbFacetWizardPage_jaxbImplementationLabel; + + public static String JaxbFacetDataModel_validatePlatformNotSpecified; + + + private static final String BUNDLE_NAME = "jpt_jaxb_ui"; //$NON-NLS-1$ private static final Class<?> BUNDLE_CLASS = JptJaxbUiMessages.class; static { diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java new file mode 100644 index 0000000000..54fb896f49 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.facet; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; +import org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetInstallDataModelProperties; +import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; +import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.help.IWorkbenchHelpSystem; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; +import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage; + + +public class JaxbFacetInstallPage + extends DataModelFacetInstallPage + implements JaxbFacetInstallDataModelProperties { + + public JaxbFacetInstallPage() { + super("jpt.jaxb.facet.install.page"); + setTitle(JptJaxbUiMessages.JaxbFacetWizardPage_title); + setDescription(JptJaxbUiMessages.JaxbFacetWizardPage_desc); + setImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER)); + } + + + @Override + public void setConfig(Object config) { + if (! (config instanceof IDataModel)) { + config = Platform.getAdapterManager().loadAdapter(config, IDataModel.class.getName()); + } + super.setConfig(config); + } + + @Override + protected Composite createTopLevelComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + composite.setLayout(layout); + + addSubComposites(composite); + + Dialog.applyDialogFont(parent); +// PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.DIALOG_JPA_FACET); + + return composite; + } + + protected void addSubComposites(Composite composite) { + new PlatformGroup(composite); + new ClasspathConfigGroup(composite); + } + + protected Button createButton(Composite container, int span, String text, int style) { + Button button = new Button(container, SWT.NONE | style); + button.setText(text); + GridData gd = new GridData(); + gd.horizontalSpan = span; + button.setLayoutData(gd); + return button; + } + + protected Combo createCombo(Composite container, int span, boolean fillHorizontal) { + Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); + GridData gd; + if (fillHorizontal) { + gd = new GridData(GridData.FILL_HORIZONTAL); + } + else { + gd = new GridData(); + } + gd.horizontalSpan = span; + combo.setLayoutData(gd); + return combo; + } + + @Override + protected String[] getValidationPropertyNames() { + return new String[] { + PLATFORM, + LIBRARY_INSTALL_DELEGATE + }; + } + + @Override + public boolean isPageComplete() { + if (! super.isPageComplete()) { + return false; + } + else { + IStatus status = this.model.validate(); + if (status.getSeverity() == IStatus.ERROR) { + setErrorMessage(status.getMessage()); + return false; + }; + setErrorMessage(null); + return true; + } + } + + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + setErrorMessage(); + } + } + + protected final IWorkbenchHelpSystem getHelpSystem() { + return PlatformUI.getWorkbench().getHelpSystem(); + } + + + protected final class PlatformGroup + { + private final Combo platformCombo; + + + public PlatformGroup(Composite composite) { + Group group = new Group(composite, SWT.NONE); + group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel); + group.setLayout(new GridLayout()); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_JPA_PLATFORM); + + this.platformCombo = createCombo(group, 1, true); + JaxbFacetInstallPage.this.synchHelper.synchCombo(platformCombo, PLATFORM, null); + } + } + + + protected final class ClasspathConfigGroup { + + public ClasspathConfigGroup(Composite composite) { + + LibraryInstallDelegate librariesInstallDelegate + = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_INSTALL_DELEGATE); + + Composite librariesComposite + = (Composite) LibraryProviderFrameworkUi.createInstallLibraryPanel( + composite, librariesInstallDelegate, + JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel); + librariesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// PlatformUI.getWorkbench().getHelpSystem().setHelp(librariesComposite, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH); + } + } +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallConfigToDataModelAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallConfigToDataModelAdapterFactory.java new file mode 100644 index 0000000000..de0df6270e --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallConfigToDataModelAdapterFactory.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.facet.model; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig; +import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; + +public class JaxbFacetInstallConfigToDataModelAdapterFactory + implements IAdapterFactory { + + private static final Class<?>[] ADAPTER_LIST = new Class[] { IDataModel.class }; + + public Class<?>[] getAdapterList() { + return ADAPTER_LIST; + } + + public Object getAdapter(Object adaptableObj, Class adapterType) { + if (adapterType == IDataModel.class) { + JaxbFacetInstallDataModelProvider provider + = new JaxbFacetInstallDataModelProvider((JaxbFacetInstallConfig) adaptableObj); + return DataModelFactory.createDataModel( provider ); + } + + return null; + } +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java new file mode 100644 index 0000000000..be2889ea9d --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.facet.model; + +import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; + +public interface JaxbFacetInstallDataModelProperties + extends IDataModelProperties { + + public static final String JAXB_FACET_INSTALL_CONFIG + = "JaxbFacetInstallDataModelProperties.JAVA_FACET_INSTALL_CONFIG"; //$NON-NLS-1$ + + public static final String PLATFORM + = "JaxbFacetInstallDataModelProperties.PLATFORM"; //$NON-NLS-1$ + + public static final String LIBRARY_INSTALL_DELEGATE + = "JaxbFacetInstallDataModelProperties.LIBRARY_INSTALL_DELEGATE"; //$NON-NLS-1$ +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java new file mode 100644 index 0000000000..8241fa8b3f --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java @@ -0,0 +1,308 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.facet.model; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Comparator; +import java.util.Set; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jpt.jaxb.core.JaxbFacet; +import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; +import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig; +import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; +import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; +import org.eclipse.jpt.utility.internal.ArrayTools; +import org.eclipse.jpt.utility.internal.iterables.FilteringIterable; +import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; +import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener; +import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; +import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; +import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; +import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; +import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; +import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; + +public class JaxbFacetInstallDataModelProvider + extends FacetInstallDataModelProvider + implements JaxbFacetInstallDataModelProperties { + + protected static final DataModelPropertyDescriptor[] EMPTY_DMPD_ARRAY = new DataModelPropertyDescriptor[0]; + + + protected static final Comparator<DataModelPropertyDescriptor> DMPD_COMPARATOR = + new Comparator<DataModelPropertyDescriptor>() { + public int compare(DataModelPropertyDescriptor dmpd1, DataModelPropertyDescriptor dmpd2) { + return dmpd1.getPropertyDescription().compareTo(dmpd2.getPropertyDescription()); + } + }; + + protected static IStatus buildErrorStatus(String message) { + return buildStatus(IStatus.ERROR, message); + } + + protected static IStatus buildStatus(int severity, String message) { + return new Status(severity, JptJaxbUiPlugin.PLUGIN_ID, message); + } + + + private JaxbFacetInstallConfig config; + + private PropertyChangeListener configListener; + + + public JaxbFacetInstallDataModelProvider() { + this(new JaxbFacetInstallConfig()); + } + + public JaxbFacetInstallDataModelProvider(JaxbFacetInstallConfig config) { + super(); + this.config = config; + this.configListener = buildConfigListener(); + this.config.addPropertyChangeListener(this.configListener); + } + + + protected PropertyChangeListener buildConfigListener() { + return new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals(JaxbFacetInstallConfig.FACETED_PROJECT_WORKING_COPY_PROPERTY)) { + + } + } + }; + } + + @Override + public Set getPropertyNames() { + Set names = super.getPropertyNames(); + names.add(JAXB_FACET_INSTALL_CONFIG); + names.add(PLATFORM); + names.add(LIBRARY_INSTALL_DELEGATE); + return names; + } + + @Override + public void init() { + super.init(); + getDataModel().setProperty(JAXB_FACET_INSTALL_CONFIG, this.config); + if (this.config.getPlatform() != null) { + getDataModel().setProperty(PLATFORM, this.config.getPlatform()); + } + else { + this.config.setPlatform(getDefaultPlatform()); + } + } + + @Override + public Object getDefaultProperty(String propertyName) { + if (propertyName.equals(FACET_ID)) { + return JaxbFacet.ID; + } + else if (propertyName.equals(PLATFORM)) { + return getDefaultPlatform(); + } + else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) { + // means that library install delegate has not been initialized + LibraryInstallDelegate lid = buildLibraryInstallDelegate(); + setLibraryInstallDelegate(lid); + return lid; + } + + return super.getDefaultProperty(propertyName); + } + + protected JaxbPlatformDescription getDefaultPlatform() { + return JptJaxbCorePlugin.getDefaultPlatform(getProjectFacetVersion()); + } + + protected LibraryInstallDelegate buildLibraryInstallDelegate() { + IFacetedProjectWorkingCopy fpjwc = this.getFacetedProjectWorkingCopy(); + if (fpjwc == null) { + return null; + } + IProjectFacetVersion pfv = this.getProjectFacetVersion(); + if (pfv == null) { + return null; + } + LibraryInstallDelegate lid = new LibraryInstallDelegate(fpjwc, pfv); + lid.addListener(buildLibraryInstallDelegateListener()); + return lid; + } + + protected IPropertyChangeListener buildLibraryInstallDelegateListener() { + return new IPropertyChangeListener() { + public void propertyChanged(String property, Object oldValue, Object newValue ) { + if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) { + adjustLibraryProviders(); + } + JaxbFacetInstallDataModelProvider.this.getDataModel().notifyPropertyChange( + LIBRARY_INSTALL_DELEGATE, IDataModel.VALUE_CHG); + } + }; + } + + @Override + public boolean propertySet(String propertyName, Object propertyValue) { + boolean ok = super.propertySet(propertyName, propertyValue); + + if (propertyName.equals(FACET_VERSION)) { + adjustLibraryProviders(); + this.model.notifyPropertyChange(PLATFORM, IDataModel.DEFAULT_CHG); + if (getLibraryInstallDelegate().getProjectFacetVersion().equals(getProjectFacetVersion())) { + getLibraryInstallDelegate().dispose(); + setLibraryInstallDelegate(buildLibraryInstallDelegate()); + } + } + else if (propertyName.equals(FACETED_PROJECT_WORKING_COPY)) { + getFacetedProjectWorkingCopy().addListener( + new IFacetedProjectListener() { + public void handleEvent(IFacetedProjectEvent event) { + LibraryInstallDelegate lid = getLibraryInstallDelegate(); + if (lid != null) { + // may be null while model is being built up + // ... or in tests + lid.refresh(); + } + } + }, + IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED); + } + else if (propertyName.equals(JAXB_FACET_INSTALL_CONFIG)) { + return false; + } + else if (propertyName.equals(PLATFORM)) { + this.config.setPlatform((JaxbPlatformDescription) propertyValue); + adjustLibraryProviders(); + } + else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) { + this.config.setLibraryInstallDelegate((LibraryInstallDelegate) propertyValue); + } + + return ok; + } + + @Override + public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { + if (propertyName.equals(PLATFORM)) { + return this.buildValidPlatformDescriptors(); + } + + return super.getValidPropertyDescriptors(propertyName); + } + + protected DataModelPropertyDescriptor[] buildValidPlatformDescriptors() { + Iterable<JaxbPlatformDescription> validPlatformDescriptions = buildValidPlatformDescriptions(); + Iterable<DataModelPropertyDescriptor> validPlatformDescriptors = + new TransformationIterable<JaxbPlatformDescription, DataModelPropertyDescriptor>(validPlatformDescriptions) { + @Override + protected DataModelPropertyDescriptor transform(JaxbPlatformDescription description) { + return buildPlatformDescriptor(description); + } + }; + return ArrayTools.sort(ArrayTools.array(validPlatformDescriptors, EMPTY_DMPD_ARRAY), DMPD_COMPARATOR); + } + + protected Iterable<JaxbPlatformDescription> buildValidPlatformDescriptions() { + return new FilteringIterable<JaxbPlatformDescription>( + JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatforms()) { + @Override + protected boolean accept(JaxbPlatformDescription o) { + return o.supportsJaxbFacetVersion(getProjectFacetVersion()); + } + }; + } + + @Override + public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) { + if (propertyName.equals(PLATFORM)) { + return buildPlatformDescriptor(getPlatform()); + } + + return super.getPropertyDescriptor(propertyName); + } + + protected DataModelPropertyDescriptor buildPlatformDescriptor(JaxbPlatformDescription desc) { + return new DataModelPropertyDescriptor(desc, desc.getLabel()); + } + + @Override + public IStatus validate(String propertyName) { + if (propertyName.equals(PLATFORM)) { + return validatePlatform(); + } + if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) { + return getLibraryInstallDelegate().validate(); + } + + return super.validate(propertyName); + } + + protected IStatus validatePlatform() { + return (getPlatform() == null) ? + buildErrorStatus(JptJaxbUiMessages.JaxbFacetDataModel_validatePlatformNotSpecified) + : OK_STATUS; + } + + protected IFacetedProjectWorkingCopy getFacetedProjectWorkingCopy() { + return (IFacetedProjectWorkingCopy) this.config.getFacetedProjectWorkingCopy(); + } + + protected IProjectFacetVersion getProjectFacetVersion() { + return (IProjectFacetVersion) this.config.getProjectFacetVersion(); + } + + protected JaxbPlatformDescription getPlatform() { + return (JaxbPlatformDescription) getProperty(PLATFORM); + } + + protected LibraryInstallDelegate getLibraryInstallDelegate() { + return (LibraryInstallDelegate) getProperty(LIBRARY_INSTALL_DELEGATE); + } + + protected void setLibraryInstallDelegate(LibraryInstallDelegate lid) { + getDataModel().setProperty(LIBRARY_INSTALL_DELEGATE, lid); + } + + protected void adjustLibraryProviders() { + LibraryInstallDelegate lid = getLibraryInstallDelegate(); + if (lid != null) { +// List<JpaLibraryProviderInstallOperationConfig> jpaConfigs +// = new ArrayList<JpaLibraryProviderInstallOperationConfig>(); +// // add the currently selected one first +// JpaLibraryProviderInstallOperationConfig currentJpaConfig = null; +// LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig(); +// if (config instanceof JpaLibraryProviderInstallOperationConfig) { +// currentJpaConfig = (JpaLibraryProviderInstallOperationConfig) config; +// jpaConfigs.add(currentJpaConfig); +// } +// for (ILibraryProvider lp : lid.getLibraryProviders()) { +// config = lid.getLibraryProviderOperationConfig(lp); +// if (config instanceof JpaLibraryProviderInstallOperationConfig +// && ! config.equals(currentJpaConfig)) { +// jpaConfigs.add((JpaLibraryProviderInstallOperationConfig) config); +// } +// } +// for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) { +// jpaConfig.setJpaPlatformId(getPlatformId()); +// } + } + } + + @Override + public void dispose() { + super.dispose(); + this.config.removePropertyChangeListener(this.configListener); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java new file mode 100644 index 0000000000..b5ff6a80c5 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.proj; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; +import org.eclipse.jpt.jaxb.ui.internal.wizards.proj.model.JaxbProjectCreationDataModelProvider; +import org.eclipse.jpt.ui.JptUiPlugin; +import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; +import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; +import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; + + +public class JaxbProjectWizard + extends NewProjectDataModelFacetWizard { + + public JaxbProjectWizard() { + super(); + setWindowTitle(JptJaxbUiMessages.JaxbProjectWizard_title); + } + + public JaxbProjectWizard(IDataModel dataModel) { + super(dataModel); + setWindowTitle(JptJaxbUiMessages.JaxbProjectWizard_title); + } + + + @Override + protected ImageDescriptor getDefaultPageImageDescriptor() { + return JptUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER); + } + + @Override + protected IWizardPage createFirstPage() { + return new JaxbProjectWizardFirstPage(model, "first.page"); //$NON-NLS-1$ + } + + @Override + protected IDataModel createDataModel() { + return DataModelFactory.createDataModel(new JaxbProjectCreationDataModelProvider()); + } + + @Override + protected IFacetedProjectTemplate getTemplate() { + return ProjectFacetsManager.getTemplate("jpt.jaxb.template"); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java new file mode 100644 index 0000000000..1a1ec07af8 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.proj; + +import org.eclipse.jpt.jaxb.core.JaxbFacet; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; +import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage; + + +public class JaxbProjectWizardFirstPage + extends DataModelFacetCreationWizardPage { + + public JaxbProjectWizardFirstPage(IDataModel dataModel, String pageName) { + super(dataModel, pageName); + setTitle(JptJaxbUiMessages.JaxbProjectWizard_firstPage_title); + setDescription(JptJaxbUiMessages.JaxbProjectWizard_firstPage_desc); + //setInfopopID(JpaJaxbHelpContextIds.NEW_JAXB_PROJECT); + } + + + @Override + protected Composite createTopLevelComposite(Composite parent) { + final Composite top = super.createTopLevelComposite(parent); + createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET, JAVA_WORKING_SET }); + return top; + } + +// @Override +// public boolean internalLaunchNewRuntimeWizard(Shell shell, IDataModel model) { +// IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy) model.getProperty(FACETED_PROJECT_WORKING_COPY); +// IProjectFacetVersion moduleFacet = FacetTools.getModuleFacet(fpwc); +// if (moduleFacet != null) { +// return launchNewRuntimeWizard(shell, model, moduleFacet.getProjectFacet().getId()); +// } +// else { +// return launchNewRuntimeWizard(shell, model); +// } +// } + + @Override + protected String getModuleTypeID() { + return JaxbFacet.ID; + } + + @Override + public void storeDefaultSettings() { + super.storeDefaultSettings(); + // TODO +// IDialogSettings settings = getDialogSettings(); +// if (settings != null) { +// FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); +// String facetID = getModuleFacetID(); +// IDataModel j2eeModel = map.getFacetDataModel(facetID); +// if(j2eeModel.getBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR)){ +// String lastEARName = j2eeModel.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); +// settings.put(STORE_LABEL, lastEARName); +// } +// } + } + + @Override + public void restoreDefaultSettings() { + super.restoreDefaultSettings(); + // TODO +// IDialogSettings settings = getDialogSettings(); +// if (settings != null) { +// String lastEARName = settings.get(STORE_LABEL); +// if (lastEARName != null){ +// FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); +// String facetID = getModuleFacetID(); +// IDataModel j2eeModel = map.getFacetDataModel(facetID); +// j2eeModel.setProperty(IJ2EEModuleFacetInstallDataModelProperties.LAST_EAR_NAME, lastEARName); +// } +// } + } + +// @Override +// protected IDialogSettings getDialogSettings() { +// return J2EEUIPlugin.getDefault().getDialogSettings(); +// } +} diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java new file mode 100644 index 0000000000..76747b04ab --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2010 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.wizards.proj.model; + +import java.util.ArrayList; +import java.util.Collection; +import org.eclipse.jpt.jaxb.core.JaxbFacet; +import org.eclipse.jst.common.project.facet.core.JavaFacet; +import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; +import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; +import org.eclipse.wst.common.project.facet.core.IProjectFacet; + + +public class JaxbProjectCreationDataModelProvider + extends FacetProjectCreationDataModelProvider + implements IFacetProjectCreationDataModelProperties { + + public JaxbProjectCreationDataModelProvider() { + super(); + } + + + @Override + public void init() { + super.init(); + + Collection<IProjectFacet> requiredFacets = new ArrayList<IProjectFacet>(); + requiredFacets.add(JavaFacet.FACET); + requiredFacets.add(JaxbFacet.FACET); + setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); + } +} |